/* =================================================================================================
   Bellwether — the design system.  PLATFORM.md §8.

   Dense, calm, operational. The reference is an operations console, not a marketing page.
   Palette and type carried forward from heritage-twelve.html without alteration:
     Spectral      display only — page titles, tile figures, nothing else
     IBM Plex Sans every piece of UI text
     IBM Plex Mono every figure, every identifier, every field name
   Navy #2B3C63 is the only accent. Green / amber / red are reserved strictly for sourcing verdicts
   and severity. If you see colour on this page it means something.

   Contents
     1  Tokens                     6  Rail                    11  Table
     2  Base + type                7  Top bar                 12  Charts
     3  Layout shell               8  Panels + tiles          13  Overlays: palette, modal, drawer, sheet
     4  Primitives                 9  Filter builder          14  Toasts
     5  Status + severity         10  States: empty/error/skeleton   15  Utilities + motion
   ================================================================================================= */

/* -------------------------------------------------------------------------------------------------
   1. Tokens — three-state theming. Bare :root defines the complete light palette; the
   prefers-color-scheme block is guarded so an explicit light choice wins; [data-theme="dark"]
   repeats it so an explicit dark choice wins under a light OS.
   ------------------------------------------------------------------------------------------------- */
:root {
  --paper: #FCFCFD;
  --surface: #FFFFFF;
  --surface-2: #F8F9FB;
  --sunk: #F4F5F8;
  --rail-bg: #F7F8FA;
  --rule: #E2E5EC;
  --rule-soft: #EDEFF4;
  --rule-strong: #C9CEDA;
  --ink: #161C27;
  --ink-2: #3D4655;
  --ink-3: #697285;
  --ink-4: #98A1B2;
  --accent: #2B3C63;
  --accent-ink: #FFFFFF;
  --accent-soft: #EDF0F7;
  --accent-line: #C3CCE0;
  --go: #256B4E;
  --go-bg: #E7F2EC;
  --go-line: #B6D8C6;
  --hold: #8A5A11;
  --hold-bg: #F8EFDE;
  --hold-line: #E4CFA4;
  --stop: #963029;
  --stop-bg: #FAEAE8;
  --stop-line: #EFC3BE;
  --shadow: 0 1px 2px rgba(22, 28, 39, .05), 0 6px 18px -10px rgba(22, 28, 39, .18);
  --shadow-lg: 0 2px 6px rgba(22, 28, 39, .08), 0 24px 60px -24px rgba(22, 28, 39, .38);
  --scrim: rgba(22, 28, 39, .34);
  --skeleton: linear-gradient(90deg, var(--sunk) 0%, var(--rule-soft) 50%, var(--sunk) 100%);

  /* chart series — a navy ramp, deliberately monochrome so the semantic colours stay meaningful */
  --s-loan: #2B3C63;
  --s-dep: #93A0BC;
  --ramp-1: #2B3C63;
  --ramp-2: #4C5C82;
  --ramp-3: #7683A4;
  --ramp-4: #A9B2C6;
  --ramp-5: #D2D7E2;
  --grid: #E7EAF1;
  --grid-strong: #C9CEDA;

  /* geometry */
  --rail-w: 232px;
  --rail-w-collapsed: 56px;
  --topbar-h: 52px;
  --row-h: 34px;
  --radius: 6px;
  --radius-sm: 4px;
  --radius-lg: 10px;
  --pad: 16px;

  /* type */
  --ui: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --display: Spectral, "Iowan Old Style", Georgia, "Times New Roman", serif;
  --fs-table: 13px;
  --fs-body: 14px;
  --fs-small: 12px;
  --fs-micro: 11px;

  --dur: 140ms;
  --ease: cubic-bezier(.2, .7, .3, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0F131A;
    --surface: #161B24;
    --surface-2: #131821;
    --sunk: #1B212C;
    --rail-bg: #12171F;
    --rule: #2A313E;
    --rule-soft: #222834;
    --rule-strong: #3C4554;
    --ink: #E9ECF2;
    --ink-2: #B4BCCB;
    --ink-3: #828C9E;
    --ink-4: #626C7D;
    --accent: #93A8D6;
    --accent-ink: #0F131A;
    --accent-soft: #1D2637;
    --accent-line: #35415C;
    --go: #6FBF98;
    --go-bg: #15291F;
    --go-line: #274A38;
    --hold: #D7A54E;
    --hold-bg: #2C2416;
    --hold-line: #4E4224;
    --stop: #E08B83;
    --stop-bg: #2E1B19;
    --stop-line: #52302C;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px -12px rgba(0, 0, 0, .6);
    --shadow-lg: 0 2px 8px rgba(0, 0, 0, .4), 0 28px 70px -28px rgba(0, 0, 0, .8);
    --scrim: rgba(4, 6, 10, .62);
    --skeleton: linear-gradient(90deg, var(--sunk) 0%, var(--rule) 50%, var(--sunk) 100%);

    --s-loan: #93A8D6;
    --s-dep: #56637F;
    --ramp-1: #93A8D6;
    --ramp-2: #7387B4;
    --ramp-3: #566792;
    --ramp-4: #3C4A6B;
    --ramp-5: #2A3450;
    --grid: #242B37;
    --grid-strong: #3C4554;
  }
}

:root[data-theme="dark"] {
  --paper: #0F131A;
  --surface: #161B24;
  --surface-2: #131821;
  --sunk: #1B212C;
  --rail-bg: #12171F;
  --rule: #2A313E;
  --rule-soft: #222834;
  --rule-strong: #3C4554;
  --ink: #E9ECF2;
  --ink-2: #B4BCCB;
  --ink-3: #828C9E;
  --ink-4: #626C7D;
  --accent: #93A8D6;
  --accent-ink: #0F131A;
  --accent-soft: #1D2637;
  --accent-line: #35415C;
  --go: #6FBF98;
  --go-bg: #15291F;
  --go-line: #274A38;
  --hold: #D7A54E;
  --hold-bg: #2C2416;
  --hold-line: #4E4224;
  --stop: #E08B83;
  --stop-bg: #2E1B19;
  --stop-line: #52302C;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px -12px rgba(0, 0, 0, .6);
  --shadow-lg: 0 2px 8px rgba(0, 0, 0, .4), 0 28px 70px -28px rgba(0, 0, 0, .8);
  --scrim: rgba(4, 6, 10, .62);
  --skeleton: linear-gradient(90deg, var(--sunk) 0%, var(--rule) 50%, var(--sunk) 100%);

  --s-loan: #93A8D6;
  --s-dep: #56637F;
  --ramp-1: #93A8D6;
  --ramp-2: #7387B4;
  --ramp-3: #566792;
  --ramp-4: #3C4A6B;
  --ramp-5: #2A3450;
  --grid: #242B37;
  --grid-strong: #3C4554;
}

/* Density is a preference, not a theme: it moves geometry only. */
:root[data-density="compact"] { --row-h: 28px; --pad: 12px; --fs-table: 12px; --fs-body: 13px; }
:root[data-density="comfortable"] { --row-h: 34px; --pad: 16px; }
:root[data-density="relaxed"] { --row-h: 40px; --pad: 20px; --fs-table: 14px; --fs-body: 15px; }

/* -------------------------------------------------------------------------------------------------
   2. Base and type
   ------------------------------------------------------------------------------------------------- */
* { box-sizing: border-box; }

html { color-scheme: light dark; height: 100%; }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--ui);
  font-size: var(--fs-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden; /* the shell owns scrolling; only .content scrolls */
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.25; }
p { margin: 0 0 .6em; }
p:last-child { margin-bottom: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

.display { font-family: var(--display); font-weight: 600; letter-spacing: -.01em; }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.eyebrow {
  font-size: var(--fs-micro); font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-3); margin: 0 0 4px;
}
.dim { color: var(--ink-3); }
.dimmer { color: var(--ink-4); }
.small { font-size: var(--fs-small); }
.micro { font-size: var(--fs-micro); }
/* Non-negotiable #5 — every field name on screen is a real corpus field, so it has to stay
   readable. BankingHub names run long (`AcctBal[].BalType=IndirectLiability` is 35 characters) and
   used to overflow a narrow tile and get painted over by the next one. Wrap at the token boundary
   inside the box; never spill out of it. */
.field-name {
  font-family: var(--mono); font-size: var(--fs-micro); color: var(--ink-3);
  display: block; max-width: 100%; min-width: 0;
  overflow-wrap: anywhere; word-break: break-word;
}

::selection { background: var(--accent-soft); color: var(--ink); }

/* Focus rings on everything reachable by keyboard — PLATFORM §8. */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Scrollbars, restrained. */
* { scrollbar-width: thin; scrollbar-color: var(--rule-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--rule-strong); border: 3px solid transparent; background-clip: content-box; border-radius: 6px; }
*::-webkit-scrollbar-thumb:hover { background: var(--ink-4); background-clip: content-box; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 200;
  background: var(--surface); color: var(--ink); border: 1px solid var(--rule-strong);
  padding: 8px 12px; border-radius: var(--radius); box-shadow: var(--shadow);
  transition: top var(--dur) var(--ease);
}
.skip-link:focus-visible { top: 8px; }

/* -------------------------------------------------------------------------------------------------
   3. Layout shell
   ------------------------------------------------------------------------------------------------- */
.shell {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  grid-template-rows: 100vh;
  height: 100vh;
}
:root[data-rail="collapsed"] .shell { grid-template-columns: var(--rail-w-collapsed) minmax(0, 1fr); }

.main {
  display: grid;
  grid-template-rows: var(--topbar-h) minmax(0, 1fr);
  min-width: 0;
  background: var(--paper);
}

.content {
  overflow: auto;
  min-width: 0;
  padding: var(--pad) calc(var(--pad) + 4px) 56px;
  scroll-behavior: smooth;
}
.content > .surface { max-width: 1560px; }

/* A surface's own header strip: no hero — page titles live in the top bar (PLATFORM §8). */
.surface-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding-bottom: 10px; margin-bottom: 12px; border-bottom: 1px solid var(--rule);
}
.surface-bar .spacer { flex: 1 1 auto; }

.grid { display: grid; gap: 12px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 1280px) { .grid.cols-4, .grid.cols-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1020px) { .grid.cols-3, .grid.cols-4, .grid.cols-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .grid.cols-2, .grid.cols-3, .grid.cols-4, .grid.cols-6 { grid-template-columns: minmax(0, 1fr); } }

.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 8px; }
.spacer { flex: 1 1 auto; }

