/* ---------- fonts ----------
   Barlow Condensed (SIL Open Font License, see fonts/OFL.txt) is nopixel.net's heading face.
   Self-hosted latin subset, semibold + bold only. */
@font-face {
  font-family: "Barlow Condensed";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url(/fonts/BarlowCondensed-600.woff2?v=7324ea124b) format("woff2");
}
@font-face {
  font-family: "Barlow Condensed";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(/fonts/BarlowCondensed-700.woff2?v=7324ea124b) format("woff2");
}

/* ---------- tokens ----------
   Dark-first, built from nopixel.net's palette: ink #0c0c0c, shade-900 #121315, shade-800 #202226,
   shade-700 #2c3035, shade-600 #383c42, shade-400 #919296, paper #fefefe, brand mint #00f8b9,
   brand-2 cyan #40e5ff. The chart line uses a darker mint step that passes the data-viz lightness
   and contrast checks; the pure brand mint is reserved for accents and translucent washes. */
:root, :root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c0c0c;
  --surface: #121315;
  --surface-2: #202226;
  --ink: #fefefe;
  --ink-2: #c9cbcf;
  --muted: #919296;
  --line: rgba(254, 254, 254, .10);
  --grid: #202226;
  --axis: #383c42;
  --accent: #00f8b9;
  --accent-2: #40e5ff;
  --accent-wash: rgba(0, 248, 185, .14);
  --series: #00ad80;
  --series-wash: #00f8b9;
  --good: #57c98a;
  --good-text: #57c98a;
  --good-ring: rgba(87, 201, 138, .22);
  --warn: #f7c600;
  --bad: #e22631;
  --shadow: 0 6px 18px rgba(0, 0, 0, .55);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Barlow Condensed", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 10px;
  --focus: 0 0 0 3px rgba(0, 248, 185, .45);
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f4f4;
  --surface: #fefefe;
  --surface-2: #f4f4f4;
  --ink: #0c0c0c;
  --ink-2: #383c42;
  --muted: #66696f;
  --line: rgba(12, 12, 12, .10);
  --grid: #e4e4e5;
  --axis: #c9cacc;
  --accent: #00a87c;
  --accent-2: #0891b2;
  --accent-wash: rgba(0, 168, 124, .14);
  --series: #00a87c;
  --series-wash: #00a87c;
  --good: #1f9d5a;
  --good-text: #1a7f4a;
  --good-ring: rgba(31, 157, 90, .22);
  --warn: #c99a00;
  --bad: #e22631;
  --shadow: 0 4px 14px rgba(0, 0, 0, .12);
  --focus: 0 0 0 3px rgba(0, 168, 124, .40);
}
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    color-scheme: light;
    --bg: #f4f4f4;
    --surface: #fefefe;
    --surface-2: #f4f4f4;
    --ink: #0c0c0c;
    --ink-2: #383c42;
    --muted: #66696f;
    --line: rgba(12, 12, 12, .10);
    --grid: #e4e4e5;
    --axis: #c9cacc;
    --accent: #00a87c;
    --accent-2: #0891b2;
    --accent-wash: rgba(0, 168, 124, .14);
    --series: #00a87c;
    --series-wash: #00a87c;
    --good: #1f9d5a;
    --good-text: #1a7f4a;
    --good-ring: rgba(31, 157, 90, .22);
    --warn: #c99a00;
    --bad: #e22631;
    --shadow: 0 4px 14px rgba(0, 0, 0, .12);
    --focus: 0 0 0 3px rgba(0, 168, 124, .40);
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: underline; text-decoration-color: var(--axis); text-underline-offset: 2px; }
a:hover { text-decoration-color: var(--accent); }
button, input, select { font: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, canvas:focus-visible, tr:focus-visible, a:focus-visible {
  outline: none; box-shadow: var(--focus);
}
.muted { color: var(--muted); }
.page { max-width: 1120px; margin: 0 auto; padding: 24px 20px 40px; }

/* ---------- header ---------- */
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark { width: 38px; height: 38px; color: var(--accent); flex: none; }
.brand-mark path { stroke: var(--bg); }
h1 { font: 700 30px/1 var(--font-display); text-transform: uppercase; letter-spacing: .01em; margin: 0; }
.tagline { margin: 2px 0 0; color: var(--ink-2); font-size: 13px; }
.top-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.live { background: var(--good); box-shadow: 0 0 0 3px var(--good-ring); }
.dot.warn { background: var(--warn); }
.dot.err { background: var(--bad); }

.notice {
  background: var(--surface); border: 1px solid var(--bad); border-left-width: 4px; color: var(--ink);
  padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 13px;
}

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; position: relative; }
.tile .label { font: 600 13px/1.2 var(--font-display); text-transform: uppercase; letter-spacing: .07em; color: var(--ink-2); margin-bottom: 6px; }
.tile .value { font: 700 42px/1 var(--font-display); }
.tile.hero { padding-left: 22px; }
.tile.hero::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 4px; border-radius: 0 3px 3px 0; background: var(--accent); }
.tile.hero .value { font-size: 60px; }
.delta { font-size: 12px; color: var(--ink-2); margin-top: 4px; min-height: 18px; }
.delta.up { color: var(--good-text); }
.delta.down { color: var(--ink-2); }

