:root{
  --bg:#ffffff;
  --text:#111827;
  --muted:#6b7280;
  --shadow:0 2px 6px rgba(0,0,0,0.08);
  --slider:#494949;
}

*{ box-sizing:border-box; }
html,body,#app{
  height:100%;
  margin:0;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Helvetica Neue,Arial,Noto Sans;
  color:var(--text);
  display:flex;
  flex-direction:column;
}

/* Header */
#ui{
  flex:0 0 auto;
  background:var(--bg);
  box-shadow:var(--shadow);
  display:flex;
  flex-direction:column;
  align-items:stretch;
}
#map{ flex:1; min-height:0; }

/* 3 columnas */
.ui-inner{
  width:100%;
  max-width:1400px;
  margin:0 auto;
  padding:12px 20px;
  display:grid;
  grid-template-columns: 1fr auto 1fr;
  align-items:center;
}
.ui-left{ display:flex; justify-content:flex-start; }
.ui-center{ display:flex; justify-content:center; }
.ui-right{ display:flex; justify-content:flex-end; }

/* Tabs */
.tabs{ display:flex; gap:10px; }
.tab{
  border:1px solid #e5e7eb;
  background:#fff;
  color:#9ca3af;
  padding:8px 14px;
  border-radius:12px;
  font-weight:700;
  text-transform:uppercase;
  cursor:pointer;
}
.tab.is-active{
  background:#0a0f1a;
  color:#fff;
  border-color:#0a0f1a;
}

/* Leyenda */
.legend{ text-align:center; }
.legend-title{ margin:0 0 6px; font-size:15px; font-weight:700; }
.legend-items{
  display:flex;
  gap:3px;
  justify-content:center;
}
.legend-item{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:3px;
}
.legend-item .sw{
  width:44px;
  height:12px;
  border-radius:2px;
  border:1px solid rgba(0,0,0,0.08);
}
.legend-item span{
  font-size:10px;
  font-weight:600;
  color:#374151;
  white-space:nowrap;
}

