:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #7a7873;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --good: #0ca30c;
  --good-ink: #006300;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --critical-ink: #b42727;
  --link: #1c5cab;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #9a988f;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --good-ink: #0ca30c;
    --critical-ink: #e66767;
    --link: #86b6ef;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232321;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #9a988f;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --good-ink: #0ca30c;
  --critical-ink: #e66767;
  --link: #86b6ef;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.45 var(--font);
}
a { color: var(--link); }
code { font-family: var(--mono); font-size: 0.9em; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.25rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 0.95rem; }

.top, .filters, main, footer { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.top {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 8px 24px; padding-top: 20px; padding-bottom: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.sub { margin: 2px 0 0; color: var(--ink-2); font-size: 0.85rem; }
.updated { margin: 0; color: var(--muted); font-size: 0.8rem; }

.filters {
  display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: end;
  padding-top: 8px; padding-bottom: 16px;
  position: sticky; top: 0; z-index: 5; background: var(--page);
  border-bottom: 1px solid var(--border);
}
.field { display: flex; flex-direction: column; gap: 4px; font-size: 0.75rem; color: var(--ink-2); }
select, .seg button {
  font: inherit; font-size: 0.875rem; color: var(--ink); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; min-height: 34px;
}
select { min-width: 200px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; cursor: pointer; padding: 6px 14px; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-checked="true"] { background: var(--ink); color: var(--page); font-weight: 600; }
.seg button:focus-visible, select:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; }

main { display: flex; flex-direction: column; gap: 32px; padding-top: 20px; padding-bottom: 32px; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; margin-bottom: 12px; }
.hint { margin: 0; color: var(--muted); font-size: 0.8rem; }
.empty, .notice { color: var(--ink-2); }
.notice {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; margin: 0;
}
.notice strong { color: var(--ink); }
.stale { opacity: 0.55; transition: opacity 0.2s; }

.grid { display: grid; gap: 12px; }
.tiles { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.cards { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.charts { grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); }
.stack > * + * { margin-top: 12px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; min-width: 0;
}
.card h3 { margin-bottom: 8px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.card-head h3 { margin: 0; }
button.card { text-align: left; font: inherit; color: inherit; cursor: pointer; width: 100%; }
button.card:hover { border-color: var(--axis); }

.tile .label { color: var(--ink-2); font-size: 0.8rem; }
.tile .value { font-size: 1.6rem; font-weight: 600; line-height: 1.2; margin-top: 2px; overflow-wrap: anywhere; }
.tile .value small { font-size: 0.85rem; font-weight: 500; color: var(--ink-2); }
.tile .detail { color: var(--muted); font-size: 0.78rem; margin-top: 4px; overflow-wrap: anywhere; }
.tile .spark { display: block; width: 100%; height: 32px; margin-top: 6px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 600;
  padding: 2px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2);
  white-space: nowrap;
}
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--muted); }
.s-good .dot { background: var(--good); }
.s-warning .dot { background: var(--warning); }
.s-serious .dot { background: var(--serious); }
.s-critical .dot { background: var(--critical); }
.s-unknown .dot { background: var(--muted); }

dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0; font-size: 0.85rem; }
dl.kv dt { color: var(--ink-2); }
dl.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 0.8rem; }
.err { color: var(--critical-ink); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th, td { padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th { color: var(--ink-2); font-weight: 500; font-size: 0.78rem; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
tr:last-child td { border-bottom: 0; }
.bar-cell { width: 18%; min-width: 48px; }
.bar { height: 8px; border-radius: 4px; background: var(--series-1); min-width: 2px; }

.errors { list-style: none; margin: 0; padding: 0; font-size: 0.85rem; }
.errors li { padding: 6px 0; border-bottom: 1px solid var(--grid); overflow-wrap: anywhere; }
.errors li:last-child { border-bottom: 0; }
.errors .when { color: var(--muted); font-size: 0.78rem; margin-right: 8px; }

.progress { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.progress > div { height: 100%; background: var(--series-1); border-radius: 4px; }

.share { display: flex; height: 14px; gap: 2px; margin: 8px 0 6px; }
.share > div { border-radius: 4px; min-width: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.78rem; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.key { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.key.line { height: 2px; width: 14px; border-radius: 1px; }
.c1 { background: var(--series-1); }
.c2 { background: var(--series-2); }
.c3 { background: var(--series-3); }

.chart { position: relative; }
.chart { min-height: 180px; }
.chart svg { display: block; max-width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { opacity: 0.12; }
.chart .cross { stroke: var(--ink-2); stroke-width: 1; }
.chart .hover-dot { stroke: var(--surface); stroke-width: 2; }

.tooltip {
  position: fixed; z-index: 20; pointer-events: none; background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 0.8rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15); min-width: 140px;
}
.tooltip .t { color: var(--muted); margin-bottom: 4px; }
.tooltip .row { display: flex; align-items: center; gap: 8px; }
.tooltip .row strong { font-variant-numeric: tabular-nums; }
.tooltip .row span:last-child { color: var(--ink-2); }

footer { color: var(--muted); font-size: 0.8rem; padding-bottom: 32px; }
footer p { margin: 0; overflow-wrap: anywhere; }

@media (max-width: 560px) {
  .filters { position: static; }
  .tile .value { font-size: 1.3rem; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  select { min-width: 0; width: 100%; }
  .filters .field:first-child { flex: 1 1 100%; }
}
