/* Stage 17b — the staff console design system.
 *
 * Rules, in order of how often they get broken:
 *   1. Every class a staff view uses is defined here. test/stage17b-console.test.ts fails otherwise.
 *   2. No `style="…"` in views except to set a custom property (e.g. style="--swatch:#0b2545").
 *   3. Colour is never the only signal: a badge has words, a danger row has an icon or a label.
 *   4. Focus is visible everywhere (two rings), targets are at least 36px on desktop, 44px on touch.
 *   5. The console is unbranded — the tenant is data on the page, not the page's brand.
 *
 * Layout: a fixed left sidebar (collapsible below 900px) + a top bar with search, then `.page`.
 */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --ink: #111827;
  --ink-muted: #5b6472;
  --ink-faint: #8b93a1;
  --line: #e3e6eb;
  --line-strong: #c9ced6;
  --surface: #ffffff;
  --surface-muted: #f4f5f7;
  --surface-sunken: #eceef2;
  --canvas: #f7f8fa;
  --sidebar: #16202f;
  --sidebar-ink: #c7cfdb;
  --sidebar-ink-strong: #ffffff;
  --sidebar-active: #243248;
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --on-accent: #ffffff;
  --accent-tint: #e8effd;
  --danger: #b42318;
  --danger-tint: #fdecea;
  --success: #067647;
  --success-tint: #e6f5ec;
  --warning: #93500a;
  --warning-tint: #fdf1dc;
  --info: #175cd3;
  --info-tint: #e7f0fd;
  --focus-outer: #1d4ed8;
  --focus-inner: #ffffff;
  --radius: 8px;
  --radius-sm: 5px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sidebar-w: 232px;
  --topbar-h: 52px;
}

html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 14px/1.5 var(--font); color: var(--ink); background: var(--canvas); }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 14px; } h4 { font-size: 13px; color: var(--ink-muted); text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0 0 .75em; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--surface-sunken); padding: 1px 5px; border-radius: 4px; }
pre { font-family: var(--mono); font-size: 12px; background: var(--surface-sunken); padding: 12px; border-radius: var(--radius-sm); overflow: auto; margin: 0; }
pre.export { white-space: pre-wrap; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus-outer); outline-offset: 2px; box-shadow: 0 0 0 2px var(--focus-inner); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 8px; top: -40px; background: var(--surface); color: var(--ink); padding: 8px 12px; border-radius: var(--radius-sm); z-index: 100; }
.skip-link:focus { top: 8px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 14px 16px; color: var(--sidebar-ink-strong); text-decoration: none; font-weight: 700; font-size: 15px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar .brand .tag { background: rgba(255,255,255,.12); color: var(--sidebar-ink); }
.sidebar nav { padding: 8px; flex: 1; }
.sidebar .group { margin: 6px 0 2px; padding: 4px 10px 2px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); }
.sidebar nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; border-radius: var(--radius-sm); color: var(--sidebar-ink); text-decoration: none; font-weight: 500; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: var(--sidebar-ink-strong); }
.sidebar nav a.on { background: var(--sidebar-active); color: var(--sidebar-ink-strong); }
.sidebar nav a .count { font-size: 11px; font-weight: 700; background: rgba(255,255,255,.14); color: var(--sidebar-ink-strong); border-radius: 999px; padding: 1px 7px; min-width: 20px; text-align: center; }
.sidebar nav a .count.warn { background: var(--warning); }
.sidebar nav a .count.danger { background: var(--danger); }
.sidebar .me { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; }
.sidebar .me a { color: var(--sidebar-ink-strong); text-decoration: none; font-weight: 600; }
.sidebar .me .role { display: block; color: var(--ink-faint); font-size: 12px; }
.sidebar .me form { margin-top: 6px; }
.content { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: var(--topbar-h); display: flex; align-items: center; gap: 12px; padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar .menu-btn { display: none; }
.topbar .search { flex: 1; max-width: 560px; display: flex; }
.topbar .search input { width: 100%; height: 36px; padding: 0 12px 0 34px; border: 1px solid var(--line-strong); border-radius: 999px; font: inherit; background: var(--surface-muted) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%235b6472' stroke-width='2'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='m11 11 3.5 3.5'/%3E%3C/svg%3E") no-repeat 11px center; }
.topbar .search input:focus { background-color: var(--surface); }
.topbar .spacer { flex: 1; }
.topbar .env { font-size: 12px; color: var(--ink-muted); }
.page { padding: 20px 24px 48px; max-width: 1400px; width: 100%; }
.page.narrow { max-width: 760px; }
.page.medium { max-width: 1040px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w); height: auto; transform: translateX(-100%); transition: transform .15s ease; z-index: 30; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vw rgba(0,0,0,.35); }
  .topbar .menu-btn { display: inline-flex; }
  .page { padding: 16px; }
  .topbar .env { display: none; }
}

