/* qopt console design system. Reference: frontend/DESIGN.md.
   No framework underneath: this file is the whole stylesheet. Sections:
   1 tokens  2 base  3 shell  4 layout  5 controls  6 chips  7 tables  8 data components
   9 pipeline (funnel, stages)  10 states  11 auth pages  12 map (in map.css)  13 utilities */

/* --- 1. Tokens ---------------------------------------------------------------- */

@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-display: swap; src: url("vendor/fonts/ibm-plex-sans-latin-400.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-display: swap; src: url("vendor/fonts/ibm-plex-sans-latin-500.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-display: swap; src: url("vendor/fonts/ibm-plex-sans-latin-600.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-display: swap; src: url("vendor/fonts/ibm-plex-mono-latin-400.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 500; font-display: swap; src: url("vendor/fonts/ibm-plex-mono-latin-500.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 600; font-display: swap; src: url("vendor/fonts/ibm-plex-mono-latin-600.woff2") format("woff2"); }

:root {
  color-scheme: light;

  /* Surfaces and ink */
  --bg: #f3f4f7;
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --surface-3: #e9ebf0;
  --line: #dde0e7;
  --line-strong: #c3c8d2;
  --ink: #141821;
  --ink-2: #454c5b;
  --ink-3: #636a79;

  /* Brand accent: links, focus, selection, primary action */
  --accent: #2f45d0;
  --accent-ink: #ffffff;
  --accent-bg: #e8ebfb;

  /* Semantic colours: foreground, and a tint to sit behind it */
  --read: #08707f;      --read-bg: #dcf1f4;
  --write: #b04a08;     --write-bg: #fbe8d8;
  --feed: #7038bd;      --feed-bg: #efe6fb;
  --win: #17753c;       --win-bg: #dcf2e4;
  --warn: #7d5800;      --warn-bg: #fbefc8;
  --fail: #be2626;      --fail-bg: #fbe1e1;
  --verified: var(--win);
  --unverified: var(--ink-3);
  --muted-bg: var(--surface-3);

  /* Severity and entry-point kind */
  --sev-critical: var(--fail);   --sev-critical-bg: var(--fail-bg);
  --sev-high: #b04a08;           --sev-high-bg: #fbe8d8;
  --sev-medium: var(--warn);     --sev-medium-bg: var(--warn-bg);
  --sev-low: #2d63ad;            --sev-low-bg: #e1ecfa;
  --kind-http: var(--accent);    --kind-http-bg: var(--accent-bg);
  --kind-async: var(--feed);     --kind-async-bg: var(--feed-bg);

  /* Project palette: a project keeps one of these for life (class p-1 … p-8) */
  --p-1: #2a6be0; --p-2: #d2470d; --p-3: #0a7d5f; --p-4: #a136c6;
  --p-5: #a87a00; --p-6: #d12f68; --p-7: #0d8ea6; --p-8: #65741a;

  /* Type */
  --font-sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --fs-1: .6875rem;  /* 11px  labels, chips, table heads */
  --fs-2: .75rem;    /* 12px  secondary text, code */
  --fs-3: .8125rem;  /* 13px  body */
  --fs-4: .875rem;   /* 14px  panel titles */
  --fs-5: 1rem;      /* 16px  page title */
  --fs-6: 1.25rem;   /* 20px  stat values */
  --fs-7: 1.625rem;  /* 26px  hero numbers */

  /* Space, radius, size */
  --sp-1: 2px; --sp-2: 4px; --sp-3: 6px; --sp-4: 8px; --sp-5: 12px; --sp-6: 16px; --sp-7: 24px; --sp-8: 32px;
  --r-1: 3px; --r-2: 5px; --r-3: 8px;
  --ctl: 28px;       /* height of inputs and buttons */
  --ctl-sm: 22px;
  --gutter: 16px;    /* page side padding */
  --shadow-pop: 0 6px 24px rgba(20, 24, 33, .14), 0 0 0 1px rgba(20, 24, 33, .06);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1014;
  --surface: #16191f;
  --surface-2: #1b1f26;
  --surface-3: #262b34;
  --line: #2a2f39;
  --line-strong: #3d4451;
  --ink: #e7e9ed;
  --ink-2: #b1b7c2;
  --ink-3: #8e95a2;

  --accent: #93a2ff;
  --accent-ink: #0e1014;
  --accent-bg: #1e2447;

  --read: #56c5d6;      --read-bg: #0e2f36;
  --write: #f0975a;     --write-bg: #3a2311;
  --feed: #b792f2;      --feed-bg: #2a1d45;
  --win: #58c587;       --win-bg: #112e1e;
  --warn: #e2b74b;      --warn-bg: #33290c;
  --fail: #f47c7c;      --fail-bg: #3b1719;

  --sev-high: #f0975a;  --sev-high-bg: #3a2311;
  --sev-low: #7fb0ee;   --sev-low-bg: #172a45;

  --p-1: #6c9cf5; --p-2: #f08045; --p-3: #3fc49d; --p-4: #c97be6;
  --p-5: #d6ab35; --p-6: #f0709b; --p-7: #45bfd6; --p-8: #a4b451;

  --shadow-pop: 0 8px 28px rgba(0, 0, 0, .5), 0 0 0 1px rgba(255, 255, 255, .07);
}

/* --- 2. Base ------------------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink);
  font: 400 var(--fs-3)/1.45 var(--font-sans); font-feature-settings: "tnum" 0;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p, dl, dd, ol, ul, figure { margin: 0; }
ol, ul { padding: 0; list-style: none; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { flex: none; }
code, pre, kbd, .mono { font-family: var(--font-mono); font-size: .94em; }
/* A part of a name only known at run time (m.rt, m.route; naming.py): a placeholder, never the raw template text. */
.rt { font-style: italic; color: var(--ink-3); border-bottom: 1px dotted var(--line-strong); }
.rt-any { font-family: var(--font-sans); font-size: var(--fs-1); color: var(--ink-3); border: 1px solid var(--line); border-radius: var(--r-1); padding: 0 3px; }
code { padding: 0 3px; border-radius: var(--r-1); background: var(--surface-3); }
strong, b { font-weight: 600; }
time { white-space: nowrap; }
::selection { background: var(--accent-bg); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: var(--r-1); }
[hidden] { display: none !important; }

.icon { width: 16px; height: 16px; stroke-width: 1.75; vertical-align: -3px; }
.icon.is-sm, .icon.icon-chip { width: 13px; height: 13px; vertical-align: -2px; }

/* --- 3. Shell ----------------------------------------------------------------- */

.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 40; display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--sp-5);
  min-height: 42px; padding: 0 var(--gutter); background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: var(--sp-3); font: 600 var(--fs-4)/1 var(--font-mono); color: var(--ink); letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: var(--r-1);
  background: var(--ink); color: var(--surface); font: 600 12px/1 var(--font-mono);
}

/* Scope: organisation / project. Each is a <details class="menu">. */
.scope { display: flex; align-items: center; gap: var(--sp-1); min-width: 0; }
.scope > .menu:first-child { flex: none; }
.scope > .menu:first-child > summary > .menu-label { max-width: 8rem; }
.scope-sep { color: var(--line-strong); font-size: var(--fs-4); user-select: none; }
.menu { position: relative; min-width: 0; }
.menu > summary {
  display: flex; align-items: center; gap: var(--sp-3); height: var(--ctl); padding: 0 var(--sp-3) 0 var(--sp-4);
  border-radius: var(--r-2); cursor: pointer; list-style: none; font-weight: 500; white-space: nowrap; min-width: 0; user-select: none;
}
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary:hover, .menu[open] > summary { background: var(--surface-3); }
.menu > summary > .menu-label { overflow: hidden; text-overflow: ellipsis; max-width: 16rem; }
.menu > summary > .icon { color: var(--ink-3); width: 12px; height: 12px; }
.menu-pop {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 50; min-width: 15rem; max-width: min(24rem, calc(100vw - 2 * var(--gutter)));
  max-height: min(28rem, 70vh); overflow-y: auto; padding: var(--sp-2); background: var(--surface); border-radius: var(--r-3); box-shadow: var(--shadow-pop);
}
.menu-pop.is-right { left: auto; right: 0; }
.menu-head { padding: var(--sp-2) var(--sp-4); color: var(--ink-3); font-size: var(--fs-1); }
.menu-item {
  display: flex; align-items: center; gap: var(--sp-4); width: 100%; min-height: var(--ctl); padding: var(--sp-2) var(--sp-4);
  border: 0; border-radius: var(--r-2); background: none; color: var(--ink); text-align: left; cursor: pointer; min-width: 0;
}
.menu-item:hover { background: var(--surface-3); text-decoration: none; }
.menu-item[aria-current="true"] { background: var(--accent-bg); }
.menu-item > .menu-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item > .menu-note { flex: none; color: var(--ink-3); font-size: var(--fs-1); }
.menu-rule { height: 1px; margin: var(--sp-2) 0; background: var(--line); }

.nav { display: flex; align-items: stretch; gap: var(--sp-1); align-self: stretch; min-width: 0; margin-left: var(--sp-4); }
.nav-link {
  position: relative; display: inline-flex; align-items: center; gap: var(--sp-3); padding: 0 var(--sp-4); color: var(--ink-2);
  font-weight: 500; white-space: nowrap; min-height: 42px;
}
.nav-link:hover { color: var(--ink); text-decoration: none; }
.nav-link .icon { color: var(--ink-3); }
.nav-link[aria-current="page"] { color: var(--ink); }
.nav-link[aria-current="page"] .icon { color: var(--accent); }
.nav-link[aria-current="page"]::after { content: ""; position: absolute; left: var(--sp-4); right: var(--sp-4); bottom: -1px; height: 2px; background: var(--accent); }
.topbar-end { display: flex; align-items: center; gap: var(--sp-2); margin-left: auto; }
.icon-btn {
  display: inline-grid; place-items: center; width: var(--ctl); height: var(--ctl); padding: 0; border: 0; border-radius: var(--r-2);
  background: none; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
:root[data-theme="dark"] .theme-light-only, :root:not([data-theme="dark"]) .theme-dark-only { display: none; }

@media (max-width: 1039.98px) {
  .topbar { padding-top: var(--sp-2); }
  .nav { order: 9; flex: 0 0 calc(100% + 2 * var(--gutter)); margin: 0 calc(-1 * var(--gutter)); padding: 0 calc(var(--gutter) - var(--sp-4)); overflow-x: auto; scrollbar-width: none; border-top: 1px solid var(--line); margin-top: var(--sp-2); }
  .nav::-webkit-scrollbar { display: none; }
  .nav-link { min-height: 36px; }
  .scope { flex: 1 1 0; }
  .menu > summary > .menu-label { max-width: 9.5rem; }
}
@media (max-width: 479.98px) {
  .brand-word { display: none; }
  .nav-link .icon { display: none; }
  .menu > summary > .menu-label { max-width: 7rem; }
}

/* --- 4. Layout ---------------------------------------------------------------- */

.page { flex: 1 1 auto; width: 100%; max-width: 1760px; margin: 0 auto; padding: 0 var(--gutter) var(--sp-8); min-width: 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3) var(--sp-5); padding: var(--sp-5) 0 var(--sp-4); min-width: 0; }
.page-title { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3) var(--sp-4); min-width: 0; font: 600 var(--fs-5)/1.3 var(--font-sans); letter-spacing: -.005em; overflow-wrap: anywhere; }
.crumbs { display: flex; align-items: center; gap: var(--sp-3); color: var(--ink-3); font-weight: 400; font-size: var(--fs-3); }
.crumbs a { color: var(--ink-2); }
.crumbs > .crumb-sep { color: var(--line-strong); }
.page-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); min-width: 0; }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); margin-left: auto; }