/* -------------------------------------------------------------------------------------------------
   4. Primitives
   ------------------------------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px;
  font: 500 var(--fs-small)/1 var(--ui);
  color: var(--ink-2); background: var(--surface);
  border: 1px solid var(--rule-strong); border-radius: var(--radius);
  cursor: pointer; white-space: nowrap; user-select: none;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.btn:hover:not(:disabled) { background: var(--sunk); color: var(--ink); }
.btn:active:not(:disabled) { background: var(--rule-soft); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.12); background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--sunk); }
.btn.danger { color: var(--stop); border-color: var(--stop-line); }
.btn.danger:hover:not(:disabled) { background: var(--stop-bg); }
.btn.sm { height: 24px; padding: 0 8px; font-size: var(--fs-micro); }
.btn.lg { height: 34px; padding: 0 14px; font-size: var(--fs-body); }
.btn.icon { width: 28px; padding: 0; justify-content: center; }
.btn.icon.sm { width: 24px; }
.btn[aria-pressed="true"], .btn.on { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }

.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }

.segmented {
  display: inline-flex; padding: 2px; gap: 2px;
  background: var(--sunk); border: 1px solid var(--rule); border-radius: var(--radius);
}
.segmented button {
  height: 22px; padding: 0 9px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--ink-3);
  font: 500 var(--fs-micro)/1 var(--ui); cursor: pointer;
}
.segmented button:hover { color: var(--ink); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.input, .select, textarea.input {
  height: 28px; padding: 0 8px; min-width: 0;
  font: 400 var(--fs-small)/1 var(--ui); color: var(--ink);
  background: var(--surface); border: 1px solid var(--rule-strong); border-radius: var(--radius);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
textarea.input { height: auto; padding: 6px 8px; line-height: 1.5; resize: vertical; font-family: var(--ui); }
.input.mono { font-family: var(--mono); }
.input::placeholder { color: var(--ink-4); }
.input:hover, .select:hover { border-color: var(--ink-4); }
.input:focus-visible, .select:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.input:disabled, .select:disabled { background: var(--sunk); color: var(--ink-4); cursor: not-allowed; }
.select { padding-right: 22px; appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 10px center, right 6px center; background-size: 4px 4px, 4px 4px; background-repeat: no-repeat; }

.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.field > label { font-size: var(--fs-micro); font-weight: 600; color: var(--ink-3); letter-spacing: .02em; }
.field .help { font-size: var(--fs-micro); color: var(--ink-4); }

.check { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-small); cursor: pointer; color: var(--ink-2); }
.check input { accent-color: var(--accent); width: 14px; height: 14px; margin: 0; cursor: pointer; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px; max-width: 100%;
  font: 500 var(--fs-micro)/1 var(--ui); color: var(--ink-2);
  background: var(--sunk); border: 1px solid var(--rule); border-radius: 11px;
  white-space: nowrap;
}
.chip.button { cursor: pointer; }
.chip.button:hover { background: var(--rule-soft); color: var(--ink); border-color: var(--rule-strong); }
.chip .x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 13px; height: 13px; margin-right: -3px; border: 0; border-radius: 50%;
  background: transparent; color: var(--ink-3); cursor: pointer; font-size: 13px; line-height: 1; padding: 0;
}
.chip .x:hover { background: var(--rule-strong); color: var(--ink); }
.chip .k { color: var(--ink-3); }
.chip .v { font-family: var(--mono); color: var(--ink); }

.kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 4px;
  font: 500 var(--fs-micro)/1 var(--mono); color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--rule-strong);
  border-bottom-width: 2px; border-radius: var(--radius-sm);
}

hr.rule { border: 0; border-top: 1px solid var(--rule); margin: 12px 0; }

.divider-v { width: 1px; height: 18px; background: var(--rule); flex: 0 0 auto; }

/* -------------------------------------------------------------------------------------------------
   5. Status, severity and sourcing verdicts
   ------------------------------------------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 18px; padding: 0 6px;
  font: 600 var(--fs-micro)/1 var(--ui); letter-spacing: .03em;
  border: 1px solid transparent; border-radius: var(--radius-sm); white-space: nowrap;
  background: var(--sunk); color: var(--ink-2); border-color: var(--rule);
}
.badge.green,  .badge[data-verdict="GREEN"]  { background: var(--go-bg);   color: var(--go);   border-color: var(--go-line); }
.badge.amber,  .badge[data-verdict="AMBER"]  { background: var(--hold-bg); color: var(--hold); border-color: var(--hold-line); }
.badge.red,    .badge[data-verdict="RED"]    { background: var(--stop-bg); color: var(--stop); border-color: var(--stop-line); }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.badge.plain  { background: transparent; }
button.badge { cursor: pointer; }
button.badge:hover { filter: brightness(.97); }

.dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; background: var(--ink-4); }
.dot.green { background: var(--go); }
.dot.amber { background: var(--hold); }
.dot.red { background: var(--stop); }
.dot.accent { background: var(--accent); }

/* Severity — critical/high are red, medium amber, low neutral. Never decorative. */
[data-sev="critical"] { --sev: var(--stop); --sev-bg: var(--stop-bg); --sev-line: var(--stop-line); }
[data-sev="high"]     { --sev: var(--stop); --sev-bg: var(--stop-bg); --sev-line: var(--stop-line); }
[data-sev="medium"]   { --sev: var(--hold); --sev-bg: var(--hold-bg); --sev-line: var(--hold-line); }
[data-sev="low"]      { --sev: var(--ink-3); --sev-bg: var(--sunk);   --sev-line: var(--rule); }
.sev-badge {
  display: inline-flex; align-items: center; height: 18px; padding: 0 6px;
  font: 600 var(--fs-micro)/1 var(--ui); letter-spacing: .03em; text-transform: capitalize;
  color: var(--sev); background: var(--sev-bg); border: 1px solid var(--sev-line); border-radius: var(--radius-sm);
}
.sev-rail { width: 3px; align-self: stretch; border-radius: 2px; background: var(--sev); flex: 0 0 auto; }

/* Exception status */
.status-pill {
  display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 7px;
  font: 500 var(--fs-micro)/1 var(--ui); border-radius: 10px; text-transform: capitalize;
  background: var(--sunk); color: var(--ink-2); border: 1px solid var(--rule);
}
.status-pill[data-status="open"]         { background: var(--stop-bg); color: var(--stop); border-color: var(--stop-line); }
.status-pill[data-status="acknowledged"] { background: var(--hold-bg); color: var(--hold); border-color: var(--hold-line); }
.status-pill[data-status="assigned"]     { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.status-pill[data-status="snoozed"]      { background: var(--sunk); color: var(--ink-3); border-color: var(--rule); }
.status-pill[data-status="resolved"]     { background: var(--go-bg); color: var(--go); border-color: var(--go-line); }

/* Deltas — up/down is neutral by default; the caller says whether up is good. */
.delta { display: inline-flex; align-items: baseline; gap: 3px; font-family: var(--mono); font-size: var(--fs-micro); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.delta .arrow { font-size: 10px; line-height: 1; }
.delta.good { color: var(--go); }
.delta.bad { color: var(--stop); }
.delta.flat { color: var(--ink-4); }

.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  font: 600 10px/1 var(--ui); letter-spacing: .04em; border: 1px solid var(--accent-line);
}
.avatar.lg { width: 30px; height: 30px; font-size: 11px; }
.avatar.none { background: var(--sunk); color: var(--ink-4); border-color: var(--rule); }

/* -------------------------------------------------------------------------------------------------
   6. Rail — 232px, collapsible to 56px, state persisted (PLATFORM §8)
   ------------------------------------------------------------------------------------------------- */
.rail {
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--rail-bg); border-right: 1px solid var(--rule);
  min-width: 0; overflow: hidden;
}

