/* Hallmark · genre: modern-minimal · macrostructure: Workbench · theme: Cobalt (light + graphite dark)
 * tone: utilitarian instrument panel · anchor hue: cobalt 258 · enrichment: none
 * Hairline panels, one cobalt signal, Space Grotesk numerals, Inter text, mono labels.
 * Every class here is rendered by public/app.js; rename one only together with it.
 */

/* ---------------------------------------------------------------- tokens */

:root {
  color-scheme: light dark;

  --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --space-3xs: 2px;
  --space-2xs: 4px;
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  --text-2xs: 10.5px;
  --text-xs: 11.5px;
  --text-sm: 13px;
  --text-md: 14px;
  --text-lg: 18px;
  --text-xl: 24px;
  --text-2xl: 30px;
  --text-3xl: 40px;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-pill: 999px;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --dur-short: 140ms;
  --dur-mid: 220ms;

  --page-max: 1200px;
}

/* Drives the native date-picker chrome too — without a per-theme value the
   calendar popup and its icon follow the OS, not the dashboard, and the icon
   goes invisible whenever the two disagree. */
.app[data-theme="light"] {
  color-scheme: light;
  --color-paper: oklch(98.4% 0.004 250);
  --color-surface: oklch(100% 0 0);
  --color-surface-2: oklch(96.6% 0.006 252);
  --color-ink: oklch(23% 0.02 258);
  --color-ink-2: oklch(48% 0.018 257);
  --color-ink-3: oklch(63% 0.014 257);
  --color-rule: oklch(91.8% 0.008 255);
  --color-rule-2: oklch(86% 0.01 255);
  --color-accent: oklch(54% 0.21 260);
  --color-accent-ink: oklch(99% 0.003 250);
  --color-accent-soft: oklch(54% 0.21 260 / 0.09);
  --color-accent-line: oklch(54% 0.21 260 / 0.35);
  --color-positive: oklch(54% 0.14 155);
  --color-negative: oklch(55% 0.19 27);
  --color-warn: oklch(62% 0.14 70);
  --color-shadow: oklch(23% 0.02 258 / 0.12);
  --color-wash: oklch(23% 0.02 258 / 0.04);
}

.app[data-theme="dark"] {
  color-scheme: dark;
  --color-paper: oklch(16.5% 0.012 262);
  --color-surface: oklch(19.8% 0.014 262);
  --color-surface-2: oklch(23.5% 0.016 262);
  --color-ink: oklch(95.5% 0.006 255);
  --color-ink-2: oklch(72% 0.014 257);
  --color-ink-3: oklch(57% 0.014 257);
  --color-rule: oklch(27.5% 0.016 262);
  --color-rule-2: oklch(34% 0.018 262);
  --color-accent: oklch(71% 0.15 256);
  --color-accent-ink: oklch(16% 0.02 262);
  --color-accent-soft: oklch(71% 0.15 256 / 0.13);
  --color-accent-line: oklch(71% 0.15 256 / 0.4);
  --color-positive: oklch(76% 0.14 155);
  --color-negative: oklch(71% 0.16 25);
  --color-warn: oklch(80% 0.13 80);
  --color-shadow: oklch(5% 0.01 262 / 0.5);
  --color-wash: oklch(95.5% 0.006 255 / 0.05);
}

/* The names app.js and older rules use. Charts read --accent and --muted. */
.app {
  --bg: var(--color-paper);
  --surface: var(--color-surface);
  --card: var(--color-surface-2);
  --text: var(--color-ink);
  --muted: var(--color-ink-2);
  --divider: var(--color-rule);
  --accent: var(--color-accent);
  --positive: var(--color-positive);
  --negative: var(--color-negative);
}

/* ------------------------------------------------------------------ base */

* { box-sizing: border-box; }

html, body { overflow-x: clip; }
body { margin: 0; background: var(--color-paper); }

.app {
  min-height: 100vh;
  background: var(--color-paper);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--text-md);
  line-height: 1.45;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}

/* Numbers everywhere: aligned digits, body face. The display face is kept
   for the few headline figures below. */
.mono {
  font-family: var(--font-body);
  font-variant-numeric: tabular-nums;
}

