/* GGN — the one stylesheet.

   What this is for: accountants sit in this all day, comparing a scanned
   document against the figures read from it. So the design is quiet on
   purpose. Surfaces are flat and divided by rules rather than boxed into
   cards; the only dark, heavy thing on a page is the document itself; and
   colour is spent on state, where it carries information.

   Colour means one thing each: amber wants a person, green is settled, red
   failed, grey is waiting. Blue is only ever "you can act on this".

   Light and dark are the same design with the tokens swapped; nothing below
   the token block names a colour. Every text/background pair clears 4.5:1 —
   check it when adding a token. */

@font-face { font-family:"IBM Plex Sans"; font-weight:400; font-display:swap;
             src:url("fonts/IBMPlexSans-Regular.woff2") format("woff2"); }
@font-face { font-family:"IBM Plex Sans"; font-weight:500; font-display:swap;
             src:url("fonts/IBMPlexSans-Medium.woff2") format("woff2"); }
@font-face { font-family:"IBM Plex Sans"; font-weight:600; font-display:swap;
             src:url("fonts/IBMPlexSans-SemiBold.woff2") format("woff2"); }

:root {
  color-scheme:light dark;
  --paper:#ffffff; --ground:#f2f4f7; --raised:#ffffff;
  --ink:#141a24; --ink-2:#4a5567; --rule:#d5dae1; --rule-soft:#e8ebef;
  --field:#8791a1; --hover:#f3f5f8; --selected:#e7eefc;
  --accent:#1b4fd1; --accent-strong:#163fa8; --accent-soft:#e7eefc;
  --on-accent:#ffffff; --link:#1746b8;
  --ok:#166534; --ok-soft:#e2f2e7;
  --warn:#8a4b08; --warn-soft:#fcf1dc;
  --err:#b3261e; --err-soft:#fcebe9;
  --idle:#4a5567; --idle-soft:#eaedf1;
  --side:#121926; --side-ink:#b9c2cf; --side-strong:#ffffff;
  --side-hover:#1c2535; --side-active:#263249; --side-rule:#232d3f;
  --desk:#0e1218;                       /* behind a document, in both themes */
  --desk-danger:#ff9d94;                /* destructive action on the desk bar */
  --alarm:#c4322a;                      /* a count of overdue things, on the rail */
  --r:6px; --bar:3.5rem; --side-w:14rem;
  --lift:0 8px 28px rgba(15,23,42,.16);
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper:#161b24; --ground:#0f131a; --raised:#1c222d;
    --ink:#e7eaef; --ink-2:#a5afbd; --rule:#2b3342; --rule-soft:#222936;
    --field:#667286; --hover:#1d2430; --selected:#1c2a4a;
    --accent:#2f62e6; --accent-strong:#4674ee; --accent-soft:#1c2a4a;
    --on-accent:#ffffff; --link:#8fb0ff;
    --ok:#7fd49d; --ok-soft:#14301f;
    --warn:#f0b866; --warn-soft:#3a2a0e;
    --err:#ff9d93; --err-soft:#3d1614;
    --idle:#a5afbd; --idle-soft:#232a36;
    --side:#0b0e14; --side-ink:#a5afbd; --side-strong:#ffffff;
    --side-hover:#161b24; --side-active:#1f2735; --side-rule:#1a202b;
    --alarm:#c4322a;
    --lift:0 8px 28px rgba(0,0,0,.5);
  }
}

* { box-sizing:border-box; }
/* Author rules like `.tree a { display:flex }` outrank the UA stylesheet's
   [hidden] rule, so a filter's hidden items would stay on screen. */
[hidden] { display:none !important; }
html { height:100%; }
body { margin:0; min-height:100%; color:var(--ink); background:var(--ground);
       font:400 .92rem/1.5 "IBM Plex Sans", system-ui, -apple-system,
            "Segoe UI", Roboto, sans-serif;
       -webkit-font-smoothing:antialiased; }
a { color:var(--link); }
h1, h2, h3 { font-weight:600; line-height:1.3; margin:0; }
h1 { font-size:1.2rem; letter-spacing:-.01em; }
h2 { font-size:1rem; margin:1.75rem 0 .75rem; }
h3 { font-size:.92rem; margin:1.25rem 0 .5rem; }
p { margin:.6rem 0; }
code { font-size:.9em; background:var(--idle-soft); padding:.05rem .3rem;
       border-radius:4px; }
.muted { color:var(--ink-2); font-size:.86rem; }
.num, td.num, th.num { font-variant-numeric:tabular-nums; }
td.num, td.amount { white-space:nowrap; }
:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }

/* ---- the shell: navigation rail, then the page ------------------------- */
body.shell { display:grid; grid-template-columns:var(--side-w) minmax(0, 1fr); }
.side { position:sticky; top:0; height:100vh; display:flex; flex-direction:column;
        background:var(--side); color:var(--side-ink); padding:.75rem .6rem; }