/* ---------- controls ---------- */
.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 10px; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 2px; }
.seg button { font: 600 14px/1.2 var(--font-display); text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); background: transparent; border: 0; border-radius: 7px; padding: 6px 12px; cursor: pointer; }
.seg button:hover { color: var(--ink); background: var(--surface-2); }
.seg button[aria-pressed="true"] { background: var(--accent-wash); color: var(--ink); }
.seg-sm button { padding: 4px 9px; font-size: 13px; }
.btn { font: 600 14px/1.2 var(--font-display); text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 7px 13px; cursor: pointer; }
.btn:hover { color: var(--ink); border-color: var(--axis); }
.btn[aria-pressed="true"] { background: var(--accent-wash); color: var(--ink); }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
h2 { font: 600 21px/1.1 var(--font-display); text-transform: uppercase; letter-spacing: .02em; margin: 0; }
.card-sub { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-2); }

/* ---------- chart ---------- */
.chart-wrap { position: relative; height: 300px; }
.chart-wrap canvas { display: block; width: 100%; height: 100%; touch-action: pan-y; transition: opacity .2s; border-radius: 6px; }
.chart-wrap canvas.dim { opacity: .55; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 2; white-space: nowrap;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px;
  box-shadow: var(--shadow); font-size: 12px; line-height: 1.4;
}
.tip-v { font-weight: 600; font-size: 14px; color: var(--ink); }
.tip-t { color: var(--ink-2); }
.tip-m { color: var(--muted); margin-top: 2px; }
.chart-table { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.chart-table.raw .min, .chart-table.raw .max, .chart-table.raw .samples { display: none; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  position: sticky; top: 0; z-index: 1; background: var(--surface); text-align: left;
  font: 600 13px/1.2 var(--font-display); text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
  padding: 9px 10px; border-bottom: 1px solid var(--line);
}
td { padding: 8px 10px; border-bottom: 1px solid var(--grid); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- directory ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.toolbar input[type="search"] {
  font-size: 14px; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 9px;
  padding: 7px 12px; flex: 1 1 220px; min-width: 160px;
}
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); cursor: pointer; user-select: none; }
.check input { accent-color: var(--accent); margin: 0; }
.sort { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
select { font-size: 13px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; }
.table-wrap { max-height: 72vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.dir tr.row { cursor: pointer; }
.dir tr.row:hover td, .dir tr.row[aria-expanded="true"] td { background: var(--surface-2); }
.dir td.status { white-space: nowrap; width: 1%; }
.dir td.time { white-space: nowrap; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.badge.on { color: var(--good-text); }
.badge.off { color: var(--muted); font-weight: 500; }
.bdot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); flex: none; }
.since { display: block; font-size: 12px; color: var(--muted); }
.nm { font-weight: 600; }
.sub { display: block; font-size: 12px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 4px 5px; }
.chip { font-size: 12px; background: var(--surface-2); border-radius: 6px; padding: 1px 7px; color: var(--ink-2); }
.chip.on { background: var(--accent-wash); color: var(--ink); font-weight: 600; }
.chip.on::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--good); margin-right: 5px; vertical-align: 1px; }
.dir tr.detail td { background: var(--surface-2); padding: 10px 14px 12px 40px; }
.detail-head { font-size: 12.5px; color: var(--ink-2); margin-bottom: 6px; }
.sess { display: grid; grid-template-columns: 130px 1fr auto; gap: 10px; font-size: 12.5px; padding: 3px 0; font-variant-numeric: tabular-nums; }
.sess-dur { color: var(--ink-2); }
.empty { padding: 22px; text-align: center; color: var(--muted); margin: 0; }

footer { color: var(--muted); font-size: 12.5px; line-height: 1.6; margin-top: 22px; }
footer p { margin: 0 0 6px; }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .page { padding: 16px 12px 32px; }
  h1 { font-size: 26px; }
  .tile .value { font-size: 34px; }
  .tile.hero .value { font-size: 48px; }
  .chart-wrap { height: 240px; }
  .dir .time { display: none; }
  .sess { grid-template-columns: 1fr auto; }
  .sess-date { grid-column: 1 / -1; color: var(--muted); }
}
@media (prefers-reduced-motion: reduce) {
  .chart-wrap canvas { transition: none; }
}