button, input, select { font: inherit; color: inherit; }

:where(button, a, input, select, [tabindex]):focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* !important: buttons set their own display, and every .hidden toggle in
   app.js must win over it. */
.hidden { display: none !important; }
.muted { color: var(--color-ink-2); font-size: var(--text-xs); }
.loading, .empty { color: var(--color-ink-2); font-size: var(--text-sm); }

/* Panel labels: the one place the mono face shows. */
.kicker,
.stat-label,
.hero .kicker,
.realtime .kicker,
#countries .kicker,
.param-card .kicker,
.head,
.path-col-head,
.report-section h4,
.report-metric .label,
.audience-head h4,
table.campaigns th,
.report-table th {
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-ink-2);
}

/* ---------------------------------------------------------------- header */

header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  background: var(--color-paper);
  border-bottom: 1px solid var(--color-rule);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-width: 0;
}

.logo {
  height: 22px;
  width: auto;
  color: var(--color-ink);
  flex: none;
}

.brand-suffix {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--color-ink-2);
  padding-left: var(--space-sm);
  border-left: 1px solid var(--color-rule-2);
}

.controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

#whoami {
  padding: 0 var(--space-2xs) 0 var(--space-xs);
  white-space: nowrap;
}

/* Production / Debug */
.seg {
  display: inline-flex;
  padding: var(--space-3xs);
  gap: var(--space-3xs);
  background: var(--color-surface-2);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-sm);
}
.seg button {
  border: 0;
  background: transparent;
  color: var(--color-ink-2);
  padding: 5px 11px;
  border-radius: 4px;
  font-size: var(--text-xs);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--dur-short) var(--ease-out), color var(--dur-short) var(--ease-out);
}
.seg button:not(.active):hover { color: var(--color-ink); }
.seg button.active {
  background: var(--color-surface);
  color: var(--color-ink);
  box-shadow: 0 1px 2px var(--color-shadow), 0 0 0 1px var(--color-rule);
}
.seg button.active[data-env="production"]::before,
.seg button.active[data-env="debug"]::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 7px;
  border-radius: var(--radius-pill);
  background: var(--color-positive);
  vertical-align: 1px;
}
.seg button.active[data-env="debug"]::before { background: var(--color-warn); }

/* Plain bordered buttons: range, Push, Report, Paths, Catalog, Clear. */
.range-btn,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  height: 32px;
  padding: 0 var(--space-sm);
  background: var(--color-surface);
  color: var(--color-ink);
  border: 1px solid var(--color-rule-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color var(--dur-short) var(--ease-out), background-color var(--dur-short) var(--ease-out);
}
.range-btn:hover,
.icon-btn:hover { border-color: var(--color-ink-3); background: var(--color-surface-2); }
.range-btn:active,
.icon-btn:active { transform: translateY(1px); }
.icon-btn { width: 32px; padding: 0; color: var(--color-ink-2); }
.icon-btn:hover { color: var(--color-ink); }
.icon-btn svg { width: 16px; height: 16px; }

#rangeBtn::before {
  content: "";
  width: 14px;
  height: 14px;
  flex: none;
  background: currentColor;
  opacity: 0.55;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4'%3E%3Crect x='2' y='3' width='12' height='11' rx='2'/%3E%3Cpath d='M2 6.5h12M5.5 1.5v3M10.5 1.5v3'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.4'%3E%3Crect x='2' y='3' width='12' height='11' rx='2'/%3E%3Cpath d='M2 6.5h12M5.5 1.5v3M10.5 1.5v3'/%3E%3C/svg%3E") center / contain no-repeat;
}

.range-btn.danger {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--color-negative);
  border-color: color-mix(in oklch, var(--color-negative) 40%, transparent);
}
.range-btn.danger:hover:not(:disabled) { background: color-mix(in oklch, var(--color-negative) 10%, transparent); border-color: var(--color-negative); }
.range-btn.danger:disabled { opacity: 0.55; cursor: default; }
.range-btn.danger.hidden, #reportBtn.hidden { display: none; }

