:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #1c1917;
  --muted: #6b665f;
  --line: #e4e1dc;
  --accent: #1d4ed8;
  --accent-text: #ffffff;
  --up: #15803d;
  --down: #b91c1c;
  --tag: #eeece8;
  --notice: #eff4ff;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413;
    --surface: #1e1d1b;
    --text: #ecebe8;
    --muted: #a19d96;
    --line: #34322e;
    --accent: #7aa2ff;
    --accent-text: #0b1530;
    --up: #4ade80;
    --down: #f87171;
    --tag: #2b2a27;
    --notice: #1b2540;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0 0 .2rem; }
h2 { font-size: 1.15rem; margin: 2rem 0 .6rem; }
code { font-size: .9em; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.narrow { max-width: 420px; margin: 3rem auto; }

/* Header */
.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.25rem; padding-top: .7rem; padding-bottom: .7rem; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.top nav { display: flex; flex-wrap: wrap; gap: .25rem 1rem; flex: 1; }
.top nav a { color: var(--muted); text-decoration: none; padding: .15rem 0; }
.top nav a[aria-current="page"] { color: var(--text); font-weight: 600; border-bottom: 2px solid var(--accent); }
.signout { margin: 0; }
.linkish { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; padding: 0; }

.page-head { margin: 1.5rem 0 1rem; }
.notice { background: var(--notice); border-radius: 10px; padding: .75rem 1rem; margin: 1rem 0; }

/* Funnel strip */
.funnel { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 1rem 0; }
.step { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .8rem; }
.step-n { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.step-label { font-size: .85rem; color: var(--muted); }
.step-rate { font-size: .8rem; color: var(--muted); margin-top: .2rem; }

/* KPI tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .8rem 1rem; }
.tile.wide { max-width: 520px; }
.tile-label { font-size: .85rem; color: var(--muted); }
.tile-value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; margin: .1rem 0 .3rem; }
.delta { font-size: .85rem; font-weight: 600; margin-left: .3rem; }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }
.delta.flat { color: var(--muted); }
.spark { color: var(--accent); display: block; }

/* Tables */
.scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .5rem .75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td a { word-break: break-all; }

.tag { display: inline-block; font-size: .75rem; padding: .05rem .45rem; border-radius: 999px; background: var(--tag); color: var(--muted); }
.tag.ok { color: var(--up); }
.tag.bad { color: var(--down); }
.err { color: var(--down); margin-top: .2rem; word-break: break-word; }

/* Forms and buttons */
.stack { display: grid; gap: .5rem; }
input[type=email], input[type=text] {
  font: inherit; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--text);
}
button, .button {
  font: inherit; font-weight: 600; padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-text); cursor: pointer; text-decoration: none; display: inline-block;
}
button.secondary, .button.secondary { background: transparent; color: var(--accent); }
button:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.actions form { margin: 0; }
.howto li { margin-bottom: .6rem; }

@media (max-width: 640px) {
  .funnel { grid-template-columns: repeat(2, 1fr); }
  .tile-value { font-size: 1.3rem; }
}
