/* ─── FONTS ──────────────────────────────────────────────────────── */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap");

/* ─── PALETTE (CSS variables) ────────────────────────────────────── */
:root {
  --bg: #0c0e14;
  --surface: #13151d;
  --card: #191c27;
  --border: #252836;
  --text: #eaecf0;
  --muted: #bebfc5;
  --accent-a: #4d67cd;
  --accent-b: #f4556f;
  --accent-p: #00d4ff;
}

/* ─── RESET ──────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}
/* Kill browser default purple/blue focus rings globally */
*:focus {
  outline: none !important;
}
*:focus-visible {
  outline: none !important;
}
button:focus,
button:active,
[role="combobox"]:focus,
[role="combobox"]:active,
[role="listbox"]:focus,
[data-radix-collection-item]:focus,
select:focus,
input:focus {
  outline: none !important;
  box-shadow: none !important;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ─── SCROLLBAR ──────────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* ─── APP SHELL ──────────────────────────────────────────────────── */
#app-container {
  display: flex;
  min-height: 100vh;
}

/* ─── SIDEBAR ────────────────────────────────────────────────────── */
#sidebar {
  width: 475px;
  min-width: 475px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1rem 1rem 2rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar-group-title {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-p);
  margin: 0 0 6px 0;
}
/* Sidebar metric cards (one per slider) */
.sidebar-metric-card {
  border: 1px solid rgba(37, 40, 54, 0.7);
  border-radius: 10px;
  padding: 10px 12px 6px;
  background: var(--card);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-metric-card:last-child {
  margin-bottom: 0;
}
/* Left column: label + slider stacked */
.metric-card-left {
  flex: 1;
  min-width: 0;
}
/* Right column: toggle */
.metric-card-right {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
}
/* Fixed-width slider inside left column */
.metric-card-left .dash-slider {
  max-width: 270px !important;
  width: 270px !important;
}
.metric-card-left .sidebar-slider {
  max-width: 270px !important;
  width: 270px !important;
}
  color: var(--accent-p);
  border-bottom: 2px solid var(--accent-p);
  padding: 5px 0;
  margin: 0.8rem 0 0.3rem;
}
.sidebar-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0;
  line-height: 1.25;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
  flex: 0 0 40%;
}
.sidebar-metric-row {
  min-height: 52px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(37, 40, 54, 0.5);
}
.sidebar-metric-row:last-child {
  border-bottom: none;
}

/* target pref buttons — vertical stacked (no fill, outline-only) */
.tgt-btn-group {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background: transparent;
  border-radius: 20px;
  padding: 2px;
  gap: 0;
  min-width: 110px;
  width: 110px;
}

/* Static direction label for unidirectional metrics */
.direction-label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 110px;
  width: 110px;
  padding: 3px 6px;
  font-family: "Inter", sans-serif;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--accent-p);
  background: transparent;
  border: 1.5px solid var(--accent-p);
  border-radius: 20px;
  box-shadow: 0 0 6px rgba(0, 212, 255, 0.15);
  line-height: 1.3;
  white-space: nowrap;
  user-select: none;
  opacity: 0.6;
}
.tgt-slider {
  position: absolute;
  left: 2px;
  width: calc(100% - 4px);
  height: calc(50% - 2px);
  background: transparent;
  border: 1.5px solid var(--accent-p);
  border-radius: 18px;
  transition: top 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 6px rgba(0, 212, 255, 0.15);
  pointer-events: none;
  z-index: 0;
  opacity: 0.6;
}
.tgt-btn {
  position: relative;
  z-index: 1;
  flex: 1;
  background: transparent;
  border: none;
  padding: 3px 6px;
  font-family: "Inter", sans-serif;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.55;
  cursor: pointer;
  transition:
    color 0.25s ease,
    opacity 0.25s ease;
  line-height: 1.3;
  white-space: nowrap;
  border-radius: 18px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tgt-btn:hover:not(.active) {
  opacity: 0.85;
  color: var(--text);
}
.tgt-btn.active {
  background: transparent;
  color: var(--accent-p);
  opacity: 0.6;
  text-decoration: none;
  box-shadow: none;
}

/* Reset button */
.reset-btn {
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--muted);
  font-size: 0.68rem;
  padding: 0.3rem 0.6rem;
  border-radius: 20px;
  letter-spacing: 0.06em;
  cursor: pointer;
  font-family: "Inter", sans-serif;
}
.reset-btn:hover {
  border-color: var(--accent-p);
  color: var(--accent-p);
}