.rail-head {
  display: flex; align-items: center; gap: 9px;
  height: var(--topbar-h); padding: 0 10px 0 14px;
  border-bottom: 1px solid var(--rule);
}
.rail-mark { display: flex; color: var(--accent); flex: 0 0 auto; }
.rail-mark svg { display: block; }
.rail-name { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.rail-name b { font: 600 14px/1.15 var(--display); letter-spacing: .005em; color: var(--ink); }
.rail-name span { font-size: 10px; color: var(--ink-3); letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-collapse { margin-left: auto; }

.rail-nav { overflow-y: auto; overflow-x: hidden; padding: 8px 8px 12px; }
.rail-section {
  font: 600 var(--fs-micro)/1 var(--ui); letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-4); padding: 12px 8px 6px;
}
.rail-link {
  display: flex; align-items: center; gap: 9px;
  height: 30px; padding: 0 8px; margin-bottom: 1px;
  border-radius: var(--radius); color: var(--ink-2);
  font-size: var(--fs-table); font-weight: 500; text-decoration: none;
  position: relative; cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.rail-link:hover { background: var(--rule-soft); color: var(--ink); text-decoration: none; }
.rail-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.rail-link.active::before {
  content: ""; position: absolute; left: -8px; top: 6px; bottom: 6px;
  width: 3px; border-radius: 0 2px 2px 0; background: var(--accent);
}
.rail-link .ico { display: flex; width: 16px; height: 16px; flex: 0 0 auto; align-items: center; justify-content: center; color: currentColor; }
.rail-link .ico svg { display: block; width: 16px; height: 16px; }
.rail-link .label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-link .count {
  font: 500 var(--fs-micro)/1 var(--mono); color: var(--ink-3);
  background: var(--sunk); border: 1px solid var(--rule); border-radius: 9px; padding: 2px 6px;
}
.rail-link .count.alert { color: var(--stop); background: var(--stop-bg); border-color: var(--stop-line); }
.rail-link .key {
  font: 500 var(--fs-micro)/1 var(--mono); color: var(--ink-4); opacity: 0;
  transition: opacity var(--dur) var(--ease);
}
.rail-link:hover .key, .rail-link:focus-visible .key { opacity: 1; }

.rail-sub { padding-left: 14px; margin-bottom: 4px; border-left: 1px solid var(--rule); margin-left: 15px; }
.rail-sub .rail-link { height: 26px; font-size: var(--fs-small); font-weight: 400; color: var(--ink-3); }
.rail-sub .rail-link.active::before { display: none; }
.rail-sub .rail-link .pin { color: var(--ink-4); font-size: 10px; }
.rail-empty { padding: 4px 8px 6px 8px; font-size: var(--fs-micro); color: var(--ink-4); line-height: 1.4; }

.rail-foot { border-top: 1px solid var(--rule); padding: 8px; }
.rail-user {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 6px 8px; border: 1px solid transparent; border-radius: var(--radius);
  background: transparent; cursor: pointer; text-align: left; color: var(--ink);
}
.rail-user:hover { background: var(--rule-soft); border-color: var(--rule); }
.rail-user .who { min-width: 0; flex: 1 1 auto; line-height: 1.2; }
.rail-user .who b { display: block; font-size: var(--fs-small); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-user .who span { display: block; font-size: var(--fs-micro); color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-tenant {
  padding: 2px 8px 8px; font-size: var(--fs-micro); color: var(--ink-4);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Collapsed rail: icons only, labels hidden but still in the accessibility tree via title/aria. */
:root[data-rail="collapsed"] .rail-head { padding: 0; justify-content: center; }
:root[data-rail="collapsed"] .rail-name,
:root[data-rail="collapsed"] .rail-collapse,
:root[data-rail="collapsed"] .rail-link .label,
:root[data-rail="collapsed"] .rail-link .key,
:root[data-rail="collapsed"] .rail-section,
:root[data-rail="collapsed"] .rail-sub,
:root[data-rail="collapsed"] .rail-empty,
:root[data-rail="collapsed"] .rail-user .who,
:root[data-rail="collapsed"] .rail-tenant { display: none; }
:root[data-rail="collapsed"] .rail-nav { padding: 8px 6px; }
:root[data-rail="collapsed"] .rail-link { justify-content: center; padding: 0; }
:root[data-rail="collapsed"] .rail-link.active::before { left: -6px; }
:root[data-rail="collapsed"] .rail-link .count {
  position: absolute; top: 1px; right: 1px; padding: 0 3px; min-width: 14px; text-align: center;
  font-size: 9px; line-height: 13px; border-radius: 7px;
}
:root[data-rail="collapsed"] .rail-user { justify-content: center; padding: 6px 0; }

/* -------------------------------------------------------------------------------------------------
   7. Top bar
   ------------------------------------------------------------------------------------------------- */
.topbar {
  display: flex; align-items: center; gap: 10px;
  height: var(--topbar-h); padding: 0 14px;
  background: var(--surface); border-bottom: 1px solid var(--rule);
  min-width: 0;
}
.topbar h1 {
  font: 600 15px/1.2 var(--display); letter-spacing: .005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar .crumb { display: flex; align-items: baseline; gap: 7px; min-width: 0; }
.topbar .crumb .sub {
  font-size: var(--fs-small); color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 42ch;
}
.topbar-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }

.omni {
  display: flex; align-items: center; gap: 6px;
  height: 28px; min-width: 210px; max-width: 300px; padding: 0 8px;
  background: var(--sunk); border: 1px solid var(--rule); border-radius: var(--radius);
  color: var(--ink-3); cursor: pointer; font: 400 var(--fs-small)/1 var(--ui);
}
.omni:hover { border-color: var(--rule-strong); background: var(--surface); }
.omni .ico { display: flex; flex: 0 0 auto; }
.omni .txt { flex: 1 1 auto; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.omni .kbd { background: var(--surface); }

/* the as-of / freshness chip */
.freshness {
  display: inline-flex; align-items: center; gap: 7px;
  height: 28px; padding: 0 9px;
  background: var(--surface); border: 1px solid var(--rule-strong); border-radius: var(--radius);
  cursor: pointer; color: var(--ink-2); font: 400 var(--fs-micro)/1 var(--ui); white-space: nowrap;
}
.freshness:hover { background: var(--sunk); }
.freshness b { font-family: var(--mono); font-weight: 500; color: var(--ink); font-size: var(--fs-small); }
.freshness .lbl { color: var(--ink-3); }

/* -------------------------------------------------------------------------------------------------
   8. Panels, tiles
   ------------------------------------------------------------------------------------------------- */
.panel {
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-lg);
  min-width: 0; overflow: hidden;
}
.panel.flush { border-radius: var(--radius); }
.panel-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; border-bottom: 1px solid var(--rule); background: var(--surface-2);
}
.panel-head h2, .panel-head h3 { font: 600 var(--fs-body)/1.3 var(--ui); }
.panel-head .sub { font-size: var(--fs-small); color: var(--ink-3); }
.panel-head .spacer { flex: 1 1 auto; }
.panel-body { padding: 14px; }
.panel-body.flush { padding: 0; }
.panel-foot {
  padding: 8px 14px; border-top: 1px solid var(--rule); background: var(--surface-2);
  font-size: var(--fs-micro); color: var(--ink-3);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}

/* A metric tile: value, delta, sparkline, sourcing badge. */
.tile {
  display: flex; flex-direction: column; gap: 6px;
  padding: 12px 13px; min-width: 0;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-lg);
  text-align: left; cursor: pointer; color: inherit;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.tile:hover { border-color: var(--rule-strong); box-shadow: var(--shadow); }
.tile:disabled, .tile.static { cursor: default; }
.tile-top { display: flex; align-items: flex-start; gap: 8px; }
.tile-label { flex: 1 1 auto; font-size: var(--fs-small); font-weight: 600; color: var(--ink-2); min-width: 0; }
.tile-value { font: 600 25px/1.05 var(--display); font-variant-numeric: tabular-nums; letter-spacing: -.012em; color: var(--ink); }
.tile-value.sm { font-size: 20px; }
.tile-unit { font-size: 14px; color: var(--ink-3); font-weight: 400; margin-left: 2px; }
.tile-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: var(--fs-micro); color: var(--ink-3); }
.tile-spark { height: 26px; margin-top: 2px; }
.tile-note { font-size: var(--fs-micro); color: var(--ink-3); line-height: 1.4; }

/* Definition rows — used everywhere a label/value pair is shown. */
.dl { display: grid; grid-template-columns: minmax(120px, max-content) minmax(0, 1fr); gap: 3px 14px; font-size: var(--fs-small); }
.dl dt { color: var(--ink-3); }
.dl dd { margin: 0; color: var(--ink); font-family: var(--mono); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.dl dd.prose { font-family: var(--ui); }

.kv-strip { display: flex; gap: 20px; flex-wrap: wrap; }
.kv { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.kv .k { font-size: var(--fs-micro); color: var(--ink-3); letter-spacing: .02em; }
.kv .v { font: 500 var(--fs-body)/1.2 var(--mono); font-variant-numeric: tabular-nums; color: var(--ink); }

.callout {
  display: flex; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--rule); border-left-width: 3px; border-radius: var(--radius);
  background: var(--surface-2); font-size: var(--fs-small); color: var(--ink-2); line-height: 1.5;
}
.callout.info  { border-left-color: var(--accent); }
.callout.good  { border-left-color: var(--go); background: var(--go-bg); color: var(--ink-2); }
.callout.warn  { border-left-color: var(--hold); background: var(--hold-bg); color: var(--ink-2); }
.callout.bad   { border-left-color: var(--stop); background: var(--stop-bg); color: var(--ink-2); }
.callout b { color: var(--ink); }

/* -------------------------------------------------------------------------------------------------
   9. Filter builder
   ------------------------------------------------------------------------------------------------- */
.fb { display: flex; flex-direction: column; gap: 0; }
.fb-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 12px; background: var(--surface-2); border-bottom: 1px solid var(--rule);
}
.fb-chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex: 1 1 auto; min-width: 0; }
.fb-chip {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 4px 0 8px;
  background: var(--surface); border: 1px solid var(--rule-strong); border-radius: var(--radius);
  font: 400 var(--fs-micro)/1 var(--ui); color: var(--ink-2); white-space: nowrap; max-width: 100%;
}
.fb-chip .k { color: var(--ink-3); }
.fb-chip .op { color: var(--ink-4); font-family: var(--mono); }
.fb-chip .v { font-family: var(--mono); color: var(--ink); font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.fb-chip button {
  width: 16px; height: 16px; border: 0; border-radius: var(--radius-sm); padding: 0;
  background: transparent; color: var(--ink-3); cursor: pointer; font-size: 13px; line-height: 1;
}
.fb-chip button:hover { background: var(--stop-bg); color: var(--stop); }
.fb-chip.editing { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

.fb-none { font-size: var(--fs-small); color: var(--ink-4); }
.fb-count { font: 500 var(--fs-small)/1 var(--mono); color: var(--ink); white-space: nowrap; }
.fb-count .n { font-weight: 600; }
.fb-count.stale { color: var(--ink-4); }

.fb-editor {
  display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 0;
  border-bottom: 1px solid var(--rule); background: var(--surface);
  max-height: 320px;
}
.fb-editor[hidden] { display: none !important; }
.fb-keys { overflow-y: auto; border-right: 1px solid var(--rule); background: var(--surface-2); padding: 6px; }
.fb-keys .fb-group { font: 600 var(--fs-micro)/1 var(--ui); letter-spacing: .07em; text-transform: uppercase; color: var(--ink-4); padding: 9px 8px 5px; }
.fb-key {
  display: flex; align-items: center; gap: 6px; width: 100%;
  padding: 4px 8px; border: 0; border-radius: var(--radius-sm); background: transparent;
  font: 400 var(--fs-small)/1.3 var(--ui); color: var(--ink-2); text-align: left; cursor: pointer;
}
.fb-key:hover { background: var(--rule-soft); color: var(--ink); }
.fb-key[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.fb-key .applied { margin-left: auto; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.fb-form { padding: 12px 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.fb-form h4 { font: 600 var(--fs-body)/1.3 var(--ui); }
.fb-form .fname { font-family: var(--mono); font-size: var(--fs-micro); color: var(--ink-3); }
.fb-form .help { font-size: var(--fs-small); color: var(--ink-3); line-height: 1.5; max-width: 62ch; }
.fb-form .controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fb-opts { display: flex; flex-wrap: wrap; gap: 4px; max-height: 156px; overflow-y: auto; padding: 2px; }
.fb-opt {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 8px;
  border: 1px solid var(--rule-strong); border-radius: 12px; background: var(--surface);
  font: 400 var(--fs-micro)/1 var(--ui); color: var(--ink-2); cursor: pointer; white-space: nowrap;
}
.fb-opt:hover { background: var(--sunk); }
.fb-opt[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); font-weight: 600; }
.fb-opt code { font-family: var(--mono); font-size: 10px; opacity: .75; }

/* -------------------------------------------------------------------------------------------------
   10. States — empty, error, skeleton
   ------------------------------------------------------------------------------------------------- */
.state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 44px 24px; text-align: center; min-height: 180px;
}
.state .ico { color: var(--ink-4); margin-bottom: 2px; }
.state h3 { font: 600 var(--fs-body)/1.3 var(--ui); color: var(--ink); }
.state p { font-size: var(--fs-small); color: var(--ink-3); max-width: 56ch; line-height: 1.55; }
.state .actions { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; justify-content: center; }
.state.error h3 { color: var(--stop); }
.state.error .ico { color: var(--stop); }
.state pre.detail {
  font: 400 var(--fs-micro)/1.5 var(--mono); color: var(--ink-3);
  background: var(--sunk); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 8px 10px; margin: 4px 0 0; max-width: 72ch; text-align: left;
  white-space: pre-wrap; overflow-wrap: anywhere; max-height: 180px; overflow: auto;
}

.skel { background: var(--skeleton); background-size: 220% 100%; border-radius: var(--radius-sm); animation: shimmer 1.35s linear infinite; }
.skel-line { height: 10px; }
.skel-tile { height: 108px; border-radius: var(--radius-lg); }
.skel-row { height: var(--row-h); border-radius: 0; }
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }

.loading-bar {
  position: absolute; left: 0; right: 0; top: 0; height: 2px; overflow: hidden;
  background: transparent; pointer-events: none; z-index: 60;
}
.loading-bar::after {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 35%;
  background: var(--accent); animation: slide 1.05s ease-in-out infinite;
}
@keyframes slide { 0% { left: -35%; } 100% { left: 100%; } }

/* -------------------------------------------------------------------------------------------------
   11. Table — sticky header, zebra-free, hairline rules, right-aligned tabular figures
   ------------------------------------------------------------------------------------------------- */
.tbl-shell { display: flex; flex-direction: column; min-width: 0; }
.tbl-toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 7px 12px; border-bottom: 1px solid var(--rule); background: var(--surface-2);
}
.tbl-toolbar .caption { font-size: var(--fs-small); color: var(--ink-2); font-weight: 500; }
.tbl-toolbar .count { font: 400 var(--fs-small)/1 var(--mono); color: var(--ink-3); }

.tbl-scroll { overflow: auto; max-height: var(--tbl-max-h, none); min-width: 0; position: relative; }

table.tbl {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: var(--fs-table); color: var(--ink);
}
table.tbl thead th {
  position: sticky; top: 0; z-index: 3;
  background: var(--surface-2); color: var(--ink-3);
  font: 600 var(--fs-micro)/1 var(--ui); letter-spacing: .04em; text-transform: uppercase;
  text-align: left; white-space: nowrap;
  padding: 0 10px; height: 30px;
  border-bottom: 1px solid var(--rule-strong);
  box-shadow: inset 0 -1px 0 var(--rule-strong);
}
table.tbl thead th.num, table.tbl thead th[data-align="right"] { text-align: right; }
table.tbl thead th.sortable { cursor: pointer; user-select: none; }
table.tbl thead th.sortable:hover { color: var(--ink); background: var(--sunk); }
table.tbl thead th .th-in { display: inline-flex; align-items: center; gap: 4px; }
table.tbl thead th[data-align="right"] .th-in { flex-direction: row-reverse; }
table.tbl thead th .sort-ind { font-size: 9px; color: var(--accent); width: 8px; }
table.tbl thead th .sort-ind.off { color: var(--ink-4); opacity: 0; }
table.tbl thead th.sortable:hover .sort-ind.off { opacity: .6; }

table.tbl tbody td {
  height: var(--row-h); padding: 0 10px;
  border-bottom: 1px solid var(--rule-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 34ch;
  vertical-align: middle;
}
table.tbl tbody td.num, table.tbl tbody td[data-align="right"] {
  text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums;
}
table.tbl tbody td.mono { font-family: var(--mono); }
table.tbl tbody td.wrap { white-space: normal; max-width: 52ch; }
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl tbody tr.clickable { cursor: pointer; }
table.tbl tbody tr.clickable:hover td { background: var(--sunk); }
table.tbl tbody tr[aria-selected="true"] td { background: var(--accent-soft); }
table.tbl tbody tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
table.tbl tbody tr.subdued td { color: var(--ink-3); }
table.tbl tfoot td {
  position: sticky; bottom: 0; z-index: 2;
  height: 30px; padding: 0 10px;
  background: var(--surface-2); border-top: 1px solid var(--rule-strong);
  font: 600 var(--fs-small)/1 var(--ui); color: var(--ink-2);
}
table.tbl tfoot td.num, table.tbl tfoot td[data-align="right"] {
  text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums;
}
table.tbl td .cell-sub { color: var(--ink-3); font-size: var(--fs-micro); }
table.tbl td a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--rule-strong); }
table.tbl td a:hover { color: var(--accent); border-bottom-color: var(--accent); text-decoration: none; }

.tbl-pager {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 12px; border-top: 1px solid var(--rule); background: var(--surface-2);
  font-size: var(--fs-small); color: var(--ink-3);
}

/* column picker popover body */
.colpick { min-width: 216px; max-height: 340px; overflow-y: auto; padding: 6px; }
.colpick .row-item {
  display: flex; align-items: center; gap: 8px; padding: 4px 7px;
  border-radius: var(--radius-sm); font-size: var(--fs-small); cursor: pointer; color: var(--ink-2);
}
.colpick .row-item:hover { background: var(--rule-soft); }
.colpick .row-item input { accent-color: var(--accent); margin: 0; }
.colpick .row-item .lock { margin-left: auto; font-size: var(--fs-micro); color: var(--ink-4); }
.colpick-foot { display: flex; gap: 6px; padding: 6px; border-top: 1px solid var(--rule); }

/* -------------------------------------------------------------------------------------------------
   12. Charts
   ------------------------------------------------------------------------------------------------- */
.chart { display: block; width: 100%; overflow: visible; }
.chart text { font-family: var(--mono); font-variant-numeric: tabular-nums; fill: var(--ink-3); }
.chart .ax-label { font-family: var(--ui); font-size: 10px; fill: var(--ink-3); }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis-line { stroke: var(--grid-strong); stroke-width: 1; shape-rendering: crispEdges; }
.chart .zero-line { stroke: var(--rule-strong); stroke-width: 1; shape-rendering: crispEdges; }
.chart .series-line { fill: none; stroke-linejoin: round; stroke-linecap: round; }
.chart .series-area { stroke: none; }
.chart .bar { shape-rendering: crispEdges; }
.chart .bar:hover { filter: brightness(1.12); }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .crosshair { stroke: var(--ink-4); stroke-width: 1; stroke-dasharray: 2 2; pointer-events: none; }
.chart .marker { pointer-events: none; }
.chart .threshold { stroke-width: 2; shape-rendering: crispEdges; }
.chart .threshold-label { font-size: 9px; font-family: var(--ui); }

.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: var(--fs-micro); color: var(--ink-3); padding-top: 6px; }
.chart-legend .item { display: inline-flex; align-items: center; gap: 5px; }
.chart-legend .swatch { width: 9px; height: 9px; border-radius: 2px; flex: 0 0 auto; }

.chart-readout {
  position: absolute; z-index: 12; pointer-events: none;
  background: var(--surface); border: 1px solid var(--rule-strong); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 6px 8px; font-size: var(--fs-micro); color: var(--ink);
  white-space: nowrap; min-width: 90px;
}
.chart-readout .rd-t { color: var(--ink-3); margin-bottom: 3px; }
.chart-readout .rd-r { display: flex; align-items: center; gap: 6px; }
.chart-readout .rd-r .v { margin-left: auto; font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 500; }
.chart-frame { position: relative; min-width: 0; }

/* -------------------------------------------------------------------------------------------------
   13. Overlays — scrim, popover, modal, drawer, palette, shortcuts sheet
   ------------------------------------------------------------------------------------------------- */
.scrim {
  position: fixed; inset: 0; z-index: 90; background: var(--scrim);
  animation: fade var(--dur) var(--ease);
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.popover {
  position: fixed; z-index: 120;
  background: var(--surface); border: 1px solid var(--rule-strong); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); min-width: 180px; max-width: min(420px, calc(100vw - 24px));
  animation: pop var(--dur) var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.popover-head { padding: 9px 12px; border-bottom: 1px solid var(--rule); }
.popover-head h3 { font: 600 var(--fs-small)/1.3 var(--ui); }
.popover-head .sub { font-size: var(--fs-micro); color: var(--ink-3); }
.popover-body { padding: 10px 12px; font-size: var(--fs-small); color: var(--ink-2); }
.popover-body.flush { padding: 0; }
.popover-foot { padding: 8px 12px; border-top: 1px solid var(--rule); background: var(--surface-2); font-size: var(--fs-micro); color: var(--ink-3); }

.menu { padding: 5px; min-width: 200px; }
.menu-label { padding: 7px 9px 4px; font: 600 var(--fs-micro)/1 var(--ui); letter-spacing: .07em; text-transform: uppercase; color: var(--ink-4); }
.menu-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 6px 9px; border: 0; border-radius: var(--radius-sm); background: transparent;
  font: 400 var(--fs-small)/1.35 var(--ui); color: var(--ink-2); text-align: left; cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--rule-soft); color: var(--ink); }
