/* ------- Design tokens ------- */
:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #0f172a;
  --ink-2: #475569;
  --muted: #94a3b8;
  --line: #e2e8f0;
  --accent: #0a4578;        /* UT Ladakh navy */
  --accent-2: #06365f;
  --danger: #dc2626;
  --warn: #d97706;
  --ok: #1d6ba8;
  --info: #0ea5e9;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  --shadow-lg: 0 10px 30px rgba(15,23,42,.08), 0 4px 10px rgba(15,23,42,.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ------- Layout ------- */
.topbar {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  color: white;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
}
.topbar .brand { font-weight: 700; font-size: 16px; letter-spacing: .3px; }
.topbar .brand small { display: block; font-weight: 400; font-size: 11px; opacity: .85; letter-spacing: .5px; text-transform: uppercase; }
.topbar .user { display: flex; align-items: center; gap: 14px; font-size: 14px; }
.topbar .user button { background: rgba(255,255,255,.15); color: white; border: 1px solid rgba(255,255,255,.3); border-radius: 6px; padding: 6px 12px; cursor: pointer; font-size: 13px; }
.topbar .user button:hover { background: rgba(255,255,255,.25); }

.tabs { background: var(--surface); border-bottom: 1px solid var(--line); padding: 0 24px; display: flex; gap: 4px; overflow-x: auto; }
.tabs button { background: none; border: none; padding: 14px 18px; font-size: 14px; color: var(--ink-2); font-weight: 500; cursor: pointer; border-bottom: 3px solid transparent; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.tabs button:hover:not(.active) { color: var(--ink); background: var(--surface-2); }
/* Thin vertical separator in the admin tab bar between core-admin tabs and the RO/DC jump-in tabs. */
.tabs .tabs-sep { align-self: center; width: 1px; height: 26px; background: var(--line); margin: 0 4px; }
.tabs button[data-tab="ro-console"], .tabs button[data-tab="dc-console"] {
  color: var(--accent); font-weight: 600;
}
.tabs button[data-tab="ro-console"]:hover, .tabs button[data-tab="dc-console"]:hover { background: #eef5fb; color: var(--accent); }

.content { padding: 24px; max-width: 1400px; margin: 0 auto; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-header h1 { margin: 0; font-size: 22px; }
.page-header .subtitle { color: var(--ink-2); font-size: 14px; }

/* ------- Card ------- */
.card { background: var(--surface); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.card + .card { margin-top: 16px; }
.card h2 { margin: 0 0 14px; font-size: 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card h3 { margin: 16px 0 8px; font-size: 14px; color: var(--ink-2); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* ------- Form ------- */
label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 4px; font-weight: 500; }
input:not([type]), input[type=text], input[type=password], input[type=number], input[type=email], input[type=date], input[type=search], input[type=tel], input[type=url], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; font-family: inherit; background: white; box-sizing: border-box;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(10,69,120,.15); }
input[type=color] { width: 44px; height: 32px; padding: 2px; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }
input[type=file] { padding: 6px; font-size: 13px; }
.form-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 12px; }
.form-row .wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 8px; font-size: 14px; font-family: inherit; font-weight: 500; cursor: pointer; border: 1px solid transparent; }
button.primary, .btn.primary { background: var(--accent); color: white; }
button.primary:hover, .btn.primary:hover { background: var(--accent-2); }
button.secondary, .btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
button.secondary:hover, .btn.secondary:hover { background: var(--surface-2); }
button.danger { background: var(--danger); color: white; }
button.danger:hover { background: #b91c1c; }
button.ok { background: var(--ok); color: white; }
button.warn { background: var(--warn); color: white; }
button.small { padding: 4px 10px; font-size: 12px; }
button:disabled { opacity: .5; cursor: not-allowed; }

/* ------- Table ------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { background: var(--surface-2); text-align: left; padding: 10px 12px; font-weight: 600; color: var(--ink-2); border-bottom: 1px solid var(--line); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }

/* ------- Badges / status ------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.badge.draft    { background: #e2e8f0; color: #475569; }
.badge.pending  { background: #fef3c7; color: #92400e; }
.badge.approved { background: #dbeafe; color: #0a4578; }
.badge.rejected { background: #fee2e2; color: #991b1b; }
.badge.active   { background: #dbeafe; color: #0a4578; }
.badge.closed   { background: #e2e8f0; color: #475569; }
.party-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 4px; color: white; font-size: 11px; font-weight: 600; margin-right: 6px; }

/* ------- Notice / message ------- */
.notice { padding: 12px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.notice.info    { background: #e0f2fe; color: #075985; border: 1px solid #bae6fd; }
.notice.error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.notice.success { background: #dbeafe; color: #0a4578; border: 1px solid #93c5fd; }
.notice.warn    { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

/* ------- Modal ------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal { background: var(--surface); border-radius: var(--radius); padding: 24px; max-width: 540px; width: 100%; box-shadow: var(--shadow-lg); max-height: 90vh; overflow-y: auto; }
.modal h2 { margin: 0 0 16px; font-size: 18px; }
.modal .form-actions { justify-content: flex-end; }

/* ------- RO candidate cards ------- */
.candidate-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.cand-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.cand-card .ident { display: flex; gap: 10px; align-items: center; }
.cand-card .avatar { width: 54px; height: 54px; border-radius: 50%; background: var(--surface-2); flex-shrink: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; color: var(--muted); font-weight: 700; font-size: 18px; border: 2px solid var(--line); }
.cand-card .avatar img { width: 100%; height: 100%; object-fit: cover; }
.cand-card .meta { flex: 1; min-width: 0; }
.cand-card .meta .name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cand-card .meta .party { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.cand-card .votes-row { display: flex; gap: 6px; align-items: center; }
.cand-card .votes-row input { font-size: 18px; font-weight: 700; text-align: right; }
.cand-card .actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ------- Public homepage (tabbed dashboard) ------- */
.public-topbar {
  padding: 14px 32px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  box-shadow: var(--shadow);
  border-bottom: 3px solid #f97316;  /* saffron accent */
}
.public-topbar .brand-row { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; }
.public-topbar .brand-mark {
  width: 46px; height: 46px; border-radius: 50%;
  background: transparent; color: white; border: 2px solid rgba(255,255,255,.7);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; letter-spacing: 1px;
  flex-shrink: 0;
}
.public-topbar .brand { font-size: 18px; font-weight: 700; color: white; letter-spacing: .2px; }
.public-topbar .brand-sub { font-size: 12px; color: rgba(255,255,255,.75); margin-top: 2px; }
.public-topbar .user { display: flex; align-items: center; gap: 14px; }
.public-topbar .official-login {
  background: white; color: var(--accent); border: none; padding: 7px 16px; border-radius: 6px;
  font-weight: 600; text-decoration: none; font-size: 14px;
}
.public-topbar .official-login:hover { background: #f1f5f9; text-decoration: none; }
.dot-indicator { color: rgba(255,255,255,.85); font-size: 12px; font-weight: 600; letter-spacing: .5px; }
.dot-indicator.live  { color: #fef2f2; }
.dot-indicator.final { color: #d1fae5; }

.election-tabs {
  background: white; padding: 0 20px; display: flex; gap: 4px;
  border-bottom: 1px solid var(--line); overflow-x: auto;
}
.election-tabs .etab {
  background: none; border: none; padding: 10px 18px; font-size: 14px; color: var(--ink-2);
  font-weight: 600; cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap;
  border-radius: 0;
}
.election-tabs .etab.active { color: var(--accent); border-bottom-color: #f97316; }
.election-tabs .etab:hover:not(.active) { color: var(--ink); background: var(--surface-2); }

/* Non-partisan dashboard (Panchayat): no party tiles — a candidate-focused summary and
 * district cards that highlight seat progress instead of who's "leading". */
.np-summary { padding: 16px 20px; margin-bottom: 14px; }
.np-summary-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.np-summary-head .np-badge {
  background: #eef5fb; color: var(--accent); font-size: 11px; font-weight: 700;
  letter-spacing: 1.1px; padding: 4px 10px; border-radius: 999px; border: 1px solid #c7ddee;
}
.np-summary-body { display: flex; gap: 32px; align-items: baseline; flex-wrap: wrap; margin-bottom: 12px; }
.np-metric .np-metric-value { font-size: 44px; font-weight: 800; color: #0a4578; line-height: 1; }
.np-metric.subtle .np-metric-value { font-size: 28px; }
.np-metric .np-metric-value .np-metric-sep { font-size: 32px; font-weight: 500; color: var(--ink-2); margin: 0 4px; }
.np-metric .np-metric-value .np-metric-total { font-size: 32px; font-weight: 600; color: var(--ink-2); }
.np-metric .np-metric-label { font-size: 12px; letter-spacing: .8px; color: var(--ink-2); text-transform: uppercase; margin-top: 4px; font-weight: 600; }
.np-progress { background: var(--surface-2); height: 10px; border-radius: 999px; overflow: hidden; margin-top: 10px; }
.np-progress-fill { background: var(--accent); height: 100%; transition: width .4s; }
.np-progress-text { margin-top: 6px; }

/* District card (non-partisan) — numbers in a row, no party tiles */
.district-full-card .np-leader .np-dist-numbers {
  display: flex; gap: 20px; align-items: baseline; flex-wrap: wrap; margin-top: 4px;
}
.district-full-card .np-leader .np-dist-num {
  display: flex; flex-direction: column; min-width: 0;
}
.district-full-card .np-leader .np-dist-num strong { font-size: 32px; font-weight: 800; line-height: 1; }
.district-full-card .np-leader .np-dist-num.declared strong { color: #0a4578; }
.district-full-card .np-leader .np-dist-num.trends   strong { color: #d97706; }
.district-full-card .np-leader .np-dist-num.awaited  strong { color: #64748b; }
.district-full-card .np-leader .np-dist-lbl {
  font-size: 10px; letter-spacing: .8px; color: var(--ink-2); text-transform: uppercase; margin-top: 2px; font-weight: 600;
}
.dash-layout .district-full-card .np-leader .np-dist-num strong { font-size: 38px; }

/* RO console: horizontal election switcher shown when an RO has >1 election. */
.ro-election-tabs {
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  margin: 0 0 16px; padding: 6px; background: var(--surface-2); border-radius: 10px;
  border: 1px solid var(--line);
}
.ro-election-tab {
  background: white; border: 1px solid var(--line); color: var(--ink-2);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; white-space: nowrap; transition: all .12s;
}
.ro-election-tab strong { color: var(--ink); font-size: 14px; font-weight: 700; letter-spacing: .3px; }
.ro-election-tab .ret-count {
  background: var(--surface-2); color: var(--ink-2); font-weight: 600;
  padding: 1px 8px; border-radius: 999px; font-size: 11px; line-height: 1.5;
}
.ro-election-tab:hover:not(.active) { border-color: var(--accent); color: var(--ink); background: #f8fafc; }
.ro-election-tab.active {
  background: var(--accent); border-color: var(--accent); color: white;
  box-shadow: 0 2px 8px rgba(14, 76, 130, .25);
}
.ro-election-tab.active strong { color: white; }
.ro-election-tab.active .ret-count { background: rgba(255,255,255,.22); color: white; }

/* Dashboard built for big-screen display: minimal side gutters, slim KPI column, big district cards.
 * max-width removed so the layout uses every pixel of a 1920/2560/4K screen. */
.dashboard-wrap { max-width: none; margin: 0; padding: 14px 20px; }
.dashboard-title { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.dashboard-title .dashboard-title-text { min-width: 0; }
.dashboard-title h1 { margin: 0 0 2px; font-size: 26px; color: var(--ink); font-weight: 800; }

/* Sidebar toggle — small square button next to the dashboard title.
 * Swaps between ☰ (sidebar hidden) and ✕ (sidebar visible). */
.sidebar-toggle {
  background: white; border: 1px solid var(--line); color: var(--ink);
  width: 38px; height: 38px; border-radius: 8px; cursor: pointer;
  font-size: 18px; line-height: 1; display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all .12s; box-shadow: var(--shadow-sm, 0 1px 2px rgba(0,0,0,.06));
}
.sidebar-toggle:hover { background: var(--accent); color: white; border-color: var(--accent); }

/* Dashboard split: slim KPI column on the left, all the room for districts on the right.
 * `.collapsed` hides the sidebar entirely and promotes the right column to the full width. */
.dash-layout { display: grid; grid-template-columns: 180px 1fr; gap: 16px; align-items: start; }
.dash-layout.collapsed { grid-template-columns: 1fr; }
.dash-layout.collapsed .dash-left { display: none; }
.dash-layout .dash-left { position: sticky; top: 14px; }
.dash-layout .dash-right { min-width: 0; }
@media (max-width: 860px) { .dash-layout { grid-template-columns: 1fr; } .dash-layout .dash-left { position: static; } }

/* KPI tiles in the slim left column — more compact than the default kpi-tile */
.dash-layout .kpi-grid { display: flex; flex-direction: column; gap: 10px; margin-bottom: 0; }
.dash-layout .kpi-tile { padding: 12px 14px; }
.dash-layout .kpi-label { font-size: 10px; letter-spacing: 1px; }
.dash-layout .kpi-value { font-size: 28px; margin-top: 2px; }
.dash-layout .kpi-value .kpi-suffix { font-size: 13px; }
@media (max-width: 860px) { .dash-layout .kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); flex-direction: initial; } }

/* Big-screen presentation mode: bigger district cards, bigger typography inside them,
 * tighter party summary. Only applies on the dashboard — scoped via .dash-layout. */
.dash-layout .party-summary-row { padding: 14px 18px; margin-bottom: 14px; }
.dash-layout .party-summary-row h2 { margin: 0 0 10px; font-size: 15px; }
.dash-layout .district-section { padding: 16px 18px; margin-bottom: 0; }
.dash-layout .district-section h2 { margin: 0 0 12px; font-size: 15px; }
/* 4 cards per row — breakpoints kept low so the 4-up layout holds on anything wider than a tablet.
 * Earlier the step-down happened at 1600px, which fired on Windows displays with DPI scaling (where
 * CSS px is well below physical px) and squeezed the grid to 3 columns. */
.dash-layout .district-card-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1100px) { .dash-layout .district-card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 820px)  { .dash-layout .district-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px)  { .dash-layout .district-card-grid { grid-template-columns: 1fr; } }
.dash-layout .district-full-card { padding: 12px 14px 10px; border-top-width: 4px; }
.dash-layout .district-full-card .dfc-head { margin-bottom: 8px; }
.dash-layout .district-full-card .dfc-name { font-size: 32px; line-height: 1.1; font-weight: 800; }
/* Sub-line is now two rows: "N seats · N declared" above, "N trends · N awaited" below, larger text. */
.dash-layout .district-full-card .dfc-sub { font-size: 18px; margin-top: 8px; line-height: 1.5; color: var(--ink-2); font-weight: 500; }
.dash-layout .district-full-card .dfc-sub .dfc-sub-line { display: block; }
.dash-layout .district-full-card .dfc-leader { padding: 10px 12px; margin-top: 6px; }
.dash-layout .district-full-card .dfc-leader-state { font-size: 13px; letter-spacing: 1.2px; }
.dash-layout .district-full-card .dfc-leader-count strong { font-size: 30px; }
.dash-layout .district-full-card .dfc-leader-count { font-size: 18px; }
.dash-layout .district-full-card .dfc-leader-split { font-size: 13px; }
.dash-layout .district-full-card .dfc-tied-count strong { font-size: 22px; }
.dash-layout .district-full-card .dfc-leader-badge .ps-logo { width: 46px; height: 46px; }
.dash-layout .district-full-card .dfc-leader-badge .ps-logo-abbr { font-size: 11px; }
.dash-layout .district-full-card .dfc-tile-badge .ps-logo { width: 38px; height: 38px; }
.dash-layout .district-full-card .dfc-tile-badge .ps-logo-abbr { font-size: 10px; }
.dash-layout .district-full-card .dfc-other-row { font-size: 14px; padding: 4px 0; }
.dash-layout .district-full-card .dfc-cta { font-size: 13px; }
.dash-layout .district-full-card .dfc-declared-tag { font-size: 11px; padding: 3px 10px; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi-tile {
  background: white; border: 1px solid var(--line); border-radius: 10px;
  padding: 16px 18px; box-shadow: var(--shadow);
}
.kpi-label { font-size: 11px; font-weight: 700; color: var(--ink-2); letter-spacing: 1px; text-transform: uppercase; }
.kpi-value { font-size: 36px; font-weight: 800; color: var(--ink); margin-top: 4px; line-height: 1.1; }
.kpi-value .kpi-suffix { font-size: 15px; font-weight: 500; color: var(--muted); margin-left: 4px; }

.dash-split { display: grid; grid-template-columns: minmax(400px, 1.2fr) minmax(360px, 1fr); gap: 20px; }
@media (max-width: 960px) { .dash-split { grid-template-columns: 1fr; } }
.dash-card { padding: 20px; }
.dash-card h2 { margin: 0 0 16px; font-size: 16px; }

/* Party summary row (horizontal chips) */
.party-summary-row { padding: 20px; margin-bottom: 20px; }
.party-summary-row h2 { margin: 0 0 14px; font-size: 16px; }
.party-summary-chips { display: flex; flex-wrap: wrap; gap: 12px; }
.party-summary-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; min-width: 150px; flex: 0 0 auto;
}
.party-summary-chip .ps-abbr {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 50%;
  color: white; font-weight: 800; font-size: 13px; letter-spacing: .5px;
  flex-shrink: 0;
}
.party-summary-chip.awaited .ps-abbr { background: #cbd5e1; color: var(--ink-2); }
.party-summary-chip .ps-logo-wrap { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; flex-shrink: 0; }
.party-summary-chip .ps-logo {
  width: 42px; height: 42px; border-radius: 50%; object-fit: contain;
  background: white; border: 1px solid var(--line); padding: 2px;
}
.party-summary-chip .ps-logo-abbr { font-size: 10px; font-weight: 800; letter-spacing: .4px; color: var(--ink-2); line-height: 1; }
.party-summary-chip .ps-body { line-height: 1.25; }
.party-summary-chip .ps-total { font-size: 15px; }
.party-summary-chip .ps-total strong { font-size: 22px; font-weight: 800; color: var(--ink); }
.party-summary-chip .ps-total-label { font-size: 12px; color: var(--ink-2); margin-left: 4px; }

/* District section (full-width grid of large cards) */
.district-section { padding: 20px; margin-bottom: 20px; }
.district-section h2 { margin: 0 0 14px; font-size: 16px; }
.district-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.district-full-card {
  background: white; border: 1px solid var(--line); border-top: 3px solid var(--accent);
  border-radius: 10px; padding: 14px 16px 10px; cursor: pointer;
  transition: transform .12s, box-shadow .12s, border-color .12s;
  display: flex; flex-direction: column;
}
.district-full-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--accent); }
.district-full-card .dfc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 6px; }
.district-full-card .dfc-name { font-size: 17px; font-weight: 700; color: var(--ink); line-height: 1.2; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.district-full-card .dfc-sub { margin-top: 3px; font-size: 11px; }
.district-full-card .dfc-declared-tag {
  display: inline-block; font-size: 10px; font-weight: 800; letter-spacing: 0.8px;
  padding: 2px 8px; border-radius: 999px;
  background: #dbeafe; color: #0a4578;
}
/* Logo-backed party badge used inside the declared-winner block (mirrors party-summary-chip look) */
.district-full-card .dfc-leader-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 54px; height: 54px; flex-shrink: 0;
}
.district-full-card .dfc-leader-badge .ps-logo-wrap { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; }
.district-full-card .dfc-leader-badge .ps-logo { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; border: 2px solid var(--line); background: white; }
.district-full-card .dfc-leader-badge .ps-logo-abbr { font-size: 10px; font-weight: 800; letter-spacing: 0.4px; color: var(--ink-2); line-height: 1; }
.district-full-card .dfc-leader-badge .ps-abbr {
  display: inline-flex; align-items: center; justify-content: center;
  width: 46px; height: 46px; border-radius: 10px;
  color: white; font-weight: 800; font-size: 14px; letter-spacing: 0.5px;
}
/* Compact logo+abbr badge used inside the counting/leading/tied tiles */
.district-full-card .dfc-tile-badge { display: inline-flex; align-items: center; justify-content: center; }
.district-full-card .dfc-tile-badge .ps-logo-wrap { display: inline-flex; flex-direction: column; align-items: center; gap: 1px; }
.district-full-card .dfc-tile-badge .ps-logo { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; border: 1.5px solid var(--line); background: white; }
.district-full-card .dfc-tile-badge .ps-logo-abbr { font-size: 9px; font-weight: 800; letter-spacing: 0.3px; color: var(--ink-2); line-height: 1; }
.district-full-card .dfc-tile-badge .ps-abbr {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 34px; border-radius: 8px;
  color: white; font-weight: 800; font-size: 12px; letter-spacing: 0.4px;
}

/* ---------- Live dashboard animations ---------- */
/* Pop used when a district's leading party flips between polls. Subtle scale-up + settle,
   paired with a soft colored glow so the user's eye catches the change without being jarring. */
@keyframes pop-swap {
  0%   { transform: scale(1);    box-shadow: 0 0 0 0 rgba(13, 110, 253, 0); }
  30%  { transform: scale(1.06); box-shadow: 0 0 0 6px rgba(13, 110, 253, 0.18); }
  60%  { transform: scale(0.98); box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.08); }
  100% { transform: scale(1);    box-shadow: 0 0 0 0 rgba(13, 110, 253, 0); }
}
.pop-swap {
  animation: pop-swap 0.7s cubic-bezier(.34,1.56,.64,1);
  transform-origin: center;
}
/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  .pop-swap { animation: none; }
}

/* ---------- Tie banner (constituency-level equal-votes clash) ---------- */
.tie-card {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 2px dashed #d97706;
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: 0 4px 16px rgba(217, 119, 6, 0.15);
}
.tie-card .tie-badge {
  display: inline-block;
  background: #d97706; color: white;
  font-weight: 800; font-size: 11px; letter-spacing: 2px;
  padding: 4px 12px; border-radius: 999px;
  margin-bottom: 14px;
}
.tie-card .tie-title { font-size: 20px; font-weight: 800; color: #92400e; margin-bottom: 4px; }
.tie-card .tie-sub   { font-size: 13px; color: #92400e; opacity: 0.85; margin-bottom: 16px; }
.tie-card .tie-list  { display: flex; flex-wrap: wrap; gap: 12px; }
.tie-card .tie-cand  {
  display: flex; align-items: center; gap: 12px;
  background: white; border-radius: 10px; padding: 12px 16px;
  border-left: 5px solid var(--pc, #d97706);
  flex: 1 1 260px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.tie-card .tie-cand .tc-avatar {
  width: 50px; height: 50px; border-radius: 50%;
  border: 3px solid var(--pc, #d97706);
  background: var(--surface-2); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: var(--pc, #d97706); font-size: 20px; flex-shrink: 0;
}
.tie-card .tie-cand .tc-avatar img { width: 100%; height: 100%; object-fit: cover; }
.tie-card .tie-cand .tc-name  { font-weight: 700; font-size: 15px; color: var(--ink); line-height: 1.2; }
.tie-card .tie-cand .tc-party { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tie-card .tie-cand .tc-votes { font-weight: 800; font-size: 18px; color: var(--pc, #d97706); margin-left: auto; }
.district-full-card .dfc-pct { font-size: 20px; font-weight: 800; color: var(--accent); white-space: nowrap; }
.district-full-card .dfc-pct.is-final { color: #0a4578; }
.district-full-card .dfc-progress {
  height: 6px; background: #e2e8f0; border-radius: 999px; overflow: hidden;
  display: flex; margin-bottom: 10px;
}
.district-full-card .dfc-progress-final { background: var(--accent); height: 100%; }
.district-full-card .dfc-progress-trend { background: #f59e0b; height: 100%; opacity: .7; }
/* --- District card leader block (flat, elegant) --- */
.district-full-card .dfc-leader {
  margin: 12px 0 10px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}
.district-full-card .dfc-leader.is-empty { background: var(--surface-2); }
.district-full-card .dfc-leader .dfc-leader-state { color: #92400e; }
.district-full-card .dfc-leader.is-winner .dfc-leader-state { color: #0a4578; }
.district-full-card .dfc-leader.is-empty .dfc-leader-state { color: var(--muted); }
.district-full-card .dfc-tied-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.district-full-card .dfc-tied-item {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 7px; background: white; border: 1px solid var(--line); border-radius: 6px;
}
.district-full-card .dfc-tied-count strong { font-size: 18px; font-weight: 800; color: var(--ink); }
/* On the big-screen dashboard with 4 tiles per card, tighten so all fit on one row at narrow widths. */
.dash-layout .district-full-card .dfc-tied-row { gap: 6px; }
.dash-layout .district-full-card .dfc-tied-item { padding: 3px 6px; gap: 4px; }
.district-full-card .dfc-leader-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.district-full-card .dfc-leader-state {
  font-size: 10px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--pc, var(--muted));
}
.district-full-card .dfc-leader.is-empty .dfc-leader-state { color: var(--muted); }
.district-full-card .dfc-leader-runnerup { font-size: 11px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 4px; }
.district-full-card .dfc-mini-chip {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 1px 6px; color: white; border-radius: 3px;
  font-weight: 700; font-size: 10px; letter-spacing: .3px;
}
.district-full-card .dfc-leader-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.district-full-card .dfc-leader-chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 48px; padding: 6px 10px; color: white;
  border-radius: 6px; font-weight: 800; font-size: 14px; letter-spacing: .5px;
  flex-shrink: 0;
}
.district-full-card .dfc-leader-meta { line-height: 1.2; min-width: 0; }
.district-full-card .dfc-leader-count { font-size: 15px; color: var(--ink); }
.district-full-card .dfc-leader-count strong { font-size: 22px; font-weight: 800; color: var(--ink); }
.district-full-card .dfc-leader-split { font-size: 11px; color: var(--ink-2); margin-top: 2px; }

/* --- Secondary party rows --- */
.district-full-card .dfc-others {
  display: flex; flex-direction: column; gap: 3px;
  padding: 6px 0 2px;
}
.district-full-card .dfc-other-row {
  display: grid; grid-template-columns: 10px 44px 1fr; align-items: center; gap: 8px;
  font-size: 12px; color: var(--ink-2);
}

.district-full-card .dfc-parties {
  display: flex; flex-direction: column; gap: 4px;
  padding: 8px 0; border-top: 1px dashed var(--line);
}
.district-full-card .dfc-party-row {
  display: grid; grid-template-columns: 14px 44px 1fr; align-items: center; gap: 8px;
  font-size: 13px;
}
.district-full-card .dfc-dot { width: 10px; height: 10px; border-radius: 50%; }
.district-full-card .dfc-abbr { font-weight: 700; color: var(--ink); }
.district-full-card .dfc-ps-counts { font-size: 12px; color: var(--ink-2); }
.district-full-card .dfc-cta { color: var(--accent); font-weight: 600; text-align: right; margin-top: 6px; }

.stacked-bar {
  width: 100%; height: 14px; border-radius: 999px; overflow: hidden;
  background: var(--surface-2); display: flex; margin-bottom: 10px;
}
.stacked-bar .sb-seg { height: 100%; transition: width .3s; }
.stacked-bar .sb-awaited, .sw.sb-awaited { background: #e2e8f0; }
.sw.sb-awaited { border: 1px solid #cbd5e1; }
.sb-legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--ink-2); margin-bottom: 4px; }
.sb-legend span { display: inline-flex; align-items: center; gap: 4px; }
.sb-legend .sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.sb-legend .awaited-chip { color: var(--muted); }

.party-table { width: 100%; }
.party-table th { background: var(--surface-2); font-size: 11px; }
.party-table .party-pill-sm { display: inline-block; color: white; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; margin-right: 6px; }
.party-table .totals-row td { background: var(--surface-2); font-weight: 700; }

.district-tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.district-tile {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 14px; cursor: pointer; transition: transform .1s, box-shadow .1s, border-color .1s;
}
.district-tile:hover { transform: translateY(-1px); box-shadow: var(--shadow); border-color: var(--accent); background: white; }
.district-tile .dt-top { display: flex; justify-content: space-between; align-items: baseline; }
.district-tile .dt-name { font-size: 16px; color: var(--ink); }
.district-tile .dt-seats { font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.district-tile .dt-meta { margin: 6px 0 8px; }
.district-tile .dt-bar-wrap { height: 5px; background: #e2e8f0; border-radius: 999px; overflow: hidden; display: flex; }
.district-tile .dt-bar-final    { height: 100%; }
.district-tile .dt-bar-reported { height: 100%; background: #f59e0b; opacity: .5; }

.public-footer-note { margin-top: 14px; padding: 10px 10px; text-align: center; color: var(--ink-2); font-size: 12px; border-top: 1px solid var(--line); }
.public-footer-note > div + div { margin-top: 2px; }

/* ------- Legacy public dashboard (election detail / district detail / constituency detail still use this) ------- */
.public-wrap { max-width: 1200px; margin: 0 auto; padding: 24px; }
.public-hero { text-align: center; padding: 40px 20px 24px; }
.public-hero h1 { margin: 0 0 10px; font-size: 32px; color: var(--accent); }
.public-hero p { margin: 0; color: var(--ink-2); font-size: 15px; }
#liveStatus { margin: 20px 0 28px; display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 13px; color: var(--ink-2); }
.public-wrap .page-header { margin-bottom: 24px; }
.public-wrap .card + .card { margin-top: 20px; }
.live-badge {
  background: var(--danger); color: white; font-weight: 700; letter-spacing: .5px;
  padding: 4px 12px; border-radius: 999px; font-size: 11px;
  animation: live-pulse 1.6s ease-in-out infinite;
}
@keyframes live-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,.55); }
  50%      { box-shadow: 0 0 0 7px rgba(220,38,38,0); }
}
.election-card { background: var(--surface); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; }
.election-card .ec-header { display: flex; align-items: center; gap: 10px; }
.election-card .ec-badge { width: 32px; height: 32px; border-radius: 8px; background: var(--accent); color: white; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.election-card .ec-title { font-size: 16px; font-weight: 700; }
.election-card .ec-subtitle { font-size: 13px; color: var(--ink-2); }
.election-card .ec-body { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; }
.election-card .ec-legend { font-size: 13px; }
.election-card .ec-legend .row { display: flex; align-items: center; gap: 6px; padding: 3px 0; }
.election-card .ec-legend .sw { width: 12px; height: 12px; border-radius: 3px; }
.election-card .ec-footer { padding-top: 10px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-2); }
.election-card .ec-footer a { color: var(--accent); font-weight: 600; }

/* --- Richer per-constituency rows --- */
.constituency-list { display: flex; flex-direction: column; gap: 14px; }
.const-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(280px, 2fr);
  gap: 16px;
  padding: 16px 18px;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s, border-color .12s;
  position: relative;
  overflow: hidden;
}
.const-row::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 6px;
  background: linear-gradient(180deg, var(--muted) 0%, #cbd5e1 100%);
}
.const-row.declared::before { background: linear-gradient(180deg, #06365f 0%, #1d6ba8 100%); }
.const-row.counting::before { background: linear-gradient(180deg, #d97706 0%, #f59e0b 100%); }
.const-row.awaiting::before { background: linear-gradient(180deg, #94a3b8 0%, #cbd5e1 100%); }
.const-row:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--accent); }

.const-left { display: flex; flex-direction: column; gap: 6px; padding-left: 6px; }
.const-head { display: flex; align-items: center; gap: 10px; }
.const-code { font-size: 12px; color: var(--muted); font-weight: 700; letter-spacing: 1px; background: var(--surface-2); padding: 2px 8px; border-radius: 4px; }
.const-name { font-size: 18px; font-weight: 700; color: var(--ink); line-height: 1.2; }
.const-winner, .const-leading { font-size: 14px; display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.const-leading .cl-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.const-leading .cl-name { font-size: 15px; }
.const-leading .cl-margin {
  display: inline-flex; align-items: center; gap: 4px; align-self: flex-start;
  background: #fef3c7; color: #92400e;
  padding: 3px 10px; border-radius: 4px;
  font-size: 13px; font-weight: 600; letter-spacing: .2px;
  border-left: 3px solid #d97706;
}
.const-leading .cl-margin strong { font-size: 15px; font-weight: 800; }
.winner-pill { display: inline-flex; align-items: center; color: white; font-weight: 700; font-size: 11px; padding: 3px 10px; border-radius: 999px; letter-spacing: .5px; }
/* "LEADING" = still counting. Use a distinctive amber so it never looks like a party colour. */
.leading-pill { display: inline-flex; align-items: center; color: white; font-weight: 700; font-size: 11px; padding: 3px 10px; border-radius: 999px; letter-spacing: .5px; background: #d97706 !important; }
.leading-pill .pl-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.const-waiting { color: var(--muted); font-style: italic; font-size: 13px; }

/* Winner / leader card on the constituency detail page */
.winner-card { position: relative; overflow: hidden; }
.winner-card.is-leading { border-left: 4px solid #d97706; }
.winner-card.is-winner  { border-left: 4px solid var(--accent); }
.winner-card.is-unopposed { border-left: 4px solid #d97706; }
.winner-card .wc-header { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.winner-card .wc-badge {
  display: inline-block; padding: 4px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 800; letter-spacing: 1px; color: white;
}
.winner-card.is-leading .wc-badge { background: #d97706; }
.winner-card.is-winner  .wc-badge { background: var(--accent); }
.winner-card.is-unopposed .wc-badge { background: #d97706; }
.winner-card .wc-counting-note { color: var(--muted); font-size: 12px; font-style: italic; }
.winner-card .wc-margin {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 18px; padding: 10px 16px; border-radius: 8px;
  font-size: 14px; font-weight: 700; letter-spacing: 1px;
}
.winner-card .wc-margin strong { font-size: 24px; font-weight: 800; }
.winner-card.is-leading .wc-margin { background: linear-gradient(90deg, #fef3c7 0%, #fde68a 100%); color: #92400e; border-left: 4px solid #d97706; }
.winner-card.is-winner  .wc-margin { background: linear-gradient(90deg, #dbeafe 0%, #bfdbfe 100%); color: var(--accent); border-left: 4px solid var(--accent); }

/* ---------- Declared winner card (final result podium) ---------- */
.declared-winner-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border-top: 6px solid var(--pc, #0a4578);
  margin-bottom: 20px;
}
.declared-winner-card .dwc-ribbon {
  background: linear-gradient(90deg, #06365f, #0a4578);
  color: white; font-weight: 700; font-size: 12px; letter-spacing: 1.5px;
  padding: 8px 18px; display: inline-block;
  border-bottom-right-radius: 10px;
}
.declared-winner-card .dwc-body {
  display: flex; gap: 22px; padding: 20px 24px 10px; align-items: center;
}
.declared-winner-card .dwc-avatar {
  width: 110px; height: 110px; border-radius: 50%;
  border: 4px solid var(--pc, #0a4578);
  background: var(--surface-2);
  overflow: hidden; display: flex; align-items: center; justify-content: center;
  font-size: 44px; font-weight: 800; color: var(--pc, #0a4578);
  flex-shrink: 0;
}
.declared-winner-card .dwc-avatar img { width: 100%; height: 100%; object-fit: cover; }
.declared-winner-card .dwc-main { flex: 1; min-width: 0; }
.declared-winner-card .dwc-party-row { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.declared-winner-card .dwc-party-name { font-size: 14px; color: var(--ink-2, #475569); font-weight: 500; }
.declared-winner-card .dwc-name { font-size: 30px; font-weight: 800; color: var(--ink, #0a0f1a); line-height: 1.1; margin-bottom: 14px; }
.declared-winner-card .dwc-stats {
  display: flex; gap: 32px; flex-wrap: wrap;
}
.declared-winner-card .dwc-stat .dwc-stat-value { font-size: 26px; font-weight: 800; color: var(--pc, #0a4578); line-height: 1; }
.declared-winner-card .dwc-stat .dwc-stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-top: 4px; }
.declared-winner-card .dwc-share-bar {
  display: flex; height: 14px; margin: 14px 24px 0; border-radius: 999px; overflow: hidden; background: var(--surface-2);
}
.declared-winner-card .dwc-share-seg { transition: width .3s ease; }
.declared-winner-card .dwc-share-seg.is-winner { box-shadow: inset 0 0 0 1px rgba(255,255,255,.3); }
.declared-winner-card .dwc-runners {
  margin: 14px 24px 20px; padding: 12px 14px; border-radius: 10px; background: var(--surface-2);
}
.declared-winner-card .dwc-runner-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.declared-winner-card .dwc-runner-row { display: flex; align-items: center; gap: 10px; }
.declared-winner-card .dwc-runner-name { flex: 1; font-weight: 600; }
.declared-winner-card .dwc-runner-votes { font-weight: 700; font-size: 15px; }
@media (max-width: 640px) {
  .declared-winner-card .dwc-body { flex-direction: column; text-align: center; }
  .declared-winner-card .dwc-stats { justify-content: center; }
}

.party-tiles { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; align-self: center; }
.party-tile {
  background: var(--tile-color, #64748b);
  color: white;
  border-radius: 10px;
  padding: 10px 14px;
  min-width: 96px;
  text-align: center;
  position: relative;
  box-shadow: 0 2px 6px rgba(15,23,42,.1);
  border: 2px solid transparent;
  transition: transform .1s;
}
.party-tile.winner { border-color: #0a4578; box-shadow: 0 4px 14px rgba(10,69,120,.3); transform: scale(1.04); }
.party-tile.leader { border-color: #f59e0b; box-shadow: 0 4px 14px rgba(245,158,11,.35); transform: scale(1.03); }
.party-tile .pt-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 11px; font-weight: 700; letter-spacing: .5px; opacity: .95; }
.party-tile .pt-abbr { font-size: 12px; font-weight: 800; letter-spacing: .5px; }
.party-tile .pt-flag { font-size: 10px; background: rgba(0,0,0,.28); padding: 2px 6px; border-radius: 4px; }
/* Leader (trending) flag gets its own amber chip so it pops against the party colour */
.party-tile.leader .pt-flag { background: #f59e0b; color: white; font-weight: 800; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.party-tile.winner .pt-flag { background: #0a4578; color: white; font-weight: 800; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.party-tile .pt-votes { font-size: 22px; font-weight: 800; line-height: 1.1; margin: 2px 0 1px; font-variant-numeric: tabular-nums; }
.party-tile .pt-share { font-size: 11px; opacity: .9; }

@media (max-width: 720px) {
  .const-row { grid-template-columns: 1fr; }
  .party-tiles { justify-content: flex-start; }
}

/* --- District cards (election page & homepage) --- */
.district-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); margin-top: 8px; }
.district-card {
  background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--muted);
  border-radius: 10px; padding: 16px; cursor: pointer; display: flex; flex-direction: column; gap: 10px;
  transition: transform .12s, box-shadow .12s, border-color .12s;
}
.district-card.declared { border-top-color: var(--accent); }
.district-card.counting { border-top-color: var(--warn); }
.district-card.awaiting { border-top-color: var(--muted); }
.district-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--accent); }
.district-card .dc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.district-card .dc-name { font-size: 18px; font-weight: 700; line-height: 1.2; }
.district-card .dc-meta { display: flex; gap: 10px; font-size: 13px; color: var(--ink-2); align-items: center; }
.district-card .dc-progress { background: var(--surface-2); height: 6px; border-radius: 999px; overflow: hidden; }
.district-card .dc-progress-bar { height: 100%; background: linear-gradient(90deg, var(--ok) 0%, var(--accent) 100%); }
.district-card .dc-body { border-top: 1px dashed var(--line); padding-top: 10px; }
.district-card .dc-leader { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.district-card .leader-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.district-card .leader-seats { font-weight: 700; font-size: 15px; color: var(--accent); }
.district-card .dc-cta { margin-top: 4px; text-align: right; color: var(--accent); font-size: 13px; font-weight: 600; }

/* --- Homepage election card: district breakdown rows --- */
.ec-districts { display: flex; flex-direction: column; gap: 6px; padding-top: 10px; border-top: 1px dashed var(--line); margin-top: 6px; }
.ec-district-row {
  display: flex; align-items: center; gap: 8px; font-size: 13px;
  padding: 6px 10px; border-radius: 6px; background: var(--surface-2); cursor: pointer;
  transition: background .1s;
}
.ec-district-row:hover { background: #e2e8f0; }
.ec-district-row .d-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); display: inline-block; }
.ec-district-row.has-leader .d-dot { background: var(--leader-color, var(--accent)); }
.ec-district-row .d-name { font-weight: 600; flex: 1; }
.ec-district-row .d-chip { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 4px; color: white; }
.ec-district-row .d-progress { font-size: 11px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* legacy class kept for safety */
.constituency-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.constituency-tile { background: var(--surface); border: 1px solid var(--line); border-left-width: 6px; border-radius: 8px; padding: 12px 14px; cursor: pointer; transition: transform .1s, box-shadow .1s; }
.constituency-tile:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }

.filter-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.filter-bar select, .filter-bar input { max-width: 240px; }

.party-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--line); cursor: pointer; }
.party-pill.active { background: var(--accent); color: white; border-color: var(--accent); }
.party-pill .sw { width: 10px; height: 10px; border-radius: 50%; }

/* ------- Login ------- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px circle at 10% -10%, #0e4e85 0%, var(--accent) 45%, #06365f 100%);
  padding: 24px;
}
.login-shell {
  display: grid; grid-template-columns: 1fr 440px;
  width: 100%; max-width: 960px;
  background: var(--surface); border-radius: 18px; overflow: hidden;
  box-shadow: 0 30px 70px rgba(0,0,0,.35);
}
@media (max-width: 760px) { .login-shell { grid-template-columns: 1fr; max-width: 440px; } }

/* Left brand panel */
.login-brand {
  background: linear-gradient(135deg, var(--accent) 0%, #06365f 100%);
  color: white; padding: 36px 32px; display: flex; flex-direction: column; justify-content: space-between;
  min-height: 460px;
}
@media (max-width: 760px) { .login-brand { min-height: auto; padding: 24px; } }
.login-brand .lb-crest {
  width: 56px; height: 56px; border-radius: 50%;
  background: transparent; border: 2px solid rgba(255,255,255,.6);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; letter-spacing: 1.5px;
  margin-bottom: 20px;
}
.login-brand .lb-title { font-size: 26px; font-weight: 800; margin: 0 0 10px; letter-spacing: .3px; line-height: 1.2; }
.login-brand .lb-sub { font-size: 14px; color: rgba(255,255,255,.82); line-height: 1.5; margin: 0; }
.login-brand .lb-footer { margin-top: 24px; }
.login-brand .lb-badge {
  display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .5px;
  padding: 6px 12px; border-radius: 999px;
  background: rgba(255,255,255,.14); color: white;
  border: 1px solid rgba(255,255,255,.25);
}
.login-brand .lb-badge.private { background: rgba(217,119,6,.25); border-color: rgba(252,211,77,.5); }
.login-brand .lb-badge.public  { background: rgba(16,185,129,.22); border-color: rgba(167,243,208,.5); }

/* Right sign-in card */
.login-card {
  background: var(--surface);
  padding: 36px 32px;
  display: flex; flex-direction: column; justify-content: center;
}
.login-card .login-hero { margin-bottom: 20px; text-align: left; }
.login-card .login-hero h1 { margin: 0 0 4px; color: var(--ink); font-size: 22px; font-weight: 700; }
.login-card .login-hero p { color: var(--ink-2); font-size: 14px; margin: 0; }
.login-card .login-hero.private { padding: 14px 16px; border-radius: 10px; background: linear-gradient(90deg, #fef3c7 0%, #fde68a 60%); border-left: 4px solid #d97706; }
.login-card .login-hero.private h1 { color: #78350f; display: flex; align-items: center; gap: 8px; }
.login-card .login-hero.private p { color: #78350f; }
.login-card .login-hero-icon { display: none; }
.login-card .form-row { margin-bottom: 14px; }
.login-card .login-help { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); text-align: center; font-size: 13px; color: var(--ink-2); }
.login-card .login-help a { color: var(--accent); font-weight: 600; }

/* ------- Utilities ------- */
.flex { display: flex; align-items: center; gap: 10px; }
.flex-wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.right { margin-left: auto; }
.text-muted { color: var(--ink-2); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.hidden { display: none !important; }
.loading { color: var(--muted); font-style: italic; padding: 20px; text-align: center; }
.empty { color: var(--muted); padding: 30px; text-align: center; font-size: 14px; }

/* Assignment modal */
.assign-tabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.assign-tabs .assign-tab {
  background: none; border: none; padding: 10px 14px; font-size: 13px; font-weight: 600;
  color: var(--ink-2); cursor: pointer; border-bottom: 3px solid transparent;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.assign-tabs .assign-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.assign-tabs .assign-tab:hover:not(.active) { color: var(--ink); }
.assign-tabs .assign-tab-count {
  background: var(--accent); color: white; font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 999px; min-width: 18px; text-align: center;
}
.assign-search { margin-bottom: 10px; }
.assign-list { max-height: 55vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 4px; }
.assign-district {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 10px; background: var(--surface-2); font-weight: 700; font-size: 12px;
  color: var(--accent); margin: 6px 0 2px; border-radius: 4px; text-transform: uppercase; letter-spacing: .5px;
}
.assign-row {
  display: grid; grid-template-columns: 24px 60px 1fr; align-items: center;
  gap: 8px; padding: 6px 10px; cursor: pointer; border-radius: 4px; font-weight: 400;
  margin: 0;
}
.assign-row:hover { background: var(--surface-2); }
.assign-code { font-family: monospace; font-weight: 700; font-size: 12px; color: var(--ink-2); }
.assign-name { font-size: 14px; }
.assign-summary { margin-top: 10px; padding: 8px 10px; background: var(--surface-2); border-radius: 6px; text-align: right; }

/* Setup checklist (RO, before counting can begin) */
.setup-card { border-left: 4px solid #d97706; background: linear-gradient(to right, #fef9c3 0%, white 60%); }
.setup-card h2 { margin: 0 0 6px; }
.setup-step { display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px dashed var(--line); }
.setup-step:first-of-type { border-top: 0; }
.setup-step .ss-check {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface-2); color: var(--ink-2);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px;
}
.setup-step.active .ss-check { background: #d97706; color: white; }
.setup-step.done   .ss-check { background: var(--ok); color: white; }
.setup-step.locked .ss-check { background: #e2e8f0; color: var(--muted); }
.setup-step .ss-title { font-weight: 600; font-size: 15px; }
.setup-step .ss-desc  { margin-top: 2px; }
.setup-step.locked { opacity: .55; }

/* Candidate rows in admin's manage-candidates modal */
.cand-admin-list { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px; margin-top: 10px; }
.cand-admin-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; background: var(--surface-2); }
.cand-admin-row:hover { background: #e2e8f0; }

/* District accordion (DC + Approver pending tabs) */
.district-accordion { padding: 0; }
.district-accordion .da-panel + .da-panel { border-top: 1px solid var(--line); }
.district-accordion .da-header {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 14px 18px; background: var(--surface-2);
  border: none; border-radius: 0; cursor: pointer;
  font-size: 15px; font-weight: 700; color: var(--accent);
  text-align: left;
}
.district-accordion .da-header:hover { background: #e2e8f0; }
.district-accordion .da-chevron { color: var(--accent); font-size: 12px; width: 14px; display: inline-block; }
.district-accordion .da-title { letter-spacing: .3px; }
.district-accordion .da-count { font-size: 12px; color: var(--ink-2); font-weight: 400; }
.district-accordion .da-body { padding: 6px 18px 14px; }
.district-accordion .da-row {
  display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center;
  padding: 10px 0; border-bottom: 1px dashed var(--line);
}
.district-accordion .da-row:last-child { border-bottom: none; }
.district-accordion .da-row-main { min-width: 0; }
.district-accordion .da-row-name { font-size: 15px; }
.district-accordion .da-row-meta { margin-top: 2px; }
.district-accordion .da-row-pending { margin-top: 6px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.district-accordion .da-pending-chip {
  display: inline-flex; align-items: center;
  padding: 2px 8px; background: #fef3c7; color: #92400e;
  border: 1px solid #fde68a; border-radius: 4px;
  font-size: 11px; font-weight: 700;
}
.district-accordion .da-row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* Round-wise matrix (DC + Approver preview + Public constituency detail) */
.round-matrix { border-collapse: collapse; width: 100%; font-size: 13px; }
.round-matrix th, .round-matrix td { border: 1px solid var(--line); padding: 8px 10px; }
.round-matrix thead th { background: var(--surface-2); vertical-align: top; text-align: left; }
.round-matrix thead th:first-child { width: 90px; }
.round-matrix .rm-cand { display: flex; align-items: center; gap: 6px; }
.round-matrix tbody td { font-variant-numeric: tabular-nums; }
.round-matrix tbody tr.totals-row td { background: var(--surface-2); font-weight: 700; border-top: 2px solid var(--accent); }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 42px; height: 22px; vertical-align: middle; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .switch-slider { position: absolute; inset: 0; background: #cbd5e1; border-radius: 999px; transition: background .15s; }
.switch .switch-slider::before { content: ''; position: absolute; left: 2px; top: 2px; width: 18px; height: 18px; background: white; border-radius: 50%; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .switch-slider { background: var(--danger); }
.switch input:checked + .switch-slider::before { transform: translateX(20px); }

/* Avatar helpers */
.avatar-sm { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2); overflow: hidden; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; color: var(--muted); border: 1px solid var(--line); vertical-align: middle; }
.avatar-sm img { width: 100%; height: 100%; object-fit: cover; }
