/* ── Reset main-content + hide footer/bottom-nav on map page ──────── */
.main-content {
  padding: 0 !important;
  min-height: 0 !important;
  overflow: hidden !important;
}
footer,
.mobile-bottom-nav {
  display: none !important;
}

/* ── Wrapper ──────────────────────────────────────────────────────── */
.map-wrap {
  display: flex;
  flex-direction: column;
  /* height set by JS — guarantees Leaflet gets a real pixel value */
}

/* ── Top bar ──────────────────────────────────────────────────────── */
.map-topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
  z-index: 10;
}
.map-topbar-title { font-weight:900; font-size:.95rem; color:var(--text); display:flex; align-items:center; gap:7px; }
.map-stat-pill {
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: 100px; padding: 3px 12px;
  font-size: .73rem; font-weight: 700; color: var(--text-muted);
  white-space: nowrap;
}
.map-stat-pill strong { color: var(--text); }
.map-back {
  margin-left: auto;
  background: var(--primary); color: #fff;
  border: none; border-radius: 9px; padding: 7px 16px;
  font-size: .8rem; font-weight: 700; cursor: pointer;
  text-decoration: none; font-family: inherit;
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
}
.map-back:hover { opacity: .9; color: #fff; }

/* ── Body row: map + panel ────────────────────────────────────────── */
.map-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  /* height set by JS */
}

/* ── Leaflet container ────────────────────────────────────────────── */
#map {
  flex: 1;
  /* explicit height/width set by JS */
}

/* ── Side panel ───────────────────────────────────────────────────── */
.map-panel {
  width: 290px;
  flex-shrink: 0;
  background: var(--card);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width .22s ease;
}
.map-panel.hidden { width: 0; }

.panel-hd { padding: 8px 12px 6px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.panel-hd h2 { font-size: .82rem; font-weight: 800; margin: 0 0 5px; }
.panel-search {
  width: 100%; background: var(--bg); border: 1.5px solid var(--border);
  border-radius: 8px; padding: 6px 11px; font-size: .81rem;
  color: var(--text); font-family: inherit; outline: none;
}
.panel-search:focus { border-color: var(--primary); }

.panel-rows { flex: 1; overflow-y: auto; padding: 6px 0; }
.panel-rows::-webkit-scrollbar { width: 3px; }
.panel-rows::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.wr {
  display: flex; align-items: center; gap: 7px;
  padding: 3px 12px; cursor: pointer;
  transition: background .1s; text-decoration: none; color: inherit;
  min-height: 0;
}
.wr:hover { background: var(--bg); }
.wr.active { background: rgba(37,99,235,.07); }
.wr-rank { font-size: .6rem; font-weight: 800; color: var(--text-muted); width: 14px; text-align: right; flex-shrink: 0; }
.wr-dot  { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.wr-name { font-size: .77rem; font-weight: 700; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wr-n    { font-size: .73rem; font-weight: 800; color: var(--primary); flex-shrink: 0; }

.panel-legend {
  padding: 7px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.panel-legend h3 { font-size: .63rem; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin: 0 0 4px; }
.leg-bar { height: 7px; border-radius: 4px; background: linear-gradient(90deg,#bfdbfe,#3b82f6,#1d4ed8,#1e3a8a); margin-bottom: 3px; }
.leg-labels { display: flex; justify-content: space-between; font-size: .63rem; color: var(--text-muted); }
.leg-hint { font-size: .67rem; color: var(--text-muted); margin-top: 6px; line-height: 1.4; }

/* ── Mobile ───────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .map-stat-pill { display: none; }
  .map-panel {
    position: fixed; bottom: 0; left: 0; right: 0;
    width: 100% !important; height: 45vh;
    border-left: none; border-top: 1px solid var(--border);
    z-index: 400; border-radius: 16px 16px 0 0;
    transition: transform .25s ease;
    transform: translateY(0);
  }
  .map-panel.hidden { transform: translateY(100%); }
  #panel-toggle {
    display: flex !important;
    position: fixed; bottom: 80px; right: 14px; z-index: 500;
    background: var(--primary); color: #fff;
    border: none; border-radius: 50%;
    width: 44px; height: 44px; font-size: 1rem; cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,.2);
    align-items: center; justify-content: center;
  }
}

/* ── Leaflet popup ────────────────────────────────────────────────── */
.leaflet-popup-content-wrapper {
  border-radius: 14px !important;
  box-shadow: 0 8px 32px rgba(0,0,0,.2) !important;
  padding: 0 !important;
  overflow: hidden;
  border: none !important;
}
.leaflet-popup-content { margin: 0 !important; min-width: 210px; }

.mp { font-family: 'DM Sans', sans-serif; }
.mp-hd { background: linear-gradient(135deg,#0f2744,#1e3a5f); padding: 11px 15px; color: #fff; }
.mp-hd .mp-code { font-size: .62rem; font-weight: 800; opacity: .6; letter-spacing: .5px; }
.mp-hd .mp-name { font-size: .95rem; font-weight: 900; margin-top: 2px; }
.mp-bd { padding: 12px 15px; }
.mp-row { display: flex; justify-content: space-between; margin-bottom: 5px; font-size: .78rem; }
.mp-lbl { color: #64748b; }
.mp-val { font-weight: 800; color: #0f172a; }
.mp-total { font-size: 1.15rem; font-weight: 900; color: #2563eb; }
.mp-bar-bg { background: #f1f5f9; border-radius: 4px; height: 5px; margin-bottom: 10px; overflow: hidden; }
.mp-bar-fg { height: 100%; border-radius: 4px; background: linear-gradient(90deg,#3b82f6,#1d4ed8); }
.mp-cta {
  display: block; text-align: center;
  background: linear-gradient(135deg,#2563eb,#1d4ed8);
  color: #fff !important; text-decoration: none;
  border-radius: 8px; padding: 8px; font-size: .79rem; font-weight: 800;
}
.mp-cta:hover { opacity: .88; }