/* ─── Dash 4 slider overrides (Radix-based) ─────────────────────── */
.dash-slider-track {
  background-color: rgba(190, 191, 197, 0.25) !important;
  height: 3px !important;
}
.dash-slider-range {
  background-color: var(--accent-p) !important;
  height: 3px !important;
}
.dash-slider-thumb {
  background-color: var(--accent-p) !important;
  border-color: var(--accent-p) !important;
  width: 10px !important;
  height: 10px !important;
}
.dash-slider-thumb:hover,
.dash-slider-thumb:focus {
  border-color: var(--accent-p) !important;
  box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.25) !important;
  outline: none !important;
}
.dash-slider-dot {
  display: none !important;
}
.dash-slider-tooltip {
  display: none !important;
}
.dash-input-container {
  display: none !important;
}
/* Sidebar label row */
.sidebar-label-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}
/* Importance suffix in heading */
.importance-suffix {
  color: var(--accent-p);
  font-weight: 500;
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-left: 6px;
  padding-left: 7px;
  border-left: 1px solid var(--accent-p);
  opacity: 1;
}

/* ─── MAIN CONTENT ───────────────────────────────────────────────── */
#main-content {
  flex: 1;
  padding: 1.6rem 2rem 2rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ─── TOP BAR ────────────────────────────────────────────────────── */
#top-bar {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: nowrap;
}
/* ─── Sliding mode toggle ─────────────────────────────────────────── */
.mode-toggle-track {
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(37, 40, 54, 0.6);
  border: none;
  border-radius: 20px;
  padding: 2px;
  gap: 0;
  width: 220px;
  flex-shrink: 0;
}
.mode-slider {
  position: absolute;
  top: 2px;
  width: calc(50% - 2px);
  height: calc(100% - 4px);
  background: var(--accent-p);
  border-radius: 18px;
  transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 8px rgba(0, 212, 255, 0.3);
  pointer-events: none;
  z-index: 0;
}
.mode-label {
  flex: 1;
  position: relative;
  z-index: 1;
  background: transparent;
  border: none;
  font-family: "Inter", sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 6px 0;
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
  color: var(--muted);
  opacity: 0.55;
  transition:
    color 0.25s ease,
    opacity 0.25s ease;
  border-radius: 18px;
}
.mode-label.active {
  color: #0c0e14;
  opacity: 1;
}
.mode-label:hover:not(.active) {
  color: var(--text);
  opacity: 0.85;
}
#county-dropdown {
  min-width: 200px;
}
.county-dropdown-wrap {
  min-width: 200px;
}

/* Mobile county: text label + hamburger (hidden on desktop) */
.county-mobile-wrap {
  display: none;
  align-items: center;
  gap: 8px;
}
.county-label-text {
  font-family: "Inter", sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.county-pick-btn {
  flex-shrink: 0;
}

/* ─── Dash 4 dropdown overrides ──────────────────────────────────── */
.dash-dropdown,
.dash-dropdown-root,
.Select,
.Select-control,
.Select-value,
.Select-input,
.Select-placeholder,
div[class*="dropdown"] > div {
  background: transparent !important;
  border-radius: 20px !important;
}
.dash-dropdown-trigger {
  background: var(--card) !important;
  border: 1px solid var(--border) !important;
  border-radius: 20px !important;
  color: var(--text) !important;
}
.dash-dropdown-value,
.dash-dropdown-placeholder,
.dash-dropdown-search {
  color: var(--text) !important;
  font-family: "Inter", sans-serif !important;
}
.dash-dropdown-content,
.dash-dropdown-options {
  background: var(--card) !important;
  border: 1px solid var(--border) !important;
  border-radius: 14px !important;
}
.dash-dropdown-option {
  background: var(--card) !important;
  color: var(--text) !important;
}
.dash-dropdown-option:hover,
.dash-dropdown-option[data-highlighted] {
  background: rgba(0, 212, 255, 0.1) !important;
  color: var(--accent-p) !important;
}
.dash-dropdown-option[data-state="checked"] {
  background: rgba(0, 212, 255, 0.08) !important;
  color: var(--accent-p) !important;
}
.dash-dropdown-trigger:focus-within {
  border-color: var(--accent-p) !important;
  box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.2) !important;
  outline: none !important;
}
.dash-dropdown-trigger:focus,
.dash-dropdown-trigger:active,
.dash-dropdown-trigger *:focus,
.dash-dropdown-trigger *:active,
.dash-dropdown-trigger[data-state="open"],
.dash-dropdown-trigger:focus-within *,
[data-radix-popper-content-wrapper] *:focus {
  outline: none !important;
}
.dash-dropdown-trigger:active,
.dash-dropdown-trigger *:active {
  box-shadow: none !important;
  border-color: var(--border) !important;
}
.dash-dropdown-trigger:focus-visible {
  border-color: var(--accent-p) !important;
  box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.2) !important;
  outline: none !important;
}
.dash-dropdown-trigger-icon {
  color: var(--muted) !important;
}
.dash-dropdown-search-icon {
  color: var(--muted) !important;
}
.dash-dropdown-clear {
  color: var(--muted) !important;
}
/* Make main-area dropdowns larger/bolder */
#main-content .dash-dropdown-value {
  font-size: 1rem !important;
  font-weight: 700 !important;
}

