/* ── TOKENS ───────────────────────────────────── */
:root {
  --ink:          #0f172a;
  --ink-2:        #334155;
  --ink-3:        #64748b;
  --ink-4:        #94a3b8;
  --surface:      #ffffff;
  --surface-2:    #f8fafc;
  --border:       #e2e8f0;
  --border-2:     #cbd5e1;
  --accent:       #00C2B3;
  --accent-soft:  rgba(0,194,179,0.10);
  --accent-mid:   rgba(0,194,179,0.35);
  --green:        #10b981;
  --green-soft:   #d1fae5;
  --red:          #ef4444;
  --red-soft:     #fee2e2;
  --amber:        #f59e0b;
  --amber-soft:   #fef3c7;
  --radius-sm:    8px;
  --radius-md:    12px;
  --radius-lg:    18px;
  --shadow-sm:    0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.06);
  --shadow-md:    0 4px 16px rgba(15,23,42,.10), 0 1px 4px rgba(15,23,42,.06);
  --shadow-lg:    0 12px 40px rgba(15,23,42,.14), 0 2px 8px rgba(15,23,42,.06);
  --blur:         blur(16px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: "DM Sans", sans-serif;
  color: var(--ink);
  background: var(--ink);
}

/* ── TOP BAR ──────────────────────────────────── */
.top-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: #0D1B2A;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

.bar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.bar-mark {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: #00C2B3;
  display: flex; align-items: center; justify-content: center;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: .75rem;
  color: #fff;
  letter-spacing: .02em;
}

.bar-title {
  font-weight: 700;
  font-size: .9rem;
  color: #fff;
  letter-spacing: -.01em;
}

.bar-city {
  font-size: .8rem;
  color: rgba(255,255,255,.45);
  margin-top: 1px;
}

.bar-back {
  color: rgba(255,255,255,.6);
  text-decoration: none;
  font-size: .82rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,.12);
  transition: all .18s;
}
.bar-back:hover {
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.9);
}

/* ── MAP WRAPPER ──────────────────────────────── */
.map-root {
  position: fixed;
  inset: 0;
  top: 56px;
}

#leaflet-map {
  width: 100%;
  height: 100%;
}

