/* DocIntel console. Tokens first; components below. No build step, no external fonts (works offline). */
:root {
  --ink: #18212F;           /* sidebar */
  --ink-2: #222D3D;
  --ink-text: #C9D2DE;
  --paper: #F2F4F6;         /* workspace */
  --surface: #FFFFFF;
  --line: #DDE2E8;
  --line-strong: #C5CDD7;
  --text: #1B2430;
  --muted: #5A6675;
  --primary: #1D4E89;
  --primary-hover: #163E6E;
  --primary-soft: #E6EEF8;
  --focus: #2F7BD8;

  /* provenance: what produced a value */
  --genuine: #2E7D4F;  --genuine-bg: #E5F3EA;
  --heuristic: #94600A; --heuristic-bg: #FBF0DA;
  --fixture: #6A4C9C;  --fixture-bg: #EFE9F8;
  --unavailable: #5F6B7A; --unavailable-bg: #EDF0F3;
  --danger: #B3261E;   --danger-bg: #FBE7E5;
  --warn-row: #FFF8E8;

  --display: Bahnschrift, "DIN Alternate", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  --body: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --r-sm: 4px; --r: 6px; --r-lg: 10px;
  --shadow: 0 1px 2px rgba(24, 33, 47, .06), 0 2px 8px rgba(24, 33, 47, .05);
  --sidebar-w: 232px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.55 var(--body); color: var(--text); background: var(--paper); }