.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--sp-5); align-items: start; }
.grid > * { grid-column: span 12; min-width: 0; }
.stack { display: grid; gap: var(--sp-5); min-width: 0; }
.stack > * { min-width: 0; }
@media (min-width: 1040px) {
  .grid > .span-3 { grid-column: span 3; } .grid > .span-4 { grid-column: span 4; } .grid > .span-5 { grid-column: span 5; }
  .grid > .span-6 { grid-column: span 6; } .grid > .span-7 { grid-column: span 7; } .grid > .span-8 { grid-column: span 8; }
  .grid > .span-9 { grid-column: span 9; }
  .grid.is-stretch { align-items: stretch; }
}

/* A grid whose columns only split from 1240px: for pages whose panels hold wide tables. */
@media (max-width: 1239.98px) { .grid.at-xl > * { grid-column: span 12; } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-3); min-width: 0; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-4); min-height: 36px; padding: var(--sp-3) var(--sp-5); border-bottom: 1px solid var(--line); min-width: 0; }
.panel-title { font: 600 var(--fs-3)/1.3 var(--font-sans); min-width: 0; overflow-wrap: anywhere; }
.panel-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); margin-left: auto; min-width: 0; color: var(--ink-3); font-size: var(--fs-2); }
.panel-body { padding: var(--sp-5); min-width: 0; }
.panel-body + .panel-body, .panel-section { border-top: 1px solid var(--line); }
.panel-section { padding: var(--sp-5); }
.panel-foot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3) var(--sp-4); padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--line); color: var(--ink-3); font-size: var(--fs-2); min-width: 0; }
.panel > :first-child { border-top-left-radius: inherit; border-top-right-radius: inherit; }
.panel > :last-child { border-bottom-left-radius: inherit; border-bottom-right-radius: inherit; }
.panel > .tbl-wrap:not(:first-child) { border-top: 0; }

/* A small heading inside a panel. Sentence case, never tracked-out capitals. */
.label { display: block; margin-bottom: var(--sp-2); color: var(--ink-3); font-size: var(--fs-1); font-weight: 500; }
.label .mono { color: var(--ink-2); }
* + .label { margin-top: var(--sp-5); }
.panel-head > .label, .funnel-skipped > .label, .row > .label { margin-top: 0; }

/* --- 5. Controls -------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-3); height: var(--ctl); padding: 0 var(--sp-5);
  border: 1px solid var(--line-strong); border-radius: var(--r-2); background: var(--surface); color: var(--ink); font-weight: 500;
  white-space: nowrap; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-3); text-decoration: none; }
.btn.is-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.is-primary:hover { filter: brightness(1.1); }
.btn.is-danger { color: var(--fail); border-color: color-mix(in srgb, var(--fail) 45%, var(--line)); }
.btn.is-danger:hover { background: var(--fail-bg); border-color: var(--fail); }
.btn.is-ghost { border-color: transparent; background: none; color: var(--ink-2); }
.btn.is-ghost:hover { background: var(--surface-3); color: var(--ink); }
.btn.is-sm { height: var(--ctl-sm); padding: 0 var(--sp-4); font-size: var(--fs-2); }
.btn.is-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; }

.input, .select, .textarea {
  height: var(--ctl); width: 100%; min-width: 0; padding: 0 var(--sp-4); border: 1px solid var(--line-strong); border-radius: var(--r-2);
  background: var(--surface); color: var(--ink);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-3); opacity: 1; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-3); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline-offset: -1px; border-color: var(--accent); }
.textarea { height: auto; padding: var(--sp-3) var(--sp-4); resize: vertical; line-height: 1.4; }
.select {
  appearance: none; padding-right: 22px; width: auto; max-width: 100%; cursor: pointer; text-overflow: ellipsis;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 12px) 12px, calc(100% - 8px) 12px; background-size: 4px 4px; background-repeat: no-repeat;
}
.input.is-sm, .select.is-sm { height: var(--ctl-sm); font-size: var(--fs-2); }
.select.is-sm { background-position: calc(100% - 12px) 9px, calc(100% - 8px) 9px; }
.input.is-code { font: 500 var(--fs-6)/1 var(--font-mono); height: 40px; letter-spacing: .08em; }
.field { display: grid; gap: var(--sp-2); min-width: 0; }
.field > label, .field-label { color: var(--ink-2); font-size: var(--fs-2); font-weight: 500; }
.check { display: inline-flex; align-items: center; gap: var(--sp-3); height: var(--ctl); padding: 0 var(--sp-4); border: 1px solid var(--line-strong); border-radius: var(--r-2); background: var(--surface); cursor: pointer; white-space: nowrap; user-select: none; }
.check:hover { border-color: var(--ink-3); }
.check input { margin: 0; accent-color: var(--accent); }
.check:has(input:checked) { background: var(--accent-bg); border-color: var(--accent); }
.check:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Filter bar: one search box that grows, then compact selects. */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--line); min-width: 0; }
.toolbar > .toolbar-grow { flex: 1 1 14rem; min-width: 0; }
.toolbar > .toolbar-fixed { flex: 0 1 8rem; min-width: 0; }
.toolbar > .select { max-width: 11rem; }
.toolbar > .toolbar-end { margin-left: auto; display: flex; align-items: center; gap: var(--sp-3); }
@media (max-width: 639.98px) {
  .toolbar > .select, .toolbar > .toolbar-fixed, .toolbar > .check { flex: 1 1 calc(50% - var(--sp-3)); }
  .toolbar > .toolbar-grow { flex-basis: 100%; }
}
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--sp-3); min-width: 0; }
.inline-form > .field.is-grow { flex: 1 1 12rem; }

/* Tabs and segmented control */
.tabs { display: flex; gap: var(--sp-5); padding: 0 var(--sp-5); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { position: relative; display: inline-flex; align-items: center; gap: var(--sp-3); height: 34px; color: var(--ink-2); font-weight: 500; white-space: nowrap; }
.tab:hover { color: var(--ink); text-decoration: none; }
.tab[aria-current] { color: var(--ink); }
.tab[aria-current]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--accent); }
.seg { display: inline-flex; padding: 2px; border-radius: var(--r-2); background: var(--surface-3); }
.seg > a, .seg > button { display: inline-flex; align-items: center; height: calc(var(--ctl) - 4px); padding: 0 var(--sp-5); border: 0; border-radius: var(--r-1); background: none; color: var(--ink-2); font-weight: 500; cursor: pointer; }
.seg > a:hover, .seg > button:hover { color: var(--ink); text-decoration: none; }
.seg > [aria-current], .seg > .is-on { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }

.pager { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--line); color: var(--ink-3); font-size: var(--fs-2); }
.pager-nav { display: flex; align-items: center; gap: var(--sp-3); margin-left: auto; }
.pager [aria-disabled="true"] { opacity: .45; pointer-events: none; }

/* Disclosure: a row that opens. */
.disc { min-width: 0; }
.disc > summary { display: inline-flex; align-items: center; gap: var(--sp-3); min-height: var(--ctl-sm); padding: 0 var(--sp-3); margin-left: calc(-1 * var(--sp-3)); border-radius: var(--r-2); color: var(--ink-2); font-weight: 500; cursor: pointer; list-style: none; user-select: none; }
.disc > summary::-webkit-details-marker { display: none; }
.disc > summary::before { content: ""; width: 0; height: 0; border-left: 5px solid var(--ink-3); border-top: 4px solid transparent; border-bottom: 4px solid transparent; transition: transform .12s; }
.disc[open] > summary::before { transform: rotate(90deg); }
.disc > summary:hover { background: var(--surface-3); color: var(--ink); }
.disc > summary + * { margin-top: var(--sp-3); }
.disc + .disc { margin-top: var(--sp-2); }

/* --- 6. Chips ----------------------------------------------------------------- */

/* A chip is a short fact: a state, a count, a name. The words carry the meaning; the tone repeats it. */
.chip {
  --c: var(--ink-2); --cb: var(--muted-bg);
  display: inline-flex; align-items: center; gap: var(--sp-2); min-height: 18px; max-width: 100%; padding: 0 var(--sp-3);
  border: 1px solid transparent; border-radius: var(--r-1); background: var(--cb); color: var(--c);
  font: 500 var(--fs-1)/1.45 var(--font-sans); white-space: nowrap; text-align: left; vertical-align: middle; text-decoration: none;
}
/* A chip holding free text from an upload may wrap; it never widens the page. */
.chip.is-text { white-space: normal; overflow-wrap: anywhere; }
a.chip:hover { border-color: var(--c); text-decoration: none; }
.chip .mono, .chip.mono { font-size: var(--fs-1); }
.chip > .icon { width: 12px; height: 12px; }
.chip > b, .chip > .chip-n { font-family: var(--font-mono); font-weight: 600; }
.chip-clip { display: inline-block; max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); min-width: 0; }