/* ---------- page head ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head .titles { min-width: 0; }
.page-head .context { color: var(--ink-muted); font-size: 13px; margin-top: 2px; }
.page-head .actions { margin: 0; }
.crumbs { font-size: 13px; color: var(--ink-muted); margin-bottom: 8px; }
.crumbs a { color: inherit; }
.crumbs span { margin: 0 6px; color: var(--ink-faint); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 6px 14px; border-radius: var(--radius-sm); border: 1px solid var(--accent); background: var(--accent); color: var(--on-accent); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn.secondary { background: var(--surface); color: var(--accent); }
.btn.secondary:hover { background: var(--accent-tint); }
.btn.ghost { background: transparent; border-color: var(--line-strong); color: var(--ink); }
.btn.ghost:hover { background: var(--surface-muted); }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn.danger.secondary { background: var(--surface); color: var(--danger); }
.btn.small { min-height: 30px; padding: 3px 10px; font-size: 13px; }
.btn[disabled], .btn.disabled { opacity: .5; cursor: not-allowed; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; text-decoration: underline; }
.linkbtn.danger { color: var(--danger); }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.actions.end { justify-content: flex-end; }
.inline-form { display: inline; }

/* ---------- cards, panels, grids ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.card + .card, .panel + .panel { margin-top: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.panel > h2, .panel > h3, .card > h2, .card > h3 { margin-bottom: 10px; }
.panel.warn { border-color: #efc27a; background: var(--warning-tint); }
.panel.danger { border-color: #efa39b; background: var(--danger-tint); }
.panel.info { border-color: #b7cdf6; background: var(--info-tint); }
.panel.muted { background: var(--surface-muted); }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid.form { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 20px; }
.span { grid-column: 1 / -1; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.top { align-items: flex-start; }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }

/* ---------- stat tiles (dashboard) ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.tile { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; text-decoration: none; color: inherit; box-shadow: var(--shadow); border-left-width: 4px; }
.tile:hover { border-color: var(--line-strong); color: inherit; }
.tile .n { font-size: 26px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile .l { font-size: 13px; color: var(--ink-muted); margin-top: 2px; }
.tile .h { font-size: 12px; color: var(--ink-faint); margin-top: 4px; }
.tile.warn { border-left-color: var(--warning); } .tile.warn .n { color: var(--warning); }
.tile.danger { border-left-color: var(--danger); } .tile.danger .n { color: var(--danger); }
.tile.zero { border-left-color: var(--line); } .tile.zero .n { color: var(--ink-faint); }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.kpi { background: var(--surface-muted); border-radius: var(--radius); padding: 10px 12px; }
.kpi .n { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 12px; color: var(--ink-muted); }

/* ---------- key/value ---------- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; align-items: baseline; }
.kv dt { color: var(--ink-muted); font-size: 13px; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.kv.tight { gap: 3px 12px; }
.kv-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 8px 24px; }

/* ---------- tables ---------- */
.table-wrap { position: relative; overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); } /* relative: visually-hidden labels inside wide tables are absolutely positioned and would otherwise widen the page */
.table-wrap.scrollable { max-height: 360px; overflow-y: auto; } /* a long log (ledger journal) scrolls inside its card */
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-muted); background: var(--surface-muted); white-space: nowrap; position: sticky; top: 0; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr.row-link { cursor: pointer; }
table.data tbody tr.row-link:hover { background: var(--accent-tint); }
table.data tbody tr.selected { background: var(--accent-tint); }
table.data tr.danger td { background: var(--danger-tint); }
table.data tr.warn td { background: var(--warning-tint); }
table.data tr.muted td { color: var(--ink-muted); }
table.data th a { color: inherit; text-decoration: none; }
table.data th a:hover { text-decoration: underline; }
table.data th.sorted { color: var(--ink); }
table.data tfoot td { font-weight: 600; background: var(--surface-muted); }
table.data.compact th, table.data.compact td { padding: 5px 8px; font-size: 13px; }
table.data .nowrap, .nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 28px 16px; text-align: center; color: var(--ink-muted); }
.empty strong { display: block; color: var(--ink); margin-bottom: 4px; }
.pager { display: flex; align-items: center; gap: 12px; margin-top: 12px; font-size: 13px; color: var(--ink-muted); }
.pager .btn { min-height: 30px; }