/* ── FLOATING CONTROLS (top-left) ─────────────── */
.float-controls {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Mode switch */
.mode-pill {
  background: rgba(255,255,255,.97);
  border: 1px solid var(--border);
  border-radius: 40px;
  padding: 5px;
  display: flex;
  gap: 3px;
  box-shadow: var(--shadow-md);
}

.mode-btn {
  border: none;
  background: transparent;
  color: var(--ink-3);
  padding: 7px 18px;
  border-radius: 40px;
  font: inherit;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .18s;
  white-space: nowrap;
}

.mode-btn.active {
  background: #00C2B3;
  color: #fff;
  box-shadow: 0 1px 6px rgba(0,194,179,.35);
}

/* Legend pill */
.legend-pill {
  background: rgba(255,255,255,.97);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  box-shadow: var(--shadow-md);
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .76rem;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
}

.leg-dot {
  width: 10px; height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}
.leg-dot.covered   { background: var(--green); }
.leg-dot.uncovered { background: var(--red); }
.leg-dot.lead-only { background: var(--amber); }

/* ── ADDRESS SEARCH (top-center) ──────────────── */
.float-search {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1001;
  width: min(540px, calc(100vw - 300px));
}

.search-wrap {
  background: rgba(255,255,255,.97);
  border: 1px solid var(--border);
  border-radius: 40px;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  overflow: hidden;
  transition: box-shadow .2s, border-color .2s;
}

.search-wrap:focus-within {
  border-color: rgba(0,194,179,.45);
  box-shadow: 0 0 0 3px rgba(0,194,179,.12), var(--shadow-md);
}

.search-icon-wrap {
  padding: 0 14px;
  color: var(--ink-4);
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  font-family: "DM Sans", sans-serif;
  font-size: .88rem;
  color: var(--ink);
  padding: 12px 0;
  background: transparent;
  min-width: 0;
}
.search-input::placeholder { color: var(--ink-4); }

.search-btn {
  border: none;
  background: #00C2B3;
  color: #fff;
  font-family: "DM Sans", sans-serif;
  font-weight: 700;
  font-size: .8rem;
  padding: 10px 20px;
  margin: 4px;
  border-radius: 40px;
  cursor: pointer;
  transition: background .18s;
  flex-shrink: 0;
}
.search-btn:hover { background: #009E92; }

/* Search result dropdown */
.search-result {
  margin-top: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  box-shadow: var(--shadow-lg);
  display: none;
}

.search-result.visible { display: flex; align-items: flex-start; gap: 12px; }

.sr-icon {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: .82rem; font-weight: 800;
  font-family: "DM Sans", sans-serif;
}
.sr-covered   .sr-icon { background: #10b981; color: #fff; }
.sr-uncovered .sr-icon { background: #ef4444; color: #fff; }
.sr-lead-only .sr-icon { background: #f59e0b; color: #fff; }
.sr-unknown   .sr-icon { background: #94a3b8; color: #fff; }
.sr-loading   .sr-icon { background: #94a3b8; color: #fff; }

.sr-title { font-weight: 700; font-size: .92rem; color: var(--ink); margin-bottom: 3px; }
.sr-sub   { font-size: .8rem; color: var(--ink-3); }

.sr-covered   { background: #d1fae5; border: 1.5px solid #6ee7b7; }
.sr-uncovered { background: #fee2e2; border: 1.5px solid #fca5a5; }
.sr-lead-only { background: #fef3c7; border: 1.5px solid #fcd34d; }
.sr-unknown   { background: var(--surface-2); border: 1px solid var(--border); }
.sr-loading   { background: var(--surface-2); border: 1px solid var(--border); }

/* Examples */
.search-examples {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
  padding: 0 6px;
  justify-content: center;
}

.ex-chip {
  background: rgba(255,255,255,.9);
  border: 1px solid var(--border);
  color: var(--ink-2);
  font-size: .74rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 40px;
  cursor: pointer;
  transition: all .15s;
  font-family: "DM Sans", sans-serif;
  box-shadow: var(--shadow-sm);
}
.ex-chip:hover { background: var(--accent-soft); border-color: var(--accent-mid); color: var(--accent); }

/* ── DISTRICT PANEL (right side) ──────────────── */
.district-panel {
  position: absolute;
  top: 16px;
  right: 16px;
  bottom: 16px;
  width: 300px;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  gap: 0;
  pointer-events: none;
  opacity: 0;
  transform: translateX(20px);
  transition: opacity .25s, transform .25s;
}

.district-panel.visible {
  pointer-events: all;
  opacity: 1;
  transform: translateX(0);
}

.dp-card {
  background: rgba(255,255,255,.97);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  max-height: 100%;
}

.dp-close {
  position: absolute;
  top: 10px; right: 10px;
  width: 28px; height: 28px;
  border: none;
  background: var(--surface-2);
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-3);
  font-size: .9rem;
  transition: background .15s;
}
.dp-close:hover { background: var(--border); }

.dp-header { position: relative; }

.dp-kicker {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}

.dp-name {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
  padding-right: 30px;
}

.dp-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 40px;
  font-size: .76rem;
  font-weight: 700;
}

.dp-badge.covered   { background: var(--green-soft); color: #065f46; }
.dp-badge.uncovered { background: var(--red-soft);   color: #991b1b; }
.dp-badge.neutral   { background: var(--surface-2);  color: var(--ink-3); border: 1px solid var(--border); }
.dp-badge.lead-only { background: var(--amber-soft); color: #92400e; }

.dp-badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.dp-desc {
  font-size: .84rem;
  color: var(--ink-3);
  line-height: 1.6;
}

.dp-section {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
}

.dp-section-label {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-4);
  margin-bottom: 8px;
}

.dp-section-value {
  font-size: .88rem;
  font-weight: 600;
  color: var(--ink-2);
}

.dp-uncovered-list {
  padding-left: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dp-uncovered-list li {
  font-size: .84rem;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 8px;
}

.dp-uncovered-list li::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 2px;
  background: var(--red);
  flex-shrink: 0;
}

/* ── DISTRICT COUNT PILL (bottom-left) ────────── */
.count-pill {
  position: absolute;
  bottom: 20px;
  left: 16px;
  z-index: 1001;
  background: rgba(255,255,255,.97);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  box-shadow: var(--shadow-md);
  font-size: .76rem;
  color: var(--ink-3);
  font-weight: 600;
  display: flex;
  gap: 14px;
}

.count-item span { color: var(--ink); font-weight: 700; }

/* ── TOOLTIP ──────────────────────────────────── */
.district-tooltip {
  background: rgba(15,23,42,.92) !important;
  border: none !important;
  border-radius: 6px !important;
  color: #fff !important;
  font-size: .76rem !important;
  font-weight: 700 !important;
  font-family: "DM Sans", sans-serif !important;
  padding: 5px 11px !important;
  box-shadow: 0 2px 10px rgba(0,0,0,.2) !important;
  white-space: nowrap !important;
  backdrop-filter: blur(8px) !important;
}
.district-tooltip::before { display: none !important; }

/* ── LEAFLET OVERRIDES ────────────────────────── */
.leaflet-control-zoom {
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-md) !important;
  overflow: hidden;
  box-shadow: var(--shadow-md) !important;
}
.leaflet-control-zoom a {
  background: rgba(255,255,255,.97) !important;
  color: var(--ink) !important;
  font-size: .9rem !important;
  line-height: 28px !important;
  width: 28px !important;
  height: 28px !important;
  border-color: var(--border) !important;
}
.leaflet-control-zoom a:hover { background: var(--surface-2) !important; }

.leaflet-bottom.leaflet-right { display: none; }

/* ── RESPONSIVE ───────────────────────────────── */
@media (max-width: 900px) {
  .float-search {
    width: calc(100vw - 200px);
    left: 50%;
    transform: translateX(-50%);
  }
  .district-panel {
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    flex-direction: row;
    transform: translateY(20px);
  }
  .district-panel.visible { transform: translateY(0); }
  .dp-card {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 50vh;
    width: 100%;
  }
  .count-pill { display: none; }
}

@media (max-width: 640px) {
  .top-bar { padding: 0 14px; }
  .bar-city { display: none; }
  .float-search {
    width: calc(100vw - 32px);
    left: 16px;
    transform: none;
    top: 72px;
  }
  .float-controls { top: 130px; }
}