/* Semantic tones */
.chip.is-read { --c: var(--read); --cb: var(--read-bg); }
.chip.is-write { --c: var(--write); --cb: var(--write-bg); }
.chip.is-feed { --c: var(--feed); --cb: var(--feed-bg); }
.chip.is-win { --c: var(--win); --cb: var(--win-bg); }
.chip.is-warn { --c: var(--warn); --cb: var(--warn-bg); }
.chip.is-fail { --c: var(--fail); --cb: var(--fail-bg); }
.chip.is-accent { --c: var(--accent); --cb: var(--accent-bg); }
.chip.is-muted { --c: var(--ink-2); --cb: var(--muted-bg); }
.chip.is-outline { --cb: transparent; border-color: var(--line-strong); }
.chip.is-verified { --c: var(--verified); --cb: var(--win-bg); border-color: var(--verified); }
.chip.is-unverified { --c: var(--unverified); --cb: transparent; border: 1px dashed var(--line-strong); }
.chip.is-sev-critical { --c: var(--sev-critical); --cb: var(--sev-critical-bg); }
.chip.is-sev-high { --c: var(--sev-high); --cb: var(--sev-high-bg); }
.chip.is-sev-medium { --c: var(--sev-medium); --cb: var(--sev-medium-bg); }
.chip.is-sev-low { --c: var(--sev-low); --cb: var(--sev-low-bg); }
.chip.is-kind-http { --c: var(--kind-http); --cb: var(--kind-http-bg); }
.chip.is-kind-async { --c: var(--kind-async); --cb: var(--kind-async-bg); }
/* Tone names that views.py hands out from its fixed tables */
.chip.t-green { --c: var(--win); --cb: var(--win-bg); }
.chip.t-red { --c: var(--fail); --cb: var(--fail-bg); }
.chip.t-yellow { --c: var(--warn); --cb: var(--warn-bg); }
.chip.t-orange { --c: var(--write); --cb: var(--write-bg); }
.chip.t-blue { --c: var(--accent); --cb: var(--accent-bg); }
.chip.t-azure, .chip.t-teal { --c: var(--read); --cb: var(--read-bg); }
.chip.t-purple { --c: var(--feed); --cb: var(--feed-bg); }

/* A severity chip starts with a level mark, so it reads without colour: ▮▮▮▮ critical … ▮ low. */
.sev-mark { display: inline-flex; gap: 1px; align-items: flex-end; height: 9px; }
.sev-mark > i { width: 2px; background: currentColor; opacity: .28; border-radius: 1px; }
.sev-mark > i:nth-child(1) { height: 3px; } .sev-mark > i:nth-child(2) { height: 5px; }
.sev-mark > i:nth-child(3) { height: 7px; } .sev-mark > i:nth-child(4) { height: 9px; }
.sev-mark > i.is-on { opacity: 1; }

/* Status dot inside a chip: filled, ring or pulsing. */
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.dot.is-ring { background: none; box-shadow: inset 0 0 0 1.5px currentColor; }
.dot.is-live { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }

/* Project dimension. p-1 … p-8 set --p; the marker always carries two letters next to the colour. */
.p-1 { --p: var(--p-1); } .p-2 { --p: var(--p-2); } .p-3 { --p: var(--p-3); } .p-4 { --p: var(--p-4); }
.p-5 { --p: var(--p-5); } .p-6 { --p: var(--p-6); } .p-7 { --p: var(--p-7); } .p-8 { --p: var(--p-8); }
.pmark {
  display: inline-grid; place-items: center; flex: none; min-width: 22px; height: 17px; padding: 0 3px; border-radius: var(--r-1);
  background: var(--p, var(--ink-3)); color: #fff; font: 600 11px/1 var(--font-mono);
}
:root[data-theme="dark"] .pmark { color: #0e1014; }
.pmark.is-all, :root[data-theme="dark"] .pmark.is-all { background: none; box-shadow: inset 0 0 0 1px var(--line-strong); color: var(--ink-2); }
.pchip { display: inline-flex; align-items: center; gap: var(--sp-3); max-width: 100%; min-width: 0; color: var(--ink); font-weight: 500; white-space: nowrap; }
.pchip > .pchip-name { overflow: hidden; text-overflow: ellipsis; }
a.pchip:hover { text-decoration: none; }
a.pchip:hover > .pchip-name { text-decoration: underline; }
.pswatch { display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: var(--p, var(--ink-3)); flex: none; }

/* --- 7. Tables ---------------------------------------------------------------- */

/* position: relative keeps visually-hidden labels inside a scrolled table from widening the page */
.tbl-wrap { position: relative; overflow-x: auto; min-width: 0; }
.tbl { width: 100%; border-collapse: collapse; font-size: var(--fs-3); }
.tbl th {
  padding: var(--sp-3) var(--sp-4); background: var(--surface-2); border-bottom: 1px solid var(--line); color: var(--ink-3);
  font-size: var(--fs-1); font-weight: 500; text-align: left; white-space: nowrap; vertical-align: bottom;
}
.tbl td { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th:first-child, .tbl td:first-child { padding-left: var(--sp-5); }
.tbl th:last-child, .tbl td:last-child { padding-right: var(--sp-5); }
.tbl tbody tr:last-child > td { border-bottom: 0; }
.tbl tbody tr:hover > td { background: var(--surface-2); }
.tbl.is-middle td { vertical-align: middle; }
.tbl .title-cell { min-width: 15rem; }
.tbl td:has(> .path) { min-width: 15rem; }
.tbl td:has(> .pchip) { min-width: 13rem; }
.tbl td.break { min-width: 10rem; }
.tbl td.cell-tables { min-width: 11rem; max-width: 16rem; }
.tbl .cell-sub { margin-top: 1px; color: var(--ink-3); font-size: var(--fs-2); }
.tbl a.row-link { color: var(--ink); font-weight: 500; }
.tbl a.row-link:hover { color: var(--accent); }
.tbl tr.site-detail:has(> td:empty) { display: none; }
.tbl tr.site-detail > td, .tbl tr.site-detail:hover > td { background: var(--surface-2); padding: var(--sp-5); }
.num { text-align: right !important; font-family: var(--font-mono); font-size: var(--fs-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl td.num { padding-top: 7px; }
.tabular { font-variant-numeric: tabular-nums; }
.path { font-family: var(--font-mono); font-size: var(--fs-2); overflow-wrap: anywhere; }
.tbl td.cell-sql { width: 40%; min-width: 14rem; max-width: 0; }
.sql-preview { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-3); font: 400 var(--fs-2)/1.5 var(--font-mono); }

/* Key-value grid: facts about one thing, many per row. */
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: var(--sp-4) var(--sp-5); }
.kv > div { min-width: 0; }
.kv dt { color: var(--ink-3); font-size: var(--fs-1); font-weight: 500; }
.kv dd { overflow-wrap: anywhere; }
.kv.is-rows { grid-template-columns: max-content minmax(0, 1fr); gap: var(--sp-2) var(--sp-5); }
.kv.is-rows > div { display: contents; }
.kv.is-rows dt { padding-top: 2px; }

/* --- 8. Data components ------------------------------------------------------- */

/* Stat tiles: one strip, hairlines between. */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-3); overflow: hidden; }
.stat { display: grid; align-content: start; gap: var(--sp-2); padding: var(--sp-4) var(--sp-5) var(--sp-5); min-width: 0; box-shadow: -1px 0 0 var(--line), 0 -1px 0 var(--line); }
.stat-label { color: var(--ink-3); font-size: var(--fs-1); font-weight: 500; }
.stat-value { font: 500 var(--fs-7)/1.1 var(--font-mono); letter-spacing: -.02em; color: var(--ink); }
a.stat-value:hover { color: var(--accent); text-decoration: none; }
.stat-value.is-win { color: var(--win); }
.stat-sub { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; min-height: 18px; color: var(--ink-3); font-size: var(--fs-1); }

/* Bars. The track is the full width; the fill is a share of it. */
.bar { height: 8px; min-width: 0; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.bar > span { display: block; height: 100%; min-width: 2px; border-radius: inherit; background: var(--accent); }
.bar.is-table > span, .bar.is-before > span, .bar.is-muted > span { background: var(--ink-3); opacity: .6; }
.bar.is-read > span { background: var(--write); }
.bar.is-result > span, .bar.is-after > span, .bar.is-win > span { background: var(--win); }
.bar.is-worse > span, .bar.is-fail > span { background: var(--fail); background-image: repeating-linear-gradient(135deg, transparent 0 3px, rgba(255, 255, 255, .35) 3px 5px); }
.bar.is-thin { height: 4px; }
.bars { display: grid; gap: var(--sp-3); }
.bars-row { display: grid; grid-template-columns: 8rem minmax(0, 1fr) 11rem; grid-template-areas: "name bar num"; gap: var(--sp-2) var(--sp-5); align-items: center; }
.bars-row > .bars-name { grid-area: name; color: var(--ink-2); font-size: var(--fs-2); min-width: 0; }
.bars-row > .bar { grid-area: bar; }
.bars-row > .bars-num { grid-area: num; text-align: right; font: 400 var(--fs-2)/1.4 var(--font-mono); white-space: nowrap; }
.bars-num > b { margin-left: var(--sp-3); }
.bars > .bars-head { margin-top: var(--sp-3); font-weight: 600; font-size: var(--fs-2); }
.bars > .bars-head:first-child { margin-top: 0; }
.bars > .bars-head > span { margin-left: var(--sp-3); color: var(--ink-3); font-weight: 400; }
.bars.is-compact .bars-row { grid-template-columns: 7rem minmax(0, 1fr) 3.5rem; }
@media (max-width: 639.98px) {
  .bars-row, .bars.is-compact .bars-row { grid-template-columns: minmax(0, 1fr) max-content; grid-template-areas: "name num" "bar bar"; }
}

/* Path strip: entry point -> callers -> call site -> tables. */
.flow { display: flex; flex-wrap: wrap; align-items: stretch; gap: var(--sp-3) var(--sp-2); }
.flow > li { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; max-width: 100%; }
.flow-arrow { display: inline-flex; flex: none; color: var(--ink-3); }
.flow-node {
  display: flex; flex-direction: column; justify-content: center; gap: 1px; min-width: 0; max-width: 100%; padding: var(--sp-2) var(--sp-4);
  border: 1px solid var(--line-strong); border-radius: var(--r-2); background: var(--surface); color: var(--ink); font-size: var(--fs-2); overflow-wrap: anywhere;
}
.flow-node > .flow-sub, .flow-node .path { color: var(--ink-3); font-size: var(--fs-1); }
.flow-node.is-site { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); padding-left: calc(var(--sp-4) + 3px); }
.flow-node.is-table { flex-direction: row; align-items: center; gap: var(--sp-3); background: var(--surface-2); }
.flow-node.is-table > .icon { color: var(--ink-3); }
a.flow-node:hover { border-color: var(--accent); text-decoration: none; }

