/* Carry Desk: dark charcoal surfaces, off-white tabular numerals and gray labels.
   Runs and Overview use monochrome state markers; detailed views retain their diagnostic series colours. */
:root {
  color-scheme: dark;
  --bg: #101010;           /* page ground, top bar */
  --surface: #161616;      /* tables, panels, plots, the drawer */
  --surface-2: #1e1e1e;    /* rail, table header, selected row */
  --line: #292929;         /* hairlines, gridlines, row rules, band fills */
  --line-2: #484848;       /* chart baseline and zero line, quiet tag border, selected control */
  --border: #484848;       /* borders of controls */
  --text: #ededed;         /* primary text and numerals */
  --text-2: #bdbdbd;       /* secondary text */
  --text-3: #a0a0a0;       /* labels, captions, axis text, units */
  /* state: the only saturated colours on the page */
  --ok: #3f9d6e;           /* nominal dot */
  --warn: #e0a12b;         /* stale feed, degraded, warning */
  --err: #ff4d4f;          /* halted, unhedged, error */
  --ok-bg: #12241c; --ok-border: #24523c; --ok-ink: #86cfa8;
  --warn-bg: #2a2110; --warn-ink: #f0bb58;
  --err-bg: #2c1416; --err-border: #6b2528; --err-ink: #ff8a8c;
  /* marks: venues and series, desaturated so they never read as a state */
  --hl: #7f9fc4;           /* Hyperliquid */
  --bn: #b9a36a;           /* Binance */
  --bybit: #b98d6f;        /* Bybit */
  --aster: #9a8fc9;        /* Aster */
  --lighter: #6fa3ad;      /* Lighter */
  --gain: #6f9c8a;         /* series: money received */
  --loss: #b0787c;         /* series: money paid */
  --forecast: #b58aa6;     /* series: the forecast */
  --forecast-bg: #2a1f27;  /* ribbon: waiting on funding */
  --forecast-line: #6d5063;
  --basis: #6b7482;        /* neutral series: basis, cancelled, the rest of a scatter */
  --tip-bg: #1d222b; --tip-text: #e6e9ef;
  --div-hl-1: #1d2a3a; --div-hl-2: #2f4a6b; --div-hl-3: #5b86bd;
  --div-mid: #171b22; --div-mid-line: #2a303a;
  --div-bn-1: #2e2819; --div-bn-2: #5a4c26; --div-bn-3: #a68c45;
  --font: system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, "Liberation Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "DejaVu Sans Mono", "Liberation Mono", monospace;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;
  --rail: 176px;
  --bar: 44px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}
* { box-sizing: border-box; }
html { font-size: 14px; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 1rem; line-height: 20px; font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased; scrollbar-color: var(--line-2) transparent;
}
* { scrollbar-color: var(--line-2) transparent; }
::selection { background: var(--line-2); color: var(--text); }
::placeholder { color: var(--text-3); opacity: 1; }
input, select { caret-color: var(--text); }
:focus-visible { outline: 2px solid var(--text-2); outline-offset: 2px; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--text-2); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 20px; line-height: 26px; font-weight: 600; text-wrap: balance; }
h2 { font-size: 16px; line-height: 22px; font-weight: 600; margin: 28px 0 10px; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
h2 small, h3 small { font-size: 12px; line-height: 16px; font-weight: 400; color: var(--text-3); font-variant-numeric: tabular-nums; }
h3 small { margin-left: 10px; }
h3 { font-size: 14px; line-height: 20px; font-weight: 600; margin: 16px 0 6px; }
code, .mono { font-family: var(--mono); font-size: 0.92em; font-variant-numeric: tabular-nums; }
small, .small { font-size: 12px; line-height: 16px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--text); color: var(--surface); padding: 6px 10px; z-index: 20; }
.skip:focus { left: 8px; top: 8px; }
.skip:hover { color: var(--surface); }

