:root {
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --bg: #f4f4f1;
  --surface: #fcfcfb;
  --line: #e6e5e0;
  --grid: #ecebe6;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-3: #7a7975;
  --accent: #1d4f91;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --wash-1: rgba(42, 120, 214, .10);
  --bar: #cde2fb;
  --bar-strong: #86b6ef;
  --good: #1a7f37;
  --demo-bg: #fff4d6;
  --demo-ink: #6b4a00;
  --demo-line: #f0d48a;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.45 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
.muted { color: var(--ink-2); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
code, .mono { font-family: var(--mono); font-size: 12px; }

/* brand */
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; font-size: 16px; letter-spacing: -.01em; }
.brand-lg { font-size: 22px; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: var(--accent) url("/assets/favicon.svg") center/cover; display: inline-block; }

/* login */
.login-body { min-height: 100vh; display: grid; place-items: center; }
.login-card { width: 360px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 32px; box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.04); }
.login-card form { display: grid; gap: 10px; margin-top: 18px; }
.login-card label { font-weight: 550; font-size: 13px; }
input[type=password], input[type=text], .input { font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--series-1); outline-offset: 1px; }
.error { color: #b42318; margin: 0; }

/* buttons */
.btn { font: inherit; font-weight: 550; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 8px; cursor: pointer; }
.btn:hover { border-color: #cfcec8; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #173f75; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); padding: 6px 8px; }
.btn-ghost:hover { color: var(--ink); background: var(--grid); }

/* layout */
.shell { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; background: linear-gradient(to right, var(--surface) 227px, var(--line) 227px, var(--line) 228px, var(--bg) 228px); }
.side { background: var(--surface); border-right: 1px solid var(--line); align-self: start; padding: 20px 14px; display: flex; flex-direction: column; gap: 10px; position: sticky; top: 0; height: 100vh; }
.side-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin-top: 14px; }
.select { font: inherit; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
.nav { display: grid; gap: 2px; margin-top: 10px; }
.nav a { color: var(--ink-2); text-decoration: none; padding: 7px 10px; border-radius: 7px; font-weight: 500; }
.nav a:hover { background: var(--grid); color: var(--ink); }
.nav a.active { background: #e8f0fb; color: var(--accent); font-weight: 600; }
.nav .nav-sub { margin-top: 10px; font-size: 13px; }
.side-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; }
.main { min-width: 0; }
.demo-banner { background: var(--demo-bg); color: var(--demo-ink); border-bottom: 1px solid var(--demo-line); padding: 9px 28px; font-size: 13px; }
.demo-banner strong { letter-spacing: .06em; background: #f5c542; color: #3d2a00; padding: 2px 7px; border-radius: 5px; margin-right: 4px; }
.top { display: flex; align-items: center; justify-content: space-between; padding: 22px 28px 6px; gap: 16px; }
.top h1 { font-size: 20px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 3px; }
.seg button { font: inherit; font-size: 13px; border: 0; background: transparent; color: var(--ink-2); padding: 5px 12px; border-radius: 6px; cursor: pointer; }
.seg button.on { background: var(--ink); color: #fff; }
.view { padding: 14px 28px 40px; display: grid; gap: 16px; }

/* cards */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
.card h2 { font-size: 13px; font-weight: 600; margin: 0 0 12px; color: var(--ink); display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card h2 .muted { font-weight: 450; font-size: 12px; }
.tile .label { font-size: 12px; color: var(--ink-2); font-weight: 500; }
.tile .value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.tile.live .label::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--good); margin-right: 6px; box-shadow: 0 0 0 3px rgba(26,127,55,.15); animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(26,127,55,.05); } }
@media (prefers-reduced-motion: reduce) { .tile.live .label::before { animation: none; } }
.hero-2 { font-size: 22px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.hero { font-size: 44px; font-weight: 650; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }

/* chart */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis { fill: var(--ink-3); font-size: 11px; font-family: var(--font); }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--ink-2); }
.legend .key { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.tip { position: fixed; pointer-events: none; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.08); padding: 8px 10px; font-size: 12px; z-index: 10; min-width: 140px; }
.tip .t { color: var(--ink-2); margin-bottom: 4px; }
.tip .r { display: flex; justify-content: space-between; gap: 14px; }
.tip .sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }

/* bar tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 600; padding: 0 0 6px; }
th.num { text-align: right; }
td { padding: 0; height: 30px; border-top: 1px solid transparent; }
.bt td { position: relative; }
.bt td.k { padding-left: 8px; max-width: 0; width: 60%; }
.bt td.k .fill { position: absolute; left: 0; top: 3px; bottom: 3px; background: var(--bar); border-radius: 0 4px 4px 0; z-index: 0; }
.bt td.k span.lbl { position: relative; z-index: 1; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bt td.num { padding-left: 14px; color: var(--ink); }
.bt td.num.dim { color: var(--ink-2); }
.bt tr:hover td.k .fill { background: var(--bar-strong); }
.plain td { border-top: 1px solid var(--grid); height: 34px; padding: 0 8px; }
.plain th { padding: 0 8px 6px; }
.plain tr:hover td { background: #f7f7f4; }
.empty { color: var(--ink-3); padding: 18px 0; text-align: center; }
.pill { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 10px; background: var(--grid); color: var(--ink-2); }
.pill.ok { background: #e3f3e7; color: #1a5c2c; }
.pill.demo { background: var(--demo-bg); color: var(--demo-ink); }
.flag { font-size: 15px; margin-right: 6px; }

/* funnel */
.fsteps { display: grid; gap: 12px; }
.fstep { display: grid; grid-template-columns: 220px 1fr 150px; align-items: center; gap: 16px; }
.fstep .name { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fstep .name small { display: block; font-weight: 400; color: var(--ink-3); }
.fbar { height: 26px; background: var(--grid); border-radius: 0 4px 4px 0; position: relative; }
.fbar > div { position: absolute; inset: 0 auto 0 0; background: var(--series-1); border-radius: 0 4px 4px 0; min-width: 2px; }
.fstep .stat { text-align: right; font-variant-numeric: tabular-nums; }
.fstep .drop { font-size: 12px; color: var(--ink-3); }
.editor { display: grid; gap: 8px; }
.editor .row { display: grid; grid-template-columns: 24px 110px 1fr 36px; gap: 8px; align-items: center; }
.editor .row .idx { color: var(--ink-3); text-align: center; }
.actions { display: flex; gap: 8px; margin-top: 6px; align-items: center; }

pre.snippet { background: #f1f0ec; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; overflow-x: auto; font-size: 12px; margin: 0; white-space: pre-wrap; word-break: break-all; }

@media (max-width: 1100px) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .g3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .g2, .g3, .tiles { grid-template-columns: 1fr; }
  .fstep { grid-template-columns: 1fr; }
}
