:root {
  color-scheme: light dark;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #1d2433;
  --muted: #637087;
  --line: #dfe3ea;
  --soft: #eef1f5;
  --accent: #3f6fd8;

  --ok: #2f9e6b;
  --warn: #c98a12;
  --bad: #d0453b;

  /* outcomes */
  --st-matched: #2f9e6b;
  --st-obstructed: #8a5cc7;
  --st-matching: #3f78e0;
  --st-awaiting: #2aa3b0;
  --st-too-big: #d9a13a;
  --st-dp-running: #8fb4f2;
  --st-dp-failed: #d0453b;
  --st-dp-cancelled: #7b8494;
  --st-unknown: #9aa3b2;

  /* tiles */
  --t-durable: #2f9e6b;
  --t-complete: #9ccc65;
  --t-running: #3f78e0;
  --t-paused: #9b7fd1;
  --t-queued: #41b8c4;
  --t-ready: #f1d36b;
  --t-blocked: #d4d9e1;
  --t-failed: #d0453b;
  --t-cancelled: #7b8494;
  --t-unscheduled: #eceff3;

  /* disk usage: tiles strong, other king_hamming a lighter tint of it, unrelated neutral, free the track */
  --disk-tiles: #2f62c9; --disk-other: #8fb0ee; --disk-unrelated: #b4bcc9; --disk-free: #eef1f5;

  /* per-work colours, shared by CPU squares and work rows */
  --w0: #3f78e0; --w1: #e07a3f; --w2: #2aa3b0; --w3: #a35bd6; --w4: #c9a227; --w5: #d64f8a;

  --radius: 10px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 8%);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1420;
    --panel: #171e2c;
    --ink: #e4e8f0;
    --muted: #93a0b8;
    --line: #2a3346;
    --soft: #1f2738;
    --accent: #7aa2ff;
    --st-dp-running: #4d6fae;
    --t-blocked: #39445a;
    --t-unscheduled: #222b3c;
    --t-ready: #c9ac3e;
    --t-complete: #7fae4a;
    --disk-tiles: #7aa2ff; --disk-other: #3d5a94; --disk-unrelated: #66718a; --disk-free: #1f2738;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1420; --panel: #171e2c; --ink: #e4e8f0; --muted: #93a0b8; --line: #2a3346;
  --soft: #1f2738; --accent: #7aa2ff; --st-dp-running: #4d6fae; --t-blocked: #39445a;
  --t-unscheduled: #222b3c; --t-ready: #c9ac3e; --t-complete: #7fae4a; --shadow: none;
  --disk-tiles: #7aa2ff; --disk-other: #3d5a94; --disk-unrelated: #66718a; --disk-free: #1f2738;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