/* ─── SELECTION CARDS ────────────────────────────────────────────── */
.sel-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  border: 1px solid rgba(37, 40, 54, 0.7);
  border-radius: 10px;
  padding: 10px 14px;
  background: #191c27;
}
.sel-dropdown-district {
  flex: 0 0 320px;
  min-width: 200px;
  font-size: 0.78rem;
}
.sel-dropdown-school {
  flex: 0 0 280px;
  min-width: 180px;
  font-size: 0.78rem;
}
/* Make dropdowns inside cards pop against the card background */
.sel-row .dash-dropdown-trigger {
  background: #0c0e14 !important;
  border: 1px solid rgba(37, 40, 54, 0.9) !important;
}
.sel-score-area {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  min-width: 0;
}
.score-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.score-circle span {
  font-family: "Inter", sans-serif;
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--card);
  letter-spacing: -0.02em;
}
.rank-num {
  font-family: "Inter", sans-serif;
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--text);
  letter-spacing: -0.03em;
  line-height: 1;
}
.rank-ctx {
  font-family: "Inter", sans-serif;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--muted);
  line-height: 1;
  white-space: nowrap;
}
.rank-info {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-shrink: 0;
  min-width: 0;
}
.rank-badge-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 340px;
  flex-shrink: 0;
}
.rank-badge-row .badge,
.rank-badge-row .badge-placeholder {
  margin-left: auto;
}
.sel-spacer {
  flex: 1 1 auto;
}
.badge-placeholder {
  display: inline-block;
  width: 0;
  flex-shrink: 0;
}
.sel-remove-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}
.sel-remove-btn:hover {
  border-color: var(--accent-b);
  color: var(--accent-b);
}

/* Rank badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: "Inter", sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}
.badge-gold {
  background: rgba(255, 215, 0, 0.15);
  color: #ffd700;
  border: 1px solid rgba(255, 215, 0, 0.35);
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}
.badge-silver {
  background: rgba(192, 192, 192, 0.12);
  color: #c0c0c0;
  border: 1px solid rgba(192, 192, 192, 0.3);
  text-shadow: 0 0 6px rgba(192, 192, 192, 0.3);
}
.badge-bronze {
  background: rgba(205, 127, 50, 0.12);
  color: #cd7f32;
  border: 1px solid rgba(205, 127, 50, 0.3);
  text-shadow: 0 0 6px rgba(205, 127, 50, 0.3);
}

/* Add button — card-shaped */
.add-btn {
  background: transparent;
  border: 1px dashed var(--accent-p);
  color: var(--accent-p);
  font-size: 0.72rem;
  padding: 10px 14px;
  border-radius: 10px;
  letter-spacing: 0.06em;
  cursor: pointer;
  font-family: "Inter", sans-serif;
  transition: all 0.2s ease;
  width: 100%;
  text-align: center;
}
.add-btn:hover {
  background: rgba(0, 212, 255, 0.06);
  border-color: var(--accent-p);
  color: var(--accent-p);
  box-shadow: 0 0 8px rgba(0, 212, 255, 0.15);
}

/* disabled dropdown appearance */
.sel-dropdown-school.disabled .dash-dropdown-trigger {
  opacity: 0.3 !important;
  pointer-events: none !important;
}

/* ─── DATA TABLE ─────────────────────────────────────────────────── */
.dash-table-container {
  overflow: auto;
}
.dash-spreadsheet-container .dash-spreadsheet-inner th {
  background: var(--surface) !important;
  color: var(--muted) !important;
  font-size: 0.72rem !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.06em !important;
  border-bottom: 1px solid var(--border) !important;
  padding: 8px 12px !important;
}
.dash-spreadsheet-container .dash-spreadsheet-inner td {
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem !important;
  font-weight: 500;
  border-bottom: 1px solid rgba(37, 40, 54, 0.5) !important;
  padding: 6px 12px !important;
  font-family: "Inter", sans-serif !important;
}

/* ─── FOOTER ─────────────────────────────────────────────────────── */
.dash-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  padding: 1rem 0 0.5rem;
  margin-top: 1.5rem;
  border-top: 1px solid var(--border);
}

