:root{
  color-scheme: light;
  --bg-page:#f5f7fb;
  --bg-card:#ffffff;
  --bg-card-2:#f0f4ff;
  --bg-nav:rgba(255,255,255,0.92);
  --bg-footer:#0b1220;
  --bg-table-header:#1e2a4a;
  --text-primary:#0f172a;
  --text-secondary:#334155;
  --text-muted:#64748b;
  --text-light:#ffffff;
  --border-color:rgba(15,23,42,0.12);
  --border-strong:rgba(15,23,42,0.18);
  --accent:#4f2e80;
  --accent-2:#29557e33;
  --shadow-sm:0 6px 16px rgba(15,23,42,0.08);
  --shadow-md:0 12px 28px rgba(15,23,42,0.12);
  --radius:16px;
}

[data-theme="dark"]{
  color-scheme: dark;
  --bg-page:#0b1220;
  --bg-card:#111a2e;
  --bg-card-2:#0f1933;
  --bg-nav:rgba(15,25,51,0.92);
  --bg-footer:#070c16;
  --bg-table-header:#0f1933;
  --text-primary:#e5e7eb;
  --text-secondary:#cbd5e1;
  --text-muted:#94a3b8;
  --text-light:#ffffff;
  --border-color:rgba(148,163,184,0.22);
  --border-strong:rgba(148,163,184,0.28);
  --accent:#4f2e80;
  --accent-2:#29557e33;
  --shadow-sm:0 8px 18px rgba(0,0,0,0.35);
  --shadow-md:0 16px 40px rgba(0,0,0,0.45);
}

html,body{height:100%;}
body{
  background:var(--bg-page) !important;
  color:var(--text-primary) !important;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,"Noto Sans","Apple Color Emoji","Segoe UI Emoji";
}

a{color:var(--accent);text-decoration:none;}
a:hover{color:var(--accent-2);}

.navbar,
.navbar.navbar-expand-lg{
  background:var(--bg-nav) !important;
  backdrop-filter:blur(14px);
  border-bottom:1px solid var(--border-color);
}

.card,
.chart-container,
.liveresults,
.container .chart-container{
  background:var(--bg-card);
  border:1px solid var(--border-color);
  border-radius:var(--radius);
  box-shadow:var(--shadow-sm);
}

/* Force common legacy light styles to follow theme */
.content-card,
.contact-card{
  background:var(--bg-card) !important;
  color:var(--text-primary) !important;
  border-color:var(--border-color) !important;
}

.table-custom tbody td{
  background:var(--bg-card) !important;
  color:var(--text-primary) !important;
  border-color:var(--border-color) !important;
}

.table-custom tbody tr:hover,
.table tbody tr:hover{
  background:rgba(102,126,234,0.08) !important;
}

.form-label,
label{
  color:var(--text-primary) !important;
}

.btn,
.btn:focus{box-shadow:none !important;}

.btn-outline-primary{
  border-color:var(--accent) !important;
  color:var(--accent) !important;
}

.btn-outline-primary:hover{
  background:rgba(102,126,234,0.12) !important;
  border-color:var(--accent) !important;
  color:var(--accent) !important;
}

.table{
  color:var(--text-primary) !important;
}

.table thead th{
  background:var(--bg-table-header) !important;
  color:var(--text-light) !important;
  border-color:rgba(255,255,255,0.12) !important;
}

.table td,
.table th{
  border-color:var(--border-color) !important;
}

.table tbody tr{
  background:transparent;
}

.table-hover tbody tr:hover{
  background:rgba(102,126,234,0.08) !important;
}

.form-control,
.form-select{
  background:var(--bg-card);
  color:var(--text-primary);
  border:1px solid var(--border-strong);
}

.form-control:focus,
.form-select:focus{
  border-color:var(--accent);
  box-shadow:0 0 0 .25rem rgba(102,126,234,0.20);
}

.text-muted{color:var(--text-muted) !important;}

.site-footer,
.footer-section,
footer{
  color:rgba(255,255,255,0.88);
}

.site-footer{
  background:var(--bg-footer) !important;
}

.footer-text,
.footer-text p,
.footer-text span,
.footer-text strong{
  color:rgba(255,255,255,0.88) !important;
}

.disclaimer,
.disclaimer-section,
.disclaimer-footer{
  color:var(--text-primary);
}

.disclaimer p,
.disclaimer-section,
.disclaimer-section strong,
.disclaimer-section b{
  color:var(--text-primary) !important;
}

.theme-toggle{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:8px 12px;
  border-radius:999px;
  border:1px solid var(--border-color);
  background:var(--bg-card);
  color:var(--text-primary);
}

.theme-toggle:hover{
  border-color:var(--accent);
}