/* Slider */
.slider-wrap{ width:360px; max-width:32vw; }
#range{ margin:6px 0; }
.noUi-target{ border:none; box-shadow:none; background:#e5e7eb; }
.noUi-base, .noUi-connects{ border-radius:6px; }
.noUi-connect{ background:var(--slider); }
.noUi-handle{
  border:1px solid #d1d5db;
  background:#fff;
  box-shadow:0 1px 2px rgba(0,0,0,0.08);
}
.slider-labels{
  display:flex;
  justify-content:space-between;
  font-size:13px;
  font-weight:600;
  color:#111;
}

/* Popup */
.maplibregl-popup {
  max-width: 280px;
  font: 13px/1.4 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Helvetica Neue, Arial, Noto Sans;
}
.maplibregl-popup-content {
  padding: 12px 14px;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}
.pp{ font-size:13px; color:#111; }
.pp-title{
  margin:0 0 4px;
  font-size:15px;
  font-weight:700;
  line-height:1.3;
  color:#111;
}
.pp-sub{
  margin:0 0 8px;
  font-size:12px;
  color:#6b7280;
}
.pp-row{
  display:flex;
  justify-content:space-between;
  gap:10px;
  margin-bottom:8px;
}
.pp-badge{
  display:inline-block;
  font-size:11px;
  font-weight:600;
  padding:2px 6px;
  border-radius:6px;
  color:black;
  margin-bottom:2px;
}
.pp-badge--gas{ background:#01f3b3; }
.pp-badge--diesel{ background:#eaea40; }
.pp-price{
  font-size:15px;
  font-weight:700;
  color:#111;
}
.pp-footer{
  font-size:11px;
  color:#6b7280;
  margin-top:4px;
}

/* Responsive móvil */
@media (max-width: 900px){
  #ui{ flex:0 0 auto; }
  .ui-inner{
    grid-template-columns:1fr;
    row-gap:10px;
  }
  .ui-left, .ui-center, .ui-right{ justify-content:center; }
  .slider-wrap{ width:100%; max-width:100%; }

  /* Barra de colores en una fila completa */
  .legend-swatches, .legend-labels{
    grid-template-columns:repeat(auto-fit, minmax(28px, 1fr));
    gap:4px 6px;
  }
  .legend-swatches .sw{ width:100%; }

  .panel-nacional{
    left:10px; right:10px; bottom:60px;
    width:auto;
  }
  .fab-nacional{
    bottom:14px; right:14px;
  }

  /* Barra de fechas: reparte espacio entre todos los botones */
  .date-bar{
    gap:3px;
    padding:4px 8px 6px;
  }
  .date-btn{
    flex:1 1 0;
    min-width:0;
    font-size:9px;
    padding:2px 0;
    border-radius:6px;
    display:flex;
    align-items:center;
    justify-content:center;
  }
  .date-btn[data-mode="variacion"]{ margin-right:0; }
}

/* ── Utilidad ── */
.hidden{ display:none !important; }

/* ── Botón modo variación ── */
.btn-modo{
  margin-left:10px;
  border:1px solid #e5e7eb;
  background:#fff;
  color:#9ca3af;
  padding:8px 14px;
  border-radius:12px;
  font-weight:700;
  text-transform:uppercase;
  cursor:pointer;
  font-size:inherit;
}
.btn-modo.is-active{
  background:#0a0f1a;
  color:#fff;
  border-color:#0a0f1a;
}

/* ── FAB nacional ── */
.fab-nacional{
  position:absolute;
  bottom:30px;
  right:50px;
  z-index:10;
  background:#0a0f1a;
  color:#fff;
  border:none;
  border-radius:20px;
  padding:10px 16px;
  font-size:13px;
  font-weight:700;
  cursor:pointer;
  box-shadow:0 2px 8px rgba(0,0,0,0.25);
  transition:opacity 0.2s;
}
.fab-nacional:hover{ opacity:0.85; }

/* ── Panel evolución nacional ── */
.panel-nacional{
  position:absolute;
  bottom:80px;
  right:50px;
  z-index:20;
  width:520px;
  background:#fff;
  border-radius:14px;
  box-shadow:0 4px 20px rgba(0,0,0,0.18);
  padding:16px 18px 14px;
}
.panel-header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom:10px;
}
.panel-title{
  font-size:15px;
  font-weight:700;
  color:#111;
}
.btn-cerrar{
  background:none;
  border:none;
  font-size:16px;
  cursor:pointer;
  color:#6b7280;
  line-height:1;
  padding:0 4px;
}
.btn-cerrar:hover{ color:#111; }
#chart-nacional{
  width:100% !important;
  height:200px !important;
}

/* ── Leyenda variación: barra gradiente ── */
.legend-var-bar{
  width: 220px;
  height: 12px;
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,0.08);
}
.legend.is-variacion #legend-swatches{
  display: flex;
  justify-content: center;
}
.legend.is-variacion #legend-labels{
  display: flex;
  justify-content: space-between;
  width: 220px;
  margin: 0 auto;
  gap: 0;
}
.legend.is-variacion #legend-labels span{
  font-size: 11px;
}

/* ── Barra de fechas ── */
.date-bar{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:5px;
  padding:6px 20px 8px;
  border-top:1px solid #f3f4f6;
  overflow-x:auto;
  scrollbar-width:none;
}
.date-bar::-webkit-scrollbar{ display:none; }
.date-btn{
  flex-shrink:0;
  border:1px solid #e5e7eb;
  background:#fff;
  color:#9ca3af;
  padding:4px 11px;
  border-radius:8px;
  font-size:11px;
  font-weight:700;
  cursor:pointer;
  white-space:nowrap;
  transition:background 0.12s, color 0.12s;
}
.date-btn:hover{ background:#f3f4f6; color:#374151; }
.date-btn.is-active{ background:#0a0f1a; color:#fff; border-color:#0a0f1a; }
.date-btn[data-mode="variacion"]{ margin-right:6px; border-color:#d1d5db; }
.slider-disabled{ opacity:0.35; pointer-events:none; }

/* ── Botón evolución en popup ── */
.pp-btn-evo{
  display:block;
  width:100%;
  margin-top:8px;
  padding:6px 0;
  background:#f3f4f6;
  border:1px solid #e5e7eb;
  border-radius:8px;
  font-size:12px;
  font-weight:600;
  color:#374151;
  cursor:pointer;
  text-align:center;
}
.pp-btn-evo:hover{ background:#e5e7eb; }

/* ── Popup con histórico ── */
.popup-chart-wrap{
  margin-top:10px;
  position:relative;
  width:100%;
  height:180px;
}
.popup-chart-wrap canvas{
  display:block;
}