h4 { font-size: 13px; margin: 18px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.hint { color: var(--muted); margin: 4px 0 0; font-size: 13px; }
.empty-note { color: var(--muted); padding: 24px 0; }
.alert {
  margin: 0; padding: 6px 10px; border-radius: 8px; font-size: 13px;
  background: color-mix(in srgb, var(--bad) 12%, var(--panel)); color: var(--bad);
}
.error-text { color: var(--bad); font-size: 12px; overflow-wrap: anywhere; }

/* ----- header ----- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.tabs { display: flex; gap: 4px; }
.tabs a {
  padding: 6px 12px; border-radius: 8px; color: var(--muted);
  text-decoration: none; font-weight: 500;
}
.tabs a:hover { background: var(--soft); color: var(--ink); }
.tabs a.active { background: var(--soft); color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); }
.status { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.pill {
  padding: 3px 10px; border-radius: 999px; font-size: 12px;
  background: var(--soft); color: var(--muted); white-space: nowrap;
}
.pill-ok { color: var(--ok); }
.pill-warn { color: var(--warn); }
.pill-bad { color: var(--bad); }
.refresh-box { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.updated { color: var(--muted); font-size: 12px; white-space: nowrap; }
button.refresh {
  font: inherit; font-size: 13px; padding: 5px 12px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
}
button.refresh:hover { border-color: var(--accent); }
button.refresh:disabled { opacity: .6; cursor: progress; }

.banner {
  margin: 12px 16px 0; padding: 8px 14px; border-radius: var(--radius);
  background: color-mix(in srgb, var(--warn) 14%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--warn) 45%, var(--line));
  font-size: 13px;
}
.banner ul { margin: 0; padding-left: 18px; }

main { padding: 16px; max-width: 1500px; margin: 0 auto; }
.panel { display: flex; flex-direction: column; gap: 12px; }
.panel-head { display: flex; flex-direction: column; gap: 2px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-item b { color: var(--ink); font-weight: 600; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--soft); font-size: 12px; }
.tag-live { color: var(--ok); }

/* outcome colours, used by cells, swatches and badges */
.st-matched { --c: var(--st-matched); }
.st-obstructed { --c: var(--st-obstructed); }
.st-matching, .st-checking { --c: var(--st-matching); }
.st-awaiting_matching { --c: var(--st-awaiting); }
.st-too_big { --c: var(--st-too-big); }
.st-dp_running { --c: var(--st-dp-running); }
.st-dp_failed { --c: var(--st-dp-failed); }
.st-dp_cancelled { --c: var(--st-dp-cancelled); }
.st-unknown { --c: var(--st-unknown); }
.swatch[class*="st-"], .badge[class*="st-"] { background: var(--c); }
.badge { font-size: 12px; font-weight: 500; color: #fff; padding: 2px 8px; border-radius: 999px; vertical-align: middle; }

/* ----- results table ----- */
.results-scroll {
  overflow-x: auto; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
table.results { border-collapse: separate; border-spacing: 3px; margin: 6px; }
table.results th {
  font-size: 12px; font-weight: 500; color: var(--muted); padding: 4px 6px; white-space: nowrap;
}
table.results thead th { position: sticky; top: 0; background: var(--panel); }
table.results tbody th { text-align: right; position: sticky; left: 0; background: var(--panel); }
td.cell { padding: 0; min-width: 64px; height: 34px; border-radius: 6px; }
td.cell.empty { background: var(--soft); opacity: .45; }
td.cell[class*="st-"] { background: color-mix(in srgb, var(--c) 22%, var(--panel)); box-shadow: inset 3px 0 0 var(--c); }
td.cell button {
  all: unset; box-sizing: border-box; cursor: pointer; display: flex; align-items: center;
  justify-content: center; gap: 2px; width: 100%; height: 100%; padding: 0 8px;
  font-variant-numeric: tabular-nums; font-size: 13px; border-radius: 6px;
}
td.cell button:hover, td.cell button:focus-visible { outline: 2px solid var(--c); }
td.cell.selected button { outline: 2px solid var(--ink); }
.cell-glyph { font-weight: 700; color: var(--c); }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 20;
  width: min(560px, 100vw); overflow-y: auto; padding: 18px 20px 30px;
  background: var(--panel); border-left: 1px solid var(--line);
  box-shadow: -8px 0 30px rgb(0 0 0 / 15%);
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.drawer-head h3 { font-size: 22px; }
.drawer-actions { align-items: center; margin-bottom: 12px; }
button.close {
  font: inherit; font-size: 22px; line-height: 1; border: 0; background: none;
  color: var(--muted); cursor: pointer; padding: 4px 8px; border-radius: 6px;
}
button.close:hover { background: var(--soft); color: var(--ink); }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; font-variant-numeric: tabular-nums; }
ul.notes { padding-left: 18px; color: var(--warn); font-size: 13px; }
table.mini { width: 100%; border-collapse: collapse; font-size: 12px; }
table.mini th { text-align: left; color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--line); padding: 4px 6px; }
table.mini td { padding: 4px 6px; border-bottom: 1px solid var(--soft); vertical-align: top; }
table.mini tr.error-row td { color: var(--bad); border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.state { font-weight: 500; }
.state-complete { color: var(--ok); }
.state-failed, .state-cancelled { color: var(--bad); }
.state-running, .state-waiting, .state-queued { color: var(--accent); }
.state-idle { color: var(--ok); }
.state-draining { color: var(--warn); }
.state-unknown { color: var(--muted); }

/* ----- fleet ----- */
.node-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.node-card, .root-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow); min-width: 0;
}
.node-down { opacity: .65; }
.node-head { display: flex; justify-content: space-between; align-items: flex-start; }
.node-head h3 { display: flex; align-items: center; gap: 8px; text-transform: capitalize; }
.node-sub, .node-beat, .node-foot, .root-sub { color: var(--muted); font-size: 12px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-busy { background: var(--ok); }
.dot-idle { background: var(--warn); }
.dot-down { background: var(--bad); }
.cpus { display: flex; flex-wrap: wrap; gap: 3px; }
.cpu { width: 16px; height: 16px; border-radius: 3px; display: inline-block; }
.cpu-free { background: var(--soft); border: 1px solid var(--line); }
.cpu-reserved {
  background: repeating-linear-gradient(45deg, var(--soft) 0 3px, var(--line) 3px 6px);
}
.cpu-busy { background: var(--wc, var(--w0)); }
.w0 { --wc: var(--w0); } .w1 { --wc: var(--w1); } .w2 { --wc: var(--w2); }
.w3 { --wc: var(--w3); } .w4 { --wc: var(--w4); } .w5 { --wc: var(--w5); }
.memline, .util-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
svg.bar { width: 100%; height: 6px; display: block; }
/* disk usage bars: four segments, with swatches in the text so colour is never the only cue */
svg.diskbar { width: 100%; height: 12px; display: block; margin: 5px 0; border-radius: 4px; overflow: hidden; }
svg.diskbar rect { stroke: var(--panel); stroke-width: 1; vector-effect: non-scaling-stroke; }
svg.diskbar .disk-tiles, .swatch.disk-tiles { fill: var(--disk-tiles); }
svg.diskbar .disk-other, .swatch.disk-other { fill: var(--disk-other); }
svg.diskbar .disk-unrelated, .swatch.disk-unrelated { fill: var(--disk-unrelated); }
svg.diskbar .disk-free { fill: var(--disk-free); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; border: 1px solid var(--line); }
.swatch.disk-tiles { background: var(--disk-tiles); } .swatch.disk-other { background: var(--disk-other); }
.swatch.disk-unrelated { background: var(--disk-unrelated); } .swatch.disk-free { background: var(--disk-free); }
.disk-figures, .disk-legend { display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: 12px; color: var(--muted); }
.disk-note { font-size: 12px; color: var(--muted); }
.disk-stale svg.diskbar { opacity: .55; }
.disk-summary { margin: 12px 0 16px; }
.disk-summary .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.disk-summary h4 { margin: 0; }
table.disk-tip td.num { text-align: right; padding-left: 14px; font-variant-numeric: tabular-nums; }
.bar-track { fill: var(--soft); }
.bar-fill { fill: var(--wc, var(--accent)); }
svg.bar.mem .bar-fill { fill: var(--muted); }
.work-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.work-head { display: flex; align-items: center; gap: 8px; }
.work-dot { width: 8px; height: 8px; border-radius: 2px; background: var(--wc); flex: none; }
.work-label { font-weight: 500; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.work-meta { color: var(--muted); font-size: 12px; margin: 2px 0 4px 16px; }
.work svg.bar { margin-left: 16px; width: calc(100% - 16px); }
.health { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--soft); white-space: nowrap; }
.health-ok { color: var(--ok); }
.health-warn { color: var(--warn); }
.health-bad { color: var(--bad); }
.idle { margin: 0; color: var(--warn); font-size: 13px; }
svg.spark { width: 100%; height: 34px; display: block; }
.spark-area { fill: color-mix(in srgb, var(--accent) 18%, transparent); }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 1.2; vector-effect: non-scaling-stroke; }