/* Sorting key: one box per key column, in key order. State is drawn three ways: tone, border and a mark. */
.keyrow { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.keybox { display: inline-flex; align-items: center; gap: var(--sp-3); min-width: 0; max-width: 100%; padding: 2px var(--sp-4) 2px 2px; border: 1px solid var(--line-strong); border-radius: var(--r-2); background: var(--surface); font-size: var(--fs-2); overflow-wrap: anywhere; }
.keybox-pos { flex: none; display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 3px; border-radius: 2px; background: var(--surface-3); color: var(--ink-2); font: 600 var(--fs-1)/1 var(--font-mono); }
.keybox.is-used { background: var(--win-bg); border-color: var(--win); }
.keybox.is-used > .keybox-pos { background: var(--win); color: var(--surface); }
.keybox.is-skipped { border-color: var(--warn); background: repeating-linear-gradient(135deg, var(--warn-bg) 0 5px, var(--surface) 5px 8px); }
.keybox.is-skipped > .keybox-pos { background: var(--warn); color: var(--surface); }
.keybox.is-filtered { background: var(--read-bg); border-color: var(--read); }
.keybox.is-filtered > .keybox-pos { background: var(--read); color: var(--surface); }
.keybox.is-idle { border-style: dashed; color: var(--ink-2); }
.keybox.is-added { box-shadow: 0 0 0 2px var(--accent); }
.keybox.is-plain { background: var(--surface); }
.keylegend { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-5); color: var(--ink-3); font-size: var(--fs-1); }
.keylegend > span { display: inline-flex; align-items: center; gap: var(--sp-3); }
.keylegend .keybox { padding: 0; width: 14px; height: 10px; border-radius: 2px; }
.access + .access { margin-top: var(--sp-5); padding-top: var(--sp-5); border-top: 1px solid var(--line); }
.filter-chip > .op { font-family: var(--font-mono); font-weight: 600; opacity: .8; }

/* Cause: an icon, a label, at most one short detail. */
.cause { display: flex; gap: var(--sp-4); align-items: flex-start; min-width: 0; max-width: 100%; padding: var(--sp-3) var(--sp-4); border: 1px solid var(--line); border-left: 3px solid var(--write); border-radius: var(--r-2); background: var(--surface); overflow-wrap: anywhere; font-size: var(--fs-2); }
.cause > .icon { color: var(--write); margin-top: 1px; }
.cause-label { font-weight: 600; }
.cause-detail { color: var(--ink-3); font-size: var(--fs-1); }

/* One small before/after pair per sandbox scale. */
.scales { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: var(--sp-3); }
.scale-cell { min-width: 0; padding: var(--sp-3) var(--sp-4); border: 1px solid var(--line); border-radius: var(--r-2); }
.scale-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); font: 500 var(--fs-2)/1.4 var(--font-mono); }
.scale-head > :last-child { margin-left: auto; }
.scale-cell .bar + .bar { margin-top: 2px; }
.scale-pair { display: grid; grid-template-columns: minmax(0, 1fr) max-content; gap: 0 var(--sp-4); align-items: center; margin-top: var(--sp-3); color: var(--ink-3); font: 400 var(--fs-1)/1.4 var(--font-mono); }
.rekey { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3) var(--sp-4); }
.reject-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: var(--sp-3); }
.reject-list > div { min-width: 0; padding: var(--sp-3) var(--sp-4); border: 1px solid var(--line); border-radius: var(--r-2); overflow-wrap: anywhere; font-size: var(--fs-2); }
.reject-list .reject-detail { color: var(--ink-3); font-size: var(--fs-1); }

/* SQL, plans and commands. Long lines scroll inside the block, never the page. */
pre.sql, pre.plan, pre.out {
  margin: 0; padding: var(--sp-4) var(--sp-5); max-height: 26rem; overflow: auto; white-space: pre; tab-size: 2;
  font: 400 var(--fs-2)/1.55 var(--font-mono); background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r-2);
}
pre.plan { max-height: 22rem; }
pre.out { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 14rem; }
.cli { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; height: var(--ctl); padding: 0 2px 0 var(--sp-4); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-2); }
.cli > code, .cli > .secret-once { flex: 1 1 auto; min-width: 0; overflow-x: auto; white-space: nowrap; background: none; padding: 0; font: 500 var(--fs-2)/1 var(--font-mono); scrollbar-width: none; }
.cli > code::before { content: "$ "; color: var(--ink-3); user-select: none; }
.cli > .btn { flex: none; }
.secret-once { user-select: all; }

/* Item list: compact rows inside a panel (history, seen-in, members of a group). */
.rows > * { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-4); padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--line); min-width: 0; color: var(--ink); }
.rows > :first-child { border-top: 0; }
.rows > a:hover { background: var(--surface-2); text-decoration: none; }
.rows > [aria-current="true"] { box-shadow: inset 3px 0 0 var(--accent); background: var(--accent-bg); }
.rows .rows-end { margin-left: auto; color: var(--ink-3); font-size: var(--fs-2); white-space: nowrap; }
.rows .rows-sub { flex: 0 0 100%; color: var(--ink-3); font-size: var(--fs-2); overflow-wrap: anywhere; }

/* --- 9. Pipeline: funnel and stage progress ------------------------------------ */

/* Funnel: found -> … -> verified. One cell per step; the bar is the share of the first step. */
.funnel { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
.funnel-step { position: relative; display: grid; align-content: start; gap: var(--sp-2); padding: var(--sp-4) var(--sp-5); min-width: 0; box-shadow: -1px 0 0 var(--line); }
/* Each step points at the next: a notch on the boundary. */
.funnel-step + .funnel-step::before { content: ""; position: absolute; left: -5px; top: 18px; width: 9px; height: 9px; background: var(--surface); border-top: 1px solid var(--line); border-right: 1px solid var(--line); transform: rotate(45deg); z-index: 1; }
@media (max-width: 639.98px) {
  .funnel { grid-auto-flow: row; }
  .funnel-step { grid-template-columns: 5.5rem minmax(0, 1fr) max-content; grid-template-areas: "n label rate" "bar bar bar"; align-items: baseline; gap: var(--sp-2) var(--sp-4); padding: var(--sp-3) var(--sp-5); box-shadow: 0 -1px 0 var(--line); }
  .funnel-step + .funnel-step::before { display: none; }
  .funnel-step > .funnel-n { grid-area: n; } .funnel-step > .funnel-label { grid-area: label; min-height: 0; }
  .funnel-step > .funnel-rate { grid-area: rate; } .funnel-step > .bar { grid-area: bar; }
}
.funnel-n { font: 500 var(--fs-6)/1.15 var(--font-mono); letter-spacing: -.02em; }
.funnel-label { color: var(--ink-2); font-size: var(--fs-2); line-height: 1.25; min-height: 2.5em; }
.funnel-rate { display: inline-flex; align-items: center; gap: var(--sp-2); color: var(--ink-3); font: 400 var(--fs-1)/1.3 var(--font-mono); min-height: 1.3em; }
.funnel-step .bar > span { background: var(--ink-2); }
.funnel-step.is-verified .funnel-n { color: var(--win); }
.funnel-step.is-verified .bar > span { background: var(--win); }
.funnel-step.is-pending .funnel-n { color: var(--ink-3); }
.funnel-step.is-pending { background: repeating-linear-gradient(135deg, transparent 0 6px, var(--surface-2) 6px 12px); }
.funnel-wrap { overflow: hidden; }
.funnel-why { border-top: 1px solid var(--line); }
.funnel-why > summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-1) var(--sp-4); padding: var(--sp-3) var(--sp-5); cursor: pointer; list-style: none; }
.funnel-why > summary::-webkit-details-marker { display: none; }
.funnel-why > summary > .label { margin: 0; min-width: 12.5rem; }
.funnel-why > .chips { padding: 0 var(--sp-5) var(--sp-3) calc(12.5rem + var(--sp-5) + var(--sp-4)); gap: var(--sp-1) var(--sp-5); }
.funnel-reason { color: var(--ink-2); font-size: var(--fs-2); white-space: nowrap; }
.funnel-reason > b { font: 600 var(--fs-2)/1 var(--font-mono); color: var(--ink); }
.funnel-more { color: var(--accent); font-size: var(--fs-2); }
.funnel-why[open] .funnel-more { display: none; }
@media (max-width: 767.98px) { .funnel-why > summary > .label { min-width: 100%; } .funnel-why > .chips { padding-left: var(--sp-5); } }
.funnel-skipped { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--line); }
.funnel-skipped > .label { margin: 0 var(--sp-2) 0 0; }
/* Inline funnel for table rows: the same steps as numbers joined by chevrons. */
.funnel-inline { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-3); font: 400 var(--fs-2)/1.4 var(--font-mono); white-space: nowrap; }
.funnel-inline > .funnel-sep { color: var(--line-strong); }
.funnel-inline > .is-verified { color: var(--win); font-weight: 600; }

