/* Invoice intake review app.
   Visual language: a quiet grey shell with a white working panel, hairlines instead of cards,
   one dark primary button, colour kept for status and for who did what (Agent / Code / Person). */

/* Geist and Geist Mono (SIL Open Font License, fonts/OFL-Geist.txt), served from this site: no font CDN. */
@font-face { font-family: Geist; src: url("fonts/Geist-Variable.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("fonts/GeistMono-Variable.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }

:root {
  --shell: #f1f1ee;
  --panel: #ffffff;
  --soft: #f7f7f5;
  --canvas: #f3f3f0;
  --dots: #dcdcd6;
  --ink: #141a24;
  --ink-2: #3b4250;
  --muted: #6c7280;
  --faint: #9aa0aa;
  --line: #e8e7e2;
  --line-2: #d9d8d1;
  --input: #ffffff;
  --focus: #2c44e033;
  --primary: #161c28;
  --primary-ink: #ffffff;
  --hover: #f4f4f1;

  /* who did it: same colours as the explainer */
  --agent: #2c44e0;  --agent-bg: #eceefd;
  --code: #2a303b;   --code-bg: #ececea;
  --person: #8a5a12; --person-bg: #f7eedd;

  /* status */
  --ok: #1d6b47;     --ok-bg: #e7f2ec;
  --warn: #a3471c;   --warn-bg: #fbece4;
  --dup: #5a4f8f;    --dup-bg: #eeecf6;
  --skip: #6a6f78;   --skip-bg: #efefec;
  --read: #2c44e0;   --read-bg: #eceefd;
  --err: #a12f2f;    --err-bg: #f8e6e4;

  --r: 12px;
  --r-sm: 7px;
  --side: 248px;
  --sans: Geist, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  color-scheme: light;
  -webkit-font-smoothing: antialiased;
}

@media (prefers-color-scheme: dark) {
  :root {
    --shell: #0a0e15;
    --panel: #10151e;
    --soft: #151b26;
    --canvas: #0c1119;
    --dots: #1f2734;
    --ink: #e7eaf0;
    --ink-2: #c3c8d2;
    --muted: #8e97a8;
    --faint: #687183;
    --line: #1e2633;
    --line-2: #2a3342;
    --input: #0c1119;
    --focus: #8f9dff40;
    --primary: #e7eaf0;
    --primary-ink: #10151e;
    --hover: #161d29;

    --agent: #8f9dff;  --agent-bg: #1b2350;
    --code: #c9ced8;   --code-bg: #212938;
    --person: #e2b25f; --person-bg: #33291a;

    --ok: #6fcf9b;     --ok-bg: #12291f;
    --warn: #f0a27c;   --warn-bg: #34201a;
    --dup: #b6acec;    --dup-bg: #231f3d;
    --skip: #a2a9b6;   --skip-bg: #1c2330;
    --read: #8f9dff;   --read-bg: #1b2350;
    --err: #f09a92;    --err-bg: #3a1f20;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { background: var(--shell); }
body { margin: 0; background: var(--shell); line-height: 1.45; color: var(--ink); }
a { color: inherit; }
code { font-family: var(--mono); font-size: .92em; }
svg { flex: none; }
.muted { color: var(--muted); }
.num, .mono { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: .93em; letter-spacing: -0.01em; }
.banner { background: var(--warn-bg); color: var(--warn); padding: 8px 20px; font-size: 13px; }

/* ---------------------------------------------------------------- shell */

.shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh; }

.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 26px;
  padding: 22px 16px 18px 20px;
}
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; font-weight: 600; font-size: 15px; letter-spacing: -0.01em; padding: 2px 4px; }
.mark { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: var(--r-sm); text-decoration: none; color: var(--muted); font-weight: 500; }
.nav a svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.nav a:hover { color: var(--ink); background: var(--hover); }
.nav a.on { color: var(--ink); background: var(--panel); box-shadow: 0 0 0 1px var(--line); }
.nav .n { margin-left: auto; font-size: 12px; font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 500; }