/* Date range menu */
.range-picker { position: relative; }
.range-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 40;
  min-width: 248px;
  padding: var(--space-2xs);
  background: var(--color-surface);
  border: 1px solid var(--color-rule-2);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px var(--color-shadow);
}
.range-menu.hidden { display: none; }
.range-menu button[data-preset] {
  display: block;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-ink);
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
}
.range-menu button[data-preset]:hover { background: var(--color-surface-2); }
.range-menu-custom {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-top: var(--space-2xs);
  padding: var(--space-sm) var(--space-xs) var(--space-2xs);
  border-top: 1px solid var(--color-rule);
}
.range-menu-custom .custom-title {
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.custom-field { display: flex; align-items: center; justify-content: space-between; gap: var(--space-xs); }
.custom-field > .muted { flex: none; width: 36px; }
.range-menu-custom .input {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  background: var(--color-paper);
  color: var(--color-ink);
  border: 1px solid var(--color-rule-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  cursor: pointer;
}
.range-menu-custom .input:hover { border-color: var(--color-ink-3); }
.range-menu-custom .input::-webkit-calendar-picker-indicator { cursor: pointer; opacity: 0.6; }
.range-menu-custom .input::-webkit-calendar-picker-indicator:hover { opacity: 1; }

/* The one filled button style. */
.apply-btn,
.search-btn,
.login-card button {
  width: 100%;
  margin-top: var(--space-2xs);
  padding: 7px 12px;
  background: var(--color-accent);
  color: var(--color-accent-ink);
  border: 0;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  transition: filter var(--dur-short) var(--ease-out);
}
.apply-btn:hover,
.search-btn:hover,
.login-card button:hover { filter: brightness(1.08); }
.apply-btn:active,
.search-btn:active,
.login-card button:active { transform: translateY(1px); }

/* ------------------------------------------------------------------ page */

main {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--space-lg) var(--space-lg) var(--space-2xl);
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg) var(--space-lg);
}

/* KPI strip: one ruled panel, a cell per period. The 1px gap over a rule-
   coloured background draws the dividers however the cells wrap. */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: var(--space-md);
  background: var(--color-rule);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.stat {
  position: relative;
  min-width: 0;
  padding: var(--space-md) var(--space-md) var(--space-md) 18px;
  background: var(--color-surface);
}
.stat:first-child::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 2px;
  background: var(--color-accent);
}
.stat-label { color: var(--color-ink); }
.stat-sub { margin-top: 1px; font-size: var(--text-xs); color: var(--color-ink-3); }
.stat-metrics {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-2xs) var(--space-md);
  margin-top: var(--space-sm);
}
.stat-metrics > div { display: flex; flex-direction: column; min-width: 0; }
.stat-num {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.01em;
}
.stat-metrics > div:first-child { flex-basis: 100%; }
.stat-metrics > div:first-child .stat-num {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 600;
  letter-spacing: -0.03em;
}
.stat-unit { margin-top: 2px; font-size: var(--text-xs); color: var(--color-ink-2); }
/* New installs is a different kind of number from the other two (a rate, not a
   population), so it reads as a secondary metric rather than a third peer. */
.stat-new { cursor: help; }
.stat-new .stat-num { color: var(--color-ink-2); }
.stat-delta { margin-top: var(--space-xs); font-size: var(--text-xs); font-weight: 500; }
.stat-delta.up { color: var(--color-positive); }
.stat-delta.down { color: var(--color-negative); }

/* Trend + realtime */
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.hero {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  min-width: 0;
  padding: var(--space-md) var(--space-lg) var(--space-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-md);
}
.hero .value-row { display: flex; align-items: baseline; flex-wrap: wrap; gap: var(--space-xs) var(--space-sm); margin-top: var(--space-xs); }
.hero .value,
.realtime .value {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}
.hero .delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 600;
}
.hero .delta.up { color: var(--color-positive); background: color-mix(in oklch, var(--color-positive) 12%, transparent); }
.hero .delta.down { color: var(--color-negative); background: color-mix(in oklch, var(--color-negative) 12%, transparent); }
.hero .hero-note { margin-top: var(--space-xs); max-width: 60ch; font-size: var(--text-xs); color: var(--color-ink-3); }
.hero .chart-wrap { width: 100%; }
.hero svg.trend { display: block; width: 100%; height: 132px; overflow: visible; }
.hero svg.trend .grid-line { stroke: var(--color-rule); stroke-width: 1; }