/* Stage rail: five small segments, for lists. Fill, outline and dash carry the state. */
.rail { display: inline-flex; gap: 2px; vertical-align: middle; }
.rail > i { width: 12px; height: 6px; border-radius: 1px; box-shadow: inset 0 0 0 1px var(--line-strong); }
.rail > i.is-done { background: var(--win); box-shadow: none; }
.rail > i.is-running { background: var(--accent); box-shadow: none; animation: pulse 1.4s ease-in-out infinite; }
.rail > i.is-failed { background: var(--fail); box-shadow: none; background-image: repeating-linear-gradient(135deg, transparent 0 2px, rgba(255, 255, 255, .5) 2px 3px); }
.rail > i.is-skipped { box-shadow: none; border-bottom: 1px dashed var(--line-strong); height: 4px; }

/* Stage progress: the full pipeline, one cell per stage, joined left to right. */
.stages { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); counter-reset: stage; }
.stage { position: relative; display: grid; align-content: start; gap: var(--sp-2); padding: var(--sp-4) var(--sp-5) var(--sp-5); min-width: 0; border-top: 3px solid var(--line); }
.stage + .stage { box-shadow: -1px 0 0 var(--line); }
.stage-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); }
.stage-name { font-weight: 600; }
.stage-name::before { counter-increment: stage; content: counter(stage); margin-right: var(--sp-3); color: var(--ink-3); font: 500 var(--fs-1)/1 var(--font-mono); }
.stage-time { margin-left: auto; color: var(--ink-3); font: 400 var(--fs-2)/1 var(--font-mono); }
.stage-message { color: var(--ink-3); font-size: var(--fs-2); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.stage.is-running { background: linear-gradient(var(--accent-bg), transparent 70%); }
.stage.is-failed { background: linear-gradient(var(--fail-bg), transparent 70%); }
.stage.is-waiting .stage-name, .stage.is-skipped .stage-name { color: var(--ink-3); }
.stages.is-vertical { grid-template-columns: minmax(0, 1fr); }
.stages.is-vertical > .stage { border-top: 0; border-left: 3px solid var(--line); padding: var(--sp-3) var(--sp-5); }
.stages.is-vertical > .stage + .stage { box-shadow: 0 -1px 0 var(--line); }
@media (max-width: 899.98px) {
  .stages { grid-template-columns: minmax(0, 1fr); }
  .stage { border-top: 0; border-left: 3px solid var(--line); padding: var(--sp-3) var(--sp-5); }
  .stage + .stage { box-shadow: 0 -1px 0 var(--line); }
}
.stages.is-vertical > .stage.is-done, .stage.is-done { border-color: var(--win); }
.stages.is-vertical > .stage.is-running, .stage.is-running { border-color: var(--accent); }
.stages.is-vertical > .stage.is-failed, .stage.is-failed { border-color: var(--fail); }
.stage.is-skipped { border-top-style: dashed; }
.stages.is-vertical > .stage.is-skipped { border-left-style: dashed; }
@media (max-width: 899.98px) { .stage.is-skipped { border-left-style: dashed; } }

/* Checklist (onboarding): numbered because it is a sequence. */
.steps { counter-reset: step; }
.step { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); gap: var(--sp-3) var(--sp-5); align-items: center; padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--line); }
.step:first-child { border-top: 0; }
.step-title { font-weight: 600; }
.step-body { display: grid; gap: var(--sp-3); min-width: 0; }
.step-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); min-width: 0; }
.step-row > .cli { flex: 1 1 16rem; max-width: 34rem; }
@media (max-width: 479.98px) { .step { grid-template-columns: minmax(0, 1fr); } }

/* --- 10. States: empty, loading, error ---------------------------------------- */

.empty { display: grid; justify-items: center; gap: var(--sp-4); padding: var(--sp-8) var(--sp-5); text-align: center; }
.empty-mark { display: grid; place-items: center; width: 32px; height: 32px; border: 1px dashed var(--line-strong); border-radius: var(--r-2); color: var(--ink-3); }
.empty-title { font-weight: 600; font-size: var(--fs-4); }
.empty-hint { color: var(--ink-3); font-size: var(--fs-2); max-width: 30rem; }
.empty-action { width: 100%; max-width: 22rem; }
.empty.is-compact { padding: var(--sp-6) var(--sp-5); }

.alert { display: flex; gap: var(--sp-4); align-items: flex-start; padding: var(--sp-4) var(--sp-5); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--r-2); background: var(--surface); min-width: 0; }
.alert > .icon { margin-top: 1px; color: var(--accent); }
.alert > div { min-width: 0; flex: 1 1 auto; display: grid; gap: var(--sp-3); }
.alert-title { font-weight: 600; }
.alert.is-fail { border-left-color: var(--fail); background: var(--fail-bg); } .alert.is-fail > .icon { color: var(--fail); }
.alert.is-warn { border-left-color: var(--warn); background: var(--warn-bg); } .alert.is-warn > .icon { color: var(--warn); }
.alert.is-win { border-left-color: var(--win); background: var(--win-bg); } .alert.is-win > .icon { color: var(--win); }
.notice { margin: var(--sp-5) 0 0; }

/* Loading: results dim while htmx fetches; a bar runs along the top of the panel. */
.results { position: relative; transition: opacity .12s; }
.htmx-request.results, .htmx-request .results { opacity: .5; }
.htmx-request.results::before, .htmx-request .results::before { content: ""; position: absolute; z-index: 2; top: 0; left: 0; height: 2px; width: 30%; background: var(--accent); animation: load 1s linear infinite; }
@keyframes load { from { left: -30%; } to { left: 100%; } }
.skel { display: block; height: 10px; border-radius: 2px; background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 200% 100%; animation: skel 1.2s linear infinite; }
@keyframes skel { to { background-position: -200% 0; } }
.live { display: inline-flex; align-items: center; gap: var(--sp-3); color: var(--accent); font-size: var(--fs-1); font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0s !important; animation-iteration-count: 1 !important; transition-duration: 0s !important; }
}

/* --- 11. Sign-in, pairing and error pages -------------------------------------- */

.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: var(--sp-7) var(--gutter); }
.auth-box { width: 100%; max-width: 23rem; display: grid; gap: var(--sp-6); }
.auth-brand { display: flex; align-items: center; justify-content: space-between; }
.auth-card { display: grid; gap: var(--sp-5); padding: var(--sp-6); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-3); }
.auth-title { font: 600 var(--fs-5)/1.3 var(--font-sans); }
.auth-card form { display: grid; gap: var(--sp-5); }
/* Provider buttons (GitHub, Google) above the code form, and the rule between them. */
.auth-providers { display: grid; gap: var(--sp-3); }
.auth-or { display: flex; align-items: center; gap: var(--sp-3); color: var(--ink-3); font-size: var(--fs-1); }
.auth-or::before, .auth-or::after { content: ""; flex: 1 1 0; border-top: 1px solid var(--line); }
.auth-foot { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; color: var(--ink-3); font-size: var(--fs-2); min-width: 0; }
.auth-foot > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
/* The pipeline as a quiet strip under the sign-in card: what the tool does, drawn. */
.auth-pipe { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); color: var(--ink-3); font: 400 var(--fs-1)/1.4 var(--font-mono); }
.auth-pipe > .is-end { color: var(--win); font-weight: 600; }
/* Privacy · Terms · Contact: under the sign-in card, at the foot of every console page and on the public pages. */
.legal-foot { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--sp-2) var(--sp-6); padding: var(--sp-5) var(--gutter); font-size: var(--fs-2); color: var(--ink-3); }
.legal-foot > a { color: var(--ink-3); }
.legal-foot > a:hover { color: var(--ink); }
.auth-box > .legal-foot { padding: 0; }
.app > .legal-foot, .pub > .legal-foot { border-top: 1px solid var(--line); }
/* Public pages (home, privacy, terms; public_layout.html): a readable measure, the console's tokens, no organisation bar. */
.pub { min-height: 100vh; display: flex; flex-direction: column; }
.pub-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-5); padding: var(--sp-4) var(--gutter); border-bottom: 1px solid var(--line); background: var(--surface); }
.pub-bar-end { display: flex; align-items: center; gap: var(--sp-3); }
.pub-main { flex: 1 1 auto; width: 100%; max-width: 52rem; margin: 0 auto; padding: var(--sp-7) var(--gutter) var(--sp-8); min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-6); align-content: start; }
.pub-title { font: 600 var(--fs-6)/1.25 var(--font-sans); letter-spacing: -.01em; overflow-wrap: anywhere; }
.pub-hero { display: grid; gap: var(--sp-5); }
.pub-actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); }
.pub-steps { display: grid; gap: var(--sp-5); grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
.pub-steps .panel-body { display: grid; gap: var(--sp-3); }
.pub-steps p { color: var(--ink-2); line-height: 1.5; }
.pub-cli { max-width: 28rem; }
.legal { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-4); line-height: 1.55; overflow-wrap: anywhere; }
.legal-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3) var(--sp-5); }
.legal h2 { margin-top: var(--sp-4); font: 600 var(--fs-4)/1.3 var(--font-sans); }
.legal ul { display: grid; gap: var(--sp-3); padding-left: 1.25em; list-style: disc; }
.legal p, .legal li { max-width: 46rem; }
.legal-note { color: var(--ink-2); }
.code-big { font: 600 var(--fs-7)/1.1 var(--font-mono); letter-spacing: .06em; }

/* --- 11b. Dense lists (findings, queries) --------------------------------------- */

/* A list table: fixed columns, two lines per row at most, nothing wraps. Text that does not fit
   ends in an ellipsis and carries the full value in a title. Below its min-width the table
   scrolls inside its wrapper. */
