/* ===== Global ===== */
*,
*::before,
*::after { box-sizing: border-box; }
 
html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
img { max-width: 100%; height: auto; display: block; }
 
/* Estructura */
body { display: flex; flex-direction: column; min-height: 100%; }
 
/* ===== Header ===== */
header {
  background-color: #33c7ff;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 8px 12px; flex: 0 0 auto; flex-wrap: nowrap;
}
#logos-izquierda, #logo-derecha { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
 
#logo  { max-height: clamp(40px, 6.2vw, 66px); height: auto; }
#logo3 { max-height: clamp(46px, 6.8vw, 74px); height: auto; }
 
header h1 {
  color: #fff; margin: 0; line-height: 1.15; flex: 1 1 auto; min-width: 0;
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.titulo-principal { font-weight: 800; letter-spacing: .5px; font-size: clamp(18px, 2.2vw + 0.5rem, 28px); white-space: nowrap; }
.subtitulo        { font-weight: 600; font-size: clamp(12px, 1.2vw + 0.35rem, 18px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
 
/* ===== Mapa ===== */
#map { flex: 1 1 auto; width: 100%; min-height: 420px; border-top: 1px solid rgba(0,0,0,.15); background: #f0f0f0; }
 
/* ===== Barra de dibujo (derecha) ===== */
.leaflet-control.drawing-bar.leaflet-bar {
  display: flex; flex-direction: column; gap: 6px; padding: 6px;
  background: #e9f6ff; border: 1px solid #cfeafa; border-radius: 6px;
}
.drawing-bar .draw-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; background: #fff; border-radius: 8px;
  text-decoration: none; box-shadow: 0 0 0 1px #e5e7eb inset; font-size: 16px; color: #111;
  transition: background .15s ease, outline-color .15s ease;
}
.drawing-bar .draw-btn:hover { background: #f3f4f6; }
.drawing-bar .draw-btn.active { outline: 2px solid #60a5fa; }
.drawing-bar .draw-btn.danger { color: #b91c1c; }
 
/* ===== Botón Home ===== */
.leaflet-control.home-control.leaflet-bar {
  display: flex; padding: 6px; background: #e9f6ff; border: 1px solid #cfeafa; border-radius: 6px;
}
.home-control .home-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; background: #fff; border-radius: 8px;
  text-decoration: none; box-shadow: 0 0 0 1px #e5e7eb inset; font-size: 16px; color: #111;
}
.home-control .home-btn:hover { background: #f3f4f6; }
 
/* ===== Geocoder (botón + panel plegable) ===== */
.geocoder-shell.leaflet-control {
  background: #e9f6ff;
  border: 1px solid #cfeafa;
  border-radius: 8px;
  padding: 6px;
}
.geo-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff; border: 1px solid #dbeafe; border-radius: 8px;
  padding: 6px 10px; font-size: 13px; font-weight: 700; color: #0f172a; cursor: pointer;
}
.geo-toggle i { opacity: .9; }
.geo-panel { margin-top: 6px; display: none; }
.geo-panel.open { display: block; }
.geo-panel .leaflet-control-geocoder {
  background: transparent; border: 0; padding: 0; border-radius: 0;
}
.geo-panel .leaflet-control-geocoder-form input {
  width: clamp(140px, 30vw, 220px);
  font-size: 13px; padding: 6px 8px; border-radius: 6px; border: 1px solid #dbeafe; outline: none;
}
 
/* ===== Fila controles (der. sup.) ===== */
.leaflet-top.leaflet-right .controls-row {
  display: flex; flex-wrap: nowrap; gap: 8px; align-items: flex-start; margin: 10px 10px 0 0;
}
.leaflet-top.leaflet-right .controls-row .leaflet-control { margin: 0; }
 
/* ===== Popup con foto ===== */
.vehab-popup .popup-photo-wrap { margin-bottom: 8px; }
.vehab-popup .popup-photo {
  display: block; width: 100%; max-height: 260px; object-fit: contain;
  border-radius: 6px; box-shadow: 0 1px 4px rgba(0,0,0,.15);
}
 
/* ===== Icono de punto (divIcon) ===== */
.vehab-dot {
  width: 12px; height: 12px; background: #ff2d55; border: 2px solid #fff; border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0,0,0,.15);
}
 
/* ===== Zoom mini vertical (estrecho) ===== */
.leaflet-control.zoom-mini-control {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: #e9f6ff; border: 1px solid #cfeafa; border-radius: 6px; padding: 6px;
}
.zoom-mini .mini-arrow {
  width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid #e5e7eb; border-radius: 6px; background: #fff; font-size: 12px; line-height: 1;
}
.zoom-mini .mini-range-wrap { height: 100px; display: flex; align-items: center; }
.zoom-mini input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100px; height: 4px; border-radius: 999px;
  background: linear-gradient(90deg, #c7d2fe, #93c5fd);
  outline: none; transform: rotate(-90deg);
}
.zoom-mini input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 14px; height: 14px;
  border-radius: 50%; background: #fff; border: 2px solid #60a5fa; box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.zoom-mini input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2px solid #60a5fa;
}
 
/* ===== Clusters ===== */
.custom-cluster div {
  border-radius: 50%;
  text-align: center;
  font-weight: bold;
  color: white;
  line-height: 40px;
  font-size: 14px;
}
.cluster-small  { background: rgba(0, 150, 255, 0.7); }
.cluster-medium { background: rgba(255, 165, 0, 0.8); }
.cluster-large  { background: rgba(255, 0, 0, 0.8); }
 
/* ===== Barra estadísticas globales ===== */
#stats-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0;
  background: #0f172a;
  padding: 0 16px;
  flex: 0 0 auto;
  min-height: 44px;
}
 
.stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
}
 
.stat-item i {
  font-size: 14px;
}
 
.stat-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: #94a3b8;
  text-transform: uppercase;
}
 
