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

:root {
  --accent: #01f3b3;
  --text:   #1c1917;
  --muted:  #78716c;
  --bg:     #ffffff;
  --shadow: 0 4px 24px rgba(0,0,0,0.10);
  --shadow-lg: 0 12px 48px rgba(0,0,0,0.14);
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, 'Helvetica Neue', Arial, sans-serif;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  scrollbar-width: none;
}
html::-webkit-scrollbar,
body::-webkit-scrollbar { display: none; }

/* ── Mapa ── */
#map {
  position: fixed;
  inset: 0;
  z-index: 1;
}

/* ── Header ── */
#header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 24px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(0,0,0,0.08);
}

.header-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text);
}

.header-legend {
  display: flex;
  align-items: center;
  gap: 8px;
}
.leg-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}
.leg-bar {
  display: flex;
  gap: 2px;
}
.leg-step {
  display: inline-block;
  width: 22px;
  height: 12px;
  border-radius: 2px;
  border: 1px solid rgba(0,0,0,0.08);
}
.leg-nd {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  margin-left: 10px;
  padding-left: 10px;
  border-left: 1px solid rgba(0,0,0,0.1);
}

/* ── Controles de filtro ── */
#controls {
  position: fixed;
  top: 72px;
  left: 16px;
  z-index: 10;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ctrl-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.ctrl-pills {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.pill {
  background: var(--bg);
  color: var(--text);
  border: 1px solid #000;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
}
.pill:hover { background: #f0f0f0; }
.pill.active {
  background: var(--accent);
  color: #000;
  border-color: #000;
}

/* ── Tooltip ── */
.map-tooltip {
  position: fixed;
  z-index: 300;
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font);
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,0.1);
  pointer-events: none;
  white-space: nowrap;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.1s;
}
.map-tooltip.visible { opacity: 1; }

/* ── Popup ── */
.maplibregl-popup {
  font: 13px/1.4 var(--font);
}
.maplibregl-popup-content {
  padding: 0;
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg);
  border: 1px solid rgba(0,0,0,0.1);
  box-shadow: var(--shadow-lg);
  min-width: 220px;
}
.maplibregl-popup-close-button {
  color: var(--muted);
  font-size: 16px;
  padding: 6px 10px;
}
.maplibregl-popup-close-button:hover { color: #000; background: transparent; }

.pp-top-bar { height: 4px; }
.pp-inner {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.pp-nombre {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}
.pp-provincia {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0;
}
.pp-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(0,0,0,0.07);
}
.pp-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pp-stat-val {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1;
}
.pp-stat-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* ── Responsive ── */
@media (max-width: 640px) {
  #header { padding: 10px 16px; }
  .header-title { font-size: 11px; }
  #controls { top: auto; bottom: 80px; left: 16px; }
  .ctrl-pills { flex-direction: row; flex-wrap: wrap; }
}
