:root {
  --bg: #0e1116;
  --bg-elev: #161b22;
  --bg-elev-2: #1c2230;
  --border: #262d3a;
  --text: #e6edf3;
  --text-dim: #9aa6b2;
  --text-faint: #6b7785;
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, 0.14);
  --good: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.28);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }

/* ── Layout ── */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  padding: 22px 14px;
  display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: 0; height: 100vh;
}
.content { padding: 34px 40px 64px; max-width: 1080px; width: 100%; }

/* ── Brand ── */
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; letter-spacing: .2px; padding: 0 8px; }
.brand-mark { color: var(--accent); font-size: 16px; }
.brand-name { font-size: 15px; }
.brand-lg { justify-content: center; font-size: 19px; }
.brand-lg .brand-mark { font-size: 20px; }

/* ── Nav ── */
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 12px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: var(--radius-sm);
  color: var(--text-dim); font-size: 14px; font-weight: 500;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--bg-elev-2); color: var(--text); }
.nav-item.is-active { background: var(--accent-soft); color: var(--text); }
.nav-item.subtle { color: var(--text-faint); }
.nav-icon { width: 16px; text-align: center; opacity: .85; }

/* ── Headings / page header ── */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 26px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0 0 3px; font-weight: 650; }
.page-sub { color: var(--text-dim); font-size: 13.5px; margin: 0; }

/* ── Cards ── */
.card {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-pad { padding: 22px 24px; }
.grid { display: grid; gap: 18px; }
.grid-hero { grid-template-columns: 1.3fr 1fr; }
@media (max-width: 860px) { .grid-hero { grid-template-columns: 1fr; } .layout { grid-template-columns: 1fr; } .sidebar { position: static; height: auto; flex-direction: row; align-items: center; } .nav { flex-direction: row; } }

/* ── Hero number ── */
.kpi-label { color: var(--text-dim); font-size: 13px; text-transform: uppercase; letter-spacing: .6px; }
.kpi-value { font-size: 46px; font-weight: 700; letter-spacing: -1px; margin: 6px 0 4px; font-variant-numeric: tabular-nums; }
.kpi-meta { color: var(--text-faint); font-size: 12.5px; }
.estimate-tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--warn); background: rgba(210,153,34,.12);
  padding: 3px 9px; border-radius: 999px; margin-top: 12px;
}

/* ── Leaderboard ── */
.lb { width: 100%; border-collapse: collapse; }
.lb th { text-align: left; color: var(--text-faint); font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; font-weight: 600; padding: 0 0 10px; }
.lb td { padding: 11px 0; border-top: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.lb tr:first-child td { border-top: none; }
.lb .partner { display: flex; align-items: center; gap: 10px; }
.lb .rank { color: var(--text-faint); width: 18px; font-size: 13px; }
.lb .amount { text-align: right; font-weight: 600; }
.lb .src-pill { font-size: 11px; color: var(--text-dim); background: var(--bg-elev-2); padding: 2px 8px; border-radius: 999px; }

/* ── Source status strip ── */
.sources { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.src-chip { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-dim); background: var(--bg-elev); border: 1px solid var(--border); padding: 6px 11px; border-radius: 999px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); }
.dot.ok { background: var(--good); }
.dot.error { background: var(--bad); }
.dot.stale { background: var(--warn); }
.dot.unconfigured { background: var(--text-faint); }

/* ── Buttons ── */
.btn { font: inherit; font-weight: 550; cursor: pointer; border: 1px solid var(--border); background: var(--bg-elev-2); color: var(--text); padding: 9px 16px; border-radius: var(--radius-sm); transition: background .12s, border-color .12s; }
.btn:hover { background: #232b3b; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #3f7df0; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: default; }

/* ── Flash / empty / states ── */
.flashes { margin-bottom: 18px; display: flex; flex-direction: column; gap: 8px; }
.flash { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13.5px; border: 1px solid transparent; }
.flash-error { background: rgba(248,81,73,.1); border-color: rgba(248,81,73,.3); color: #ffb3ae; }
.flash-success { background: rgba(63,185,80,.1); border-color: rgba(63,185,80,.3); color: #aef0b6; }
.empty { text-align: center; color: var(--text-faint); padding: 38px 10px; }

/* ── Login ── */
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 34px 30px; width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 16px; }
.login-sub { text-align: center; color: var(--text-dim); font-size: 13px; margin: -6px 0 4px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-dim); }
.field input { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.field input:focus { outline: none; border-color: var(--accent); }

.muted { color: var(--text-dim); }
.tabular { font-variant-numeric: tabular-nums; }

/* ── Chart ── */
.chart-card { margin-bottom: 22px; }
.chart-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 6px; }
.chart-total { font-size: 26px; font-weight: 700; letter-spacing: -.5px; margin-top: 2px; }
.chart-hint { font-size: 12.5px; }
.chart { width: 100%; height: auto; display: block; margin-top: 6px; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-ytick, .chart-xtick { fill: var(--text-faint); font-size: 11px; font-family: var(--font); }
.chart-bar { fill: var(--accent); opacity: .8; transition: opacity .12s; cursor: pointer; }
.chart-bar:hover { opacity: 1; }
.chart-bar.sel { fill: #7aa9ff; opacity: 1; }

/* ── Day navigation ── */
.day-nav { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.day-nav-label { font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn.disabled { opacity: .4; pointer-events: none; }

/* ── Page-head actions ── */
.head-actions { display: flex; align-items: center; gap: 12px; }
.last-refresh { font-size: 12.5px; white-space: nowrap; }
