/* ── Reset & Variables ───────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Dark theme (default) */
:root,
[data-theme="dark"] {
  --green: #006b3f;
  --red: #ce1126;
  --black: #000000;
  --orange: #ef7d00;
  --bg: #0d1117;
  --surface: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #58a6ff;
  --success: #3fb950;
  --warning: #d29922;
  --danger: #f85149;
  --radius: 8px;
  --table-hover: #1c2128;
  --badge-declared-bg: #0d4429;
  --badge-pending-bg: #3d2f00;
  --badge-winner-bg: #1a2f1a;
  --alert-error-bg: #3d0f0f;
  --alert-success-bg: #0d4429;
}

/* Light theme */
[data-theme="light"] {
  --green: #006b3f;
  --red: #ce1126;
  --black: #000000;
  --orange: #ef7d00;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --border: #d0d7de;
  --text: #1a1f27;
  --muted: #6e7781;
  --accent: #0969da;
  --success: #1a7f37;
  --warning: #9a6700;
  --danger: #cf222e;
  --radius: 8px;
  --table-hover: #f0f3f6;
  --badge-declared-bg: #dafbe1;
  --badge-pending-bg: #fff8c5;
  --badge-winner-bg: #dafbe1;
  --alert-error-bg: #ffebe9;
  --alert-success-bg: #dafbe1;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  transition:
    background 0.2s,
    color 0.2s;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Navbar ─────────────────────────────────────────────────────── */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.flag {
  font-size: 1.4rem;
}
.live-badge {
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0.05em;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}
.nav-links a {
  white-space: nowrap;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s;
}
.nav-links a:hover {
  color: var(--text);
}
.nav-user {
  color: var(--accent);
  font-weight: 600;
}
.btn-logout {
  background: var(--border);
  color: var(--text) !important;
  padding: 4px 12px;
  border-radius: var(--radius);
}

/* ── Main layout ─────────────────────────────────────────────────── */
.main-content {
  padding: 1.5rem;
  max-width: 1600px;
  margin: 0 auto;
  flex: 1;
  width: 100%;
}

/* ── Footer ──────────────────────────────────────────────────────── */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
}
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.25rem;
}
.footer-sep {
  opacity: 0.4;
  margin: 0 0.25rem;
}

/* ── Notification bar ────────────────────────────────────────────── */
.notification-bar {
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  z-index: 99;
  background: var(--success);
  color: #000;
  text-align: center;
  padding: 0.6rem 1rem;
  font-weight: 600;
  transition: transform 0.3s;
}
.notification-bar.hidden {
  transform: translateY(-100%);
}
.notification-bar.alert {
  background: var(--warning);
}

/* ── Cards / surfaces ────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
}
.card-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.card-value {
  font-size: 2rem;
  font-weight: 700;
}
.card-sub {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

/* ── Grid layouts ────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 1.5rem;
}
@media (max-width: 900px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Map ─────────────────────────────────────────────────────────── */
.map-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.map-container svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}
.map-container svg {
  display: block;
}
.map-container svg path {
  fill: #2a3a4a;
  stroke: #8ba7c0;
  stroke-width: 1.5;
  cursor: pointer;
  transition:
    fill 0.3s,
    opacity 0.2s,
    stroke 0.2s;
}
.map-container svg path:hover {
  opacity: 0.85;
  stroke: #ffffff;
  stroke-width: 2.5;
  filter: brightness(1.15);
}
#map-svg-wrap {
  overflow: visible;
}
.map-container svg path.active {
  stroke: #ffffff;
  stroke-width: 2.5;
}

/* Map legend */
.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.8rem;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
}
.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

/* ── Progress bars ───────────────────────────────────────────────── */
.progress-bar {
  background: var(--border);
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
  margin: 0.4rem 0;
}
.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s;
}

/* ── Candidate bars ──────────────────────────────────────────────── */
.candidate-row {
  margin-bottom: 1rem;
}
.candidate-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.3rem;
}
.candidate-name {
  font-weight: 600;
}
.candidate-party {
  font-size: 0.75rem;
  padding: 1px 6px;
  border-radius: 3px;
  color: #fff;
}
.candidate-votes {
  font-size: 1.1rem;
  font-weight: 700;
}
.candidate-pct {
  font-size: 0.85rem;
  color: var(--muted);
}

