/* Syn Bank Coverage Desk
 *
 * Design direction: an institutional coverage terminal, not a data-science
 * notebook. The one idea the visual language carries is the thing this whole
 * project is about — that the five pillars are not the same kind of claim.
 *
 *   The range mark      every figure that is a range is drawn as one: a band
 *                       from low to high with a dot at the base. Cash, which is
 *                       identity-anchored, gets a dot with no band. The reader
 *                       learns the difference without reading a word.
 *   The pillar grammar  CORE pillars carry a solid accent rule, SUPPORTING a
 *                       two-tone half rule, SIGNAL_ONLY a dotted one. Repeated
 *                       at every scale so "this is a different kind of number"
 *                       is structural rather than a footnote.
 *
 * Colour is indigo: one accent, a sequential indigo ramp for magnitude, and the
 * reserved status four. NO GRADIENTS ANYWHERE — every fill in this file is a
 * flat colour or a border. The half rule is two solid blocks; the dotted rule is
 * a real dotted border. A gradient would make magnitude ambiguous in exactly the
 * places this dashboard is asking to be trusted on magnitude.
 *
 * Two type voices, both from the system stack because the dashboard must run
 * with no network:
 *   the sans   headings and figures. Tight tracking, tabular numerals.
 *   the mono   every label that names rather than states — eyebrows, table
 *              heads, chips, ticks, ranks. Instrumentation, not prose.
 *
 * Hairline discipline: cards are borders, not shadows. Shadow is reserved for
 * things that genuinely float — the tooltip, the copilot, a hovered heat cell.
 *
 * Light only, with an explicit colour-scheme, so it renders identically on a
 * judge's dark-mode laptop.
 */

:root {
  color-scheme: light;

  /* Surfaces — cool paper with a faint violet cast, deliberately not warm cream. */
  --plane: #f2f2f7;
  --surface: #ffffff;
  --surface-2: #fafafd;
  --surface-sunk: #ececf3;

  /* Ink — near-black carrying the same violet cast, never pure black. */
  --ink: #17182a;
  --ink-2: #4b4d63;
  --muted: #7c7e94;
  --rule: #e5e5ee;
  --rule-strong: #cdcedb;

  /* Accent — indigo. One hue, used sparingly. */
  --accent: #5b57d4;
  --accent-strong: #4b47bd;
  --accent-ink: #3b389c;
  --accent-wash: #f0efff;
  --accent-line: #d5d3f7;

  /* The dark plane the rail sits on. */
  --rail-bg: #1a1b2e;
  --rail-line: rgba(255, 255, 255, 0.09);

  /* Reserved status palette. Never used for series identity. */
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-ink: #06630b;
  --warning-ink: #7a5200;
  --critical-ink: #8e2020;
  --good-wash: #e9f6e9;
  --good-line: #bce3bc;
  --warning-wash: #fdf3e0;
  --warning-line: #f0dcae;
  --critical-wash: #fbeaea;
  --critical-line: #eec2c2;

  /* Sequential indigo ramp, for magnitude only. Text flips to white at s-4. */
  --seq-100: #e6e5fb;
  --seq-200: #ccccf5;
  --seq-300: #adadec;
  --seq-400: #8a8ae0;
  --seq-500: #5a5ac8;
  --seq-600: #3d3d9c;

  --rail: 214px;
  --panel: 452px;
  /* Fallback only. The real value is measured from the topbar at boot and on
   * every resize — a hardcoded guess parks the sticky table header behind the
   * topbar the moment a page title wraps. See `trackTopbarHeight` in app.js. */
  --topbar-h: 72px;
  --radius: 7px;
  --radius-sm: 5px;
  --lift: 0 10px 30px -14px rgba(23, 24, 42, 0.42);
  --lift-strong: 0 18px 44px -18px rgba(23, 24, 42, 0.55);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--plane);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* One focus treatment for the whole surface, so nothing is reachable by
 * keyboard without being visible. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ---------------------------------------------------------------- type */

/* The mono voice: labels that name rather than state. */
.eyebrow,
.stat .k,
.gauge .k,
.chip,
.role-tag,
table.data th,
.heat th.col,
.heat th.row .sec,
.filters label,
.legend,
.tooltip .t-k,
.rangemark .tick-label {
  font-family: var(--mono);
}

.eyebrow {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted);
}

