:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #16191d;
  --muted: #5d6670;
  --border: #dde1e6;
  --grid: #e9ecef;
  --accent: #0b6bcb;
  --accent-text: #ffffff;
  --line: #0b6bcb;
  --band: rgba(11, 107, 203, 0.16);
  --ok: #1a7f37;
  --ok-bg: #dcf5e3;
  --warn: #9a5b00;
  --warn-bg: #fff1d6;
  --bad: #b42318;
  --bad-bg: #fde4e1;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1215;
    --surface: #171b20;
    --text: #e6e9ec;
    --muted: #98a1ab;
    --border: #2a3038;
    --grid: #232930;
    --accent: #4ea1ff;
    --accent-text: #0b1520;
    --line: #4ea1ff;
    --band: rgba(78, 161, 255, 0.20);
    --ok: #5fd67f;
    --ok-bg: #12301c;
    --warn: #f2b44c;
    --warn-bg: #352610;
    --bad: #ff8577;
    --bad-bg: #3a1714;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1215;
  --surface: #171b20;
  --text: #e6e9ec;
  --muted: #98a1ab;
  --border: #2a3038;
  --grid: #232930;
  --accent: #4ea1ff;
  --accent-text: #0b1520;
  --line: #4ea1ff;
  --band: rgba(78, 161, 255, 0.20);
  --ok: #5fd67f;
  --ok-bg: #12301c;
  --warn: #f2b44c;
  --warn-bg: #352610;
  --bad: #ff8577;
  --bad-bg: #3a1714;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.top, main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 24px;
  padding-bottom: 16px;
}

h1 { margin: 0; font-size: 1.5rem; font-weight: 650; }
.sub { margin: 2px 0 0; color: var(--muted); }

.pill {
  white-space: nowrap;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid transparent;
}
.pill-wait { color: var(--muted); border-color: var(--border); }
.pill-ok   { color: var(--ok); background: var(--ok-bg); }
.pill-warn { color: var(--warn); background: var(--warn-bg); }
.pill-bad  { color: var(--bad); background: var(--bad-bg); }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat, .card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.stat { padding: 14px 16px; display: flex; flex-direction: column; }
.label { color: var(--muted); font-size: 0.85rem; }
.value { font-size: 1.6rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.meta  { color: var(--muted); font-size: 0.8rem; }

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.seg { display: flex; flex-wrap: wrap; gap: 4px; }

button, .btn, select, input {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

button, .btn {
  padding: 6px 12px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button:hover, .btn:hover { border-color: var(--accent); }
button:focus-visible, .btn:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.seg button.active, button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

select, input { padding: 5px 8px; }
.refresh { color: var(--muted); display: flex; align-items: center; gap: 6px; }

.custom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.custom[hidden] { display: none; }
.custom label { display: flex; align-items: center; gap: 6px; color: var(--muted); }

.chart-card { position: relative; padding: 8px; margin-bottom: 16px; }
#chart { width: 100%; height: 460px; }
.empty {
  position: absolute;
  inset: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  pointer-events: none;
}
.empty[hidden] { display: none; }

.downloads { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }

.foot { color: var(--muted); font-size: 0.85rem; padding-bottom: 32px; max-width: 75ch; }

@media (max-width: 600px) {
  #chart { height: 340px; }
  .value { font-size: 1.35rem; }
  .top { align-items: flex-start; }
}
