/* Omega Analytics dashboard.
   Tokens first; everything below references roles, so light/dark swap in one place. */
:root {
  color-scheme: light;
  --page: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --ink: #15181d;
  --ink-2: #555c69;
  --ink-3: #8a909b;
  --line: #e4e7ec;
  --line-strong: #cfd4dc;
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --accent-wash: #e8f1fc;
  --bar: #dceafb;
  --area: #eaf2fc;   /* accent at ~10% on the surface, pre-mixed so fills stay opaque */
  --live: #0ca30c;
  --live-wash: #e3f6e3;
  --warn-wash: #fdf0d5;
  --warn-ink: #7a4f00;
  --up: #006300;
  --down: #c03030;
  --danger: #c03030;
  --focus: #2a78d6;
  --radius-s: 6px;
  --radius-m: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --rail: 232px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0e1014;
    --surface: #161a20;
    --surface-2: #1b2027;
    --ink: #eef1f5;
    --ink-2: #aab1bd;
    --ink-3: #7d8591;
    --line: #262b33;
    --line-strong: #353b45;
    --accent: #3987e5;
    --accent-ink: #86b6ef;
    --accent-wash: #16273d;
    --bar: #1a3353;
    --area: #182a40;
    --live: #0ca30c;
    --live-wash: #13301a;
    --warn-wash: #3a2c0c;
    --warn-ink: #f5c86b;
    --up: #2fbf4a;
    --down: #e66767;
    --danger: #e66767;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.soft { color: var(--ink-2); }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 20px;
  padding: 20px 14px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; font-weight: 650; font-size: 16px; letter-spacing: -0.01em; }
.brand-mark { width: 26px; height: 26px; }
.site-picker { position: relative; }
.site-picker select {
  width: 100%; appearance: none; cursor: pointer;
  padding: 9px 32px 9px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%238a909b' stroke-width='1.6'%3E%3Cpath d='m3 4.5 3 3 3-3'/%3E%3C/svg%3E") no-repeat right 12px center;
  font-weight: 550;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-s);
  color: var(--ink-2); font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--accent-wash); color: var(--accent-ink); }
.nav svg { width: 17px; height: 17px; flex: none; }
.nav .count { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--live); }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding: 0 6px; font-size: 13px; }
.rail-foot button { all: unset; cursor: pointer; color: var(--ink-2); }
.rail-foot button:hover { color: var(--ink); }

main { min-width: 0; padding: 24px 32px 64px; max-width: 1320px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -0.015em; }
.page-head .spacer { flex: 1; }
.crumb { color: var(--ink-3); font-weight: 500; }

/* ---------- Controls ---------- */
.segmented { display: inline-flex; max-width: 100%; overflow-x: auto; padding: 3px; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.segmented button {
  border: 0; background: none; cursor: pointer;
  padding: 5px 11px; border-radius: 6px; color: var(--ink-2); font-weight: 500; font-size: 13px;
}
.segmented button:hover { color: var(--ink); }
.segmented button[aria-pressed="true"] { background: var(--accent-wash); color: var(--accent-ink); font-weight: 600; }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-s); cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-weight: 550;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 550; font-size: 13px; }
.field .hint { font-size: 12.5px; color: var(--ink-3); }
.input {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-s); background: var(--surface);
}
.input:focus { outline: 2px solid var(--focus); outline-offset: -1px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: -8px 0 18px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 6px 4px 10px; border-radius: 999px;
  background: var(--accent-wash); color: var(--accent-ink); font-size: 13px; font-weight: 500;
}
.chip button { border: 0; background: none; cursor: pointer; color: inherit; padding: 0 4px; font-size: 15px; line-height: 1; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px 0; }
.card-head h2 { margin: 0; font-size: 14.5px; font-weight: 650; }
.card-head .spacer { flex: 1; }
.card-body { padding: 14px 18px 18px; }
.tabs { display: flex; gap: 14px; }
.tabs button { border: 0; background: none; cursor: pointer; padding: 2px 0; color: var(--ink-3); font-weight: 550; font-size: 13px; border-bottom: 2px solid transparent; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }

/* ---------- Unique-visitor windows: the signature strip ---------- */
.windows {
  display: grid; grid-template-columns: 1.1fr repeat(4, 1fr);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m);
  box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden;
}
.window { padding: 16px 20px 18px; border-left: 1px solid var(--line); }
.window:first-child { border-left: 0; }
.window h3 { margin: 0 0 6px; font-size: 13px; font-weight: 550; color: var(--ink-2); }
.window .big { font-size: 34px; font-weight: 650; letter-spacing: -0.03em; line-height: 1.1; }
.window .delta { margin-top: 4px; font-size: 12.5px; }
.window.live { background: var(--live-wash); cursor: pointer; }
.window.live:hover { filter: brightness(0.98); }
.window.live .big { display: flex; align-items: center; gap: 12px; }
.pulse { position: relative; width: 11px; height: 11px; border-radius: 50%; background: var(--live); flex: none; }
.pulse::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--live);
  animation: pulse 2s ease-out infinite;
}
@keyframes pulse { from { transform: scale(1); opacity: .55; } to { transform: scale(2.8); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .pulse::after { animation: none; } }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }
.delta.flat { color: var(--ink-3); }

/* ---------- Chart card with metric tabs ---------- */
.metrics { display: grid; grid-template-columns: repeat(5, 1fr); border-bottom: 1px solid var(--line); }
.metric {
  all: unset; box-sizing: border-box; cursor: pointer;
  padding: 14px 18px 12px; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.metric[disabled] { cursor: default; }
.metric:not([disabled]):hover { background: var(--surface-2); }
.metric[aria-selected="true"] { border-bottom-color: var(--accent); }
.metric .label { font-size: 13px; color: var(--ink-2); font-weight: 550; }
.metric .value { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; }
.metric .delta { font-size: 12px; }
.metric:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.chart { position: relative; height: 280px; padding: 16px 12px 8px 4px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis { stroke: var(--line-strong); stroke-width: 1; shape-rendering: crispEdges; }
.chart .tick { fill: var(--ink-3); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: miter; }
.chart .area { fill: var(--area); }
.chart .cross { stroke: var(--ink-3); stroke-width: 1; }
.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 5;
  padding: 8px 10px; border-radius: 8px; min-width: 120px;
  background: var(--surface); border: 1px solid var(--line-strong);
  box-shadow: 0 6px 20px rgba(16, 24, 40, 0.12); font-size: 12.5px;
}
.tooltip .t-title { color: var(--ink-2); margin-bottom: 2px; }
.tooltip .t-value { font-size: 15px; font-weight: 650; }

/* ---------- Breakdown panels ---------- */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.bars { width: 100%; border-collapse: collapse; }
.bars th { text-align: left; font-size: 12px; font-weight: 550; color: var(--ink-3); padding: 0 0 8px; }
.bars th.r, .bars td.r { text-align: right; padding-left: 14px; white-space: nowrap; }
.bars td { padding: 0; height: 32px; }
.bars .name { position: relative; width: 100%; max-width: 0; }
.bars .fill { position: absolute; inset: 2px auto 2px 0; background: var(--bar); border-radius: 4px; }
.bars .label { position: relative; display: block; padding: 0 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.bars tr.clickable { cursor: pointer; }
.bars tr.clickable:hover .label { text-decoration: underline; }
.bars tr.clickable:focus-visible { outline: 2px solid var(--focus); }
.empty { padding: 28px 0; text-align: center; color: var(--ink-3); }
.more { display: block; margin-top: 10px; font-size: 13px; }
.attribution { margin: 12px 0 0; font-size: 12px; }
.attribution a { color: var(--ink-3); }

/* ---------- Tables (sessions, visitors, live) ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; font-weight: 550; color: var(--ink-3);
  padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr[data-href] { cursor: pointer; }
.table tbody tr[data-href]:hover { background: var(--surface-2); }
.table .path { font-weight: 550; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table .sub { color: var(--ink-3); font-size: 12.5px; }
.person { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 11px; font-weight: 650; color: #fff;
}
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12px; color: var(--ink-2); }
.tag.id { background: var(--accent-wash); border-color: transparent; color: var(--accent-ink); }
.tag.bot { background: var(--warn-wash); border-color: transparent; color: var(--warn-ink); }
.reasons { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.notice {
  margin: -4px 0 16px; padding: 12px 14px; border-radius: var(--radius-s);
  background: var(--accent-wash); color: var(--ink); font-size: 13.5px;
}

/* ---------- Live ---------- */
.live-head { display: flex; align-items: center; gap: 16px; padding: 22px 24px; }
.live-head .big { font-size: 48px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.live-head .pulse { width: 14px; height: 14px; }
.live-pages { display: flex; flex-direction: column; gap: 10px; }
.live-page { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; }
.live-page .path { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-dots { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px; }
.live-dots span { width: 10px; height: 10px; border-radius: 50%; background: var(--live); }
.live-grid { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; }

/* ---------- Journey (session detail) ---------- */
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px 24px; }
.facts dt { font-size: 12.5px; color: var(--ink-3); }
.facts dd { margin: 2px 0 0; font-weight: 550; overflow-wrap: break-word; }
.journey { list-style: none; margin: 0; padding: 0; position: relative; }
.journey::before { content: ""; position: absolute; left: 11px; top: 14px; bottom: 14px; width: 2px; background: var(--line); }
.journey li { position: relative; display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 14px; padding: 10px 0; }
.journey .node {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); border: 2px solid var(--accent); font-size: 11px; font-weight: 700; color: var(--accent-ink); z-index: 1;
}
.journey li.event .node { border-color: var(--line-strong); color: var(--ink-3); width: 16px; height: 16px; margin: 4px; }
.journey .what { min-width: 0; }
.journey .what b { font-weight: 600; }
.journey .when { color: var(--ink-3); font-size: 12.5px; text-align: right; white-space: nowrap; }
.journey .sub { font-size: 12.5px; }
.journey .props { font-size: 12.5px; color: var(--ink-2); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }

/* ---------- Sites ---------- */
.snippet {
  position: relative; margin: 0; padding: 14px 16px; border-radius: var(--radius-s);
  background: var(--surface-2); border: 1px solid var(--line);
  font: 12.5px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; word-break: break-all;
}
.snippet + .btn { margin-top: 10px; }
.site-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; padding: 18px; border-bottom: 1px solid var(--line); }
.site-row:last-child { border-bottom: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.error { color: var(--danger); font-size: 13px; }
.footnote { margin: -6px 0 16px; font-size: 12.5px; color: var(--ink-3); }

/* Radio cards (site privacy mode) */
.choices { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.choices legend { font-weight: 550; font-size: 13px; padding: 0; margin-bottom: 6px; }
.choice {
  display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start;
  padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-s); cursor: pointer;
}
.choice:hover { background: var(--surface-2); }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-wash); }
.choice input { margin: 3px 0 0; accent-color: var(--accent); }
.choice b { display: block; font-weight: 600; }
.choice .hint { display: block; margin-top: 2px; }
.choices > .hint { font-size: 12.5px; color: var(--ink-3); }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .card { width: 100%; max-width: 380px; padding: 28px; }
.auth h1 { margin: 12px 0 4px; font-size: 20px; }
.auth p { margin: 0 0 20px; color: var(--ink-2); }

.loading { padding: 60px 0; text-align: center; color: var(--ink-3); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .windows { grid-template-columns: repeat(2, 1fr); }
  .window.live { grid-column: 1 / -1; }
  .window { border-left: 0; border-top: 1px solid var(--line); }
  .window:nth-child(odd):not(.live) { border-left: 1px solid var(--line); }
  .window.live { border-top: 0; }
  .metrics { grid-template-columns: repeat(3, 1fr); }
  .split, .live-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .site-picker { flex: 1; min-width: 0; }
  .nav { flex-direction: row; overflow-x: auto; width: 100%; min-width: 0; }
  .nav a { white-space: nowrap; }
  .rail-foot { display: none; }
  main { padding: 18px 16px 48px; }
  .grid-2 { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .window .big { font-size: 28px; }
}
