/* Lumos Analytics. Chart colours and chrome follow a validated, colour-blind-safe palette
   (series 1-4 checked in light and dark); the header uses the studio's navy. */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #706e69;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --ring: rgba(11, 11, 11, 0.10);
  --brand: #003366;
  --accent: #2a78d6;
  --s1: #2a78d6;  /* Google Play */
  --s2: #eb6834;  /* AdMob */
  --s3: #1baf7a;  /* Website (Paystack) */
  --s4: #eda100;  /* App Store */
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --up: #006300;
  --down: #b42318;
  --wash: rgba(42, 120, 214, 0.10);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #9a9890;
    --grid: #2c2c2a;
    --axis: #383835;
    --ring: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --s4: #c98500;
    --up: #0ca30c;
    --down: #f97066;
    --wash: rgba(57, 135, 229, 0.12);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2 { margin: 0; font-weight: 600; }
h2 { font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
button { font: inherit; cursor: pointer; }

/* Header */
.topbar { background: var(--brand); color: #fff; position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1280px; margin: 0 auto; display: flex; align-items: center; gap: 12px; padding: 10px 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; margin-right: auto; }
.brand img { border-radius: 7px; }
.updated { font-size: 0.8rem; color: rgba(255, 255, 255, 0.75); }
.topbar form { margin: 0; }
.btn-ghost { background: rgba(255, 255, 255, 0.12); color: #fff; border: 0; border-radius: 8px; padding: 6px 12px; font-size: 0.85rem; }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.22); }
.btn-link { background: none; border: 0; color: var(--accent); font-size: 0.85rem; padding: 4px 6px; border-radius: 6px; }
.btn-link[aria-pressed="true"] { background: var(--wash); }

.page { max-width: 1280px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }

/* Filters */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.segmented { display: inline-flex; background: var(--surface); border-radius: 10px; padding: 3px; box-shadow: 0 0 0 1px var(--ring); }
.segmented button { border: 0; background: none; color: var(--ink-2); padding: 6px 12px; border-radius: 8px; font-size: 0.88rem; }
.segmented button[aria-checked="true"] { background: var(--brand); color: #fff; font-weight: 600; }
.select-wrap select {
  font: inherit; font-size: 0.9rem; color: var(--ink); background: var(--surface);
  border: 0; box-shadow: 0 0 0 1px var(--ring); border-radius: 10px; padding: 7px 10px; max-width: 72vw;
}
.range-label { font-size: 0.85rem; }
@media (max-width: 560px) { .updated { display: none; } .brand { font-size: 0.95rem; } }

/* Cards */
.card { margin: 0; background: var(--surface); border-radius: 12px; box-shadow: 0 0 0 1px var(--ring); padding: 16px; min-width: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2-wide { grid-template-columns: 3fr 2fr; }
@media (max-width: 900px) { .grid-2, .grid-2-wide { grid-template-columns: 1fr; } }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { background: var(--surface); border-radius: 12px; box-shadow: 0 0 0 1px var(--ring); padding: 12px 14px; min-width: 0; }
.kpi-label { font-size: 0.8rem; color: var(--ink-2); }
.kpi-value { font-size: 1.6rem; font-weight: 600; line-height: 1.25; margin-top: 2px; }
.kpi-note { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }
.delta-up { color: var(--up); }
.delta-down { color: var(--down); }
.kpi-empty .kpi-value { color: var(--muted); }

/* Charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke: var(--s1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--wash); }
.chart .crosshair { stroke: var(--axis); stroke-width: 1; }
.chart .dot { fill: var(--s1); stroke: var(--surface); stroke-width: 2; }
.chart .end-label { fill: var(--ink-2); font-size: 11px; font-weight: 600; }
.chart .bar-hit { fill: transparent; }
.chart .col-hl { fill: var(--grid); opacity: 0.6; }
.chart .seg-play { fill: var(--s1); }
.chart .seg-admob { fill: var(--s2); }
.chart .seg-paystack { fill: var(--s3); }
.chart .seg-appstore { fill: var(--s4); }
.empty { display: grid; place-items: center; text-align: center; min-height: 160px; color: var(--muted); font-size: 0.9rem; padding: 16px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 8px; font-size: 0.82rem; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

.tooltip {
  position: fixed; z-index: 50; pointer-events: none; min-width: 140px;
  background: var(--surface); color: var(--ink); border-radius: 10px; padding: 8px 10px;
  box-shadow: 0 0 0 1px var(--ring), 0 8px 24px rgba(0, 0, 0, 0.18); font-size: 0.82rem;
}
.tooltip .tt-date { color: var(--muted); margin-bottom: 4px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 8px; }
.tooltip .tt-row s { width: 12px; height: 2px; border-radius: 1px; display: inline-block; text-decoration: none; }
.tooltip .tt-row strong { font-variant-numeric: tabular-nums; margin-left: auto; padding-left: 14px; }
.tooltip .tt-total { border-top: 1px solid var(--grid); margin-top: 4px; padding-top: 4px; }
.tooltip .tt-row span { color: var(--ink-2); }

/* Tables */
.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
table.data th { text-align: left; font-weight: 600; color: var(--ink-2); padding: 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
table.data td { padding: 8px; border-bottom: 1px solid var(--grid); vertical-align: top; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tr:last-child td { border-bottom: 0; }
.app-name { font-weight: 600; }
.app-id { color: var(--muted); font-size: 0.75rem; overflow-wrap: anywhere; }
table.data td:first-child { min-width: 200px; }
.status { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-weight: 600; font-size: 0.8rem; }
.status-icon {
  display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%;
  font-size: 10px; line-height: 1; font-weight: 700; color: #fff; background: var(--muted);
}
.status.good .status-icon { background: var(--good); }
.status.warning .status-icon { background: var(--warning); color: #0b0b0b; }
.status.serious .status-icon { background: var(--serious); color: #0b0b0b; }
.status.critical .status-icon { background: var(--critical); }
.app-link { background: none; border: 0; padding: 0; color: var(--ink); font-weight: 600; text-align: left; }
.app-link:hover { text-decoration: underline; }
.more-row td { text-align: center; }
.status-reason { display: block; font-weight: 400; color: var(--muted); font-size: 0.75rem; }
.over { color: var(--critical); font-weight: 600; }

/* Reviews */
.reviews { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; max-height: 640px; overflow-y: auto; }
.review { padding: 10px 12px; border-radius: 10px; background: var(--page); }
.review-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 0.82rem; }
.stars { letter-spacing: 1px; font-size: 0.9rem; }
.stars.low { color: var(--critical); }
.review-title { font-weight: 600; margin-top: 4px; }
.review-text { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--ink-2); white-space: nowrap; }

/* Sources */
.sources { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.source { padding: 10px 12px; border-radius: 10px; background: var(--page); }
.source-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.source-name { font-weight: 600; font-size: 0.9rem; }
.source-msg { font-size: 0.82rem; color: var(--ink-2); margin-top: 2px; overflow-wrap: anywhere; }
.source-msg a { color: var(--accent); }

/* Loading: keep the frame, dim it */
body.loading .page > *:not(.filters) { opacity: 0.55; transition: opacity 0.15s; }

/* Sign-in */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border-radius: 16px; box-shadow: 0 0 0 1px var(--ring); padding: 28px; text-align: center; }
.login-icon { border-radius: 12px; }
.login-card h1 { font-size: 1.3rem; margin-top: 10px; }
.login-card form { text-align: left; margin-top: 18px; display: grid; gap: 8px; }
.login-card label { font-size: 0.85rem; font-weight: 600; }
.login-card input { font: inherit; padding: 10px 12px; border-radius: 10px; border: 0; box-shadow: 0 0 0 1px var(--axis); background: var(--page); color: var(--ink); }
.btn-primary { margin-top: 6px; background: var(--brand); color: #fff; border: 0; border-radius: 10px; padding: 10px; font-weight: 600; }
.form-error { color: var(--critical); font-size: 0.85rem; margin: 4px 0 0; }
