:root {
  color-scheme: light dark;
  --fg: #1a1c1e;
  --bg: #ffffff;
  --muted: #5b6168;
  --line: #d5d9de;
  --band: #f4f6f8;
  --warn-fg: #8a3b00;
  --warn-bg: #fff1e0;
  --bad-fg: #9b1c1c;
  --bad-bg: #fde8e8;
  --accent: #0b5cad;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fg: #e6e8ea;
    --bg: #14171a;
    --muted: #a0a7af;
    --line: #353b42;
    --band: #1c2126;
    --warn-fg: #ffc27a;
    --warn-bg: #3a2a12;
    --bad-fg: #ffb0b0;
    --bad-bg: #3d1a1a;
    --accent: #7db8f5;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--fg);
  background: var(--bg);
}
main { max-width: 1280px; margin: 0 auto; padding: 1rem 1.25rem 3rem; }
header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.5rem 1.5rem; }
h1 { font-size: 1.4rem; margin: 0.5rem 0; }
h2 { font-size: 1.05rem; margin: 1.75rem 0 0.5rem; }
a { color: var(--accent); }
button, select {
  font: inherit;
  color: inherit;
  background: var(--band);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.3rem 0.7rem;
}
button { cursor: pointer; }
button:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#sign-in { font-size: 1.05rem; padding: 0.5rem 1.2rem; }
#signed-out, #refused, .notice { margin-top: 2rem; }
.problem { color: var(--bad-fg); background: var(--bad-bg); padding: 0.6rem 0.8rem; border-radius: 4px; max-width: 46rem; }

#counts ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
#counts li { border: 1px solid var(--line); border-radius: 4px; padding: 0.35rem 0.7rem; background: var(--band); }
#counts li.flag { color: var(--warn-fg); background: var(--warn-bg); border-color: currentColor; }

#controls { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; margin: 0.5rem 0 0.75rem; }
#controls label { color: var(--muted); }
#controls select { color: var(--fg); max-width: 22rem; }

#agents-host, #accounts-section, #sources-section { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
caption { text-align: left; color: var(--muted); padding: 0.25rem 0; }
th, td { text-align: left; vertical-align: top; padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--line); }
thead th { font-weight: 600; background: var(--band); position: sticky; top: 0; }
tbody th { font-weight: 600; }
tfoot th, tfoot td { font-weight: 600; border-top: 2px solid var(--line); }
td.cost, td.n, thead th:last-child { text-align: right; font-variant-numeric: tabular-nums; }
#accounts thead th:nth-child(n+2), #sources thead th:last-child { text-align: right; }
.note { display: block; color: var(--muted); font-size: 0.85em; font-weight: 400; }
.mark { color: var(--warn-fg); }
td.owner.unknown, td.role.none .reason { color: var(--warn-fg); }
tr.absent th.name, tr.absent td { opacity: 0.7; }
tr.absent .absent-mark { opacity: 1; }
tr.failed td.run { color: var(--bad-fg); }
tr.stale td.good { color: var(--warn-fg); }
.stale-mark, .estimate { font-weight: 600; }

#counts ul + ul { margin-top: 0.5rem; }
button.open { background: none; border: 0; padding: 0; font-weight: 600; color: var(--accent); text-align: left; text-decoration: underline; }
.flag-name { display: block; color: var(--warn-fg); }
td.none .reason, .reason { color: var(--muted); }
.state { font-weight: 600; }
.state-failed, .state-errors { color: var(--bad-fg); }
.state-throttled { color: var(--warn-fg); }
.state-idle, .state-new { color: var(--muted); }

#detail { border: 1px solid var(--line); border-radius: 4px; padding: 0.25rem 1rem 1rem; margin: 0.5rem 0 1rem; background: var(--band); position: relative; }
#detail:focus-visible { outline: 2px solid var(--accent); }
#detail h3 { font-size: 1.1rem; margin: 0.75rem 0 0; }
#detail h4 { font-size: 0.95rem; margin: 1.1rem 0 0.35rem; }
#detail-close { position: absolute; top: 0.6rem; right: 0.75rem; }
#detail-id, #detail-role { overflow-wrap: anywhere; }
#detail table { width: auto; min-width: 24rem; }
#detail thead th { position: static; }
#detail ul { margin: 0.25rem 0; padding-left: 1.25rem; }
.sentence { border-left: 3px solid var(--accent); padding-left: 0.6rem; max-width: 46rem; }
.facts { margin: 0.25rem 0 0.75rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 0.4rem 1.25rem; }
.facts dt { color: var(--muted); font-size: 0.85em; }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
#detail-periods button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.bars { display: block; width: 100%; max-width: 44rem; height: 4.5rem; }
.bars .hit { fill: transparent; }
.bars .bar { fill: var(--accent); }
.bars.errors .bar { fill: var(--bad-fg); }
.bars g:hover .hit { fill: var(--line); }
.bars .base { stroke: var(--line); stroke-width: 1; }
.flags .flag-note { display: block; max-width: 22ch; }
