:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --card: #ffffff;
  --card-2: #fafafa;
  --line: rgba(0, 0, 0, 0.07);
  --grid: #ececef;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #a1a1a6;
  --accent: #2a78d6;
  --accent-wash: rgba(42, 120, 214, 0.1);
  --accent-soft: #e7f0fb;
  --money: #1baf7a;
  --money-wash: rgba(27, 175, 122, 0.1);
  --prev: #c7c7cc;
  --good: #1a8f4a;
  --bad: #d93a3a;
  --live: #30c85a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 24px rgba(0, 0, 0, 0.04);
  --radius: 18px;
  --seq-0: #f0f4fa;
  --seq-1: #cde2fb;
  --seq-2: #86b6ef;
  --seq-3: #3987e5;
  --seq-4: #1c5cab;
  --seq-5: #0d366b;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #000000;
    --card: #1c1c1e;
    --card-2: #232326;
    --line: rgba(255, 255, 255, 0.08);
    --grid: #2c2c2e;
    --text: #f5f5f7;
    --text-2: #a1a1a6;
    --text-3: #6e6e73;
    --accent: #3987e5;
    --accent-wash: rgba(57, 135, 229, 0.16);
    --accent-soft: rgba(57, 135, 229, 0.16);
    --money: #199e70;
    --money-wash: rgba(25, 158, 112, 0.16);
    --prev: #48484a;
    --good: #34c46a;
    --bad: #ff6961;
    --shadow: none;
    --seq-0: #1f2530;
    --seq-1: #184f95;
    --seq-2: #256abf;
    --seq-3: #3987e5;
    --seq-4: #6da7ec;
    --seq-5: #b7d3f6;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --card: #1c1c1e;
  --card-2: #232326;
  --line: rgba(255, 255, 255, 0.08);
  --grid: #2c2c2e;
  --text: #f5f5f7;
  --text-2: #a1a1a6;
  --text-3: #6e6e73;
  --accent: #3987e5;
  --accent-wash: rgba(57, 135, 229, 0.16);
  --accent-soft: rgba(57, 135, 229, 0.16);
  --money: #199e70;
  --money-wash: rgba(25, 158, 112, 0.16);
  --prev: #48484a;
  --good: #34c46a;
  --bad: #ff6961;
  --shadow: none;
  --seq-0: #1f2530;
  --seq-1: #184f95;
  --seq-2: #256abf;
  --seq-3: #3987e5;
  --seq-4: #6da7ec;
  --seq-5: #b7d3f6;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; padding: 22px 14px;
  display: flex; flex-direction: column; gap: 18px;
  border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; font-weight: 600; font-size: 16px; }
.brand-mark { width: 26px; height: 26px; border-radius: 8px; background: var(--text); display: grid; place-items: center; }
.brand-mark svg { width: 15px; height: 15px; stroke: var(--bg); }
.site-select {
  width: 100%; appearance: none; border: 1px solid var(--line); background: var(--card);
  border-radius: 10px; padding: 8px 30px 8px 10px; font-weight: 500; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none' stroke='%2386868b' stroke-width='1.5'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px;
  color: var(--text-2); font-weight: 500; transition: background .15s, color .15s;
}
.nav a svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.7; flex: none; }
.nav a:hover { background: var(--line); color: var(--text); }
.nav a.active { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }

.main { padding: 26px 34px 60px; max-width: 1320px; width: 100%; min-width: 0; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.head h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; margin: 0; }
.head-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.live-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px;
  background: var(--card); box-shadow: var(--shadow); border: 1px solid var(--line);
  font-weight: 500; color: var(--text-2);
}
.live-pill b { color: var(--text); font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--live); position: relative; flex: none; }
.dot::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%; background: var(--live);
  opacity: .35; animation: pulse 2s ease-out infinite;
}
@keyframes pulse { 0% { transform: scale(.5); opacity: .5; } 100% { transform: scale(1.6); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .dot::after { animation: none; } }

.segmented {
  display: inline-flex; padding: 2px; border-radius: 10px; background: var(--line); gap: 2px;
}
.segmented button {
  border: 0; background: transparent; padding: 5px 11px; border-radius: 8px; cursor: pointer;
  font-weight: 500; font-size: 13px; color: var(--text-2); white-space: nowrap;
}
.segmented button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin: -8px 0 18px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 6px 5px 12px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-weight: 500; font-size: 13px;
}
.chip button { border: 0; background: transparent; cursor: pointer; color: inherit; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; }
.chip button:hover { background: var(--accent-wash); }