/* ─── THEME TOGGLE BUTTON ────────────────────────────────────────── */
.theme-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 1.05rem;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
  flex-shrink: 0;
  margin-left: auto;
  line-height: 1;
  padding: 0;
}
.theme-toggle-btn:hover {
  border-color: var(--accent-p);
  color: var(--accent-p);
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   LIGHT MODE
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
body.light-mode {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --card: #ffffff;
  --border: #e1e5eb;
  --text: #1e2330;
  --muted: #64748b;
  --accent-p: #0891b2;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: auto;
}

/* Scrollbar */
body.light-mode ::-webkit-scrollbar-track { background: var(--bg); }
body.light-mode ::-webkit-scrollbar-thumb { background: #c4c9d4; border-radius: 3px; }
body.light-mode ::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* Sidebar */
body.light-mode #sidebar {
  background: var(--surface);
  border-right-color: var(--border);
  box-shadow: 1px 0 12px rgba(0, 0, 0, 0.04);
}

/* Sidebar metric cards */
body.light-mode .sidebar-metric-card {
  background: var(--bg);
  border-color: var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

/* Mode toggle track */
body.light-mode .mode-toggle-track {
  background: rgba(100, 116, 139, 0.1);
}

/* Active mode label: white text on teal pill */
body.light-mode .mode-label.active {
  color: #ffffff;
}

/* Mode slider glow */
body.light-mode .mode-slider {
  box-shadow: 0 0 8px rgba(8, 145, 178, 0.2);
}

/* Selection cards */
body.light-mode .sel-row {
  background: var(--surface);
  border-color: var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
body.light-mode .sel-row .dash-dropdown-trigger {
  background: var(--bg) !important;
  border-color: var(--border) !important;
}

/* Dropdowns */
body.light-mode .dash-dropdown-trigger {
  background: var(--surface) !important;
  border-color: var(--border) !important;
}
body.light-mode .dash-dropdown-content,
body.light-mode .dash-dropdown-options {
  background: var(--surface) !important;
  border-color: var(--border) !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08) !important;
}
body.light-mode .dash-dropdown-option {
  background: var(--surface) !important;
  color: var(--text) !important;
}
body.light-mode .dash-dropdown-option:hover,
body.light-mode .dash-dropdown-option[data-highlighted] {
  background: rgba(8, 145, 178, 0.06) !important;
  color: var(--accent-p) !important;
}
body.light-mode .dash-dropdown-option[data-state="checked"] {
  background: rgba(8, 145, 178, 0.06) !important;
  color: var(--accent-p) !important;
}
body.light-mode .dash-dropdown-trigger:focus-within {
  box-shadow: 0 0 0 2px rgba(8, 145, 178, 0.15) !important;
}

/* Slider track & thumb */
body.light-mode .dash-slider-track {
  background-color: rgba(100, 116, 139, 0.2) !important;
}
body.light-mode .dash-slider-thumb:hover,
body.light-mode .dash-slider-thumb:focus {
  box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.18) !important;
}

/* Target toggle outline glow */
body.light-mode .tgt-slider {
  box-shadow: 0 0 6px rgba(8, 145, 178, 0.08);
}

/* Direction label outline glow */
body.light-mode .direction-label {
  box-shadow: 0 0 6px rgba(8, 145, 178, 0.08);
}

/* Score circle text always dark for readability */
body.light-mode .score-circle span {
  color: #1e2330;
}

/* Empty score circle */
body.light-mode .score-empty {
  background: var(--border) !important;
}

/* Badges: soften glow for light backgrounds */
body.light-mode .badge-gold  { text-shadow: none; }
body.light-mode .badge-silver { text-shadow: none; }
body.light-mode .badge-bronze { text-shadow: none; }

/* FAB: white text on teal */
body.light-mode .fab-filter {
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(8, 145, 178, 0.25);
}
body.light-mode .fab-filter:hover {
  box-shadow: 0 6px 24px rgba(8, 145, 178, 0.35);
}

/* Mobile picker overlay */
body.light-mode .picker-search {
  background: var(--bg);
  border-color: var(--border);
}
body.light-mode .picker-opt-btn {
  border-bottom-color: var(--border);
}

/* Mobile sidebar shadow */
body.light-mode #sidebar.sidebar-open {
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.1);
}
body.light-mode .sidebar-backdrop.active {
  background: rgba(0, 0, 0, 0.2);
}

/* Reset & Add buttons */
body.light-mode .reset-btn { border-color: var(--border); }
body.light-mode .sel-remove-btn { border-color: var(--border); }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   MOBILE-FIRST RESPONSIVE OVERHAUL  (< 768 px)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

/* ── Mobile name text block (hidden on desktop) ─────────────────── */
.sel-name-block {
  display: none;
  flex-direction: column;
  gap: 0px;
  flex: 1 1 100%;
  min-width: 0;
  overflow: hidden;
  padding-right: 28px; /* room for remove btn */
}
.sel-name-primary {
  font-family: "Inter", sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.sel-name-secondary {
  font-family: "Inter", sans-serif;
  font-size: 0.62rem;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin-top: 1px;
}

/* ── Sidebar top row (reset + close) ──────────────────────────── */
.sidebar-top-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  margin-bottom: 10px;
  min-height: 32px;
}

/* Mobile hamburger pick buttons — hidden on desktop */
.sel-mobile-pickers {
  display: none;
  flex-direction: row;
  gap: 4px;
  flex-shrink: 0;
}
.sel-pick-hamburger {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 26px;
  padding: 0 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition:
    border-color 0.2s ease,
    background 0.2s ease;
  font-family: "Inter", sans-serif;
  font-size: 0.58rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  flex-shrink: 0;
  line-height: 1;
  white-space: nowrap;
}
.sel-pick-hamburger:hover {
  border-color: var(--accent-p);
  color: var(--accent-p);
}
.sel-pick-hamburger:active {
  background: rgba(0, 212, 255, 0.1);
}

