:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --ring: rgba(11, 11, 11, 0.10);
  --wash: rgba(11, 11, 11, 0.04);
  --up: #006300;
  --down: #b42828;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --q1: #cde2fb; --q2: #b7d3f6; --q3: #9ec5f4; --q4: #86b6ef; --q5: #6da7ec;
  --q6: #5598e7; --q7: #3987e5; --q8: #2a78d6; --q9: #256abf; --q10: #1c5cab;
  --radius: 12px;
  font-family: system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --ring: rgba(255, 255, 255, 0.10);
    --wash: rgba(255, 255, 255, 0.05);
    --up: #0ca30c;
    --down: #e66767;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #0ca30c; --s7: #9085e9; --s8: #e66767;
    --q1: #0d366b; --q2: #104281; --q3: #184f95; --q4: #1c5cab; --q5: #256abf;
    --q6: #2a78d6; --q7: #3987e5; --q8: #5598e7; --q9: #6da7ec; --q10: #86b6ef;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --ring: rgba(255, 255, 255, 0.10); --wash: rgba(255, 255, 255, 0.05);
  --up: #0ca30c; --down: #e66767;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #0ca30c; --s7: #9085e9; --s8: #e66767;
  --q1: #0d366b; --q2: #104281; --q3: #184f95; --q4: #1c5cab; --q5: #256abf;
  --q6: #2a78d6; --q7: #3987e5; --q8: #5598e7; --q9: #6da7ec; --q10: #86b6ef;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font-size: 14px; line-height: 1.45; }
button, select, input { font: inherit; color: inherit; }
a { color: inherit; }

/* Top bar: app switcher, then the filters that scope everything below. */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
  padding: 12px max(16px, calc((100vw - 1180px) / 2));
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--ring);
}
.apps { display: flex; gap: 4px; flex-wrap: wrap; margin-right: auto; }
.apps button {
  border: 0; background: none; padding: 6px 12px; border-radius: 8px; cursor: pointer;
  font-size: 15px; font-weight: 600; color: var(--muted);
}
.apps button:hover { background: var(--wash); color: var(--ink-2); }
.apps button[aria-current="true"] { color: var(--ink); background: var(--surface); box-shadow: 0 0 0 1px var(--ring); }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--wash); border-radius: 9px; padding: 2px; }
.seg button { border: 0; background: none; padding: 4px 10px; border-radius: 7px; cursor: pointer; color: var(--ink-2); font-size: 13px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--ring); font-weight: 600; }
.filters select {
  appearance: none; -webkit-appearance: none; border: 0; background: var(--wash); border-radius: 9px;
  padding: 6px 26px 6px 10px; font-size: 13px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 13px) 50%, calc(100% - 9px) 50%; background-size: 4px 4px; background-repeat: no-repeat;
}
.logout { font-size: 13px; color: var(--muted); text-decoration: none; padding: 4px 6px; }
.logout:hover { color: var(--ink-2); }

main { max-width: 1180px; margin: 0 auto; padding: 16px 16px 64px; transition: opacity .15s; }
main.loading { opacity: .55; pointer-events: none; }