/* ── Tables ──────────────────────────────────────────────────────── */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.results-table {
  width: 100%;
  border-collapse: collapse;
}
.results-table th {
  background: var(--border);
  color: var(--muted);
  text-align: left;
  padding: 0.6rem 0.8rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.results-table td {
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid var(--border);
}
.results-table tr:hover td {
  background: var(--table-hover);
}
.results-table a {
  color: var(--accent);
  text-decoration: none;
}
.results-table a:hover {
  text-decoration: underline;
}

/* ── Badges ──────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge-declared {
  background: var(--badge-declared-bg);
  color: var(--success);
}
.badge-pending {
  background: var(--badge-pending-bg);
  color: var(--warning);
}
.badge-winner {
  background: var(--badge-winner-bg);
  color: var(--success);
}

/* ── Section headers ─────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.section-title {
  font-size: 1rem;
  font-weight: 700;
}

/* ── Panel right ─────────────────────────────────────────────────── */
.panel-right {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ── Map column (left side of dashboard-grid) ─────────────────────
   ✅ NEW: wraps the map card + the "Constituencies Won" chart card so
   they stack vertically with the same spacing rhythm as .panel-right
   on the opposite column. */
.map-column {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ── Login ───────────────────────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
}
.login-header {
  text-align: center;
  margin-bottom: 2rem;
}
.login-header h1 {
  font-size: 1.4rem;
  margin: 0.5rem 0 0.3rem;
}
.login-header p {
  color: var(--muted);
}
.login-footer {
  text-align: center;
  margin-top: 1.5rem;
  color: var(--muted);
  font-size: 0.75rem;
}
.form-group {
  margin-bottom: 1rem;
}
.form-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
.form-group input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
}
.form-group input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--green);
  color: #fff;
  border: none;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
}
.btn-primary:hover {
  opacity: 0.9;
}
.btn-full {
  width: 100%;
}
.btn-secondary {
  background: var(--border);
  color: var(--text);
  border: none;
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
}

/* ── Alerts ──────────────────────────────────────────────────────── */
.alert {
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}
.alert-error {
  background: var(--alert-error-bg);
  color: var(--danger);
  border: 1px solid var(--danger);
}
.alert-success {
  background: var(--alert-success-bg);
  color: var(--success);
  border: 1px solid var(--success);
}

/* ── Upload ──────────────────────────────────────────────────────── */
.upload-card {
  max-width: 700px;
}
.file-input {
  width: 100%;
  background: var(--bg);
  border: 2px dashed var(--border);
  color: var(--text);
  padding: 1.5rem;
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
}

/* ── Page header ─────────────────────────────────────────────────── */
.page-header {
  margin-bottom: 1.5rem;
}
.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
}
.page-header p {
  color: var(--muted);
  margin-top: 0.3rem;
}
.breadcrumb {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
}

/* ── Search ──────────────────────────────────────────────────────── */
.search-box {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.45rem 0.8rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
}
.search-box:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Last updated ────────────────────────────────────────────────── */
.last-updated {
  font-size: 0.72rem;
  color: var(--muted);
}

/* ── Turnout indicator ───────────────────────────────────────────── */
.turnout-ring {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
}

/* ── Nav active state & role badge ───────────────────────────────── */
.nav-links a.nav-active {
  color: var(--text) !important;
  border-bottom: 2px solid var(--green);
  padding-bottom: 2px;
}
.role-badge {
  background: var(--green);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: 0.04em;
  vertical-align: middle;
  margin-left: 3px;
}

/* ── Wider map on dashboard now that constituency table is gone ───── */
.dashboard-grid {
  grid-template-columns: 1.6fr 1fr;
  align-items: start;
}
@media (max-width: 900px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Theme toggle button ─────────────────────────────────────────── */
.theme-toggle {
  background: var(--border);
  border: 1px solid var(--border);
  color: var(--text);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition:
    background 0.2s,
    border-color 0.2s;
  padding: 0;
  flex-shrink: 0;
}
.theme-toggle:hover {
  background: var(--accent);
  border-color: var(--accent);
}

/* ── Export dropdown ─────────────────────────────────────────────── */
.export-dropdown {
  position: relative;
}
.btn-export {
  background: var(--green);
  color: #fff;
  border: none;
  padding: 4px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}
.btn-export:hover {
  opacity: 0.88;
}
.export-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 230px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  z-index: 200;
  overflow: hidden;
}
.export-menu.open {
  display: block;
}
.export-menu a {
  display: block;
  padding: 0.6rem 1rem;
  color: var(--text) !important;
  text-decoration: none;
  font-size: 0.85rem;
  transition: background 0.15s;
}
.export-menu a:hover {
  background: var(--border);
}