/* ── Sidebar close button (hidden on desktop) ──────────────────── */
.sidebar-close-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s;
  padding: 0;
  line-height: 1;
  margin-left: auto; /* push to right */
  flex-shrink: 0;
}
.sidebar-close-btn:hover {
  border-color: var(--accent-p);
  color: var(--accent-p);
}

/* ── Fullscreen mobile picker overlay ───────────────────────────── */
.mobile-picker {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition:
    opacity 0.25s ease,
    transform 0.25s ease;
}
.mobile-picker.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.picker-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 0;
}
.picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.picker-title {
  font-family: "Inter", sans-serif;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}
.picker-close-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}
.picker-close-btn:hover {
  border-color: var(--accent-p);
  color: var(--accent-p);
}
.picker-search {
  display: block;
  width: calc(100% - 32px);
  margin: 12px 16px 8px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-family: "Inter", sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
}
.picker-search::placeholder {
  color: var(--muted);
}
.picker-search:focus {
  border-color: var(--accent-p);
  box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.15);
}
.picker-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 8px 24px;
}
.picker-opt-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(37, 40, 54, 0.5);
  padding: 14px 12px;
  font-family: "Inter", sans-serif;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}
.picker-opt-btn:last-child {
  border-bottom: none;
}
.picker-opt-btn:hover,
.picker-opt-btn:active {
  background: rgba(0, 212, 255, 0.08);
  color: var(--accent-p);
}

/* ── Floating Action Button (mobile-only trigger) ───────────────── */
.fab-filter {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1060;
  background: var(--accent-p);
  color: var(--bg);
  border: none;
  border-radius: 50px;
  padding: 12px 22px;
  font-family: "Inter", sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 212, 255, 0.4);
  transition:
    box-shadow 0.2s ease,
    transform 0.2s ease;
  align-items: center;
  gap: 6px;
}
.fab-filter:hover {
  box-shadow: 0 6px 28px rgba(0, 212, 255, 0.6);
  transform: translateY(-2px);
}

/* ── Sidebar backdrop (mobile overlay) ──────────────────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 1040;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.sidebar-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* ── Mobile breakpoint ──────────────────────────────────────────── */
@media (max-width: 767.98px) {
  /* Show FAB & backdrop layer */
  .fab-filter {
    display: flex;
  }
  .sidebar-backdrop {
    display: block;
  }

  /* Sidebar → slide-up from bottom */
  #sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: 100%;
    max-width: 100%;
    min-width: unset;
    height: 75vh;
    max-height: 75vh;
    border-right: none;
    border-top: 1px solid var(--border);
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1050;
    padding-top: 0;
  }
  #sidebar.sidebar-open {
    transform: translateY(0);
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.5);
  }

  /* Show close button on mobile */
  .sidebar-close-btn {
    display: flex;
  }

  /* Drag-handle hint at top of pane */
  #sidebar::before {
    content: "";
    display: block;
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 10px auto 8px;
    flex-shrink: 0;
  }

  /* Hide FAB when sidebar is open (it's behind the pane anyway) */
  #sidebar.sidebar-open ~ .fab-filter,
  .sidebar-open ~ .fab-filter {
    opacity: 0;
    pointer-events: none;
  }

  /* App shell: single column, viewport-locked */
  #app-container {
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
  }

  /* Main content: fill remaining space, no page scroll */
  #main-content {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    padding: 0.75rem 0.75rem 0;
    gap: 0.4rem;
  }

  /* Top bar compact */
  #top-bar {
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  .mode-toggle-track {
    width: 160px;
  }
  .mode-label {
    font-size: 0.58rem;
    padding: 5px 0;
  }

  /* Hide desktop county dropdown, show mobile county */
  .county-dropdown-wrap {
    display: none !important;
  }
  .county-mobile-wrap {
    display: flex !important;
  }

  /* ── Stacked full-width selection cards ──────────────────────── */
  #selection-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 2px 0 4px;
    flex-shrink: 0;
  }

  /* Hide desktop dropdowns, show mobile text + hamburgers */
  .sel-dropdown-district,
  .sel-dropdown-school {
    display: none !important;
  }
  .sel-name-block {
    display: flex !important;
  }
  .sel-mobile-pickers {
    display: flex !important;
  }

  .sel-row {
    flex-wrap: wrap !important;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px 10px !important;
    position: relative;
    gap: 4px 8px !important;
    align-items: center;
  }

  /* Name block spans full width at top of card */
  .sel-name-block {
    order: -2;
    flex: 1 1 100% !important;
  }
  /* Hamburgers in upper-right area */
  .sel-mobile-pickers {
    position: absolute !important;
    top: 8px;
    right: 8px;
    order: -1;
  }
  .sel-score-area {
    flex: 0 0 auto;
    order: 1;
  }
  .sel-spacer {
    display: block;
    flex: 1 1 auto;
    order: 2;
  }
  /* Remove button bottom-right */
  .sel-remove-btn {
    position: absolute !important;
    bottom: 6px;
    right: 8px;
    top: auto;
    width: 22px !important;
    height: 22px !important;
    font-size: 0.55rem !important;
    order: 4;
  }

  /* Compact score elements */
  .score-circle {
    width: 38px;
    height: 38px;
  }
  .score-circle span {
    font-size: 0.82rem;
  }
  .rank-num {
    font-size: 1.1rem;
  }
  .rank-ctx {
    font-size: 0.55rem;
  }
  .rank-badge-row {
    width: auto;
  }
  .badge {
    font-size: 0.55rem;
    padding: 2px 6px;
  }

  /* Add button full width */
  .add-btn {
    font-size: 0.62rem;
    padding: 0.35rem 0.7rem;
    flex-shrink: 0;
    align-self: stretch;
    text-align: center;
    width: 100%;
  }

  /* ── Data-table viewport (independent scroll) ───────────────── */
  .table-viewport {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
  }
  .dash-spreadsheet-container .dash-spreadsheet-inner th {
    font-size: 0.6rem !important;
    padding: 4px 5px !important;
  }
  .dash-spreadsheet-container .dash-spreadsheet-inner td {
    font-size: 0.73rem !important;
    padding: 3px 5px !important;
  }

  /* Footer compact */
  .dash-footer {
    font-size: 0.5rem;
    padding: 0.3rem 0;
    margin-top: 0.3rem;
    flex-shrink: 0;
  }
}