/* ---------- badges ---------- */
.badge, .status, .pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 650; white-space: nowrap; background: var(--surface-sunken); color: var(--ink); line-height: 1.6; vertical-align: middle; }
.badge.ok, .pill.ok, .pill.success, .pill.on { background: var(--success-tint); color: var(--success); }
.badge.warn, .pill.warn { background: var(--warning-tint); color: var(--warning); }
.badge.bad, .badge.danger, .pill.bad, .pill.off { background: var(--danger-tint); color: var(--danger); }
.badge.info, .pill.info { background: var(--info-tint); color: var(--info); }
.badge.muted, .pill.muted { background: var(--surface-sunken); color: var(--ink-muted); }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--surface-sunken); color: var(--ink-muted); font-weight: 600; vertical-align: middle; }
/* application status */
.s-submitted { background: var(--info-tint); color: var(--info); }
.s-in_review, .s-manual_review { background: var(--warning-tint); color: var(--warning); }
.s-approved, .s-offer_sent, .s-agreement_signed, .s-accepted { background: var(--success-tint); color: var(--success); }
.s-declined { background: var(--danger-tint); color: var(--danger); }
.s-withdrawn { background: var(--surface-sunken); color: var(--ink-muted); }
/* bureau band and checks */
.band-A, .band-B { background: var(--success-tint); color: var(--success); }
.band-C { background: var(--warning-tint); color: var(--warning); }
.band-D, .band-E { background: var(--danger-tint); color: var(--danger); }
.chk-pass { background: var(--success-tint); color: var(--success); }
.chk-fail { background: var(--danger-tint); color: var(--danger); }
.chk-flag { background: var(--warning-tint); color: var(--warning); }
.chk-skipped, .chk-info { background: var(--surface-sunken); color: var(--ink-muted); }
/* identity / fraud / mandate / schedule / loan / notification / disbursement / task */
.id-approved, .fr-pass, .md-active, .rs-collected, .rs-paid_out, .ls-active, .ls-completed, .ns-sent, .ns-delivered, .ds-settled, .ts-done { background: var(--success-tint); color: var(--success); }
.id-pending, .fr-review, .md-pending_submission, .md-submitted, .rs-submitted, .rs-scheduled, .ls-awaiting_mandate, .ls-awaiting_disbursement, .ns-queued, .ds-requested, .ds-approved, .ds-sent, .ts-open { background: var(--info-tint); color: var(--info); }
.id-rejected, .fr-block, .md-failed, .md-cancelled, .md-expired, .rs-failed, .rs-cancelled, .ls-in_arrears, .ls-defaulted, .ls-written_off, .ns-bounced, .ns-complained, .ns-failed, .ds-failed, .ds-returned, .ds-cancelled { background: var(--danger-tint); color: var(--danger); }
.id-unavailable, .fr-unavailable, .md-consumed, .md-replaced, .rs-flagged_for_review, .ls-cancelled, .ns-suppressed { background: var(--warning-tint); color: var(--warning); }