/* ---------- cards ---------- */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--line); padding: 20px; min-width: 0;
}
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; min-height: 28px; }
.card-h h3 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.015em; }
.card-h .sub { color: var(--text-2); font-size: 13px; }
.tabs { display: flex; gap: 14px; }
.tabs button { border: 0; background: none; padding: 0; cursor: pointer; color: var(--text-3); font-weight: 500; font-size: 13px; }
.tabs button.on { color: var(--text); }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); border-bottom: 1px solid var(--line); margin: -20px -20px 18px; }
.kpi { padding: 18px 20px 16px; cursor: pointer; border: 0; background: none; text-align: left; position: relative; border-radius: 0; }
.kpi:first-child { border-top-left-radius: var(--radius); }
.kpi:last-child { border-top-right-radius: var(--radius); }
.kpi:hover { background: var(--card-2); }
.kpi.on::after { content: ""; position: absolute; left: 20px; right: 20px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--text); }
.kpi .l { color: var(--text-2); font-size: 13px; font-weight: 500; }
.kpi .v { font-size: 26px; font-weight: 600; letter-spacing: -0.03em; margin-top: 2px; white-space: nowrap; }
.delta { font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 2px; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.delta.flat { color: var(--text-3); }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.tile .l { color: var(--text-2); font-weight: 500; font-size: 13px; }
.tile .v { font-size: 30px; font-weight: 600; letter-spacing: -0.03em; margin: 4px 0 2px; }
.hero-num { font-size: 64px; font-weight: 700; letter-spacing: -0.045em; line-height: 1; }

/* ---------- bar list ---------- */
.bars { display: flex; flex-direction: column; gap: 3px; }
.bars-head { display: flex; justify-content: space-between; color: var(--text-3); font-size: 12px; font-weight: 500; padding: 0 10px 6px; }
.bars-head span:last-child { display: flex; gap: 16px; }
.bar {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 7px 10px; border-radius: 8px; cursor: pointer; min-height: 34px; overflow: hidden;
}
.bar:hover { background: var(--card-2); }
.bar .fill { position: absolute; inset: 2px auto 2px 0; border-radius: 7px; background: var(--accent-wash); transition: width .5s cubic-bezier(.2,.8,.2,1); }
.bar.money .fill { background: var(--money-wash); }
.bar .k { position: relative; display: flex; align-items: center; gap: 8px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .k span.t { overflow: hidden; text-overflow: ellipsis; }
.bar .vals { position: relative; display: flex; gap: 16px; font-weight: 500; flex: none; }
.bar .vals .muted { color: var(--text-3); font-weight: 400; min-width: 44px; text-align: right; }
.fav { width: 16px; height: 16px; border-radius: 4px; flex: none; }
.flag { font-size: 16px; line-height: 1; flex: none; }
.empty { color: var(--text-3); text-align: center; padding: 34px 0; }
.more { margin-top: 8px; border: 0; background: none; color: var(--accent); cursor: pointer; font-weight: 500; font-size: 13px; padding: 4px 10px; }

/* ---------- charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; overflow: visible; }
.chart text { fill: var(--text-3); font-size: 11px; font-family: var(--font); }
.tip {
  position: absolute; pointer-events: none; z-index: 5; min-width: 150px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,.12); padding: 10px 12px; font-size: 12px;
  opacity: 0; transition: opacity .12s; white-space: nowrap;
}
.tip.show { opacity: 1; }
.tip .tt { color: var(--text-2); margin-bottom: 6px; font-weight: 500; }
.tip .row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.tip .row .sw { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.tip .row b { font-weight: 600; }
.legend { display: flex; gap: 16px; color: var(--text-2); font-size: 12px; }
.legend i { display: inline-block; width: 12px; height: 2px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; color: var(--text-3); font-weight: 500; font-size: 12px; padding: 0 10px 8px; white-space: nowrap; }
.table td { padding: 10px; border-top: 1px solid var(--line); white-space: nowrap; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--card-2); }
.table .r { text-align: right; }
.table-wrap { overflow-x: auto; margin: 0 -10px; }
.who { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-size: 12px; font-weight: 600; color: #fff;
}
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; }

/* ---------- live ---------- */
.feed { display: flex; flex-direction: column; }
.feed-item { display: flex; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); align-items: flex-start; }
.feed-item:first-child { border-top: 0; }
.ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; background: var(--card-2); border: 1px solid var(--line); }
.ico svg { width: 15px; height: 15px; stroke: var(--text-2); fill: none; stroke-width: 1.8; }
.ico.buy { background: var(--money-wash); border-color: transparent; }
.ico.buy svg { stroke: var(--money); }
.feed-item .body { flex: 1; min-width: 0; }
.feed-item .body .t1 { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-item .body .t2 { color: var(--text-3); font-size: 12px; }

/* ---------- heatmap / funnel ---------- */
.heat { display: grid; grid-template-columns: 34px repeat(24, minmax(0, 1fr)); gap: 3px; }
.heat .c { aspect-ratio: 1; border-radius: 4px; background: var(--seq-0); }
.heat .lbl { color: var(--text-3); font-size: 11px; display: flex; align-items: center; }
.heat .hl { color: var(--text-3); font-size: 10px; text-align: center; }
.funnel { display: flex; flex-direction: column; gap: 12px; }
.fstep .top { display: flex; justify-content: space-between; margin-bottom: 6px; }
.fstep .track { height: 10px; border-radius: 5px; background: var(--seq-0); overflow: hidden; }
.fstep .track div { height: 100%; border-radius: 5px; background: var(--accent); transition: width .6s cubic-bezier(.2,.8,.2,1); }
.fstep .drop { color: var(--text-3); font-size: 12px; }
.cohort td { text-align: center; font-size: 12px; padding: 7px 4px; border-top: 0; }
.cohort td.cell { border-radius: 6px; }
.cohort td:first-child, .cohort th:first-child { padding-left: 10px; }

/* ---------- forms ---------- */
.input {
  width: 100%; border: 1px solid var(--line); background: var(--card-2); border-radius: 10px; padding: 9px 12px; outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.btn {
  border: 0; border-radius: 10px; padding: 9px 16px; font-weight: 600; cursor: pointer;
  background: var(--text); color: var(--bg); white-space: nowrap;
}
.btn.ghost { background: var(--line); color: var(--text); }
.btn.danger { background: transparent; color: var(--bad); }
.row-form { display: flex; gap: 8px; flex-wrap: wrap; }
.row-form .input { flex: 1; min-width: 140px; }
pre.code {
  background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; overflow-x: auto;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; line-height: 1.6; margin: 8px 0 0;
}
.label { font-size: 12px; font-weight: 600; color: var(--text-2); margin: 16px 0 4px; text-transform: none; }

/* ---------- drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.25); backdrop-filter: blur(2px); z-index: 20; opacity: 0; transition: opacity .2s; pointer-events: none; }
.scrim.show { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 10px; right: 10px; bottom: 10px; width: min(480px, calc(100vw - 20px)); z-index: 21;
  background: var(--card); border-radius: 22px; border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(0,0,0,.2);
  transform: translateX(110%); transition: transform .32s cubic-bezier(.2,.8,.2,1); overflow-y: auto; padding: 24px;
}
.drawer.show { transform: none; }
.close { position: absolute; top: 18px; right: 18px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: var(--line); cursor: pointer; font-size: 16px; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 18px 0; }
.kv div .l { color: var(--text-3); font-size: 12px; }
.kv div .v { font-weight: 600; }
.session-h { color: var(--text-3); font-size: 12px; font-weight: 600; margin: 18px 0 4px; }

.skeleton { background: linear-gradient(90deg, var(--card-2), var(--line), var(--card-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 8px; }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi:first-child, .kpi:last-child { border-radius: 0; }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 10; padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    flex-direction: row; border-right: 0; border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  }
  .side .brand, .side .site-wrap, .side-foot { display: none; }
  .nav { flex-direction: row; justify-content: space-around; width: 100%; }
  .nav a { flex-direction: column; gap: 2px; font-size: 10px; padding: 6px 4px; }
  .nav a.active { background: none; box-shadow: none; color: var(--accent); }
  .main { padding: 18px 16px 100px; }
  .head h1 { font-size: 24px; }
  .mobile-site { display: block !important; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .v { font-size: 22px; }
  .tiles { gap: 10px; }
  .tile .v { font-size: 24px; }
  .hero-num { font-size: 52px; }
  .segmented { overflow-x: auto; max-width: 100%; }
}
.mobile-site { display: none; }
.show-m { display: none; }
.ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 820px) {
  .hide-m { display: none; }
  .show-m { display: block; }
  .hide-d { display: none; }
  .head { gap: 12px; margin-bottom: 16px; }
  .head-right { width: 100%; min-width: 0; }
  .head-right .segmented { width: 100%; scrollbar-width: none; }
  .head-right .segmented::-webkit-scrollbar { display: none; }
  .head-right .segmented button { flex: 1 0 auto; }
  .card { padding: 16px; }
  .kpis { margin: -16px -16px 16px; }
  .kpi { padding: 14px 16px; }
  .kpi.on::after { left: 16px; right: 16px; }
  .card-h { flex-wrap: wrap; }
  .card-h .input { max-width: none !important; }
  .table td { padding: 10px 8px; }
  .table-wrap { margin: 0 -8px; }
  .heat { grid-template-columns: 26px repeat(24, minmax(0, 1fr)); gap: 2px; }
  .heat .c { border-radius: 2px; }
  .drawer { top: auto; left: 0; right: 0; bottom: 0; width: 100%; max-height: 88vh; border-radius: 22px 22px 0 0; transform: translateY(105%); padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  .kv { gap: 12px; }
  .tip { min-width: 130px; }
}

/* ---------- nav labels ---------- */
.nav .ns { display: none; }
@media (max-width: 820px) {
  .nav .nl { display: none; }
  .nav .ns { display: inline; }
  .nav a { flex: 1; min-width: 0; }
}

/* ---------- docs ---------- */
.docs { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 24px; align-items: start; }
.toc { position: sticky; top: 26px; display: flex; flex-direction: column; gap: 2px; }
.toc a { padding: 6px 10px; border-radius: 8px; color: var(--text-2); font-size: 13px; font-weight: 500; }
.toc a:hover { background: var(--line); color: var(--text); }
.docs-body { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.doc-hero { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.doc-hero h2 { margin: 0 0 4px; font-size: 20px; letter-spacing: -0.02em; }
.doc-hero p { margin: 0; max-width: 520px; }
.doc-hero .btn, .copy { display: inline-flex; align-items: center; gap: 8px; }
.doc-hero .btn svg, .copy svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.doc-sec { scroll-margin-top: 20px; }
.doc-sec p, .doc-sec li { color: var(--text); line-height: 1.6; margin: 0 0 12px; }
.doc-sec ul { margin: 0; padding-left: 20px; }
.doc-sec code, .note code, .doc-table code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px;
  background: var(--card-2); border: 1px solid var(--line); padding: 1px 5px; border-radius: 5px;
}
.note { background: var(--accent-soft); color: var(--text); border-radius: 12px; padding: 10px 14px; margin: 12px 0; font-size: 13px; line-height: 1.55; }
.code-box { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin: 0 0 12px; background: var(--card-2); }
.code-bar { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px 6px 14px; border-bottom: 1px solid var(--line); color: var(--text-3); font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.code-box pre.code { margin: 0; border: 0; border-radius: 0; background: transparent; white-space: pre; }
.copy { border: 0; background: var(--card); color: var(--text-2); border-radius: 8px; padding: 5px 10px; cursor: pointer; font-size: 12px; font-weight: 500; text-transform: none; letter-spacing: 0; box-shadow: 0 0 0 1px var(--line); }
.copy:hover { color: var(--text); }
.copy.ghost { background: transparent; box-shadow: none; }
.copy.done, .btn.done { color: var(--good); }
.doc-tabs .segmented { margin: 0 0 10px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.doc-table td { white-space: normal; vertical-align: top; }
.doc-table td:first-child { white-space: nowrap; }
.doc-link:hover { border-color: var(--accent); }
@media (max-width: 1000px) {
  .docs { grid-template-columns: 1fr; }
  .toc { position: static; flex-direction: row; overflow-x: auto; scrollbar-width: none; gap: 4px; }
  .toc a { white-space: nowrap; background: var(--card); border: 1px solid var(--line); }
}
@media (max-width: 820px) {
  .doc-hero .btn { width: 100%; justify-content: center; }
  .doc-sec .card-h .copy span { display: none; }
}