.menu-item[aria-checked="true"] { color: var(--accent); font-weight: 600; }
.menu-item .tick { margin-left: auto; color: var(--accent); font-size: 11px; }
.menu-item .meta { margin-left: auto; font-size: var(--fs-micro); color: var(--ink-4); }
.menu-item .who { min-width: 0; }
.menu-item .who b { display: block; font-weight: 600; }
.menu-item .who span { display: block; font-size: var(--fs-micro); color: var(--ink-3); }
.menu-sep { height: 1px; background: var(--rule); margin: 5px 0; }

.modal {
  position: fixed; z-index: 100; left: 50%; top: 8vh; transform: translateX(-50%);
  width: min(760px, calc(100vw - 32px)); max-height: 84vh;
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--rule-strong); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); overflow: hidden;
  animation: rise var(--dur) var(--ease);
}
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--rule); }
.modal-head h2 { font: 600 16px/1.3 var(--display); }
.modal-body { padding: 16px; overflow-y: auto; font-size: var(--fs-small); color: var(--ink-2); line-height: 1.6; }
.modal-foot { padding: 10px 16px; border-top: 1px solid var(--rule); background: var(--surface-2); display: flex; gap: 8px; align-items: center; }

.drawer {
  position: fixed; z-index: 100; top: 0; right: 0; bottom: 0;
  width: min(720px, 94vw); display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--rule-strong); box-shadow: var(--shadow-lg);
  animation: slidein 180ms var(--ease);
}
@keyframes slidein { from { transform: translateX(24px); opacity: .4; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: flex-start; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--rule); }
.drawer-head h2 { font: 600 15px/1.3 var(--display); }
.drawer-head .sub { font-size: var(--fs-small); color: var(--ink-3); }
.drawer-body { flex: 1 1 auto; overflow-y: auto; padding: 16px; }
.drawer-foot { padding: 10px 16px; border-top: 1px solid var(--rule); background: var(--surface-2); display: flex; gap: 8px; }

/* Command palette */
.palette {
  position: fixed; z-index: 130; left: 50%; top: 11vh; transform: translateX(-50%);
  width: min(640px, calc(100vw - 32px)); max-height: 70vh;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--rule-strong); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: rise var(--dur) var(--ease);
}
.palette-input { display: flex; align-items: center; gap: 9px; padding: 12px 14px; border-bottom: 1px solid var(--rule); }
.palette-input .ico { color: var(--ink-4); display: flex; flex: 0 0 auto; }
.palette-input input {
  flex: 1 1 auto; border: 0; background: transparent; outline: none;
  font: 400 15px/1.3 var(--ui); color: var(--ink); min-width: 0;
}
.palette-input input::placeholder { color: var(--ink-4); }
.palette-input .status { font-size: var(--fs-micro); color: var(--ink-4); font-family: var(--mono); }
.palette-list { overflow-y: auto; padding: 5px; flex: 1 1 auto; }
.palette-group { padding: 9px 10px 4px; font: 600 var(--fs-micro)/1 var(--ui); letter-spacing: .07em; text-transform: uppercase; color: var(--ink-4); }
.palette-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 7px 10px; border: 0; border-radius: var(--radius); background: transparent;
  text-align: left; cursor: pointer; color: var(--ink-2); font-size: var(--fs-small);
}
.palette-item[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); }
.palette-item .ico { display: flex; width: 16px; flex: 0 0 auto; color: var(--ink-4); }
.palette-item[aria-selected="true"] .ico { color: var(--accent); }
.palette-item .txt { min-width: 0; flex: 1 1 auto; }
.palette-item .txt b { display: block; font-weight: 500; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item[aria-selected="true"] .txt b { color: var(--accent); }
.palette-item .txt span { display: block; font-size: var(--fs-micro); color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item .txt mark { background: transparent; color: var(--accent); font-weight: 700; }
.palette-item .hint { margin-left: auto; flex: 0 0 auto; font-size: var(--fs-micro); color: var(--ink-4); font-family: var(--mono); }
.palette-foot {
  display: flex; align-items: center; gap: 14px; padding: 7px 12px;
  border-top: 1px solid var(--rule); background: var(--surface-2);
  font-size: var(--fs-micro); color: var(--ink-3);
}
.palette-foot .hintk { display: inline-flex; align-items: center; gap: 5px; }

/* Shortcuts sheet */
.sheet-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 32px; }
@media (max-width: 640px) { .sheet-cols { grid-template-columns: minmax(0, 1fr); } }
.sheet-group h3 { font: 600 var(--fs-small)/1.3 var(--ui); margin-bottom: 7px; color: var(--ink); }
.sheet-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; border-bottom: 1px solid var(--rule-soft); font-size: var(--fs-small); }
.sheet-row:last-child { border-bottom: 0; }
.sheet-row .keys { margin-left: auto; display: inline-flex; gap: 3px; align-items: center; flex: 0 0 auto; }
.sheet-row .keys .then { color: var(--ink-4); font-size: var(--fs-micro); }

/* -------------------------------------------------------------------------------------------------
   14. Toasts
   ------------------------------------------------------------------------------------------------- */