.brand { display:flex; align-items:center; gap:.55rem; padding:.5rem .6rem 1rem;
         color:var(--side-strong); text-decoration:none; font-weight:600;
         font-size:1.05rem; letter-spacing:.03em; }
.brand-mark { width:1.4rem; height:1.4rem; border-radius:5px; background:var(--accent);
              display:grid; place-items:center; color:#fff; font-size:.8rem; }
.side nav { display:flex; flex-direction:column; gap:.1rem; flex:1; }
.side nav a { display:flex; align-items:center; justify-content:space-between;
              gap:.5rem; padding:.45rem .6rem; border-radius:var(--r);
              color:var(--side-ink); text-decoration:none; font-weight:500; }
.side nav a:hover { background:var(--side-hover); color:var(--side-strong); }
.side nav a.active { background:var(--side-active); color:var(--side-strong); }
.navcount { min-width:1.35rem; padding:0 .35rem; border-radius:99px;
            background:var(--accent); color:#fff; font-size:.74rem;
            font-weight:600; line-height:1.35rem; text-align:center;
            font-variant-numeric:tabular-nums; }
.navcount.alarm { background:var(--alarm); }
.side-foot { border-top:1px solid var(--side-rule); padding:.75rem .6rem 0;
             display:grid; gap:.5rem; font-size:.84rem; }
.whoami { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.side-foot .row { display:flex; align-items:center; justify-content:space-between; gap:.5rem; }
.lang a { color:var(--side-ink); text-decoration:none; font-weight:500;
          padding:.1rem .3rem; border-radius:4px; }
.lang a:hover, .lang a.active { color:var(--side-strong); }
.lang a.active { background:var(--side-active); }
.side-foot button { background:none; border:0; color:var(--side-ink); padding:.1rem .3rem;
                    height:auto; min-height:0; font-weight:500; font-size:.84rem; }
.side-foot button:hover { background:none; color:var(--side-strong); text-decoration:underline; }

.main { min-width:0; display:flex; flex-direction:column; min-height:100vh; }
.pagebar { position:sticky; top:0; z-index:5; height:var(--bar); flex:none;
           display:flex; align-items:center; gap:1rem; padding:0 1.5rem;
           background:var(--paper); border-bottom:1px solid var(--rule); }
.pagebar h1 { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.pagebar .sub { color:var(--ink-2); font-size:.88rem; white-space:nowrap; }
.pagebar .actions { margin-left:auto; display:flex; align-items:center; gap:.6rem; }
.page { padding:1.5rem; flex:1; }
.page.narrow { max-width:46rem; }
.page.flush { padding:0; display:flex; flex-direction:column; }
.flashes { padding:1rem 1.5rem 0; }
.page > .flashes { padding:0; }
footer { color:var(--ink-2); font-size:.76rem; padding:.75rem 1.5rem 1rem; }
.page.flush + footer { display:none; }

/* Pages with nobody signed in: one box, centred. */
body.bare { display:grid; place-items:center; padding:1.5rem; }
.authbox { width:min(24rem, 100%); background:var(--paper); border:1px solid var(--rule);
           border-radius:10px; padding:1.75rem; }
.authbox .brand { color:var(--ink); padding:0 0 1.25rem; }
.authbox h1 { margin-bottom:1rem; }
.authbox form > p { margin:0 0 .9rem; }
.authbox .lang { display:block; margin-top:1.25rem; }
.authbox .lang a { color:var(--ink-2); }
.authbox .lang a.active { background:var(--idle-soft); color:var(--ink); }

/* ---- surfaces ---------------------------------------------------------- */
/* A section is a titled block on the page, separated by space. A card is
   reserved for a thing that is genuinely an object: a form, a dialog. */
.card { background:var(--paper); border:1px solid var(--rule); border-radius:8px;
        padding:1.25rem; margin-bottom:1.25rem; }
.card > :first-child, .card > h3:first-of-type, .card > form > h3:first-of-type { margin-top:0; }
.card > :last-child { margin-bottom:0; }
.card.table { padding:0; overflow:auto; }
.grid2 { display:grid; grid-template-columns:1fr 1fr; gap:1.25rem; }
.fields { display:grid; grid-template-columns:repeat(2, minmax(0, 1fr)); gap:.8rem 1rem; }
.fields.four { grid-template-columns:repeat(4, minmax(0, 1fr)); }
.fields > * { margin:0; min-width:0; }
.fields > .wide { grid-column:1 / -1; }
.stack > * + * { margin-top:.9rem; }
.rowline { display:flex; align-items:center; gap:.6rem; flex-wrap:wrap; }
.empty { color:var(--ink-2); padding:3rem 1rem; text-align:center; }
hr { border:0; border-top:1px solid var(--rule-soft); margin:1.25rem 0; }

/* ---- tables ------------------------------------------------------------ */
table { width:100%; border-collapse:collapse; }
th, td { text-align:left; padding:.6rem .9rem; border-bottom:1px solid var(--rule-soft);
         vertical-align:middle; }
th { font-size:.82rem; font-weight:500; color:var(--ink-2); white-space:nowrap;
     border-bottom-color:var(--rule); background:var(--paper); }
tbody tr:last-child td { border-bottom:0; }
tbody tr:hover td { background:var(--hover); }
td.amount, th.amount, input.amount { text-align:right; font-variant-numeric:tabular-nums; }
a.row-link { color:var(--link); text-decoration:none; font-weight:500; }
a.row-link:hover { text-decoration:underline; }
/* The actions at the end of a table row. */
.rowacts { display:flex; gap:1rem; justify-content:flex-end; white-space:nowrap; }
.doc-what { display:block; font-weight:500; }
.doc-file { display:block; color:var(--ink-2); font-size:.8rem; word-break:break-all; }

/* ---- state ------------------------------------------------------------- */
.badge { display:inline-flex; align-items:center; gap:.35rem; padding:.1rem .55rem;
         border-radius:99px; font-size:.78rem; font-weight:500; line-height:1.5;
         white-space:nowrap; vertical-align:middle;
         background:var(--idle-soft); color:var(--idle); }
.badge::before { content:""; width:.42rem; height:.42rem; border-radius:99px;
                 background:currentColor; }
.badge.extracted, .badge.prio-medium, .badge.doing { background:var(--warn-soft); color:var(--warn); }
.badge.approved, .badge.qr, .badge.done { background:var(--ok-soft); color:var(--ok); }
.badge.failed, .badge.prio-high { background:var(--err-soft); color:var(--err); }
.dot { width:.5rem; height:.5rem; border-radius:99px; background:var(--idle);
       display:inline-block; flex:none; }
.dot.extracted { background:var(--warn); }
.dot.approved { background:var(--ok); }
.dot.failed { background:var(--err); }

.flash, .warnbox, .notebox { padding:.65rem .9rem; border-radius:var(--r);
        margin:0 0 1rem; border:1px solid transparent; word-break:break-word; }
.flash.ok { background:var(--ok-soft); color:var(--ok); }
.flash.error { background:var(--err-soft); color:var(--err); }
.warnbox { background:var(--warn-soft); color:var(--warn); }
/* The same notes once a document is approved: for the record, not a prompt
   to act, so they are drawn as plain information. */
.notebox { background:var(--idle-soft); color:var(--ink); }
.warnbox ul, .notebox ul { margin:.3rem 0 0; padding-left:1.1rem; }
.warnbox .muted { color:inherit; opacity:.85; }

/* ---- controls ---------------------------------------------------------- */
form.inline { display:inline; }
label { display:block; font-size:.84rem; font-weight:500; margin-bottom:.3rem; }
input[type=text], input[type=password], input[type=email], input[type=search],
input[type=date], select, textarea {
  width:100%; height:2.35rem; padding:0 .65rem; font:inherit; color:var(--ink);
  background:var(--paper); border:1px solid var(--field); border-radius:var(--r); }
select[size], select[multiple] { height:auto; padding:.25rem; }
textarea { height:auto; padding:.5rem .65rem; resize:vertical; line-height:1.45; }
textarea:focus-visible { outline-offset:0; border-color:var(--accent); }
/* A tick box or radio with its wording beside it, not above. */
label.check { display:flex; align-items:baseline; gap:.5rem; font-weight:400;
              font-size:inherit; margin:.2rem 0; cursor:pointer; }
label.check input { flex:none; width:auto; }
fieldset { border:1px solid var(--rule); border-radius:var(--r); margin:0;
           padding:.5rem .8rem .6rem; min-width:0; }
legend { font-size:.84rem; font-weight:500; padding:0 .3rem; }
input::placeholder { color:var(--ink-2); opacity:.85; }
input:focus-visible, select:focus-visible { outline-offset:0; border-color:var(--accent); }
button, .btn { display:inline-flex; align-items:center; justify-content:center;
  gap:.4rem; height:2.35rem; padding:0 1rem; font:inherit; font-weight:500;
  border-radius:var(--r); cursor:pointer; text-decoration:none; white-space:nowrap;
  background:var(--accent); color:var(--on-accent); border:1px solid var(--accent); }
button:hover, .btn:hover { background:var(--accent-strong); border-color:var(--accent-strong); }
button.secondary, .btn.secondary { background:var(--paper); color:var(--ink);
  border-color:var(--field); }
button.secondary:hover, .btn.secondary:hover { background:var(--hover); border-color:var(--ink-2); }
button.danger { background:var(--paper); color:var(--err); border-color:var(--err); }
button.danger:hover { background:var(--err-soft); }
button:disabled { opacity:.5; cursor:not-allowed; }
button.small, .btn.small { height:1.9rem; padding:0 .65rem; font-size:.86rem; }
input[type=file] { font:inherit; font-size:.88rem; color:var(--ink-2); max-width:100%; }
input[type=file]::file-selector-button { font:inherit; font-weight:500; cursor:pointer;
  height:2.1rem; padding:0 .8rem; margin-right:.7rem; border-radius:var(--r);
  background:var(--paper); color:var(--ink); border:1px solid var(--field); }
input[type=checkbox] { accent-color:var(--accent); }

/* A row of choices where exactly one is on: status filters, categories. */
.chips { display:flex; flex-wrap:wrap; gap:.35rem; margin:0 0 1rem; padding:0; align-items:center; }
.chip { display:inline-flex; align-items:center; height:1.9rem; padding:0 .7rem;
        border-radius:99px; border:1px solid var(--rule); background:var(--paper);
        color:var(--ink); text-decoration:none; font-size:.86rem; font-weight:500; }
.chip:hover { border-color:var(--ink-2); }
.chip.active { background:var(--ink); border-color:var(--ink); color:var(--paper); }

input.filterbox { padding-left:2rem; background-repeat:no-repeat;
  background-position:.6rem center; background-size:.9rem;
  background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a8594' stroke-width='2.2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.6-3.6'/%3E%3C/svg%3E"); }
.filter-empty { color:var(--ink-2); font-size:.86rem; padding:.4rem .55rem; }

/* ---- the client picker ------------------------------------------------- */
/* Every control that chooses a client is this one: type a name or a NIF,
   pick from what matches. app.js builds it over an ordinary <select>, which
   stays in the form as the value and is what works with scripts off. */
.combo { position:relative; }
input.combo-input { padding-right:2rem; background-repeat:no-repeat;
  background-position:right .6rem center; background-size:.8rem;
  background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a8594' stroke-width='2.6'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); }
input.combo-input.unset { color:var(--err); }
.combo-list { position:absolute; z-index:20; top:calc(100% + 4px); left:0; right:0;
  max-height:16rem; overflow:auto; margin:0; padding:.25rem; list-style:none;
  background:var(--raised); border:1px solid var(--rule); border-radius:8px;
  box-shadow:var(--lift); }
.combo-list li { display:flex; justify-content:space-between; gap:1rem;
  padding:.4rem .55rem; border-radius:5px; cursor:pointer; }
.combo-list li .sub { color:var(--ink-2); font-variant-numeric:tabular-nums; white-space:nowrap; }
.combo-list li.active { background:var(--selected); }
.combo-list li[aria-selected=true] { font-weight:500; }
.combo-list li.combo-empty { color:var(--ink-2); cursor:default; }

/* ---- split pages: a filter column beside the content -------------------- */
.split { display:grid; grid-template-columns:15.5rem minmax(0, 1fr); flex:1; min-height:0; }
.split > aside { border-right:1px solid var(--rule); background:var(--paper);
                 padding:1rem .75rem; position:sticky; top:var(--bar);
                 height:calc(100vh - var(--bar)); overflow:auto; }
.split > section { padding:1.25rem 1.5rem 2rem; min-width:0; }
.tree h3 { margin:1.1rem .55rem .35rem; font-size:.82rem; font-weight:500; color:var(--ink-2); }
.tree h3:first-child { margin-top:0; }
.tree a { display:flex; justify-content:space-between; align-items:baseline; gap:.5rem;
          padding:.32rem .55rem; border-radius:var(--r); color:var(--ink);
          text-decoration:none; }
.tree a:hover { background:var(--hover); }
.tree a.active { background:var(--selected); font-weight:500; }
.tree a .n { color:var(--ink-2); font-size:.8rem; font-variant-numeric:tabular-nums; }
.tree .scroll { max-height:17rem; overflow-y:auto; }
.tree .filterbox { margin:.35rem 0 .3rem; }
.months { display:grid; grid-template-columns:1fr 1fr; gap:.15rem; }
.months a { justify-content:center; text-transform:capitalize; }

.toolbar { display:flex; flex-wrap:wrap; align-items:flex-end; gap:.75rem; margin:0 0 1rem; }
.toolbar > * { margin:0; }
.toolbar .grow { flex:1 1 14rem; }
.toolbar .fixed { flex:0 1 10rem; }
.toolbar .push { margin-left:auto; }
.crumbs { display:flex; flex-wrap:wrap; align-items:center; gap:.4rem; margin:0; }
.crumbs a { color:var(--link); text-decoration:none; }
.crumbs a:hover { text-decoration:underline; }
.crumbs .sep { color:var(--ink-2); }
.crumbs .here { font-weight:600; }

/* The same tree beside content that is not full-bleed (the client portal). */
.browser { display:grid; grid-template-columns:13rem minmax(0, 1fr); gap:1.5rem; align-items:start; }
.browser > .tree { position:sticky; top:calc(var(--bar) + 1rem); }

/* An area that opens in place: the upload box, an answer to a request. */
details.fold > summary { list-style:none; cursor:pointer; }
details.fold > summary::-webkit-details-marker { display:none; }
details.fold[open] > summary.btn { background:var(--hover); }
.foldbody { margin:0 0 1.25rem; padding:1rem; background:var(--paper);
            border:1px solid var(--rule); border-radius:8px; }

/* ---- document tiles ---------------------------------------------------- */
.mosaic { display:grid; gap:1rem; grid-template-columns:repeat(auto-fill, minmax(11rem, 1fr)); }
.tile { display:flex; flex-direction:column; text-decoration:none; color:var(--ink);
        border:1px solid var(--rule); border-radius:8px; background:var(--paper);
        overflow:hidden; }
.tile:hover { border-color:var(--accent); }
.tile-thumb { position:relative; display:block; aspect-ratio:3/4; background:var(--idle-soft);
              overflow:hidden; border-bottom:1px solid var(--rule-soft); }
/* top-anchored: an invoice is identified by its header, not its footer */
.tile-thumb img { width:100%; height:100%; object-fit:cover; object-position:top center; display:block; }
.tile-blank { position:absolute; inset:0; display:grid; place-items:center;
              color:var(--ink-2); font-weight:600; }
.tile-status { position:absolute; top:.45rem; left:.45rem; }
.tile-meta { padding:.6rem .7rem .7rem; display:grid; gap:.1rem; }
.tile-name { font-weight:500; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.tile-sub { font-size:.82rem; color:var(--ink-2); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.tile-total { font-weight:500; font-variant-numeric:tabular-nums; }

/* ---- the document on its desk ------------------------------------------ */
.desk { display:flex; flex-direction:column; min-height:0; background:var(--desk); color:#c5cdd9; }
.desk-bar { display:flex; align-items:center; gap:.75rem; padding:.45rem .9rem;
            font-size:.84rem; border-bottom:1px solid #1d2430; flex:none; }
.desk-bar .name { flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.desk-bar a, .desk-bar button { color:#fff; background:none; border:0; padding:.15rem .4rem;
            height:auto; font:inherit; font-weight:500; text-decoration:none;
            border-radius:4px; cursor:pointer; }
.desk-bar a:hover, .desk-bar button:hover { background:#1d2430; }
.desk-bar form { display:contents; }
.desk-bar button.danger-link { color:var(--desk-danger); }
/* The whole document fits the pane, whatever its shape: a till receipt
   photographed on a phone is thousands of pixels tall, and fitting only its
   width made it fill the screen several times over. */
.desk-body { flex:1; min-height:0; overflow:auto; padding:1.25rem;
             display:flex; align-items:center; justify-content:center; }
.desk-body img { max-width:100%; max-height:100%; object-fit:contain; background:#fff;
                 cursor:zoom-in; box-shadow:0 2px 14px rgba(0,0,0,.45); }
/* Zoomed, for reading small print: the pane's full width, and scroll. Not a
   flex box any more — centring one would put the top of a tall image out of
   reach of the scrollbar. */
.desk-body.zoomed { display:block; text-align:center; }
.desk-body.zoomed img { max-height:none; cursor:zoom-out; }
.desk-body.pdf { padding:0; display:block; }
.desk-body object, .desk-body iframe { width:100%; height:100%; border:0; display:block; }

/* ---- triage: queue, document, what was read ----------------------------- */
/* The page is pinned to the viewport so the three panes scroll, not it. */
.main:has(> .page.flush > .inbox) { height:100vh; min-height:0; }
.page.flush:has(> .inbox) { min-height:0; overflow:hidden; }
.inbox { display:grid; flex:1; min-height:0; grid-template-rows:minmax(0, 1fr);
         grid-template-columns:18.5rem minmax(0, 1fr) 26rem; }
.inbox > * { min-height:0; min-width:0; }
.queue { display:flex; flex-direction:column; background:var(--paper);
         border-right:1px solid var(--rule); }
.queue-head { padding:.75rem .75rem .6rem; border-bottom:1px solid var(--rule-soft); flex:none; }
.queue-list { overflow:auto; flex:1; }
.queue-list a { display:grid; grid-template-columns:auto minmax(0, 1fr) auto; gap:.1rem .6rem;
                align-items:baseline; padding:.6rem .75rem; text-decoration:none;
                color:var(--ink); border-bottom:1px solid var(--rule-soft);
                border-left:3px solid transparent; }
.queue-list a:hover { background:var(--hover); }
.queue-list a.current { background:var(--selected); border-left-color:var(--accent); }
.queue-list .dot { align-self:center; }
.queue-list .what { font-weight:500; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.queue-list .total { font-variant-numeric:tabular-nums; }
.queue-list .who { grid-column:2 / -1; color:var(--ink-2); font-size:.84rem;
                   overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.queue-list .who.unset { color:var(--err); }
.record { display:flex; flex-direction:column; background:var(--paper);
          border-left:1px solid var(--rule); overflow:hidden; }
.record-scroll { flex:1; overflow:auto; }
.record-head { padding:1rem 1.1rem .9rem; border-bottom:1px solid var(--rule-soft); }
.record-head h2 { margin:0 0 .4rem; font-size:1.05rem; }
.record-head .facts { margin:.6rem 0 0; }
.record section { padding:1rem 1.1rem 1.1rem; border-bottom:1px solid var(--rule-soft); }
.record section > h3 { margin:0 0 .7rem; }
.record .warnbox, .record .notebox, .record .flash { margin:1rem 1.1rem 0; }
.record section .warnbox { margin:0 0 .75rem; }
.record table th, .record table td { padding:.4rem .5rem; }
.record table th:first-child, .record table td:first-child { padding-left:0; }
.record table th:last-child, .record table td:last-child { padding-right:0; }
.actionbar { flex:none; display:flex; align-items:center; justify-content:flex-end;
             gap:.6rem; flex-wrap:wrap; padding:.7rem 1.1rem;
             border-top:1px solid var(--rule); background:var(--paper); }
.actionbar .note { margin-right:auto; }
.facts { display:grid; grid-template-columns:auto minmax(0, 1fr); gap:.25rem .9rem;
         margin:0; font-size:.88rem; }
.facts dt { color:var(--ink-2); }
.facts dd { margin:0; }
.blank { display:grid; place-items:center; color:var(--ink-2); padding:2rem; text-align:center; }

/* ---- key/value lists, summaries ---------------------------------------- */
.kv { display:grid; grid-template-columns:auto 1fr; gap:.4rem 1rem; margin:0; align-items:baseline; }
.kv dt { color:var(--ink-2); font-size:.86rem; }
.kv dd { margin:0; font-variant-numeric:tabular-nums; }
.figures { display:flex; flex-wrap:wrap; gap:1.25rem 2.5rem; align-items:flex-end; margin:0 0 1.25rem; }
.figures div span { display:block; color:var(--ink-2); font-size:.86rem; }
.figures div b { font-size:1.5rem; font-weight:600; font-variant-numeric:tabular-nums; }

/* ---- missing documents ------------------------------------------------- */
.prio { display:inline-flex; align-items:baseline; gap:.4rem; white-space:nowrap; }
.prio b { font-variant-numeric:tabular-nums; }
.request { border:1px solid var(--rule); border-radius:8px; background:var(--paper);
           padding:.85rem 1rem; margin-bottom:.6rem; }
.request-head { display:flex; gap:.7rem; align-items:baseline; flex-wrap:wrap; }
.request-total { font-weight:600; font-variant-numeric:tabular-nums; margin-left:auto; }
details.answer > summary { display:inline-flex; align-items:center; height:1.9rem;
           cursor:pointer; padding:0 .7rem; border-radius:var(--r); list-style:none;
           border:1px solid var(--field); background:var(--paper); font-weight:500;
           font-size:.86rem; }
details.answer > summary::-webkit-details-marker { display:none; }
details.answer > summary:hover, details.answer[open] > summary { background:var(--hover); }
details.answer > form { margin-top:.6rem; padding:.8rem; border:1px solid var(--rule);
           border-radius:var(--r); background:var(--ground); max-width:38rem; }

/* ---- the obligations calendar ------------------------------------------ */
.late, h2.late { color:var(--err); }
.muted.late { font-weight:500; }
.chip-gap { width:.9rem; }
.taglist { display:flex; flex-wrap:wrap; gap:.35rem; }
.meter { display:inline-block; width:6.5rem; height:.4rem; border-radius:99px;
         background:var(--idle-soft); overflow:hidden; vertical-align:middle; }
.meter > span { display:block; height:100%; background:var(--ok); }
.meter.wide { width:100%; height:.5rem; }
.worklist td.when { width:13rem; white-space:nowrap; }
.worklist td.when .num { display:inline-block; min-width:5.6rem; text-transform:capitalize; }
.worklist td.progress { width:13rem; white-space:nowrap; }
.worklist td.progress .num { margin-left:.5rem; }
.worklist td.people { width:26%; }
td.lastnote { max-width:24rem; font-size:.88rem; }
.bulkbar { position:sticky; bottom:0; display:flex; flex-wrap:wrap; align-items:center;
           gap:.6rem; padding:.7rem .9rem; margin-top:-.5rem; background:var(--paper);
           border:1px solid var(--rule); border-radius:8px; box-shadow:var(--lift); }
.monthgrid { table-layout:fixed; }
.monthgrid th { text-transform:capitalize; text-align:left; }
.monthgrid td { vertical-align:top; height:6.5rem; padding:.35rem .4rem;
                border-left:1px solid var(--rule-soft); }
.monthgrid td:first-child { border-left:0; }
.monthgrid tbody tr:hover td { background:none; }
.monthgrid td.out { background:var(--ground); }
.monthgrid td.out .daynum { opacity:.55; }
.monthgrid .daynum { display:block; font-size:.8rem; color:var(--ink-2); margin-bottom:.2rem; }
.monthgrid td.today .daynum { color:var(--accent); font-weight:600; }
.monthgrid a.due { display:flex; justify-content:space-between; gap:.4rem;
                   padding:.12rem .4rem; margin-bottom:.15rem; border-radius:4px;
                   font-size:.8rem; text-decoration:none;
                   background:var(--warn-soft); color:var(--warn); }
.monthgrid a.due .what { overflow-wrap:anywhere; }
.monthgrid a.due.done { background:var(--ok-soft); color:var(--ok); }
.monthgrid a.due.late { background:var(--err-soft); color:var(--err); }
.monthgrid a.due:hover { text-decoration:underline; }
table.plain td { border:0; padding:.2rem 1rem .2rem 0; }
table.plain tr:hover td { background:none; }
table.proofs td { padding:.3rem 1rem .3rem 0; vertical-align:middle; }
pre.letter { white-space:pre-wrap; font:inherit; margin:.6rem 0 0; }
/* The System page: three small charts, one measure each, one scale each. */
.gauges { display:grid; grid-template-columns:repeat(auto-fit, minmax(20rem, 1fr)); gap:1.25rem; }
.gauge h3 { margin-bottom:.2rem; }
.gauge-now { display:flex; align-items:center; gap:.75rem; margin:0 0 .2rem; }
.gauge-now strong { font-size:1.9rem; font-weight:600; font-variant-numeric:tabular-nums; }
.trend { position:relative; margin-top:.6rem; }
.trend svg { display:block; width:100%; height:auto; overflow:visible; }
.trend-grid { stroke:var(--rule-soft); stroke-width:1; }
.trend-limit { stroke:var(--err); stroke-width:1; stroke-dasharray:4 3; }
.trend-line { fill:none; stroke:var(--accent); stroke-width:2; stroke-linejoin:round; stroke-linecap:round; }
.trend-tick { fill:var(--ink-2); font-size:10px; font-variant-numeric:tabular-nums; }
.trend-cross { stroke:var(--field); stroke-width:1; }
.trend-dot { fill:var(--accent); stroke:var(--paper); stroke-width:2; }
.trend-tip { position:absolute; top:0; right:0; padding:.1rem .45rem; border:1px solid var(--rule);
             border-radius:var(--r); background:var(--raised); font-size:.8rem;
             font-variant-numeric:tabular-nums; pointer-events:none; }
pre.errortext { white-space:pre-wrap; overflow-wrap:anywhere; font-size:.8rem; margin:.4rem 0 0;
                padding:.6rem; background:var(--idle-soft); border-radius:6px; max-width:60rem; }
details.fold > summary.row-link { display:inline-block; margin:.2rem 0 .4rem; }
.trail { list-style:none; margin:0; padding:0; }
.trail li { display:grid; grid-template-columns:8.5rem 7rem minmax(0, 1fr); gap:.2rem .9rem;
            padding:.55rem 0; border-bottom:1px solid var(--rule-soft); align-items:baseline; }
.trail .who { font-weight:500; overflow:hidden; text-overflow:ellipsis; }
form.unsay { margin-top:.2rem; }
button.linkish { background:none; border:0; height:auto; padding:0;
                 color:var(--link); font-size:.82rem; font-weight:500; }
button.linkish:hover { background:none; text-decoration:underline; }
.trail .said { display:block; margin-top:.2rem; padding:.4rem .6rem; border-radius:var(--r);
               background:var(--idle-soft); white-space:pre-line; }

/* ---- dialogs ----------------------------------------------------------- */
dialog { color:var(--ink); }
dialog.docmodal { border:0; padding:0; border-radius:10px; overflow:hidden;
                  width:min(1180px, 95vw); max-width:95vw; height:min(92vh, 980px);
                  background:var(--paper); box-shadow:var(--lift); }
dialog::backdrop { background:rgba(8,12,18,.6); }
/* The fetched card is injected into this wrapper, so it has to carry the
   dialog's height through — without it .modal-body's height:100% resolves
   against an auto-height parent and collapses. */
#docmodal-content { height:100%; }
/* minmax(0,…) so a wide PDF cannot push the grid past the dialog. */
.modal-body { display:grid; height:100%; grid-template-columns:minmax(0, 1.7fr) minmax(19rem, 1fr); }
.modal-preview { position:relative; background:var(--desk); display:flex;
                 align-items:center; justify-content:center; overflow:auto; }
.modal-preview iframe { width:100%; height:100%; border:0; }
.modal-preview img { max-width:100%; max-height:100%; object-fit:contain; }
.modal-side { display:flex; flex-direction:column; min-height:0; }
.modal-head { padding:1rem 1.1rem .8rem; border-bottom:1px solid var(--rule-soft); }
.modal-head h2 { margin:0 0 .4rem; font-size:1.05rem; }
.modal-scroll { overflow-y:auto; padding:1rem 1.1rem; flex:1; }
.modal-foot { padding:.7rem 1.1rem; border-top:1px solid var(--rule);
              display:flex; gap:.5rem; align-items:center; }
.modal-close { position:absolute; top:.6rem; right:.6rem; z-index:2; width:2rem; height:2rem;
               padding:0; border-radius:99px; background:rgba(255,255,255,.94); color:#141a24;
               border:0; font-size:1.2rem; }
.modal-close:hover { background:#fff; }
.modal-nav { margin-left:auto; display:flex; gap:.4rem; }
dialog.modal { border:1px solid var(--rule); border-radius:10px; box-shadow:var(--lift);
               padding:1.3rem 1.4rem; min-width:min(30rem, 92vw); max-width:36rem;
               background:var(--paper); }
dialog.modal h3 { margin:0 0 .5rem; font-size:1.05rem; }
.up-label { margin:.2rem 0 .6rem; word-break:break-word; min-height:1.2em; }
.up-bar { height:.4rem; border-radius:99px; background:var(--idle-soft); overflow:hidden; margin:0 0 .7rem; }
.up-bar span { display:block; height:100%; width:0; background:var(--accent); transition:width .18s ease; }
.up-errors { margin:.85rem 0 0; font-size:.86rem; color:var(--err); max-height:11rem; overflow:auto; }
.up-errors div { margin-top:.28rem; word-break:break-word; }

/* ---- the upload drop zone ---------------------------------------------- */
/* The file input is stretched invisibly across the whole box: clicking
   anywhere opens the picker and a native file input already accepts drops,
   so drag-and-drop works with JavaScript disabled. */
.dropzone { position:relative; border:1.5px dashed var(--field); border-radius:8px;
            background:var(--ground); padding:1.5rem 1rem; text-align:center; }
.dropzone:hover, .dropzone.over { border-color:var(--accent); background:var(--accent-soft); }
.dropzone input[type=file] { position:absolute; inset:0; width:100%; height:100%; opacity:0; cursor:pointer; }
.dz-prompt { margin:0; }
.dz-files { margin:.65rem 0 0; font-size:.86rem; word-break:break-word; }

/* ---- smaller screens --------------------------------------------------- */
@media (max-width: 1250px) {
  .inbox { grid-template-columns:15rem minmax(0, 1fr) 23rem; }
}
@media (max-width: 1000px) {
  /* The rail becomes a strip across the top; panes stack and the page scrolls. */
  body.shell { display:block; }
  .side { position:static; height:auto; flex-direction:row; align-items:center;
          gap:.5rem; padding:.4rem .6rem; overflow-x:auto; }
  .brand { padding:.3rem .5rem; }
  .side nav { flex-direction:row; }
  .side nav a { white-space:nowrap; }
  .side-foot { border:0; padding:0; display:flex; align-items:center; gap:.6rem; white-space:nowrap; }
  .whoami { display:none; }
  .main { min-height:0; }
  .pagebar { position:static; }
  .main:has(> .page.flush > .inbox) { height:auto; }
  .page.flush:has(> .inbox) { overflow:visible; }
  .inbox { display:block; }
  .queue-list { max-height:14rem; }
  .desk { height:70vh; }
  .record { border-left:0; }
  .actionbar { position:sticky; bottom:0; }
  .split, .browser { display:block; }
  .browser > .tree { position:static; margin-bottom:1rem; }
  .split > aside { position:static; height:auto; border-right:0; border-bottom:1px solid var(--rule); }
  .modal-body { grid-template-columns:1fr; grid-template-rows:45% 55%; }
  .grid2, .fields.four { grid-template-columns:repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .grid2, .fields, .fields.four { grid-template-columns:1fr; }
  .trail li { grid-template-columns:1fr; }
  .worklist td.when, .worklist td.progress, .worklist td.people { width:auto; white-space:normal; }
  .page, .split > section { padding:1rem; }
  .pagebar { padding:0 1rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition:none !important; } }
