/* Peekie Analytics — light/dark token system. Chart colors follow the validated reference palette. */
:root {
  color-scheme: light;
  --page: #f4f4f1;
  --surface: #fcfcfb;
  --surface-2: #f4f3ef;
  --raised: #ffffff;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.09);
  --border-strong: rgba(11, 11, 11, 0.16);
  --hover: rgba(11, 11, 11, 0.04);
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --accent-wash: rgba(42, 120, 214, 0.10);
  --accent-bar: rgba(42, 120, 214, 0.13);
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --prev: #b3b1a9;
  --up: #006300;
  --down: #d03b3b;
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --seq-0: #e9e8e3;
  --seq-1: #cde2fb; --seq-2: #9ec5f4; --seq-3: #6da7ec; --seq-4: #3987e5; --seq-5: #256abf; --seq-6: #184f95;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 4px 16px rgba(11, 11, 11, 0.04);
  --shadow-lg: 0 12px 40px rgba(11, 11, 11, 0.14), 0 2px 6px rgba(11, 11, 11, 0.06);
  --glow: radial-gradient(900px 320px at 18% -80px, rgba(42, 120, 214, 0.10), transparent 70%),
          radial-gradient(700px 260px at 92% -120px, rgba(27, 175, 122, 0.06), transparent 70%);
  --radius: 14px;
  --radius-sm: 9px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #222220; --raised: #242422;
    --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781; --grid: #2c2c2a; --axis: #383835;
    --border: rgba(255, 255, 255, 0.08); --border-strong: rgba(255, 255, 255, 0.16); --hover: rgba(255, 255, 255, 0.05);
    --accent: #3987e5; --accent-ink: #86b6ef; --accent-wash: rgba(57, 135, 229, 0.14); --accent-bar: rgba(57, 135, 229, 0.20);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --prev: #5b5a55; --up: #0ca30c; --down: #e66767;
    --seq-0: #262624;
    --seq-1: #104281; --seq-2: #1c5cab; --seq-3: #2a78d6; --seq-4: #5598e7; --seq-5: #86b6ef; --seq-6: #cde2fb;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 20px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.6), 0 2px 8px rgba(0, 0, 0, 0.4);
    --glow: radial-gradient(900px 340px at 18% -80px, rgba(57, 135, 229, 0.16), transparent 70%),
            radial-gradient(700px 280px at 92% -120px, rgba(25, 158, 112, 0.09), transparent 70%);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #222220; --raised: #242422;
  --ink: #ffffff; --ink-2: #c3c2b7; --muted: #898781; --grid: #2c2c2a; --axis: #383835;
  --border: rgba(255, 255, 255, 0.08); --border-strong: rgba(255, 255, 255, 0.16); --hover: rgba(255, 255, 255, 0.05);
  --accent: #3987e5; --accent-ink: #86b6ef; --accent-wash: rgba(57, 135, 229, 0.14); --accent-bar: rgba(57, 135, 229, 0.20);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --prev: #5b5a55; --up: #0ca30c; --down: #e66767;
  --seq-0: #262624;
  --seq-1: #104281; --seq-2: #1c5cab; --seq-3: #2a78d6; --seq-4: #5598e7; --seq-5: #86b6ef; --seq-6: #cde2fb;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 20px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.6), 0 2px 8px rgba(0, 0, 0, 0.4);
  --glow: radial-gradient(900px 340px at 18% -80px, rgba(57, 135, 229, 0.16), transparent 70%),
          radial-gradient(700px 280px at 92% -120px, rgba(25, 158, 112, 0.09), transparent 70%);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font: 14px/1.45 var(--font); color: var(--ink); background: var(--page);
  -webkit-font-smoothing: antialiased; min-height: 100vh;
}
[hidden] { display: none !important; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.ink2 { color: var(--ink-2); }
.num { font-variant-numeric: tabular-nums; }
.mono, code, pre { font-family: var(--mono); font-size: 12.5px; }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---- Auth ---------------------------------------------------------------- */
body.auth { display: grid; place-items: center; padding: 24px 16px; background: var(--glow), var(--page); }
.auth-card {
  width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  padding: 36px 32px 28px; box-shadow: var(--shadow-lg);
}
.auth-card h1 { font-size: 22px; font-weight: 650; margin: 26px 0 4px; letter-spacing: -0.01em; }
.auth-card form { display: grid; gap: 12px; margin-top: 22px; }
.auth-card input { width: 100%; }
.auth-warn { display: flex; gap: 8px; align-items: flex-start; color: var(--ink-2); font-size: 12.5px; margin: 18px 0 0; }
.auth-warn svg { color: var(--warning); margin-top: 1px; flex: none; }
.code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; overflow-x: auto; }