.eyebrow { margin: 0 0 6px; font-size: 11px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.rule { padding: 0 4px; }
.rule-line { margin: 0 0 14px; font-size: 13px; color: var(--ink-2); }
.who { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.who li { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 8px; align-items: baseline; font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.who .tag { justify-self: start; }

.intake { margin-top: auto; display: flex; flex-direction: column; gap: 5px; padding: 12px 4px 0; border-top: 1px solid var(--line-2); font-size: 12px; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); font-size: 12.5px; font-weight: 500; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.on { background: #2f9a62; box-shadow: 0 0 0 3px #2f9a6226; }
.dot.err { background: #c24a3d; }
.dot.wait { background: #d6a23a; }

.panel {
  margin: 8px 8px 8px 0; min-width: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  display: flex; flex-direction: column;
}
#view { flex: 1; padding: 28px 36px 40px; min-width: 0; }
.foot { padding: 16px 36px 22px; border-top: 1px solid var(--line); font-size: 12px; color: var(--faint); }

.static-note { display: none; }
body.static .static-note {
  display: flex; align-items: center; gap: 9px; margin: 0;
  padding: 10px 36px; border-bottom: 1px solid var(--line); border-radius: var(--r) var(--r) 0 0;
  background: var(--soft); font-size: 12.5px; color: var(--ink-2);
}
.static-note svg { width: 15px; height: 15px; fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; }

/* ---------------------------------------------------------------- shared pieces */

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px 24px; flex-wrap: wrap; margin-bottom: 26px; }
.page-head h1 { margin: 0; font-size: 28px; font-weight: 450; letter-spacing: -0.02em; line-height: 1.15; }
.page-head .sub { margin: 6px 0 0; color: var(--muted); font-size: 13.5px; max-width: 64ch; }

/* who did it */
.tag { display: inline-flex; align-items: center; font-size: 11px; font-weight: 600; letter-spacing: .01em; line-height: 1; padding: 4px 6px 4px; border-radius: 5px; vertical-align: 1px; white-space: nowrap; }
.tag.agent { color: var(--agent); background: var(--agent-bg); }
.tag.code { color: var(--code); background: var(--code-bg); }
.tag.person { color: var(--person); background: var(--person-bg); }

/* status */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; line-height: 1; padding: 5px 8px 5px 7px; border-radius: 6px; white-space: nowrap; color: var(--skip); background: var(--skip-bg); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ready, .pill.approved { color: var(--ok); background: var(--ok-bg); }
.pill.needs_review { color: var(--warn); background: var(--warn-bg); }
.pill.duplicate { color: var(--dup); background: var(--dup-bg); }
.pill.reading { color: var(--read); background: var(--read-bg); }
.pill.reading::before { animation: pulse 1.2s ease-in-out infinite; }
.pill.error { color: var(--err); background: var(--err-bg); }
@keyframes pulse { 50% { opacity: .25; } }

.btn {
  font: inherit; font-size: 13.5px; font-weight: 500; line-height: 1;
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; border-radius: 8px;
  border: 1px solid var(--line-2); background: var(--panel); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { opacity: .88; }
.btn.quiet { color: var(--muted); }
.btn:focus-visible, .nav a:focus-visible, .tabs a:focus-visible, .stat:focus-visible { outline: 2px solid var(--agent); outline-offset: 2px; }
.link { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
.link:hover { text-decoration-color: currentColor; }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 64px 20px; color: var(--muted); font-size: 13.5px; }
.empty svg { width: 34px; height: 34px; fill: none; stroke: var(--faint); stroke-width: 1.3; stroke-linejoin: round; stroke-linecap: round; margin-bottom: 8px; }
.empty b { color: var(--ink); font-weight: 500; font-size: 14.5px; }
.empty p { margin: 0; max-width: 46ch; }

/* ---------------------------------------------------------------- inbox */

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.stat {
  position: relative; display: flex; flex-direction: column; gap: 4px; padding: 16px 18px 15px;
  text-decoration: none; color: var(--ink); border-left: 1px solid var(--line);
}
.stat:first-child { border-left: 0; padding-left: 0; }
.stat .stat-n { font-size: 30px; font-weight: 400; letter-spacing: -0.03em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.stat .stat-l { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.stat .stat-l::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--faint)); }
.stat.ready { --c: var(--ok); } .stat.review { --c: var(--warn); } .stat.duplicates { --c: var(--dup); } .stat.skipped { --c: var(--skip); }
.stat:hover .stat-l { color: var(--ink); }
.stat.on::after { content: ""; position: absolute; left: 18px; right: 18px; bottom: -1px; height: 2px; background: var(--ink); }
.stat.on:first-child::after { left: 0; }
.stats.filtered .stat:not(.on) .stat-n { color: var(--faint); }
.stat.zero .stat-n { color: var(--faint); }

.tabs { display: flex; align-items: center; gap: 22px; border-bottom: 1px solid var(--line); margin-bottom: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { position: relative; display: inline-flex; align-items: center; gap: 7px; padding: 0 0 11px; color: var(--muted); text-decoration: none; font-weight: 500; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a.on { color: var(--ink); }
.tabs a.on::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--ink); border-radius: 2px; }
.tabs .c { min-width: 20px; padding: 3px 6px; border-radius: 5px; font-size: 11px; line-height: 1; text-align: center; font-variant-numeric: tabular-nums; background: var(--soft); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }
.tabs a.on .c { background: var(--primary); color: var(--primary-ink); box-shadow: none; }
.tabs .spacer { flex: 1; }
.tabs .showing { font-size: 12.5px; color: var(--muted); padding-bottom: 11px; white-space: nowrap; }

.list-head, .row {
  display: grid; align-items: center; gap: 16px;
  grid-template-columns: 34px minmax(0, 1fr) 96px 128px 112px;
}
.list-head { padding: 12px 10px 9px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); }
.list-head .r, .row .amount { text-align: right; }

.row { position: relative; padding: 11px 10px; border-bottom: 1px solid var(--line); color: inherit; }
.row-link { color: inherit; text-decoration: none; }
.row-link::after { content: ""; position: absolute; inset: 0; } /* the whole row opens the document */
.row-link:focus-visible { outline: none; }
.row:has(.row-link:focus-visible) { outline: 2px solid var(--agent); outline-offset: -2px; }
.row .note a { position: relative; z-index: 1; color: inherit; font-weight: 500; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.row .note a:hover { text-decoration-thickness: 2px; }
.row:hover { background: var(--hover); }
.row.fresh { animation: fresh 2.6s ease-out; }
@keyframes fresh { from { background: var(--read-bg); } to { background: transparent; } }
.row.dim .title, .row.dim .amount { color: var(--muted); }
.mini { width: 34px; height: 44px; border-radius: 4px; box-shadow: 0 0 0 1px var(--line-2); background: var(--soft) center top / cover no-repeat; }
.row .main { min-width: 0; }
.row .title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .id { color: var(--faint); font-weight: 400; margin-right: 8px; font-variant-numeric: tabular-nums; }
.row .meta { margin-top: 2px; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .note { margin-top: 3px; font-size: 12.5px; color: var(--warn); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row[data-status="duplicate"] .note { color: var(--dup); }
.row[data-status="skipped"] .note, .row[data-status="rejected"] .note { color: var(--skip); }
.row .via { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; font-size: 11.5px; color: var(--muted); }
.row .amount { font-variant-numeric: tabular-nums; font-weight: 500; white-space: nowrap; }
.list-foot { padding: 12px 10px; font-size: 12.5px; color: var(--muted); }

/* ---------------------------------------------------------------- document */

.doc-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: -8px 0 18px; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 500; }
.back svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.back:hover { color: var(--ink); }
.stepper { display: flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--muted); }
.stepper a { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; border: 1px solid var(--line-2); color: var(--ink); text-decoration: none; }
.stepper a:hover { background: var(--hover); }
.stepper a.off { pointer-events: none; opacity: .35; }
.stepper svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.stepper span { margin-right: 6px; font-variant-numeric: tabular-nums; }

.doc-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 36px; align-items: start; }

.original { position: sticky; top: 16px; }
.canvas {
  border-radius: 10px; box-shadow: inset 0 0 0 1px var(--line);
  background-color: var(--canvas);
  background-image: radial-gradient(var(--dots) 1px, transparent 1.2px);
  background-size: 14px 14px;
  padding: 22px; max-height: calc(100vh - 150px); overflow: auto;
}
.canvas a { display: block; }
.canvas img.frame { display: block; margin: 0 auto; max-width: 100%; height: auto; max-height: calc(100vh - 196px); background: #fff; border-radius: 3px; box-shadow: 0 0 0 1px #0000000f, 0 8px 24px -12px #1a20302e; }
.canvas iframe { width: 100%; height: calc(100vh - 196px); min-height: 480px; border: 0; background: #fff; border-radius: 3px; box-shadow: 0 0 0 1px #0000000f; }
.original-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px 14px; flex-wrap: wrap; padding: 10px 2px 0; font-size: 12px; color: var(--muted); }
.original-foot .btn { padding: 7px 11px; font-size: 12.5px; }

.doc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px 18px; flex-wrap: wrap; padding-bottom: 20px; }
.doc-head > div:first-child { flex: 1 1 300px; min-width: 0; }
.doc-head .eyebrow { margin-bottom: 6px; }
.doc-head h1 { margin: 0; font-size: 24px; font-weight: 450; letter-spacing: -0.02em; line-height: 1.2; }
.doc-head .from { margin-top: 5px; font-size: 13px; color: var(--muted); }
.doc-head .from a { color: var(--ink); }
.doc-head .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.doc-head .status-line { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }

.sec { border-top: 1px solid var(--line); padding: 18px 0 20px; }
.sec h3 { margin: 0 0 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 11px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.sec h3 .tag { text-transform: none; letter-spacing: .01em; }
.sec h3 .aside { text-transform: none; letter-spacing: 0; font-size: 12px; font-weight: 400; color: var(--muted); }
.sec .hint { margin: -4px 0 10px; font-size: 13px; color: var(--muted); }

.kv { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.kv td { padding: 7px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
.kv tr:last-child td { border-bottom: 0; }
.kv td.k { color: var(--muted); width: 32%; padding-right: 12px; }
.kv td.v { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kv td.t { text-align: right; width: 66px; padding-left: 10px; }
.kv .null { color: var(--warn); font-style: italic; }
.kv input, .kv select {
  width: 100%; font: inherit; font-size: 13.5px; font-variant-numeric: tabular-nums;
  padding: 6px 9px; border: 1px solid var(--line-2); border-radius: 7px; background: var(--input); color: var(--ink);
}
.kv input:focus, .kv select:focus { outline: none; border-color: var(--agent); box-shadow: 0 0 0 3px var(--focus); }
.kv input.empty-val { border-color: var(--warn); border-style: dashed; }
.kv input.bad { border-color: var(--err); }
.kv input.changed { border-color: var(--person); }
.vatline { display: grid; grid-template-columns: 58px 1fr 1fr 22px; gap: 6px; align-items: center; margin-bottom: 5px; }
.icon-btn { border: none; background: none; color: var(--muted); font-size: 18px; cursor: pointer; padding: 0; line-height: 1; }
.link-btn { border: none; background: none; color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; font: inherit; font-size: 12.5px; cursor: pointer; padding: 2px 0; }

.checks { list-style: none; margin: 0; padding: 0; font-size: 13.5px; }
.checks li { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 10px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--line); }
.checks li:last-child { border-bottom: 0; }
.checks .mark { font-weight: 600; }
.checks .ok .mark { color: var(--ok); }
.checks .bad .mark, .checks .bad .text { color: var(--warn); }
.checks .text { font-variant-numeric: tabular-nums; }
.checks a { color: inherit; font-weight: 500; }
.verdict { display: flex; align-items: center; gap: 9px; margin-top: 12px; padding: 9px 12px; border-radius: 8px; font-size: 13px; font-weight: 500; }
.verdict::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.verdict.ok { background: var(--ok-bg); color: var(--ok); }
.verdict.warn { background: var(--warn-bg); color: var(--warn); }
.verdict.dup { background: var(--dup-bg); color: var(--dup); }
.verdict.skip { background: var(--skip-bg); color: var(--skip); }

.compare { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.compare th { text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); padding: 0 10px 8px 0; vertical-align: bottom; }
.compare th .tag { margin-left: 4px; }
.compare td { padding: 6px 10px 6px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.compare td:first-child { color: var(--muted); white-space: nowrap; width: 1%; padding-right: 14px; }
.compare td.m { text-align: center; font-weight: 600; width: 24px; padding-right: 0; }
.compare tr.correct td.m { color: var(--ok); }
.compare tr.wrong td, .compare tr.null td { color: var(--warn); }
.compare-sum { margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.compare-sum b { color: var(--ink); font-weight: 500; }
.exact { display: inline-flex; align-items: center; gap: 6px; text-transform: none; letter-spacing: 0; color: var(--ink-2); background: var(--soft); box-shadow: inset 0 0 0 1px var(--line); border-radius: 6px; padding: 4px 8px; font-weight: 500; font-size: 12px; }

.history { list-style: none; margin: 0; padding: 0; font-size: 13px; position: relative; }
.history li { display: grid; grid-template-columns: 64px 60px minmax(0, 1fr); gap: 8px; padding: 5px 0; align-items: baseline; }
.history time { color: var(--faint); font-variant-numeric: tabular-nums; font-size: 12px; font-family: var(--mono); }
.history .tag { justify-self: start; }

details.record summary, details.mailtext summary { cursor: pointer; font-size: 13px; color: var(--muted); list-style-position: outside; }
details.record summary:hover, details.mailtext summary:hover { color: var(--ink); }
pre.json, details.mailtext pre {
  margin: 10px 0 0; padding: 12px 14px; background: var(--soft); border: 1px solid var(--line); border-radius: 8px;
  font-family: var(--mono); font-size: 12px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; max-height: 300px; overflow: auto; color: var(--ink-2);
}
details.mailtext { margin-top: 10px; }

/* ---------------------------------------------------------------- approved */

.summary { display: flex; gap: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.summary > div { padding: 14px 22px 13px; border-left: 1px solid var(--line); }
.summary > div:first-child { padding-left: 0; border-left: 0; }
.summary .stat-n { display: block; font-size: 26px; font-weight: 400; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.summary .stat-l { font-size: 12.5px; color: var(--muted); }
.legend { font-size: 12.5px; color: var(--muted); margin: -8px 0 14px; display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

.table-wrap { overflow-x: auto; margin: 0 -2px; }
table.list { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
table.list th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 400; padding: 10px 12px 9px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list th:first-child, table.list td:first-child { padding-left: 2px; }
table.list td.num, table.list th.num { text-align: right; }
table.list td.strong { font-weight: 500; }
table.list tbody tr { cursor: pointer; }
table.list tbody tr:hover td { background: var(--hover); }
table.list tfoot td { border-bottom: 0; font-weight: 500; padding-top: 12px; }
table.list a { color: var(--muted); }
table.list a:hover { color: var(--ink); }

/* ---------------------------------------------------------------- narrower screens */

@media (max-width: 1180px) {
  .doc-grid { grid-template-columns: 1fr; gap: 26px; }
  .original { position: static; }
  .canvas { max-height: none; }
  .canvas img.frame { max-height: 78vh; }
  .canvas iframe { height: 70vh; min-height: 360px; }
}

@media (max-width: 900px) {
  .shell { display: block; }
  .side {
    position: static; height: auto; overflow: visible; gap: 14px;
    padding: 14px 16px 12px;
  }
  .side .brand { padding: 0; }
  .nav { flex-direction: row; gap: 6px; }
  .nav a { flex: 1; padding: 8px 10px; }
  .rule { padding: 0; }
  .rule .eyebrow { display: none; }
  body:not([data-view="inbox"]) .rule { display: none; }
  .rule-line { margin-bottom: 10px; font-size: 12.5px; }
  .who { gap: 6px; }
  .intake { margin-top: 0; padding-top: 10px; flex-direction: row; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
  .panel { margin: 0 8px 8px; }
  #view { padding: 22px 16px 32px; }
  .foot { padding: 14px 16px 18px; }
  body.static .static-note { padding: 10px 16px; }
}

@media (max-width: 640px) {
  .page-head { margin-bottom: 18px; }
  .page-head h1 { font-size: 24px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: 12px 0 11px 14px; }
  .stat:nth-child(odd) { border-left: 0; padding-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
  .stat.on::after { left: 14px; right: 0; }
  .stat.on:nth-child(odd)::after { left: 0; right: 14px; }
  .stat .stat-n { font-size: 26px; }
  .tabs { gap: 18px; }
  .tabs .spacer, .tabs .showing { display: none; }
  .list-head { display: none; }
  .row { grid-template-columns: 34px minmax(0, 1fr) auto; grid-template-areas: "mini main amount" "mini status via"; gap: 4px 12px; align-items: start; padding: 12px 2px; }
  .row .mini { grid-area: mini; }
  .row .main { grid-area: main; }
  .row .amount { grid-area: amount; }
  .row .status { grid-area: status; margin-top: 6px; }
  .row .via { grid-area: via; flex-direction: row; align-items: center; justify-content: flex-end; margin-top: 6px; }
  .row .title, .row .note { white-space: normal; }
  .row .via span { display: none; }
  .doc-bar { margin-top: -4px; }
  .doc-head h1 { font-size: 21px; }
  .doc-head .actions { width: 100%; }
  .doc-head .actions .btn { flex: 1; justify-content: center; }
  .canvas { padding: 12px; }
  .kv td.k { width: 36%; }
  .kv td.t { width: 56px; }
  .history li { grid-template-columns: 56px minmax(0, 1fr); }
  .history li .tag { grid-column: 2; }
  .history li .text { grid-column: 1 / -1; padding-bottom: 4px; }
  .compare th:nth-child(2), .compare th:nth-child(3) { font-size: 11.5px; }
  .summary > div { padding: 12px 14px; }
  .summary .stat-n { font-size: 22px; }
}