.toast-root {
  position: fixed; z-index: 150; right: 16px; bottom: 16px;
  display: flex; flex-direction: column-reverse; gap: 8px;
  max-width: min(420px, calc(100vw - 32px)); pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; pointer-events: auto;
  background: var(--surface); border: 1px solid var(--rule-strong); border-left-width: 3px;
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  animation: toastin 180ms var(--ease);
}
.toast.leaving { animation: toastout 150ms var(--ease) forwards; }
@keyframes toastin { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toastout { to { opacity: 0; transform: translateY(6px) scale(.98); } }
.toast[data-kind="success"] { border-left-color: var(--go); }
.toast[data-kind="warn"] { border-left-color: var(--hold); }
.toast[data-kind="error"] { border-left-color: var(--stop); }
.toast[data-kind="info"] { border-left-color: var(--accent); }
.toast .body { flex: 1 1 auto; min-width: 0; }
.toast .msg { font-size: var(--fs-small); color: var(--ink); line-height: 1.45; }
.toast .detail { font-size: var(--fs-micro); color: var(--ink-3); margin-top: 3px; line-height: 1.45; overflow-wrap: anywhere; }
.toast .acts { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.toast .close { color: var(--ink-4); }
.toast .bar { position: absolute; }

/* -------------------------------------------------------------------------------------------------
   15. Utilities and motion
   ------------------------------------------------------------------------------------------------- */
.trunc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.flex1 { flex: 1 1 auto; min-width: 0; }
.pad { padding: var(--pad); }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 6px; } .mt-2 { margin-top: 12px; } .mt-3 { margin-top: 18px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 6px; } .mb-2 { margin-bottom: 12px; } .mb-3 { margin-bottom: 18px; }
.gap-1 { gap: 6px; } .gap-2 { gap: 12px; } .gap-3 { gap: 18px; }
.hidden, [hidden] { display: none !important; }
.prose { max-width: 74ch; font-size: var(--fs-small); line-height: 1.6; color: var(--ink-2); }
.prose b, .prose strong { color: var(--ink); font-weight: 600; }
code.inline {
  font: 400 var(--fs-micro)/1.4 var(--mono); padding: 1px 4px;
  background: var(--sunk); border: 1px solid var(--rule); border-radius: var(--radius-sm); color: var(--ink-2);
}
pre.code {
  font: 400 var(--fs-small)/1.55 var(--mono); color: var(--ink);
  background: var(--sunk); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 10px 12px; margin: 0; overflow-x: auto;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .skel { animation: none; background: var(--sunk); }
}

@media print {
  .rail, .topbar, .toast-root, .palette, .scrim { display: none !important; }
  .shell { grid-template-columns: 1fr; }
  body { overflow: visible; }
  .content { overflow: visible; padding: 0; }
}

/* -------------------------------------------------------------------------------------------------

   16. Surface: Exceptions  (web/views/exceptions.js)

   The worklist. Owned by the exceptions surface — nothing else on the platform uses these classes,
   and no other surface's block may edit them. Everything here builds on the shared vocabulary
   (.panel, .chip, .status-pill, .sev-badge) rather than restating it; the only genuinely new shape
   is the audit timeline, which no other surface needs.
   ------------------------------------------------------------------------------------------------- */

/* The status scopes — a count strip that is also the status filter. Denser than tiles, and every
   number on it is a link to the list it describes. */
.exc-scopes { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.exc-scope {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  min-width: 92px; padding: 6px 10px 7px; cursor: pointer; text-align: left;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius);
  color: var(--ink-3); font: inherit; transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.exc-scope:hover { border-color: var(--rule-strong); background: var(--surface-2); }
.exc-scope:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.exc-scope[aria-pressed="true"] { border-color: var(--accent-line); background: var(--accent-soft); }
.exc-scope[aria-pressed="true"] .exc-scope-l { color: var(--accent); }
.exc-scope-n {
  font: 600 17px/1.1 var(--mono); font-variant-numeric: tabular-nums; color: var(--ink);
}
.exc-scope-l { font-size: var(--fs-micro); letter-spacing: .02em; }
.exc-scope[data-zero] .exc-scope-n { color: var(--ink-4); }
.exc-scope[data-status="open"][aria-pressed="true"] { border-color: var(--stop-line); background: var(--stop-bg); }
.exc-scope[data-status="open"][aria-pressed="true"] .exc-scope-l { color: var(--stop); }
.exc-scope[data-status="resolved"][aria-pressed="true"] { border-color: var(--go-line); background: var(--go-bg); }
.exc-scope[data-status="resolved"][aria-pressed="true"] .exc-scope-l { color: var(--go); }

.exc-search { min-width: 250px; flex: 0 1 320px; }
.exc-stake { white-space: nowrap; }
.exc-stake .k + .v { margin-left: 2px; }

/* The bulk bar. Hidden until something is ticked, so it costs no vertical space when idle. */
.exc-selbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 10px 0 0; padding: 7px 10px;
  background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: var(--radius);
}
.exc-selcount { font-weight: 600; font-size: var(--fs-small); color: var(--accent); }
.exc-selstake {
  font: 400 var(--fs-small)/1 var(--mono); font-variant-numeric: tabular-nums; color: var(--ink-2);
}
.exc-panel { margin-top: 10px; }

/* Rows. The title is a real anchor so middle-click and copy-link-address work on a worklist item. */
.exc-title { color: var(--ink); font-weight: 500; text-decoration: none; }
.exc-title:hover { color: var(--accent); text-decoration: underline; }
table.tbl td .exc-sub { display: block; font-family: var(--mono); }
table.tbl td .exc-cellsub { display: block; }
.exc-owner { gap: 6px; white-space: nowrap; }

/* The detail drawer. */
.exc-detail-tags { align-items: center; }
.exc-detail .panel { box-shadow: none; }
.exc-note { margin: 0; color: var(--ink-3); }
.exc-field {
  padding: 2px 6px; background: var(--sunk);
  border: 1px solid var(--rule); border-radius: var(--radius-sm); color: var(--ink-2);
}
.exc-efx { font: 400 var(--fs-micro)/1 var(--mono); color: var(--hold); }

/* The audit timeline — who moved this, from what to what, when, and what they said about it.
   A rule down the left with a dot per entry, coloured by the status the entry moved it into. */
.exc-history { list-style: none; margin: 0; padding: 0 0 0 2px; }
.exc-hist { position: relative; display: flex; gap: 10px; padding: 0 0 14px 0; }
.exc-hist:last-child { padding-bottom: 0; }
.exc-hist::before {
  content: ""; position: absolute; left: 4px; top: 13px; bottom: 0; width: 1px; background: var(--rule);
}
.exc-hist:last-child::before { display: none; }
.exc-hist-dot {
  position: relative; z-index: 1; flex: 0 0 auto;
  width: 9px; height: 9px; margin-top: 4px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--rule-strong);
}
.exc-hist-dot[data-status="open"]         { border-color: var(--stop); }
.exc-hist-dot[data-status="acknowledged"] { border-color: var(--hold); }
.exc-hist-dot[data-status="assigned"]     { border-color: var(--accent); }
.exc-hist-dot[data-status="resolved"]     { border-color: var(--go); }
.exc-hist-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.exc-hist-line {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px;
  font-size: var(--fs-small); color: var(--ink-2);
}
.exc-hist-line strong { color: var(--ink); font-weight: 600; }
.exc-hist-note { margin: 0; color: var(--ink-2); }
.exc-hist-when {
  font: 400 var(--fs-micro)/1.3 var(--mono); color: var(--ink-4); font-variant-numeric: tabular-nums;
}

/* Modal validation — the one place this surface says no. */
.exc-problem {
  margin: 0; padding: 6px 9px; font-size: var(--fs-small);
  color: var(--stop); background: var(--stop-bg);
  border: 1px solid var(--stop-line); border-radius: var(--radius-sm);
}

@media (max-width: 900px) {
  .exc-search { flex: 1 1 100%; }
  .exc-scope { min-width: 78px; }
}

/* =================================================================================================
   SURFACE BLOCK — Overview  (web/views/overview.js)
   Owned by the Overview surface. Nothing outside web/views/overview.js uses these classes; nothing
   in here redefines a shell class. Every selector is prefixed `.ov-` except where it narrows a
   shell class inside `.ov-tile`.
   ================================================================================================= */

/* -- the compare-window control, in the top bar ---------------------------------------------------- */
.ov-compare { display: inline-flex; align-items: center; gap: 7px; }
.ov-compare-label { letter-spacing: .04em; }
@media (max-width: 1180px) { .ov-compare-label { display: none; } }
/* Under 1000px the chrome needs the room; the freshness chip carries the same control. */
@media (max-width: 1000px) { .ov-compare { display: none; } }

/* -- alert strip ---------------------------------------------------------------------------------- */
.ov-alerts {
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-lg);
  overflow: hidden; margin-bottom: 18px;
}
.ov-alerts-head {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; background: var(--surface-2); border-bottom: 1px solid var(--rule);
}
.ov-alerts-head .eyebrow { margin: 0; }
.ov-alerts-link { font-size: var(--fs-small); font-weight: 500; white-space: nowrap; }

.ov-alert-list { list-style: none; margin: 0; padding: 0; }
.ov-alert {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 10px 14px; border-bottom: 1px solid var(--rule-soft);
}
.ov-alert-list > li:last-child { border-bottom: 0; }
.ov-alert .sev-rail { margin-top: 1px; min-height: 30px; }
.ov-alert-body { flex: 1 1 auto; min-width: 0; }
.ov-alert-title { margin: 0 0 2px; font: 600 var(--fs-body)/1.35 var(--ui); color: var(--ink); }
.ov-alert-detail { margin: 0; font-size: var(--fs-small); line-height: 1.5; color: var(--ink-2); }
.ov-alert-detail b { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 500; color: var(--ink); }
.ov-alert-acts { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 900px) {
  .ov-alert { flex-wrap: wrap; }
  .ov-alert-acts { width: 100%; justify-content: flex-start; padding-left: 14px; }
}

/* -- the three-week past-due story, expanded under its alert row ----------------------------------- */
.ov-story-item { display: block; padding: 0 14px 14px 28px; border-bottom: 1px solid var(--rule-soft); }
.ov-story { display: flex; flex-direction: column; gap: 12px; }
.ov-story-cap { margin: 0; font-size: var(--fs-micro); line-height: 1.55; color: var(--ink-3); max-width: 96ch; }
.ov-story-cap .field-name { color: var(--ink-2); }
.ov-story-lines { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 5px; }
.ov-story-lines li { font-size: var(--fs-small); line-height: 1.55; color: var(--ink-2); }
.ov-story-lines li::marker { color: var(--ink-4); font-family: var(--mono); font-size: var(--fs-micro); }
.ov-story-table { border-radius: var(--radius); }
.ov-story-acts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* -- bands ----------------------------------------------------------------------------------------- */
.ov-band { display: flex; flex-direction: column; gap: 9px; }
.ov-band-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.ov-band-head .eyebrow { margin: 0; }
.ov-band-head h2 { font: 400 var(--fs-small)/1.3 var(--ui); color: var(--ink-3); }

/* -- tiles ------------------------------------------------------------------------------------------ */
.ov-tile { position: relative; gap: 5px; padding: 11px 13px 12px; }
.ov-tile.linked { cursor: pointer; }
.ov-tile.linked:hover { border-color: var(--accent-line); box-shadow: var(--shadow); }
.ov-tile:has(.ov-tile-link:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.ov-tile .ov-tile-link { color: inherit; text-decoration: none; }
.ov-tile .ov-tile-link:hover { text-decoration: none; }
.ov-tile .ov-tile-link:focus-visible { outline: none; }
.ov-tile .ov-tile-link::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius-lg); }

/* the sourcing badge stays a separate control, above the stretched link, and small */
.ov-tile .tile-top .badge {
  position: relative; z-index: 2;
  height: 16px; padding: 0 5px; font-size: 10px; letter-spacing: .02em;
}
.ov-tile .tile-value { font-size: 23px; }
.ov-tile .tile-meta { gap: 6px 10px; row-gap: 3px; }
.ov-tile .tile-note {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; color: var(--ink-3);
}
/* The sparkline and the note sit on the floor of the tile, so a row of tiles carrying different
   amounts of copy still shares one baseline across the grid. */
.ov-tile .tile-spark { margin-top: auto; padding-top: 6px; }

/* Figures sit above the stretched link so their own explanations are reachable on hover. They are
   small enough not to eat the tile's click target. */
.ov-fig { color: var(--ink-3); white-space: nowrap; position: relative; z-index: 2; }
.ov-fig[title] { cursor: help; }
.ov-fig b {
  font: 500 var(--fs-micro)/1 var(--mono); font-variant-numeric: tabular-nums; color: var(--ink-2);
}

.ov-nospark {
  display: flex; align-items: center; justify-content: center;
  border-top: 1px dashed var(--rule); margin-top: 8px;
}
.ov-nospark span {
  font-size: 10px; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-4);
  cursor: help; position: relative; z-index: 2;
}

.ov-tile-foot {
  font-size: var(--fs-micro); line-height: 1.45; color: var(--ink-4);
  padding-top: 6px; margin-top: 2px; border-top: 1px solid var(--rule-soft);
}

/* -- largest relationships, hung off band 3 --------------------------------------------------------- */
.ov-rels { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding-top: 2px; }
.ov-rels-label {
  font-size: var(--fs-micro); font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-4); margin-right: 2px;
}
.ov-rels .chip { max-width: 30ch; overflow: hidden; }
.ov-rels .chip .k { overflow: hidden; text-overflow: ellipsis; }
.ov-rels .chip:hover { text-decoration: none; }