h1, h2, h3, h4 { margin: 0; font-weight: 620; letter-spacing: -0.014em; }
h1 { font-size: 21px; }
h2 { font-size: 15.5px; }
h3 { font-size: 13.5px; }

.num {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.022em;
  font-weight: 600;
}
.num-xl { font-size: 28px; line-height: 1.15; }
.num-lg { font-size: 20px; }
.num-md { font-size: 16px; }

.dim { color: var(--muted); }
.sub { color: var(--ink-2); font-size: 12.8px; }
.tiny { font-size: 11.5px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

a { color: var(--accent-ink); text-underline-offset: 2px; }

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

.shell { display: flex; min-height: 100vh; }

.rail {
  width: var(--rail);
  flex: 0 0 var(--rail);
  background: var(--rail-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.rail-brand {
  padding: 19px 18px 17px;
  border-bottom: 1px solid var(--rail-line);
}
.rail-brand .mark {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.012em;
}
.rail-brand .sub-mark {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.46);
  margin-top: 4px;
}

.rail-nav { padding: 12px 12px; flex: 1; }

/* Active state is a solid accent bar on the leading edge, not a pill. The nav
 * is a set of views, not a sequence, so nothing here is numbered. */
.rail-link {
  display: block;
  position: relative;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.66);
  text-decoration: none;
  font-size: 13px;
  transition: background 120ms ease, color 120ms ease;
}
.rail-link::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 0;
  border-radius: 0 2px 2px 0;
  background: var(--accent);
  transition: height 140ms ease;
}
.rail-link:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.rail-link.active { background: rgba(255, 255, 255, 0.1); color: #fff; font-weight: 560; }
.rail-link.active::before { height: 20px; }

.rail-foot {
  padding: 14px 18px 18px;
  border-top: 1px solid var(--rail-line);
  font-family: var(--mono);
  font-size: 10.5px;
  color: rgba(255, 255, 255, 0.44);
  line-height: 1.6;
}
.rail-foot .ai-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: 1px;
}
.ai-dot.on { background: var(--good); }
.ai-dot.off { background: var(--warning); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  min-height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .title-block { min-width: 0; flex: 1; }

/* The rail slides off-canvas below 900px, so it needs a way back. Hidden on
 * desktop, where the rail is always present. */
.rail-toggle {
  display: none;
  align-items: center; justify-content: center;
  width: 36px; height: 36px; flex: 0 0 auto;
  border: 1px solid var(--rule-strong); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; padding: 0;
}
.rail-toggle:hover { background: var(--surface-sunk); }
.rail-toggle .bars { display: grid; gap: 3px; }
.rail-toggle .bars i { display: block; width: 15px; height: 1.5px; background: var(--ink); border-radius: 1px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.topbar .lede { color: var(--muted); font-size: 12.8px; margin-top: 1px; }

/* Bottom padding clears the floating copilot button, which is fixed and would
 * otherwise sit on top of the last row of a table. */
.page { padding: 22px 28px 96px; max-width: 1560px; }
.page > * { animation: rise 240ms cubic-bezier(0.22, 0.8, 0.3, 1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .page > * { animation: none; }
  * { transition: none !important; }
}

/* ---------------------------------------------------------------- cards */

/* Cards are hairlines, not shadows. Shadow means "this floats above the page",
 * and a page of twenty floating cards means nothing floats. */
/* No `overflow: hidden` here, however tempting: it would make the card the
 * scrollport for everything inside it and silently kill the sticky table
 * header. The two children that touch the top edge round their own corners
 * instead. */
.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}
.card > :first-child { border-radius: var(--radius) var(--radius) 0 0; }
.card > :last-child { border-radius: 0 0 var(--radius) var(--radius); }
.card-head {
  padding: 13px 16px 12px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  background: var(--surface-2);
}
.card-body { padding: 15px 16px 16px; }
.card-body.tight { padding: 8px 16px 10px; }

/* A section head is a label and a hairline that runs to the edge — structure,
 * not decoration: it says where one argument ends and the next begins. */
.section-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin: 28px 0 12px;
}
.section-head::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
  align-self: center;
  order: 1;
}
.section-head .note {
  order: 2;
  color: var(--muted);
  font-size: 11.8px;
  max-width: 58ch;
  text-align: right;
  line-height: 1.45;
}
.section-head:first-child { margin-top: 2px; }

.grid { display: grid; gap: 14px; }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1240px) { .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 900px) { .grid-3, .grid-2 { grid-template-columns: 1fr; } }