.tiles { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 12px; }
.tile { background: var(--surface); border-radius: var(--radius); box-shadow: 0 0 0 1px var(--ring); padding: 14px 16px 12px; min-width: 0; }
.tile .label { color: var(--ink-2); font-size: 13px; }
.tile .value { font-size: 28px; font-weight: 600; letter-spacing: -0.01em; margin-top: 2px; white-space: nowrap; }
.tile.hero .value { font-size: 48px; line-height: 1.05; }
.tile .delta { font-size: 12px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.delta .up { color: var(--up); }
.delta .down { color: var(--down); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: 0 0 0 1px var(--ring); padding: 14px 16px 16px; min-width: 0; margin-bottom: 12px; }
.grid2 > .card { margin-bottom: 0; }
.card h2 { font-size: 15px; font-weight: 600; margin: 0 0 10px; display: flex; align-items: baseline; gap: 10px; }
.card h2 .aside { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: auto; }
.empty { color: var(--muted); font-size: 13px; padding: 24px 0; text-align: center; }

/* Charts */
.chart { position: relative; width: 100%; touch-action: pan-y; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart .endlabel { fill: var(--ink-2); font-size: 12px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--ink-2); margin: -2px 0 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 14px; height: 2px; border-radius: 1px; }
.legend i.box { width: 10px; height: 10px; border-radius: 3px; }
.tip {
  position: absolute; pointer-events: none; z-index: 3; min-width: 120px;
  background: var(--surface); box-shadow: 0 0 0 1px var(--ring), 0 6px 20px rgba(0,0,0,.12);
  border-radius: 8px; padding: 8px 10px; font-size: 12px; line-height: 1.5; white-space: nowrap;
}
.tip .d { color: var(--muted); margin-bottom: 2px; }
.tip .r { display: flex; align-items: center; gap: 8px; }
.tip .r i { width: 10px; height: 2px; border-radius: 1px; flex: none; }
.tip .r b { font-weight: 600; font-variant-numeric: tabular-nums; }
.tip .r span { color: var(--ink-2); }

/* Retention heat table */
.ret { width: 100%; border-collapse: separate; border-spacing: 2px; font-size: 12px; font-variant-numeric: tabular-nums; }
.ret th { font-weight: 400; color: var(--muted); text-align: center; padding: 2px 4px; }
.ret th:first-child, .ret td:first-child { text-align: left; color: var(--ink-2); white-space: nowrap; }
.ret td { text-align: center; padding: 6px 4px; border-radius: 4px; }
.ret td.n { color: var(--muted); text-align: right; padding-right: 10px; }
.ret td.light { color: #0b0b0b; }
.ret td.dark { color: #ffffff; }

/* Ranked lists */
.lists { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px 24px; }
.list h3 { font-size: 12px; font-weight: 400; color: var(--muted); margin: 0 0 6px; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; align-items: center; padding: 3px 0; font-size: 13px; }
.row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .num { color: var(--ink-2); font-variant-numeric: tabular-nums; text-align: right; }
.row .num small { color: var(--muted); font-size: 11px; margin-left: 6px; }
.row .track { grid-column: 1 / -1; height: 6px; }
.row .track b { display: block; height: 6px; border-radius: 0 4px 4px 0; background: var(--s1); min-width: 2px; }

/* Feature table */
table.ev { width: 100%; border-collapse: collapse; font-size: 13px; }
table.ev th { text-align: right; font-weight: 400; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
table.ev th:first-child, table.ev td:first-child { text-align: left; }
table.ev td { text-align: right; padding: 8px; border-bottom: 1px solid var(--grid); font-variant-numeric: tabular-nums; white-space: nowrap; }
table.ev td:first-child { white-space: normal; }
table.ev tbody tr { cursor: pointer; }
table.ev tbody tr:hover { background: var(--wash); }
table.ev tbody tr[aria-selected="true"] { background: var(--wash); }
table.ev td .code { color: var(--muted); font-size: 11px; margin-left: 6px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
table.ev td .share { display: inline-block; width: 48px; height: 6px; border-radius: 3px; background: var(--wash); vertical-align: middle; margin-right: 8px; overflow: hidden; }
table.ev td .share b { display: block; height: 100%; background: var(--s1); border-radius: 3px; }
.detail { padding: 12px 0 4px; }
.detail .lists { margin-top: 14px; }

/* Funnel */
.funnel { display: grid; grid-template-columns: max-content minmax(0, 1fr) auto; gap: 8px 12px; align-items: center; font-size: 13px; }
.funnel .step { display: contents; }
.funnel .step .bar { height: 20px; background: var(--wash); border-radius: 4px; overflow: hidden; }
.funnel .step .bar b { display: block; height: 100%; background: var(--s1); border-radius: 0 4px 4px 0; min-width: 2px; }
.funnel .step .num { font-variant-numeric: tabular-nums; color: var(--ink-2); text-align: right; min-width: 92px; }
.funnel .step .num small { color: var(--muted); margin-left: 6px; }
.funnel + .funnel { margin-top: 18px; }
.funnel h3 { grid-column: 1 / -1; font-size: 13px; font-weight: 600; margin: 0; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: min(320px, 100%); background: var(--surface); border-radius: 16px; box-shadow: 0 0 0 1px var(--ring); padding: 28px 24px; }
.login h1 { font-size: 18px; margin: 0 0 18px; }
.login input { width: 100%; padding: 10px 12px; border-radius: 10px; border: 0; background: var(--wash); box-shadow: inset 0 0 0 1px var(--ring); font-size: 15px; }
.login button { width: 100%; margin-top: 12px; padding: 10px; border: 0; border-radius: 10px; background: var(--ink); color: var(--surface); font-weight: 600; cursor: pointer; }
.login .err { color: var(--down); font-size: 13px; margin-top: 10px; min-height: 1em; }

@media (max-width: 980px) {
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .tile.hero .value { font-size: 40px; }
  .lists { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 680px) {
  .grid2 { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .tile .value { font-size: 24px; }
  .tile.hero { grid-column: 1 / -1; }
  .lists { grid-template-columns: 1fr; }
  table.ev .hide-sm { display: none; }
  .top { position: static; }
  .apps { margin-right: 0; flex: 1; }
  .filters { order: 3; width: 100%; }
  .funnel .step .num { min-width: 0; }
}