/* -- band 2: three numbers, and the number of record ------------------------------------------------ */
.ov-margin-panel .panel-head .badge {
  height: 16px; padding: 0 5px; font-size: 10px; cursor: pointer;
}
.ov-margin { display: grid; grid-template-columns: minmax(0, 1.7fr) 1px minmax(0, 1fr); gap: 18px; }
.ov-margin-rule { background: var(--rule); }
.ov-rates { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.ov-rate { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ov-rate-label { font-size: var(--fs-small); font-weight: 600; color: var(--ink-2); }
.ov-rate-value {
  font: 600 30px/1.05 var(--display); font-variant-numeric: tabular-nums;
  letter-spacing: -.014em; color: var(--ink);
}
.ov-rate-meta { display: flex; align-items: center; gap: 8px; min-height: 15px; font-size: var(--fs-micro); }
.ov-rate-sub { font-size: var(--fs-micro); line-height: 1.45; color: var(--ink-3); }

.ov-nim { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ov-nim .eyebrow { margin: 0; }
.ov-nim-top { display: flex; align-items: center; gap: 8px; }
.ov-nim-top .ov-rate-label { flex: 1 1 auto; min-width: 0; }
.ov-nim .ov-rate-value { color: var(--ink-2); }
.ov-nim-note { margin: 4px 0 6px; font-size: var(--fs-micro); line-height: 1.5; color: var(--ink-3); }
.ov-nim .dl { font-size: var(--fs-micro); grid-template-columns: minmax(96px, max-content) minmax(0, 1fr); }
.ov-nim .dl dd { font-family: var(--ui); color: var(--ink-2); }
.ov-nim .dl dd:first-of-type { font-family: var(--mono); color: var(--ink); }

.ov-margin-panel .callout { margin-top: 14px; }

@media (max-width: 1180px) {
  .ov-margin { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .ov-margin-rule { height: 1px; width: 100%; }
}
@media (max-width: 720px) {
  .ov-rates { grid-template-columns: minmax(0, 1fr); }
}

/* -- the quiet footer that replaces the disclaimer banner -------------------------------------------- */
.ov-foot {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  margin-top: 20px; padding-top: 12px; border-top: 1px solid var(--rule);
}
.ov-score { display: inline-flex; gap: 5px; flex: 0 0 auto; }
.ov-foot-text {
  flex: 1 1 380px; min-width: 0;
  font-size: var(--fs-micro); line-height: 1.55; color: var(--ink-3); max-width: 108ch;
}

/* -------------------------------------------------------------------------------------------------
   16. Portfolio surface — web/views/portfolio.js
   View-scoped. Everything here is prefixed `.pf-` and is used by that one module; nothing above this
   comment is modified. The surface otherwise builds out of the shared vocabulary — .panel, .tbl,
   .fb, .chip, .btn — so it inherits density, theming and focus behaviour for free.
   ------------------------------------------------------------------------------------------------- */

.pf-filterbar { margin-bottom: 10px; }

/* --- the totals bar ------------------------------------------------------------------------------
   Above the table, off the `Totals` block, which covers every matched row and not just the page.
   Deliberately not tiles: this is a readout on a working screen, not a set of headline cards. */
.pf-totals-host { margin-bottom: 10px; }

.pf-totals {
  display: flex; flex-wrap: wrap; align-items: stretch;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-lg);
  padding: 2px 0;
}
.pf-totals.loading { opacity: .5; }

.pf-total {
  display: flex; flex-direction: column; justify-content: center; gap: 1px;
  min-width: 124px; max-width: 280px; flex: 1 1 auto; padding: 9px 14px;
  border-left: 1px solid var(--rule-soft);
}
.pf-total:first-child { border-left: 0; }
.pf-total .lbl {
  font-size: var(--fs-micro); font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--ink-3);
}
.pf-total .val {
  font: 500 17px/1.15 var(--mono); font-variant-numeric: tabular-nums;
  color: var(--ink); letter-spacing: -.01em;
}
.pf-total .sub {
  font: 400 var(--fs-micro)/1.3 var(--mono); font-variant-numeric: tabular-nums;
  color: var(--ink-4);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
@media (max-width: 900px) {
  .pf-total { border-left: 0; border-top: 1px solid var(--rule-soft); min-width: 50%; }
  .pf-total:nth-child(-n+2) { border-top: 0; }
}

/* --- the saved-view banner ----------------------------------------------------------------------- */
.pf-viewbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 10px; padding: 9px 12px;
  background: var(--accent-soft); border: 1px solid var(--accent-line);
  border-radius: var(--radius); color: var(--ink-2);
}
.pf-viewbar strong { color: var(--ink); font-weight: 600; }
.pf-viewbar .field-name { color: var(--ink-3); }
.pf-viewbar .chip { background: var(--surface); }
.pf-viewbar .chip[data-tone="warn"] {
  background: var(--hold-bg); border-color: var(--hold-line); color: var(--hold); font-weight: 600;
}

/* --- EFX notices above the table ------------------------------------------------------------------ */
.pf-notices:not(:empty) { margin-bottom: 10px; display: flex; flex-direction: column; gap: 8px; }

/* --- the flags cell -------------------------------------------------------------------------------
   The planted seams, on the row. Amber and red here are severity, which is the one thing they are
   reserved for; `info` stays neutral navy because a binding rate floor is income, not a problem. */
.pf-flags { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.pf-flag {
  display: inline-flex; align-items: center; height: 17px; padding: 0 6px;
  font: 500 var(--fs-micro)/1 var(--ui); letter-spacing: .01em;
  border: 1px solid var(--rule); border-radius: 9px;
  background: var(--sunk); color: var(--ink-3); cursor: help; white-space: nowrap;
}
.pf-flag[data-tone="info"] { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.pf-flag[data-tone="warn"] { background: var(--hold-bg); border-color: var(--hold-line); color: var(--hold); }
.pf-flag[data-tone="bad"]  { background: var(--stop-bg); border-color: var(--stop-line); color: var(--stop); }

/* --- paging foot ---------------------------------------------------------------------------------- */
.pf-more { display: flex; align-items: center; gap: 10px; width: 100%; }
.pf-more .small { line-height: 1.4; }

/* --- the save dialog ------------------------------------------------------------------------------ */
.pf-save-preview {
  padding: 10px 12px; background: var(--sunk);
  border: 1px solid var(--rule); border-radius: var(--radius);
}
.pf-save-preview .dl dd { font-family: var(--ui); }
.pf-save-preview .prose { max-width: none; }

/* --- the account card, in the drawer --------------------------------------------------------------- */
.pf-card-head {
  display: flex; flex-direction: column; gap: 8px;
  padding-bottom: 12px; margin-bottom: 4px; border-bottom: 1px solid var(--rule);
}
.pf-card-owner { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.pf-card-owner a { font-weight: 600; }

.pf-card-sec { padding: 12px 0; border-top: 1px solid var(--rule-soft); }
.pf-card-sec:first-of-type { border-top: 0; }
.pf-card-sec .eyebrow { margin-bottom: 6px; }
.pf-card-note {
  margin: 8px 0 0; font-size: var(--fs-micro); line-height: 1.5; color: var(--ink-3);
  padding-left: 9px; border-left: 2px solid var(--rule);
}

/* -------------------------------------------------------------------------------------------------
   16. Ask surface — web/views/ask.js
   Scoped entirely to `.ask-*`. Nothing here touches the shell or another surface's block.
   Every colour is a token, so light, dark and the three-state theme switch all work unchanged.
   ------------------------------------------------------------------------------------------------- */

/* ---- the console: chips above, composer below ------------------------------------------------ */
.ask-console .panel-body { display: flex; flex-direction: column; gap: 12px; }

.ask-chiprow { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; }

.ask-chip {
  display: inline-flex; align-items: center; gap: 6px;
  max-width: 100%; padding: 5px 10px;
  font: 400 var(--fs-small)/1.35 var(--ui); text-align: left; color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--rule-strong); border-radius: 13px;
  cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.ask-chip:hover { background: var(--sunk); border-color: var(--ink-4); color: var(--ink); }
.ask-chip.demo { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); font-weight: 500; }
.ask-chip.demo:hover { filter: brightness(.97); background: var(--accent-soft); color: var(--accent); }
.ask-chip.suggest { border-color: var(--accent); color: var(--accent); font-weight: 500; }

/* a recent question is a chip with its own remove button, so it is a span wrapping two buttons */
.ask-chip.recent { padding: 0 4px 0 0; background: var(--sunk); border-color: var(--rule); cursor: default; }
.ask-chip.recent:hover { background: var(--sunk); border-color: var(--rule-strong); }
.ask-chip.recent.miss .ask-chip-go { color: var(--ink-3); text-decoration: underline dotted var(--hold-line); }
.ask-chip-go {
  max-width: 46ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 5px 4px 5px 10px; border: 0; background: transparent; cursor: pointer;
  font: 400 var(--fs-small)/1.35 var(--ui); color: var(--ink-2); text-align: left;
}
.ask-chip-go:hover { color: var(--ink); }
.ask-chip.recent .x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 17px; height: 17px; padding: 0; border: 0; border-radius: 50%;
  background: transparent; color: var(--ink-4); cursor: pointer; font-size: 14px; line-height: 1;
}
.ask-chip.recent .x:hover { background: var(--stop-bg); color: var(--stop); }

.ask-composer { display: flex; align-items: flex-start; gap: 8px; }
textarea.ask-input {
  flex: 1 1 auto; min-height: 56px; font-size: var(--fs-body); line-height: 1.5;
  font-family: var(--ui); resize: vertical;
}
.ask-composer-actions { display: flex; flex-direction: column; gap: 6px; flex: 0 0 auto; }
.ask-composer-actions .btn { justify-content: center; min-width: 84px; }

.ask-hint { display: flex; flex-wrap: wrap; gap: 4px; font-size: var(--fs-micro); color: var(--ink-4); }
.ask-hint .kbd { margin: 0 2px; }

.ask-recent { display: flex; flex-direction: column; gap: 6px; padding-top: 10px; border-top: 1px solid var(--rule-soft); }

/* ---- the answer ------------------------------------------------------------------------------ */
.ask-answerhost { min-height: 120px; }
.ask-result .panel-head h2 { font-family: var(--display); font-weight: 600; font-size: 15px; }
.ask-result .panel-body { display: flex; flex-direction: column; gap: 16px; }
.ask-result.miss .panel-head { background: var(--hold-bg); border-bottom-color: var(--hold-line); }

.ask-prose { font-size: var(--fs-body); line-height: 1.6; color: var(--ink-2); max-width: 82ch; }
.ask-prose.lead { font-size: 15px; color: var(--ink); line-height: 1.55; }
.ask-prose.small { font-size: var(--fs-small); line-height: 1.55; }

.ask-figures { gap: 18px 24px; padding: 10px 12px; background: var(--sunk); border-radius: var(--radius); }
.ask-figures .v { font-size: var(--fs-body); }

/* interpretation — one chip per criterion the parser recognised */
.ask-interp { display: flex; flex-direction: column; gap: 6px; }
.ask-interp-row { display: flex; flex-wrap: wrap; gap: 6px; }
.ask-interp-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 8px;
  font: 400 var(--fs-small)/1.35 var(--ui); color: var(--ink);
  background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: var(--radius);
}
.ask-interp-chip.dim { background: var(--sunk); border-color: var(--rule); color: var(--ink-3); }
.ask-interp-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); flex: 0 0 auto; }

/* the tool call */
.ask-toolcall { display: flex; flex-direction: column; gap: 6px; }
.ask-codewrap { position: relative; }
.ask-codewrap pre.code { padding-right: 66px; }
pre.ask-code { font-size: var(--fs-small); white-space: pre; }
.ask-copy { position: absolute; top: 7px; right: 7px; }
pre.ask-mcp { color: var(--ink); background: var(--sunk); }

.ask-answerprose { display: flex; flex-direction: column; gap: 10px; }

.ask-tablepanel .tbl-shell { border-radius: 0; }

/* small second line inside a table cell — the call-report description, the days to maturity */
.ask-sub { display: block; font-size: var(--fs-micro); color: var(--ink-3); line-height: 1.3; }
.ask-sub.bad { color: var(--stop); }

/* ---- provenance ------------------------------------------------------------------------------ */
.ask-prov-row { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 10px; align-items: start; }
.ask-prov-k { font: 600 var(--fs-micro)/1.6 var(--ui); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-4); }
.ask-prov-v { min-width: 0; font-size: var(--fs-small); color: var(--ink-2); line-height: 1.55; }

.ask-op { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; min-width: 0; }
.ask-op-method {
  font: 600 10px/1 var(--mono); letter-spacing: .06em; color: var(--accent);
  background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: var(--radius-sm);
  padding: 3px 5px; flex: 0 0 auto;
}
.ask-op-path { font: 400 var(--fs-small)/1.4 var(--mono); color: var(--ink); overflow-wrap: anywhere; }
.ask-op-name { font-size: var(--fs-small); color: var(--ink-3); }
.ask-op-cores { flex: 1 0 100%; font-size: var(--fs-micro); color: var(--ink-4); }

.ask-fields { display: flex; flex-wrap: wrap; gap: 5px; }
.ask-field {
  font: 400 var(--fs-micro)/1.4 var(--mono); color: var(--ink-2);
  background: var(--sunk); border: 1px solid var(--rule); border-radius: var(--radius-sm);
  padding: 3px 6px; overflow-wrap: anywhere;
}
.ask-unknown {
  font: 500 var(--fs-micro)/1.4 var(--mono); color: var(--hold);
  background: var(--hold-bg); border: 1px solid var(--hold-line); border-radius: var(--radius-sm);
  padding: 3px 6px;
}
.ask-suggest { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }

/* ---- the permanent explainer ----------------------------------------------------------------- */
.ask-explainer-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 24px; }
@media (max-width: 1020px) { .ask-explainer-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; } }