/* -------------------------------------------------- the pillar grammar */
/* CORE solid, SUPPORTING half, SIGNAL_ONLY dotted. The rule sits on the top
 * edge of every pillar card so the difference is visible before any number.
 * Built from solid blocks and a dotted border — never a gradient, because a
 * gradient would read as a third, in-between kind of claim. */

.pillar-rule { position: relative; height: 3px; background: var(--rule-strong); }
.pillar-rule.core { background: var(--accent); }
.pillar-rule.supporting::before {
  content: "";
  position: absolute;
  inset: 0 50% 0 0;
  background: var(--accent);
}
.pillar-rule.signal {
  height: 0;
  background: none;
  border-top: 3px dotted var(--rule-strong);
}

.role-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
/* The swatch is the same grammar at label scale. Two-tone is two solid borders
 * on a zero-width box; dotted is a dotted border. No gradient in either. */
.role-tag::before {
  content: "";
  width: 14px;
  height: 3px;
  background: var(--accent);
  border-radius: 1px;
  flex: 0 0 auto;
}
.role-tag.supporting::before {
  width: 0;
  background: none;
  border-left: 7px solid var(--accent);
  border-right: 7px solid var(--rule-strong);
  height: 3px;
}
.role-tag.signal::before {
  width: 14px;
  height: 0;
  background: none;
  border-top: 3px dotted var(--rule-strong);
}

/* ------------------------------------------------------- the range mark */
/* The signature. A band from low to high with a dot at the base. A figure with
 * no range gets a lone dot and a hairline — the visual claim that it does not
 * move. */

.rangemark { display: block; margin-top: 8px; overflow: visible; }
.rangemark .band { fill: var(--seq-100); }
.rangemark .band.wide { fill: var(--warning-wash); }
.rangemark .axis { stroke: var(--rule-strong); stroke-width: 1; }
.rangemark .cap { stroke: var(--rule-strong); stroke-width: 1; }
.rangemark .base { fill: var(--accent); }
.rangemark .base.fixed { fill: var(--ink); }
.rangemark .tick-label { fill: var(--muted); font-size: 9px; letter-spacing: -0.01em; }

/* ---------------------------------------------------------------- stats */

.stat-row { display: flex; flex-wrap: wrap; gap: 18px 32px; }
.stat { min-width: 0; }
.stat .k, .gauge .k {
  font-size: 9.5px; font-weight: 600; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--muted);
}
.stat .v { margin-top: 4px; }
.stat .h { font-size: 11.3px; color: var(--muted); margin-top: 3px; }

