:root {
  color-scheme: light;
  --plane: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --series-1: #2a78d6;
  --series-1-soft: #cde2fb;
  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --critical: #d03b3b;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.05), 0 8px 24px rgba(11, 11, 11, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --plane: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --ink-muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --series-1: #3987e5;
    --series-1-soft: #184f95;
    --good-text: #0ca30c;
    --shadow: none;
  }
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --plane: #0d0d0d;
  --surface: #1a1a19;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --ink-muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --series-1: #3987e5;
  --series-1-soft: #184f95;
  --good-text: #0ca30c;
  --shadow: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--plane);
  color: var(--ink);
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.wrap { max-width: 1400px; margin: 0 auto; padding: 24px 20px 64px; }

/* ---------- header ---------- */

header.top {
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
header.top h1 { font-size: 19px; margin: 0; letter-spacing: -0.01em; }
header.top .sub { color: var(--ink-muted); font-size: 12.5px; margin-top: 2px; }
.auth { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

input, select, button {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
}
input::placeholder { color: var(--ink-muted); }
input:focus-visible, select:focus-visible, button:focus-visible {
  outline: 2px solid var(--series-1); outline-offset: 1px;
}
button { cursor: pointer; }
button:hover { background: var(--plane); }
button.primary { background: var(--series-1); border-color: var(--series-1); color: #fff; }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--critical); }
button.sm { padding: 4px 8px; font-size: 12.5px; border-radius: 6px; }

/* ---------- tabs ---------- */

nav.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--grid); margin-bottom: 20px; }
nav.tabs button {
  background: none; border: none; border-bottom: 2px solid transparent;
  border-radius: 0; padding: 9px 14px; color: var(--ink-2);
}
nav.tabs button:hover { color: var(--ink); background: none; }
nav.tabs button[aria-selected='true'] { color: var(--ink); border-bottom-color: var(--series-1); font-weight: 600; }

.panel[hidden] { display: none; }

/* ---------- cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-muted); margin: 0 0 14px; font-weight: 600;
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; }

/* ---------- stat tiles ---------- */

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow);
}
.tile .label { font-size: 12px; color: var(--ink-muted); }
.tile .value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; margin-top: 2px; }
.tile .foot { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.tile .foot.bad { color: var(--critical); }
.tile .foot.ok { color: var(--good-text); }

/* ---------- chart ---------- */

.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.legend { display: flex; gap: 16px; align-items: center; font-size: 12.5px; color: var(--ink-2); margin-bottom: 10px; }
.legend .item { display: flex; gap: 6px; align-items: center; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.tooltip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: 12.5px; white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  transform: translate(-50%, -100%);
}
.tooltip[hidden] { display: none; }
.tooltip .t-title { font-weight: 600; margin-bottom: 4px; }
.tooltip .t-row { display: flex; gap: 10px; justify-content: space-between; color: var(--ink-2); }
.tooltip .t-row b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- tables ---------- */

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--ink-muted); font-weight: 600; padding: 6px 10px 8px; border-bottom: 1px solid var(--grid);
  white-space: nowrap;
}
td { padding: 8px 10px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--plane); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; }
.mono { font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--ink-muted); }
.nowrap { white-space: nowrap; }
.empty { padding: 28px 10px; text-align: center; color: var(--ink-muted); }

/* share bar inside table rows */
.share { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.share .track { flex: 1; height: 6px; border-radius: 3px; background: var(--grid); overflow: hidden; }
.share .fill { height: 100%; border-radius: 3px; background: var(--series-1); }

/* ---------- pills ---------- */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  border: 1px solid var(--border); color: var(--ink-2); white-space: nowrap;
}
.pill.ok { color: var(--good-text); border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.pill.fail { color: var(--critical); border-color: color-mix(in srgb, var(--critical) 45%, transparent); }
.pill.admin { color: var(--series-1); border-color: color-mix(in srgb, var(--series-1) 45%, transparent); }
.pill.off { color: var(--ink-muted); }

/* ---------- forms ---------- */

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.nowrap { flex-wrap: nowrap; }
.row.end { justify-content: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 11.5px; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }

/* ---------- toast + gate ---------- */

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: var(--plane);
  padding: 9px 16px; border-radius: 999px; font-size: 13px; z-index: 50;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}
#toast[hidden] { display: none; }
#toast.bad { background: var(--critical); color: #fff; }

.gate { max-width: 420px; margin: 12vh auto; text-align: center; }
.gate .card { text-align: left; }
.gate h1 { font-size: 20px; margin: 0 0 6px; }
.gate p { color: var(--ink-2); margin: 0 0 16px; font-size: 13px; }
