:root {
  --bg: #f6f7f9; --card: #ffffff; --ink: #14181f; --muted: #5b6573; --line: #e3e7ed; --accent: #2f5bea; --accent-soft: #e8eefe;
  --good: #14804a; --bad: #b42318; --c1: #2f5bea; --c2: #0f9d8a; --c3: #d9822b; --c4: #8a4fe0; --bar: #cfdcfb; --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116; --card: #161b22; --ink: #e8ecf2; --muted: #9aa5b4; --line: #262d38; --accent: #7b9cff; --accent-soft: #1d2745;
    --good: #4cc38a; --bad: #ff8a80; --c1: #7b9cff; --c2: #3ec9b3; --c3: #f0a35e; --c4: #b48cf2; --bar: #26355f; --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 15px; font-weight: 650; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

.top { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top-row { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; padding: 10px 20px 0; max-width: 1240px; margin: 0 auto; }
.brand { font-weight: 700; display: flex; align-items: center; gap: 8px; font-size: 15px; }
.brand-mark { width: 16px; height: 16px; border-radius: 4px; background: linear-gradient(135deg, var(--c1), var(--c4)); display: inline-block; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
select, input[type=date], input[type=text], input[type=password] {
  font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; min-height: 34px;
}
select:focus, input:focus, .btn:focus-visible, .tab:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.custom { display: inline-flex; gap: 6px; }
.btn { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; min-height: 34px; cursor: pointer; }
.btn:hover { background: var(--accent-soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.small { padding: 3px 9px; min-height: 28px; font-size: 13px; }
.tabs { display: flex; gap: 2px; overflow-x: auto; padding: 0 14px; max-width: 1240px; margin: 0 auto; }
.tab { font: inherit; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); padding: 10px 12px; cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab[aria-selected=true] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 650; }

main { max-width: 1240px; margin: 0 auto; padding: 18px 20px 40px; display: grid; gap: 16px; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 860px) { .cols-2, .cols-3 { grid-template-columns: 1fr; } .top-row { padding: 10px 14px 0; } main { padding: 14px; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 12.5px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: 12.5px; }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .delta { font-size: 12.5px; margin-top: 2px; color: var(--muted); }
.delta.up { color: var(--good); } .delta.down { color: var(--bad); }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; white-space: nowrap; }
th.num, td.num { text-align: right; }
.th-sort { all: unset; box-sizing: border-box; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; border-radius: 4px; padding: 1px 2px; margin: -1px -2px; }
.th-sort:hover { color: var(--ink); }
.th-sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.th-sort .arrow { display: inline-block; min-width: 1em; font-size: 10px; color: var(--accent); }
th[aria-sort="ascending"], th[aria-sort="descending"] { color: var(--ink); }
th.num .th-sort { flex-direction: row-reverse; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: var(--accent-soft); }
tr.sel { background: var(--accent-soft); }
.cell-bar { position: relative; min-width: 140px; }
.cell-bar > span { position: relative; z-index: 1; word-break: break-all; }
.cell-bar::before { content: ""; position: absolute; inset: 3px auto 3px 0; width: var(--w, 0%); background: var(--bar); border-radius: 4px; }
.scroll-x { overflow-x: auto; }
.empty { color: var(--muted); padding: 24px 8px; text-align: center; }

.funnel { display: grid; gap: 10px; }
.funnel-row { display: grid; grid-template-columns: minmax(150px, 1.1fr) minmax(120px, 3fr) minmax(110px, .9fr); gap: 12px; align-items: center; }
.funnel-label { display: grid; gap: 2px; }
.funnel-bar { position: relative; height: 30px; border-radius: 6px; background: var(--accent-soft); }
.funnel-bar::before { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--w); background: var(--bar); border-radius: 6px; }
.funnel-bar > span { position: relative; z-index: 1; display: block; padding: 0 10px; line-height: 30px; font-weight: 650; font-variant-numeric: tabular-nums; }
.funnel-pct { font-size: 13px; }
@media (max-width: 640px) { .funnel-row { grid-template-columns: 1fr; gap: 4px; } .funnel-pct { text-align: left; } }
.cohort td, .cohort th { text-align: center; white-space: nowrap; }
.cohort td:first-child, .cohort th:first-child { text-align: left; }
.cohort td { min-width: 62px; }
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 11px; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart-wrap { position: relative; }
.tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--bg); font-size: 12px; padding: 6px 9px; border-radius: 8px; white-space: nowrap; transform: translate(-50%, -110%); z-index: 3; }
.legend { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.chip { font: inherit; font-size: 12.5px; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 999px; padding: 3px 11px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip[aria-pressed=true] { background: var(--accent-soft); border-color: var(--accent); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

.big { font-size: 44px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--good); display: inline-block; margin-right: 8px; box-shadow: 0 0 0 0 var(--good); animation: pulse 1.8s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 9px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }
.pill { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.feed { display: grid; gap: 0; max-height: 420px; overflow: auto; }
.feed-row { display: grid; grid-template-columns: 74px minmax(0, 1fr) auto; gap: 10px; padding: 6px 2px; border-bottom: 1px solid var(--line); align-items: baseline; }
.feed-row:last-child { border-bottom: 0; }
.path { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; word-break: break-all; }
.timeline { display: grid; gap: 4px; }
.t-row { display: grid; grid-template-columns: 70px minmax(0, 1fr); gap: 10px; padding: 3px 0; }
.t-session { margin-top: 10px; padding: 8px 10px; background: var(--accent-soft); border-radius: 8px; font-weight: 600; }
.notice { background: var(--accent-soft); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; font-size: 13px; }
.foot { max-width: 1240px; margin: 0 auto; padding: 0 20px 30px; color: var(--muted); font-size: 12.5px; }
.def { margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: 12.5px; }

.login-body { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 24px; display: grid; gap: 10px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 20px; margin: 6px 0 4px; }
.login-card label { font-size: 13px; color: var(--muted); }
.login-card input { width: 100%; }
.login-card .btn { margin-top: 6px; }
.err { color: var(--bad); margin: 0; font-size: 13px; }