.stat-value {
  font-size: 18px;
  font-weight: 800;
  color: #f8fafc;
  font-family: Arial, sans-serif;
  min-width: 28px;
}
 
.stat-pct {
  font-size: 11px;
  font-weight: 500;
  color: #64748b;
  min-width: 36px;
}
 
.stat-divider {
  width: 1px;
  height: 28px;
  background: #1e293b;
  flex-shrink: 0;
}
 
/* Colores por estado */
#stat-total .stat-value  { color: #38bdf8; }
.stat-buena  i           { color: #22c55e; }
.stat-buena  .stat-value { color: #22c55e; }
.stat-regular i          { color: #f59e0b; }
.stat-regular .stat-value{ color: #f59e0b; }
.stat-mala  i            { color: #ef4444; }
.stat-mala  .stat-value  { color: #ef4444; }
.stat-sindato i          { color: #94a3b8; }
.stat-sindato .stat-value{ color: #94a3b8; }
 
@media (max-width: 600px) {
  .stat-item  { padding: 6px 10px; }
  .stat-value { font-size: 15px; }
  .stat-label { font-size: 9px; }
  .stat-pct   { display: none; }
}
 
/* ===== Dashboard ===== */
#dashboard {
  display: none; /* oculto por defecto, se muestra al hacer click en macrosector */
  position: absolute;
  top: 100px;
  right: 10px;
  width: 290px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  border: 1px solid #e2e8f0;
  z-index: 1000;
  padding: 14px 16px 16px;
  pointer-events: all;
}
 
#dash-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #f1f5f9;
}
 
#dash-nombre {
  font-weight: 700;
  font-size: 14px;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}
 
#dash-cerrar {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: #94a3b8;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
  transition: color .15s;
}
#dash-cerrar:hover { color: #b91c1c; }
 
#total {
  font-size: 13px;
  color: #475569;
  margin-bottom: 14px;
  line-height: 1.5;
}
#total strong {
  font-size: 20px;
  font-weight: 800;
  color: #0f172a;
  display: block;
  margin-top: 2px;
}
 
#graficoEstado {
  width: 100% !important;
  max-height: 220px;
}
 
/* ===== Ajustes móviles muy angostos ===== */
@media (max-width: 380px) {
  .geo-panel .leaflet-control-geocoder-form input { width: clamp(120px, 42vw, 200px); }
  .titulo-principal { font-size: clamp(16px, 4.2vw, 24px); }
  .subtitulo        { font-size: clamp(11px, 3.6vw, 16px); }
  #dashboard        { width: calc(100vw - 20px); right: 10px; }
}

#barra-macro {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #0f172a;
  z-index: 1000;
  padding: 6px 12px;
  overflow-x: auto;
  white-space: nowrap;
}
#barra-macro-inner {
  display: inline-flex;
  gap: 8px;
}
.macro-card {
  display: inline-flex;
  flex-direction: column;
  background: #1e293b;
  border-radius: 8px;
  padding: 6px 12px;
  min-width: 110px;
  cursor: pointer;
  border: 1px solid #334155;
}
.macro-card:hover { background: #334155; }
.macro-card-nombre {
  font-size: 10px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100px;
}
.macro-card-total {
  font-size: 16px;
  font-weight: 700;
  color: #f1f5f9;
}
.macro-card-pct {
  font-size: 10px;
  color: #64748b;
}
.macro-card-barra {
  height: 3px;
  border-radius: 2px;
  margin-top: 4px;
  display: flex;
  overflow: hidden;
}