.tbl.is-list { table-layout: fixed; min-width: 58rem; }
.tbl.is-list td { padding-top: 5px; padding-bottom: 5px; vertical-align: top; overflow: hidden; }
.tbl.is-list td > .l1, .tbl.is-list td > .l2 { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; height: 20px; white-space: nowrap; }
.tbl.is-list td > .l2 { height: 18px; color: var(--ink-3); font-size: var(--fs-2); }
.tbl.is-list .clip { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl.is-list .l1 > .chip, .tbl.is-list .l2 > .chip { flex: none; }
.tbl.is-list .l2 > .chip.clip, .tbl.is-list .l1 > .chip.clip { flex: 0 1 auto; display: inline-block; line-height: 16px; }
.tbl.is-list a.row-link { display: block; }
.tbl.is-list th.is-num, .tbl.is-list td.is-num { text-align: right; }
.tbl.is-list td.is-num > .l1, .tbl.is-list td.is-num > .l2 { justify-content: flex-end; }
.tbl col.w-mark { width: 2.6rem; } .tbl col.w-sev { width: 5.75rem; } .tbl col.w-gain { width: 8.25rem; }
.tbl col.w-seen { width: 5.75rem; } .tbl col.w-kind { width: 6rem; } .tbl col.w-btn { width: 2.5rem; }
.tbl col.w-13 { width: 13%; } .tbl col.w-15 { width: 15%; } .tbl col.w-18 { width: 18%; } .tbl col.w-22 { width: 22%; } .tbl col.w-25 { width: 25%; } .tbl col.w-28 { width: 28%; }
.tbl.is-list td.cell-mark { padding-right: 0; }

/* Rows that open something: the whole row is the target; the link or button inside is the keyboard target. */
.tbl tr.is-click { cursor: pointer; }
.tbl tr.is-click:focus-within > td { background: var(--accent-bg); }
.tbl tr.is-stale > td { background: repeating-linear-gradient(135deg, transparent 0 7px, var(--surface-2) 7px 14px); }
.tbl tr.is-stale a.row-link { color: var(--ink-2); font-weight: 400; }
.tbl tr.group-row > th { padding: var(--sp-2) var(--sp-5); background: var(--surface-3); border-bottom: 1px solid var(--line); color: var(--ink); font-size: var(--fs-2); font-weight: 600; text-align: left; position: static; }
.tbl tr.group-row > th > .row { gap: var(--sp-4); }
.group-n { color: var(--ink-3); font-weight: 400; }
/* Counts beside a page title: plain text, the number in mono. Not chips. */
.count-link { color: var(--ink-2); font-size: var(--fs-2); white-space: nowrap; }
.count-link > b { font: 600 var(--fs-2)/1 var(--font-mono); color: var(--ink); }
a.count-link:hover { color: var(--accent); text-decoration: none; }
.page-meta > .count-link + .count-link::before { content: "·"; margin-right: var(--sp-3); color: var(--line-strong); }

/* A table that fills the window: it scrolls in its own box and its head stays put. */
.tbl-wrap.is-fill { max-height: max(22rem, calc(100vh - 12.5rem)); overflow: auto; }
.tbl-wrap.is-fill thead th { position: sticky; top: 0; z-index: 3; box-shadow: 0 1px 0 var(--line); }
.tbl th > a.sort { display: inline-flex; align-items: center; gap: var(--sp-2); color: inherit; }
.tbl th > a.sort:hover { color: var(--ink); text-decoration: none; }
.tbl th > a.sort[aria-current="true"] { color: var(--accent); font-weight: 600; }
.sort-mark { font-size: 11px; line-height: 1; }

/* A file as directory (muted, cut from the left) and name:line (always whole). */
.loc { display: inline-flex; max-width: 100%; min-width: 0; font: 400 var(--fs-2)/1.4 var(--font-mono); white-space: nowrap; vertical-align: bottom; }
.loc-dir { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; direction: rtl; color: var(--ink-3); }
/* The name never shrinks (a sub-pixel shrink would already put an ellipsis in it); only the directory gives way.
   A name too long for the cell on its own is cut with an ellipsis, keeping room for the line number. */
.loc-file { flex: none; max-width: calc(100% - 5ch); overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.loc-line { flex: none; color: var(--ink); }
.l2 .loc-line { color: var(--ink-2); }
.l2 .loc-file { color: var(--ink-2); }

/* Gain: rows read after the fix as a share of before. Short bar, then the number. */
.gain { display: inline-flex; align-items: center; gap: var(--sp-3); min-width: 0; max-width: 100%; font: 400 var(--fs-2)/1.2 var(--font-mono); white-space: nowrap; }
.gain > .bar { width: 2.5rem; height: 6px; flex: none; }
.gain.is-wide > .bar { width: 7rem; height: 8px; }
.gain-abs { color: var(--ink-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.gain-pct { font-weight: 600; color: var(--ink-2); }
.gain.is-win > .gain-pct { color: var(--win); }
.gain.is-worse > .gain-pct { color: var(--fail); }
.gain-metric { color: var(--ink-3); font-family: var(--font-sans); font-size: var(--fs-1); }
.gain.is-none { color: var(--ink-3); }

/* The chevron button that opens a row in place. */
.row-toggle { display: inline-grid; place-items: center; width: var(--ctl-sm); height: var(--ctl-sm); padding: 0; border: 0; border-radius: var(--r-2); background: none; color: var(--ink-3); cursor: pointer; }
.row-toggle:hover { background: var(--surface-3); color: var(--ink); }
.row-toggle > .icon { transition: transform .12s; transform: rotate(-90deg); }
.row-toggle[aria-expanded="true"] > .icon { transform: none; }
.tbl.is-list tr.site-detail > td { overflow: visible; }

/* --- 11c. Filters, views, peek, jump box, checklist, hints, tour ---------------- */

/* Filters live in a popover; what is active shows as removable chips above the list. */
/* The filter popover hangs from the toolbar, not the button, so it never leaves the panel. */
.toolbar { position: relative; }
.filter-menu { position: static; }
.filter-menu > .filter-pop { top: calc(100% - var(--sp-2)); left: auto; right: var(--sp-5); }
.filter-pop { display: grid; grid-template-columns: repeat(2, minmax(9rem, 1fr)); gap: var(--sp-4); padding: var(--sp-5); min-width: min(24rem, calc(100vw - 2 * var(--gutter))); overflow: visible; max-height: none; }
.filter-pop .select, .filter-pop .input { width: 100%; max-width: none; }
.list-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); min-height: 34px; padding: var(--sp-2) var(--sp-5); border-bottom: 1px solid var(--line); min-width: 0; }
.filter-on { gap: var(--sp-2); max-width: 22rem; overflow: hidden; }
.filter-on > .muted { color: inherit; opacity: .7; font-weight: 400; }
.menu-row { display: flex; align-items: center; gap: var(--sp-1); }
.menu-row > .menu-item { flex: 1 1 auto; width: auto; }
.menu-form { display: flex; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3) var(--sp-3); }
.seg-off { display: inline-flex; align-items: center; height: calc(var(--ctl) - 4px); padding: 0 var(--sp-5); color: var(--ink-3); opacity: .6; cursor: not-allowed; white-space: nowrap; }
.seg > a { white-space: nowrap; }
.funnel-drop { margin-left: var(--sp-3); color: var(--fail); }
.bars.is-wide-name .bars-row { grid-template-columns: minmax(0, 11rem) minmax(0, 1fr) 2.5rem; }
.bars .clip, .rows .clip { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rows > a > .gain { margin-left: auto; }

/* Live feed: newest event first, one line each. */
.feed { border-top: 1px solid var(--line); max-height: 13.5rem; overflow-y: auto; }
.feed > li { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-5); min-width: 0; font-size: var(--fs-2); }
.feed > li + li { border-top: 1px solid var(--line); }
.feed-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.feed-time { flex: none; color: var(--ink-3); font: 400 var(--fs-1)/1 var(--font-mono); }

/* Peek: a finding beside the list. */
.peek { position: fixed; z-index: 45; top: 42px; right: 0; bottom: 0; width: min(31rem, 100vw); overflow-y: auto; background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow-pop); }
.peek:focus { outline: none; }
.peek-close { position: absolute; top: var(--sp-4); right: var(--sp-4); }
.peek-head { display: grid; gap: var(--sp-4); justify-items: start; padding: var(--sp-5) calc(var(--ctl) + var(--sp-6)) var(--sp-5) var(--sp-6); border-bottom: 1px solid var(--line); }
.peek-title { font: 600 var(--fs-4)/1.35 var(--font-sans); overflow-wrap: anywhere; }
.peek-section { padding: var(--sp-5) var(--sp-6); border-bottom: 1px solid var(--line); min-width: 0; }
.peek-variant + .peek-variant { margin-top: var(--sp-5); padding-top: var(--sp-5); border-top: 1px dashed var(--line); }
.tbl tr.is-peeked > td { background: var(--accent-bg); box-shadow: inset 0 1px 0 var(--accent), inset 0 -1px 0 var(--accent); }

/* Dialogs: shortcuts, CLI commands and the jump box. */
.dlg { width: min(34rem, calc(100vw - 2 * var(--gutter))); max-height: min(36rem, 86vh); padding: 0; border: 0; border-radius: var(--r-3); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-pop); overflow: hidden; }
.dlg::backdrop { background: rgba(14, 16, 20, .45); }
.dlg[open] { display: flex; flex-direction: column; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); padding: var(--sp-4) var(--sp-4) var(--sp-4) var(--sp-6); border-bottom: 1px solid var(--line); }
.dlg-body { padding: var(--sp-6); overflow-y: auto; }
.dlg.is-palette { margin-top: 12vh; }
.palette-in { display: flex; align-items: center; gap: var(--sp-4); padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--line); color: var(--ink-3); }
.palette-in > .input { border: 0; height: 32px; font-size: var(--fs-4); padding: 0; background: none; }
.palette-in > .input:focus-visible { outline: none; }
.palette-results { overflow-y: auto; padding: var(--sp-2); min-height: 6rem; }
.jump-item { display: flex; align-items: center; gap: var(--sp-4); width: 100%; min-height: var(--ctl); padding: var(--sp-2) var(--sp-4); border: 0; border-radius: var(--r-2); background: none; color: var(--ink); text-align: left; cursor: pointer; min-width: 0; }
.jump-item:hover { text-decoration: none; }
.jump-item.is-active, .jump-item:focus-visible { background: var(--accent-bg); outline: none; box-shadow: inset 2px 0 0 var(--accent); }
.jump-kind { flex: none; color: var(--ink-3); font-size: var(--fs-1); }
.jump-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jump-item .mono, .jump-item .muted { white-space: nowrap; flex: none; }
.jump-item .jump-name.mono { flex: 1 1 auto; }
.jump-empty { padding: var(--sp-5) var(--sp-4); color: var(--ink-3); }
.palette-foot { display: flex; gap: var(--sp-6); padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--line); color: var(--ink-3); font-size: var(--fs-1); }
kbd { display: inline-block; min-width: 18px; padding: 0 4px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: var(--r-1); background: var(--surface-2); color: var(--ink-2); font: 500 var(--fs-1)/16px var(--font-mono); text-align: center; }
.jump-btn { display: inline-flex; align-items: center; gap: var(--sp-3); height: var(--ctl); padding: 0 var(--sp-3) 0 var(--sp-4); border: 1px solid var(--line); border-radius: var(--r-2); background: var(--surface-2); color: var(--ink-3); cursor: pointer; white-space: nowrap; }
.jump-btn:hover { border-color: var(--line-strong); color: var(--ink); }
@media (max-width: 1239.98px) { .jump-word { display: none; } }
@media (max-width: 479.98px) { .jump-btn > kbd { display: none; } .jump-btn { padding: 0 var(--sp-4); border: 0; background: none; } }