/* ---- Brand ---------------------------------------------------------------- */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -0.02em; }
.brand img { border-radius: 8px; box-shadow: 0 4px 14px rgba(42, 120, 214, 0.35); }
.brand-lg { font-size: 22px; }

/* ---- Controls ---------------------------------------------------------------- */
input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  background: var(--raised); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 9px 12px; min-height: 38px; outline: none; transition: border-color .15s, box-shadow .15s; max-width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; padding: 7px 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--raised); color: var(--ink);
  cursor: pointer; font-weight: 550; font-size: 13.5px; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--hover); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: transparent; color: #fff; box-shadow: 0 2px 10px rgba(42, 120, 214, .3); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--down); }
.btn-danger.confirm { background: var(--critical); color: #fff; border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { color: var(--ink); }
.btn-sm { min-height: 30px; padding: 4px 10px; font-size: 12.5px; }
.btn-icon { width: 36px; padding: 0; }
.btn-block { width: 100%; min-height: 42px; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 36px; height: 20px; border-radius: 20px; background: var(--grid); position: relative; transition: background .2s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- Shell ---------------------------------------------------------------- */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 18px; padding: 20px 14px 16px;
  border-right: 1px solid var(--border); background: var(--surface);
}
.sidebar .brand { padding: 2px 8px 0; }
.site-switch { position: relative; }
.site-switch select { width: 100%; appearance: none; padding-right: 32px; font-weight: 600; background: var(--surface-2); border-color: var(--border); cursor: pointer; }
.site-switch::after { content: ""; position: absolute; right: 13px; top: 50%; width: 7px; height: 7px; border: solid var(--muted); border-width: 0 1.8px 1.8px 0; transform: translateY(-70%) rotate(45deg); pointer-events: none; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 9px; color: var(--ink-2); font-weight: 520;
  transition: background .12s, color .12s;
}
.nav a:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
.nav a.active { background: var(--accent-wash); color: var(--accent-ink); }
.nav a .badge { margin-left: auto; }
.nav-sep { height: 1px; background: var(--border); margin: 8px 6px; }
.sidebar-foot { margin-top: auto; display: flex; gap: 6px; align-items: center; padding: 0 4px; }
.theme-seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 2px; }
.theme-seg button { border: 0; background: transparent; width: 32px; height: 28px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); cursor: pointer; }
.theme-seg button.on { background: var(--raised); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.sidebar-foot .btn-ghost { margin-left: auto; }

.main { min-width: 0; background: var(--glow); background-repeat: no-repeat; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px;
  padding: 14px 28px; background: color-mix(in srgb, var(--page) 78%, transparent); backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--border); }
.topbar h1 { font-size: 20px; font-weight: 680; letter-spacing: -0.02em; margin: 0 8px 0 0; }
.topbar .spacer { flex: 1; }
.menu-btn { display: none; }
.content { padding: 8px 28px 48px; display: grid; gap: 18px; max-width: 1480px; }

