:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e2e1dc;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #77756f;
  --accent: #2a78d6;
  --ok: #2a78d6;
  --failed: #d03b3b;
  --good: #0ca30c;
  --warning: #b77900;
  --critical: #d03b3b;
  --grid: #e7e6e1;
  --bar: #86b6ef;
  --focus: #2a78d6;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111110;
    --surface: #1a1a19;
    --surface-2: #242422;
    --border: #33332f;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #9a998f;
    --accent: #5598e7;
    --ok: #3987e5;
    --failed: #e66767;
    --good: #2fbf2f;
    --warning: #fab219;
    --critical: #e66767;
    --grid: #2c2c29;
    --bar: #256abf;
    --focus: #6da7ec;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111110;
  --surface: #1a1a19;
  --surface-2: #242422;
  --border: #33332f;
  --text: #f0efec;
  --text-2: #c3c2b7;
  --muted: #9a998f;
  --accent: #5598e7;
  --ok: #3987e5;
  --failed: #e66767;
  --good: #2fbf2f;
  --warning: #fab219;
  --critical: #e66767;
  --grid: #2c2c29;
  --bar: #256abf;
  --focus: #6da7ec;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
button, input, select { font: inherit; color: inherit; }
button, select, input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  min-height: 34px;
}
button { cursor: pointer; }
button:hover { background: var(--surface-2); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--critical); }
button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
header {
  position: sticky; top: 0; z-index: 5;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
}
.bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.bar .grow { flex: 1 1 auto; }
h1 { font-size: 17px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 10px; }
main { padding: 16px; max-width: 1400px; margin: 0 auto; display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
main > *, .cols > *, .cards > * { min-width: 0; }
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  min-width: 0;
}
.panel-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.panel-head h2 { margin: 0; }
.cols { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); }
.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(140px, 100%), 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.card .label { color: var(--text-2); font-size: 12px; }
.card .value { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; }
.card .sub { color: var(--muted); font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.segmented { display: inline-flex; gap: 0; }
.segmented button { border-radius: 0; margin-left: -1px; }
.segmented button:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.segmented button:last-child { border-radius: 0 6px 6px 0; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.filters label { display: inline-flex; gap: 6px; align-items: center; color: var(--text-2); font-size: 12px; }
.filters select { max-width: 240px; }
.hidden { display: none !important; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: top; }
th { color: var(--text-2); font-weight: 600; font-size: 12px; }
td.num, th.num { text-align: right; }
td.wrap { white-space: normal; min-width: 220px; max-width: 520px; overflow-wrap: anywhere; }
tbody tr:hover { background: var(--surface-2); }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border); }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.pill.good::before { background: var(--good); }
.pill.warning::before { background: var(--warning); }
.pill.critical::before { background: var(--critical); }
.actions { display: flex; gap: 6px; }
.actions button { min-height: 28px; padding: 2px 8px; font-size: 12px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.swatch.ok { background: var(--ok); }
.swatch.failed { background: var(--failed); }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: 240px; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .ok { fill: var(--ok); }
.chart .failed { fill: var(--failed); }
.chart .hit { fill: transparent; }
.chart .hit:hover { fill: var(--text); fill-opacity: .06; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 3;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 9px; font-size: 12px; box-shadow: 0 4px 14px rgba(0,0,0,.15);
  white-space: nowrap;
}
.hbars { display: grid; gap: 6px; }
.hbar { display: grid; grid-template-columns: minmax(110px, 160px) 1fr auto; gap: 8px; align-items: center; font-size: 13px; }
.hbar .track { background: var(--surface-2); border-radius: 4px; height: 12px; overflow: hidden; }
.hbar .fill { background: var(--bar); height: 100%; border-radius: 0 4px 4px 0; }
.hbar .fill.client { background: var(--muted); opacity: .55; }
.hbar .count { font-variant-numeric: tabular-nums; color: var(--text-2); }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; }
dl.kv dt { color: var(--text-2); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
.status-line { font-size: 12px; color: var(--text-2); }
.error-banner { background: var(--surface); border: 1px solid var(--critical); color: var(--critical); border-radius: 8px; padding: 8px 12px; }
.pager { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
#login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
#login form { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 22px; width: min(420px, 100%); display: grid; gap: 12px; }
#login input { width: 100%; }
#custom-range input { max-width: 210px; }
@media (max-width: 640px) {
  header { position: static; }
  .card .value { font-size: 20px; }
  .filters select { max-width: 100%; }
  .filters label { flex: 1 1 140px; }
  .filters label select { flex: 1 1 auto; min-width: 0; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hbar { grid-template-columns: 100px 1fr auto; }
}