/* Getting-started checklist. */
.progress { display: inline-block; width: 6rem; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--win); }
.step.is-next { background: var(--accent-bg); box-shadow: inset 3px 0 0 var(--accent); }
.step.is-optional .step-title { color: var(--ink-2); font-weight: 500; }
.step-row > .step-title { flex: 0 0 11rem; }
.checklist.is-compact .steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); }
.checklist.is-compact .step { grid-template-columns: 4.75rem minmax(0, 1fr); padding: var(--sp-3) var(--sp-5); border-top: 0; box-shadow: 0 -1px 0 var(--line), -1px 0 0 var(--line); }
.checklist.is-compact .step.is-next { box-shadow: inset 3px 0 0 var(--accent), 0 -1px 0 var(--line); }
.checklist.is-compact .step-row > .step-title { flex: 1 1 auto; }
.checklist.is-compact .step-row > .cli { flex: 1 1 100%; }
.checklist .panel-head { gap: var(--sp-4); }
@media (max-width: 639.98px) { .step-row > .step-title { flex-basis: 100%; } }

/* First-visit hint: one line, dismissed for good. */
.hint { display: flex; align-items: center; gap: var(--sp-4); margin-bottom: var(--sp-4); padding: var(--sp-2) var(--sp-3) var(--sp-2) var(--sp-5); border: 1px dashed var(--accent); border-radius: var(--r-2); background: var(--accent-bg); color: var(--ink); font-size: var(--fs-2); }
.hint > .icon { color: var(--accent); }
.hint > span { flex: 1 1 auto; min-width: 0; }

/* Tour: a spotlight on one element and a callout beside it. */
.tour-shade { position: fixed; inset: 0; z-index: 90; }
.tour-spot { position: fixed; z-index: 91; border-radius: var(--r-2); box-shadow: 0 0 0 2px var(--accent), 0 0 0 9999px rgba(10, 12, 18, .55); pointer-events: none; transition: top .15s, left .15s, width .15s, height .15s; }
.tour-card { position: fixed; z-index: 92; width: min(21rem, calc(100vw - 24px)); display: grid; gap: var(--sp-4); padding: var(--sp-5) var(--sp-6); border-radius: var(--r-3); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-pop); }
.tour-card:focus { outline: none; }
.tour-title { font: 600 var(--fs-4)/1.3 var(--font-sans); }
.tour-text { color: var(--ink-2); }
.tour-foot { display: flex; align-items: center; gap: var(--sp-3); }
.tour-count { margin-right: auto; color: var(--ink-3); font: 500 var(--fs-1)/1 var(--font-mono); }

/* --- 11d. Finding page: compact path strip, index rows --------------------------- */

/* The call path wraps as short cards: name on one line, file under it cut from the left. */
.flow-node { max-width: 17rem; }
.flow { gap: var(--sp-2); }
.flow-node > .flow-main { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow-node > .flow-sub { display: flex; min-width: 0; }
.flow-node.is-table { max-width: 100%; }
.peek .flow-node { max-width: 100%; }

/* The best measured fix, first thing on the page: what changes, and before against after. */
.headline { display: grid; grid-template-columns: minmax(0, 1fr) minmax(14rem, 22rem); gap: var(--sp-3) var(--sp-6); align-items: center; padding: var(--sp-4) var(--sp-5); border-left: 3px solid var(--win); }
.headline .label { margin-bottom: var(--sp-1); }
.headline-bars .bars-row { grid-template-columns: 6.5rem minmax(0, 1fr) 3.25rem; }
@media (max-width: 767.98px) { .headline { grid-template-columns: minmax(0, 1fr); } }
details.access > summary { gap: var(--sp-4); }

.headline { grid-template-columns: minmax(11rem, 1fr) minmax(0, auto); border-left-color: var(--line-strong); }
.headline.is-verified { border-left-color: var(--win); }
.headline.is-rejected, .headline.is-failed { border-left-color: var(--fail); }
.headline-gains { display: grid; gap: var(--sp-3); min-width: 0; }
.headline-gain { display: grid; grid-template-columns: 6rem minmax(0, auto); align-items: center; gap: var(--sp-4); min-width: 0; }
.headline .gain.is-wide { flex-wrap: wrap; row-gap: 2px; }
.headline .gain.is-wide > .bar { width: 5rem; }
.headline-gain > .label { margin: 0; }
.headline .gain { font-size: var(--fs-3); }
@media (max-width: 767.98px) { .headline { grid-template-columns: minmax(0, 1fr); } .headline-gain { grid-template-columns: minmax(0, 1fr); gap: var(--sp-1); } }

/* The query itself: about twelve lines, the rest one click away. Never behind a disclosure. */
.sqlbox { position: relative; }
.sqlbox > pre.sql { border: 0; border-radius: 0; max-height: calc(12 * 1.55em + 2 * var(--sp-4)); overflow: hidden; }
.sqlbox.is-open > pre.sql { max-height: none; overflow: auto; }
.sqlbox:not(.is-open) > pre.sql { overflow-x: auto; }
.sqlbox-more { position: absolute; right: var(--sp-4); bottom: var(--sp-4); box-shadow: 0 0 0 6px var(--surface-2); }
pre.out.is-error { max-height: 18rem; background: var(--surface); }

/* A fix as a diff: what it removes and what it adds. The sign carries it; the tint repeats it. */
.diff { border: 1px solid var(--line); border-radius: var(--r-2); background: var(--surface-2); overflow-x: auto; font: 400 var(--fs-2)/1.55 var(--font-mono); max-height: 22rem; overflow-y: auto; }
.diff-line { display: flex; min-width: max-content; padding: 0 var(--sp-4); white-space: pre; }
.diff-line > code { background: none; padding: 0; font: inherit; }
.diff-sign { flex: none; width: 1.5em; color: var(--ink-3); user-select: none; }
.diff-line.is-add { background: var(--win-bg); } .diff-line.is-add > .diff-sign { color: var(--win); font-weight: 600; }
.diff-line.is-del { background: var(--fail-bg); } .diff-line.is-del > .diff-sign { color: var(--fail); font-weight: 600; }
.diff-line.is-del > code { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--fail) 45%, transparent); }
.diff-gap { padding: 0 var(--sp-4); color: var(--ink-3); line-height: 1.2; }

/* Fixes as one comparison: a heading row, then one row per fix that opens to its evidence. */
.fix-head, .fix > summary { display: grid; grid-template-columns: minmax(0, 1fr) 8.25rem 8.5rem 8.5rem 4.5rem 5.5rem; gap: var(--sp-4); align-items: center; padding: var(--sp-3) var(--sp-5); min-width: 0; }
.fix-head { background: var(--surface-2); border-bottom: 1px solid var(--line); color: var(--ink-3); font-size: var(--fs-1); font-weight: 500; }
.fix-head > span:nth-child(n+3), .fix-num { text-align: right; white-space: nowrap; }
.fix + .fix { border-top: 1px solid var(--line); }
.fix > summary { cursor: pointer; list-style: none; }
.fix > summary::-webkit-details-marker { display: none; }
.fix > summary:hover { background: var(--surface-2); }
.fix[open] > summary { background: var(--surface-2); border-bottom: 1px solid var(--line); }
.fix-name { display: grid; min-width: 0; }
.fix-name > .clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fix-name > .strong::before { content: ""; display: inline-block; margin-right: var(--sp-3); border-left: 5px solid var(--ink-3); border-top: 4px solid transparent; border-bottom: 4px solid transparent; transition: transform .12s; }
.fix[open] .fix-name > .strong::before { transform: rotate(90deg); }
.fix-body { padding: var(--sp-5); }
.gain-pct.is-win { color: var(--win); } .gain-pct.is-worse { color: var(--fail); }
.fixes { min-width: 0; }
.fixes.is-detail .fix > summary { grid-template-columns: minmax(0, 1fr) auto; }
.fix-body { min-width: 0; overflow-wrap: anywhere; }
.fix-body .tbl-wrap { max-width: 100%; }
/* Below 1240 the page's side column takes the room the time and storage columns had: both stay in the open fix's chips. */
@media (max-width: 1239.98px) {
  .fix-head, .fix > summary { grid-template-columns: minmax(0, 1fr) auto 7.5rem 7.5rem; }
  .fix-extra { display: none; }
}
@media (max-width: 767.98px) {
  .fix-head { display: none; }
  .fix > summary { grid-template-columns: minmax(0, 1fr) auto; }
  .fix > summary > .fix-num { display: none; }
}