/* ---------- forms ---------- */
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.field .help, .help { font-size: 12px; color: var(--ink-muted); margin-top: 3px; }
.help.inline { display: inline; margin: 0; }
input[type=text], input[type=email], input[type=url], input[type=number], input[type=password], input[type=date], input[type=search], select, textarea { width: 100%; min-height: 36px; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font: inherit; background: var(--surface); color: var(--ink); }
textarea { min-height: 80px; resize: vertical; }
select { padding-right: 28px; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; vertical-align: -3px; margin-right: 6px; }
.check { display: flex; align-items: center; gap: 6px; font-weight: 500; }
fieldset { border: 0; padding: 0; margin: 0 0 16px; min-width: 0; }
legend { font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-muted); margin-bottom: 8px; padding: 0; }
form.card { max-width: 900px; }
.color-row { display: flex; gap: 8px; align-items: center; }
.color-row input[type=color] { width: 44px; height: 36px; padding: 0; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: none; }
.swatch { display: inline-block; width: 18px; height: 18px; border-radius: 4px; border: 1px solid rgba(0,0,0,.15); vertical-align: middle; margin-right: 6px; background: var(--swatch, transparent); }
.logo-preview { max-height: 40px; max-width: 160px; vertical-align: middle; }
.filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.filters > div { min-width: 140px; }
.filters .wide { flex: 1; min-width: 220px; }
.filters label { margin-bottom: 3px; font-size: 12px; }
.filters select, .filters input { min-height: 34px; }
.filters .count { margin-left: auto; color: var(--ink-muted); font-size: 13px; align-self: center; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line-strong); font-size: 13px; color: var(--ink); text-decoration: none; }
.chip.on { background: var(--accent-tint); border-color: var(--accent); color: var(--accent); }
.chip .x { color: var(--ink-faint); }
.inline-fields { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-fields select, .inline-fields input { width: auto; }

/* ---------- messages ---------- */
.flash, .errors, .notice { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; border: 1px solid; }
.flash { background: var(--success-tint); border-color: #a9dcbf; color: var(--success); }
.errors { background: var(--danger-tint); border-color: #efa39b; color: var(--danger); }
.errors ul { margin: 4px 0 0 18px; padding: 0; }
.notice { background: var(--info-tint); border-color: #b7cdf6; color: var(--info); }
.notice.warn { background: var(--warning-tint); border-color: #efc27a; color: var(--warning); }
.warn { color: var(--warning); } .bad { color: var(--danger); } .ok { color: var(--success); } .muted { color: var(--ink-muted); } .small { font-size: 12.5px; }
.callout { border-left: 4px solid var(--accent); background: var(--accent-tint); padding: 10px 14px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin-bottom: 12px; }
.callout.warn { border-color: var(--warning); background: var(--warning-tint); }
.callout.danger { border-color: var(--danger); background: var(--danger-tint); }
.secret { font-family: var(--mono); font-size: 18px; letter-spacing: .08em; background: var(--surface-sunken); padding: 8px 12px; border-radius: var(--radius-sm); display: inline-block; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 9px 12px; color: var(--ink-muted); text-decoration: none; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a.on, .tabs a[aria-selected=true] { color: var(--accent); border-bottom-color: var(--accent); }
.tabs a .count { font-size: 11px; background: var(--surface-sunken); color: var(--ink-muted); border-radius: 999px; padding: 0 6px; margin-left: 4px; }
.tabs a .count.warn { background: var(--warning-tint); color: var(--warning); }
.tabs a .count.danger { background: var(--danger-tint); color: var(--danger); }
.tab-panel[hidden] { display: none; }
.js .tab-panel { display: none; }
.js .tab-panel.on { display: block; }
.no-js .tab-panel > h2:first-child { margin-top: 24px; }

/* ---------- record header (application page) ---------- */
.record-head { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 16px; display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.record-head .who { min-width: 0; flex: 1; }
.record-head .who h1 { font-size: 20px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.record-head .who .sub { color: var(--ink-muted); font-size: 13px; margin-top: 2px; }
.record-head .facts { display: flex; gap: 18px; flex-wrap: wrap; }
.record-head .fact { font-size: 12px; color: var(--ink-muted); }
.record-head .fact strong { display: block; font-size: 15px; color: var(--ink); font-variant-numeric: tabular-nums; }
.record-head .assign { display: flex; gap: 6px; align-items: center; }
.record-head .assign select { min-height: 32px; width: auto; }

/* ---------- timeline / notes / tasks ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline .ev { display: grid; grid-template-columns: 150px 1fr; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.timeline .ev:last-child { border-bottom: 0; }
.timeline .ev.latest { background: var(--accent-tint); margin: 0 -8px; padding: 8px; border-radius: var(--radius-sm); }
.timeline .when { color: var(--ink-muted); font-size: 12px; font-family: var(--mono); }
.timeline .who { color: var(--ink-muted); font-size: 12px; }
.note { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; background: var(--surface); }
.note + .note { margin-top: 8px; }
.note.pinned { border-color: #efc27a; background: var(--warning-tint); }
.note .meta { font-size: 12px; color: var(--ink-muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.note .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.task { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start; padding: 8px 0; border-bottom: 1px solid var(--line); }
.task:last-child { border-bottom: 0; }
.task .title { font-weight: 600; }
.task .meta { font-size: 12px; color: var(--ink-muted); }
.task.done .title { text-decoration: line-through; color: var(--ink-muted); }
.task.overdue .meta { color: var(--danger); font-weight: 600; }
.thread { display: flex; flex-direction: column; gap: 10px; }
.message { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; background: var(--surface); max-width: 720px; }
.message.from-us { border-color: #b7cdf6; background: var(--info-tint); align-self: flex-end; }
.message.system { background: var(--surface-muted); font-size: 13px; color: var(--ink-muted); }
.message .who { font-size: 12px; color: var(--ink-muted); margin-bottom: 4px; }
.message .body { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- misc ---------- */
.matrix td.yes { background: var(--success-tint); color: var(--success); text-align: center; font-weight: 700; }
.matrix td.no { color: var(--ink-faint); text-align: center; }
.progress-bar { height: 8px; background: var(--surface-sunken); border-radius: 999px; overflow: hidden; }
.progress-bar > span { display: block; height: 100%; background: var(--accent); width: var(--pct, 0%); }
.doc-list { list-style: none; margin: 0; padding: 0; }
.doc-list li { display: flex; gap: 10px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.doc-list li:last-child { border-bottom: 0; }
.login-box { max-width: 380px; margin: 60px auto; }
.login-box .card { padding: 24px; }
.login-box h1 { font-size: 20px; margin-bottom: 4px; }
.login-box .sub { color: var(--ink-muted); font-size: 13px; margin-bottom: 16px; }
.qr-secret { display: inline-block; font-family: var(--mono); font-size: 14px; padding: 6px 10px; background: var(--surface-sunken); border-radius: var(--radius-sm); letter-spacing: .05em; }
details.disclosure > summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; display: inline-block; vertical-align: bottom; }
.result { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.result:hover { background: var(--accent-tint); }
.result:last-child { border-bottom: 0; }
.result .kind { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-faint); width: 80px; }
.result .title { font-weight: 600; }
.result .sub { color: var(--ink-muted); font-size: 13px; }
.result .why { margin-left: auto; font-size: 12px; color: var(--ink-faint); }

@media print {
  .sidebar, .topbar, .actions, .btn, .tabs, .skip-link { display: none !important; }
  .shell { display: block; }
  .page { padding: 0; max-width: none; }
  .js .tab-panel { display: block; }
  .card, .panel, .table-wrap { box-shadow: none; border-color: #999; break-inside: avoid; }
}

/* ---------- Stage 23: the phone shell (/admin/m) ---------- */
.m-body { background: var(--canvas); }
.m-bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 12px; padding-top: env(safe-area-inset-top); background: var(--sidebar); color: var(--sidebar-ink-strong); }
.m-brand { font-weight: 700; letter-spacing: .01em; }
.m-back { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; margin-left: -8px; border-radius: 999px; color: var(--sidebar-ink-strong); text-decoration: none; font-size: 26px; line-height: 1; }
.m-back:hover, .m-bar-link:hover { background: var(--sidebar-active); }
.m-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.m-bar-link { color: var(--sidebar-ink); text-decoration: none; padding: 6px 10px; border-radius: var(--radius-sm); font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }
.m-bar-link .count { background: var(--danger); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 12px; font-weight: 700; }
.m-page { padding: 12px 12px 32px; max-width: 720px; margin: 0 auto; }
.m-page .card { padding: 12px 14px; }
.m-page .card + .card, .m-page .card + section, .m-page section + .card { margin-top: 10px; }
.m-page h2 { font-size: 15px; margin: 0 0 8px; }
.m-h { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-muted); margin: 18px 0 8px; }
.m-foot { text-align: center; color: var(--ink-muted); font-size: 12px; padding: 12px 12px calc(20px + env(safe-area-inset-bottom)); }
.m-list { list-style: none; margin: 0; padding: 0; }
.m-list li + li { margin-top: 8px; }
.m-item { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; color: inherit; text-decoration: none; box-shadow: var(--shadow); }
.m-item:active { background: var(--accent-tint); }
.m-item-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 600; }
.m-item-sub { display: block; color: var(--ink-muted); font-size: 13px; margin-top: 2px; }
.m-item-needs { display: block; margin-top: 6px; }
.m-unread .m-item { border-left: 4px solid var(--accent); }
.m-push { border-left: 4px solid var(--accent); }
.m-head .m-amount { font-size: 18px; margin: 8px 0 2px; }
.m-act { border-color: var(--accent); }
.m-btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.m-btns .btn { flex: 1 1 auto; min-height: 44px; }
.m-btns input[type="text"] { flex: 1 1 120px; }
.m-checks { list-style: none; margin: 0 0 8px; padding: 0; }
.m-checks li { padding: 4px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.m-checks li:last-child { border-bottom: 0; }
.m-doc { display: flex; flex-direction: column; gap: 3px; min-width: 0; width: 100%; }
.m-docs li { align-items: stretch; }
.m-timeline .ev { grid-template-columns: 1fr; gap: 2px; }
.m-page .kv { grid-template-columns: 90px 1fr; }