.live-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--surface);
  border: 1px solid var(--border); font-weight: 600; font-size: 13px; color: var(--ink); cursor: pointer; box-shadow: var(--shadow);
}
.live-pill:hover { text-decoration: none; border-color: var(--border-strong); }
.pulse { position: relative; width: 8px; height: 8px; border-radius: 50%; background: var(--good); flex: none; }
.pulse::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--good); opacity: 0; animation: pulse 2s infinite; }
@keyframes pulse { 0% { transform: scale(.5); opacity: .8; } 100% { transform: scale(1.6); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .pulse::after { animation: none; } }

/* ---- Date picker & filters ---------------------------------------------------- */
.dropdown { position: relative; }
.menu {
  position: absolute; z-index: 50; top: calc(100% + 6px); right: 0; min-width: 240px; background: var(--raised); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; animation: pop .14s ease-out;
}
.menu.left { right: auto; left: 0; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
.menu button.row {
  display: flex; width: 100%; align-items: center; gap: 10px; border: 0; background: transparent; padding: 8px 10px; border-radius: 8px;
  cursor: pointer; text-align: left; color: var(--ink);
}
.menu button.row:hover { background: var(--hover); }
.menu button.row .check { width: 16px; color: var(--accent); font-weight: 800; }
.menu button.row kbd { margin-left: auto; }
.menu .foot { border-top: 1px solid var(--border); margin-top: 6px; padding: 10px 8px 4px; display: grid; gap: 8px; }
.menu .foot .dates { display: flex; gap: 6px; align-items: center; }
.menu .foot input[type=date] { flex: 1; min-width: 0; padding: 6px 8px; min-height: 34px; }
kbd { font: 11px var(--mono); color: var(--muted); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 360px; padding: 5px 6px 5px 11px; border-radius: 999px;
  background: var(--accent-wash); color: var(--accent-ink); font-size: 12.5px; font-weight: 560; border: 1px solid transparent;
}
.chip .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .op { opacity: .7; font-weight: 450; }
.chip button { border: 0; background: transparent; color: inherit; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; padding: 0; }
.chip button:hover { background: rgba(127, 127, 127, .2); }

/* ---- Cards ---------------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  min-width: 0; position: relative; transition: opacity .2s;
}
.loading .card { opacity: .55; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px 10px; flex-wrap: wrap; }
.card-head h2 { font-size: 14.5px; font-weight: 650; margin: 0; letter-spacing: -0.01em; }
.card-head .sub { color: var(--muted); font-size: 12.5px; }
.card-head .right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.card-body { padding: 4px 18px 16px; }
.grid-2 { display: grid; gap: 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: 18px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }

.tabs { display: inline-flex; gap: 2px; background: var(--surface-2); border-radius: 9px; padding: 2px; border: 1px solid var(--border); }
.tabs button { border: 0; background: transparent; color: var(--muted); padding: 4px 10px; border-radius: 7px; font-size: 12.5px; font-weight: 580; cursor: pointer; }
.tabs button:hover { color: var(--ink); }
.tabs button.on { background: var(--raised); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }

/* ---- KPI tiles ---------------------------------------------------------------- */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); border-bottom: 1px solid var(--border); }
.kpi {
  position: relative; text-align: left; border: 0; background: transparent; padding: 16px 18px 14px; cursor: pointer; min-width: 0;
  border-right: 1px solid var(--border); transition: background .15s;
}
.kpi:last-child { border-right: 0; }
.kpi:hover { background: var(--hover); }
.kpi:first-child { border-top-left-radius: var(--radius); }
.kpi:last-child { border-top-right-radius: var(--radius); }
.kpi.on::after { content: ""; position: absolute; left: 18px; right: 18px; bottom: -1px; height: 2px; background: var(--accent); border-radius: 2px; }
.kpi .label { color: var(--ink-2); font-size: 12.5px; font-weight: 560; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .value { font-size: 26px; font-weight: 680; letter-spacing: -0.03em; margin-top: 4px; display: block; line-height: 1.15; }
.kpi .meta { display: flex; align-items: center; gap: 8px; margin-top: 4px; min-height: 20px; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; font-weight: 650; }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }
.delta.flat { color: var(--muted); }
.kpi .spark { position: absolute; right: 14px; bottom: 14px; width: 64px; height: 22px; opacity: .9; }

