:root {
  color-scheme: light;
  --surface: #fcfcfb;
  --raised: #ffffff;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #8a8984;
  --grid: #e7e6e2;
  --axis: #c9c8c2;
  --accent: #2a78d6;
  --danger: #c4332f;
  --series-1: #2a78d6;
  --series-2: #eb6834;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface: #1a1a19;
    --raised: #232322;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #8f8e86;
    --grid: #2e2e2c;
    --axis: #4a4a46;
    --accent: #3987e5;
    --danger: #e66767;
    --series-1: #3987e5;
    --series-2: #d95926;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface: #1a1a19;
  --raised: #232322;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #8f8e86;
  --grid: #2e2e2c;
  --axis: #4a4a46;
  --accent: #3987e5;
  --danger: #e66767;
  --series-1: #3987e5;
  --series-2: #d95926;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  padding: 24px 16px;
  background: var(--surface);
  color: var(--text-primary);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
main { max-width: 980px; margin: 0 auto; }
a { color: var(--accent); }
h1 { font-size: 20px; margin: 0 0 4px; font-weight: 600; }
h2 { font-size: 16px; margin: 16px 0 8px; font-weight: 600; }
.sub { color: var(--text-secondary); margin: 0 0 16px; }
.top { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.who { color: var(--text-secondary); font-size: 13px; display: flex; gap: 12px; align-items: baseline; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

button, input, select {
  font: inherit;
  color: var(--text-primary);
  background: var(--raised);
  border: 1px solid var(--axis);
  border-radius: 6px;
  padding: 4px 8px;
}
button { cursor: pointer; }
button:disabled { opacity: 0.6; cursor: progress; }
button.link { border: 0; background: none; color: var(--accent); padding: 0; text-decoration: underline; }
input[type="password"] { min-width: 0; flex: 1; max-width: 420px; }
.inline { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#token-form .inline { display: flex; margin-top: 4px; }
.error { color: var(--danger); min-height: 1.4em; margin: 4px 0; }

.controls { display: flex; gap: 12px 16px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.controls label { display: inline-flex; gap: 6px; align-items: center; color: var(--text-secondary); }
.controls select { max-width: 260px; }
.check input { margin: 0; }
.status { color: var(--text-secondary); min-height: 1.4em; margin: 0 0 8px; }
.status.error { color: var(--danger); }

.legend { display: flex; gap: 16px; flex-wrap: wrap; color: var(--text-secondary); font-size: 13px; margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; }
.swatch { width: 14px; height: 2px; border-radius: 1px; display: inline-block; margin-right: 6px; vertical-align: middle; }
.swatch.remaining { background: var(--series-1); }
.swatch.scope { background: var(--series-2); }
.swatch.ideal { background: none; border-top: 2px dashed var(--text-muted); height: 0; }

.stats { display: flex; gap: 32px; flex-wrap: wrap; margin: 4px 0 16px; }
.stat b { display: block; font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat small { color: var(--text-secondary); }

.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .empty { color: var(--text-muted); padding: 48px 0; text-align: center; }
.tick { fill: var(--text-secondary); font-size: 11px; font-variant-numeric: tabular-nums; }
.end-label { fill: var(--text-primary); font-size: 11px; font-variant-numeric: tabular-nums; }
.grid { stroke: var(--grid); stroke-width: 1; }
.axis { stroke: var(--axis); stroke-width: 1; }
.ideal { stroke: var(--text-muted); stroke-width: 1.5; stroke-dasharray: 4 4; }
.line { fill: none; stroke-width: 2; stroke-linejoin: round; }
.line.remaining { stroke: var(--series-1); }
.line.scope { stroke: var(--series-2); }
.dot { stroke: var(--surface); stroke-width: 2; }
.dot.remaining { fill: var(--series-1); }
.dot.scope { fill: var(--series-2); }
.cross { stroke: var(--axis); stroke-width: 1; }
.hit { fill: transparent; }

.tip {
  position: absolute;
  display: none;
  pointer-events: none;
  background: var(--raised);
  color: var(--text-primary);
  border: 1px solid var(--axis);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.12);
  white-space: nowrap;
}
.tip.on { display: block; }
.tip-date { color: var(--text-secondary); margin-bottom: 2px; }
.tip .row { display: flex; gap: 12px; justify-content: space-between; }
.tip .val { font-variant-numeric: tabular-nums; font-weight: 600; }

.table-view { margin-top: 16px; color: var(--text-secondary); }
.table-view summary { cursor: pointer; }
table { border-collapse: collapse; margin-top: 8px; font-variant-numeric: tabular-nums; font-size: 12px; }
th, td { padding: 2px 12px 2px 0; text-align: right; }
th:first-child, td:first-child { text-align: left; }
.notes { color: var(--text-muted); font-size: 12px; margin-top: 16px; padding-left: 18px; }