h1, h2, h3, h4 { font-family: var(--display); font-weight: 600; line-height: 1.2; margin: 0; letter-spacing: .005em; }
h1 { font-size: 26px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
h4 { font-size: 14px; }
p { margin: 0 0 .75em; }
a { color: var(--primary); text-underline-offset: 2px; }
a:hover { color: var(--primary-hover); }
code, .mono { font-family: Consolas, "Cascadia Mono", ui-monospace, monospace; font-size: .9em; }
.num { font-family: var(--display); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.wrap-any { overflow-wrap: anywhere; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: 12px; top: -48px; z-index: 50; background: var(--surface); padding: 8px 12px; border-radius: var(--r); }
.skip:focus { top: 12px; }

.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; background: linear-gradient(to right, var(--ink) var(--sidebar-w), var(--paper) 0); }
.sidebar { background: var(--ink); color: var(--ink-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 18px 12px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; color: #fff; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--primary); }
.brand-name { font-family: var(--display); font-size: 20px; font-weight: 600; letter-spacing: .01em; }
.nav { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: var(--r); color: var(--ink-text); text-decoration: none; font-size: 14.5px; }
.nav a:hover { background: var(--ink-2); color: #fff; }
.nav a[aria-current="page"] { background: #2B3A50; color: #fff; box-shadow: inset 3px 0 0 #7FB3E8; }
.nav-count { margin-left: auto; min-width: 22px; padding: 0 7px; border-radius: 11px; background: #F2C46B; color: #3A2800; font: 600 12px/20px var(--display); text-align: center; }
.sidebar-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid #2C3849; font-size: 12.5px; line-height: 1.45; }
.sidebar-foot strong { color: #fff; font-weight: 600; display: block; margin-bottom: 2px; }
.mode-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #6CC08B; margin-right: 6px; vertical-align: 1px; }
.mode-dot.remote { background: #7FB3E8; }
.mode-dot.off { background: #E0776F; }

.workspace { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px; padding: 12px 28px; background: rgba(242, 244, 246, .94); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.crumbs { flex: 1; min-width: 0; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs a { color: var(--muted); }
.crumbs strong { color: var(--text); font-weight: 600; }
.icon-btn.menu-btn { display: none; }
main { padding: 28px; max-width: 1240px; width: 100%; margin: 0 auto; outline: none; }
.scrim { position: fixed; inset: 0; background: rgba(15, 22, 32, .45); z-index: 29; }

/* ---------------------------------------------------------------- page header */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; margin-bottom: 22px; }
.page-head p { margin: 6px 0 0; color: var(--muted); max-width: 70ch; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------------------------------------------------------------- controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 36px; padding: 7px 14px; border-radius: var(--r); border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font: 500 14px/1.2 var(--body); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #9AA6B4; background: #F8F9FB; color: var(--text); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn.quiet { border-color: transparent; background: transparent; color: var(--primary); padding-inline: 8px; }
.btn.quiet:hover { background: var(--primary-soft); }
.btn.danger { color: var(--danger); }
.btn.sm { min-height: 30px; padding: 4px 10px; font-size: 13px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r); border: 1px solid transparent; background: transparent; color: inherit; cursor: pointer; }
.icon-btn:hover { background: rgba(24, 33, 47, .07); }

label.field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
input[type=text], input[type=search], input[type=number], input[type=date], input[type=password], input:not([type]), select, textarea {
  font: inherit; font-size: 14px; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r); padding: 7px 10px; min-height: 36px; max-width: 100%; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--text); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.toolbar .grow { flex: 1 1 220px; }
.toolbar .grow input { width: 100%; }

/* ---------------------------------------------------------------- panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 20px; min-width: 0; }
.panel + .panel { margin-top: 18px; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 14px; }
.panel-head p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.section { margin-top: 22px; }
.section:first-child { margin-top: 0; }
.section > h3 { margin-bottom: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.grid-2 > .panel + .panel, .stack > .panel + .panel { margin-top: 0; }
.stack { display: grid; gap: 18px; align-content: start; }
.flush { padding: 0; overflow: hidden; }
.flush .panel-head { padding: 18px 20px 0; }

/* ---------------------------------------------------------------- dashboard ledger */
.ledger { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 18px; }
.ledger-cell { padding: 18px 20px 16px; border-left: 1px solid var(--line); text-decoration: none; color: inherit; display: block; }
.ledger-cell:first-child { border-left: 0; }
a.ledger-cell:hover { background: #F8FAFC; }
.ledger-cell .n { font: 600 34px/1.05 var(--display); font-variant-numeric: tabular-nums; display: block; }
.ledger-cell .l { font-size: 13.5px; color: var(--muted); }
.ledger-cell.attention .n { color: var(--heuristic); }
.ledger-cell.bad .n { color: var(--danger); }
.split { grid-column: 1 / -1; display: flex; height: 6px; background: var(--unavailable-bg); }
.split span { display: block; height: 100%; }
.source-note { font-size: 13px; color: var(--muted); margin: -8px 0 18px; }

.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) 36px; gap: 10px; align-items: center; font-size: 13.5px; }
.bar { height: 8px; border-radius: 4px; background: var(--unavailable-bg); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--primary); border-radius: 4px; }
.bar.low > span { background: var(--heuristic); }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th { font-size: 12.5px; font-weight: 600; color: var(--muted); background: #F7F9FB; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #FAFBFC; }
tr.needs td { background: var(--warn-row); }
tr.needs:hover td { background: #FFF3D6; }
.sort-btn { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
.sort-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
.sort-btn .arrow { font-size: 10px; opacity: .45; }
th[aria-sort="ascending"] .arrow, th[aria-sort="descending"] .arrow { opacity: 1; }
.doc-name { font-weight: 600; color: var(--text); text-decoration: none; overflow-wrap: anywhere; }
.doc-name:hover { color: var(--primary); text-decoration: underline; }
.cell-sub { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); font-size: 13.5px; color: var(--muted); }

/* ---------------------------------------------------------------- pills */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 500; line-height: 1.6; white-space: nowrap; background: var(--unavailable-bg); color: var(--unavailable); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.plain::before { display: none; }
.pill.ok { background: var(--genuine-bg); color: var(--genuine); }
.pill.warn { background: var(--heuristic-bg); color: var(--heuristic); }
.pill.bad { background: var(--danger-bg); color: var(--danger); }
.pill.info { background: var(--primary-soft); color: var(--primary); }
.pill.fixture { background: var(--fixture-bg); color: var(--fixture); }
.chip { display: inline-block; padding: 2px 9px; border-radius: var(--r-sm); background: #EEF1F4; font-size: 13px; margin: 0 6px 6px 0; }
.chip small { color: var(--muted); margin-left: 4px; }

/* ---------------------------------------------------------------- provenance: the signature element */
.prov { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; padding: 1px 8px 1px 6px; border-radius: var(--r-sm); border: 1px solid currentColor; line-height: 1.6; white-space: nowrap; cursor: help; font-family: var(--body); }
.prov::before { content: ""; width: 7px; height: 7px; border-radius: 2px; background: currentColor; }
.prov.genuine { color: var(--genuine); background: var(--genuine-bg); }
.prov.heuristic { color: var(--heuristic); background: var(--heuristic-bg); }
.prov.fixture { color: var(--fixture); background: var(--fixture-bg); }
.prov.unavailable { color: var(--unavailable); background: var(--unavailable-bg); }
.prov.ai { color: var(--primary); background: var(--primary-soft); }
.prov-ledger { list-style: none; margin: 10px 0 0; padding: 0; }
details.prov-box summary { cursor: pointer; font-size: 13.5px; color: var(--primary); margin-top: 10px; }
details.prov-box summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.prov-counts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.prov-ledger li { display: grid; grid-template-columns: 12px 1fr; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.prov-ledger li:first-child { border-top: 0; padding-top: 0; }
.prov-ledger .tick { width: 12px; height: 12px; border-radius: 3px; margin-top: 4px; }
.prov-ledger .tick.genuine { background: var(--genuine); }
.prov-ledger .tick.heuristic { background: var(--heuristic); }
.prov-ledger .tick.fixture { background: var(--fixture); }
.prov-ledger .tick.unavailable { background: transparent; border: 2px solid var(--unavailable); }
.prov-ledger b { font-weight: 600; font-size: 14px; }
.prov-ledger span { display: block; font-size: 13px; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 8px; }

.notice { display: flex; gap: 12px; padding: 12px 14px; border-radius: var(--r); background: var(--primary-soft); color: #173C66; font-size: 14px; margin-bottom: 18px; border: 1px solid #C8DAF0; }
.notice .ic { margin-top: 2px; }
.notice.warn { background: var(--heuristic-bg); border-color: #EBD3A3; color: #5E3D04; }
.notice.bad { background: var(--danger-bg); border-color: #F0C2BE; color: #7A1A14; }
.notice.ok { background: var(--genuine-bg); border-color: #BFDFCB; color: #1D5134; }
.notice p { margin: 0; }
.notice p + p { margin-top: 4px; }

/* ---------------------------------------------------------------- document detail */
.doc-head { display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.doc-head h1 { overflow-wrap: anywhere; }
.doc-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 8px; font-size: 13.5px; color: var(--muted); }
.doc-meta .pill { font-size: 12px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line-strong); margin-bottom: 20px; overflow-x: auto; scrollbar-width: thin; }
.tabs [role=tab] { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; padding: 10px 14px; font-size: 14.5px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs [role=tab]:hover { color: var(--text); }
.tabs [role=tab][aria-selected=true] { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tabs [role=tab]:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; border-radius: 4px 4px 0 0; }
.summary-text { font-size: 15.5px; line-height: 1.6; max-width: 72ch; }
.summary-text p { margin: 0 0 4px; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: 14px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.quote { display: block; font-size: 13px; color: var(--muted); border-left: 2px solid var(--line-strong); padding-left: 8px; margin-top: 4px; }
.pagebox { border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 14px; }
.pagebox h4 { padding: 8px 12px; background: #F7F9FB; border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.pagebox ol { margin: 0; padding: 10px 12px 10px 48px; font-size: 14px; max-width: 90ch; }
.pagebox li::marker { color: #9AA6B4; font-size: 12px; font-variant-numeric: tabular-nums; }
.inline-form { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.inline-form input { width: 150px; }

/* ---------------------------------------------------------------- stages, findings, timeline */
.stages { list-style: none; margin: 0; padding: 0; }
.stage { position: relative; padding: 6px 0 8px 22px; border-left: 2px solid var(--line); margin-left: 6px; }
.stage::before { content: ""; position: absolute; left: -7px; top: 9px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line-strong); }
.stage.completed::before { background: var(--genuine); border-color: var(--genuine); }
.stage.failed::before { background: var(--danger); border-color: var(--danger); }
.stage.skipped::before, .stage.not_run::before { background: var(--surface); }
.stage:last-child { border-left-color: transparent; }
.stage-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.stage-row b { font-weight: 600; font-size: 14px; }
.finding { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--line-strong); border-radius: var(--r-lg); padding: 14px 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.finding.sev-high { border-left-color: var(--danger); }
.finding.sev-medium { border-left-color: var(--heuristic); }
.finding.sev-info { border-left-color: var(--primary); }
.finding-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.finding-head h3 { font-size: 15.5px; }
#docFindings .finding { box-shadow: none; }
table.evidence { font-size: 13.5px; }
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.checks li { display: grid; grid-template-columns: auto auto 1fr; gap: 8px; align-items: baseline; }
.checks li b { font-weight: 600; white-space: nowrap; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 44px 1fr; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.timeline li:first-child { border-top: 0; }
.timeline .vnum { font: 600 15px/1.6 var(--display); color: var(--muted); }
.timeline li.current .vnum { color: var(--primary); }
.ledger-cell.as-btn { all: unset; box-sizing: border-box; cursor: pointer; padding: 18px 20px 16px; border-left: 1px solid var(--line); display: block; }
.ledger-cell.as-btn:first-child { border-left: 0; }
.ledger-cell.as-btn:hover { background: #F8FAFC; }
.ledger-cell.as-btn[aria-pressed="true"] { box-shadow: inset 0 -3px 0 var(--primary); }
.ledger-cell.as-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
details.panel > summary { cursor: pointer; }

/* ---------------------------------------------------------------- chat */
.chat { display: flex; flex-direction: column; gap: 12px; max-height: 56vh; min-height: 120px; overflow-y: auto; padding: 4px 2px 8px; }
.msg { max-width: min(680px, 88%); padding: 10px 14px; border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: #F1F4F7; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.cite { margin-top: 8px; padding: 6px 10px; border-left: 3px solid var(--primary); background: var(--surface); border-radius: 0 4px 4px 0; font-size: 13px; white-space: normal; }
.composer { display: flex; gap: 8px; margin-top: 12px; }
.composer input { flex: 1; min-width: 0; }

/* ---------------------------------------------------------------- empty / loading / error */
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty h3 { color: var(--text); margin-bottom: 6px; }
.empty p { max-width: 52ch; margin: 0 auto 14px; }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 24px 4px; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--primary); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
mark { background: #FFE8A3; color: inherit; padding: 0 1px; border-radius: 2px; }
.diff-add { color: var(--genuine); }
.diff-del { color: var(--danger); }

/* ---------------------------------------------------------------- upload dialog */
dialog { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); border: 0; border-radius: var(--r-lg); padding: 0; box-shadow: 0 20px 60px rgba(15, 22, 32, .3); color: var(--text); }
dialog::backdrop { background: rgba(15, 22, 32, .5); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 4px 22px; margin: 0; }
#uploadBody { padding: 8px 22px 22px; }
.drop { display: grid; justify-items: center; gap: 8px; text-align: center; padding: 26px 16px; border: 2px dashed var(--line-strong); border-radius: var(--r-lg); background: #F8FAFC; transition: border-color .15s, background .15s; }
.drop.over { border-color: var(--primary); background: var(--primary-soft); }
.drop .ic { width: 28px; height: 28px; color: var(--primary); }
.drop p { margin: 0; }
.file-card { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); margin-top: 14px; }
.file-card .ic { width: 24px; height: 24px; color: var(--primary); }
.file-card b { display: block; overflow-wrap: anywhere; font-weight: 600; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.rules { font-size: 13px; color: var(--muted); margin: 12px 0 0; padding-left: 18px; }

/* ---------------------------------------------------------------- toasts */
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 60; max-width: min(420px, calc(100vw - 32px)); }
.toast { padding: 10px 14px; border-radius: var(--r); background: var(--ink); color: #fff; box-shadow: 0 6px 20px rgba(15, 22, 32, .25); font-size: 14px; }
.toast.bad { background: #8E1F18; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1080px) {
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; background: var(--paper); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(280px, 84vw); z-index: 30; transform: translateX(-102%); transition: transform .2s ease; }
  .sidebar.open { transform: none; }
  .icon-btn.menu-btn { display: inline-grid; }
  .topbar { padding: 10px 16px; }
  main { padding: 20px 16px 40px; }
  .ledger { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ledger-cell:nth-child(3) { border-left: 0; }
  .ledger-cell:nth-child(n+3) { border-top: 1px solid var(--line); }
}
@media (max-width: 640px) {
  h1 { font-size: 22px; }
  .topbar .btn.primary span { display: none; }
  .topbar .btn.primary { padding: 7px 10px; }
  .panel:not(.flush) { padding: 16px; }
  /* tables become stacked rows */
  table.stack-sm thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.stack-sm, table.stack-sm tbody, table.stack-sm tr, table.stack-sm td { display: block; width: 100%; }
  table.stack-sm tr { border-bottom: 1px solid var(--line); padding: 10px 4px; }
  table.stack-sm td { border: 0; padding: 3px 12px; }
  table.stack-sm td[data-label]::before { content: attr(data-label); display: inline-block; min-width: 92px; color: var(--muted); font-size: 12.5px; }
  table.stack-sm td.primary-cell::before { display: none; }
  .bar-row { grid-template-columns: 90px minmax(0, 1fr) 30px; }
  .checks li { grid-template-columns: auto 1fr; }
  .checks li span { grid-column: 1 / -1; }
  .composer { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
