/* ──────────────────────────────────────────────────────────────
   Alokai paid-media dashboard theme.
   Ported from the Alokai design system (claude.ai/design):
   - Signature green #00E16D on near-black ink #151A16
   - Inter everywhere; slightly negative tracking
   - Warm off-white page (#F2F7F4), hairline-bordered white cards
   - Pills for actions, soft rectangles for structure
   ────────────────────────────────────────────────────────────── */
/* Inter, self-hosted (variable weight, SIL OFL): the CSP allows no third-party
   font or style origins, and no visitor IP goes to Google Fonts. */
@font-face{font-family:Inter;font-style:normal;font-weight:100 900;font-display:swap;src:url(/static/fonts/inter-latin.woff2) format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}
@font-face{font-family:Inter;font-style:normal;font-weight:100 900;font-display:swap;src:url(/static/fonts/inter-latin-ext.woff2) format('woff2');unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}

:root {
  /* Brand */
  --brand-green:        rgb(0,225,109);
  --brand-green-strong: rgb(7,203,97);
  --brand-green-dark:   rgb(0,128,62);
  --brand-green-darker: rgb(0,51,25);
  --brand-green-light:  rgb(194,242,210);
  --brand-green-lighter:rgb(229,255,238);
  --brand-ink:          rgb(21,26,22);

  /* Accent (purple) + mint — used for the second series / breakdowns */
  --accent-purple:      rgb(126,87,217);
  --mint-base:          rgb(155,204,180);

  /* Neutrals (warm green-grey ramp) */
  --n-0:   rgb(255,255,255);
  --n-50:  rgb(249,251,250);
  --n-100: rgb(242,247,244);
  --n-200: rgb(215,224,219);
  --n-300: rgb(168,178,171);
  --n-400: rgb(129,140,133);
  --n-500: rgb(92,102,95);
  --n-600: rgb(67,77,70);
  --n-700: rgb(44,51,46);
  --n-800: rgb(32,38,34);
  --n-900: rgb(21,26,22);

  /* Semantic surfaces / text / lines mapped to the app's class vocabulary */
  --bg: var(--n-100);
  --surface: var(--n-0);
  --surface-soft: var(--n-50);
  --surface-alt: var(--n-100);
  --ink: var(--n-900);
  --ink-soft: var(--n-700);
  --ink-mid: var(--n-500);
  --muted: var(--n-400);
  --line: var(--n-200);
  --line-strong: var(--n-300);

  --accent: var(--brand-green);
  --accent-soft: var(--brand-green-lighter);
  --accent-strong: var(--brand-green-strong);
  --accent-ink: var(--brand-green-darker);   /* readable green text on light */
  --on-accent: var(--brand-ink);             /* ink reads on green */

  --good: rgb(19,195,96);
  --warn: rgb(237,153,14);
  --bad:  rgb(226,7,72);

  --radius: 12px;
  --radius-lg: 16px;
  --radius-pill: 9999px;
  --shadow-sm: 0 1px 2px rgba(21,26,22,0.06);
  --shadow: 0 1px 3px rgba(21,26,22,0.08), 0 1px 2px rgba(21,26,22,0.04);
  --shadow-md: 0 4px 12px rgba(21,26,22,0.10), 0 2px 4px rgba(21,26,22,0.05);
  --ring: 0 0 0 3px rgba(0,225,109,0.30);

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 14px; line-height: 1.5;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
/* Faint interlocking-"A" brand watermark, bottom-right, behind everything. */
body::before {
  content: ""; position: fixed; right: -40px; bottom: -40px;
  width: 360px; height: 360px; z-index: 0; pointer-events: none;
  background: url("/static/alokai-symbol.svg") no-repeat center / contain;
  opacity: 0.035;
}
body > * { position: relative; z-index: 1; }
a { color: inherit; text-decoration: none; }
::selection { background: rgba(0,225,109,0.28); }
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: none; box-shadow: var(--ring); border-radius: 8px;
}

