/* The Cockpit: an immigration officer's workstation for the case management system of the future.
   Dark by default (it is a cockpit), light on request. Public Sans for working text, IBM Plex Mono for
   identifiers, dates and counts, Libre Caslon Display for the masthead only, to tie the page to the rest of
   administrativerecord.org. Status colours carry meaning everywhere: green met/verified/clear, amber at
   risk/needs review, red breached/contradicted/hit, blue the accent, violet the AI assistant. */

:root {
  --bg: #0b0e14; --surface: #12161e; --surface-2: #181d27; --surface-3: #1f2532;
  --ink: #e8ecf2; --ink-2: #b4bdcb; --muted: #7b869a; --faint: #4b5567;
  --rule: #222a37; --rule-strong: #2f394a;
  --accent: #6ea8ff; --accent-ink: #0b0e14; --accent-soft: rgba(110,168,255,.12);
  --ok: #3ccf91; --ok-soft: rgba(60,207,145,.14);
  --warn: #f2b544; --warn-soft: rgba(242,181,68,.14);
  --bad: #ff6b6b; --bad-soft: rgba(255,107,107,.14);
  --info: #7fd1e8; --info-soft: rgba(127,209,232,.14);
  --ai: #b394f5; --ai-soft: rgba(179,148,245,.14);
  --lane-invited: #ffd166; --lane-premium: #6ea8ff; --lane-expedite: #ff8fab; --lane-standard: #8a94a6;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 10px 30px rgba(0,0,0,.35);
  --font-display: "Libre Caslon Display", Georgia, serif;
  --font-sans: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --radius: 10px; --radius-sm: 6px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f6f9; --surface: #ffffff; --surface-2: #f7f9fc; --surface-3: #eef2f7;
  --ink: #141820; --ink-2: #3f4858; --muted: #6c7484; --faint: #a7afbd;
  --rule: #dfe3ea; --rule-strong: #c9cfd9;
  --accent: #1d4ed8; --accent-ink: #ffffff; --accent-soft: rgba(29,78,216,.09);
  --ok: #138a5a; --ok-soft: rgba(19,138,90,.11);
  --warn: #b26b00; --warn-soft: rgba(178,107,0,.12);
  --bad: #c92a2a; --bad-soft: rgba(201,42,42,.10);
  --info: #0b7285; --info-soft: rgba(11,114,133,.10);
  --ai: #6741d9; --ai-soft: rgba(103,65,217,.10);
  --lane-invited: #b37d00; --lane-premium: #1d4ed8; --lane-expedite: #c2255c; --lane-standard: #6c7484;
  --shadow: 0 1px 2px rgba(20,24,32,.06), 0 8px 24px rgba(20,24,32,.06);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 var(--font-sans); -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button { font: inherit; color: inherit; }
code, .mono { font-family: var(--font-mono); font-size: 12.5px; letter-spacing: .01em; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 20px; }
h3 { font-size: 15px; }
h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); }
.ink2 { color: var(--ink-2); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: grid; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--rule); background: var(--surface);
  display: flex; flex-direction: column; padding: 18px 14px; gap: 18px;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 0 4px; }