/* Light mode map fill adjustment */
[data-theme="light"] .map-container svg path {
  fill: #c8dce8;
  stroke: #6a9cb8;
}
[data-theme="light"] .map-container svg path:hover {
  stroke: #1a1f27;
}

/* Light mode form inputs */
[data-theme="light"] .form-group input,
[data-theme="light"] .search-box,
[data-theme="light"] select {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
}
[data-theme="light"] .file-input {
  background: var(--bg);
  border-color: var(--border);
  color: var(--text);
}

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE + PERFORMANCE LAYER
   ═══════════════════════════════════════════════════════════════════ */

/* ── Global mobile hygiene ───────────────────────────────────────── */
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
body {
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
img,
svg,
video,
canvas {
  max-width: 100%;
}

/* Never let long names/codes blow out the layout on narrow screens */
h1,
h2,
h3,
p,
td,
th,
a,
strong,
span {
  overflow-wrap: anywhere;
}

/* Comfortable touch targets on touch devices */
@media (hover: none) and (pointer: coarse) {
  .nav-links a,
  .btn-primary,
  .btn-secondary,
  .btn-logout,
  .btn-export,
  .theme-toggle,
  .nav-toggle,
  .export-menu a {
    min-height: 44px;
  }
  .btn-primary,
  .btn-secondary,
  .btn-logout,
  .btn-export,
  .nav-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  /* Hover-only affordances are noise on touch */
  .results-table tr:hover td {
    background: transparent;
  }
}

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Mobile nav toggle (hamburger) ───────────────────────────────── */
.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  font-size: 1.2rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.nav-toggle:focus-visible,
.theme-toggle:focus-visible,
.btn-export:focus-visible,
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-logout:focus-visible,
.nav-links a:focus-visible,
.search-box:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Responsive tables ───────────────────────────────────────────── */
.table-responsive {
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}
.results-table th {
  position: sticky;
  top: 0;
  z-index: 2;
}

/* Columns that get dropped on small screens (secondary detail) */
@media (max-width: 768px) {
  .col-hide-sm {
    display: none !important;
  }
}

/* ── Nav collapses to a hamburger as soon as the links stop fitting ─ */
@media (max-width: 1360px) {
  /* Navbar collapses into a hamburger-driven dropdown */
  .navbar {
    flex-wrap: wrap;
    padding: 0 0.85rem;
    height: auto;
    min-height: 52px;
    gap: 0.5rem;
  }
  .nav-brand {
    font-size: 0.8rem;
    min-width: 0;
    flex: 1;
    gap: 0.4rem;
  }
  .nav-brand strong {
    font-size: 0.85rem;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .nav-toggle {
    display: flex;
  }
  .nav-links {
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    width: 100%;
    border-top: 1px solid var(--border);
    padding: 0.4rem 0 0.8rem;
    max-height: calc(100vh - 52px);
    max-height: calc(100dvh - 52px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .nav-links.open {
    display: flex;
  }
  .nav-links a {
    padding: 0.7rem 0.2rem;
    width: 100%;
    justify-content: flex-start;
  }
  .nav-links a.nav-active {
    border-bottom: none;
    border-left: 3px solid var(--green);
    padding-left: 0.6rem;
    background: var(--table-hover);
  }
  .nav-links .export-dropdown,
  .nav-links .nav-user,
  .nav-links form {
    margin: 0.4rem 0;
    width: 100%;
  }
  .nav-links .theme-toggle {
    margin: 0.5rem 0;
  }
  .btn-export {
    width: 100%;
    padding: 0.7rem 1rem;
  }
  .export-menu {
    position: static;
    width: 100%;
    box-shadow: none;
    margin-top: 0.4rem;
  }
  .export-menu.open {
    display: block;
  }
  .btn-logout {
    width: 100%;
    padding: 0.7rem 1rem;
  }

  /* Prevent background scroll while the menu is open */
  body.nav-open {
    overflow: hidden;
  }

}

/* ── Tablet / small laptop ───────────────────────────────────────── */
@media (max-width: 1100px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .main-content {
    padding: 1.25rem 1rem;
  }
}

/* ── Mobile responsive overrides ─────────────────────────────────── */
@media (max-width: 768px) {
  body {
    font-size: 13px;
  }

  /* Main content & cards */
  .main-content {
    padding: 1rem 0.75rem;
  }
  .card,
  .map-container {
    padding: 0.9rem;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
    margin-bottom: 1rem;
  }
  .dashboard-grid,
  .panel-right,
  .map-column {
    gap: 1rem;
  }
  .card-value {
    font-size: 1.35rem;
  }
  .card-title {
    font-size: 0.68rem;
    letter-spacing: 0.06em;
  }

  /* Page header */
  .page-header {
    margin-bottom: 1rem;
  }
  .page-header h1 {
    font-size: 1.15rem;
  }
  .page-header p {
    font-size: 0.82rem;
  }

  /* Section headers wrap and stack their controls */
  .section-header {
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: flex-start;
  }
  .section-title {
    font-size: 0.92rem;
  }

  /* Tables: horizontal scroll with a pinned first column */
  .results-table th,
  .results-table td {
    padding: 0.5rem 0.55rem;
    font-size: 0.78rem;
    white-space: nowrap;
  }
  .results-table th:first-child,
  .results-table td:first-child {
    position: sticky;
    left: 0;
    background: var(--surface);
    z-index: 1;
  }
  .results-table th:first-child {
    background: var(--border);
    z-index: 3;
  }
  .results-table td[style*="padding-left"] {
    padding-left: 0.6rem !important;
  }
  .results-table th[style*="padding-left"] {
    padding-left: 0.6rem !important;
  }

  /* Candidate rows stack vote count below name */
  .candidate-meta {
    flex-wrap: wrap;
    gap: 0.2rem 0.5rem;
  }
  .candidate-meta > div:last-child {
    text-align: left !important;
  }

  /* Filter bars / search boxes take full width */
  .search-box,
  select.search-box,
  input.search-box {
    width: 100% !important;
    min-width: 0 !important;
    flex: 1 1 100% !important;
    font-size: 16px; /* stops iOS zoom-on-focus */
    padding: 0.6rem 0.8rem;
  }
  .form-group input {
    font-size: 16px;
  }
  .btn-secondary {
    padding: 0.55rem 0.9rem;
  }

  /* Ward accordion: stack header stats under the ward name */
  .ward-header {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .ward-header > div:last-child {
    width: 100%;
    flex-wrap: wrap;
    gap: 0.35rem 0.9rem !important;
    font-size: 0.75rem !important;
    padding-left: 1.5rem;
  }

  /* Login card fills more of the screen */
  .login-page {
    padding: 1rem;
    min-height: 100dvh;
  }
  .login-card {
    padding: 1.5rem;
  }

  /* Map legend wraps tightly */
  .legend-item {
    font-size: 0.7rem;
  }

  .site-footer {
    padding: 0.75rem 1rem;
    font-size: 0.72rem;
  }
  .footer-sep {
    display: none;
  }
  .footer-inner {
    flex-direction: column;
    gap: 0.15rem;
  }

  .upload-card {
    max-width: 100%;
  }
  .file-input {
    padding: 1.1rem 0.8rem;
  }
}

/* ── Small phones ────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
  .nav-brand .flag {
    font-size: 1.1rem;
  }
  .nav-brand strong {
    display: none;
  }
  .main-content {
    padding: 0.85rem 0.6rem;
  }
  .card-value {
    font-size: 1.2rem;
  }
  .page-header h1 {
    font-size: 1.05rem;
  }
  .results-table th,
  .results-table td {
    font-size: 0.74rem;
    padding: 0.45rem 0.45rem;
  }
  .notification-bar {
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
  }
}

@media (max-width: 360px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Landscape phones: keep the menu usable ──────────────────────── */
@media (max-height: 480px) and (max-width: 900px) {
  .nav-links {
    max-height: 70vh;
  }
}

/* ── Print ───────────────────────────────────────────────────────── */
@media print {
  .navbar,
  .site-footer,
  .notification-bar,
  .nav-toggle,
  .export-dropdown,
  .theme-toggle,
  .search-box,
  .btn-secondary {
    display: none !important;
  }
  .main-content {
    padding: 0;
    max-width: none;
  }
  .card,
  .map-container {
    break-inside: avoid;
    border-color: #ccc;
  }
}

/* ── Skip link & nav helpers ─────────────────────────────────────── */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 300;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
}
.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
}
.nav-logout-form {
  display: inline;
}

/* ── Two-column page layouts (upload screens) ────────────────────── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 900px) {
  .two-col {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

/* ── Ward toolbar ────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .ward-controls {
    width: 100%;
  }
  .ward-controls .search-box {
    width: 100% !important;
  }
  .ward-controls .btn-secondary {
    flex: 1 1 auto;
  }
}