/* ----- Top bar (ink) ----- */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 12px 28px; background: var(--brand-ink); color: var(--n-0);
  border-bottom: 1px solid var(--brand-ink);
  position: sticky; top: 0; z-index: 20;
}
/* Full Alokai lockup (symbol + lowercase wordmark) in signature green on the
   ink topbar - the brand's core "green on near-black ink" statement. The
   lockup is single-colour by design (never recolour only half of it). */
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; color: var(--brand-green); }
.brand-lockup { display: inline-flex; }
.brand-lockup svg { display: block; height: 24px; width: auto; }
.brand .brand-tag {
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: rgba(255,255,255,0.6); border: 1px solid rgba(255,255,255,0.18);
  padding: 2px 9px; border-radius: var(--radius-pill);
}

.tabs { display: flex; gap: 4px; margin-left: 12px; }
.tab {
  padding: 7px 14px; border-radius: var(--radius-pill); color: rgba(255,255,255,0.72);
  font-weight: 500; font-size: 13.5px; letter-spacing: -0.005em;
  transition: background 120ms ease, color 120ms ease;
}
.tab:hover { background: rgba(255,255,255,0.08); color: var(--n-0); }
.tab.is-active { background: var(--brand-green); color: var(--on-accent); font-weight: 600; }
.tab-signout { display: none; }

.user { margin-left: auto; display: flex; align-items: center; gap: 12px; color: rgba(255,255,255,0.7); }
.freshness-badge {
  font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: var(--radius-pill);
  letter-spacing: 0.01em; font-variant-numeric: tabular-nums;
  background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.8);
  border: 1px solid rgba(255,255,255,0.14); cursor: help;
}
.freshness-badge.fresh  { background: rgba(0,225,109,0.16); color: var(--brand-green); border-color: rgba(0,225,109,0.4); }
.freshness-badge.stale  { background: rgba(237,153,14,0.16); color: rgb(253,199,110); border-color: rgba(237,153,14,0.4); }
.freshness-badge.broken { background: rgba(226,7,72,0.18); color: rgb(255,150,175); border-color: rgba(226,7,72,0.45); }
.avatar { width: 26px; height: 26px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.2); }
.email { font-size: 13px; color: rgba(255,255,255,0.8); }
.logout {
  color: rgba(255,255,255,0.6); font-size: 12.5px; padding: 6px 10px; border-radius: 8px;
}
.logout:hover { color: var(--n-0); background: rgba(255,255,255,0.08); }

.hamburger {
  display: none; background: transparent; border: 1px solid rgba(255,255,255,0.24);
  border-radius: 10px; padding: 0; cursor: pointer;
  flex-direction: column; gap: 4px; align-items: center; justify-content: center;
  width: 38px; height: 38px;
}
.hamburger span { display: block; width: 18px; height: 2px; background: var(--n-0); border-radius: 1px; transition: transform 200ms ease, opacity 200ms ease; }
.hamburger[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.hamburger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.hamburger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ----- Range bar ----- */
.range {
  display: flex; align-items: center; gap: 14px; padding: 18px 28px 8px;
  flex-wrap: wrap; max-width: 1480px; margin: 0 auto;
}
.range label {
  color: var(--muted); font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.04em; display: flex; align-items: center; gap: 8px; font-weight: 600;
}
.range input[type="date"] {
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); font-family: var(--font); font-size: 13.5px; color: var(--ink);
}
.range input[type="date"]:hover { border-color: var(--line-strong); }
.btn-primary {
  background: var(--brand-green); color: var(--on-accent); border: 0;
  padding: 9px 20px; border-radius: var(--radius-pill);
  font-weight: 600; font-size: 13.5px; cursor: pointer; font-family: var(--font);
  letter-spacing: -0.005em; transition: background 120ms ease, transform 80ms ease, box-shadow 120ms ease;
}
.btn-primary:hover { background: var(--accent-strong); box-shadow: 0 4px 14px rgba(0,225,109,0.35); }
.btn-primary:active { transform: translateY(1px); }
.muted { color: var(--muted); font-size: 12px; }
.range-sep { width: 1px; height: 22px; background: var(--line-strong); margin: 0 4px; }