.realtime { display: flex; flex-direction: column; min-width: 0; }
.realtime .kicker { display: flex; align-items: center; gap: var(--space-xs); }
.realtime .kicker::before {
  content: "";
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: var(--radius-pill);
  background: var(--color-positive);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--color-positive) 22%, transparent);
}
@media (prefers-reduced-motion: no-preference) {
  .realtime .kicker::before { animation: live 2.4s var(--ease-in-out) infinite; }
}
@keyframes live { 50% { opacity: 0.35; } }
.realtime .value { margin-top: var(--space-sm); }
.realtime .bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 64px;
  margin-top: auto;
  padding-top: var(--space-md);
}
.realtime .bars span {
  flex: 1;
  min-height: 2px;
  background: var(--color-accent);
  border-radius: 2px 2px 0 0;
  opacity: 0.85;
}
.realtime .bars span:last-child { opacity: 1; }

/* Countries */
#countries { margin-bottom: var(--space-lg); }
#countries .kicker { margin-bottom: var(--space-xs); }
.country-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: var(--space-xl);
}
.country-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 7px 0;
  font-size: var(--text-sm);
}
.country-list .country-row { border-bottom: 1px solid var(--color-rule); }
.country-row .name { width: 150px; flex: none; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.country-row .code { margin-left: 6px; font-family: var(--font-mono); font-size: var(--text-2xs); color: var(--color-ink-3); }
.country-row .bar-track {
  flex: 1;
  min-width: 40px;
  height: 6px;
  overflow: hidden;
  background: var(--color-surface-2);
  border-radius: var(--radius-pill);
}
/* display:block — it's a <span>, and an inline box ignores width/height. */
.country-row .bar-fill { display: block; height: 100%; background: var(--color-accent); border-radius: var(--radius-pill); }
.country-row .num { width: 52px; flex: none; text-align: right; color: var(--color-ink-2); }

/* Search */
.searchbar {
  position: relative;
  display: flex;
  gap: var(--space-xs);
  margin-bottom: var(--space-lg);
}
.searchbar::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 50%;
  width: 15px;
  height: 15px;
  translate: 0 -50%;
  pointer-events: none;
  background: var(--color-ink-3);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.6'%3E%3Ccircle cx='7' cy='7' r='4.75'/%3E%3Cpath d='m10.5 10.5 3.5 3.5'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.6'%3E%3Ccircle cx='7' cy='7' r='4.75'/%3E%3Cpath d='m10.5 10.5 3.5 3.5'/%3E%3C/svg%3E") center / contain no-repeat;
}
.search-input {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 var(--space-sm) 0 38px;
  background: var(--color-surface);
  color: var(--color-ink);
  border: 1px solid var(--color-rule-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  transition: border-color var(--dur-short) var(--ease-out), box-shadow var(--dur-short) var(--ease-out);
}
.search-input::placeholder { color: var(--color-ink-3); }
.search-input:hover { border-color: var(--color-ink-3); }
.search-input:focus { outline: none; border-color: var(--color-accent); box-shadow: 0 0 0 3px var(--color-accent-soft); }
.search-btn { flex: none; width: auto; height: 40px; margin: 0; padding: 0 var(--space-md); font-size: var(--text-sm); }
.searchbar .range-btn { height: 40px; }

/* Breadcrumbs + level title */
#breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: var(--space-2xs);
  font-size: var(--text-xs);
  color: var(--color-ink-2);
}
#breadcrumbs a { color: inherit; text-decoration: none; cursor: pointer; border-radius: 3px; }
#breadcrumbs a:hover { color: var(--color-accent); }
#breadcrumbs .current { color: var(--color-ink); }
#breadcrumbs .sep { color: var(--color-ink-3); }

.level-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}
.level-title-row h3 {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: -0.025em;
}
.level-title-actions { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-xs); }
#rowCount { padding-left: var(--space-2xs); }

/* Lists: projects, modules, events, params. A list view sits in the same
   hairline panel as the rest of the page. */