/* ---- rail */
.rail {
  position: fixed; inset: 0 auto 0 0; width: var(--rail); background: var(--surface-2); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; overflow-y: auto;
}
.mark { display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: center; padding: 14px 12px 16px; }
.mark svg { flex: none; }
.mark strong { font-size: 16px; line-height: 24px; font-weight: 600; }
.mark span { flex-basis: 100%; font-size: 12px; line-height: 16px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#nav { display: flex; flex-direction: column; min-height: 44px; }
#nav a {
  display: flex; align-items: center; height: 36px; padding: 0 12px; text-decoration: none; font-size: 14px;
  transition: background-color 160ms ease-out;
}
#nav a:hover { background: var(--line); color: var(--text); }
#nav a { color: var(--text-2); }
#nav a[aria-current="page"] { background: var(--bg); color: var(--text); font-weight: 600; box-shadow: inset 2px 0 0 var(--text-2); }
.rail-foot { margin-top: auto; padding: 12px; font-size: 12px; line-height: 16px; color: var(--text-3); display: grid; gap: 8px; }
.rail-foot .clock { font-size: 13px; line-height: 18px; color: var(--text); font-variant-numeric: tabular-nums; }
.rail-foot .clock span { display: block; color: var(--text-3); font-size: 12px; line-height: 16px; }

/* ---- page */
.page { margin-left: var(--rail); min-height: 100vh; }
.bar {
  position: sticky; top: 0; z-index: 5; display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  padding: 6px 24px; background: var(--bg); border-bottom: 1px solid var(--line); min-height: var(--bar);
}
.bar label { color: var(--text-2); }
.bar .spacer { flex: 1; }
.bar .runname { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.bar select#run { max-width: 100%; }
.bar .fresh { color: var(--text-3); font-size: 13px; font-variant-numeric: tabular-nums; }
main { padding: 20px 24px 64px; max-width: 1680px; }
main:focus { outline: none; }

select, button, input { font: inherit; color: inherit; }
select, .btn, input[type="search"], input[type="number"], input[type="datetime-local"] {
  background: var(--surface); border: 1px solid var(--border); border-radius: 4px; padding: 4px 8px; min-height: 28px;
  transition: background-color 160ms ease-out;
}
input[type="search"]::placeholder { color: var(--text-3); opacity: 1; }
select:hover, .btn:hover { background: var(--surface-2); }
.btn { cursor: pointer; }
.btn.quiet { border-color: var(--line-2); font-size: 12px; line-height: 16px; min-height: 22px; padding: 2px 8px; }
.btn[aria-pressed="true"] { background: var(--line-2); color: var(--text); border-color: var(--text-3); }
.btn:disabled { color: var(--text-3); border-color: var(--line-2); cursor: default; background: var(--bg); }
.seg { display: inline-flex; }
.seg .btn { border-radius: 0; margin-left: -1px; }
.seg .btn:first-child { margin-left: 0; border-radius: 4px 0 0 4px; }
.seg .btn:last-child { border-radius: 0 4px 4px 0; }
input[type="range"] { accent-color: var(--text-2); width: 220px; vertical-align: middle; }
.controls { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin: 8px 0 12px; }
.controls label { color: var(--text-2); }
.controls .field { display: inline-flex; gap: 10px; align-items: center; white-space: nowrap; }

/* ---- grid */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 20px; align-items: start; }
.grid + .grid, .grid + .sec, .sec + .grid { margin-top: 24px; }
.grid.even { align-items: stretch; }
.grid.even > div > .panel { height: 100%; }
.c-12 { grid-column: span 12; } .c-8 { grid-column: span 8; } .c-7 { grid-column: span 7; } .c-6 { grid-column: span 6; }
.c-5 { grid-column: span 5; } .c-4 { grid-column: span 4; } .c-3 { grid-column: span 3; }
@media (max-width: 1439px) {
  .m-12 { grid-column: span 12; } .m-8 { grid-column: span 8; } .m-7 { grid-column: span 7; } .m-6 { grid-column: span 6; } .m-5 { grid-column: span 5; } .m-4 { grid-column: span 4; }
  .tbl .wide { display: none; }
}
@media (max-width: 1179px) { .grid > * { grid-column: 1 / -1; } }
.sec { margin-top: 24px; }
.sec > h2:first-child { margin-top: 0; }
h2 .btn { font-weight: 400; font-size: 13px; }

/* ---- surfaces */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 16px; }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.panel .chart + .chart { margin-top: 0; }

