:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --ink: #16243a;
  --muted: #5d6b82;
  --line: #d7dee8;
  --primary: #1d4f91;
  --primary-strong: #123a6e;
  --warning: #9f5a00;
  --danger: #ab2a2a;
  --radius: 14px;
  --shadow: 0 8px 24px rgb(22 36 58 / 8%);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.45;
}

a {
  color: var(--primary);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--primary-strong);
  outline-offset: 2px;
}

.top-band {
  background: #fff;
}

.brand-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 700;
  font-size: 0.92rem;
  text-decoration: none;
  color: var(--primary-strong);
}

.brand-chip:hover,
.brand-chip:focus {
  color: var(--primary-strong);
  text-decoration: underline;
}

.hero {
  padding-top: 1rem;
}

.kicker {
  margin: 0;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--primary);
}

h1 {
  margin: 0;
  color: var(--ink);
}

.lede {
  max-width: 76ch;
  margin: 0;
  color: var(--muted);
}

.hero-meta {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.stat-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-value {
  margin: 0;
  color: var(--ink);
  font-weight: 700;
  font-size: 1rem;
}

.top-offset {
  top: 1rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.controls .card-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.form-label {
  margin: 0;
  font-weight: 600;
  color: var(--ink);
}

.form-control,
.form-select,
.btn {
  min-height: 44px;
}

.form-control,
.form-select {
  border-color: #c7d2e2;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 0.2rem rgb(29 79 145 / 16%);
}

.btn-primary {
  --bs-btn-bg: var(--primary);
  --bs-btn-border-color: var(--primary);
  --bs-btn-hover-bg: var(--primary-strong);
  --bs-btn-hover-border-color: var(--primary-strong);
  --bs-btn-active-bg: #0f2f58;
  --bs-btn-active-border-color: #0f2f58;
  --bs-btn-focus-shadow-rgb: 29, 79, 145;
  font-weight: 600;
}

.btn-outline-primary {
  --bs-btn-color: var(--primary);
  --bs-btn-border-color: var(--primary);
  --bs-btn-hover-bg: var(--primary);
  --bs-btn-hover-border-color: var(--primary);
  --bs-btn-active-bg: var(--primary-strong);
  --bs-btn-active-border-color: var(--primary-strong);
  --bs-btn-focus-shadow-rgb: 29, 79, 145;
}

.muted {
  color: var(--muted);
  font-size: 0.92rem;
}

.county-list,
.result-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.75rem;
}

.state-county-list {
  max-height: min(70vh, 740px);
  overflow: auto;
  padding-right: 0.1rem;
  -webkit-overflow-scrolling: touch;
}

.state-page .state-county-list {
  max-height: min(46vh, 430px);
}

.county-card,
.county-item,
.result-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.county-card {
  box-shadow: 0 2px 10px rgb(22 36 58 / 5%);
}

.county-home-button {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  width: 100%;
  height: 100%;
  padding: 0.68rem 0.78rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
  background: #fff;
  transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.county-home-button:hover,
.county-home-button:focus {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
  text-decoration: none;
}

.county-home-name {
  font-size: 0.94rem;
  font-weight: 700;
  line-height: 1.25;
}

.county-home-count {
  font-size: 0.82rem;
  color: var(--muted);
}

.county-home-button:hover .county-home-count,
.county-home-button:focus .county-home-count {
  color: #eef4ff;
}

.county-item,
.result-item {
  padding: 0.8rem;
}

.county-item a {
  color: inherit;
  text-decoration: none;
}

.county-item:hover,
.county-item:focus-within,
.county-card:hover,
.county-card:focus-within {
  border-color: #bccadd;
  box-shadow: 0 8px 20px rgb(22 36 58 / 10%);
}

.county-item h3,
.result-item h3 {
  margin: 0;
  font-size: 1rem;
}

.county-item p,
.result-item p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.map-panel .card-body,
.offenders-panel .card-body {
  min-height: 0;
}

.map {
  width: 100%;
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #eef2f7;
}

.map-empty-state {
  color: var(--muted);
  font-size: 0.92rem;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.site-footer {
  background: #fff;
}

.site-footer .container {
  text-align: center;
  letter-spacing: 0.01em;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  margin-right: 0.35rem;
}

.dot.offender {
  background: var(--danger);
}

.dot.school {
  background: var(--primary);
}

.table-wrap {
  width: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.offender-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
  background: #fff;
}

.offender-table th,
.offender-table td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  padding: 0.55rem 0.5rem;
  font-size: 0.9rem;
}

.offender-table th {
  position: sticky;
  top: 0;
  background: #eff3f8;
  color: #233852;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  z-index: 1;
}

.offender-table tbody tr:nth-child(even) {
  background: #fbfcfe;
}

.offender-photo-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--ink);
}

.offender-photo {
  width: 56px;
  height: 70px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #f4f6f9;
}

.offender-photo-fallback {
  display: none;
  font-size: 0.8rem;
}

.popup-photo {
  width: 92px;
  height: 116px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #f4f6f9;
}

.map-label {
  background: rgb(255 255 255 / 94%);
  border: 1px solid rgb(22 36 58 / 14%);
  border-radius: 999px;
  box-shadow: 0 3px 10px rgb(22 36 58 / 9%);
  color: #233852;
  font-size: 0.72rem;
  line-height: 1.1;
  padding: 0.22rem 0.45rem;
  white-space: nowrap;
}

