:root {
  color-scheme: light;
  --bg: #f4f3f0; --surface: #fcfcfb; --surface-2: #f0efec; --border: #dedcd6;
  --text: #0b0b0b; --text-2: #52514e; --text-3: #85837d;
  --accent: #2a78d6; --accent-ink: #fff; --danger: #d03b3b; --good: #0ca30c;
  --grid: #e6e4de;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --heat: 42, 120, 214;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #111110; --surface: #1a1a19; --surface-2: #242422; --border: #353532;
    --text: #f0efec; --text-2: #c3c2b7; --text-3: #8b8a82;
    --accent: #3987e5; --grid: #2b2b28;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --heat: 57, 135, 229;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", sans-serif; }
#app { display: flex; min-height: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0 0 16px; font-weight: 650; }
h2 { font-size: 14px; margin: 0 0 10px; font-weight: 650; }
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; overflow-x: auto; margin: 8px 0; white-space: pre-wrap; word-break: break-word; }

.side { width: 208px; flex: none; background: var(--surface); border-right: 1px solid var(--border); padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 15px; padding: 4px 10px 12px; display: flex; align-items: center; gap: 8px; }
.brand i { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); display: inline-block; }
.side select { width: 100%; margin-bottom: 12px; }
.nav { display: block; padding: 7px 10px; border-radius: 7px; color: var(--text-2); font-weight: 500; }
.nav:hover { background: var(--surface-2); text-decoration: none; }
.nav.on { background: var(--surface-2); color: var(--text); font-weight: 650; }
.side .sp { flex: 1; }
.side small { color: var(--text-3); padding: 0 10px; }
.main { flex: 1; min-width: 0; padding: 22px 26px 60px; max-width: 1280px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row + .row { margin-top: 8px; }
.lbl { color: var(--text-3); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; min-width: 86px; }
.grow { flex: 1; }
.muted { color: var(--text-3); }
.right { margin-left: auto; }

input, select, button, textarea { font: inherit; color: inherit; }
input, select { background: var(--surface); border: 1px solid var(--border); border-radius: 7px; padding: 6px 9px; min-height: 32px; max-width: 100%; }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button { background: var(--surface); border: 1px solid var(--border); border-radius: 7px; padding: 6px 12px; min-height: 32px; cursor: pointer; font-weight: 550; }
button:hover { background: var(--surface-2); }
button.pri { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.pri:hover { filter: brightness(1.08); background: var(--accent); }
button.ghost { border-color: transparent; background: none; color: var(--text-2); padding: 6px 8px; }
button.ghost:hover { background: var(--surface-2); }
button:disabled { opacity: .55; cursor: default; }
.block { border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin-top: 8px; background: var(--bg); }
.block .idx { width: 22px; height: 22px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 650; flex: none; }
.err { color: var(--danger); margin: 8px 0; }
.empty { color: var(--text-3); padding: 34px 0; text-align: center; }

table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--text-3); font-size: 12px; font-weight: 600; position: sticky; top: 0; background: var(--surface); }
td.num, th.num { text-align: right; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
.scroll { overflow-x: auto; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; word-break: break-word; }

.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { fill: var(--text-3); font-size: 11px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; color: var(--text-2); font-size: 12.5px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.tip { position: fixed; z-index: 50; pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; box-shadow: 0 6px 24px rgba(0,0,0,.16); font-size: 12.5px; max-width: 340px; }
.tip b { display: block; margin-bottom: 4px; }
.tip div { display: flex; gap: 8px; align-items: center; }
.tip div em { font-style: normal; margin-left: auto; padding-left: 14px; font-variant-numeric: tabular-nums; font-weight: 600; }
.tip div span.l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }

.funnel .step { display: grid; grid-template-columns: minmax(110px, 200px) 1fr minmax(120px, auto); gap: 12px; align-items: center; padding: 7px 0; }
.funnel .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.funnel .track { background: var(--surface-2); border-radius: 4px; height: 26px; }
.funnel .bar { background: var(--s1); height: 100%; border-radius: 4px; min-width: 2px; }
.funnel .val { font-variant-numeric: tabular-nums; text-align: right; }
.funnel .val small { color: var(--text-3); display: block; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.stat b { display: block; font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat span { color: var(--text-3); font-size: 12px; }
.heat td { text-align: right; padding: 5px 9px; border-bottom: 2px solid var(--surface); border-right: 2px solid var(--surface); }
.heat td.c { border-radius: 4px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(460px, 1fr)); gap: 14px; }
.grid2 .card { margin: 0; min-width: 0; }
.login { margin: 12vh auto; width: 320px; }
.login input { width: 100%; margin-bottom: 10px; }
details summary { cursor: pointer; color: var(--text-2); }
@media (max-width: 800px) {
  #app { flex-direction: column; }
  .side { width: auto; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side .sp, .side small, .brand { display: none; }
  .side select { width: auto; margin: 0; }
  .main { padding: 16px; }
  .funnel .step { grid-template-columns: 1fr; gap: 4px; }
  .funnel .val { text-align: left; }
  .grid2 { grid-template-columns: 1fr; }
}