/* ---- tags: a state is always a word; a monochrome outline, and a dot only when the word is a state */
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 0 8px; border: 1px solid var(--line-2); border-radius: 4px; font-size: 12px; line-height: 18px; color: var(--text-2); white-space: nowrap; font-weight: 400; vertical-align: 1px; }
.tag.ok::before, .tag.warn::before, .tag.danger::before { content: ""; width: 6px; height: 6px; border-radius: 50%; flex: none; }
.tag.ok::before { background: var(--ok); }
.tag.warn { color: var(--warn-ink); }
.tag.warn::before { background: var(--warn); }
.tag.danger { color: var(--err-ink); border-color: var(--err-border); }
.tag.danger::before { background: var(--err); }
.tag.quiet { color: var(--text-3); }
.tags { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.synthetic { background: var(--warn-bg); border: 1px solid var(--line-2); border-radius: 4px; color: var(--warn-ink); padding: 8px 12px; margin: 12px 0 0; max-width: 110ch; font-size: 13px; line-height: 18px; }
.dot-held { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--text); margin-right: 6px; vertical-align: 1px; flex: none; }

/* ---- sentences and figures */
.lede { max-width: 110ch; margin-top: 4px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.lede strong { color: var(--text); font-weight: 600; }
.figures {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin: 16px 0 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: 4px;
}
.figure { padding: 12px 14px; min-height: 98px; border-left: 1px solid var(--line); min-width: 0; }
.figure:first-child { border-left: 0; }
.figure dt { color: var(--text-2); font-size: 12px; line-height: 16px; font-weight: 500; }
.figure dd {
  margin: 4px 0 0; font-family: var(--mono); font-size: 20px; line-height: 26px; font-weight: 600; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.figure.lead dd { font-size: 26px; line-height: 32px; letter-spacing: -0.025em; }
.figure dd .unit { font-size: 14px; font-weight: 600; color: var(--text-2); letter-spacing: 0; }
.figure .sub { margin-top: 3px; font-size: 12px; line-height: 16px; color: var(--text-3); font-weight: 400; letter-spacing: 0; font-variant-numeric: tabular-nums; }
/* a sign is not a state: negative and positive numbers stay the text colour; only a named anomaly is coloured */
strong.neg { color: var(--err-ink); }
dl { margin: 0; }

@media (max-width: 1279px) and (min-width: 861px) {
  .figures { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .figure:first-child { grid-column: span 2; }
  .figure:nth-child(3) { border-left: 0; }
  .figure:nth-child(n + 3) { border-top: 1px solid var(--line); }
}

/* ---- charts */
.chart { margin: 0; position: relative; }
.chart + .chart { margin-top: 12px; }
.chart figcaption { display: flex; justify-content: space-between; align-items: baseline; gap: 4px 14px; flex-wrap: wrap; padding: 0 0 6px; min-height: 22px; }
.chart-title { font-weight: 600; }
.chart-title .unit, .unit { font-weight: 400; color: var(--text-3); font-size: 12px; }
.chart-actions { margin-left: auto; display: inline-flex; gap: 6px; align-items: center; }
.legend { display: flex; gap: 4px 14px; flex-wrap: wrap; color: var(--text-2); font-size: 12px; line-height: 16px; }
.legend-item { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.legend-value { color: var(--text); font-variant-numeric: tabular-nums; min-width: 1ch; }
.swatch { width: 14px; height: 10px; flex: none; }
.plot { position: relative; width: 100%; background: var(--surface); }
.plot canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.plot canvas.over { cursor: crosshair; touch-action: pan-y; }
.chart-note, .note { color: var(--text-3); font-size: 13px; line-height: 18px; max-width: 110ch; margin-top: 4px; font-variant-numeric: tabular-nums; }
.chart .scroll { margin-top: 8px; max-height: 240px; }
.chart.compact figcaption { padding: 0 0 2px; min-height: 0; font-size: 12px; line-height: 16px; }
.tip {
  position: fixed; z-index: 30; pointer-events: none; background: var(--tip-bg); color: var(--tip-text); padding: 8px 10px; border-radius: 4px;
  font-size: 13px; line-height: 18px; max-width: 360px; border: 1px solid var(--line-2);
}
.tip[hidden] { display: none; }
.tip-head { font-weight: 600; margin-bottom: 2px; }
.tip-row { display: flex; align-items: center; gap: 8px; }
.tip-row i { width: 10px; height: 2px; flex: none; display: inline-block; }
.tip-row b { font-weight: 600; font-variant-numeric: tabular-nums; }
.hint-zoom { color: var(--text-3); font-size: 12px; }
/* ---- tables */
.scroll { overflow: auto; max-width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; }
.scroll.tall { max-height: 520px; }
.tbl { border-collapse: separate; border-spacing: 0; width: 100%; background: var(--surface); font-size: 13px; line-height: 18px; font-variant-numeric: tabular-nums; }
.tbl caption { text-align: left; color: var(--text-3); padding: 6px 10px 8px; caption-side: bottom; font-size: 12px; line-height: 16px; position: sticky; left: 0; width: min(100%, 110ch, calc(100vw - var(--rail) - 56px)); box-sizing: border-box; white-space: normal; }
.tbl th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); text-align: left; font-size: 12px; line-height: 16px; font-weight: 600; color: var(--text-2); padding: 0; height: 30px; border-bottom: 1px solid var(--line-2); white-space: normal; vertical-align: bottom; }
.tbl th > .sort, .tbl th:not(:has(.sort)) { padding: 6px 10px; }
.tbl th .sort { all: unset; cursor: pointer; display: block; padding: 6px 10px; width: 100%; box-sizing: border-box; }
.tbl th .sort:hover { background: var(--line); }
.tbl th .sort:focus-visible { outline: 2px solid var(--text-2); outline-offset: -2px; }
.tbl th.num, .tbl td.num { text-align: right; }
.tbl td.num, .kv dd, .legend-value, .stats { font-family: var(--mono); font-size: 0.94em; }
.tbl th[aria-sort] .dir { display: inline-block; margin-left: 5px; border: 4px solid transparent; }
.tbl th[aria-sort="ascending"] .dir { border-bottom-color: var(--text); transform: translateY(-2px); }
.tbl th[aria-sort="descending"] .dir { border-top-color: var(--text); transform: translateY(3px); }
.tbl td { padding: 4px 10px; height: 28px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; transition: background-color 160ms ease-out; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.wrap { white-space: normal; min-width: 22ch; max-width: 60ch; }
.tbl tr.pick { cursor: pointer; }
.tbl tr.pick:hover td { background: var(--surface-2); }
.tbl tr.pick:focus-visible { outline: 2px solid var(--text-2); outline-offset: -2px; }
.tbl tr.heldrow td:first-child { font-weight: 600; }
.tbl tr.on td { background: var(--surface-2); box-shadow: inset 0 1px 0 var(--line-2), inset 0 -1px 0 var(--line-2); }
.tbl tr.on td:first-child { font-weight: 600; }
/* a declined row is marked by one amber dot in its first cell, not by a wash over the whole row */
.tbl tr.declined td:first-child::before { content: ""; position: absolute; left: 2px; top: 50%; width: 5px; height: 5px; margin-top: -3px; border-radius: 50%; background: var(--warn); }
.tbl tr.order td { background: var(--surface-2); }
.tbl tr.more td { color: var(--text-3); }
.tbl td.coin, .tbl th.coin, .tbl td.sticky, .tbl th.sticky { position: sticky; left: 0; }
.tbl td.coin, .tbl td.sticky { background: var(--surface); z-index: 1; }
.tbl th.coin, .tbl th.sticky { z-index: 3; }
.tbl tr.pick:hover td.coin, .tbl tr.pick:hover td.sticky { background: var(--surface-2); }
.tbl tr.on td.sticky, .tbl tr.on td.coin { background: var(--surface-2); }
.tbl td.num.strong { font-weight: 600; }
.tbl.tight th > .sort, .tbl.tight th:not(:has(.sort)), .tbl.tight td { padding-left: 8px; padding-right: 8px; }
.tbl.tight td.wrap { min-width: 12ch; }
.tbl td.narrow { white-space: normal; max-width: 18ch; min-width: 8ch; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 3px 16px; margin: 0; font-size: 13px; line-height: 18px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.stats { font-variant-numeric: tabular-nums; }

.nodata { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 12px 16px; color: var(--text-2); max-width: 110ch; }
.nodata .hint { color: var(--text-3); }
.skeleton { min-height: 240px; }
.error { border: 1px solid var(--err-border); background: var(--err-bg); color: var(--err-ink); border-radius: 4px; padding: 12px 16px; max-width: 110ch; }

.cols { display: grid; gap: 0 24px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1179px) { .cols { grid-template-columns: minmax(0, 1fr); } }
.head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }

.panel-title { font-size: 16px; line-height: 22px; font-weight: 600; margin: 0 0 10px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.panel-title small { font-size: 12px; line-height: 16px; font-weight: 400; color: var(--text-3); font-variant-numeric: tabular-nums; }
/* ---- the leg bar: the pair as its two legs meeting at a centre line */
.legbar { display: inline-block; vertical-align: middle; margin-right: 6px; }

/* ---- coin retrace: shared time axis and the inspector */
.retrace { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 24px; align-items: start; margin-top: 12px; }
@media (max-width: 1179px) { .retrace { grid-template-columns: minmax(0, 1fr); } }
.inspector { position: sticky; top: calc(var(--bar) + 12px); background: var(--surface); border: 1px solid var(--line); border-radius: 4px; max-height: calc(100vh - var(--bar) - 24px); overflow: auto; }
.inspector header { background: var(--surface-2); color: var(--text); border-bottom: 1px solid var(--line-2); padding: 8px 12px; display: flex; justify-content: space-between; gap: 10px; align-items: baseline; border-radius: 3px 3px 0 0; font-variant-numeric: tabular-nums; }
.inspector header strong { font-size: 14px; }
.inspector section { padding: 12px; border-bottom: 1px solid var(--line); }
.inspector section:last-child { border-bottom: 0; }
.inspector h3 { margin: 0 0 6px; }
.inspector .why { font-size: 14px; line-height: 20px; }
.inspector .why p + p { margin-top: 6px; }
.inspector .steps { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.inspector .tbl td, .inspector .tbl th .sort, .inspector .tbl th { padding-left: 6px; padding-right: 6px; }
.pair-picker { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.pair-picker input[type="search"] { width: 220px; max-width: 100%; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 0; }
.chips-label { margin-top: 10px; color: var(--text-3); font-size: 12px; line-height: 16px; }
.chip {
  all: unset; cursor: pointer; padding: 3px 10px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface);
  display: inline-flex; gap: 6px; align-items: baseline; font-variant-numeric: tabular-nums; transition: background-color 160ms ease-out;
}
.chip:hover { background: var(--surface-2); }
.chip:focus-visible { outline: 2px solid var(--text-2); outline-offset: 2px; }
.chip[aria-pressed="true"] { background: var(--line-2); border-color: var(--text-3); color: var(--text); }
.chip small { color: var(--text-2); font-size: 12px; }
.chip[aria-pressed="true"] small { color: var(--text-2); }
.key { display: flex; gap: 4px 16px; flex-wrap: wrap; color: var(--text-2); font-size: 12px; line-height: 16px; margin: 8px 0 0; align-items: center; }
.key > span { display: inline-flex; gap: 5px; align-items: center; white-space: nowrap; }
.key i { width: 14px; height: 10px; display: inline-block; border: 1px solid var(--line-2); border-radius: 2px; }

/* ---- bar list: categories whose names are phrases, one row each (name, bar, count) */
.barlist { display: grid; grid-template-columns: max-content minmax(40px, 1fr) max-content; gap: 8px 12px; align-items: center; align-content: start; min-height: 160px; font-size: 13px; line-height: 18px; }
.barlist .barrow { display: contents; }
.barlist .track { height: 12px; }
.barlist .fill { display: block; height: 100%; min-width: 2px; background: var(--text-2); border-radius: 0 4px 4px 0; }
.barlist .count { text-align: right; font-variant-numeric: tabular-nums; }
.barlist .note { grid-column: 1 / -1; }

/* ---- small multiples */
.multiples { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px 24px; }
.multiple { all: unset; display: block; cursor: pointer; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 8px 10px 6px; }
.multiple:focus-visible { outline: 2px solid var(--text-2); outline-offset: 2px; }
.multiple:hover { background: var(--surface-2); }
.multiple header { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; padding: 0 0 2px; font-size: 12px; line-height: 16px; font-variant-numeric: tabular-nums; }
.multiple header strong { font-size: 14px; line-height: 20px; }
.multiple header span { color: var(--text-2); white-space: nowrap; }
.multiple .split { font-size: 12px; line-height: 16px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.multiple.on { border-color: var(--text-3); }
.multiple .plot canvas.over { cursor: pointer; }
.multiple .plot { background: transparent; }
.detail { border: 1px solid var(--line); border-radius: 4px; background: var(--surface); padding: 16px; margin: 12px 0; }
.detail .head { justify-content: space-between; }
.detail h2 { margin: 0; }

/* ---- state dot: the one place saturated colour lives */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; vertical-align: 0; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--err); }
.dot.idle { box-shadow: inset 0 0 0 1px var(--line-2); }
.st-bad { color: var(--err-ink); }
.st-warn { color: var(--warn-ink); }
/* an identity: a state dot or a name, then its small qualifier */
.id { display: inline-flex; align-items: baseline; gap: 8px; }
.id .dot { align-self: center; }
.id strong { font-weight: 600; }
.id small { color: var(--text-3); font-size: 11px; line-height: 16px; letter-spacing: 0.02em; }
.id a { text-decoration: none; }
.id a:hover { text-decoration: underline; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.kv-block { margin: 0 0 12px; }

/* ---- tier 1: the strip, four numbers and no more */
.strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 12px 0 0; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; }
.kpi { padding: 12px 16px 12px; border-left: 1px solid var(--line); min-width: 0; min-height: 104px; }
.kpi:first-child { border-left: 0; }
.kpi dt { display: flex; align-items: center; gap: 8px; color: var(--text-3); font-size: 12px; line-height: 16px; font-weight: 500; }
.kpi dd { margin: 6px 0 2px; font-family: var(--mono); font-size: 24px; line-height: 30px; font-weight: 600; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi dd .unit { font-family: var(--font); font-size: 13px; font-weight: 400; color: var(--text-3); letter-spacing: 0; }
.kpi .sub { font-size: 12px; line-height: 17px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .sub.st-bad { color: var(--err-ink); }
.kpi .sub.st-warn { color: var(--warn-ink); }
@media (max-width: 1179px) {
  .strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(3) { border-left: 0; }
  .kpi:nth-child(n + 3) { border-top: 1px solid var(--line); }
}
@media (max-width: 560px) {
  .strip { grid-template-columns: minmax(0, 1fr); }
  .kpi { border-left: 0; min-height: 0; }
  .kpi + .kpi { border-top: 1px solid var(--line); }
}

/* ---- run-level anomalies: present only when something is wrong */
.notices { list-style: none; margin: 12px 0 0; padding: 8px 12px; border: 1px solid var(--line-2); border-radius: 4px; background: var(--surface); font-size: 13px; line-height: 18px; display: grid; gap: 4px; }
.notices li { display: grid; grid-template-columns: 8px minmax(0, 1fr); gap: 10px; align-items: baseline; }

/* ---- tier 2: the matrix, one 28 px row per pair or run, worst first */
.matrix-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 24px 0 8px; }
.matrix-head h2 { margin: 0; }
.matrix-head .btn { margin-left: auto; }
.matrix td { height: 28px; padding-top: 2px; padding-bottom: 2px; }
.matrix th:first-child, .matrix td:first-child { width: 28px; padding-right: 0; text-align: center; }
.matrix th:first-child .sort { padding-right: 0; }
.matrix td.state { white-space: normal; min-width: 18ch; max-width: 84ch; color: var(--text-2); }
.matrix th { white-space: nowrap; }
/* The two overview screens encode severity by marker shape and text, not hue. */
.view-overview, .view-runs {
  --ok: #a0a0a0; --warn: #bdbdbd; --err: #ededed;
  --warn-bg: #1e1e1e; --warn-ink: #bdbdbd;
  --err-bg: #1e1e1e; --err-border: #777777; --err-ink: #ededed;
}
:is(.view-overview, .view-runs) .dot.bad { border-radius: 1px; }
:is(.view-overview, .view-runs) .dot.warn { border-radius: 0; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
:is(.view-overview, .view-runs) .st-bad { font-weight: 600; }
:is(.view-overview, .view-runs) .st-warn { text-decoration: underline dotted; text-underline-offset: 3px; }

/* ---- tier 3: the slide-out drawer, drawn on demand for one row */
dialog.drawer {
  position: fixed; inset: 0 0 0 auto; margin: 0; padding: 0; width: min(820px, 100vw); max-width: none; height: 100dvh; max-height: none;
  border: 0; border-left: 1px solid var(--line-2); background: var(--surface); color: var(--text); overflow: hidden;
  transform: translateX(100%); transition: transform 220ms var(--ease), overlay 220ms allow-discrete, display 220ms allow-discrete;
}
dialog.drawer[open] { transform: none; display: flex; flex-direction: column; }
@starting-style { dialog.drawer[open] { transform: translateX(100%); } }
dialog.drawer::backdrop { background: rgba(0, 0, 0, 0.6); }
.drawer-head { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); flex: none; }
.drawer-title { min-width: 0; flex: 1; }
.drawer-title h2 { margin: 0; font-size: 18px; line-height: 24px; align-items: center; gap: 10px; }
.drawer-title h2 small { color: var(--text-3); }
.drawer-title p { margin-top: 2px; font-size: 13px; line-height: 18px; color: var(--text-2); overflow-wrap: anywhere; }
.drawer-close { all: unset; cursor: pointer; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 4px; color: var(--text-2); flex: none; }
.drawer-close:hover { background: var(--line); color: var(--text); }
.drawer-close:focus-visible { outline: 2px solid var(--text-2); outline-offset: 1px; }
.drawer-body { overflow: auto; flex: 1; padding: 4px 16px 32px; overscroll-behavior: contain; }
.drawer-body section { padding: 12px 0 14px; border-bottom: 1px solid var(--line); }
.drawer-body section:last-child { border-bottom: 0; }
.drawer-body h3 { margin: 0 0 8px; font-size: 12px; line-height: 16px; font-weight: 600; color: var(--text-3); display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.drawer-body h3 small { margin-left: 0; font-weight: 400; }
.drawer-body p { font-size: 13px; line-height: 19px; max-width: 72ch; }
.drawer-body p + p { margin-top: 6px; }
.drawer-body .why strong { font-weight: 600; }
.drawer-body .tbl td, .drawer-body .tbl th .sort, .drawer-body .tbl th:not(:has(.sort)) { padding-left: 8px; padding-right: 8px; }
.drawer-body .scroll + .kv, .drawer-body .kv + .scroll, .drawer-body .chart + .chart, .drawer-body p + .scroll, .drawer-body .scroll + p, .drawer-body .scroll + h3, .drawer-body p + h3 { margin-top: 10px; }
.drawer-body .tbl th { white-space: nowrap; }
.drawer-body .plot { background: transparent; }
.drawer-links { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; padding: 12px 0 0; }
@media (max-width: 860px) { dialog.drawer { width: 100vw; border-left: 0; } }

pre.log { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 10px 12px; overflow: auto; max-height: 420px; font-family: var(--mono); font-size: 12px; line-height: 18px; margin: 6px 0 0; }
details { margin-top: 12px; }
details > summary { cursor: pointer; color: var(--text-2); padding: 6px 0; font-size: 14px; }
details > summary:hover { color: var(--text); }
details[open] > summary { margin-bottom: 8px; color: var(--text); font-weight: 600; }

@media (max-width: 860px) {
  :root { --rail: 0px; }
  html { font-size: 15px; }
  .rail { position: static; width: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .mark { padding: 8px 12px; }
  .mark span { display: inline; flex-basis: auto; margin-left: auto; }
  #nav { flex-direction: row; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  #nav a { flex: 1 0 auto; justify-content: center; padding: 0 12px; min-height: 44px; }
  #nav a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--text-2); }
  .rail-foot { display: none; }
  .page { margin-left: 0; min-width: 0; }
  .bar { position: static; padding: 8px 12px; gap: 4px 10px; }
  .bar .spacer { display: none; }
  main { padding: 16px 12px 48px; }
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .figure { border-left: 1px solid var(--line); border-top: 1px solid var(--line); min-height: 0; }
  .figure:first-child { grid-column: 1 / -1; border-left: 0; border-top: 0; }
  .figure:nth-child(2n) { border-left: 0; }
  .tbl td { padding: 9px 7px; }
  .tbl th.num { white-space: normal; }
  .tbl th .sort, .tbl th:not(:has(.sort)) { padding: 9px 7px; }
  .tbl th .sort { min-height: 44px; display: flex; align-items: flex-end; }
  .controls:has(label) { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); align-items: center; }
  .controls:has(label) > :not(label):not(select):not(input) { grid-column: 1 / -1; }
  .controls:has(label) > span:empty { display: none; }
  .controls .field { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); }
  .chip { padding: 8px 12px; }
  details > summary { padding: 11px 0; }
  .btn, select, input[type="search"], input[type="datetime-local"] { min-height: 40px; }
  .inspector { position: static; max-height: none; }
  .controls { gap: 10px 12px; }
}
@media (max-width: 560px) {
  .figures { grid-template-columns: minmax(0, 1fr); }
  .figure { border-left: 0; border-top: 1px solid var(--line); }
  .figure:first-child { grid-column: auto; border-top: 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
