/* Rewards admin. Colors by role; dark mode has its own validated steps (dataviz reference palette). */
:root {
  color-scheme: light;
  --surface-0: #f4f3f0;
  --surface-1: #fcfcfb;
  --border: #e2e1dc;
  --grid: #ecebe7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #77766f;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --series-1: #2a78d6;
  --hover-band: rgba(42, 120, 214, 0.08);
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-ink: #006300;
  --critical-ink: #b02a2a;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --surface-0: #111110;
    --surface-1: #1a1a19;
    --border: #2e2e2b;
    --grid: #262624;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #96958c;
    --accent: #3987e5;
    --series-1: #3987e5;
    --hover-band: rgba(57, 135, 229, 0.14);
    --good-ink: #4cc24c;
    --critical-ink: #f08a8a;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--surface-0); color: var(--text-primary); }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 20px; }
h2 { font-size: 15px; }
.muted { color: var(--text-muted); }
.secondary { color: var(--text-secondary); }
.loading { padding: 40px; color: var(--text-muted); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
.side { background: var(--surface-1); border-right: 1px solid var(--border); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; }
.brand { font-weight: 700; font-size: 16px; padding: 4px 10px 16px; }
.nav a { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-radius: 8px; color: var(--text-secondary); text-decoration: none; }
.nav a:hover { background: var(--surface-0); color: var(--text-primary); }
.nav a.active { background: var(--surface-0); color: var(--text-primary); font-weight: 600; }
.count { background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 0 7px; font-size: 12px; font-weight: 600; }
.side .spacer { flex: 1; }
.main { padding: 22px 28px 60px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .side { flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--border); }
  .side .spacer, .brand { display: none; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; width: 100%; }
  .side { align-items: center; padding: 8px; }
  .main { padding: 16px; }
}

/* ---------- cards / tiles ---------- */
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 16px; }
.card h2 { margin-bottom: 12px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.tile .label { color: var(--text-secondary); font-size: 12.5px; }
.tile .value { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; }
.tile .sub { color: var(--text-muted); font-size: 12.5px; }
.tile.attention { border-color: var(--accent); }

/* ---------- charts (small multiples, one series each) ---------- */
.charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.chart h3 { font-size: 13.5px; font-weight: 600; }
.chart .total { color: var(--text-muted); font-size: 12.5px; margin-bottom: 6px; }
.chart svg { display: block; width: 100%; height: auto; max-height: 200px; overflow: visible; }
.chart .bar { fill: var(--series-1); }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--text-muted); font-size: 10.5px; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover, .chart .hit.on { fill: var(--hover-band); }
.tooltip { position: fixed; z-index: 10; pointer-events: none; background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 9px; font-size: 12.5px; box-shadow: 0 4px 14px rgba(0,0,0,.12); }
.tooltip b { font-variant-numeric: tabular-nums; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { color: var(--text-secondary); font-weight: 600; font-size: 12.5px; white-space: nowrap; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-0); }
td .small { font-size: 12px; color: var(--text-muted); }
.amount-pos { color: var(--good-ink); }
.amount-neg { color: var(--critical-ink); }
.empty { padding: 24px; text-align: center; color: var(--text-muted); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; color: var(--text-secondary); }

/* ---------- status badges: color + dot + text, never color alone ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface-0); color: var(--text-primary); white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); }
.badge.good::before { background: var(--good); }
.badge.warning::before { background: var(--warning); }
.badge.serious::before { background: var(--serious); }
.badge.critical::before { background: var(--critical); }
.badge.info::before { background: var(--accent); }

/* ---------- controls ---------- */
button, .btn { font: inherit; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary);
  padding: 6px 12px; cursor: pointer; white-space: nowrap; }
button:hover { border-color: var(--text-muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.danger { color: var(--critical-ink); }
button:disabled { opacity: .5; cursor: progress; }
button.small { padding: 3px 9px; font-size: 12.5px; }
input, select { font: inherit; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary); }
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs button { border-radius: 999px; }
.tabs button.on { background: var(--text-primary); color: var(--surface-1); border-color: var(--text-primary); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.notice { border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; border: 1px solid var(--border); background: var(--surface-1); }
.notice.error { border-color: var(--critical); }
.notice.ok { border-color: var(--good); }
.error-text { color: var(--critical-ink); font-size: 12.5px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-bottom: 16px; }
.grid2 > .card { margin-top: 0; }
.grid2 + .card { margin-top: 0; }
dl.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
dl.kv dt { color: var(--text-secondary); }
dl.kv dd { margin: 0; }

/* ---------- login ---------- */
.login { max-width: 360px; margin: 12vh auto; }
.login form { display: grid; gap: 10px; }
.login input { width: 100%; }
