:root {
  --navy: #0b1626;
  --navy-2: #12233a;
  --ink: #10233a;
  --muted: #4a5b6e;
  --line: #d5dde6;
  --paper: #ffffff;
  --map-bg: #f4f6f9;
  --accent: #6baed6;
  --focus: #1757ac;
  --font: "Noto Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--paper); line-height: 1.5; }
a { color: var(--focus); }
button, input { font: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---- one-screen app: header + controls + map always fit the viewport, so a
   selection never needs a scroll to see its result */
.app { height: 100vh; height: 100dvh; min-height: 520px; display: flex; flex-direction: column; }

/* ---- masthead */
.masthead { background: var(--navy); color: #fff; flex: none; }
.masthead-inner { max-width: 1240px; margin: 0 auto; padding: 14px 16px 12px; }
.eyebrow { margin: 0 0 4px; color: var(--accent); font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(22px, 3.2vw, 32px); line-height: 1.1; letter-spacing: -.01em; }

/* ---- toolbar */
.explore { flex: 1; min-height: 0; width: 100%; max-width: 1240px; margin: 0 auto; padding: 12px 16px 16px; display: flex; flex-direction: column; }
.toolbar { flex: none; display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.toolbar-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button {
  border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 999px;
  padding: 5px 12px; font-size: 14px; cursor: pointer; min-height: 32px;
}
.seg button:hover { border-color: #9aa8b8; }
.seg button[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.seg-subs button { font-size: 13px; padding: 3px 10px; min-height: 28px; }
.seg-subs button[aria-pressed="true"] { background: #e7eef7; color: var(--ink); border-color: #9fb3c8; font-weight: 600; }
.find { display: flex; gap: 6px; }
.combo { position: relative; flex: 1; min-width: 0; max-width: 260px; }
.combo input { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; min-height: 32px; }
/* custom list instead of the native datalist, so its height and width can be controlled */
.combo-list {
  position: absolute; top: calc(100% + 4px); right: 0; z-index: 1100; width: max(100%, 300px);
  max-height: 264px; overflow-y: auto; margin: 0; padding: 4px; list-style: none;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 6px 20px rgba(16,35,58,.16);
}
.combo-list li { padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.combo-list li[aria-selected="true"], .combo-list li:hover { background: #e7eef7; }
.combo-list .combo-empty { color: var(--muted); cursor: default; background: none; }
.find button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 5px 12px; cursor: pointer; white-space: nowrap; }
/* on/off switch: a small track + knob before the text */
.find .toggle { display: inline-flex; align-items: center; gap: 7px; }
.find .toggle::before {
  content: ""; width: 26px; height: 16px; border-radius: 8px; flex: none;
  background: radial-gradient(circle at 8px 50%, #fff 5px, transparent 5.5px), #b3bfcc;
}
.find .toggle[aria-pressed="true"]::before { background: radial-gradient(circle at 18px 50%, #fff 5px, transparent 5.5px), var(--navy); }

.narrow-only { display: none; }

/* ---- county name labels on the map */
.county-label { pointer-events: none; }
.county-label span {
  position: absolute; transform: translate(-50%, -50%); white-space: nowrap;
  font-size: 11.5px; font-weight: 600; color: #0b1626; letter-spacing: .01em;
  text-shadow: 0 0 2px #fff, 0 0 2px #fff, 0 0 3px #fff, 0 0 4px rgba(255,255,255,.9);
}
.county-label.is-hidden { display: none; }
.county-label.is-selected span { font-size: 13px; font-weight: 700; }

/* ---- map stage */
.stage { position: relative; flex: 1; min-height: 0; }
#map { height: 100%; min-height: 280px; border-radius: 12px; background: var(--map-bg); border: 1px solid var(--line); }
.leaflet-container { font-family: var(--font); background: var(--map-bg); }
.legend {
  position: absolute; left: 12px; bottom: 12px; z-index: 500; max-width: min(360px, calc(100% - 24px));
  background: rgba(255,255,255,.94); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font-size: 12.5px; box-shadow: 0 1px 4px rgba(16,35,58,.08);
}
.lg-title { font-weight: 600; margin-bottom: 6px; }
.lg-items { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.lg-items.compact { gap: 3px 8px; }
.lg-item { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.lg-item i, .dot { display: inline-block; width: 14px; height: 12px; border-radius: 3px; }
.lg-item i { box-shadow: inset 0 0 0 1px rgba(16,35,58,.12); }
.lg-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 2px; }
.lg-rowname { width: 64px; font-weight: 600; }
.lg-note { margin-top: 6px; color: var(--muted); font-size: 12px; }

.county-tip { font-family: var(--font); font-size: 13px; line-height: 1.35; padding: 6px 9px; border-radius: 8px; border: 1px solid var(--line); box-shadow: 0 2px 6px rgba(16,35,58,.12); }
.tip-name { font-weight: 700; }

/* ---- county panel */
.panel {
  position: absolute; top: 12px; right: 12px; z-index: 600; width: min(380px, calc(100% - 24px));
  max-height: calc(100% - 24px); overflow: auto; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; padding: 14px 16px; box-shadow: 0 4px 16px rgba(16,35,58,.14);
}
.panel h2 { margin: 0 28px 2px 0; font-size: 22px; }
.panel h3 { margin: 14px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.panel-sub { margin: 0; color: var(--muted); font-size: 13px; }
.panel-close { position: absolute; top: 8px; right: 10px; border: 0; background: none; font-size: 24px; line-height: 1; cursor: pointer; color: var(--muted); width: 32px; height: 32px; }
.bars { display: grid; gap: 5px; }
.bar { display: grid; grid-template-columns: 82px 1fr 52px; align-items: center; gap: 8px; font-size: 13px; }
.bar-track { height: 12px; background: #eef1f5; border-radius: 4px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 0 4px 4px 0; }
.bar-val { text-align: right; font-variant-numeric: tabular-nums; }
.panel-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.panel-table th, .panel-table td { padding: 4px 3px; text-align: left; border-bottom: 1px solid #eef1f5; white-space: nowrap; }
.panel-table thead th { color: var(--muted); font-weight: 600; font-size: 12px; }
.panel-note { margin: 6px 0 0; font-size: 11.5px; color: var(--muted); }
.panel-table .dot { width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: 0; }

/* ---- table view */
.below { max-width: 1240px; margin: 0 auto; padding: 4px 16px 0; }
.table-view { font-size: 14px; }
.table-view summary { cursor: pointer; color: var(--focus); }
#data-table { border-collapse: collapse; margin-top: 8px; font-variant-numeric: tabular-nums; }
#data-table caption { text-align: left; font-weight: 600; padding-bottom: 6px; }
#data-table th, #data-table td { text-align: left; padding: 3px 12px 3px 0; border-bottom: 1px solid #eef1f5; }

/* ---- footer */
.foot { max-width: 1240px; margin: 24px auto 0; padding: 18px 16px 32px; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: 24px; font-size: 13px; color: var(--muted); }
.foot p { margin: 0 0 6px; }
.author { display: flex; flex-direction: column; text-align: right; }
.author b { color: var(--ink); font-size: 15px; }
.author .made { margin-top: 6px; font-size: 12px; }

@media (max-width: 720px) {
  .masthead-inner { padding: 10px 16px 8px; }
  .eyebrow { font-size: 11px; margin-bottom: 2px; }
  .explore { padding: 8px 16px 12px; }
  .toolbar { gap: 6px; margin-bottom: 8px; }
  /* one swipeable row each instead of wrapping onto several lines */
  .seg { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
  .seg::-webkit-scrollbar { display: none; }
  .seg button { flex: none; }
  .toolbar-row { flex-direction: column; align-items: stretch; gap: 6px; }
  .combo { max-width: none; }
  .wide-only { display: none; }
  .narrow-only { display: inline; }
  .combo-list { left: 0; width: 100%; max-height: 40vh; }
  .panel { position: fixed; top: auto; bottom: 0; left: 0; right: 0; width: auto; max-height: 55vh; border-radius: 14px 14px 0 0; }
  .legend { font-size: 11.5px; padding: 8px 10px; }
  .foot { grid-template-columns: 1fr; }
  .author { text-align: left; }
}