/* ═══════════════════════════════════════════════════════════════════════
   NARRATIVE MODAL  –  "Why This Fit?" overlay
   ═══════════════════════════════════════════════════════════════════════ */

/* ── "Why This Fit?" button on each selection card ────────────────── */
.narrative-btn {
  background: transparent;
  border: 1.5px solid var(--accent-p);
  color: var(--accent-p);
  font-family: "Inter", sans-serif;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.narrative-btn-icon {
  font-size: 0.8rem;
  line-height: 1;
}
.narrative-btn:hover {
  background: var(--accent-p);
  color: #0c0e14;
}

/* ── Modal backdrop ───────────────────────────────────────────────── */
.narrative-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  align-items: flex-start;
  justify-content: center;
  padding: 1.5rem 1rem;
  overflow-y: auto;
}
.narrative-modal.active {
  display: flex;
}

/* ── Modal card ───────────────────────────────────────────────────── */
.narrative-modal-content {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  max-width: 620px;
  width: 100%;
  padding: 0;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255,255,255,0.04);
  animation: nm-slide-up 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  margin-top: 3vh;
}
@keyframes nm-slide-up {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1);       }
}

/* Close button — floats top-right inside card */
.narrative-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--muted);
  font-size: 1rem;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  padding: 0;
  line-height: 1;
}
.narrative-close-btn:hover {
  background: rgba(255,255,255,0.12);
  color: var(--text);
}

