:root {
  color-scheme: light;
  --bg: #f7f5f1;
  --surface: #ffffff;
  --surface-2: #f3f1ec;
  --border: #e7e3dc;
  --text: #1c1b19;
  --text-2: #5c5953;
  --muted: #8d8982;
  --accent: #eb6834;          /* series colour: the bars */
  --accent-soft: #fbe3d8;     /* row fills behind breakdown labels */
  --live: #e34948;            /* the pulsing "online" dot */
  --good: #12805c;
  --bad: #c43d3c;
  --grid: #ece9e3;
  --shadow: 0 1px 2px rgba(28, 27, 25, 0.04), 0 4px 16px rgba(28, 27, 25, 0.04);
  --radius: 22px;
  --font: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "DM Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1b1b1a;
    --surface-2: #242422;
    --border: #2d2d2a;
    --text: #f4f3ef;
    --text-2: #c3c2b7;
    --muted: #8e8d86;
    --accent: #d95926;
    --accent-soft: #3a2419;
    --live: #e66767;
    --good: #3fbf8f;
    --bad: #ef7a79;
    --grid: #262624;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211;
  --surface: #1b1b1a;
  --surface-2: #242422;
  --border: #2d2d2a;
  --text: #f4f3ef;
  --text-2: #c3c2b7;
  --muted: #8e8d86;
  --accent: #d95926;
  --accent-soft: #3a2419;
  --live: #e66767;
  --good: #3fbf8f;
  --bad: #ef7a79;
  --grid: #262624;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---- top bar ------------------------------------------------------------ */
.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 18px 28px; max-width: 1800px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }
.brand .mascot { width: 26px; height: 26px; border-radius: 7px; }
.topbar .summary { color: var(--text-2); font-size: 14px; }
.topbar .summary strong { color: var(--text); }
.spacer { flex: 1; }
.clock { font-family: var(--mono); color: var(--text-2); font-size: 14px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; min-width: 36px; padding: 0 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); cursor: pointer; font-size: 14px; color: var(--text-2);
}
.icon-btn:hover { color: var(--text); border-color: var(--muted); }
.icon-btn svg { width: 16px; height: 16px; }
.btn {
  height: 38px; padding: 0 16px; border-radius: 12px; border: 1px solid transparent; cursor: pointer;
  background: var(--text); color: var(--bg); font-weight: 600;
}
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--border); }