.ask-tools { display: flex; flex-direction: column; border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.ask-tool {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  padding: 6px 10px; border-bottom: 1px solid var(--rule-soft); background: var(--surface);
}
.ask-tool:last-child { border-bottom: 0; }
.ask-tool[data-layer="BankingHub"] { background: var(--surface-2); }
.ask-tool-name { font: 500 var(--fs-small)/1.4 var(--mono); color: var(--ink); flex: 0 0 auto; }
.ask-tool-path { display: flex; align-items: center; gap: 6px; font: 400 var(--fs-micro)/1.4 var(--mono); color: var(--ink-3); overflow-wrap: anywhere; }
.ask-tool-note { font-size: var(--fs-micro); color: var(--ink-3); }

/* the party picker inside the relationship-miss modal */
.ask-pick { height: auto; justify-content: flex-start; gap: 10px; padding: 7px 10px; text-align: left; }
.ask-pick .mono { color: var(--ink-3); }

/* =================================================================================================
   16. RELATIONSHIPS SURFACE — web/views/relationships.js
   View-scoped. Nothing above this header belongs to this surface, and nothing here is used by any
   other one. Every class is prefixed `rel-` except where it extends an existing primitive
   (.chip, .field-name) with a modifier.
   ================================================================================================= */

/* -- Directory: search box and hits ---------------------------------------------------------------- */
.rel-searchbar { margin-bottom: 10px; }
.rel-search { width: 100%; max-width: 520px; }
.rel-hint { font-size: var(--fs-small); color: var(--ink-4); line-height: 1.6; }
.rel-hint .kbd { margin: 0 1px; }

.rel-hits { display: flex; flex-direction: column; }
.rel-hit {
  display: grid; grid-template-columns: 74px minmax(0, 1fr) minmax(0, auto);
  align-items: center; gap: 10px;
  padding: 7px 8px; border-radius: var(--radius);
  text-decoration: none; color: var(--ink); border: 1px solid transparent;
}
.rel-hit:hover { background: var(--sunk); border-color: var(--rule); }
.rel-hit:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.rel-kind {
  display: inline-flex; align-items: center; justify-content: center; height: 19px;
  border: 1px solid var(--rule-strong); border-radius: 10px; background: var(--surface-2);
  font: 500 var(--fs-micro)/1 var(--ui); color: var(--ink-3); letter-spacing: .02em;
}
.rel-kind[data-kind="party"]     { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.rel-kind[data-kind="account"]   { font-family: var(--mono); }
.rel-hit-label { font-size: var(--fs-body); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rel-hit-detail { font: 400 var(--fs-micro)/1 var(--mono); color: var(--ink-3); white-space: nowrap; }

.rel-panel-tight .tbl-shell { border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }

/* -- Directory: watchlist -------------------------------------------------------------------------- */
.rel-watch { display: flex; flex-direction: column; gap: 2px; }
.rel-watch-row {
  display: block; padding: 8px 9px; border-radius: var(--radius);
  text-decoration: none; color: inherit; border: 1px solid transparent;
}
.rel-watch-row:hover { background: var(--sunk); border-color: var(--rule); }
.rel-watch-row.static:hover { background: transparent; border-color: transparent; }
.rel-watch-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.rel-watch-label { font-size: var(--fs-small); font-weight: 600; color: var(--ink); }
.rel-watch-id { font-size: var(--fs-micro); color: var(--ink-4); }
.rel-watch-note { font-size: var(--fs-small); color: var(--ink-2); line-height: 1.5; margin-top: 2px; max-width: 60ch; }
.rel-watch-meta { font-size: var(--fs-micro); color: var(--ink-4); margin-top: 3px; }

/* -- The card ------------------------------------------------------------------------------------- */
.rel-card .tile-value.sm { font-size: 19px; }
.rel-dim { color: var(--ink-4); }
.rel-foot-note {
  font-size: var(--fs-micro); color: var(--ink-3); line-height: 1.55;
  max-width: 92ch; margin-top: 8px;
}

/* PartyAcctRelType, shown as itself. `nocover` is the honest half of non-negotiable #4. */
.chip.rel-reltype { font-family: var(--mono); font-size: 10px; margin-right: 4px; }
.chip.rel-reltype.nocover { color: var(--ink-4); border-style: dashed; }
.chip.rel-reltype.guarantor { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.chip.rel-flag { font-size: 10px; margin-right: 4px; }
.chip.rel-flag.warn { color: var(--hold); background: var(--hold-bg); border-color: var(--hold-line); }

table.tbl tbody tr.rel-row-flag td:first-child { box-shadow: inset 2px 0 0 var(--hold); }
table.tbl tbody td.rel-floor { color: var(--hold); }
table.tbl tbody td.rel-uninsured { color: var(--ink); font-weight: 600; }

/* -- Exceptions on this relationship ---------------------------------------------------------------- */
.rel-exlist { display: flex; flex-direction: column; gap: 10px; }
.rel-ex {
  padding: 10px 12px; border: 1px solid var(--rule); border-left-width: 3px;
  border-left-color: var(--rule-strong); border-radius: var(--radius); background: var(--surface-2);
}
.rel-ex-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rel-ex-title { font-size: var(--fs-small); font-weight: 600; color: var(--ink); }
.rel-ex-amt { font-size: var(--fs-small); color: var(--ink-2); font-weight: 600; }
.rel-ex-amt-note { font-size: var(--fs-micro); color: var(--ink-4); }
.rel-ex-why { font-size: var(--fs-small); color: var(--ink-2); line-height: 1.55; margin-top: 5px; max-width: 92ch; }
.rel-ex-accts { font-size: var(--fs-micro); color: var(--ink-3); margin-top: 5px; line-height: 1.7; }
.rel-ex-accts a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent-line); }

/* -- FDIC coverage ---------------------------------------------------------------------------------- */
.rel-cov-strip { padding: 2px 0 4px; }
.rel-method { font-size: var(--fs-small); color: var(--ink-2); margin-top: 10px; }
.rel-method > summary { cursor: pointer; color: var(--ink-3); font-size: var(--fs-small); padding: 4px 0; }
.rel-method > summary:hover { color: var(--ink); }
.rel-method-list { margin: 6px 0 0 16px; display: flex; flex-direction: column; gap: 5px; line-height: 1.55; max-width: 92ch; }

/* -- Per-loan collateral / classification / guarantees --------------------------------------------- */
.rel-loancards { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 12px; }
.rel-loancard {
  border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface-2);
  padding: 11px 12px; min-width: 0;
}
.rel-loancard-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 9px; flex-wrap: wrap; }
.rel-loancard-id { font-size: var(--fs-small); font-weight: 600; color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent-line); }
.rel-loancard-name { font-size: var(--fs-micro); color: var(--ink-3); }
.rel-loancard-amt { font-size: var(--fs-small); font-weight: 600; color: var(--ink); }
.rel-loancard .dl { grid-template-columns: minmax(96px, max-content) minmax(0, 1fr); }

.rel-classified { margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--rule); }
.rel-classified-row { display: flex; align-items: center; gap: 8px; padding: 2px 0; font-size: var(--fs-small); }
.rel-classified-row .mono { margin-left: auto; }

.rel-guarantors { margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--rule); }
.rel-guarantor {
  display: flex; align-items: baseline; gap: 8px; padding: 3px 4px; border-radius: var(--radius-sm);
  text-decoration: none; color: var(--ink); font-size: var(--fs-small);
}
.rel-guarantor:hover { background: var(--sunk); }
.rel-guarantor-name { font-weight: 500; }

/* -- Provenance popover and panel ------------------------------------------------------------------- */
.rel-prov { max-height: 60vh; overflow-y: auto; }
.rel-prov .eyebrow { margin-top: 10px; }
.rel-prov .callout { margin-top: 8px; }
.rel-oplist { list-style: none; display: flex; flex-direction: column; gap: 7px; margin-top: 5px; }
.rel-oplist li, .rel-op { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rel-ops { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; margin-top: 10px; }
.rel-op { padding: 8px 10px; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface-2); }
.op-name { font-size: var(--fs-small); font-weight: 600; color: var(--ink); }
.op-cores { font: 400 var(--fs-micro)/1.4 var(--ui); color: var(--ink-4); }
.rel-fieldset { display: flex; flex-wrap: wrap; gap: 4px; }
.rel-fieldset code.inline { white-space: nowrap; }

/* -- Account drawer --------------------------------------------------------------------------------- */
.rel-drawer { display: flex; flex-direction: column; gap: 18px; }
.rel-drawer-sec { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.rel-balgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px; }
.rel-bal {
  display: flex; align-items: baseline; gap: 8px; padding: 5px 8px;
  background: var(--sunk); border-radius: var(--radius-sm); font-size: var(--fs-small);
}
.rel-bal-type { color: var(--ink-3); font-size: var(--fs-micro); }
.rel-bal-amt { margin-left: auto; color: var(--ink); font-weight: 500; }
.rel-drawer-parties { display: flex; flex-direction: column; gap: 2px; }
.rel-drawer-party {
  display: flex; align-items: baseline; gap: 8px; padding: 4px 5px; border-radius: var(--radius-sm);
  text-decoration: none; color: var(--ink); font-size: var(--fs-small);
}
.rel-drawer-party:hover { background: var(--sunk); }
.rel-drawer-party-name { font-weight: 500; }