.map-label::before {
  display: none;
}

.map-label-school {
  color: var(--primary);
  font-weight: 700;
}

.map-label-offender {
  color: var(--danger);
}

.name-last {
  display: inline;
}

.name-first {
  display: block;
  margin-top: 0.02rem;
}

.back-link {
  color: var(--primary-strong);
  text-decoration: none;
}

.back-link:hover,
.back-link:focus {
  text-decoration: underline;
}

.school-layout > [class*='col-'] {
  display: flex;
}

.school-page .offenders-panel,
.school-page .map-panel {
  width: 100%;
}

.school-page .offenders-panel .card-body,
.school-page .map-panel .card-body {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.school-page .school-results-scroll {
  flex: 0 0 auto;
  min-height: auto;
  max-height: none;
  overflow: visible;
}

.school-page .offender-table {
  min-width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
}

.school-page .offender-table th {
  top: 0;
  z-index: 2;
  background: linear-gradient(180deg, #f5f8fc 0%, #edf2f8 100%);
  color: #1f3d5d;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  padding: 0.62rem 0.65rem;
  border-bottom: 1px solid #d1d9e4;
}

.school-page .offender-table td {
  padding: 0.7rem 0.65rem;
  vertical-align: top;
}

.school-page .offender-table tbody tr {
  transition: background-color 0.16s ease;
}

.school-page .offender-table tbody tr:hover {
  background: #f8fbff;
}

.school-page .offender-table th:nth-child(1),
.school-page .offender-table td:nth-child(1) {
  width: 104px;
}

.school-page .offender-table th:nth-child(2),
.school-page .offender-table td:nth-child(2) {
  width: 25%;
}

.school-page .offender-table th:nth-child(3),
.school-page .offender-table td:nth-child(3) {
  width: 39%;
}

.school-page .offender-table th:nth-child(4),
.school-page .offender-table td:nth-child(4) {
  width: 120px;
}

.school-page .offender-table th:nth-child(5),
.school-page .offender-table td:nth-child(5) {
  width: 94px;
}

.school-page .offender-name-cell {
  font-weight: 600;
  line-height: 1.25;
}

.school-page .offense-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.school-page .distance-cell {
  white-space: nowrap;
}

.school-page .distance-pill {
  display: inline-block;
  min-width: 3.4ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
  color: #1d3048;
}

.school-page .details-cell {
  white-space: nowrap;
}

.school-page .details-link {
  font-weight: 600;
}

.school-page #schoolMap {
  flex: 0 0 auto;
  min-height: 460px;
}

@media (min-width: 992px) {
  .split-layout > .col-lg-4,
  .split-layout > .col-lg-5,
  .split-layout > .col-lg-7,
  .split-layout > .col-lg-8 {
    display: flex;
  }

  .split-layout > .col-lg-4 > .panel,
  .split-layout > .col-lg-5 > .panel,
  .split-layout > .col-lg-7 > .panel,
  .split-layout > .col-lg-8 > .panel {
    width: 100%;
  }

  .county-layout {
    align-items: stretch;
  }
}

@media (max-width: 991.98px) {
  .sticky-panel-mobile {
    position: sticky;
    top: 0;
    z-index: 1020;
  }

  .state-county-list {
    max-height: none;
    overflow: visible;
  }

  .map {
    min-height: 360px;
  }

  .school-page #schoolMap {
    min-height: 360px;
  }

  .school-page .school-results-scroll {
    max-height: none;
  }
}

@media (max-width: 768px) {
  .hero {
    padding-top: 0.75rem;
  }

  h1 {
    font-size: clamp(1.5rem, 6.2vw, 2.2rem);
  }

  .lede {
    font-size: 0.97rem;
  }

  .panel {
    border-radius: 12px;
  }

  .legend {
    font-size: 0.82rem;
  }

  .offender-table {
    min-width: 600px;
  }

  .school-page .offender-table {
    min-width: 500px;
  }

  .school-page .offender-table th:nth-child(1),
  .school-page .offender-table td:nth-child(1) {
    width: 78px;
  }

  .school-page .offender-table th:nth-child(2),
  .school-page .offender-table td:nth-child(2) {
    width: 32%;
  }

  .school-page .offender-table th:nth-child(3),
  .school-page .offender-table td:nth-child(3) {
    width: 34%;
  }

  .school-page .offender-table th:nth-child(4),
  .school-page .offender-table td:nth-child(4) {
    width: 90px;
  }

  .school-page .offender-table th:nth-child(5),
  .school-page .offender-table td:nth-child(5) {
    width: 72px;
  }

  .offender-table th,
  .offender-table td {
    padding: 0.48rem 0.4rem;
    font-size: 0.82rem;
  }

  .offender-photo {
    width: 38px;
    height: 48px;
  }

  .popup-photo {
    width: 76px;
    height: 96px;
  }

  .map-label {
    font-size: 0.64rem;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (max-width: 640px) {
  .hero-meta {
    font-size: 0.82rem;
  }

  .map {
    min-height: 300px;
  }

  .school-page #schoolMap {
    min-height: 320px;
  }

  .offender-table {
    min-width: 520px;
  }

  .school-page .offender-table {
    min-width: 460px;
  }
}