/* ---- live dot ----------------------------------------------------------- */
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--live); position: relative; flex: none; }
.dot.idle { background: var(--muted); opacity: 0.5; }
.dot:not(.idle)::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--live);
  animation: pulse 2s ease-out infinite;
}
@keyframes pulse { 0% { transform: scale(1); opacity: 0.6; } 100% { transform: scale(2.6); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .dot::after { animation: none; } }

/* ---- the wall ----------------------------------------------------------- */
/* The wall uses the whole screen, edge to edge. */
.wall-page .topbar { max-width: none; padding: 16px 24px; }
.wall {
  display: grid; gap: 18px; padding: 0 24px 24px;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
}
.wall .card { container-type: inline-size; }
.wall .realtime { display: flex; flex-direction: column; flex: 1; min-height: 0; }

/* Aggregate across every site, in the top bar. */
.totals { display: flex; align-items: baseline; gap: 22px; flex-wrap: wrap; }
.total { display: flex; align-items: baseline; gap: 7px; color: var(--text-2); font-size: 14px; }
.total strong { color: var(--text); font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.total .dot { align-self: center; width: 10px; height: 10px; }

/* Fit mode (full screen, the F key, or ?fit): every card on one screen, sized to fill it. */
.fit, .fit body { height: 100%; overflow: hidden; }
.fit .wall {
  height: calc(100vh - var(--topbar-h, 72px)); padding-bottom: 18px;
  grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr);
}
.fit .wall .card { container-type: size; overflow: hidden; padding: clamp(14px, 3cqh, 28px) clamp(16px, 3cqw, 30px); }
.fit .wall .card-head { margin-bottom: clamp(6px, 2cqh, 18px); }
.fit .wall .hero { margin: clamp(2px, 1cqh, 8px) 0 clamp(4px, 1.5cqh, 14px); }
.fit .wall .hero .value { font-size: clamp(32px, 11cqh, 150px); }
.fit .wall .hero .dot { width: clamp(10px, 2.2cqh, 22px); height: clamp(10px, 2.2cqh, 22px); }
.fit .wall .minute-chart { flex: 1; height: auto; min-height: 50px; }
.fit .wall .country-row { font-size: clamp(13px, 2.4cqh, 20px); padding: clamp(1px, 0.5cqh, 5px) 0; }
.fit .wall .stat-sm .num { font-size: clamp(15px, 3cqh, 28px); }
.fit .total strong { font-size: 28px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px 24px 20px; display: flex; flex-direction: column; min-width: 0;
}
a.card:hover { border-color: var(--muted); }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; min-width: 0; }
.favicon { width: 20px; height: 20px; border-radius: 5px; flex: none; background: var(--surface-2); }
.favicon.letter { display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--text-2); }
.site-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.site-domain { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.online-pill {
  margin-left: auto; display: inline-flex; align-items: center; gap: 7px; flex: none;
  font-size: 13px; color: var(--text-2); background: var(--surface-2); padding: 4px 10px; border-radius: 999px;
}
.online-pill .dot { width: 8px; height: 8px; }
.bot-pill {
  margin-left: auto; flex: none; font-size: 12.5px; color: var(--muted); background: var(--surface-2);
  padding: 4px 9px; border-radius: 999px; cursor: help;
}
.bot-pill + .online-pill { margin-left: 0; }
.bot-pill[hidden] + .online-pill { margin-left: auto; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.06em; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.hero { display: flex; align-items: center; gap: 14px; margin: 6px 0 14px; }
.hero .value { font-size: 44px; font-weight: 700; letter-spacing: -0.02em; line-height: 1; }
.minute-chart { position: relative; height: 120px; }
.minute-chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.axis-label { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.bar { fill: var(--accent); }
.bar-hit { fill: transparent; cursor: default; }
.bar-hit:hover + .bar, .bar.active { opacity: 0.75; }
.baseline { stroke: var(--grid); stroke-width: 1; }
.lists { display: grid; grid-template-columns: 1fr; gap: 16px; margin-top: 18px; }
.lists:has(.now-pages) { grid-template-columns: 1fr 1fr; gap: 24px; }
.lists > * { min-width: 0; }
@container (max-width: 460px) {
  .lists:has(.now-pages) { grid-template-columns: 1fr; gap: 16px; }
}
.page-row .name { font-family: var(--mono); font-size: 13px; }
.page-icon { width: 14px; height: 14px; border-radius: 3px; flex: none; }
.hero-since { font-size: 14px; font-weight: 500; }
.since { font-size: 12px; font-weight: 600; min-width: 28px; text-align: right; }
.since.up { color: var(--good); }
.since.down { color: var(--bad); }
@keyframes bump-up { from { color: var(--good); transform: translateY(-2px); } to { color: inherit; transform: none; } }
@keyframes bump-down { from { color: var(--bad); transform: translateY(2px); } to { color: inherit; transform: none; } }
.bump-up { animation: bump-up 1.6s ease-out; display: inline-block; }
.bump-down { animation: bump-down 1.6s ease-out; display: inline-block; }
@media (prefers-reduced-motion: reduce) { .bump-up, .bump-down { animation: none; } }
.country-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; font-size: 15px; }
.country-row .flag { font-size: 18px; width: 22px; text-align: center; }
.country-row .name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.country-row .count { font-weight: 500; }
.card-foot {
  display: grid; grid-template-columns: auto auto 1fr; align-items: end; gap: 18px;
  margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border);
}
.card .realtime + .card-foot { margin-top: auto; }
.card .realtime { margin-bottom: 18px; }
.stat-sm .label { font-size: 12px; color: var(--muted); }
.stat-sm .num { font-weight: 600; font-size: 17px; }
.delta { font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.delta.flat { color: var(--muted); }
.spark { height: 34px; width: 100%; display: block; }
.spark path.line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark path.area { fill: var(--accent); opacity: 0.1; }
.empty { color: var(--muted); font-size: 14px; padding: 10px 0 0; }
.empty a { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }

.tooltip {
  position: fixed; pointer-events: none; z-index: 50; background: var(--text); color: var(--bg);
  padding: 6px 10px; border-radius: 8px; font-size: 13px; white-space: nowrap; transform: translate(-50%, calc(-100% - 10px));
}
.tooltip strong { font-weight: 600; }

/* ---- site detail -------------------------------------------------------- */
.page { max-width: 1280px; margin: 0 auto; padding: 0 28px 48px; }
.site-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 8px 0 18px; }
.site-bar select, .field select, .field input {
  height: 38px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); padding: 0 12px;
}
.segmented { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 3px; }
.segmented button {
  border: 0; background: transparent; padding: 6px 12px; border-radius: 9px; cursor: pointer; color: var(--text-2); font-size: 14px;
}
.segmented button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 6px 4px 12px; font-size: 13.5px;
}
.chip button { border: 0; background: var(--surface-2); border-radius: 50%; width: 22px; height: 22px; cursor: pointer; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0; }
.kpi { padding: 4px 22px 16px 0; }
.kpi .num { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.main-chart { height: 260px; margin-top: 8px; position: relative; }
.main-chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 20px; margin-top: 20px; }
.panel { padding: 18px 20px; }
.panel-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.panel-head h2 { font-size: 15px; margin: 0; font-weight: 600; }
.tabs { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.tabs button { border: 0; background: transparent; color: var(--muted); padding: 4px 8px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.tabs button[aria-pressed="true"] { color: var(--text); background: var(--surface-2); font-weight: 600; }
.cols { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); padding: 0 8px 6px; text-transform: uppercase; letter-spacing: 0.05em; }
.rows { display: flex; flex-direction: column; gap: 3px; min-height: 120px; }
.row {
  position: relative; display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px;
  cursor: pointer; font-size: 14px; border: 0; background: transparent; text-align: left; width: 100%;
}
.row .fill { position: absolute; inset: 0 auto 0 0; background: var(--accent-soft); border-radius: 8px; z-index: 0; }
.row > :not(.fill) { position: relative; z-index: 1; }
.row .label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .value { font-weight: 500; }
.row .sub { color: var(--muted); font-size: 12.5px; min-width: 44px; text-align: right; }
.row:hover { outline: 1px solid var(--border); }
.row img { width: 16px; height: 16px; border-radius: 3px; }
.feed { display: flex; flex-direction: column; gap: 2px; font-size: 14px; max-height: 320px; overflow: auto; }
.feed .item { display: flex; gap: 10px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--border); }
.feed .item:last-child { border-bottom: 0; }
.feed .when { color: var(--muted); font-size: 12.5px; min-width: 52px; }
.feed .what { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { font-size: 11.5px; padding: 1px 7px; border-radius: 6px; background: var(--accent-soft); color: var(--text); }

/* ---- settings / login --------------------------------------------------- */
.narrow { max-width: 820px; margin: 0 auto; padding: 0 28px 48px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; flex: 1; min-width: 160px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.site-item { padding: 18px 20px; margin-top: 14px; }
.site-item .meta { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin: 4px 0 12px; }
pre.snippet {
  margin: 0; padding: 12px 14px; background: var(--surface-2); border-radius: 12px; font: 12.5px/1.5 var(--mono);
  white-space: pre-wrap; word-break: break-all;
}
.error { color: var(--bad); font-size: 14px; min-height: 20px; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: min(360px, 100%); display: flex; flex-direction: column; gap: 14px; }

@media (max-width: 640px) {
  .topbar, .wall, .page, .narrow { padding-left: 16px; padding-right: 16px; }
  .panels { grid-template-columns: 1fr; }
  .hero .value { font-size: 38px; }
}

/* ---- onboarding wizard -------------------------------------------------- */
.wizard { padding: 22px 24px; margin-bottom: 20px; }
.wizard h2 { font-size: 19px; margin: 6px 0 8px; }
.steps { display: flex; gap: 8px; list-style: none; padding: 0; margin: 0 0 14px; counter-reset: step; }
.steps li { counter-increment: step; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.steps li::before {
  content: counter(step); display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--surface-2); font-weight: 600; font-size: 12px;
}
.steps li:not(:last-child)::after { content: ""; width: 28px; height: 1px; background: var(--border); margin-left: 4px; }
.steps li.active { color: var(--text); font-weight: 600; }
.steps li.active::before { background: var(--text); color: var(--bg); }
.steps li.done::before { content: "✓"; background: var(--good); color: #fff; }
.hint { font-size: 13px; margin: 0; flex: 1; align-self: end; }
.fw-tabs { margin: 12px 0 8px; justify-content: flex-start; margin-left: 0; }
.code-wrap { position: relative; margin-top: 8px; }
.code-wrap .copy { position: absolute; top: 8px; right: 8px; height: 30px; font-size: 13px; }
.code-wrap pre { padding-right: 84px; }
.goals-help { margin-top: 14px; font-size: 14px; }
.goals-help summary { cursor: pointer; color: var(--text-2); }
.checks { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 12px; }
.checks li { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; }
.checks .detail { font-size: 13.5px; margin-top: 2px; }
.checks .state { width: 22px; height: 22px; border-radius: 50%; flex: none; display: inline-grid; place-items: center; font-size: 13px; font-weight: 700; margin-top: 1px; }
.checks .state.wait { border: 2px solid var(--border); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
.checks .state.ok { background: var(--good); color: #fff; }
.checks .state.warn { background: var(--surface-2); color: var(--text-2); }
.checks .state.ok::after { content: "✓"; }
.checks .state.warn::after { content: "!"; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .checks .state.wait { animation: none; } }
.site-item .status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.site-item .status .dot { width: 8px; height: 8px; }

/* ---- goals --------------------------------------------------------------- */
.goal-form { margin-top: 14px; }
.goal-form select, .goal-form input { height: 38px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); padding: 0 12px; }
.discovered { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13.5px; color: var(--text-2); margin-top: 4px; }
.discovered button { border: 1px dashed var(--border); background: transparent; border-radius: 999px; padding: 3px 10px; cursor: pointer; font-size: 13px; }
.discovered button:hover { border-style: solid; color: var(--text); }
.chip-sm { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); margin-left: 4px; }
.icon-x { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 15px; }
.icon-x:hover { color: var(--bad); }

/* ---- revenue ------------------------------------------------------------ */
.sale {
  margin: -6px 0 12px; padding: 7px 12px; border-radius: 12px; font-weight: 600; font-size: 14px;
  background: color-mix(in srgb, var(--good) 14%, var(--surface)); color: var(--text);
  animation: sale-in 0.6s ease-out;
}
.sale[hidden] { display: none; }
@keyframes sale-in { from { transform: scale(0.96); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sale { animation: none; } }
.revenue { margin-top: 20px; padding: 20px 22px; }
.revenue .panel-head h2 { font-size: 17px; }
.segmented.small button { padding: 4px 10px; font-size: 13px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 10px 0 2px; font-size: 13px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.rev-tables { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 18px 28px; margin-top: 18px; }
.rev-tables > * { min-width: 0; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-top: 6px; }
table.data th { text-align: right; font-weight: 500; color: var(--muted); font-size: 12px; padding: 4px 6px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data td { text-align: right; padding: 6px; border-bottom: 1px solid var(--border); white-space: nowrap; font-variant-numeric: tabular-nums; }
table.data td:first-child { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
table.data tr:last-child td { border-bottom: 0; }
table.data .sw { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 7px; vertical-align: middle; }
table.data .dim { color: var(--muted); }
:root { --c-direct:#6f6d68; --c-rest:#c9c6bf; --c1:#2a78d6; --c2:#eb6834; --c3:#1baf7a; --c4:#eda100; --c5:#e87ba4; --c6:#008300; --c7:#4a3aa7; --c8:#e34948; --c-other:#a9a69f; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --c1:#3987e5; --c2:#d95926; --c3:#199e70; --c4:#c98500; --c5:#d55181; --c6:#008300; --c7:#9085e9; --c8:#e66767; --c-other:#6f6d68; --c-direct:#a9a69f; --c-rest:#4a4946; } }
:root[data-theme="dark"] { --c1:#3987e5; --c2:#d95926; --c3:#199e70; --c4:#c98500; --c5:#d55181; --c6:#008300; --c7:#9085e9; --c8:#e66767; --c-other:#6f6d68; --c-direct:#a9a69f; --c-rest:#4a4946; }
.seg { stroke: var(--surface); stroke-width: 2px; }