#app:has(> .head) {
  overflow: hidden;
  background: var(--color-surface);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-md);
}
#app:has(> .head) > .head { padding-top: var(--space-sm); background: var(--color-surface-2); }
#app:has(> .head) > .row:last-of-type { border-bottom: 0; }
#app:has(> .head) > .row:hover { background: var(--color-surface-2); }
#app:has(> .head) > .list-note { margin: 0; padding: var(--space-sm); border-top: 1px solid var(--color-rule); }
.head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 90px 120px 110px 20px;
  gap: var(--space-sm);
  padding: 0 var(--space-sm) var(--space-xs);
  border-bottom: 1px solid var(--color-rule-2);
}
.head.no-dau { grid-template-columns: minmax(0, 1fr) 120px 110px 20px; }

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 90px 120px 110px 20px;
  align-items: center;
  gap: var(--space-sm);
  padding: 13px var(--space-sm);
  border-bottom: 1px solid var(--color-rule);
  cursor: pointer;
  transition: background-color var(--dur-short) var(--ease-out);
}
.row.no-dau { grid-template-columns: minmax(0, 1fr) 120px 110px 20px; }
.row:hover { background: var(--color-surface); }
.row:hover .chevron { color: var(--color-accent); transform: translateX(2px); }
.row .name { min-width: 0; overflow-wrap: anywhere; font-size: var(--text-md); font-weight: 500; }
.row .sub { margin-top: 2px; font-size: var(--text-xs); color: var(--color-ink-3); }
.row .num { text-align: right; font-size: var(--text-md); }
.row svg.spark { display: block; width: 110px; height: 28px; overflow: visible; }
.row svg.spark polyline { stroke-linejoin: round; stroke-linecap: round; }
.row .chevron { color: var(--color-ink-3); transition: transform var(--dur-short) var(--ease-out), color var(--dur-short) var(--ease-out); }

.list-note { max-width: 70ch; margin: var(--space-sm) var(--space-sm) 0; font-size: var(--text-xs); color: var(--color-ink-2); }

/* Param breakdown cards */
.param-card { margin-bottom: var(--space-md); }
.param-card .kicker { margin-bottom: var(--space-sm); }

/* ------------------------------------------------------------------ push */

#push { margin-bottom: var(--space-lg); }
#push .kicker { margin-bottom: var(--space-2xs); }
.push-meta { margin-bottom: var(--space-sm); font-size: var(--text-xs); }
.push-form { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-xs); }
.push-form .input {
  flex: 1 1 200px;
  min-width: 0;
  height: 36px;
  padding: 0 10px;
  background: var(--color-paper);
  color: var(--color-ink);
  border: 1px solid var(--color-rule-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
}
.push-form .input:focus { outline: none; border-color: var(--color-accent); box-shadow: 0 0 0 3px var(--color-accent-soft); }
.push-form select.input { flex: 0 1 auto; cursor: pointer; }
/* The shared .apply-btn is full-width for the date picker; here it sits inline. */
.push-form .apply-btn { flex: 0 0 auto; width: auto; height: 36px; margin-top: 0; padding: 0 var(--space-md); }
.push-form .input:disabled,
.push-form .apply-btn:disabled { opacity: 0.45; cursor: not-allowed; }
#pushStatus { margin-top: 10px; font-size: var(--text-sm); }

/* Push console (#/~push): the analytics panels are hidden, the composer stays. */
.app.push-console .stats-grid,
.app.push-console .hero-grid,
.app.push-console #countries,
.app.push-console .searchbar { display: none; }
.app.push-console #pushNav { background: var(--color-accent-soft); color: var(--color-accent); border-color: var(--color-accent-line); }

.table-scroll { overflow-x: auto; }
table.campaigns { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
table.campaigns th,
table.campaigns td {
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--color-rule);
}
table.campaigns th { white-space: nowrap; border-bottom-color: var(--color-rule-2); }
table.campaigns td.num, table.campaigns th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.campaigns td.nowrap { white-space: nowrap; }
table.campaigns tbody tr:hover { background: var(--color-surface-2); }
.campaign-title { font-weight: 600; }
.campaign-body, .campaign-reasons { margin-top: 2px; font-size: var(--text-xs); }
.campaign-body { max-width: 320px; }
.campaign-foot { margin-top: 14px; font-size: var(--text-xs); }
.campaign-route { margin-top: 3px; font-size: var(--text-xs); color: var(--color-accent); }

.status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: var(--text-2xs);
  font-weight: 600;
  white-space: nowrap;
}
.status.done    { background: color-mix(in oklch, var(--color-positive) 14%, transparent); color: var(--color-positive); }
.status.partial { background: color-mix(in oklch, var(--color-warn) 16%, transparent);     color: var(--color-warn); }
.status.failed  { background: color-mix(in oklch, var(--color-negative) 14%, transparent); color: var(--color-negative); }
.status.sending { background: var(--color-surface-2); color: var(--color-ink-2); }