.brand .mark { width: 34px; height: 34px; border-radius: 9px; background: var(--accent-soft); display: grid; place-items: center; flex: none; }
.brand .mark svg { width: 22px; height: 22px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.brandtext { display: grid; gap: 2px; min-width: 0; }
.brand .sys { font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--ink); }
.brand .env { font-family: var(--font-mono); font-size: 10px; color: var(--muted); display: flex; align-items: center; gap: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand .env i { width: 6px; height: 6px; border-radius: 50%; background: var(--lane-invited); box-shadow: 0 0 0 3px color-mix(in srgb, var(--lane-invited) 25%, transparent); flex: none; }
.statusstrip { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.statusstrip .cell { padding: 7px 9px; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--rule); display: grid; gap: 1px; }
.statusstrip .cell b { font-family: var(--font-mono); font-size: 15px; font-weight: 500; line-height: 1.1; }
.statusstrip .cell span { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.statusstrip .cell.warn b { color: var(--warn); } .statusstrip .cell.bad b { color: var(--bad); } .statusstrip .cell.ok b { color: var(--ok); }
.nav { display: grid; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--ink-2); font-weight: 500;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav a .n { margin-left: auto; font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.nav svg { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.side .foot { margin-top: auto; display: grid; gap: 10px; font-size: 12px; color: var(--muted); padding: 0 6px; }
.persona { display: grid; gap: 4px; }
.persona select { width: 100%; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 10px 24px; border-bottom: 1px solid var(--rule); background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
}
.search { position: relative; flex: 1; max-width: 640px; }
.search input[type="search"] {
  width: 100%; padding: 8px 12px 8px 36px; border-radius: 8px; border: 1px solid var(--rule-strong);
  background: var(--surface); color: var(--ink); font: inherit;
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.search svg { position: absolute; left: 11px; top: 9px; width: 16px; height: 16px; stroke: var(--muted); fill: none; stroke-width: 1.8; }
.search .results {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--rule-strong);
  border-radius: 10px; box-shadow: var(--shadow); max-height: 60vh; overflow: auto; display: none;
}
.search .results.open { display: block; }
.search .results a { display: grid; grid-template-columns: 110px 1fr auto; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--rule); color: var(--ink); align-items: center; }
.search .results a:last-child { border-bottom: 0; }
.search .results a:hover, .search .results a.hi { background: var(--surface-2); text-decoration: none; }
.search .results .k { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.asof { font-family: var(--font-mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
.content { padding: 24px; display: grid; gap: 20px; align-content: start; }
.content.wide { max-width: none; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 8px; border: 1px solid var(--rule-strong);
  background: var(--surface-2); color: var(--ink); cursor: pointer; font-weight: 500; font-size: 13px; line-height: 1.2; white-space: nowrap;
}
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.btn.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.btn.bad { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.btn.ai { background: var(--ai-soft); border-color: transparent; color: var(--ai); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.xs { padding: 2px 7px; font-size: 11px; border-radius: 6px; }
.btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
select, input[type="text"], input[type="search"], textarea {
  padding: 6px 10px; border-radius: 8px; border: 1px solid var(--rule-strong); background: var(--surface); color: var(--ink); font: inherit; font-size: 13px;
}
select:focus, input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { width: 100%; min-height: 90px; resize: vertical; line-height: 1.45; }
input[type="range"] { accent-color: var(--accent); }
label.field { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
label.field > span:first-child { text-transform: uppercase; letter-spacing: .06em; font-size: 10.5px; font-weight: 600; }
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: var(--ink-2); }
.toggle input { accent-color: var(--accent); width: 15px; height: 15px; }
.seg { display: inline-flex; border: 1px solid var(--rule-strong); border-radius: 8px; overflow: hidden; }
.seg button { padding: 6px 11px; background: transparent; border: 0; border-right: 1px solid var(--rule-strong); cursor: pointer; font-size: 12.5px; color: var(--ink-2); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
  display: grid; gap: 12px; align-content: start; min-width: 0;
}
.card.flat { box-shadow: none; }
.card > * { min-width: 0; }
.card > header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card > header h3 { display: flex; align-items: center; gap: 8px; }
.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.c6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.grid.cockpit { grid-template-columns: 320px minmax(0, 1fr) 380px; }
.grid.cockpit > * { min-width: 0; }
.span2 { grid-column: span 2; }
.span3 { grid-column: span 3; }

.kpi { display: grid; gap: 4px; }
.kpi .v { font-family: var(--font-mono); font-size: 26px; font-weight: 500; letter-spacing: -.02em; line-height: 1.1; }
.kpi .v small { font-size: 13px; color: var(--muted); margin-left: 4px; font-weight: 400; }
.kpi .l { font-size: 12px; color: var(--muted); }
.kpi .d { font-size: 12px; color: var(--ink-2); }
.delta.ok { color: var(--ok); } .delta.bad { color: var(--bad); } .delta.warn { color: var(--warn); }

.masthead { display: grid; gap: 10px; padding: 8px 0 4px; }
.masthead h1 { font: 400 clamp(30px, 4vw, 44px)/1.05 var(--font-display); letter-spacing: 0; }
.masthead .lede { max-width: 820px; color: var(--ink-2); font-size: 15px; }
.eyebrow { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; }

/* ---------- chips and badges ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: var(--surface-3); color: var(--ink-2); border: 1px solid transparent; white-space: nowrap; line-height: 1.5;
}
.chip.mono { font-family: var(--font-mono); font-weight: 500; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.info { background: var(--info-soft); color: var(--info); }
.chip.ai { background: var(--ai-soft); color: var(--ai); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.outline { background: transparent; border-color: var(--rule-strong); }
.chip.lane-invited { background: color-mix(in srgb, var(--lane-invited) 18%, transparent); color: var(--lane-invited); }
.chip.lane-premium { background: color-mix(in srgb, var(--lane-premium) 18%, transparent); color: var(--lane-premium); }
.chip.lane-expedite { background: color-mix(in srgb, var(--lane-expedite) 18%, transparent); color: var(--lane-expedite); }
.chip.lane-standard { background: color-mix(in srgb, var(--lane-standard) 18%, transparent); color: var(--lane-standard); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }
.src { font-size: 10.5px; color: var(--muted); font-family: var(--font-mono); background: var(--surface-3); padding: 1px 6px; border-radius: 4px; }
.verif { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 5px; }
.verif.verified { background: var(--ok-soft); color: var(--ok); }
.verif.corroborated { background: var(--info-soft); color: var(--info); }
.verif.unverifiable { background: var(--warn-soft); color: var(--warn); }
.verif.contradicted { background: var(--bad-soft); color: var(--bad); }
.verif.needs_review { background: var(--warn-soft); color: var(--warn); }
.verif.pending_interview { background: var(--surface-3); color: var(--ink-2); }

/* ---------- tables ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; padding: 6px 10px; border-bottom: 1px solid var(--rule-strong); white-space: nowrap; }
.tbl th.sortable { cursor: pointer; }
.tbl th.sortable:hover { color: var(--ink); }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover { background: var(--surface-2); }
.tbl tbody tr.sel { background: var(--accent-soft); }
.tbl td.num, .tbl th.num { text-align: right; font-family: var(--font-mono); }
.tbl.dense td { padding: 5px 8px; font-size: 12.5px; }
.tbl-wrap { overflow: auto; max-width: 100%; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 5px 14px; font-size: 13px; align-items: baseline; }
.kv dt { color: var(--muted); font-size: 12px; }
.kv dd { margin: 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }

/* ---------- bars, rings, SLA ---------- */
.bar { position: relative; height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.bar > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--accent); }
.bar.ok > i { background: var(--ok); } .bar.warn > i { background: var(--warn); } .bar.bad > i { background: var(--bad); }
.bars { display: grid; gap: 6px; }
.bars .r { display: grid; grid-template-columns: minmax(90px, 160px) 1fr 44px; gap: 10px; align-items: center; font-size: 12.5px; }
.bars .r .lbl { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .r .n { font-family: var(--font-mono); text-align: right; color: var(--muted); font-size: 12px; }
.bars .r.click { cursor: pointer; } .bars .r.click:hover .lbl { color: var(--accent); }
.sla { display: inline-grid; grid-template-columns: auto 1fr; gap: 2px 8px; align-items: center; min-width: 150px; }
.sla .bar { width: 100%; }
.sla .t { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); grid-column: 1 / -1; }
.ring { display: grid; place-items: center; position: relative; }
.ring svg { transform: rotate(-90deg); }
.ring .c { position: absolute; text-align: center; font-family: var(--font-mono); line-height: 1.1; }
.ring .c b { font-size: 20px; font-weight: 500; display: block; }
.ring .c span { font-size: 10.5px; color: var(--muted); }
svg.chart { width: 100%; height: auto; display: block; font-family: var(--font-mono); font-size: 10.5px; }
svg.chart text { fill: var(--muted); }
svg.chart .axis { stroke: var(--rule-strong); }
svg.chart .grid { stroke: var(--rule); }
svg.chart .pt { cursor: pointer; stroke: var(--bg); stroke-width: 1; }
svg.chart .pt:hover { stroke: var(--ink); stroke-width: 2; }
.legend { display: flex; flex-wrap: wrap; gap: 10px 14px; font-size: 12px; color: var(--ink-2); }
.legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; margin-right: 6px; vertical-align: -1px; }

/* ---------- matrix ---------- */
.matrix { display: grid; gap: 6px; }
.mrow { display: grid; grid-template-columns: 76px minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 9px 10px; border: 1px solid var(--rule); border-radius: 8px; background: var(--surface-2); }
.mrow.not_claimed { opacity: .55; }
.mrow .code { font-family: var(--font-mono); font-size: 12px; font-weight: 500; }
.mrow .cite { font-size: 10.5px; color: var(--muted); font-family: var(--font-mono); }
.mrow .lbl { font-size: 12.5px; color: var(--ink-2); }
.mrow .ev { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.evchip { font-family: var(--font-mono); font-size: 10.5px; padding: 1px 6px; border-radius: 4px; background: var(--surface-3); color: var(--ink-2); border-left: 3px solid var(--muted); cursor: pointer; }
.evchip.verified { border-left-color: var(--ok); } .evchip.corroborated { border-left-color: var(--info); }
.evchip.unverifiable, .evchip.needs_review { border-left-color: var(--warn); } .evchip.contradicted { border-left-color: var(--bad); }
.evchip.pending_interview { border-left-color: var(--faint); }
.evchip:hover { background: var(--accent-soft); color: var(--accent); }
.assess { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; }
.assess.met { color: var(--ok); } .assess.needs_review { color: var(--warn); } .assess.not_met { color: var(--bad); } .assess.not_claimed { color: var(--muted); }
.mrow select { padding: 4px 8px; font-size: 12px; }
.threshold { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); border: 1px dashed var(--rule-strong); font-size: 13px; }
.threshold b { font-family: var(--font-mono); font-size: 18px; font-weight: 500; }

/* ---------- timeline ---------- */
.timeline { display: grid; gap: 0; position: relative; }
.timeline .ev { display: grid; grid-template-columns: 128px 14px 1fr; gap: 10px; align-items: start; padding: 6px 0; position: relative; }
.timeline .ev .t { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); padding-top: 2px; }
.timeline .ev .m { width: 14px; display: grid; justify-items: center; }
.timeline .ev .m i { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); margin-top: 5px; border: 2px solid var(--surface); }
.timeline .ev .m::after { content: ""; width: 1px; flex: 1; background: var(--rule); position: absolute; top: 20px; bottom: -6px; }
.timeline .ev:last-child .m::after { display: none; }
.timeline .ev.ok .m i { background: var(--ok); } .timeline .ev.warn .m i { background: var(--warn); } .timeline .ev.bad .m i { background: var(--bad); }
.timeline .ev.accent .m i { background: var(--accent); } .timeline .ev.ai .m i { background: var(--ai); } .timeline .ev.new .m i { box-shadow: 0 0 0 3px var(--accent-soft); }
.timeline .ev .b { font-size: 12.5px; }
.timeline .ev .b .ty { font-family: var(--font-mono); font-weight: 500; font-size: 12px; }
.timeline .ev .b .dt { color: var(--muted); font-size: 11.5px; }

/* ---------- assistant / memo ---------- */
.memo { font-size: 13px; line-height: 1.55; display: grid; gap: 10px; }
.memo h5 { margin: 6px 0 0; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ai); }
.memo p { color: var(--ink-2); }
.memo .cite { font-family: var(--font-mono); font-size: 11px; color: var(--accent); cursor: pointer; }
.memo .cite:hover { text-decoration: underline; }
.memo ul { margin: 0; padding-left: 18px; color: var(--ink-2); }
.memo li { margin: 2px 0; }
.memo blockquote { margin: 0; padding: 8px 12px; border-left: 3px solid var(--ai); background: var(--ai-soft); border-radius: 0 6px 6px 0; color: var(--ink-2); }
.aihead { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--ai); font-weight: 600; text-transform: uppercase; letter-spacing: .07em; }
.letter { white-space: pre-wrap; font-size: 13px; line-height: 1.55; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--rule); border-radius: 8px; padding: 14px 16px; max-height: 50vh; overflow: auto; }

/* ---------- basis footers (legal authority) ---------- */
.basis { display: flex; gap: 10px; align-items: flex-start; font-size: 11.5px; color: var(--muted); padding-top: 10px; border-top: 1px dashed var(--rule); }
.basis svg { width: 13px; height: 13px; flex: none; stroke: var(--muted); fill: none; stroke-width: 1.8; margin-top: 2px; }
.basis b { color: var(--ink-2); font-weight: 600; }
.basis .obj { margin-left: auto; white-space: nowrap; color: var(--accent); cursor: pointer; background: none; border: 0; font-size: 11.5px; padding: 0; }
.basis .obj:hover { text-decoration: underline; }

/* ---------- drawer / modal / toast ---------- */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface); border-left: 1px solid var(--rule-strong);
  box-shadow: -20px 0 60px rgba(0,0,0,.35); z-index: 50; transform: translateX(100%); transition: transform .22s ease; display: flex; flex-direction: column;
}
.drawer.open { transform: none; }
.drawer > header { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--rule); }
.drawer > header h3 { flex: 1; }
.drawer > .body { padding: 18px; overflow: auto; display: grid; gap: 14px; align-content: start; }
.drawer > footer { padding: 12px 18px; border-top: 1px solid var(--rule); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40; display: none; }
.scrim.open { display: block; }
.modal { position: fixed; inset: 0; z-index: 60; display: none; place-items: center; padding: 24px; }
.modal.open { display: grid; }
.modal .box { width: min(760px, 100%); max-height: 90vh; overflow: auto; background: var(--surface); border: 1px solid var(--rule-strong); border-radius: 14px; box-shadow: var(--shadow); display: grid; gap: 14px; padding: 20px; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 20px); opacity: 0; background: var(--ink); color: var(--bg); padding: 9px 14px; border-radius: 8px; font-size: 13px; font-weight: 500; z-index: 70; transition: all .2s; pointer-events: none; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ---------- misc ---------- */
.notice { padding: 10px 14px; border-radius: 8px; font-size: 12.5px; border: 1px solid var(--rule); background: var(--surface-2); color: var(--ink-2); }
.notice.warn { border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: var(--warn-soft); color: var(--ink); }
.notice.bad { border-color: color-mix(in srgb, var(--bad) 40%, transparent); background: var(--bad-soft); color: var(--ink); }
.notice.ok { border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: var(--ok-soft); color: var(--ink); }
.notice.ai { border-color: color-mix(in srgb, var(--ai) 40%, transparent); background: var(--ai-soft); color: var(--ink); }
.empty { padding: 28px; text-align: center; color: var(--muted); font-size: 13px; border: 1px dashed var(--rule-strong); border-radius: 10px; }
.steps { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.step { padding: 10px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--rule); display: grid; gap: 4px; font-size: 12px; }
.step .n { font-family: var(--font-mono); color: var(--muted); font-size: 11px; }
.step b { font-size: 12.5px; }
.step .c { color: var(--accent); font-family: var(--font-mono); font-size: 11px; }
.funnel { display: grid; gap: 6px; }
.funnel .f { display: grid; grid-template-columns: 90px 1fr 40px; gap: 10px; align-items: center; font-size: 12.5px; }
.funnel .f .bar { height: 18px; border-radius: 4px; }
.funnel .f .bar > i { border-radius: 4px; }
.pathway { display: grid; gap: 8px; padding: 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--rule); }
.pathway.rec { border-color: var(--accent); }
.pathway header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pathway .crit { display: flex; flex-wrap: wrap; gap: 4px; }
.pathway .crit .c { font-family: var(--font-mono); font-size: 10.5px; padding: 1px 6px; border-radius: 4px; background: var(--surface-3); color: var(--muted); }
.pathway .crit .c.met { background: var(--ok-soft); color: var(--ok); }
.evlist { display: grid; gap: 6px; }
.evitem { display: grid; grid-template-columns: 92px 1fr auto; gap: 10px; padding: 8px 10px; border: 1px solid var(--rule); border-radius: 8px; background: var(--surface-2); font-size: 12.5px; align-items: start; }
.evitem.hi { border-color: var(--accent); }
.evitem .id { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-2); }
.evitem .d { color: var(--ink-2); }
.evitem .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 3px; }
.checks { display: grid; gap: 6px; }
.chk { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 10px; align-items: start; padding: 7px 10px; border: 1px solid var(--rule); border-radius: 8px; background: var(--surface-2); font-size: 12.5px; }
.chk .ty { font-family: var(--font-mono); font-weight: 500; }
.chk .s { color: var(--muted); font-size: 11.5px; }
.ids { display: grid; gap: 6px; }
.idrow { display: grid; grid-template-columns: 84px minmax(0, 1fr); grid-template-areas: 'k v' 'k s'; gap: 8px; align-items: center; font-size: 12.5px; padding: 6px 0; border-bottom: 1px solid var(--rule); }
.idrow:last-child { border-bottom: 0; }
.idrow .k { color: var(--muted); font-size: 11.5px; grid-area: k; }
.idrow .v { grid-area: v; }
.idrow .src { grid-area: s; justify-self: start; }
.idrow .v { font-family: var(--font-mono); font-size: 12px; overflow-wrap: anywhere; }
.spec { max-width: 860px; font-size: 15px; line-height: 1.6; color: var(--ink-2); }
.spec h1 { font: 400 36px/1.1 var(--font-display); color: var(--ink); margin: 0 0 12px; }
.spec h2 { font-size: 24px; margin: 36px 0 10px; color: var(--ink); }
.spec h3 { font-size: 18px; margin: 26px 0 8px; color: var(--ink); }
.spec p { margin: 10px 0; }
.spec table { border-collapse: collapse; width: 100%; font-size: 13px; margin: 14px 0; display: block; overflow: auto; }
.spec th, .spec td { border: 1px solid var(--rule); padding: 6px 9px; text-align: left; vertical-align: top; }
.spec th { background: var(--surface-2); color: var(--ink); }
.spec li { margin: 4px 0; }
.spec code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.spec pre { background: var(--surface-2); padding: 12px; border-radius: 8px; overflow: auto; font-size: 12.5px; }
.toc { display: grid; gap: 4px; font-size: 13px; position: sticky; top: 72px; align-self: start; max-height: calc(100vh - 90px); overflow: auto; }
.toc a { color: var(--ink-2); }
.toc a.h3 { padding-left: 14px; font-size: 12px; color: var(--muted); }
.loading { display: grid; place-items: center; min-height: 60vh; color: var(--muted); font-family: var(--font-mono); font-size: 13px; }
.pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: .4; } 50% { opacity: 1; } }
.hl { background: var(--warn-soft); border-radius: 3px; padding: 0 2px; }
.linkish { color: var(--accent); cursor: pointer; }
.linkish:hover { text-decoration: underline; }
.impact { display: grid; gap: 6px; }
.impact .r { display: grid; grid-template-columns: 120px 1fr 56px; gap: 10px; align-items: center; font-size: 12.5px; }
.impact .track { position: relative; height: 14px; background: var(--surface-3); border-radius: 4px; }
.impact .track .band { position: absolute; top: 0; bottom: 0; background: var(--ok-soft); }
.impact .track .mk { position: absolute; top: -3px; width: 3px; height: 20px; border-radius: 2px; background: var(--accent); transform: translateX(-50%); }
.impact .track .mk.out { background: var(--bad); }
.impact .n { font-family: var(--font-mono); text-align: right; font-size: 12px; }

@media (max-width: 1560px) {
  .grid.cockpit { grid-template-columns: 300px minmax(0, 1fr); }
  .grid.cockpit > .span-right { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
}
@media (max-width: 1180px) {
  .grid.cockpit { grid-template-columns: 1fr 1fr; }
  .grid.cockpit > .span-right { grid-column: 1 / -1; grid-template-columns: 1fr; }
  .grid.c4, .grid.c6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .steps { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--rule); padding: 12px 16px; }
  .nav { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .side .foot { display: none; }
  .content { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .grid.c2, .grid.c3, .grid.cockpit { grid-template-columns: 1fr; }
  .grid.cockpit > .span-right { grid-template-columns: 1fr; }
  .span2, .span3 { grid-column: auto; }
  .mrow { grid-template-columns: 1fr; gap: 6px; }
  .steps { grid-template-columns: repeat(2, 1fr); }
  .asof { display: none; }
}