main { padding: 8px 28px 72px; max-width: 1480px; margin: 0 auto; }

/* ----- Page intro / banner note ----- */
.intro { margin: 8px 0 20px; }
.intro h1 {
  font-size: 26px; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 4px;
}
.intro p { color: var(--ink-mid); margin: 0; font-size: 14px; max-width: 720px; }
.note {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--accent-soft); border: 1px solid var(--brand-green-light);
  color: var(--brand-green-darker); border-radius: var(--radius);
  padding: 12px 16px; font-size: 13px; margin-bottom: 18px;
}
.note .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand-green-strong); margin-top: 6px; flex: none; }
.note code { font-family: var(--mono); font-size: 12px; background: rgba(0,51,25,0.06); padding: 1px 5px; border-radius: 5px; }

/* ----- KPIs ----- */
.kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; margin-bottom: 22px;
}
.kpi {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 15px 16px; box-shadow: var(--shadow-sm);
}
.kpi .label {
  color: var(--muted); font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.06em; font-weight: 600;
}
.kpi .value {
  font-size: 24px; font-weight: 600; margin-top: 6px;
  letter-spacing: -0.03em; color: var(--ink); font-variant-numeric: tabular-nums;
}
.kpi .sub { color: var(--ink-mid); font-size: 12px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi.accent { background: var(--brand-ink); border-color: var(--brand-ink); }
.kpi.accent .label { color: rgba(255,255,255,0.6); }
.kpi.accent .value { color: var(--brand-green); }

/* ----- Cards ----- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 18px 20px; box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
}
.card.no-pad { padding: 0; overflow: hidden; }
.card h2 {
  margin: 0 0 14px 0; font-size: 15px; font-weight: 600;
  letter-spacing: -0.01em; color: var(--ink);
}
.card.no-pad h2 { padding: 18px 20px 0; }
.card h3 {
  margin: 18px 0 8px 0; font-size: 12px; font-weight: 600; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: 0.05em;
}
.card .sub-head { color: var(--muted); font-size: 12.5px; margin: -8px 0 14px; }

/* ----- Tables ----- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap > table { min-width: 760px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td {
  padding: 11px 12px; text-align: right; border-bottom: 1px solid var(--line);
  white-space: nowrap; font-variant-numeric: tabular-nums;
}
th:first-child, td:first-child { text-align: left; font-variant-numeric: normal; }
thead th {
  background: var(--surface-soft); color: var(--muted);
  font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  border-bottom: 1px solid var(--line);
}
tbody tr:hover { background: var(--surface-soft); }
tbody tr:last-child td { border-bottom: 0; }
tr.total td {
  font-weight: 700; background: var(--surface-alt);
  border-top: 2px solid var(--line-strong);
}
/* Grouped (campaign -> ad group) table: a bold group-header row per campaign,
   then its ad-group rows indented beneath. */
tbody.grp { border-top: 2px solid var(--line-strong); }
tbody.grp:first-of-type { border-top: 0; }
tr.grp-head td { font-weight: 700; background: var(--surface-soft); }
tr.grp-child td.sub { padding-left: 30px; color: var(--ink-mid); font-weight: 400; }
td.sub { position: relative; }
td.num { font-family: var(--mono); font-size: 12.5px; color: var(--ink); }
td.dim { color: var(--muted); }
.chan-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }

/* Segmented control (quick range) */
.seg {
  display: inline-flex; background: rgba(255,255,255,0.08); border-radius: var(--radius-pill); padding: 3px;
  border: 1px solid var(--line);
}
.range .seg { background: var(--surface); }
.seg-btn {
  background: transparent; border: 0; padding: 6px 13px; border-radius: var(--radius-pill);
  font-family: var(--font); font-size: 12.5px; font-weight: 600; color: var(--ink-mid);
  cursor: pointer; letter-spacing: -0.005em;
  transition: background 120ms ease, color 120ms ease;
}
.seg-btn:hover:not(.is-active) { color: var(--ink); }
.seg-btn.is-active { background: var(--brand-ink); color: var(--n-0); }
.range .seg-btn.is-active { background: var(--brand-ink); color: var(--n-0); }