.meter { height: 6px; background: var(--surface-sunk); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.meter.thin { height: 4px; }

/* ---------------------------------------------------------------- chips */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.chip-HIGH { background: var(--good-wash); color: var(--good-ink); border-color: var(--good-line); }
.chip-MEDIUM { background: var(--warning-wash); color: var(--warning-ink); border-color: var(--warning-line); }
.chip-LOW { background: var(--critical-wash); color: var(--critical-ink); border-color: var(--critical-line); }
.chip-neutral { background: var(--surface-sunk); color: var(--ink-2); border-color: var(--rule-strong); }
.chip-accent { background: var(--accent-wash); color: var(--accent-ink); border-color: var(--accent-line); }

.status {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
}
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.status-PRIORITY { color: var(--good-ink); }
.status-PRIORITY::before { background: var(--good); }
.status-INVESTIGATE { color: var(--warning-ink); }
.status-INVESTIGATE::before { background: var(--warning); }
.status-MONITOR { color: var(--ink-2); }
.status-MONITOR::before { background: var(--muted); }
.status-NO_HEADROOM_DEMONSTRATED { color: var(--muted); }
.status-NO_HEADROOM_DEMONSTRATED::before { background: var(--rule-strong); }

.sens {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; font-weight: 600; color: var(--ink-2);
}
.sens .glyph { font-family: var(--mono); font-size: 12px; line-height: 1; }
.sens-STABLE { color: var(--good-ink); }
.sens-MODERATE { color: var(--warning-ink); }
.sens-SENSITIVE { color: var(--critical-ink); }
.sens-NOT_APPLICABLE { color: var(--muted); }

/* ---------------------------------------------------------------- tables */

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left;
  font-size: 9.5px; font-weight: 600; letter-spacing: 0.11em; text-transform: uppercase;
  color: var(--muted);
  padding: 10px 10px 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--rule-strong);
  white-space: nowrap;
  /* Twenty clients is taller than a viewport. The header follows the reader
   * down rather than making them scroll back up to name a column. */
  position: sticky;
  top: var(--topbar-h);
  z-index: 5;
}
table.data td { padding: 9px 10px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.r, table.data th.r { text-align: right; font-variant-numeric: tabular-nums; }
table.data tbody tr.click { cursor: pointer; transition: background 110ms ease; }
table.data tbody tr.click:hover { background: var(--accent-wash); }
table.data tbody tr.click:focus-within { background: var(--accent-wash); }

/* ---------------------------------------------------------------- heatmap */

.heat-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
.heat { border-collapse: separate; border-spacing: 3px; font-size: 12px; }
.heat th.col {
  font-size: 9.5px; letter-spacing: 0.11em; text-transform: uppercase; color: var(--muted);
  font-weight: 600; padding: 0 0 9px; text-align: center; min-width: 120px;
}
.heat th.row {
  text-align: left; font-weight: 500; font-size: 12.5px; padding-right: 14px;
  white-space: nowrap; color: var(--ink);
  /* Names stay put while the pillars scroll under them — otherwise the right
   * half of the grid is a wall of unlabelled scores. */
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 2;
  /* A hairline, not a border: the cells slide underneath and would otherwise
   * butt straight against the name with no edge to read them apart. */
  box-shadow: 1px 0 0 var(--rule);
}
.heat th.row .sec {
  display: block; font-size: 9px; color: var(--muted);
  letter-spacing: 0.1em; text-transform: uppercase; margin-top: 2px;
}

.cell {
  position: relative;
  height: 48px; min-width: 120px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 110ms ease, box-shadow 110ms ease;
  padding: 6px 8px;
  overflow: hidden;
}
.cell:hover { transform: translateY(-1px); box-shadow: var(--lift); }
.cell .sc { font-size: 13.5px; font-weight: 640; font-variant-numeric: tabular-nums; letter-spacing: -0.025em; }
.cell .meta { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.cell .pips { display: inline-flex; gap: 2.5px; }
.cell .pips i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; opacity: 0.26; }
.cell .pips i.on { opacity: 1; }
.cell .warn { font-family: var(--mono); font-size: 11px; line-height: 1; }

/* Confidence is encoded by FILL STYLE, never by hue — hue is already carrying
 * magnitude. HIGH is solid, MEDIUM is a tint with a ring, LOW is an outline
 * with no fill, so a weakly evidenced cell can never read like a strong one. */
.cell.c-HIGH { color: #fff; }
.cell.c-HIGH.s-1 { background: var(--seq-200); color: var(--ink); }
.cell.c-HIGH.s-2 { background: var(--seq-300); color: var(--ink); }
.cell.c-HIGH.s-3 { background: var(--seq-400); color: var(--ink); }
.cell.c-HIGH.s-4 { background: var(--seq-500); }
.cell.c-HIGH.s-5 { background: var(--seq-600); }

.cell.c-MEDIUM { color: var(--accent-ink); border-color: var(--accent-line); }
.cell.c-MEDIUM.s-1 { background: #fafaff; }
.cell.c-MEDIUM.s-2 { background: #f3f2ff; }
.cell.c-MEDIUM.s-3 { background: #ebeaff; }
.cell.c-MEDIUM.s-4 { background: #e2e1fd; }
.cell.c-MEDIUM.s-5 { background: #d9d7fb; }

.cell.c-LOW {
  background: var(--surface);
  color: var(--muted);
  border: 1px dashed var(--rule-strong);
}
.cell.c-LOW .sc { font-weight: 560; }

.cell.empty { background: var(--surface-sunk); border-color: var(--rule); color: var(--muted); cursor: default; }
.cell.empty:hover { transform: none; box-shadow: none; }

.legend {
  display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center;
  font-size: 10px; letter-spacing: 0.05em; color: var(--ink-2);
}
.legend .swatches { display: inline-flex; gap: 2px; vertical-align: -1px; }
.legend .swatches i { width: 18px; height: 11px; border-radius: 2px; display: block; }

/* ---------------------------------------------------------------- filters */

.filters { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
.filters label {
  font-size: 9.5px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); font-weight: 600;
}
.filters label + select { margin-right: 6px; }

select, input[type="search"], input[type="text"] {
  font-family: var(--font); font-size: 13px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm); padding: 6px 9px;
  transition: border-color 110ms ease;
}
select:hover, input:hover { border-color: var(--muted); }
select:focus-visible, input:focus-visible { outline-offset: -1px; border-color: var(--accent); }

.seg { display: inline-flex; border: 1px solid var(--rule-strong); border-radius: var(--radius); overflow: hidden; }
.seg button {
  font-family: var(--font); font-size: 12.5px; font-weight: 550;
  padding: 7px 14px; border: 0; background: var(--surface); color: var(--ink-2);
  cursor: pointer; border-right: 1px solid var(--rule);
  transition: background 110ms ease, color 110ms ease;
}
.seg button:last-child { border-right: 0; }
.seg button:hover { background: var(--surface-sunk); color: var(--ink); }
.seg button.on { background: var(--accent); color: #fff; }
.seg button.on:hover { background: var(--accent-strong); }

.btn {
  font-family: var(--font); font-size: 12.8px; font-weight: 560;
  padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid var(--rule-strong); background: var(--surface); color: var(--ink);
  transition: background 110ms ease, border-color 110ms ease;
}
.btn:hover { background: var(--surface-sunk); border-color: var(--muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-sm { padding: 5px 11px; font-size: 12px; }

/* ---------------------------------------------------------------- copilot */

.copilot-toggle {
  position: fixed; right: 22px; bottom: 22px; z-index: 60;
  display: inline-flex; align-items: center; gap: 9px;
  padding: 11px 17px; border-radius: 999px;
  background: var(--accent); color: #fff; border: 0; cursor: pointer;
  font-family: var(--font); font-size: 13px; font-weight: 560;
  box-shadow: var(--lift-strong);
  transition: background 120ms ease, transform 120ms ease;
}
.copilot-toggle:hover { background: var(--accent-strong); transform: translateY(-1px); }
.copilot-toggle .key {
  font-family: var(--mono); font-size: 10.5px; line-height: 1;
  border: 1px solid rgba(255, 255, 255, 0.36); border-radius: 3px;
  padding: 3px 5px; color: rgba(255, 255, 255, 0.82);
}

.copilot {
  position: fixed; top: 0; right: 0; height: 100vh; width: var(--panel);
  max-width: 92vw; background: var(--surface); border-left: 1px solid var(--rule);
  box-shadow: var(--lift-strong);
  display: flex; flex-direction: column; z-index: 70;
  transform: translateX(100%); transition: transform 200ms cubic-bezier(0.22, 0.8, 0.3, 1);
}
.copilot.open { transform: none; }
.copilot-head {
  padding: 15px 18px; border-bottom: 1px solid var(--rule); background: var(--surface-2);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
}
.copilot-body { flex: 1; overflow-y: auto; padding: 16px 18px; }
.copilot-foot { border-top: 1px solid var(--rule); padding: 11px 14px 13px; background: var(--surface-2); }
.copilot-foot form { display: flex; gap: 8px; }
.copilot-foot input { flex: 1; }

.suggest { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.suggest button {
  text-align: left; font-family: var(--font); font-size: 12.5px; color: var(--accent-ink);
  background: var(--accent-wash); border: 1px solid var(--accent-line); border-radius: var(--radius-sm);
  padding: 8px 10px; cursor: pointer; transition: background 110ms ease;
}
.suggest button:hover { background: #e6e4ff; }

.msg { margin-bottom: 18px; }
.msg .q {
  font-weight: 600; font-size: 13px; padding: 9px 11px;
  background: var(--surface-sunk); border-radius: var(--radius-sm);
  border-left: 3px solid var(--rule-strong); margin-bottom: 10px;
}
.msg .a { font-size: 13.2px; line-height: 1.64; color: var(--ink); }
.msg .a h2 { font-size: 12.5px; margin: 15px 0 5px; letter-spacing: 0.02em; }
.msg .a h3 { font-size: 12.2px; margin: 12px 0 4px; color: var(--ink-2); }
.msg .a p { margin: 0 0 9px; }
.msg .a ul, .msg .a ol { margin: 0 0 9px; padding-left: 19px; }
.msg .a li { margin-bottom: 4px; }
.msg .a code {
  font-family: var(--mono); background: var(--surface-sunk);
  padding: 1px 4px; border-radius: 3px; font-size: 11.5px;
}
.msg .a strong { font-weight: 640; }
.msg .a hr { border: 0; border-top: 1px solid var(--rule); margin: 13px 0; }

.notice {
  font-size: 11.5px; line-height: 1.5; padding: 8px 10px; border-radius: var(--radius-sm);
  margin-bottom: 10px; border: 1px solid;
}
.notice-demo { background: var(--warning-wash); border-color: var(--warning-line); color: #6b4800; }
.notice-live { background: var(--good-wash); border-color: var(--good-line); color: var(--good-ink); }
.notice-reject { background: var(--critical-wash); border-color: var(--critical-line); color: var(--critical-ink); }

.thinking { display: inline-flex; gap: 4px; align-items: center; color: var(--muted); font-size: 12.5px; }
.thinking i { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); animation: blink 1.1s infinite; }
.thinking i:nth-child(2) { animation-delay: 0.16s; }
.thinking i:nth-child(3) { animation-delay: 0.32s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.22; } 30% { opacity: 1; } }

.scrim {
  position: fixed; inset: 0; background: rgba(23, 24, 42, 0.3);
  z-index: 65; opacity: 0; pointer-events: none; transition: opacity 180ms ease;
}
.scrim.on { opacity: 1; pointer-events: auto; }

/* ---------------------------------------------------------------- misc */

.bar-row { display: flex; align-items: center; gap: 11px; margin-bottom: 9px; }
.bar-row .lbl { width: 152px; flex: 0 0 152px; font-size: 12.5px; color: var(--ink-2); }
.bar-row .track { flex: 1; height: 13px; background: var(--surface-sunk); border-radius: 3px; overflow: hidden; }
.bar-row .track > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.bar-row .val { width: 96px; text-align: right; font-size: 12.5px; font-variant-numeric: tabular-nums; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 5px 14px; font-size: 12.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }

.callout {
  border-left: 3px solid var(--accent); background: var(--accent-wash);
  padding: 11px 14px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 12.8px; line-height: 1.58; color: var(--ink);
}
.callout.warn { border-left-color: var(--warning); background: var(--warning-wash); }
.callout.stop { border-left-color: var(--critical); background: var(--critical-wash); }

.empty-state { padding: 36px; text-align: center; color: var(--muted); font-size: 13px; }
.spinner { padding: 44px; text-align: center; color: var(--muted); font-size: 12.5px; }

.crumb { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.crumb button {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--accent-ink); font-family: var(--font); font-size: 12px;
}
.crumb button:hover { text-decoration: underline; }

.gauge-row { display: flex; gap: 14px; flex-wrap: wrap; }
.gauge {
  flex: 1 1 178px; border: 1px solid var(--rule); border-radius: var(--radius-sm);
  padding: 12px 13px; background: var(--surface-2);
}
.gauge .v { margin: 6px 0 2px; }

.sig-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(184px, 1fr)); gap: 10px; }
.sig {
  border: 1px solid var(--rule); border-radius: var(--radius-sm);
  padding: 10px 12px; background: var(--surface-2);
}
.sig .k { font-size: 11px; color: var(--ink-2); font-weight: 560; }
.sig .v { font-size: 15px; font-weight: 620; font-variant-numeric: tabular-nums; letter-spacing: -0.022em; margin-top: 3px; }
.sig .w { font-size: 10.5px; color: var(--muted); margin-top: 4px; line-height: 1.45; }

.tooltip {
  position: fixed; z-index: 90; pointer-events: none;
  background: var(--rail-bg); color: #fff; border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 12px; line-height: 1.5; max-width: 300px;
  box-shadow: var(--lift-strong);
  opacity: 0; transition: opacity 110ms ease;
}
.tooltip.on { opacity: 1; }
.tooltip .t-k {
  color: rgba(255, 255, 255, 0.58); font-size: 9.5px;
  letter-spacing: 0.11em; text-transform: uppercase;
}
.tooltip .t-row { display: flex; justify-content: space-between; gap: 14px; margin-top: 4px; }
.tooltip .t-row span:last-child { font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
  .rail { position: fixed; transform: translateX(-100%); z-index: 80; transition: transform 180ms ease; }
  .rail.open { transform: none; box-shadow: var(--lift-strong); }
  .rail-toggle { display: inline-flex; }
  .page { padding: 16px 16px 96px; }
  .topbar { padding: 12px 16px; }
  .section-head { flex-wrap: wrap; }
  .section-head .note { text-align: left; max-width: none; }
  /* The sticky offset assumes a one-line topbar; on a narrow screen the title
   * wraps, so pin the header to the top of the scroll instead of guessing. */
  table.data th { position: static; }
}