/* -- Print: this card replaces a manual write-up, so it has to survive a printer ------------------- */
@media print {
  .rel-card { display: block; }
  .rel-card .panel,
  .rel-card .tile,
  .rel-loancard,
  .rel-ex { break-inside: avoid; page-break-inside: avoid; box-shadow: none; }
  .rel-card .panel { margin-bottom: 12px; border-color: #c9ced9; }
  .rel-card .grid { display: block; }
  .rel-card .grid > * { margin-bottom: 12px; }
  .rel-card .grid.cols-6 { display: grid; grid-template-columns: repeat(3, 1fr); }
  .rel-card .grid.cols-6 > * { margin-bottom: 0; }
  .tbl-scroll { overflow: visible !important; max-height: none !important; }
  .tbl-toolbar .btn { display: none; }
  table.tbl thead th { position: static; }
  table.tbl tfoot td { position: static; }
  .rel-method[open] > summary, .rel-method > summary { display: none; }
  .rel-method-list { display: flex !important; }
  .rel-hits, .rel-searchbar { display: none; }
}

/* =================================================================================================
   16. VIEW-SCOPED — Connections (web/views/connections.js, PLATFORM §7)

   Everything below is owned by the Connections surface and by nothing else. Every class is
   prefixed `cx-`, and anything that touches a shared element (a table row, a details marker) is
   scoped under `.cx-surface`, which that view adds to its own host element and removes on
   teardown. No other surface's block and no shell rule is touched.

   Colour discipline is the same as everywhere: green / amber / red appear only where they carry a
   sourcing verdict or an EFX severity — a connector awaiting configuration, an EFX Warning, a
   failed run. The rest of the surface is navy, ink and rule.
   ================================================================================================= */

.cx-surface { display: block; }
.cx-gap { height: 12px; }
.cx-mt { margin-top: 14px; }
/* padding inside a flush panel, where the body itself has none */
.cx-pad { padding: 12px 14px; display: flex; flex-direction: column; gap: 12px; }

/* -- the provenance statement: what used to be the masthead disclaimer -------------------------- */
.cx-surface > .callout:first-child { margin-bottom: 12px; }
.cx-prov p { margin: 0; font-size: var(--fs-small); line-height: 1.55; }
.cx-prov p + p { margin-top: 6px; color: var(--ink-3); }

/* -- cards: the repeating unit of the API-health and awaiting-configuration blocks -------------- */
.cx-card {
  display: flex; flex-direction: column; gap: 10px; min-width: 0;
  padding: 12px 13px;
  background: var(--surface-2); border: 1px solid var(--rule); border-radius: var(--radius-lg);
}
.cx-card-head { display: flex; align-items: center; gap: 8px; }
.cx-card-head h4 { font: 600 var(--fs-body)/1.3 var(--ui); flex: 1 1 auto; min-width: 0; }
.cx-card-detail { margin: 0; font-size: var(--fs-small); color: var(--ink-3); }
.cx-card-block { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cx-card-block .eyebrow { margin: 0; }
.cx-card-note { margin: 0; font-size: var(--fs-micro); color: var(--ink-3); line-height: 1.5; }
.cx-card-none { margin: 0; font-size: var(--fs-small); color: var(--ink-4); }
.cx-card-foot { display: flex; gap: 6px; margin-top: auto; padding-top: 2px; }
.cx-card-grid { align-items: start; }
.cx-card-wide { min-width: 0; }
.cx-card .state { padding: 22px 14px; min-height: 0; }

/* -- connectors awaiting configuration: a gap, stated plainly, never a failure ------------------ */
.cx-await {
  display: flex; flex-direction: column; gap: 12px;
  padding: 14px; border-top: 1px solid var(--rule); background: var(--surface);
}
.cx-await .cx-card { background: var(--surface); }

/* -- master/detail: the block that opens under a table when a row is selected ------------------- */
.cx-detail-host:empty { display: none; }
.cx-detail-host > .callout { margin: 14px; }
.cx-detail {
  display: flex; flex-direction: column; gap: 12px;
  padding: 14px; border-top: 1px solid var(--rule-strong); background: var(--surface-2);
}
.cx-detail-head { display: flex; align-items: flex-start; gap: 10px; }
.cx-detail-head h3 { font: 600 var(--fs-body)/1.3 var(--ui); }
.cx-detail-head .eyebrow { margin-bottom: 2px; }
.cx-detail .kv-strip { gap: 18px; }

/* -- chips and field names --------------------------------------------------------------------- */
.cx-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.cx-mono-chip { font-family: var(--mono); font-size: 10.5px; letter-spacing: -.01em; }

/* -- a BankingHub operation, rendered as verb + path + the cores that carry it ------------------ */
.cx-ops { display: flex; flex-direction: column; gap: 4px; }
.cx-op {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  padding: 5px 8px; font-size: var(--fs-micro);
  background: var(--sunk); border: 1px solid var(--rule); border-radius: var(--radius-sm);
}
.cx-op-verb {
  font: 600 10px/1 var(--mono); letter-spacing: .06em; padding: 2px 4px;
  color: var(--accent); background: var(--accent-soft);
  border: 1px solid var(--accent-line); border-radius: 3px;
}
.cx-op-path { font-family: var(--mono); font-size: var(--fs-micro); color: var(--ink); overflow-wrap: anywhere; }
.cx-op-name { color: var(--ink-2); font-weight: 500; }
.cx-op-cores { margin-left: auto; color: var(--ink-4); font-size: 10px; }

/* -- prose lists ------------------------------------------------------------------------------- */
.cx-steps, .cx-bullets {
  margin: 0; display: flex; flex-direction: column; gap: 6px;
  font-size: var(--fs-small); color: var(--ink-2); line-height: 1.55; max-width: 96ch;
}
.cx-steps { padding-left: 20px; }
.cx-bullets { padding-left: 18px; }
.cx-steps li::marker, .cx-bullets li::marker { color: var(--ink-4); }

/* -- the three run statistics with their 30-night sparklines ------------------------------------ */
.cx-stat {
  display: flex; flex-direction: column; gap: 3px; min-width: 0;
  padding: 10px 12px;
  background: var(--surface-2); border: 1px solid var(--rule); border-radius: var(--radius-lg);
}
.cx-stat-label { margin: 0; font-size: var(--fs-small); font-weight: 600; color: var(--ink-2); }
.cx-stat-value {
  margin: 0; font: 600 20px/1.15 var(--display);
  font-variant-numeric: tabular-nums; color: var(--ink);
}
.cx-stat-sub { margin: 0; font-size: var(--fs-micro); color: var(--ink-3); line-height: 1.4; }
.cx-stat .chart-frame { margin: 2px 0; }

/* -- a button that reads as a sentence link ----------------------------------------------------- */
.cx-inline-link {
  margin: 0; padding: 0; border: 0; background: transparent; cursor: pointer;
  font-family: var(--mono); font-size: var(--fs-small); font-weight: 500;
  color: var(--accent); text-decoration: underline; text-underline-offset: 2px;
}
.cx-inline-link:hover { filter: brightness(1.15); }

/* -- table decoration owned by this surface ----------------------------------------------------- */
.cx-surface .cx-why {
  font: 500 var(--fs-micro)/1 var(--ui);
  color: var(--ink-3); border-bottom: 1px dotted var(--ink-4); cursor: help;
}
.cx-surface table.tbl tbody td.cx-bad-num { color: var(--stop); font-weight: 600; }
.cx-surface table.tbl tbody tr.cx-sel td,
.cx-surface table.tbl tbody tr.cx-sel:hover td { background: var(--accent-soft); }
.cx-surface table.tbl tbody tr.cx-sel td:first-child { box-shadow: inset 3px 0 0 var(--accent); }

/* -- the per-run log --------------------------------------------------------------------------- */
.cx-log {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius);
}
.cx-log-line {
  display: grid; grid-template-columns: 72px 54px minmax(0, 1fr); gap: 10px; align-items: baseline;
  padding: 6px 10px; border-bottom: 1px solid var(--rule-soft); font-size: var(--fs-small);
}
.cx-log-line:last-child { border-bottom: 0; }
.cx-log-at { font-family: var(--mono); font-size: var(--fs-micro); color: var(--ink-3); }
.cx-log-level {
  font: 600 10px/1.4 var(--ui); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-4);
}
.cx-log-msg { color: var(--ink-2); line-height: 1.5; overflow-wrap: anywhere; }
.cx-log-line[data-level="warn"] { background: var(--hold-bg); }
.cx-log-line[data-level="warn"] .cx-log-level { color: var(--hold); }
.cx-log-line[data-level="error"] { background: var(--stop-bg); }
.cx-log-line[data-level="error"] .cx-log-level { color: var(--stop); }
.cx-log-line[data-level="error"] .cx-log-msg { color: var(--ink); }
@media (max-width: 720px) { .cx-log-line { grid-template-columns: minmax(0, 1fr); gap: 2px; } }

/* -- the EFX status mix: the real health signal, not the HTTP status ---------------------------- */
.cx-efx { display: flex; flex-direction: column; gap: 2px; }
.cx-efx-row {
  display: grid; grid-template-columns: 52px 66px minmax(0, 1fr) 78px 76px 84px;
  gap: 10px; align-items: center;
  padding: 5px 8px; font-size: var(--fs-small);
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-sm);
}
.cx-efx-row[data-zero="true"] { opacity: .5; }
.cx-efx-code { font: 600 var(--fs-small)/1 var(--mono); color: var(--ink); }
.cx-efx-sev {
  font: 500 10px/1 var(--ui); letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3);
}
.cx-efx-sev[data-sev-word="Info"] { color: var(--go); }
.cx-efx-sev[data-sev-word="Warning"] { color: var(--hold); }
.cx-efx-sev[data-sev-word="Error"] { color: var(--stop); }
.cx-efx-sev[data-sev-word="unknown"] { color: var(--ink-4); border-bottom: 1px dotted var(--ink-4); cursor: help; }
.cx-efx-desc { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cx-efx-count, .cx-efx-share {
  font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right;
}
.cx-efx-count { color: var(--ink); }
.cx-efx-share { color: var(--ink-3); font-size: var(--fs-micro); }
.cx-efx-bar {
  height: 6px; overflow: hidden;
  background: var(--sunk); border: 1px solid var(--rule); border-radius: 3px;
}
.cx-efx-fill { display: block; height: 100%; background: var(--ramp-3); }
@media (max-width: 1180px) {
  .cx-efx-row { grid-template-columns: 46px 60px minmax(0, 1fr) 70px 68px; }
  .cx-efx-bar { display: none; }
}

/* -- the OAuth2 token window, counting down its real fifteen minutes ---------------------------- */
.cx-token-face { display: flex; align-items: baseline; gap: 8px; }
.cx-token-clock {
  font: 600 34px/1 var(--display); font-variant-numeric: tabular-nums;
  letter-spacing: -.02em; color: var(--ink);
}
.cx-token-unit { font-size: var(--fs-small); color: var(--ink-3); }
.cx-token-bar {
  height: 6px; overflow: hidden;
  background: var(--sunk); border: 1px solid var(--rule); border-radius: 3px;
}
.cx-token-fill { display: block; height: 100%; background: var(--accent); transition: width 1s linear; }
.cx-token-cycle-wrap { margin: 0; }
.cx-token-cycle { font: 400 var(--fs-micro)/1.4 var(--mono); color: var(--ink-3); }

/* -- observed call volume against a ceiling nobody publishes ------------------------------------ */
.cx-ceiling { display: flex; flex-direction: column; gap: 4px; }
.cx-ceiling-track {
  display: flex; align-items: stretch; height: 26px; overflow: hidden;
  background: var(--sunk); border: 1px solid var(--rule); border-radius: var(--radius);
}
.cx-ceiling-observed {
  display: flex; align-items: center; padding: 0 8px; flex: 0 0 auto;
  background: var(--accent-soft); border-right: 1px solid var(--accent-line);
}
.cx-ceiling-open {
  flex: 1 1 auto; display: flex; align-items: center; justify-content: center; padding: 0 8px;
  background: repeating-linear-gradient(135deg, transparent 0 6px, var(--rule-soft) 6px 12px);
}
.cx-ceiling-label { font: 500 var(--fs-micro)/1 var(--ui); color: var(--accent); white-space: nowrap; }
.cx-ceiling-label.dim { color: var(--ink-4); }

/* -- field lineage: search, then an accordion of every metric on the platform ------------------- */
.cx-search-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.cx-search { flex: 1 1 auto; max-width: 520px; height: 30px; }
.cx-count { font: 400 var(--fs-small)/1 var(--mono); color: var(--ink-3); white-space: nowrap; }

.cx-lineage { display: flex; flex-direction: column; gap: 4px; }
.cx-lin {
  overflow: hidden; background: var(--surface);
  border: 1px solid var(--rule); border-radius: var(--radius);
}
.cx-lin.open { border-color: var(--accent-line); box-shadow: var(--shadow); }
.cx-lin-head {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 10px; border: 0; background: transparent; cursor: pointer;
  text-align: left; color: inherit; font-family: var(--ui);
}
.cx-lin-head:hover { background: var(--sunk); }
.cx-lin.open .cx-lin-head { background: var(--accent-soft); }
.cx-lin-title { font-size: var(--fs-body); font-weight: 600; color: var(--ink); }
.cx-lin-id {
  font: 400 var(--fs-micro)/1 var(--mono); color: var(--ink-3); padding: 2px 5px;
  background: var(--sunk); border: 1px solid var(--rule); border-radius: 3px;
}
.cx-lin.open .cx-lin-id { background: var(--surface); }
.cx-lin-meta { font: 400 var(--fs-micro)/1 var(--mono); color: var(--ink-3); white-space: nowrap; }
.cx-lin-caret { font: 500 14px/1 var(--mono); color: var(--ink-3); width: 12px; text-align: center; }
.cx-lin-body {
  display: flex; flex-direction: column; gap: 12px;
  padding: 12px 12px 14px; border-top: 1px solid var(--rule);
}
@media (max-width: 860px) {
  .cx-lin-head { flex-wrap: wrap; }
  .cx-lin-meta { display: none; }
}

.cx-corpus {
  display: flex; flex-direction: column; gap: 8px; margin-top: 14px; padding: 12px;
  background: var(--sunk); border: 1px solid var(--rule); border-radius: var(--radius);
}

/* -- foldouts: native <details>, so they work without script and reach the keyboard ------------- */
.cx-fold {
  margin-top: 12px; background: var(--surface-2);
  border: 1px solid var(--rule); border-radius: var(--radius);
}
.cx-fold > summary {
  display: flex; align-items: center; gap: 8px; list-style: none; cursor: pointer;
  padding: 8px 12px; font-size: var(--fs-small); font-weight: 600; color: var(--ink-2);
}
.cx-fold > summary::-webkit-details-marker { display: none; }
.cx-fold > summary::before { content: "\25B8"; color: var(--ink-4); font-size: 10px; }
.cx-fold[open] > summary::before { content: "\25BE"; }
.cx-fold > summary:hover { color: var(--ink); background: var(--sunk); }
.cx-fold-body {
  display: flex; flex-direction: column; gap: 14px;
  padding: 12px; border-top: 1px solid var(--rule);
}
.cx-trap { display: flex; flex-direction: column; gap: 6px; }
.cx-trap h5 { margin: 0; font: 600 var(--fs-small)/1.3 var(--ui); color: var(--ink); }

.cx-code {
  font: 400 var(--fs-micro)/1.4 var(--mono); padding: 1px 4px; overflow-wrap: anywhere;
  color: var(--ink-2); background: var(--sunk);
  border: 1px solid var(--rule); border-radius: var(--radius-sm);
}
.cx-code-bad { color: var(--stop); background: var(--stop-bg); border-color: var(--stop-line); }
.cx-code-good { color: var(--go); background: var(--go-bg); border-color: var(--go-line); }