/* ---------------------------------------------------------------- report */

#reportBtn { cursor: pointer; }

.report {
  padding: var(--space-xl) var(--space-xl) var(--space-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-md);
}
.report-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--space-md); }
.report-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 600;
  letter-spacing: -0.03em;
  overflow-wrap: anywhere;
}
.report-sub { margin-top: var(--space-2xs); font-size: var(--text-xs); color: var(--color-ink-2); }
.report-periods { display: inline-flex; flex-wrap: wrap; gap: var(--space-3xs); padding: var(--space-3xs); background: var(--color-surface-2); border: 1px solid var(--color-rule); border-radius: var(--radius-sm); }
.report-periods button {
  padding: 5px 11px;
  background: transparent;
  color: var(--color-ink-2);
  border: 0;
  border-radius: 4px;
  font-size: var(--text-xs);
  font-weight: 500;
  cursor: pointer;
}
.report-periods button:hover { color: var(--color-ink); }
.report-periods button.active { background: var(--color-surface); color: var(--color-ink); box-shadow: 0 1px 2px var(--color-shadow), 0 0 0 1px var(--color-rule); }

/* Headline metrics: the same ruled strip as the KPI row. */
.report-headline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1px;
  margin: var(--space-lg) 0;
  background: var(--color-rule);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.report-metric { padding: var(--space-md) 18px; background: var(--color-surface); }
.report-metric .value {
  margin-top: var(--space-xs);
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.05;
}
.report-metric .delta { margin-top: var(--space-2xs); font-size: var(--text-xs); font-weight: 600; }
.report-metric .delta.up { color: var(--color-positive); }
.report-metric .delta.down { color: var(--color-negative); }
.report-metric .prev { margin-top: 2px; font-size: var(--text-xs); color: var(--color-ink-3); }

.report-section { margin-top: var(--space-xl); }
.report-section h4 { margin: 0 0 var(--space-sm); }
.report-chart { width: 100%; height: 160px; }
.report-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.report-table th { padding: 7px 8px; text-align: left; border-bottom: 1px solid var(--color-rule-2); }
.report-table td { padding: 8px; border-bottom: 1px solid var(--color-rule); }
.report-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.report-table tbody tr:hover { background: var(--color-surface-2); }
.report-foot { margin-top: var(--space-xl); padding-top: var(--space-sm); font-size: var(--text-xs); color: var(--color-ink-3); border-top: 1px solid var(--color-rule); }

/* --------------------------------------------------------- path explorer */

