body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--gray-bg);
}

#pageLoader {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 20px;
  background: var(--white);
  transition: opacity 0.4s ease;
}

#pageLoader.fade-out { opacity: 0; pointer-events: none; }
.loader-logo-public {
  display: block;
  width: clamp(130px, 26vw, 190px);
  height: auto;
  margin-bottom: 2px;
}
.loader-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--gray-lt);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.loader-message { font-size: 0.88rem; color: var(--text-muted); text-align: center; max-width: 320px; line-height: 1.5; }

.topbar-center { display: flex; align-items: center; justify-content: center; gap: 8px; flex: 1; min-width: 0; margin: 0 20px; overflow: hidden; }
.topbar-center .filter-chip-label { color: rgba(255,255,255,0.76); }
.filter-chips { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 20px;
  font-size: 0.75rem;
  color: var(--white);
}
.filter-chip-label { color: var(--gray-md); font-size: 0.68rem; }

.national-layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  overflow: hidden;
  min-height: 0;
}

.national-map-panel { position: relative; min-width: 0; overflow: hidden; background: var(--surface-tint); }
#nationalMap { position: absolute; inset: 0; width: 100%; height: 100%; }

.error-banner {
  position: absolute;
  bottom: 16px;
  left: 50%;
  z-index: 10;
  transform: translateX(-50%);
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 0.82rem;
  color: var(--error-text);
  max-width: 520px;
  box-shadow: var(--shadow-md);
}

.national-legend {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 5;
  min-width: 220px;
  padding: 12px 14px;
  background: rgba(255,255,255,0.96);
  border: 1px solid rgba(38,47,104,0.12);
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(38,47,104,0.12);
  transition:
    border-color var(--transition),
    box-shadow var(--transition);
}

.national-legend:hover {
  border-color: rgba(38,47,104,0.2);
  box-shadow: 0 12px 30px rgba(38,47,104,0.14);
}
.legend-title { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; }
.legend-ramp { display: grid; grid-template-columns: repeat(5, 1fr); height: 9px; border-radius: 999px; overflow: hidden; margin-bottom: 7px; }
.legend-labels { display: flex; justify-content: space-between; gap: 10px; font-size: 0.68rem; color: var(--text-muted); }
.legend-note { margin-top: 6px; font-size: 0.66rem; line-height: 1.35; color: var(--text-muted); }

.national-sidebar {
  background: var(--gray-bg);
  border-left: 1px solid rgba(38,47,104,0.12);
  box-shadow: -14px 0 36px rgba(8,13,35,0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-empty, .sidebar-detail { padding: 16px; overflow-y: auto; }
.sidebar-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  color: var(--text-sub);
}
.sidebar-empty h2 { color: var(--navy); font-size: 1rem; }
.sidebar-empty p { max-width: 250px; color: var(--text-muted); font-size: 0.78rem; line-height: 1.55; }
.sidebar-detail { display: flex; flex-direction: column; gap: 14px; }
.state-summary-card, .breakdown-card {
  background: var(--white);
  border: 1px solid rgba(38,47,104,0.1);
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(38,47,104,0.06);
  transition:
    border-color var(--transition),
    box-shadow var(--transition);
}

.state-summary-card:hover,
.breakdown-card:hover {
  border-color: rgba(38,47,104,0.18);
  box-shadow: 0 10px 24px rgba(38,47,104,0.08);
}
.state-summary-card { padding: 18px; }
.state-eyebrow {
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.state-summary-card h2 { color: var(--navy); font-size: 1.1rem; }
.state-total {
  margin-top: 10px;
  color: var(--navy);
  font-size: 2.1rem;
  line-height: 1;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
}
.state-total-label { margin-top: 5px; font-size: 0.72rem; color: var(--text-muted); }
.breakdown-card { padding: 18px; }
.breakdown-card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.breakdown-card-header h2 {
  color: var(--text-soft);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.breakdown-loading { display: flex; align-items: center; gap: 10px; padding: 12px 0; }
.sidebar-help { font-size: 0.68rem; color: var(--text-muted); margin-bottom: 10px; line-height: 1.45; }
.discipline-list { display: flex; flex-direction: column; gap: 8px; }
.disc-row { display: flex; flex-direction: column; gap: 4px; }
.disc-row-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.disc-name { font-size: 0.75rem; font-weight: 600; color: var(--text-sub); }
.disc-counts { display: flex; gap: 8px; align-items: center; }
.disc-count-val { font-size: 0.75rem; font-variant-numeric: tabular-nums; color: var(--text-main); font-weight: 600; min-width: 38px; text-align: right; }
.disc-pct { font-size: 0.68rem; color: var(--text-muted); min-width: 42px; text-align: right; }
.disc-track { height: 7px; background: var(--surface-tint); border-radius: 999px; overflow: hidden; }
.disc-fill { height: 100%; background: var(--navy); border-radius: 999px; transition: width 0.5s cubic-bezier(0.4,0,0.2,1); }

.maplibregl-popup-content {
  font-family: var(--font-ui) !important;
  padding: 10px 12px !important;
  border-radius: 10px !important;
  box-shadow: var(--shadow-lg) !important;
}
.state-popup-title { color: var(--navy); font-size: 0.82rem; font-weight: 700; }
.state-popup-count { margin-top: 2px; color: var(--text-sub); font-size: 0.76rem; }

@media (max-width: 1050px) {
  .topbar-center { display: none; }
  .national-layout { grid-template-columns: 1fr 310px; }
}

@media (max-width: 820px) {
  body { height: auto; min-height: 100vh; overflow: auto; }
  .national-layout { grid-template-columns: 1fr; grid-template-rows: minmax(520px, 68vh) auto; overflow: visible; }
  .national-map-panel { min-height: 520px; }
  .national-sidebar { border-left: none; border-top: 1px solid rgba(38,47,104,0.12); box-shadow: none; overflow: visible; }
  .sidebar-empty, .sidebar-detail { overflow: visible; }
}

@media (max-width: 560px) {
  .national-legend { left: 10px; right: 10px; bottom: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  #pageLoader, .disc-fill, .preset-chip, .btn { transition: none; }
  .loader-spinner { animation: none; }
}

/* ── Topbar date controls ── */
.national-topbar-controls { display: flex; align-items: center; gap: 6px; }

.preset-chip-nav {
  padding: 4px 10px; font-size: 0.75rem;
  border-color: rgba(255,255,255,0.25);
  color: rgba(255,255,255,0.75);
  background: rgba(255,255,255,0.08);
}
.preset-chip-nav:hover { border-color: rgba(255,255,255,0.5); color: var(--white); background: rgba(255,255,255,0.15); }
.preset-chip-nav.active { background: rgba(255,255,255,0.2); border-color: rgba(255,255,255,0.5); color: var(--white); }

.preset-chip-nav:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.45);
}

/* ── State date range ── */
.state-date-range {
  margin-top: 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-height: 1em;
}
/* ── National sidebar footer ── */
.national-sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(38,47,104,0.1);
  flex-shrink: 0;
}

.national-csv-btn {
  width: 100%;
  justify-content: center;
  min-height: 38px;
  border-radius: 9px;
  background: var(--white);
  border: 1px solid rgba(38,47,104,0.14);
}

.national-csv-btn:hover:not(:disabled) {
  background: var(--navy);
  color: var(--white);
  border-color: var(--navy);
}