/* Overview pieces. */
.stat.is-wide { grid-column: span 2; }
@media (max-width: 767.98px) { .stat.is-wide { grid-column: auto; } }
.trend { height: 34px; }
.trend > svg { display: block; width: 100%; height: 100%; overflow: visible; }
.trend-line { fill: none; stroke-width: 1.5; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.trend-line.is-findings { stroke: var(--ink-3); stroke-dasharray: 3 2; }
.trend-line.is-verified { stroke: var(--win); }
.trend-key { display: inline-block; width: 14px; height: 0; border-top: 2px solid var(--win); }
.trend-key.is-findings { border-top: 2px dashed var(--ink-3); }
.legend { display: grid; gap: 1px; }
.legend > li > a { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--sp-4); padding: var(--sp-2) 0; color: var(--ink); }
.legend > li > a:hover { text-decoration: none; color: var(--accent); }
.legend b { font: 600 var(--fs-2)/1 var(--font-mono); }
.split-part.is-no_change, .split-key.is-no_change { background: var(--line-strong); }
.rows.is-two > a { display: grid; gap: 1px; }
.rows-main { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.rows.is-two .rows-sub { flex: none; }
.grow-panel { flex: 1 1 auto; }
.stack.span-4 { align-content: start; grid-auto-rows: auto; }
.run-line > a { font-weight: 500; }
.more-rows { padding: var(--sp-2) var(--sp-5); }
.more-rows > table { margin: 0 calc(-1 * var(--sp-5)); width: calc(100% + 2 * var(--sp-5)); }

/* Queries: what the inventory holds, above the rows. */
.summary { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-7); padding: var(--sp-3) var(--sp-5); border-bottom: 1px solid var(--line); }
.summary-group { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-1) var(--sp-4); min-width: 0; }
.summary-group > .label { margin: 0; }
.count-link.is-on { color: var(--accent); font-weight: 600; }
/* A statement kind is a word, not a chip; a write is marked with a dot. */
.stmt { font: 500 var(--fs-2)/1 var(--font-mono); color: var(--ink-2); }
.stmt.is-write::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: var(--sp-3); border-radius: 50%; background: var(--write); vertical-align: 1px; }

/* Measured production load: facts in one line, a share bar in lists, a second funnel. */
.load-facts { font-size: var(--fs-3); color: var(--ink-2); }
.load-facts > b { font: 600 var(--fs-3)/1.2 var(--font-mono); color: var(--ink); }
.load-sep { margin: 0 var(--sp-3); color: var(--line-strong); }
.load-facts.is-located { color: var(--ink-3); font-size: var(--fs-2); }
.bar.is-load > span { background: var(--accent); }
.measured { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: var(--sp-2) var(--sp-6); padding: var(--sp-4) var(--sp-5); border-left: 3px solid var(--accent); }
.measured-share { font: 500 var(--fs-7)/1 var(--font-mono); letter-spacing: -.02em; }
.measured-what { display: grid; gap: var(--sp-1); min-width: 0; }
.measured .label { margin: 0; }
.source-note { color: var(--ink-3); font-size: var(--fs-1); }
.funnel.is-load .funnel-step .bar > span { background: var(--accent); }
.funnel.is-load .funnel-step.is-verified .bar > span { background: var(--win); }
.match-rate { display: grid; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--line); }
.match-rate > .label { margin: 0; }
.split-part.is-matched, .split-key.is-matched { background: var(--accent); }
.split-part.is-likely, .split-key.is-likely { background: var(--ink-3); background-image: repeating-linear-gradient(135deg, transparent 0 3px, rgba(255, 255, 255, .45) 3px 5px); }
.split-part.is-unmatched, .split-key.is-unmatched { background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line-strong); }
.match-legend { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-7); font-size: var(--fs-2); }
.match-legend > li { display: flex; align-items: center; gap: var(--sp-3); }
.match-legend b { font: 600 var(--fs-2)/1 var(--font-mono); }
@media (max-width: 767.98px) { .measured { grid-template-columns: minmax(0, 1fr); } }

/* One index: its name and qualifiers, then its columns as boxes in index order. */
.ixrow { display: grid; grid-template-columns: minmax(0, 15rem) minmax(0, 1fr); gap: var(--sp-2) var(--sp-5); align-items: center; padding: var(--sp-2) 0; }
.ixrow + .ixrow { border-top: 1px dashed var(--line); }
.ixrow-name { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); min-width: 0; font-size: var(--fs-2); }
.ixrow-name > .mono { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ixrow-cols { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); min-width: 0; }
.ixrow.is-new { padding: var(--sp-3) var(--sp-4); border: 1px solid var(--accent); border-radius: var(--r-2); background: var(--accent-bg); }
.keybox.is-include { padding-left: var(--sp-4); border-style: dotted; color: var(--ink-2); }
@media (max-width: 767.98px) { .ixrow { grid-template-columns: minmax(0, 1fr); } }

/* Two engines, two funnels: a heading row before each. */
.funnel-engine { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3) var(--sp-4); padding: var(--sp-3) var(--sp-5); background: var(--surface-2); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.panel-head + .funnel-engine { border-top: 0; }
/* A split bar: parts of one whole, each with its own fill and pattern, named by the chips under it. */
.split { display: flex; gap: 2px; height: 10px; border-radius: 2px; overflow: hidden; }
.split-part { min-width: 3px; flex-basis: 0; }
.split-part.is-verified, .split-key.is-verified { background: var(--win); }
.split-part.is-unverified, .split-key.is-unverified { background: var(--ink-3); opacity: .55; }
.split-part.is-rejected, .split-key.is-rejected { background: var(--warn); }
.split-part.is-failed, .split-key.is-failed { background: var(--fail); background-image: repeating-linear-gradient(135deg, transparent 0 3px, rgba(255, 255, 255, .4) 3px 5px); }
.split-key { display: inline-block; width: 8px; height: 8px; border-radius: 2px; }

/* --- 12. Map: lives in map.css, loaded by the map templates only ---------------- */

/* --- 13. Utilities ------------------------------------------------------------- */

.mono { font-family: var(--font-mono); }
.muted { color: var(--ink-3); }
.small { font-size: var(--fs-2); }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.break { overflow-wrap: anywhere; }
.end { margin-left: auto; }
.right { text-align: right; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); min-width: 0; }
.mt-1 { margin-top: var(--sp-2); } .mt-2 { margin-top: var(--sp-4); } .mt-3 { margin-top: var(--sp-5); }
.mb-1 { margin-bottom: var(--sp-2); } .mb-2 { margin-bottom: var(--sp-4); } .mb-3 { margin-bottom: var(--sp-5); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.grow { flex: 1 1 0; min-width: 0; }
.is-block { width: 100%; }

.cell-bar { flex: 1 1 auto; min-width: 2rem; }
.gain.is-wide > .gain-abs { overflow: visible; }
.funnel.is-load .funnel-rate { flex-wrap: wrap; row-gap: 0; }
/* A column that gives way first when the window is narrow. */
@media (max-width: 1239.98px) { .hide-lt-xl { display: none; } col.hide-lt-xl { visibility: collapse; width: 0 !important; } }
/* The second line of a load cell: two short facts that never cut each other off. */
.tbl.is-list td > .load-l2 { gap: var(--sp-4); }
.tbl.is-list td > .load-l2 > span { flex: none; }

/* Runs that went silent (liveness.py): a stage the CLI stopped in, and the stalled count in a page header. */
.rail > i.is-stopped { background: var(--warn-bg); box-shadow: inset 0 0 0 1.5px var(--warn); }
.stage.is-stopped { border-color: var(--warn); }
.stage.is-stopped { border-top-style: dashed; }
.stages.is-vertical > .stage.is-stopped { border-left-style: dashed; }
.count-link.is-warn, a.count-link.is-warn > b { color: var(--warn); }
.count-link.is-warn { display: inline-flex; align-items: center; gap: var(--sp-2); font-weight: 600; }
#run-status { display: contents; }

/* Inventory-only runs: a stage or funnel step that was never asked for. Dashed like "not reported", and it says "not run". */
.rail > i.is-notrun { box-shadow: none; border-bottom: 1px dashed var(--line-strong); height: 4px; }
.stage.is-notrun .stage-name { color: var(--ink-3); }
.stage.is-notrun { border-top-style: dashed; }
.stages.is-vertical > .stage.is-notrun { border-left-style: dashed; }
@media (max-width: 899.98px) { .stage.is-notrun { border-left-style: dashed; } }
.funnel-step.is-notrun { background: repeating-linear-gradient(135deg, transparent 0 6px, var(--surface-2) 6px 12px); }
.funnel-step.is-notrun .funnel-n, .funnel-step.is-notrun .funnel-label, .funnel-step.is-notrun .funnel-rate { color: var(--ink-3); }
.tbl td.is-notrun { color: var(--ink-3); font-size: var(--fs-2); background: repeating-linear-gradient(135deg, transparent 0 6px, var(--surface-2) 6px 12px); }
/* Coverage facts under a funnel or in a list header: counts with their exclusions, ORM calls not read. */
.orm-gap { color: var(--ink-2); font-size: var(--fs-2); }
.orm-gap b { font: 600 var(--fs-2)/1 var(--font-mono); color: var(--ink); }
.reconcile { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-2) var(--sp-4); padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--line); color: var(--ink-2); font-size: var(--fs-2); }
.reconcile > .label { margin: 0; }
.reconcile .count-link + .count-link::before, .reconcile .count-link + .orm-gap::before { content: "·"; margin-right: var(--sp-4); color: var(--line-strong); }
.list-head .reconcile { border: 0; padding: 0; }
.engines { color: var(--ink-2); }

/* Settings: shared databases. */
.sharedb-set { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3) var(--sp-5); padding: var(--sp-3) 0; border-top: 1px solid var(--line); }
.sharedb-set:first-of-type { border-top: 0; }
.sharedb-projects { display: inline-flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); }
.sharedb-why { color: var(--ink-2); font-size: var(--fs-2); }
.sharedb-sample { display: inline-flex; flex-wrap: wrap; gap: var(--sp-2); }
.sharedb-wrap { max-height: 26rem; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-2); }
.sharedb-table .input { width: min(100%, 18rem); }
.sharedb-rule { align-items: center; flex-wrap: wrap; gap: var(--sp-3); }
.sharedb-min { width: 4.5rem; }

.funnel-step.is-notrun .bar { visibility: hidden; }
.stat-sub.is-parts { column-gap: var(--sp-5); }