.paths-controls { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-sm); margin: 18px 0 6px; font-size: var(--text-sm); color: var(--color-ink-2); }
.paths-controls select {
  max-width: 360px;
  margin-left: var(--space-xs);
  padding: 6px 8px;
  background: var(--color-surface);
  color: var(--color-ink);
  border: 1px solid var(--color-rule-2);
  border-radius: var(--radius-sm);
}
.path-chain {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 10px 0 2px;
  padding: 10px 12px;
  font-size: var(--text-xs);
  background: var(--color-surface-2);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-sm);
}
.path-chain-step { color: var(--color-ink); }
.path-chain-arrow { color: var(--color-ink-3); }
.paths-grid { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(200px, 1fr); gap: 18px; overflow-x: auto; padding: var(--space-xs) 0 var(--space-2xs); }
.path-col-head { padding-bottom: var(--space-xs); margin-bottom: var(--space-xs); border-bottom: 1px solid var(--color-rule-2); }
.path-node { display: flex; align-items: stretch; gap: 10px; height: 48px; margin-bottom: 2px; padding: 4px 6px; border-radius: var(--radius-sm); }
.path-node.clickable { cursor: pointer; }
.path-node.clickable:hover { background: var(--color-surface-2); }
.path-node .path-bar { align-self: flex-end; width: 10px; min-height: 4px; border-radius: 3px; background: var(--color-ink-3); opacity: 0.5; }
.path-node.followed .path-bar, .path-node.root .path-bar { background: var(--color-accent); opacity: 1; }
.path-node.followed { background: var(--color-accent-soft); }
.path-node.ended { opacity: 0.6; }
.path-node.more .path-name { color: var(--color-accent); font-weight: 600; }
.path-text { display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.path-name { font-size: var(--text-sm); overflow-wrap: anywhere; }
.path-mod { color: var(--color-ink-2); }
.path-num { font-size: var(--text-sm); font-weight: 600; }

/* ---------------------------------------------------------- event catalog */

.cat-table td { vertical-align: top; }
.cat-event { font-size: var(--text-sm); }
.cat-count { margin-left: 6px; font-weight: 400; color: var(--color-ink-2); }
.cat-count.warn { color: var(--color-negative); }
.cat-flag {
  margin-left: var(--space-xs);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}
.cat-flag.warn { background: color-mix(in oklch, var(--color-negative) 14%, transparent); color: var(--color-negative); }
.cat-flag.quiet { background: var(--color-surface-2); color: var(--color-ink-2); }
.cat-todo { color: var(--color-ink-2); font-style: italic; }
.cat-params { margin: 0; padding-left: 14px; font-size: var(--text-xs); color: var(--color-ink-2); }
.cat-params code { font-family: var(--font-mono); color: var(--color-ink); }
.cat-sites { margin-top: 5px; font-family: var(--font-mono); font-size: var(--text-2xs); color: var(--color-ink-3); word-break: break-all; }
.cat-dash { color: var(--color-ink-3); }
.cat-table td:nth-child(2), .cat-table td:nth-child(3) { font-size: var(--text-sm); line-height: 1.5; }

/* ------------------------------------- release markers, notes, audience */

.chart-wrap { position: relative; }
.release-line { stroke: var(--color-ink-3); stroke-width: 1; stroke-dasharray: 2 3; }
.release-label {
  position: absolute;
  top: -4px;
  transform: translateX(4px);
  padding: 1px 5px;
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  line-height: 1.3;
  color: var(--color-ink-2);
  background: var(--color-surface);
  border: 1px solid var(--color-rule);
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: auto;
}
/* A marker near the right edge puts its label on the left of the line. */
.release-label.flip { transform: translateX(calc(-100% - 4px)); }

.audience { margin-top: var(--space-xs); }
.card.audience { padding: var(--space-xs) 0 0; background: transparent; border: 0; }
.audience-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: var(--space-2xs); }
.audience-head h4 { margin: 0; }
.audience-sum { font-size: var(--text-sm); }
.audience-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--space-sm); margin-top: var(--space-sm); }
.audience-grid .param-card { margin-bottom: 0; padding: var(--space-md) 18px; }
.report .audience-grid .param-card { background: var(--color-paper); }
.audience .country-row { gap: var(--space-xs); }
.audience .country-row .name { width: 92px; }
.audience .country-row .num { width: 44px; }
.audience .country-row .num.muted-num { opacity: 0.7; }
.audience .pick { padding-inline: 4px; margin-inline: -4px; border-radius: var(--radius-sm); cursor: pointer; }
.audience .pick:hover { background: var(--color-surface-2); }
.chip {
  padding: 3px 10px;
  font-size: var(--text-xs);
  color: var(--color-accent);
  background: var(--color-accent-soft);
  border: 1px solid var(--color-accent-line);
  border-radius: var(--radius-pill);
  cursor: pointer;
}
.chip:hover { border-color: var(--color-accent); }

/* ----------------------------------------------------------------- login */