/* ── Modal body (scrollable inner) ────────────────────────────────── */
.narrative-body {
  min-height: 60px;
  max-height: 82vh;
  overflow-y: auto;
  padding: 1.5rem 1.75rem 1.25rem;
}
.nm-container {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ═══  1  HERO  ═══════════════════════════════════════════════════════ */
.nm-hero {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.9rem;
}
.nm-score-badge {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: var(--badge-clr, #00d4ff);
  display: flex;
  align-items: baseline;
  justify-content: center;
  padding-top: 12px;
  box-shadow: 0 4px 20px color-mix(in srgb, var(--badge-clr, #00d4ff) 40%, transparent);
}
.nm-score-num {
  font-family: "Plus Jakarta Sans", "Inter", sans-serif;
  font-size: 1.55rem;
  font-weight: 800;
  color: #fff;
  line-height: 1;
}
.nm-score-denom {
  font-size: 0.7rem;
  font-weight: 600;
  color: rgba(255,255,255,0.7);
  margin-left: 1px;
}
.nm-hero-text {
  flex: 1;
  min-width: 0;
}
.nm-entity-name {
  font-family: "Plus Jakarta Sans", "Inter", sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 2px 0;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nm-rank-row {
  font-size: 0.76rem;
}
.nm-rank-num {
  font-weight: 700;
  color: var(--accent-p, #00d4ff);
}
.nm-rank-of {
  color: var(--muted);
}
.nm-rank-pct {
  color: var(--muted);
  font-weight: 600;
}

/* ═══  2  PILLS  ══════════════════════════════════════════════════════ */
.nm-pills-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 1rem;
}
.nm-pill {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--muted);
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 8px;
  padding: 4px 10px;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
.nm-pill-icon {
  font-size: 0.72rem;
}
.nm-pill-link {
  cursor: pointer;
  color: var(--muted);
  text-decoration: none;
}
.nm-pill-link:hover {
  background: rgba(0, 212, 255, 0.08);
  border-color: rgba(0, 212, 255, 0.25);
  color: var(--accent-p, #00d4ff);
}
.nm-pill-charter {
  background: rgba(251, 191, 36, 0.1);
  border-color: rgba(251, 191, 36, 0.25);
  color: #fbbf24;
}

/* ═══  3  METRIC BARS  ════════════════════════════════════════════════ */
.nm-section {
  margin-bottom: 1rem;
}
.nm-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  margin: 0 0 0.55rem 0;
}
.nm-bars-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.nm-bar-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nm-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.nm-bar-label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text);
}
.nm-bar-score {
  font-size: 0.82rem;
  font-weight: 800;
  font-family: "Plus Jakarta Sans", "Inter", sans-serif;
}
.nm-bar-track {
  height: 6px;
  border-radius: 3px;
  background: rgba(255,255,255,0.06);
  overflow: hidden;
}
.nm-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.nm-bar-sub {
  font-size: 0.66rem;
  color: var(--muted);
  margin-top: 1px;
}

/* ═══  4  ETHNICITY  ══════════════════════════════════════════════════ */
.nm-eth-bar {
  display: flex;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 6px;
  background: rgba(255,255,255,0.04);
}
.nm-eth-seg {
  height: 100%;
  min-width: 2px;
  transition: width 0.3s ease;
}
.nm-eth-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}
.nm-eth-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.66rem;
  color: var(--muted);
  white-space: nowrap;
}
.nm-eth-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ═══  5  AI NARRATIVE  ═══════════════════════════════════════════════ */
.nm-ai-section {
  background: rgba(0, 212, 255, 0.03);
  border: 1px solid rgba(0, 212, 255, 0.10);
  border-radius: 12px;
  padding: 0.85rem 1rem;
}
.nm-ai-title {
  color: var(--accent-p, #00d4ff) !important;
}
.nm-ai-icon {
  font-size: 0.8rem;
}
.nm-narrative-text {
  font-size: 0.84rem;
  line-height: 1.6;
  color: var(--text);
  margin: 0;
}

/* ═══  6  CONTACT BAR  ════════════════════════════════════════════════ */
.nm-contact-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  margin-top: 0.25rem;
}
.nm-contact-item {
  font-size: 0.74rem;
  color: var(--muted);
}
.nm-contact-link {
  font-size: 0.74rem;
  color: var(--accent-p, #00d4ff);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.nm-contact-link:hover {
  text-decoration: underline;
}

/* ═══  LIGHT MODE  ════════════════════════════════════════════════════ */
body.light-mode .narrative-modal {
  background: rgba(0, 0, 0, 0.35);
}
body.light-mode .narrative-modal-content {
  background: #ffffff;
  border-color: #e1e5eb;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0,0,0,0.04);
}
body.light-mode .narrative-close-btn {
  background: rgba(0,0,0,0.04);
  border-color: rgba(0,0,0,0.08);
  color: #64748b;
}
body.light-mode .narrative-close-btn:hover {
  background: rgba(0,0,0,0.08);
  color: #1e2330;
}
body.light-mode .nm-entity-name {
  color: #1e2330;
}
body.light-mode .nm-rank-num {
  color: #0891b2;
}
body.light-mode .nm-pill {
  background: rgba(0,0,0,0.03);
  border-color: rgba(0,0,0,0.08);
  color: #64748b;
}
body.light-mode .nm-pill-link:hover {
  background: rgba(8, 145, 178, 0.06);
  border-color: rgba(8, 145, 178, 0.2);
  color: #0891b2;
}
body.light-mode .nm-pill-charter {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.2);
  color: #b45309;
}
body.light-mode .nm-section-title {
  color: #64748b;
}
body.light-mode .nm-bar-label {
  color: #1e2330;
}
body.light-mode .nm-bar-track {
  background: rgba(0,0,0,0.06);
}
body.light-mode .nm-bar-sub {
  color: #94a3b8;
}
body.light-mode .nm-eth-bar {
  background: rgba(0,0,0,0.04);
}
body.light-mode .nm-eth-legend-item {
  color: #64748b;
}
body.light-mode .nm-ai-section {
  background: rgba(8, 145, 178, 0.04);
  border-color: rgba(8, 145, 178, 0.12);
}
body.light-mode .nm-ai-title {
  color: #0891b2 !important;
}
body.light-mode .nm-narrative-text {
  color: #1e2330;
}
body.light-mode .nm-contact-bar {
  border-top-color: #e1e5eb;
}
body.light-mode .nm-contact-item {
  color: #64748b;
}
body.light-mode .nm-contact-link {
  color: #0891b2;
}
body.light-mode .narrative-btn {
  border-color: #0891b2;
  color: #0891b2;
}
body.light-mode .narrative-btn:hover {
  background: #0891b2;
  color: #ffffff;
}

/* ═══  MOBILE  ════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
  .narrative-modal-content {
    border-radius: 14px;
    max-width: 100%;
  }
  .narrative-body {
    padding: 1.1rem 1rem 0.9rem;
  }
  .nm-hero {
    gap: 0.7rem;
  }
  .nm-score-badge {
    width: 52px;
    height: 52px;
    border-radius: 13px;
  }
  .nm-score-num {
    font-size: 1.25rem;
  }
  .nm-entity-name {
    font-size: 0.95rem;
  }
  .nm-pill {
    font-size: 0.65rem;
    padding: 3px 8px;
  }
  .nm-bar-label {
    font-size: 0.72rem;
  }
  .nm-narrative-text {
    font-size: 0.8rem;
  }
  .narrative-btn {
    font-size: 0.52rem;
    padding: 3px 7px;
  }
}


/* ═══════════════════════════════════════════════════════════════════════
   SCORING-HELP MODAL
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Sidebar button ───────────────────────────────────────────────── */
.scoring-help-btn {
  display: block;
  width: 100%;
  margin-top: 1.2rem;
  padding: 10px 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.scoring-help-btn:hover {
  background: rgba(0, 212, 255, 0.07);
  border-color: var(--accent-p, #00d4ff);
  color: var(--accent-p, #00d4ff);
}
body.light-mode .scoring-help-btn {
  border-color: #d1d5db;
  color: #64748b;
}
body.light-mode .scoring-help-btn:hover {
  background: rgba(8, 145, 178, 0.06);
  border-color: #0891b2;
  color: #0891b2;
}

/* ── Backdrop ─────────────────────────────────────────────────────── */
.scoring-help-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9500;
  background: rgba(0, 0, 0, 0.65);
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
  overflow-y: auto;
}
.scoring-help-modal.active {
  display: flex;
}

/* ── Card ─────────────────────────────────────────────────────────── */
.scoring-help-modal-content {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  max-width: 580px;
  width: 100%;
  padding: 1.5rem 1.75rem 1.25rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: narrative-fade-in 0.18s ease-out;
  margin-top: 2vh;
}

/* ── Header ───────────────────────────────────────────────────────── */
.scoring-help-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.scoring-help-title {
  font-family: "Plus Jakarta Sans", "Inter", sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent-p, #00d4ff);
}

/* ── Body / sections ──────────────────────────────────────────────── */
.scoring-help-body {
  max-height: 72vh;
  overflow-y: auto;
  padding-right: 4px;
}
.sh-container {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}
.sh-section-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent-p, #00d4ff);
  margin: 0 0 0.35rem 0;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.sh-note {
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--muted);
  margin: 0 0 0.4rem 0;
}
.sh-formula {
  font-family: "Fira Code", "Consolas", monospace;
  font-size: 0.78rem;
  color: var(--text);
  background: rgba(255,255,255,0.04);
  border-radius: 6px;
  padding: 6px 10px;
  margin: 0.25rem 0 0.4rem 0;
}

/* ── Tables ───────────────────────────────────────────────────────── */
.sh-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.76rem;
  margin-bottom: 0.2rem;
}
.sh-th {
  text-align: left;
  padding: 5px 8px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.sh-td {
  padding: 4px 8px;
  color: var(--text);
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.sh-td.sh-metric {
  font-weight: 600;
}
.sh-td.sh-weight {
  color: var(--accent-p, #00d4ff);
}
.sh-td.sh-pref {
  color: var(--muted);
  font-style: italic;
}

/* ── Light-mode overrides ─────────────────────────────────────────── */
body.light-mode .scoring-help-modal {
  background: rgba(0, 0, 0, 0.3);
}
body.light-mode .scoring-help-modal-content {
  background: #ffffff;
  border-color: #e1e5eb;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}
body.light-mode .scoring-help-title {
  color: #0891b2;
}
body.light-mode .sh-section-title {
  color: #0891b2;
}
body.light-mode .sh-note {
  color: #64748b;
}
body.light-mode .sh-formula {
  color: #1e2330;
  background: rgba(0, 0, 0, 0.04);
}
body.light-mode .sh-th {
  color: #64748b;
  border-bottom-color: #e1e5eb;
}
body.light-mode .sh-td {
  color: #1e2330;
  border-bottom-color: rgba(0, 0, 0, 0.06);
}
body.light-mode .sh-td.sh-weight {
  color: #0891b2;
}
body.light-mode .sh-td.sh-pref {
  color: #64748b;
}

/* ── Mobile tweaks ────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .scoring-help-modal-content {
    padding: 1rem 1.15rem 0.9rem;
    border-radius: 12px;
    max-width: 100%;
  }
  .sh-table {
    font-size: 0.7rem;
  }
  .sh-section-title {
    font-size: 0.76rem;
  }
  .scoring-help-body {
    max-height: 80vh;
  }
}
