:root {
  --navy: #1e3a5f;
  --navy-dark: #16283f;
  --blue: #2f5597;
  --blue-light: #eaf1fb;
  --gray-50: #f7f8fa;
  --gray-100: #eef0f3;
  --gray-200: #dfe3e8;
  --gray-400: #9aa3af;
  --gray-600: #5b6470;
  --gray-800: #29303a;
  --green: #1b8a5a;
  --amber: #b7791f;
  --red: #b23b3b;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(20, 30, 50, 0.08), 0 1px 2px rgba(20, 30, 50, 0.06);
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--gray-50);
  color: var(--gray-800);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Header ---------- */
header.site-header {
  background: var(--navy);
  color: #fff;
  padding: 14px 20px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-weight: 700;
  font-size: 1.15rem;
  color: #fff;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; opacity: 0.9; }
.brand .brand-sub {
  font-weight: 400;
  font-size: 0.75rem;
  color: #b9c6dc;
}

.search-wrap {
  flex: 1;
  min-width: 220px;
  position: relative;
}

.search-wrap input[type="search"] {
  width: 100%;
  padding: 9px 14px;
  border-radius: 20px;
  border: none;
  font-size: 0.95rem;
  outline: none;
  background: #fff;
}

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  max-height: 420px;
  overflow-y: auto;
  display: none;
  color: var(--gray-800);
}
.search-results.open { display: block; }

.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--gray-100);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--blue-light); }
.sr-icon { font-size: 1.1rem; width: 22px; text-align: center; flex: none; }
.sr-main { min-width: 0; }
.sr-name { font-weight: 600; font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-meta { font-size: 0.78rem; color: var(--gray-600); }
.search-empty, .search-loading {
  padding: 14px;
  font-size: 0.88rem;
  color: var(--gray-600);
}

/* ---------- Layout ---------- */
main.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.hero {
  text-align: center;
  margin-bottom: 28px;
}
.hero h1 {
  font-size: 1.9rem;
  margin: 0 0 8px;
  color: var(--navy);
}
.hero p {
  color: var(--gray-600);
  margin: 0;
  font-size: 1.02rem;
}
.stat-strip {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.stat-strip .stat { text-align: center; }
.stat-strip .stat b { display: block; font-size: 1.3rem; color: var(--navy); }
.stat-strip .stat span { font-size: 0.8rem; color: var(--gray-600); }

/* ---------- Map ---------- */
.map-section {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 24px;
}
.map-section h2 { margin: 0 0 4px; font-size: 1.1rem; color: var(--navy); }
.map-section .hint { font-size: 0.85rem; color: var(--gray-600); margin: 0 0 10px; }

#usMap {
  width: 100%;
  height: auto;
  max-height: 520px;
  display: block;
  margin: 0 auto;
}
#usMap path.state {
  fill: #cddcee;
  stroke: #fff;
  stroke-width: 1.2;
  cursor: pointer;
  transition: fill 0.12s ease;
}
#usMap path.state:hover { fill: var(--blue); }
#usMap path.state.state-unavailable {
  fill: var(--gray-200);
  cursor: default;
}
#usMap path.state.state-unavailable:hover { fill: var(--gray-200); }

.map-legend {
  display: flex;
  gap: 18px;
  justify-content: center;
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--gray-600);
}
.map-legend .swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.sw-available { background: #cddcee; }
.sw-unavailable { background: var(--gray-200); }

/* ---------- Territories ---------- */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}
.chip {
  background: var(--blue-light);
  border: 1px solid var(--gray-200);
  border-radius: 20px;
  padding: 7px 14px;
  font-size: 0.85rem;
  color: var(--navy);
}
.chip:hover { background: #dbe8fa; text-decoration: none; }
.chip.unavailable { background: var(--gray-100); color: var(--gray-400); cursor: default; }
.chip.unavailable:hover { background: var(--gray-100); }

/* ---------- Browse grid ---------- */
.browse-section {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.browse-section h2 { margin: 0 0 14px; font-size: 1.1rem; color: var(--navy); }
.browse-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}
.browse-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 12px;
  border-radius: 6px;
  border: 1px solid var(--gray-100);
  font-size: 0.9rem;
}
.browse-item.unavailable { color: var(--gray-400); }
.browse-item .count { font-size: 0.75rem; color: var(--gray-600); }

/* ---------- Breadcrumb ---------- */
.breadcrumb {
  font-size: 0.85rem;
  color: var(--gray-600);
  margin-bottom: 16px;
}
.breadcrumb a { color: var(--blue); }

/* ---------- State page ---------- */
.page-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}
.page-title h1 { margin: 0; font-size: 1.6rem; color: var(--navy); }
.page-title .counts { font-size: 0.9rem; color: var(--gray-600); }

.filter-bar {
  margin-bottom: 14px;
}
.filter-bar input {
  width: 100%;
  max-width: 380px;
  padding: 9px 14px;
  border: 1px solid var(--gray-200);
  border-radius: 20px;
  font-size: 0.92rem;
  outline: none;
}
.filter-bar input:focus { border-color: var(--blue); }

.district-table-wrap {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
table.district-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.district-table th {
  text-align: left;
  background: var(--gray-50);
  padding: 10px 14px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--gray-600);
  border-bottom: 1px solid var(--gray-200);
}
table.district-table td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
table.district-table tr:last-child td { border-bottom: none; }
table.district-table tr:hover td { background: var(--blue-light); }
table.district-table td.num { color: var(--gray-600); white-space: nowrap; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-high { background: #dff3e8; color: var(--green); }
.badge-medium { background: #fbf0da; color: var(--amber); }
.badge-low { background: #fbe4e4; color: var(--red); }
.badge-unknown { background: var(--gray-100); color: var(--gray-600); }

.empty-note {
  padding: 30px;
  text-align: center;
  color: var(--gray-600);
}

/* ---------- District page ---------- */
.detail-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}
.detail-card h1 { margin: 0 0 4px; font-size: 1.5rem; color: var(--navy); }
.detail-card .subline { color: var(--gray-600); font-size: 0.9rem; margin-bottom: 18px; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}
.detail-field .label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--gray-600);
  margin-bottom: 3px;
}
.detail-field .value { font-size: 1rem; color: var(--gray-800); }
.detail-field .value.muted { color: var(--gray-400); }

.notice-box {
  background: var(--blue-light);
  border: 1px solid #cddcee;
  border-radius: 6px;
  padding: 12px 16px;
  font-size: 0.88rem;
  color: var(--navy-dark);
  margin-bottom: 16px;
}

.source-link {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.9rem;
}

.search-results-inline {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.search-result-card {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 10px 14px;
}
.search-result-card a {
  font-size: 0.95rem;
  font-weight: 600;
}
.search-result-url {
  font-size: 0.78rem;
  color: var(--green);
  margin-top: 2px;
  word-break: break-all;
}
.search-result-snippet {
  font-size: 0.85rem;
  color: var(--gray-600);
  margin-top: 4px;
  line-height: 1.4;
}

.schools-section {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
}
.schools-section h2 { margin: 0 0 12px; font-size: 1.05rem; color: var(--navy); }
.schools-list { list-style: none; margin: 0; padding: 0; columns: 2; column-gap: 24px; }
.schools-list li {
  padding: 6px 0;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--gray-100);
  break-inside: avoid;
}
@media (max-width: 640px) {
  .schools-list { columns: 1; }
}

footer.site-footer {
  text-align: center;
  padding: 24px 20px 40px;
  color: var(--gray-400);
  font-size: 0.8rem;
}