.login-wrap {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: var(--space-lg) var(--space-md);
  background: var(--color-paper);
}
.login-card {
  width: min(360px, 100%);
  padding: var(--space-xl);
  background: var(--color-surface);
  border: 1px solid var(--color-rule-2);
  border-radius: var(--radius-md);
  box-shadow: 0 24px 48px -24px var(--color-shadow);
}
.login-card .brand { margin-bottom: var(--space-lg); }
.login-card .logo { height: 26px; }
.login-card h1 {
  margin: 0 0 var(--space-2xs);
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: -0.025em;
}
.login-card .lede { margin: 0 0 var(--space-md); font-size: var(--text-sm); color: var(--color-ink-2); }
.login-card label { display: block; margin: var(--space-sm) 0 6px; font-size: var(--text-xs); font-weight: 500; color: var(--color-ink-2); }
.login-card input {
  width: 100%;
  height: 40px;
  padding: 0 var(--space-sm);
  background: var(--color-paper);
  color: var(--color-ink);
  border: 1px solid var(--color-rule-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-md);
}
.login-card input:focus { outline: none; border-color: var(--color-accent); box-shadow: 0 0 0 3px var(--color-accent-soft); }
.login-card button { height: 40px; margin-top: var(--space-lg); font-size: var(--text-sm); }
.login-card .error { display: none; margin-top: var(--space-sm); font-size: var(--text-sm); color: var(--color-negative); }

/* ------------------------------------------------------------ responsive */

@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat:nth-child(4), .stat:nth-child(5) { grid-column: span 1; }
}

@media (max-width: 820px) {
  header { padding: var(--space-sm) var(--space-md); }
  main { padding: var(--space-md) var(--space-md) var(--space-2xl); }
  .hero-grid { grid-template-columns: minmax(0, 1fr); }
  .country-list { grid-template-columns: minmax(0, 1fr); }
  #whoami { display: none; }
}

@media (max-width: 600px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:last-child { grid-column: 1 / -1; }
  .stat-metrics > div:first-child .stat-num { font-size: var(--text-xl); }
  .hero .value, .realtime .value { font-size: var(--text-2xl); }
  .hero, .card { padding: var(--space-md); }
  .head, .row { grid-template-columns: minmax(0, 1fr) 64px 84px 16px; }
  .head.no-dau, .row.no-dau { grid-template-columns: minmax(0, 1fr) 84px 16px; }
  .head > :nth-child(4), .head.no-dau > :nth-child(3), .row .spark, .row svg.spark { display: none; }
  .head.no-dau > :nth-child(4) { display: revert; }
  .row .num { font-size: var(--text-sm); }
  .report { padding: var(--space-md); }
  .audience-grid { grid-template-columns: minmax(0, 1fr); }
  .controls { width: 100%; }
  /* The controls wrap to a second row here; pinned, they'd eat the screen. */
  header { position: static; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation: none !important; }
}

/* Print: the report only. Forced to a light palette because printers and PDF
   readers render the dark theme as a wall of ink. */
@media print {
  @page { margin: 14mm; }
  header, #breadcrumbs, .searchbar, .stats-grid, .hero-grid, #countries,
  .level-title-row, #pushNav, .report-periods, .report-print { display: none !important; }
  .app, body { background: #fff !important; }
  .report {
    background: #fff !important; color: #111 !important;
    border: none !important; border-radius: 0 !important; padding: 0 !important;
  }
  .report * { color: #111 !important; }
  .report-headline { background: #ccc !important; border-color: #ccc !important; }
  .report-metric { background: #fff !important; break-inside: avoid; }
  .report-section { break-inside: avoid; }
  .cat-flag { border: 1px solid #ccc !important; }
  .report-table th, .report-table td { border-color: #ddd !important; }
  .report-metric .delta.up { color: #1a7f42 !important; }
  .report-metric .delta.down { color: #b3261e !important; }
  main { padding: 0 !important; max-width: none !important; }
  .report .bar-fill { background: #888 !important; }
  .report .param-card { background: #fff !important; border-color: #ccc !important; break-inside: avoid; }
}

/* The report is a standalone document: hide the dashboard chrome behind it. */
.app.report-view .stats-grid,
.app.report-view .hero-grid,
.app.report-view #countries,
.app.report-view #push,
.app.report-view .searchbar,
.app.report-view .level-title-row { display: none; }
