/* Diasphère GED — base, layout, components, then responsive rules. */
@font-face {
  font-family: Montserrat;
  src: url('/assets/fonts/Montserrat-Bold.woff2') format('woff2');
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}
:root {
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  color: #202b40;
  background: #f3f5fa;
  --accent: #5445a5;
  --accent-soft: #eeebfa;
  --line: #e1e5ef;
  --muted: #69758a;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100vh; }
main { min-width: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.brand, h1, h2, h3 { font-family: Montserrat, "Segoe UI", Arial, sans-serif; font-weight: 700; }
h1 { margin: 6px 0; font-size: 28px; letter-spacing: -.7px; overflow-wrap: anywhere; }
h2 { margin: 0 0 12px; font-size: 18px; }
p { color: var(--muted); margin: 6px 0 14px; overflow-wrap: anywhere; }
small { color: var(--muted); }
input, select, button, textarea { font: inherit; border-radius: 7px; padding: 10px 12px; }
input, select, textarea { width: 100%; min-width: 0; background: #fff; border: 1px solid #cfd6e5; color: inherit; }
textarea { resize: vertical; }
select { appearance: none; background: #fff url('/assets/select-chevron.svg') no-repeat right 10px center / 16px; padding-right: 34px; }
input[type=checkbox] { accent-color: var(--accent); width: 17px; height: 17px; flex: none; }
input[type=file] { padding: 7px; background: #f8f7fc; }
input[type=file]::file-selector-button { font: inherit; font-weight: 650; border: 0; border-radius: 5px; background: #e6e0f6; color: #42367e; padding: 8px 12px; margin-right: 10px; cursor: pointer; }
button { background: var(--accent); color: #fff; border: 1px solid transparent; cursor: pointer; font-weight: 650; }
button:hover { filter: brightness(.94); }
button:disabled { opacity: .55; cursor: not-allowed; }
:where(button, a, input, select, textarea, summary):focus-visible { outline: 3px solid #a69bef; outline-offset: 3px; }
label { display: grid; gap: 7px; margin: 0 0 16px; font-weight: 600; }
fieldset { min-width: 0; border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
legend { padding: 0 6px; }
.rail { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 25px 16px; gap: 25px; color: #fff; background: linear-gradient(155deg, #292644, #181c30 65%); overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 6px; font-weight: 800; letter-spacing: 1.4px; }
.brand small { display: block; color: #b9b8d5; font-size: 10px; font-weight: 500; letter-spacing: 0; margin-top: 3px; }
.mark { width: 39px; height: 39px; flex: none; display: grid; place-items: center; border: 2px solid #bcb2f5; border-radius: 50%; font-size: 25px; }
.rail nav { display: grid; gap: 3px; }
.rail nav small { font-size: 10px; letter-spacing: 1px; color: #a6a4c5; padding: 10px 12px 4px; }
.rail nav a { display: flex; align-items: center; gap: 12px; color: #dadbed; padding: 9px 12px; min-height: 36px; border-radius: 7px; font-weight: 550; }
.rail nav a:hover { background: #ffffff12; text-decoration: none; }
.rail nav a.active { background: #7564bd45; box-shadow: inset 3px 0 #b0a1ff; color: #fff; }
.nav-icon { width: 19px; height: 19px; flex: none; }
.logout { margin-top: auto; }
.logout button { width: 100%; background: #ffffff12; border: 1px solid #ffffff20; text-align: left; }
main > header { min-height: 64px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 30px; }
main > header strong { font-size: 16px; }
.top-tag { font-size: 12px; color: var(--muted); }
.reading-alert { flex: none; }
main > section { padding: 28px 30px; max-width: 1800px; margin: auto; }
.intro, .dashboard-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.intro p { margin-bottom: 0; }
.eyebrow { font-size: 10px; letter-spacing: 1.6px; color: #7164a8; font-weight: 750; }
.summary { display: flex; gap: 12px; }
.summary > div { min-width: 110px; background: linear-gradient(135deg, #fff, #eeebfa); border: 1px solid var(--line); border-radius: 11px; padding: 12px 18px; }
.summary b { display: block; font-size: 26px; color: var(--accent); margin-top: 4px; }
.panel { min-width: 0; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 4px 16px #28375a07; padding: 20px; }
.document-content > .panel + .panel, main > section > .panel + .panel { margin-top: 16px; }
.toolbar, .bar { display: flex; align-items: center; gap: 12px; justify-content: space-between; flex-wrap: wrap; margin-bottom: 16px; }
.bar h2 { margin: 0; }
.bar strong { font-size: 15px; }
.form-actions, .viewer-actions, .quick-links { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.form-actions > *, .viewer-actions > * { flex: 0 0 auto; }
.action-link, .preview-link, .viewer-actions a, .toolbar > a, .quick-links a { display: inline-flex; align-items: center; gap: 7px; padding: 9px 12px; border-radius: 7px; background: var(--accent-soft); color: #50428f; font-weight: 650; text-decoration: none; }
.action-link:hover, .preview-link:hover, .viewer-actions a:hover, .quick-links a:hover { background: #e2dcf6; text-decoration: none; }
.subtle, .search-button { background: var(--accent-soft); color: #50428f; border: 1px solid #e3def5; }
.library-heading { display: grid; grid-template-columns: minmax(0,1fr) auto; margin-bottom: 20px; }
.library-heading h1 { margin-top: 0; }
.library-heading p { font-size: 13px; }
.library-heading p span { padding: 0 8px; }
.library-tools { margin: 0 0 18px; padding: 0 0 16px; border-bottom: 1px solid var(--line); }
.library-search-row { display: flex; align-items: center; gap: 12px; }
.library-search { display: flex; flex: 1; min-width: 0; border: 1px solid #cfd6e5; border-radius: 7px; overflow: hidden; }
.library-search input { border: 0; background: #f9fafc; border-radius: 0; }
.library-search button { border: 0; border-left: 1px solid var(--line); border-radius: 0; display: grid; place-items: center; padding: 10px 12px; }
.library-search svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.7; }
.library-sort { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 13px; color: var(--muted); }
.library-sort select { width: 166px; color: #202b40; }
.library-filters { margin-top: 10px; }
.library-filters summary { padding: 2px 0; font-size: 13px; }
.library-filter-fields { display: grid; grid-template-columns: minmax(140px,1fr) minmax(140px,1fr) auto; gap: 14px; align-items: end; padding-top: 12px; }
.library-filter-fields label { font-size: 13px; margin: 0; }
.library-filter-fields > a { padding-bottom: 11px; font-size: 13px; }
.workspace { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 18px; align-items: start; }
.library-workspace { gap: 0; align-items: stretch; background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; min-height: 480px; }
.library-workspace > .panel { border: 0; border-radius: 0; box-shadow: none; }
.library-workspace > .folders { border-right: 1px solid var(--line); background: #fafbfe; }
.listing-heading { margin-bottom: 8px; }
.library-empty { padding: 54px 20px; }
.empty-document { width: 64px; height: 64px; stroke: #8c80ba; stroke-width: 1.6; margin-bottom: 8px; }
.library-empty p { max-width: 440px; margin: 0 auto; font-size: 14px; line-height: 1.6; }
.workspace:has(> .listing:first-child) { grid-template-columns: minmax(0, 1fr); }
.folders a { display: flex; gap: 10px; align-items: center; padding: 10px 8px; margin-top: 5px; color: #48546a; overflow-wrap: anywhere; border-radius: 6px; }
.folders a.selected { background: var(--accent-soft); color: #514395; font-weight: 700; }
.folders a:hover { text-decoration: none; background: #f5f3fa; }
.folders .bar { flex-wrap: nowrap; }
.folders .bar strong { flex: 1; }
.folders .bar button { display: grid; place-items: center; flex: none; width: 34px; height: 34px; padding: 6px; }
.folder-icon { color: #7967b7; width: 19px; height: 19px; flex: none; }
.table-scroll, .revision-table { max-width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { background: #f4f5fa; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: #64718a; }
td, th { padding: 13px 10px; border-bottom: 1px solid #edf0f5; overflow-wrap: anywhere; vertical-align: middle; }
td small { display: block; margin-top: 4px; }
td a { font-weight: 600; }
tr:hover td { background: #faf9fd; }
td:last-child a { display: inline-flex; margin: 3px 4px 3px 0; }
.file-cell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.file-cell > div { min-width: 180px; }
.listing th { white-space: nowrap; }
.listing td:nth-child(2) { white-space: nowrap; }
.listing td:nth-child(4) { min-width: 100px; overflow-wrap: normal; }
.file-icon { flex: none; display: grid; place-items: center; width: 40px; height: 46px; background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: 10px; border-radius: 7px; }
.pagination { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; padding-top: 18px; color: var(--muted); font-size: 13px; }
.empty { text-align: center; padding: 28px 12px; }
.empty h2 { margin: 12px 0 8px; }
.empty button, .compact-empty .action-link { margin-top: 16px; }
.empty-art { width: 86px; height: 64px; margin: 0 auto 15px; background: var(--accent-soft); border: 2px solid #b9aee9; border-radius: 10px; }
.empty-icon { width: 44px; height: 44px; padding: 8px; border-radius: 12px; background: var(--accent-soft); color: #7967b7; }
dialog { border: 1px solid var(--line); border-radius: 14px; width: min(580px, 94vw); max-height: 90vh; overflow-y: auto; padding: 24px; color: inherit; box-shadow: 0 25px 80px #171b4350; }
dialog::backdrop { background: #17243c88; }
.login { max-width: 420px; margin: 40px auto; }
.error { color: #9e2525; background: #fff1f1; padding: 14px; border-radius: 8px; }
.document-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px; margin-bottom: 20px; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.document-tabs a { padding: 11px 15px; border-radius: 7px; color: #48546a; font-weight: 650; }
.document-tabs a[aria-current=page] { background: var(--accent-soft); color: var(--accent); }
.document-tabs a:hover { background: #f5f3fa; text-decoration: none; }
.document-content { min-width: 0; }
.document-metadata form, .account-panel form, .circuit-list form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.document-metadata label, .account-panel form label, .circuit-list form label { margin: 0; }
.document-metadata label:has(textarea), .document-metadata form p, .document-metadata .form-actions, .account-panel fieldset, .account-panel .account-check, .circuit-list form button { grid-column: 1 / -1; }
.account-panel form button, .circuit-list form button { justify-self: start; }
.metadata-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin: 0; }
.metadata-grid dt { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.metadata-grid dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.metadata-grid .full-width { grid-column: 1 / -1; }
.revision-state { display: block; color: var(--muted); overflow-wrap: anywhere; }
.count-chip, .state-chip { display: inline-flex; align-items: center; padding: 5px 10px; border-radius: 7px; background: var(--accent-soft); color: #50428f; font-size: 12px; font-weight: 650; white-space: nowrap; }
.state-ok { background: #e2f2eb; color: #20644e; }
.state-pending { background: #fff0d9; color: #865519; }
.account-panel { margin-top: 16px; max-width: 1000px; }
.account-check, .choice-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; margin: 0; }
.choice-row { border-bottom: 1px solid var(--line); }
.recipient-list { margin: 12px 0; max-height: 260px; overflow-y: auto; }
.record-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); padding: 12px 0; }
.date-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 16px 0; }
.date-grid > div { background: #f5f4fa; border-radius: 8px; padding: 14px; }
.date-grid strong { display: block; margin-top: 5px; }
details summary { cursor: pointer; color: var(--accent); font-weight: 650; padding: 12px 0; }
.decision-box { border: 1px solid var(--line); border-radius: 8px; padding: 0 14px 14px; margin: 16px 0; }
.circuit-list { display: grid; gap: 14px; }
.circuit-list .panel { margin: 0; }
.circuit-list summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; list-style: none; padding: 0; color: #202b40; }
.circuit-list summary::-webkit-details-marker { display: none; }
.circuit-list summary::after { content: '+'; color: var(--accent); font-size: 22px; }
.circuit-list details[open] summary::after { content: '−'; }
.circuit-list summary .state-chip { margin-left: auto; }
.circuit-list form { margin-top: 18px; }
.comment-entry { padding: 14px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.comment-entry:last-child { border-bottom: 0; }
.comment-entry p { white-space: pre-wrap; margin: 8px 0 0; }
.dashboard-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 7px; padding: 16px 18px; border: 1px solid #e0dced; border-radius: 12px; background: linear-gradient(135deg, #fff, #f0ecfc); color: #403579; min-width: 0; }
.metric-icon { grid-column: 2; grid-row: 1 / 3; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 11px; background: #e6dff9; }
.metric-label { grid-column: 1; grid-row: 1; font-weight: 650; font-size: 13px; }
.metric strong { grid-column: 1; grid-row: 2; font-size: 29px; line-height: 1.1; }
.metric-foot { grid-column: 1 / -1; font-size: 12px; color: #61567e; }
.metric-types { background: linear-gradient(135deg, #fff, #eaf1fb); color: #36547e; }
.metric-types .metric-icon { background: #dce7f8; }
.metric-deadlines { background: linear-gradient(135deg, #fff, #fff1dc); color: #865519; }
.metric-deadlines .metric-icon { background: #f8e5c4; }
.metric-my-documents { background: linear-gradient(135deg, #fff, #e7f4ef); color: #256b58; }
.metric-my-documents .metric-icon { background: #d5eee4; }
.metric:hover { border-color: currentColor; text-decoration: none; }
.dashboard-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 24px; }
.dashboard-actions > .panel { margin: 0; }
.section-title { margin: 0 0 12px; }
.viewer-body { display: flex; flex-direction: column; min-height: 100vh; background: #eef0f6; }
.viewer-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 20px 30px; background: #fff; border-bottom: 1px solid var(--line); }
.viewer-header h1 { font-size: 21px; }
.viewer-header p { margin: 0; }
.viewer-surface { flex: 1; min-height: 70vh; margin: 16px; padding: 16px; background: #fff; border: 1px solid var(--line); border-radius: 12px; display: grid; place-items: center; overflow: auto; }
.viewer-surface iframe { width: 100%; height: 78vh; border: 0; }
.viewer-surface img { max-width: 100%; max-height: 78vh; object-fit: contain; }
.viewer-surface pre { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 100%; width: 100%; align-self: start; margin: 0; }
/* Metadata template workspace */
.model-search { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 12px; margin-bottom: 20px; }
.model-actions { display: flex; align-items: center; gap: 16px; flex-wrap: nowrap; white-space: nowrap; }
.model-table td:last-child a { margin: 0; }
.model-dialog { width: min(680px,94vw); }
.model-form { display: grid; gap: 20px; }
.model-form > .bar, .model-form p { margin: 0; }
.model-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; }
.model-fields label { margin: 0; }
.model-fields .full-width { grid-column: 1 / -1; }
@media (max-width: 1200px) {
  body { grid-template-columns: 220px minmax(0, 1fr); }
  main > section { padding: 22px; }
  .workspace { grid-template-columns: 200px minmax(0, 1fr); }
  .library-sort span { display: none; }
  .dashboard-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .file-icon { display: none; }
}
@media (max-width: 760px) {
  body { display: block; }
  .rail { position: relative; height: auto; padding: 16px; gap: 16px; }
  .rail nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
  .rail nav small { display: none; }
  .rail nav a { padding: 8px; }
  .logout { margin: 0; }
  .logout button { width: auto; }
  main > header { padding: 12px 16px; }
  main > section { padding: 16px; }
  .intro, .dashboard-heading, .viewer-header, .record-row { flex-wrap: wrap; }
  .workspace, .dashboard-actions { grid-template-columns: minmax(0, 1fr); }
  .library-workspace > .folders { border-right: 0; border-bottom: 1px solid var(--line); }
  .model-fields { grid-template-columns: minmax(0,1fr); }
  .library-heading { grid-template-columns: minmax(0,1fr); }
  .library-heading > button { width: 100%; }
  .library-search-row { display: grid; grid-template-columns: minmax(0,1fr) auto; }
  .library-search { grid-column: 1 / -1; }
  .library-sort { min-width: 0; }
  .library-sort select { width: 100%; }
  .library-filter-fields { grid-template-columns: minmax(0,1fr); }
  .library-empty { padding: 30px 8px; }
  .document-metadata form, .account-panel form, .circuit-list form, .metadata-grid { grid-template-columns: minmax(0, 1fr); }
  .summary { width: 100%; }
  .summary > div { flex: 1; }
  .table-scroll table, .revision-table table { min-width: 540px; }
  .document-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .document-tabs a { padding: 10px 12px; }
  .document-tabs a:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .viewer-header { padding: 16px; }
}
@media (max-width: 480px) {
  .date-grid { grid-template-columns: minmax(0, 1fr); }
  h1 { font-size: 24px; }
  .dashboard-summary { grid-template-columns: minmax(0, 1fr); }
  .top-tag { display: none; }
  .panel { padding: 16px; }
}