/* ----- Charts ----- */
.two-col {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 18px; margin-bottom: 18px;
}
.two-col > .card { margin-bottom: 0; }
.chart-box { position: relative; width: 100%; }
.chart-box > canvas { width: 100% !important; height: 100% !important; display: block; }

/* Status / pace pills */
.pct-pill {
  display: inline-block; padding: 2px 8px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.pct-pill.pace-good { background: var(--brand-green-lighter); color: var(--brand-green-darker); }
.pct-pill.pace-warn { background: rgb(254,238,212); color: rgb(146,64,14); }
.pct-pill.pace-bad  { background: rgb(255,232,237); color: rgb(153,27,49); }
.pct-pill.pace-neutral { background: var(--surface-alt); color: var(--muted); }

/* Empty state */
.empty {
  padding: 44px 28px; text-align: center; color: var(--ink-mid); font-size: 14px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.empty .empty-symbol { color: var(--brand-green); opacity: 0.9; margin-bottom: 4px; }
.empty strong { color: var(--ink); font-weight: 600; }
.empty code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-alt); padding: 2px 6px; border-radius: 6px; }

/* ===== Mobile / narrow viewport ===== */
@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; gap: 10px 8px; padding: 10px 16px; position: relative; }
  .brand { order: 0; flex: 1 1 auto; min-width: 0; }
  .brand .brand-tag { display: none; }
  .user { order: 1; gap: 8px; margin-left: auto; }
  .user .email { display: none; }
  .user .logout { display: none; }
  .hamburger { display: inline-flex; order: 2; }

  .tabs {
    order: 99; width: 100%; margin-left: 0;
    flex-direction: column; gap: 2px;
    background: rgba(255,255,255,0.04); border-top: 1px solid rgba(255,255,255,0.1);
    margin: 8px -16px -10px; padding: 8px 16px 12px;
    display: none;
  }
  .tabs.is-open { display: flex; }
  .tab { padding: 12px 14px; font-size: 14px; border-radius: 10px; }
  .tab-signout {
    display: block; margin-top: 8px; padding-top: 14px;
    border-top: 1px solid rgba(255,255,255,0.1); color: rgb(255,150,175); font-weight: 600;
  }

  .range {
    padding: 12px 16px 8px; gap: 8px; display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "from to" "quick quick" "apply apply";
    align-items: center;
  }
  .range > label:nth-of-type(1) { grid-area: from; }
  .range > label:nth-of-type(2) { grid-area: to; }
  .range > #applyRange { grid-area: apply; width: 100%; }
  .range > #quickRange { grid-area: quick; }
  .range-sep { display: none; }
  .range label { font-size: 10.5px; flex-direction: column; align-items: stretch; gap: 4px; }
  .range input[type="date"] { width: 100%; padding: 10px; font-size: 14px; }
  #quickRange {
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; width: 100%;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-pill); padding: 3px;
  }
  #quickRange .seg-btn { padding: 8px 4px; font-size: 12px; }

  main { padding: 4px 16px 56px; }
  .intro h1 { font-size: 22px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { padding: 12px; }
  .kpi .value { font-size: 20px; }
  .two-col { grid-template-columns: 1fr; gap: 12px; }
  .card { padding: 14px; }
  .card.no-pad h2 { padding: 14px 14px 0; }
  .card h2 { font-size: 14px; }
  .freshness-badge { font-size: 10.5px; padding: 3px 8px; }
}

@media (max-width: 480px) {
  .kpi .value { font-size: 18px; }
  .freshness-badge { display: none; }
  main { padding: 4px 12px 44px; }
  .range { padding: 10px 12px 4px; }
}