/* ----- tiles ----- */
.root-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.root-head h3 { display: flex; align-items: center; gap: 10px; font-size: 20px; }
.root-head .state { font-size: 13px; }
.root-progress { font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px;
  padding: 2px 8px; border-radius: 999px; background: var(--soft);
}
svg.tile-grid, canvas.tile-grid { width: 100%; max-width: 560px; height: auto; display: block; margin: 0 auto; touch-action: manipulation; }
canvas.tile-grid { cursor: pointer; }
rect.tile { stroke: none; }
rect.tile:hover { stroke: var(--ink); stroke-width: .8; }
.tile-label { font-size: 4.2px; text-anchor: middle; fill: #fff; pointer-events: none; font-weight: 600; }
.t-durable { fill: var(--t-durable); background: var(--t-durable); }
.t-complete { fill: var(--t-complete); background: var(--t-complete); }
.t-running { fill: var(--t-running); background: var(--t-running); }
.t-paused { fill: var(--t-paused); background: var(--t-paused); }
.t-queued { fill: var(--t-queued); background: var(--t-queued); }
.t-ready { fill: var(--t-ready); background: var(--t-ready); }
.t-blocked { fill: var(--t-blocked); background: var(--t-blocked); }
.t-failed { fill: var(--t-failed); background: var(--t-failed); }
.t-cancelled { fill: var(--t-cancelled); background: var(--t-cancelled); }
.t-unscheduled { fill: var(--t-unscheduled); background: var(--t-unscheduled); border: 1px solid var(--line); }
details.finished summary { cursor: pointer; color: var(--muted); padding: 8px 0; font-weight: 500; }
.root-finished { opacity: .9; }

/* ----- tooltip ----- */
.tooltip {
  position: fixed; z-index: 30; pointer-events: none; max-width: 320px;
  padding: 7px 10px; border-radius: 8px; font-size: 12px; line-height: 1.5;
  background: var(--ink); color: var(--panel); box-shadow: 0 4px 14px rgb(0 0 0 / 25%);
}
.tooltip .error-text { color: #ff9d94; }
.tooltip svg.loupe { display: block; margin: 0 0 6px; border-radius: 4px; background: rgb(255 255 255 / 8%); }
.tooltip svg.loupe rect.centre { stroke: var(--panel); stroke-width: 3; }
.tooltip svg.loupe rect.selected { stroke: var(--panel); stroke-width: 1.6; stroke-dasharray: 3 2; }
.loupe-label { font-size: 8px; text-anchor: middle; fill: #fff; font-weight: 600; pointer-events: none; }

@media (max-width: 640px) {
  .top { padding: 8px 12px; }
  main { padding: 12px; }
  .refresh-box { margin-left: 0; width: 100%; justify-content: space-between; }
  .node-grid, .root-grid { grid-template-columns: 1fr; }
  .drawer { width: 100vw; border-left: 0; }
}

/* ----- shared bits for timeline / feeder / problems ----- */
.tabs { flex-wrap: wrap; }
.nav-badge {
  display: inline-block; min-width: 18px; margin-left: 6px; padding: 0 5px; border-radius: 999px;
  font-size: 11px; line-height: 18px; text-align: center; color: #fff; background: var(--warn);
}
.nav-badge.sev-critical { background: var(--bad); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.seg-group { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg-btn { padding: 4px 12px; color: var(--muted); text-decoration: none; font-size: 13px; }
.seg-btn + .seg-btn { border-left: 1px solid var(--line); }
.seg-btn.active { background: var(--soft); color: var(--ink); font-weight: 600; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow); min-width: 0;
}
.card h3 { margin-bottom: 10px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; font-size: 13px; }
.kv span { color: var(--muted); }
.text-ok { color: var(--ok); }
.text-bad { color: var(--bad); }
.section-title { font-size: 15px; margin-top: 6px; }
.table-scroll { overflow-x: auto; }

/* ----- timeline ----- */
.timeline-scroll {
  overflow-x: auto; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 12px; box-shadow: var(--shadow);
}
svg.timeline { display: block; font-size: 12px; }
.tick { stroke: var(--line); stroke-width: 1; }
.tick-label { fill: var(--muted); font-size: 11px; text-anchor: middle; }
.now-line { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 3 3; }
.tl-row { fill: var(--soft); opacity: .55; }
.tl-util { fill: color-mix(in srgb, var(--ok) 22%, transparent); }
.tl-name { fill: var(--ink); font-weight: 600; text-transform: capitalize; }
.tl-sub { fill: var(--muted); font-size: 10px; }
rect.seg { stroke-width: 0; }
rect.seg:hover { stroke: var(--ink); stroke-width: 1.2; }
rect.seg.o-fail, rect.seg.o-expired { stroke: var(--bad); stroke-width: 1.6; }
rect.seg.o-retry { stroke: var(--warn); stroke-width: 1.4; }
rect.seg.o-stop { opacity: .45; }
rect.seg.o-running { opacity: .8; }
rect.seg.k-matching_partner { opacity: .7; }
.swatch.outline-fail { border: 2px solid var(--bad); }
.swatch.outline-retry { border: 2px solid var(--warn); }
.swatch.outline-stop { background: var(--muted); opacity: .45; }

/* ----- feeder ----- */
.feeder-top { display: grid; grid-template-columns: minmax(240px, 320px) 1fr; gap: 12px; }
.gauges { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.gauge {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow);
}
.gauge-label { color: var(--muted); font-size: 12px; }
.gauge-value { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.gauge-value span { font-size: 12px; font-weight: 400; color: var(--muted); }
.gauge-note { font-size: 12px; color: var(--muted); }
.tone-ok { --wc: var(--ok); }
.tone-warn { --wc: var(--warn); }
.tone-bad { --wc: var(--bad); }
.feeder-grid { display: grid; grid-template-columns: 1fr minmax(260px, 360px); gap: 12px; align-items: start; }
.side { display: flex; flex-direction: column; gap: 12px; }
table.fields td { vertical-align: top; }
table.fields a { color: var(--ink); font-weight: 600; text-decoration: none; }
tr.row-bad td { background: color-mix(in srgb, var(--bad) 7%, transparent); }
.mini-progress { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 11px; color: var(--muted); }
.mini-progress svg.bar { width: 90px; }
.upcoming { margin: 0; padding-left: 20px; display: grid; gap: 3px; }
.passes { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow-y: auto; font-size: 12px; }
.pass { display: flex; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--soft); }
.pass-time { color: var(--muted); flex: none; width: 70px; }
.pass-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.pass-error .pass-text { color: var(--bad); }
.pass-count { color: var(--muted); font-size: 12px; flex: none; }
details.settings summary { cursor: pointer; list-style: none; }
details.settings summary h3 { display: inline; }
details.settings[open] summary { margin-bottom: 10px; }

/* ----- problems ----- */
.sev-critical { --sev: var(--bad); }
.sev-warning { --sev: var(--warn); }
.sev-info { --sev: var(--muted); }
.sev-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--sev); flex: none; display: inline-block; }
.problems, .events { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.problem {
  display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px;
  background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--sev);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.problem-main { display: flex; gap: 10px; align-items: baseline; min-width: 0; }
.problem-title { font-weight: 600; }
.problem-detail { color: var(--muted); font-size: 13px; margin: 2px 0 0; overflow-wrap: anywhere; }
.problem-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.problem-side a, .event-link { color: var(--accent); text-decoration: none; }
.all-clear { color: var(--ok); font-weight: 500; margin: 0; }
.toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.toggle {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  background: var(--soft); font-size: 12px; cursor: pointer; text-transform: capitalize;
}
.toggle input { margin: 0; }
.event { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.event summary {
  display: flex; align-items: center; gap: 10px; padding: 9px 14px; cursor: pointer; list-style: none;
}
.event summary::-webkit-details-marker { display: none; }
.event-title { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.event-when { color: var(--muted); font-size: 12px; white-space: nowrap; }
.event details > .problem-detail { padding: 0 14px 0 33px; }
.event-items { list-style: none; margin: 6px 0 10px; padding: 0 14px 0 33px; font-size: 12px; display: grid; gap: 3px; max-height: 300px; overflow-y: auto; }
.event-time { color: var(--muted); display: inline-block; width: 120px; }
.new-tag { font-size: 10px; font-weight: 700; color: #fff; background: var(--accent); padding: 1px 6px; border-radius: 999px; vertical-align: middle; }

@media (max-width: 900px) {
  .feeder-top, .feeder-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .problem { flex-direction: column; }
  .problem-side { align-items: flex-start; flex-direction: row; gap: 12px; }
  .event summary { flex-wrap: wrap; }
  .event-time { width: auto; margin-right: 6px; }
}

/* ----- login and account ----- */
body.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-box {
  width: min(360px, 100%); padding: 28px; display: flex; flex-direction: column; gap: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
}
.login-box h1 { font-size: 22px; }
.login-form, .password-form, .reauth-form { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.login-form label, .password-form label, .reauth-form label {
  display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted);
}
input[type="password"], input:not([type]), input[type="text"] {
  font: inherit; color: var(--ink); background: var(--bg); padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.login-form button, .password-form button, .reauth-form button, .sign-out {
  font: inherit; font-weight: 600; padding: 8px 12px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
}
button.secondary, .sign-out { background: var(--panel); color: var(--ink); border-color: var(--line); }
button:disabled { opacity: .6; cursor: progress; }
.login-error, .form-message { color: var(--bad); font-size: 13px; margin: 0; }
.account-menu { position: relative; }
.account-menu summary {
  list-style: none; cursor: pointer; font-size: 13px; padding: 5px 10px; border-radius: 8px;
  border: 1px solid var(--line); white-space: nowrap;
}
.account-menu summary::-webkit-details-marker { display: none; }
.role { font-size: 11px; padding: 1px 6px; border-radius: 999px; background: var(--soft); color: var(--muted); margin-left: 4px; }
.role-operator { color: var(--accent); }
.account-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 25; width: 280px;
  display: flex; flex-direction: column; gap: 12px; padding: 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 30px rgb(0 0 0 / 18%);
}
.account-panel h4 { margin: 0; }
dialog.reauth-dialog {
  border: 1px solid var(--line); border-radius: 14px; padding: 22px; width: min(380px, calc(100vw - 32px));
  background: var(--panel); color: var(--ink);
}
dialog.reauth-dialog::backdrop { background: rgb(0 0 0 / 45%); }
.dialog-buttons { display: flex; justify-content: flex-end; gap: 8px; }

/* ----- commands ----- */
.cmd-row { display: flex; flex-wrap: wrap; gap: 6px; }
button.cmd {
  font: inherit; font-size: 13px; padding: 5px 11px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
}
button.cmd:hover { border-color: var(--accent); color: var(--accent); }
button.cmd.small { font-size: 12px; padding: 2px 9px; }
button.cmd.danger:hover, button.danger { border-color: var(--bad); color: var(--bad); }
.command-form button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.work .cmd-row { margin: 6px 0 0 16px; }
.panel-head.row { flex-direction: row; justify-content: space-between; align-items: center; gap: 12px; }
.root-card .cmd-row { margin-top: 4px; }
details.settings summary { display: flex; justify-content: space-between; align-items: center; }
dialog.command-dialog {
  border: 1px solid var(--line); border-radius: 14px; padding: 22px; width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 48px); overflow-y: auto; background: var(--panel); color: var(--ink);
}
dialog.command-dialog::backdrop { background: rgb(0 0 0 / 45%); }
.command-form { display: flex; flex-direction: column; gap: 10px; }
.command-form h3 { font-size: 18px; }
.command-form p { margin: 0; }
.command-form button {
  font: inherit; font-weight: 600; padding: 7px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
}
.command-form button.secondary { background: var(--panel); color: var(--ink); border-color: var(--line); }
.cmd-items { margin: 0; padding-left: 18px; max-height: 180px; overflow-y: auto; font-size: 13px; }
.cmd-warnings, .cmd-blockers { margin: 0; padding: 8px 12px 8px 28px; border-radius: 8px; font-size: 13px; }
.cmd-warnings { background: color-mix(in srgb, var(--warn) 12%, var(--panel)); }
.cmd-blockers { background: color-mix(in srgb, var(--bad) 12%, var(--panel)); color: var(--bad); }
.cmd-notice { padding: 8px 12px; border-radius: 8px; background: color-mix(in srgb, var(--accent) 12%, var(--panel)); }
.cmd-confirm, .field-row { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.cmd-confirm code { color: var(--ink); font-weight: 600; }
table.changes td:first-child { color: var(--muted); }
.toast {
  position: fixed; right: 16px; bottom: 16px; z-index: 40; padding: 10px 16px; border-radius: 10px;
  background: var(--ink); color: var(--panel); box-shadow: 0 6px 20px rgb(0 0 0 / 25%);
  transition: opacity .5s; max-width: min(420px, calc(100vw - 32px));
}
.toast-bad { background: var(--bad); color: #fff; }
.toast-out { opacity: 0; }

/* ----- activity ----- */
.jobs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.job { border: 1px solid var(--line); border-radius: var(--radius); }
.job summary { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; }
.job-status { font-size: 11px; font-weight: 700; text-transform: uppercase; padding: 1px 8px; border-radius: 999px; background: var(--soft); }
.job-running .job-status { color: var(--accent); }
.job-ok .job-status { color: var(--ok); }
.job-failed .job-status, .job-lost .job-status { color: var(--bad); }
.job-cancelled .job-status { color: var(--warn); }
.job summary .cmd { margin-left: auto; }
.job-title { font-weight: 600; }
.job-log {
  margin: 0; padding: 10px 12px; max-height: 360px; overflow: auto; font-size: 12px; line-height: 1.45;
  background: var(--bg); border-top: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere;
}
table.audit tr.audit-failed td, table.audit tr.audit-throttled td { color: var(--bad); }

/* ----- matching ----- */
.match-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 12px; }
.match-card { display: flex; flex-direction: column; gap: 10px; }
.match-progress { display: flex; flex-direction: column; gap: 4px; }
svg.conv { width: 100%; max-width: 620px; height: auto; display: block; }
svg.conv .grid { stroke: var(--line); stroke-width: 1; }
svg.conv .grid.zero { stroke: var(--muted); }
svg.conv .axis { fill: var(--muted); font-size: 11px; }
.conv-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.conv-line.live { stroke-dasharray: 4 4; }
.conv-dot { fill: var(--accent); stroke: var(--panel); stroke-width: 2; }
.conv-dot.done { fill: var(--ok); }
.conv-dot.live { fill: var(--panel); stroke: var(--accent); }
.conv-hit { fill: transparent; cursor: default; }

/* block GPU matching: stages with progress */
svg.stage-timeline { width: 100%; height: 14px; display: block; margin: 8px 0 10px; border-radius: 4px; background: var(--soft); }
.stage-seg.running { opacity: .65; }
.seg-gpu_wait { fill: #9aa3b5; background: #9aa3b5; }
.seg-field { fill: #c98a12; background: #c98a12; }
.seg-blocks { fill: var(--accent); background: var(--accent); }
.seg-exchange { fill: #7b5cd6; background: #7b5cd6; }
.seg-write { fill: #2a9d8f; background: #2a9d8f; }
.seg-publish { fill: #6d8f3a; background: #6d8f3a; }
.seg-verify { fill: var(--ok); background: var(--ok); }
ol.stages { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; }
.stage { display: grid; grid-template-columns: 18px 1fr auto; column-gap: 8px; align-items: center; font-size: 13px; }
.stage .stage-detail, .stage svg.bar { grid-column: 2 / 4; }
.stage .stage-time { font-variant-numeric: tabular-nums; color: var(--muted); }
.stage-mark { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--muted); box-sizing: border-box; }
.stage-done .stage-mark { background: var(--ok); border-color: var(--ok); }
.stage-running .stage-mark { border-color: var(--accent); border-top-color: transparent; animation: stage-spin 1s linear infinite; }
.stage-stopped .stage-mark { background: var(--bad); border-color: var(--bad); }
.stage-pending, .stage-skipped { color: var(--muted); }
.stage-skipped .stage-mark { border-style: dashed; }
.stage-running .stage-name { font-weight: 600; }
@keyframes stage-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .stage-running .stage-mark { animation: none; background: var(--accent); } }
.conv-end { fill: var(--ink); font-size: 12px; font-weight: 600; }
.phase-table summary { cursor: pointer; color: var(--muted); font-size: 12px; }
.phase-table table { margin-top: 6px; max-width: 520px; }
table.history tr.history-row { cursor: pointer; }
table.history tr.history-row:hover td, table.history tr.open td { background: var(--soft); }
table.history > tbody > tr.history-detail > td { padding: 10px 14px 16px; }
.link-button { all: unset; cursor: pointer; font-weight: 600; }
.state-obstructed { color: var(--st-obstructed); }
.all-clear.neutral { color: var(--muted); }
@media (max-width: 640px) { .match-grid { grid-template-columns: 1fr; } }
td.cell.empty .submit-cell {
  all: unset; box-sizing: border-box; display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%; cursor: pointer; color: transparent; border-radius: 6px; font-size: 16px;
}
td.cell.empty:has(.submit-cell) { opacity: 1; background: color-mix(in srgb, var(--soft) 45%, transparent); }
td.cell.empty .submit-cell:hover, td.cell.empty .submit-cell:focus-visible {
  color: var(--accent); outline: 1px dashed var(--accent);
}

/* ----- DP root focus view ----- */
.root-link { color: inherit; text-decoration: none; }
.root-link:hover { color: var(--accent); }
.grid-link { display: block; cursor: zoom-in; }
.card-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
a.open-link { text-decoration: none; color: var(--ink); margin-left: auto; }
.focus-head { display: flex; flex-direction: column; gap: 4px; }
.focus-head h2 { display: flex; align-items: center; gap: 10px; font-size: 24px; }
.focus-head .state { font-size: 14px; }
.back-link { color: var(--accent); text-decoration: none; font-size: 13px; }
.focus-body { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.focus-grid {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; box-shadow: var(--shadow); min-width: 0;
}
svg.tile-grid.focus, canvas.tile-grid.focus { width: calc(var(--zoom, 1) * min(100%, 100vh - 150px)); max-width: none; }
.focus-grid.zoomed .focus-scroll { overflow: auto; max-height: calc(100vh - 150px); scrollbar-color: var(--line) transparent; }
.zoom-bar { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.zoom-level { min-width: 2.2em; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }
.grid-number { font-size: 6px; fill: var(--muted); text-anchor: middle; }
rect.tile.selected { stroke: var(--ink); stroke-width: 1.4; }
.focus-side { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 80px; }
.big-number { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.done-fill { fill: var(--t-durable); }
.focus-side svg.bar { margin: 6px 0 10px; }
.tile-detail p { margin: 0; font-size: 13px; line-height: 1.6; }
@media (max-width: 900px) {
  .focus-body { grid-template-columns: 1fr; }
  .focus-side { position: static; }
}
.no-history { fill: var(--soft); opacity: .7; }
.no-history-label { fill: var(--muted); font-size: 12px; text-anchor: middle; }

/* ----- header: status row, then a single row of tabs ----- */
.top { flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 6px; padding: 8px 16px 0; }
.top > * { min-width: 0; }
.top-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.top-row h1 { font-size: 17px; white-space: nowrap; }
.top .status { flex: 1; min-width: 0; }
.top .refresh-box { margin-left: auto; }
nav.tabs {
  display: flex; flex-wrap: nowrap; gap: 2px; overflow-x: auto; scrollbar-width: none;
  margin: 0 -16px; padding: 0 12px;
}
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs a {
  flex: none; padding: 8px 12px 9px; border-radius: 0; white-space: nowrap;
  border-bottom: 2px solid transparent;
}
nav.tabs a:hover { background: none; color: var(--ink); border-bottom-color: var(--line); }
nav.tabs a.active { background: none; box-shadow: none; color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }
@media (max-width: 640px) {
  .top { padding: 8px 12px 0; }
  .top .status { order: 3; flex-basis: 100%; }
  .top .refresh-box { width: auto; }
  nav.tabs { margin: 0 -12px; padding: 0 8px; }
}
@media (max-width: 640px) {
  .top { position: static; }
  .top .refresh-box { order: 2; flex-basis: 100%; flex-wrap: wrap; justify-content: flex-start; margin-left: 0; }
  .top .refresh-box .updated { flex-basis: 100%; }
  .top .status { order: 3; }
}

/* GPU leases and opportunistic GPU tiles */
.gpu-tag { display: inline-block; padding: 0 0.35em; border-radius: 0.3em; font-size: 0.8em;
  background: color-mix(in srgb, #76b900 22%, transparent); color: inherit; }
.gpuline { margin-top: 0.25rem; }
.gpu-util .spark-area { fill: color-mix(in srgb, #76b900 22%, transparent); }
.gpu-util .spark-line { stroke: #76b900; }
.gpu-summary p { margin: 0.4rem 0; }
.gpu-summary table { max-width: 22rem; }

/* heat gauges and history (Fleet cards) */
.heat-gauges { display: flex; flex-wrap: wrap; gap: 6px 12px; margin: 2px 0 4px; font-size: 12px; }
.heat-chip { display: inline-flex; align-items: center; gap: 4px; }
.heat-name { color: var(--muted); }
.heat-tube { width: 42px; height: 6px; }
.heat-track { fill: var(--soft); }
.heat-fill { fill: #2f9e6b; }
.heat-warm .heat-fill { fill: var(--warn); }
.heat-hot .heat-fill { fill: #d0453b; }
.heat-warm b, .heat-text.heat-warm { color: var(--warn); }
.heat-hot b, .heat-text.heat-hot { color: #d0453b; }
svg.spark.heat-chart { height: 56px; }
.heat-chart .heat-line { fill: none; stroke-width: 1.2; vector-effect: non-scaling-stroke; }
.heat-guide { stroke: var(--line); stroke-dasharray: 2 2; stroke-width: 1; vector-effect: non-scaling-stroke; }
.heat-cpu-line { stroke: #e07a3f; } .heat-cpu-dot { fill: #e07a3f; }
.heat-gpu-line { stroke: #76b900; } .heat-gpu-dot { fill: #76b900; }
.heat-nvme-line { stroke: #3f78e0; } .heat-nvme-dot { fill: #3f78e0; }
.heat-legend { display: flex; gap: 10px; font-size: 11px; color: var(--muted); margin-top: 2px; }
.heat-key { display: inline-block; width: 10px; height: 2px; margin-right: 4px; vertical-align: middle; }
.heat-cpu-key { background: #e07a3f; } .heat-gpu-key { background: #76b900; } .heat-nvme-key { background: #3f78e0; }