/* ---- Charts ---------------------------------------------------------------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .crosshair { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { opacity: .12; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .bar { transition: opacity .12s; }
.chart .bar:hover, .chart .bar.hl { opacity: .78; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--ink-2); padding: 0 18px 4px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend .key { width: 14px; height: 2px; border-radius: 2px; display: inline-block; }
.legend .swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.main-chart { padding: 10px 18px 10px 6px; }

#tooltip {
  position: fixed; z-index: 100; pointer-events: none; background: var(--raised); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-lg); padding: 9px 12px; font-size: 12.5px; min-width: 120px; max-width: 320px;
}
#tooltip .tt-title { color: var(--muted); font-size: 11.5px; margin-bottom: 5px; font-weight: 560; }
#tooltip .tt-row { display: flex; align-items: center; gap: 8px; margin-top: 3px; }
#tooltip .tt-row .v { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
#tooltip .tt-row .n { color: var(--ink-2); }
#tooltip .tt-key { width: 12px; height: 2px; border-radius: 2px; flex: none; }

/* ---- Bar lists (panels) -------------------------------------------------------- */
.list-head { display: flex; gap: 12px; color: var(--muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: 2px 0 6px; }
.list-head .grow { flex: 1; }
.list-head .c, .bl-row .c { width: 64px; text-align: right; flex: none; }
.list-head .c.w, .bl-row .c.w { width: 72px; }
.bl { display: grid; gap: 3px; }
.bl-row {
  position: relative; display: flex; align-items: center; gap: 12px; min-height: 32px; border-radius: 7px; cursor: pointer;
  background: transparent; border: 0; width: 100%; text-align: left; padding: 0; color: inherit;
}
.bl-row:hover .bl-bar { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.bl-row:hover .bl-label .ext { opacity: 1; }
.bl-label { position: relative; flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 10px; }
.bl-bar { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 6px; background: var(--accent-bar); transition: width .4s cubic-bezier(.2,.7,.2,1), background .15s; }
.bl-label .txt { position: relative; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bl-label .ext { position: relative; opacity: 0; color: var(--muted); display: inline-flex; transition: opacity .15s; }
.bl-label .ico { position: relative; display: inline-flex; color: var(--ink-2); flex: none; }
.bl-row .c { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--ink); }
.bl-row .c.dim { color: var(--muted); }
.flag { width: 20px; height: 15px; border-radius: 3px; object-fit: cover; flex: none; box-shadow: 0 0 0 1px var(--border); position: relative; }
.empty { color: var(--muted); padding: 28px 8px; text-align: center; font-size: 13px; }
.empty .big { display: block; font-size: 15px; color: var(--ink-2); font-weight: 600; margin-bottom: 4px; }
.more { display: flex; justify-content: center; padding-top: 8px; }

/* ---- Map ---------------------------------------------------------------- */
.map-wrap { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.map svg { width: 100%; height: auto; display: block; }
.map path { stroke: var(--surface); stroke-width: .6; transition: filter .15s; cursor: pointer; }
.map path:hover { filter: brightness(1.15) saturate(1.1); stroke: var(--ink); stroke-width: 1; }
.scale { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); margin-top: 8px; }
.scale .steps { display: flex; gap: 2px; }
.scale .steps i { width: 22px; height: 8px; border-radius: 2px; display: block; }

/* ---- Heatmap ---------------------------------------------------------------- */
.heat { display: grid; grid-template-columns: 34px repeat(24, minmax(0, 1fr)); gap: 3px; font-size: 11px; color: var(--muted); }
.heat .cell { aspect-ratio: 1.6; border-radius: 4px; min-height: 10px; }
.heat .cell:hover { outline: 2px solid var(--ink); outline-offset: 0; }
.heat .hl { text-align: center; font-variant-numeric: tabular-nums; }
.heat .dl { display: flex; align-items: center; }

/* ---- Tables ---------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; color: var(--muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.t td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t td.r, table.t th.r { text-align: right; font-variant-numeric: tabular-nums; }
table.t tbody tr.click { cursor: pointer; }
table.t tbody tr.click:hover td { background: var(--hover); }
table.t .trunc { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--border); white-space: nowrap; }
.pill.accent { background: var(--accent-wash); color: var(--accent-ink); border-color: transparent; }
.badge { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--accent-wash); color: var(--accent-ink); }

/* ---- Realtime ---------------------------------------------------------------- */
.hero { font-size: 64px; font-weight: 720; letter-spacing: -0.04em; line-height: 1; }
.rt-top { display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); }
.rt-top > div { padding: 20px 22px; }
.rt-top > div + div { border-left: 1px solid var(--border); }
.feed { display: grid; gap: 0; max-height: 620px; overflow-y: auto; }
.feed-item { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--border); animation: slidein .35s ease-out; }
.feed-item:last-child { border-bottom: 0; }
.feed-ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-wash); color: var(--accent-ink); }
.feed-ico.ev { background: color-mix(in srgb, var(--s2) 14%, transparent); color: var(--s2); }
.feed-main { min-width: 0; }
.feed-main .p { font-weight: 580; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-main .m { color: var(--muted); font-size: 12px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.feed-time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
@keyframes slidein { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---- Vitals ---------------------------------------------------------------- */
.vitals { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 18px; }
.vital { padding: 16px 18px; cursor: pointer; text-align: left; border: 1px solid var(--border); font: inherit; color: inherit; }
.vital.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash), var(--shadow); }
.vital .name { display: flex; align-items: baseline; gap: 6px; }
.vital .name b { font-size: 13px; }
.vital .name span { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vital .val { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; margin: 8px 0 6px; }
.vital .val small { font-size: 14px; color: var(--ink-2); font-weight: 600; margin-left: 2px; letter-spacing: 0; }
.rating { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 650; color: var(--ink-2); }
.rating i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.rating.good i { background: var(--good); } .rating.ni i { background: var(--warning); border-radius: 2px; transform: rotate(45deg); } .rating.poor i { background: var(--critical); border-radius: 1px; }
.dist { display: flex; gap: 2px; height: 8px; margin: 12px 0 6px; border-radius: 4px; overflow: hidden; }
.dist span { display: block; height: 100%; min-width: 0; }
.dist .g { background: var(--good); } .dist .n { background: var(--warning); } .dist .p { background: var(--critical); }
.dist-legend { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---- Stacked part-to-whole bar ---------------------------------------------- */
.stack { display: flex; gap: 2px; height: 10px; border-radius: 5px; overflow: hidden; margin: 6px 0 14px; }
.stack span { height: 100%; }

/* ---- Modal & drawer ---------------------------------------------------------- */
.overlay { position: fixed; inset: 0; z-index: 80; background: rgba(8, 8, 10, .45); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 16px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(760px, 100%); max-height: min(86vh, 900px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg); animation: pop .18s ease-out; }
.modal.sm { width: min(460px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 650; }
.modal-head .right { margin-left: auto; display: flex; gap: 6px; }
.modal-body { padding: 16px 20px 20px; overflow-y: auto; }
.drawer-overlay { place-items: stretch end; padding: 0; }
.drawer { width: min(560px, 100vw); height: 100%; background: var(--surface); border-left: 1px solid var(--border); display: flex; flex-direction: column; animation: slide .22s cubic-bezier(.2,.7,.2,1); }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.timeline { position: relative; display: grid; gap: 0; margin-top: 8px; }
.tl-item { position: relative; display: grid; grid-template-columns: 58px 22px minmax(0, 1fr); gap: 10px; padding: 8px 0; }
.tl-item .time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; padding-top: 2px; }
.tl-item .dotcol { position: relative; display: flex; justify-content: center; }
.tl-item .dotcol::before { content: ""; position: absolute; top: 0; bottom: -8px; width: 2px; background: var(--grid); }
.tl-item:first-child .dotcol::before { top: 10px; }
.tl-item:last-child .dotcol::before { bottom: calc(100% - 10px); }
.tl-item .dotcol i { position: relative; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); margin-top: 4px; box-shadow: 0 0 0 3px var(--surface); }
.tl-item.ev .dotcol i { background: var(--s2); border-radius: 3px; }
.tl-item .what { min-width: 0; }
.tl-item .what .p { font-weight: 600; word-break: break-all; }
.tl-item .what .m { color: var(--muted); font-size: 12px; }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; font-size: 13px; }
.kv div span { display: block; color: var(--muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

/* ---- Forms / settings -------------------------------------------------------- */
.form-grid { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field > label, .field > .label { font-weight: 600; font-size: 13px; }
.field .help { color: var(--muted); font-size: 12.5px; }
.row-inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row-inline > input, .row-inline > select { flex: 1; min-width: 160px; }
.snippet { position: relative; }
.snippet pre { margin: 0; white-space: pre-wrap; word-break: break-all; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 84px 12px 14px; }
.snippet .btn { position: absolute; top: 7px; right: 7px; }
.site-item { display: grid; gap: 10px; padding: 16px 0; border-bottom: 1px solid var(--border); }
.site-item:last-child { border-bottom: 0; }
.site-item .top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.site-item .top b { font-size: 14.5px; }
.error-text { color: var(--down); font-size: 13px; }
.ok-text { color: var(--up); font-size: 13px; }
.goal-card { padding: 16px 18px; display: grid; gap: 8px; }
.goal-card .top { display: flex; gap: 8px; align-items: center; }
.goal-card .top b { font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.goal-card .top .right { margin-left: auto; display: flex; gap: 2px; }
.goal-card .stats { display: flex; gap: 22px; align-items: flex-end; }
.goal-card .stats .v { font-size: 24px; font-weight: 700; letter-spacing: -0.03em; }
.goal-card .stats .l { color: var(--muted); font-size: 12px; }
.goal-card .meter { height: 6px; border-radius: 3px; background: var(--accent-wash); overflow: hidden; }
.goal-card .meter span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.docs h3 { font-size: 13.5px; margin: 18px 0 6px; }
.docs p { margin: 6px 0; color: var(--ink-2); }
.welcome { padding: 44px 32px; text-align: center; display: grid; justify-items: center; gap: 8px; }
.welcome h2 { font-size: 22px; margin: 8px 0 0; letter-spacing: -0.02em; }
.welcome p { color: var(--ink-2); max-width: 460px; margin: 0 0 12px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 120; background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: 13px; box-shadow: var(--shadow-lg); animation: pop .18s ease-out; }

/* ---- Responsive ---------------------------------------------------------------- */
@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi:nth-child(3) { border-right: 0; }
  .kpi:nth-child(-n+3) { border-bottom: 1px solid var(--border); }
  .kpi:last-child { border-top-right-radius: 0; }
  .vitals { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1080px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .map-wrap { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 90; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .22s; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .content { padding: 8px 16px 40px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .rt-top { grid-template-columns: 1fr; }
  .rt-top > div + div { border-left: 0; border-top: 1px solid var(--border); }
  .vitals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(3) { border-right: 1px solid var(--border); }
  .kpi:nth-child(2n) { border-right: 0; }
  .kpi:nth-child(-n+4) { border-bottom: 1px solid var(--border); }
  .kpi .spark { display: none; }
  .kpi .value { font-size: 22px; }
  .list-head .c.opt, .bl-row .c.opt { display: none; }
  .hero { font-size: 52px; }
  .kv { grid-template-columns: 1fr; }
}
