:root {
  --bg: #0f1117;
  --card: #1a1d27;
  --card-border: #262a36;
  --text: #e4e4e7;
  --text-muted: #71717a;
  --accent: #6366f1;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --blue: #3b82f6;
  --orange: #f97316;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* ── Auth Screen ── */
#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px;
}

.auth-card {
  text-align: center;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 40px 32px;
  max-width: 360px;
  width: 100%;
}

.auth-card h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.auth-card p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 24px;
}

.btn-google {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  color: #333;
  border: none;
  border-radius: 8px;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s;
}

.btn-google:hover { background: #f0f0f0; }

/* ── Navbar ── */
#navbar {
  display: flex;
  align-items: center;
  padding: 0 16px;
  height: 52px;
  background: var(--card);
  border-bottom: 1px solid var(--card-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-right: 20px;
  white-space: nowrap;
}

.nav-tabs {
  display: flex;
  gap: 4px;
  flex: 1;
  overflow-x: auto;
}

.nav-tab {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 6px;
  transition: 0.15s;
  white-space: nowrap;
}

.nav-tab:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.nav-tab.active { color: var(--text); background: var(--accent); }

.nav-signout {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  margin-left: 8px;
  display: flex;
  align-items: center;
}

.nav-signout:hover { color: var(--text); background: rgba(255,255,255,0.05); }

/* ── Main Content ── */
#content {
  padding: 16px;
  max-width: 800px;
  margin: 0 auto;
}

/* ── Cards ── */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
}

.card-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ── Summary grid ── */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(85px, 1fr));
  gap: 8px;
}

.si {
  text-align: center;
  padding: 8px 4px;
  border-radius: 8px;
  background: rgba(255,255,255,0.03);
}

.si .v { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.si .l { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

.pos { color: var(--green); }
.neg { color: var(--red); }

/* ── Stat row ── */
.stat-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.stat-row.triple { grid-template-columns: repeat(3, 1fr); }

.stat-box {
  text-align: center;
  padding: 10px 4px;
  border-radius: 8px;
  background: rgba(255,255,255,0.03);
}

.stat-box .num { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-box .lbl { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.stat-box.green .num { color: var(--green); }
.stat-box.red .num { color: var(--red); }
.stat-box.yellow .num { color: var(--yellow); }
.stat-box.blue .num { color: var(--blue); }

/* ── Revenue ── */
.revenue { text-align: center; padding: 14px; }
.revenue .amount { font-size: 32px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -1px; }
.revenue .amount.positive { color: var(--green); }
.revenue .amount.negative { color: var(--red); }
.revenue .amount.zero { color: var(--text-muted); }
.revenue .sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Bankroll grid ── */
.bankroll-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.bankroll-item { background: rgba(99,102,241,0.08); border-radius: 8px; padding: 12px; }
.bankroll-item .label { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.bankroll-item .value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ── Bet list ── */
.bet-list { list-style: none; }
.bet-item { padding: 12px 0; border-bottom: 1px solid var(--card-border); display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.bet-item:last-child { border-bottom: none; }
.bet-info { flex: 1; min-width: 0; }
.bet-info .match { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; color: var(--text); text-decoration: none; }
.bet-info .detail { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.bet-meta { text-align: right; flex-shrink: 0; }
.bet-meta .stake { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.bet-meta .odds { font-size: 11px; color: var(--accent); margin-top: 2px; }

.badge { display: inline-block; font-size: 10px; font-weight: 600; text-transform: uppercase; padding: 2px 6px; border-radius: 4px; margin-top: 4px; }
.badge.won { background: rgba(34,197,94,0.15); color: var(--green); }
.badge.lost { background: rgba(239,68,68,0.15); color: var(--red); }
.badge.void { background: rgba(234,179,8,0.15); color: var(--yellow); }
.badge.pending { background: rgba(99,102,241,0.15); color: var(--accent); }
.badge.placed { background: rgba(59,130,246,0.15); color: var(--blue); }
.badge.rejected { background: rgba(239,68,68,0.1); color: var(--red); }

/* ── Charts ── */
.chart-wrap { position: relative; width: 100%; }
canvas { width: 100% !important; }

/* ── Breakdown table ── */
table.bd { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 11px; }
table.bd th, table.bd td { padding: 5px 6px; text-align: right; border-bottom: 1px solid var(--card-border); }
table.bd th { color: var(--text-muted); font-weight: 600; text-transform: uppercase; font-size: 9px; letter-spacing: 0.3px; }
table.bd th:first-child, table.bd td:first-child { text-align: left; }

/* ── Admin fields ── */
.field { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--card-border); }
.field:last-child { border-bottom: none; }
.field label { font-size: 13px; color: var(--text); flex: 1; }
.field .hint { font-size: 11px; color: var(--text-muted); display: block; }
.field input[type="number"] { width: 90px; background: var(--bg); border: 1px solid var(--card-border); border-radius: 6px; color: var(--text); padding: 6px 10px; font-size: 13px; text-align: right; }
.field input[type="number"]:focus { outline: none; border-color: var(--accent); }

.toggle { position: relative; width: 44px; min-width: 44px; height: 24px; flex: 0 0 44px; cursor: pointer; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider { position: absolute; inset: 0; background: var(--card-border); border-radius: 12px; transition: 0.2s; }
.toggle .slider::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; bottom: 3px; background: var(--text); border-radius: 50%; transition: 0.2s; }
.toggle input:checked + .slider { background: var(--green); }
.toggle input:checked + .slider::before { transform: translateX(20px); }

.tier-table { border: 1px solid var(--card-border); border-radius: 8px; overflow: hidden; }
.tier-header { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; padding: 8px 12px; background: var(--bg); font-size: 10px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; }
.tier-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--card-border); }
.tier-input { width: 100%; background: var(--bg); border: 1px solid var(--card-border); border-radius: 6px; color: var(--text); padding: 6px 10px; font-size: 13px; text-align: right; }
.tier-input:focus { outline: none; border-color: var(--accent); }

.bookie-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--card-border); }
.bookie-row:last-child { border-bottom: none; }
.bookie-info { flex: 1; }
.bookie-id { font-size: 13px; font-weight: 600; }
.bookie-desc { font-size: 11px; color: var(--text-muted); }
.bookie-type { font-size: 11px; color: var(--accent); background: var(--bg); padding: 2px 6px; border-radius: 4px; margin-right: 12px; }

.btn-save { background: #238636; color: #fff; border: none; border-radius: 8px; padding: 10px 24px; font-size: 14px; cursor: pointer; width: 100%; margin-top: 8px; transition: 0.15s; }
.btn-save:hover { background: #2ea043; }
.btn-save:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Toast ── */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #238636; color: #fff; padding: 10px 20px; border-radius: 8px; font-size: 13px; opacity: 0; transition: opacity 0.3s; pointer-events: none; z-index: 200; }
.toast.show { opacity: 1; }
.toast.error { background: var(--red); }

/* ── Loading ── */
.loading { text-align: center; color: var(--text-muted); padding: 40px; font-size: 13px; }
.loading::after { content: ""; display: block; width: 20px; height: 20px; border: 2px solid var(--card-border); border-top-color: var(--accent); border-radius: 50%; margin: 12px auto 0; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty { text-align: center; color: var(--text-muted); font-size: 13px; padding: 20px; }

/* ── Responsive ── */
@media (max-width: 480px) {
  .nav-brand { display: none; }
  .nav-tabs { justify-content: center; }
  #content { padding: 12px; }
}
