﻿body, html {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: Arial, sans-serif;
}

/* Media help button and menu */
.media-help-btn { display:flex; align-items:center; justify-content:center; background:linear-gradient(180deg,#ffffff,#f3fbff); border:1px solid #d7eaf8; width:42px; height:42px; border-radius:10px; cursor:pointer; box-shadow:0 6px 18px rgba(3,57,95,0.12); transition:transform 120ms ease, box-shadow 120ms ease; }
.media-help-btn:hover { transform:translateY(-2px); box-shadow:0 10px 26px rgba(3,57,95,0.14); }
.media-help-btn svg { width:18px; height:18px; color:#0077c8; }
.tour-help-btn { display:none !important; }
.map-base-toggle { position:relative; }
.media-menu { position:absolute; left:8px; top:110px; list-style:none; margin:8px 0 0 0; padding:8px; background:linear-gradient(180deg,#ffffff,#fbfdff); border:1px solid rgba(6,94,140,0.08); border-radius:10px; box-shadow:0 12px 34px rgba(2,46,75,0.12); display:none; z-index:1400; min-width:200px; }
.media-menu li { padding:10px 14px; cursor:pointer; color:#033b57; font-weight:600; display:flex; gap:10px; align-items:center; }
.media-menu li::before { content: ''; display:inline-block; width:14px; height:14px; border-radius:3px; background:linear-gradient(90deg,#3aa0ff,#2b8bd6); margin-right:8px; }
.media-menu li:hover { background:linear-gradient(90deg, rgba(3,124,190,0.06), rgba(3,124,190,0.02)); border-radius:6px; }
.media-menu.open { display:block; }

/* Video modal styles */
.video-modal.hidden{display:none}
.video-modal{position:fixed;inset:0;display:flex;align-items:center;justify-content:center;z-index:9999}
.video-modal-backdrop{position:absolute;inset:0;background:rgba(0,0,0,0.7)}
.video-modal-content{position:relative;background:#fff;padding:14px;border-radius:10px;max-width:1100px;max-height:92%;width:95%;box-shadow:0 18px 50px rgba(2,46,75,0.22);z-index:2;overflow:auto}
.video-modal-content iframe{border-radius:6px}
.video-close{position:absolute;top:8px;right:8px;background:transparent;border:none;font-size:20px;cursor:pointer}
.video-controls{margin-top:8px;display:flex;gap:8px;justify-content:center}

./* Loading overlay */
#loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  /* translucent dark so the cinematic map is visible underneath */
  background: rgba(0,0,0,0.75);
  z-index: 99999;
  transition: background 1s ease;
}
#loading-overlay.cinematic-mode {
  background: rgba(0,0,0,0.3);
}
.loader-box { display:flex; flex-direction:column; align-items:center; gap:12px; background: rgba(0,0,0,0.5); padding: 40px 50px; border-radius: 12px; backdrop-filter: blur(8px); transition: opacity 1s ease; }
#loading-overlay.cinematic-mode .loader-box { opacity: 0.5; }
.loader-text { font-size:18px; color:#fff; font-weight:700; }
.spinner { width:48px; height:48px; border-radius:50%; border:5px solid rgba(255,255,255,0.18); border-top-color: #fff; animation: spin 1s linear infinite; }
.loader-progress-container { width: 300px; height: 8px; background: rgba(255,255,255,0.2); border-radius: 10px; overflow: hidden; }
.loader-progress-bar { width: 0%; height: 100%; background: linear-gradient(90deg, #0077c8, #00c8ff); transition: width 0.3s ease; border-radius: 10px; }
.loader-subtext { font-size:14px; color: rgba(255,255,255,0.9); font-weight:500; font-style:italic; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-hidden { opacity:0; visibility:hidden; transition: opacity 300ms ease, visibility 300ms; }

/* Layout */
#layout {
  display: grid;
  grid-template-columns: 1fr 0px;
  height: 100vh;
  transition: grid-template-columns 3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

#layout.panel-ready {
  grid-template-columns: 1fr 450px;
}

/* Mapa */
#map {
  width: 100%;
  height: 100%;
  position: relative;
}

/* Base layer toggle control */
.map-base-toggle {
  position: absolute;
  top: 8px;
  left: 8px;
  right: auto;
  z-index: 1000;
}
.map-base-toggle button {
  background: rgba(255,255,255,0.95);
  border: 1px solid rgba(0,0,0,0.12);
  padding: 6px;
  width: 38px;
  height: 38px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.map-base-toggle button:hover { background: rgba(250,250,250,1); }
.map-base-toggle button svg { display: block; margin: 0 auto; color: #333; }
.map-base-control { position: relative; }
.base-list { display: none; position: absolute; left: 0; top: 44px; min-width: 150px; background: white; border: 1px solid rgba(0,0,0,0.08); box-shadow: 0 6px 18px rgba(0,0,0,0.08); border-radius: 6px; padding: 6px 0; list-style:none; margin:0; z-index:1200; }
.base-list.open { display: block; }
.base-list li { padding: 8px 12px; cursor: pointer; white-space: nowrap; }
.base-list li:hover { background: #f3f7fb; }
.base-list li.unavailable { color: #9aa7b7; pointer-events: none; }
.base-check { display: inline-block; width: 16px; font-weight: bold; color: #0077c8; }

/* Attribution display */
.map-attribution { position: absolute; left: 8px; bottom: 6px; background: rgba(255,255,255,0.9); padding: 4px 8px; border-radius: 4px; font-size: 11px; color: #222; z-index: 1000; max-width: 320px; }

/* Map tooltip */
.map-tooltip {
  position: absolute;
  background: rgba(250, 248, 240, 0.98);
  color: #2c3e50;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  pointer-events: none;
  z-index: 10000;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(200, 195, 180, 0.4);
  transition: opacity 150ms ease, transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
  transform: scale(0.95);
}
.map-tooltip:not(.hidden) {
  transform: scale(1);
  animation: tooltipBounce 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.map-tooltip.hidden {
  opacity: 0;
  visibility: hidden;
  transform: scale(0.95);
}

@keyframes tooltipBounce {
  0% { transform: scale(0.8); opacity: 0; }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

/* View control removed; rotation now handled with Alt+drag */

/* Panel lateral */
#panel {
  background: transparent;
  padding: 15px;
  overflow-y: auto;
  max-height: 100vh;
  transition: transform 3s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 3s ease;
}

/* Hidden panel - fuera de la pantalla a la derecha */
.panel-hidden {
  background: rgba(255, 255, 255, 0.3);
  border-left: 3px solid #0b8bd9;
  box-shadow: 0 8px 20px rgba(0,0,0,0.08);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  opacity: 0;
  transform: translateX(100%);
  pointer-events: none;
}
.panel-hidden .panel-inner { opacity: 0; transform: translateY(8px); transition: opacity 360ms ease, transform 360ms ease; }
.panel-visible {
  /* transparent panel with glass effect */
  background: rgba(255, 255, 255, 0.3);
  border-left: 3px solid #0b8bd9;
  box-shadow: 0 8px 20px rgba(0,0,0,0.08);
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.panel-visible .panel-inner { opacity: 1; transform: translateY(0); transition: opacity 420ms ease, transform 420ms ease; }

/* KPI reveal animation (staggered by JS) */
.kpi { opacity: 0; transform: translateY(8px); transition: opacity 360ms ease, transform 360ms ease; }
.kpi.kpi-show { opacity: 1; transform: translateY(0); }

/* Sparkline small canvases inside KPI cards */
.kpi-sparkline {
  width: 100%;
  height: 34px;
  display: block;
  margin: 6px 0 10px 0;
  pointer-events: auto; /* allow hover for tooltip */
  cursor: pointer;
  border-radius: 4px;
}

/* Pulse animation when sparkline is updated */
.kpi-sparkline.pulse { animation: spark-pulse 900ms ease-out; }
@keyframes spark-pulse {
  0% { transform: scaleY(1); box-shadow: 0 0 0 rgba(11,139,217,0); }
  40% { transform: scaleY(1.02); box-shadow: 0 6px 18px rgba(11,139,217,0.08); }
  100% { transform: scaleY(1); box-shadow: 0 0 0 rgba(11,139,217,0); }
}
/* KPI row: label and numeric value */
.kpi-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.kpi-value { font-weight: 700; color: #0b6fb0; font-size: 1.05rem; }

/* Horizontal progress bar that fills from right to left */
.kpi-bar { position: relative; height: 12px; background: #f1f8ff; border-radius: 8px; overflow: hidden; }
.kpi-fill { position: absolute; top: 0; bottom: 0; right: 0; width: 0%; background: linear-gradient(90deg,#8cc8f2 0%,#5aaee8 100%); border-radius: 8px; transition: width 420ms cubic-bezier(.2,.9,.2,1); }
.kpi-bar[aria-valuenow] { /* accessible hook - reserved for future focus styles */ }

/* Logos */
.logo-container {
  position: absolute;
  left: 0;
  right: 450px;
  text-align: center;
  margin-top: 20px;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.8s ease, left 0.3s ease, right 0.3s ease;
}

#layout:not(.panel-ready) .logo-container {
  right: 0;
}

.logo-container.show {
  opacity: 1;
}

.logo-container.fade-out {
  opacity: 0;
}

.logo-box {
  background: white;
  padding: 15px 35px;
  border-radius: 12px;
  display: inline-flex;
  gap: 30px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  align-items: center;
  pointer-events: auto;
  animation: logoWave 3s ease-in-out infinite;
}

@keyframes logoWave {
  0%, 100% { 
    transform: translateY(0) scale(1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  }
  50% { 
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
  }
}

.cine-logo {
  height: 110px;
  object-fit: contain;
}

.indicador-dropdown {
  width: 100%;
  padding: 10px 12px;
  margin: 8px 0;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background-color: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  cursor: pointer;
  transition: all 0.2s ease;
}

.indicador-dropdown optgroup {
  font-weight: 700;
  font-size: 14px;
  color: #333;
  padding: 8px 0;
  background-color: #f8f9fa;
  text-align: center;
  letter-spacing: 0.5px;
}

.indicador-dropdown option {
  font-weight: 400;
  padding: 8px 12px 8px 32px;
  background-color: white;
  transition: all 0.2s ease;
  position: relative;
  background-size: 16px 100%;
  background-repeat: no-repeat;
  background-position: 8px center;
}

.indicador-dropdown option:hover {
  background-color: #f0f8ff;
}

/* Rectángulos con gradiente continuo (color ramp) extendido */
.indicador-dropdown option[value="Pérdida Km/día"] {
  background-image: linear-gradient(90deg, #fee5d9 0%, #fcbba1 25%, #fc9272 50%, #fb6a4a 75%, #de2d26 90%, #a50f15 100%, transparent 100%);
  background-size: 60px 100%;
  background-repeat: no-repeat;
}

.indicador-dropdown option[value="IANC"] {
  background-image: linear-gradient(90deg, #edf8e9 0%, #c7e9c0 25%, #a1d99b 50%, #74c476 75%, #31a354 90%, #006d2c 100%, transparent 100%);
  background-size: 60px 100%;
  background-repeat: no-repeat;
}

.indicador-dropdown option[value="UARL"] {
  background-image: linear-gradient(90deg, #f2e6f5 0%, #dadaeb 25%, #bcbddc 50%, #9e9ac8 75%, #756bb1 90%, #54278f 100%, transparent 100%);
  background-size: 60px 100%;
  background-repeat: no-repeat;
}

.indicador-dropdown option[value="Dotación nominal"] {
  background-image: linear-gradient(90deg, #e0f3f8 0%, #abd9e9 25%, #74add1 50%, #4575b4 75%, #313695 90%, #081d58 100%, transparent 100%);
  background-size: 60px 100%;
  background-repeat: no-repeat;
}

.indicador-dropdown option[value="Dotación facturada autorizada"] {
  background-image: linear-gradient(90deg, #e1f5fe 0%, #b3e5fc 25%, #81d4fa 50%, #4fc3f7 75%, #039be5 90%, #01579b 100%, transparent 100%);
  background-size: 60px 100%;
  background-repeat: no-repeat;
}

.indicador-dropdown option[value="ILI"] {
  background-image: linear-gradient(90deg, #fee5d9 0%, #fcbba1 25%, #fc9272 50%, #fb6a4a 75%, #de2d26 90%, #a50f15 100%, transparent 100%);
  background-size: 60px 100%;
  background-repeat: no-repeat;
}

.indicador-dropdown option[value="IPUF"] {
  background-image: linear-gradient(90deg, #efedf5 0%, #dadaeb 25%, #bcbddc 50%, #9e9ac8 75%, #756bb1 90%, #54278f 100%, transparent 100%);
  background-size: 60px 100%;
  background-repeat: no-repeat;
}

/* Balance Hídrico - gradientes según diagrama extendidos */
.indicador-dropdown option[value="Volumen de Entrada"] {
  background-image: linear-gradient(90deg, #f8ece1 0%, #ecd4b8 25%, #e0bc8f 50%, #d4a574 75%, #c89559 90%, #bc853e 100%, transparent 100%);
  background-size: 60px 100%;
  background-repeat: no-repeat;
}

.indicador-dropdown option[value="Consumo autorizado"] {
  background-image: linear-gradient(90deg, #e8f5e0 0%, #cde5b8 25%, #b3d590 50%, #9dc183 75%, #87ad76 90%, #71996a 100%, transparent 100%);
  background-size: 60px 100%;
  background-repeat: no-repeat;
}

.indicador-dropdown option[value="Pérdidas totales"] {
  background-image: linear-gradient(90deg, #fce8e7 0%, #f6cccb 25%, #f0b0af 50%, #e8a5a3 75%, #e08a88 90%, #d8706d 100%, transparent 100%);
  background-size: 60px 100%;
  background-repeat: no-repeat;
}

.indicador-dropdown option[value="Consumo autorizado facturado"] {
  background-image: linear-gradient(90deg, #ecf5e3 0%, #d9e9c7 25%, #c6ddab 50%, #b8d3a0 75%, #aac994 90%, #9cbf88 100%, transparent 100%);
  background-size: 60px 100%;
  background-repeat: no-repeat;
}

.indicador-dropdown option[value="Consumo autorizado NO facturado"] {
  background-image: linear-gradient(90deg, #d9ecc9 0%, #b5d494 25%, #91bc5f 50%, #85b369 75%, #79aa73 90%, #6da17d 100%, transparent 100%);
  background-size: 60px 100%;
  background-repeat: no-repeat;
}

.indicador-dropdown option[value="Pérdidas aparentes"] {
  background-image: linear-gradient(90deg, #fce8e7 0%, #f6cccb 25%, #f0b0af 50%, #e8a5a3 75%, #e08a88 90%, #d8706d 100%, transparent 100%);
  background-size: 60px 100%;
  background-repeat: no-repeat;
}

.indicador-dropdown option[value="Pérdidas reales"] {
  background-image: linear-gradient(90deg, #f5dbd9 0%, #ebbbb8 25%, #e19b98 50%, #d88e8c 75%, #ce8180 90%, #c47474 100%, transparent 100%);
  background-size: 60px 100%;
  background-repeat: no-repeat;
}

.indicador-dropdown option[value="Agua Facturada"] {
  background-image: linear-gradient(90deg, #e6f3fb 0%, #cce7f7 25%, #99cff0 50%, #66b8e9 75%, #33a0e2 90%, #1976d2 100%, transparent 100%);
  background-size: 60px 100%;
  background-repeat: no-repeat;
}

.indicador-dropdown option[value="Agua NO facturada"] {
  background-image: linear-gradient(90deg, #fef8e5 0%, #fdf1cb 25%, #fceab1 50%, #fae397 75%, #f9dc7d 90%, #f8d563 100%, transparent 100%);
  background-size: 60px 100%;
  background-repeat: no-repeat;
}

.indicador-dropdown option[value="Fugas Visibles"] {
  background-image: linear-gradient(90deg, #ffe6cc 0%, #ffd9b3 25%, #ffcc99 50%, #ffbf80 75%, #ffb366 90%, #ffa64d 100%, transparent 100%);
  background-size: 60px 100%;
  background-repeat: no-repeat;
}

.indicador-dropdown option[value="Fugas No visibles"] {
  background-image: linear-gradient(90deg, #f3e5f5 0%, #e1bee7 25%, #ce93d8 50%, #ba68c8 75%, #ab47bc 90%, #8e24aa 100%, transparent 100%);
  background-size: 60px 100%;
  background-repeat: no-repeat;
}

.indicador-dropdown:hover {
  border-color: #0077c8;
  box-shadow: 0 2px 4px rgba(0, 119, 200, 0.1);
}

.indicador-dropdown:focus {
  outline: none;
  border-color: #0077c8;
  box-shadow: 0 0 0 3px rgba(0, 119, 200, 0.1);
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px;
  cursor: pointer;
}

/* Coroplético header as a button */
.coropletico-btn {
  display: inline-block;
  background: #f0f8ff;
  border: 1px solid rgba(11,139,217,0.15);
  color: #0969b3;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}
.coropletico-btn.active { background: #e6f4ff; box-shadow: inset 0 -2px 0 rgba(11,139,217,0.06); }
.coropletico-btn:focus { outline: 2px solid rgba(11,139,217,0.18); outline-offset: 2px; }

/* Collapsible container for coropletico options */
#coropletico-opciones {
  max-height: 1000px; /* large enough */
  overflow: hidden;
  transition: max-height 280ms ease;
}

/* Cuadro visual para el selector de variables */
.visual-selection-box {
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 2px solid rgba(0, 119, 200, 0.25);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 4px 16px rgba(0, 119, 200, 0.12);
  transition: all 0.3s ease;
}

.visual-selection-box:hover {
  border-color: rgba(0, 119, 200, 0.4);
  box-shadow: 0 6px 20px rgba(0, 119, 200, 0.18);
}

.visual-selection-box h4 {
  font-size: 16px;
  color: #0077c8;
  margin: 0 0 12px 0;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

#coropletico-opciones.collapsed {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
}

/* Sector dropdown */
#sector-dropdown.hidden { display: none; }
#sector-list li { padding: 6px; cursor: pointer; border-radius:4px; }
#sector-list li:hover { background:#f0f8ff; }

.legend-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}

#sector-box {
  margin: 15px 0;
  padding: 10px;
  background: rgba(238, 247, 255, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 8px;
}

#sector-actual {
  font-weight: bold;
  color: #0077c8;
}

#tabs {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: nowrap;
  margin-bottom: 15px;
}

.tab {
  flex: 1;
  padding: 8px 10px;
  background: rgba(225, 225, 225, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: none;
  cursor: pointer;
  border-radius: 6px;
  font-size: 13px;
  white-space: nowrap;
  text-align: center;
}

.tab.active {
  background: #0077c8;
  color: white;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

.kpi {
  background: rgba(245, 250, 255, 0.5);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 10px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
}

.kpi:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Barra de leyenda del mapa */
.map-legend {
  position: absolute;
  top: 12px;
  right: 12px;
  left: auto;
  transform: none;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 12px 18px;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(0, 119, 200, 0.15);
  z-index: 1000;
  min-width: 280px;
  max-width: 400px;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.map-legend.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
}

.map-legend .legend-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.map-legend .legend-title {
  font-size: 13px;
  font-weight: 600;
  color: #333;
  flex: 1;
}

.map-legend .legend-buttons {
  display: flex;
  gap: 6px;
}

.map-legend .legend-reset-btn {
  background: #f0f6fb;
  border: 1px solid #d7eaf8;
  border-radius: 6px;
  padding: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  color: #0077c8;
  min-width: 28px;
  min-height: 28px;
}

.map-legend .legend-reset-btn:hover {
  background: #e6f4ff;
  transform: scale(1.05);
}

.map-legend .legend-reset-btn:active {
  transform: scale(0.95);
}

.map-legend .legend-reset-btn svg {
  display: block;
}

/* Export buttons */
.export-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.export-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.export-btn:active {
  transform: translateY(0);
}

.export-btn svg {
  flex-shrink: 0;
}

.map-legend .legend-bar {
  height: 18px;
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.1);
  margin-bottom: 4px;
  position: relative;
}

.map-legend .legend-gradient {
  width: 100%;
  height: 100%;
  background: linear-gradient(to right, #d0e9ff, #2b8cbe);
}

.map-legend .legend-bar {
  position: relative;
  height: 30px;
  margin: 10px 0;
  background: white;
  border-radius: 8px;
  padding: 5px;
}

.map-legend .legend-gradient {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 8px;
  transform: translateY(-50%);
  border-radius: 4px;
  z-index: 1;
}

.map-legend .legend-range-track {
  position: absolute;
  top: 50%;
  height: 8px;
  background: rgba(0, 119, 200, 0.3);
  border-radius: 4px;
  transform: translateY(-50%);
  z-index: 2;
  pointer-events: none;
}

.map-legend .legend-slider-handle {
  position: absolute;
  top: 50%;
  width: 20px;
  height: 20px;
  background: white;
  border: 3px solid #0077c8;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  cursor: grab;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: transform 0.1s ease;
}

.map-legend .legend-slider-handle:active {
  cursor: grabbing;
  transform: translate(-50%, -50%) scale(1.1);
}

.map-legend .legend-slider-handle:hover {
  border-width: 4px;
}

.map-legend .legend-value-label {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #0077c8 0%, #005a9e 100%);
  color: white;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 119, 200, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.map-legend .legend-slider-handle:hover .legend-value-label,
.map-legend .legend-slider-handle:active .legend-value-label {
  opacity: 1;
}

.map-legend .legend-sector-count {
  position: absolute;
  top: -35px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #0077c8 0%, #005a9e 100%);
  color: white;
  padding: 6px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 119, 200, 0.4);
  pointer-events: none;
  z-index: 1000;
}

.map-legend .legend-sector-count.fade-out {
  opacity: 0;
}

.map-legend .legend-sector-count::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid #005a9e;
}

.map-legend .legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #666;
  font-weight: 500;
  position: relative;
}

.map-legend .legend-current {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  min-width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  border-radius: 4px;
  font-size: 10px;
  white-space: nowrap;
  top: -2px;
  cursor: pointer;
  transition: left 100ms linear, width 120ms ease, transform 120ms ease, opacity 120ms ease;
}

/* Efecto 3D para todas las gráficas */
.geo-charts-top > div:last-child,
.geo-charts-bottom > div:last-child,
.geo-charts > div > div > div {
  box-shadow: 
    0 1px 2px rgba(0,0,0,0.06),
    4px 4px 8px rgba(0,0,0,0.15),
    8px 8px 16px rgba(0,0,0,0.1) !important;
  transform: perspective(1000px) rotateX(2deg) rotateY(-2deg);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.geo-charts-top > div:last-child:hover,
.geo-charts-bottom > div:last-child:hover,
.geo-charts > div > div > div:hover {
  transform: perspective(1000px) rotateX(0deg) rotateY(0deg) translateY(-2px);
  box-shadow: 
    0 2px 4px rgba(0,0,0,0.08),
    6px 6px 12px rgba(0,0,0,0.2),
    12px 12px 24px rgba(0,0,0,0.15) !important;
}

/* Efecto 3D para gráficas del comparativo */
#comparativo-chart-container {
  box-shadow: 
    0 1px 2px rgba(0,0,0,0.06),
    4px 4px 8px rgba(0,0,0,0.15),
    8px 8px 16px rgba(0,0,0,0.1);
  transform: perspective(1000px) rotateX(2deg) rotateY(-2deg);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

#comparativo-chart-container:hover {
  transform: perspective(1000px) rotateX(0deg) rotateY(0deg) translateY(-2px);
  box-shadow: 
    0 2px 4px rgba(0,0,0,0.08),
    6px 6px 12px rgba(0,0,0,0.2),
    12px 12px 24px rgba(0,0,0,0.15);
}

/* Rosa de los vientos 3D */
#compass-rose {
  position: absolute;
  top: 50%;
  left: 20px;
  transform: translateY(-50%);
  z-index: 1000;
  cursor: grab;
  display: none !important; /* Oculto inicialmente, se muestra cuando el mapa carga */
  opacity: 0 !important;
}

.compass-container {
  width: 120px;
  height: 120px;
  perspective: 1000px;
}

.compass-circle {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transform: rotateX(60deg) rotateZ(0deg);
  transition: transform 0.1s ease-out;
  background: radial-gradient(circle, rgba(255,255,255,0.95) 0%, rgba(240,240,240,0.9) 100%);
  border-radius: 50%;
  box-shadow: 
    0 8px 16px rgba(0,0,0,0.2),
    0 4px 8px rgba(0,0,0,0.15),
    inset 0 2px 4px rgba(255,255,255,0.8),
    inset 0 -2px 4px rgba(0,0,0,0.1);
  border: 3px solid rgba(11,139,217,0.4);
}

#compass-rose:active {
  cursor: grabbing;
}

/* Control de escala personalizado con relación numérica y barra gráfica - Estilo watermark */
.custom-scale-control {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  padding: 20px 30px;
  backdrop-filter: blur(6px);
  z-index: 1100;
  transition: opacity 0.5s ease, visibility 0.5s ease;
  cursor: default;
  user-select: none;
  pointer-events: none;
  min-width: 300px;
}

.custom-scale-control:hover {
  background-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
}

/* Relación de escala numérica (1:X) - Estilo watermark */
.scale-ratio {
  font-size: 24px;
  font-weight: 700;
  color: rgba(0, 0, 0, 0.4);
  text-align: center;
  margin-bottom: 12px;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  letter-spacing: 1px;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
}

/* Contenedor de la barra gráfica */
.scale-bar-container {
  position: relative;
  width: 250px;
  margin: 0 auto;
}

/* Barra gráfica principal - Estilo watermark */
.scale-bar {
  position: relative;
  width: 100%;
  height: 12px;
  background: linear-gradient(to right, 
    rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.3) 20%, 
    rgba(255, 255, 255, 0.4) 20%, rgba(255, 255, 255, 0.4) 40%,
    rgba(0, 0, 0, 0.3) 40%, rgba(0, 0, 0, 0.3) 60%,
    rgba(255, 255, 255, 0.4) 60%, rgba(255, 255, 255, 0.4) 80%,
    rgba(0, 0, 0, 0.3) 80%, rgba(0, 0, 0, 0.3) 100%);
  border: 1px solid rgba(0, 0, 0, 0.25);
  border-radius: 3px;
  margin-bottom: 8px;
}

/* Marcas de división verticales - Estilo watermark */
.scale-segment {
  position: absolute;
  top: -6px;
  width: 2px;
  height: 24px;
  background-color: rgba(0, 0, 0, 0.3);
  transform: translateX(-50%);
}

/* Etiquetas de distancia - Estilo watermark */
.scale-labels {
  position: relative;
  width: 100%;
  height: 20px;
  font-size: 14px;
  font-weight: 600;
  color: rgba(0, 0, 0, 0.4);
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
}

.scale-label {
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
}

.scale-distance {
  font-weight: 700;
}

.scale-unit {
  font-weight: 600;
  font-size: 13px;
  color: rgba(0, 0, 0, 0.35);
}

.compass-center {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  background: linear-gradient(135deg, #0b8bd9 0%, #0a5f9e 100%);
  border-radius: 50%;
  transform: translate(-50%, -50%) translateZ(20px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  border: 2px solid #fff;
}

.compass-point {
  position: absolute;
  font-weight: 900;
  font-size: 16px;
  color: #0b8bd9;
  text-shadow: 0 1px 2px rgba(255,255,255,0.8), 0 2px 4px rgba(0,0,0,0.3);
  transform-style: preserve-3d;
}

.compass-n {
  top: 8px;
  left: 50%;
  transform: translate(-50%, 0) translateZ(15px);
  color: #d32f2f;
  font-size: 20px;
}

.compass-s {
  bottom: 8px;
  left: 50%;
  transform: translate(-50%, 0) translateZ(15px);
}

.compass-e {
  top: 50%;
  right: 8px;
  transform: translate(0, -50%) translateZ(15px);
}

.compass-w {
  top: 50%;
  left: 8px;
  transform: translate(0, -50%) translateZ(15px);
}

.compass-arrow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform-origin: center;
  transform-style: preserve-3d;
}

.compass-arrow-n {
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 45px solid #d32f2f;
  transform: translate(-50%, -100%) translateZ(10px);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.compass-arrow-s {
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 35px solid #666;
  transform: translate(-50%, 0%) translateZ(8px);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.compass-arrow-e {
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 30px solid #888;
  transform: translate(0%, -50%) translateZ(8px);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.compass-arrow-w {
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 30px solid #888;
  transform: translate(-100%, -50%) translateZ(8px);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

/* Ripple effect for buttons */
.ripple {
  position: relative;
  overflow: hidden;
  transform: translate3d(0, 0, 0);
}

.ripple:after {
  content: "";
  display: block;
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  pointer-events: none;
  background-image: radial-gradient(circle, #fff 10%, transparent 10.01%);
  background-repeat: no-repeat;
  background-position: 50%;
  transform: scale(10, 10);
  opacity: 0;
  transition: transform 0.5s, opacity 1s;
}

.ripple:active:after {
  transform: scale(0, 0);
  opacity: 0.3;
  transition: 0s;
}

/* Smooth transitions for map layers */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 0.85; }
}

@keyframes fadeOut {
  from { opacity: 0.85; }
  to { opacity: 0; }
}

.sector-fade-in {
  animation: fadeIn 0.3s ease-in-out;
}

.sector-fade-out {
  animation: fadeOut 0.3s ease-in-out;
}

/* Pulsing loader animation */
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.8; }
}

.loader-pulse {
  animation: pulse 2s ease-in-out infinite;
}

/* Water wave animation for loader */
@keyframes wave {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.loader-wave {
  position: relative;
  overflow: hidden;
}

.loader-wave::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 200%;
  height: 100%;
  background: linear-gradient(90deg, 
    transparent, 
    rgba(255, 255, 255, 0.3), 
    transparent
  );
  animation: wave 2s ease-in-out infinite;
}

/* Stats Panel */
.stats-panel {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(10px);
  padding: 12px;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  min-width: 260px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateX(0);
  animation: statsWave 3s ease-in-out infinite;
}

@keyframes statsWave {
  0%, 100% { 
    transform: translateY(0) scale(1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  }
  50% { 
    transform: translateY(-5px) scale(1.01);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
  }
}

.stats-panel.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(20px);
}

.stats-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.stats-title {
  font-size: 13px;
  font-weight: 700;
  color: #2c3e50;
}

.stats-minimize-btn {
  background: transparent;
  border: none;
  color: #999;
  cursor: pointer;
  padding: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.stats-minimize-btn:hover {
  background: #e8f4f8;
  color: #0077c8;
}

.stats-close-btn {
  background: transparent;
  border: none;
  font-size: 24px;
  color: #999;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.stats-close-btn:hover {
  background: #f0f0f0;
  color: #333;
}

/* Botón de volver en panel de estadísticas */
.stats-back-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: none;
  color: #0077c8;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.stats-back-btn:hover {
  background: #e8f4f8;
}

.stats-back-btn.hidden {
  display: none;
}

/* Lista de sectores en panel de estadísticas */
.stats-sectors-list {
  display: block;
  max-height: 300px;
  overflow-y: auto;
}

.stats-sectors-list.hidden {
  display: none;
}

.sectors-list-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sector-item {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 8px 12px;
  border-radius: 6px;
  color: white;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: transform 0.2s ease;
  cursor: pointer;
}

.sector-item:hover {
  transform: translateX(4px);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.sector-item-name {
  font-weight: 600;
}

.sector-item-value {
  font-size: 11px;
  opacity: 0.9;
}

/* Cuadrito minimizado de estadísticas */
.stats-minimized {
  position: absolute;
  top: 20px;
  right: 470px;
  width: 50px;
  height: 50px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  backdrop-filter: blur(10px);
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  animation: statsWave 3s ease-in-out infinite;
  color: white;
}

.stats-minimized:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 24px rgba(102, 126, 234, 0.5);
}

.stats-minimized.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.stat-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 10px;
  border-radius: 8px;
  text-align: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  color: white;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.stat-label {
  font-size: 10px;
  opacity: 0.9;
  margin-bottom: 3px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 16px;
  font-weight: 700;
}

/* ============================================
   BOTÓN DE AYUDA PARA TOUR GUIADO
   ============================================ */
.tour-help-btn {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0077c8, #00a8e8);
  border: none;
  box-shadow: 0 4px 12px rgba(0, 119, 200, 0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: all 0.3s ease;
  color: white;
}

.tour-help-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(0, 119, 200, 0.5);
  background: linear-gradient(135deg, #0056a3, #0077c8);
}

.tour-help-btn:active {
  transform: scale(0.95);
}

/* Animación de pulso para llamar la atención */
@keyframes pulse-help {
  0%, 100% {
    box-shadow: 0 4px 12px rgba(0, 119, 200, 0.3);
  }
  50% {
    box-shadow: 0 4px 24px rgba(0, 119, 200, 0.6);
  }
}

.tour-help-btn {
  animation: pulse-help 2s ease-in-out infinite;
}

/* ============================================
   ESTILOS PERSONALIZADOS PARA INTRO.JS
   ============================================ */
.introjs-tooltip {
  border-radius: 12px !important;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3) !important;
  background: linear-gradient(135deg, #ffffff, #f8fbff) !important;
  border: 2px solid #0077c8 !important;
  max-width: 450px !important;
}

.introjs-tooltiptext {
  font-size: 14px !important;
  line-height: 1.6 !important;
  color: #333 !important;
  padding: 10px !important;
}

.introjs-tooltip h2 {
  color: #0077c8 !important;
  margin-top: 0 !important;
}

.introjs-button {
  border-radius: 6px !important;
  padding: 8px 16px !important;
  font-weight: 600 !important;
  font-size: 13px !important;
  transition: all 0.2s ease !important;
  border: none !important;
  text-shadow: none !important;
}

.introjs-nextbutton {
  background: linear-gradient(135deg, #0077c8, #00a8e8) !important;
  color: white !important;
}

.introjs-nextbutton:hover {
  background: linear-gradient(135deg, #0056a3, #0077c8) !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 119, 200, 0.3) !important;
}

.introjs-prevbutton {
  background: #f0f6fb !important;
  color: #0077c8 !important;
}

.introjs-prevbutton:hover {
  background: #d7eaf8 !important;
}

.introjs-skipbutton {
  color: #999 !important;
}

.introjs-skipbutton:hover {
  color: #666 !important;
}

.introjs-donebutton {
  background: linear-gradient(135deg, #00c851, #00a843) !important;
  color: white !important;
}

.introjs-donebutton:hover {
  background: linear-gradient(135deg, #00a843, #008a36) !important;
}

/* Make the skip/finish button small and avoid overflowing the tooltip */
.introjs-skipbutton {
  padding: 6px 8px !important;
  font-size: 11px !important;
  line-height: 1 !important;
  border-radius: 6px !important;
  min-width: 36px !important;
  max-width: 48px !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

/* Ensure the small label fits inside tooltip without pushing content */
.dashboard-tour-tooltip .introjs-skipbutton {
  position: absolute;
  right: 12px;
  top: 12px;
}

/* Pictogram button for FIN (intro skip) */
.introjs-skipicon {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 36px !important;
  height: 36px !important;
  padding: 0 !important;
  background: linear-gradient(135deg, #ff6b6b, #ff8e53) !important;
  border: none !important;
  box-shadow: 0 6px 18px rgba(255,107,107,0.18) !important;
  color: white !important;
  border-radius: 50% !important;
  font-weight: 700 !important;
  font-size: 12px !important;
}

/* Breathing animation similar to logos */
@keyframes skip-breathe {
  0% { transform: scale(1); box-shadow: 0 6px 18px rgba(255,107,107,0.18); }
  50% { transform: scale(1.06); box-shadow: 0 10px 26px rgba(255,107,107,0.22); }
  100% { transform: scale(1); box-shadow: 0 6px 18px rgba(255,107,107,0.18); }
}

.introjs-skipicon { animation: skip-breathe 2.2s ease-in-out infinite; }

/* Ensure tooltip padding leaves room for the round button */
.dashboard-tour-tooltip { padding-top: 44px !important; }

.introjs-bullets ul li a {
  width: 10px !important;
  height: 10px !important;
  background: #d7eaf8 !important;
}

.introjs-bullets ul li a.active {
  background: #0077c8 !important;
  width: 12px !important;
  height: 12px !important;
}

.introjs-progressbar {
  background: #0077c8 !important;
}

.introjs-helperLayer {
  border-radius: 8px !important;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.7), 0 0 30px rgba(0, 119, 200, 0.5) !important;
}

.introjs-arrow {
  border-color: #0077c8 !important;
}

/* Asegurar que elementos sean clickeables después del tour */
.introjs-showElement {
  pointer-events: auto !important;
}

/* Resetear estilos después del tour */
[data-intro]:not(.introjs-showElement),
[data-step]:not(.introjs-showElement) {
  pointer-events: auto !important;
  position: static !important;
  z-index: auto !important;
}

/* ============================================
   RESPONSIVE DESIGN - TABLETS Y MÓVILES
   ============================================ */

/* TABLET (768px - 1024px) */
@media (max-width: 1024px) and (min-width: 768px) {
  /* Panel lateral más compacto */
  #layout.panel-ready {
    grid-template-columns: 1fr 350px;
  }
  
  /* Rosa de los vientos más pequeña */
  #compass-rose {
    width: 60px;
    height: 60px;
    bottom: 15px;
    left: 15px;
  }
  
  /* Logos más pequeños */
  .logo-container {
    gap: 8px;
    padding: 10px;
  }
  
  .cine-logo {
    max-height: 40px;
  }
  
  /* Botón de tour más pequeño */
  .tour-help-btn {
    width: 45px;
    height: 45px;
    top: 15px;
    right: 15px;
  }
  
  /* KPIs más compactos */
  .kpi {
    padding: 10px;
    min-height: 70px;
  }
  
  .kpi-label {
    font-size: 11px;
  }
  
  .kpi-value {
    font-size: 20px;
  }
}

/* MÓVIL Y TABLET PEQUEÑA (< 768px) */
@media (max-width: 767px) {
  /* Layout vertical: mapa arriba, panel abajo */
  #layout {
    grid-template-columns: 1fr !important;
    grid-template-rows: 60vh 40vh;
    height: 100vh;
    overflow: hidden;
  }
  
  #layout.panel-ready {
    grid-template-columns: 1fr !important;
  }
  
  /* Mapa ocupa más espacio superior */
  #map {
    height: 60vh !important;
    width: 100%;
  }
  
  /* Panel más compacto en la parte inferior */
  aside {
    height: 40vh !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
  }
  
  /* Ocultar animación inicial del panel */
  .panel-hidden {
    transform: none !important;
  }
  
  .panel-visible {
    transform: none !important;
  }
  
  /* Rosa de los vientos más pequeña y reposicionada */
  #compass-rose {
    width: 50px;
    height: 50px;
    bottom: 10px;
    left: 10px;
  }
  
  /* Logos más compactos */
  .logo-container {
    top: 10px;
    left: 10px;
    gap: 6px;
    padding: 8px;
  }
  
  .cine-logo {
    max-height: 35px;
  }
  
  /* Botón de tour */
  .tour-help-btn {
    width: 40px;
    height: 40px;
    top: 10px;
    right: 10px;
  }
  
  .tour-help-btn svg {
    width: 20px;
    height: 20px;
  }
  
  /* Leyenda del mapa más compacta y centrada */
  .map-legend {
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    right: auto;
    max-width: 90%;
    width: auto;
    min-width: 280px;
  }
  
  .legend-header {
    flex-direction: column;
    gap: 8px;
    align-items: center;
  }
  
  .legend-title {
    font-size: 12px;
    text-align: center;
  }
  
  .legend-buttons {
    width: 100%;
    justify-content: center;
    gap: 8px;
  }
  
  /* Slider más centrado y visible */
  .legend-slider-container {
    width: 100%;
    display: flex;
    justify-content: center;
  }
  
  .legend-slider {
    width: 90%;
  }
  
  /* Estadísticas flotantes - ancladas abajo */
  .stats-panel {
    position: fixed;
    bottom: 10px;
    right: 10px;
    left: 10px;
    max-width: calc(100% - 20px);
    width: auto;
  }
  
  .stats-minimized {
    bottom: 10px;
    right: 10px;
  }
  
  /* Sector info más compacto */
  #sector-info {
    padding: 12px;
  }
  
  .sector-title {
    font-size: 16px;
  }
  
  /* Dropdown de variables */
  .indicador-dropdown {
    font-size: 14px;
    padding: 10px;
  }
  
  /* Tabs apilados verticalmente en móviles */
  #tabs {
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    width: 100%;
    gap: 0;
  }
  
  .tab {
    width: 100% !important;
    flex: none !important;
    text-align: center;
    padding: 14px 16px;
    font-size: 14px;
    min-height: 48px;
    border-left: none !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0;
  }
  
  .tab:first-child {
    border-radius: 6px 6px 0 0;
  }
  
  .tab:last-child {
    border-radius: 0 0 6px 6px;
    border-bottom: none;
  }
  
  .tab.active {
    border-left: none !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 119, 200, 0.3);
    box-shadow: inset 0 0 10px rgba(0, 119, 200, 0.4);
  }
  
  /* KPIs en 2 columnas */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  
  .kpi {
    padding: 12px;
    min-height: 80px;
  }
  
  .kpi-label {
    font-size: 11px;
  }
  
  .kpi-value {
    font-size: 18px;
  }
  
  /* Gráficos más compactos */
  .geo-charts-top,
  .geo-charts-bottom {
    padding: 12px;
    min-height: 250px;
  }
  
  /* Selector de sectores */
  #sector-box {
    padding: 10px;
  }
  
  #sector-actual {
    font-size: 13px;
  }
  
  /* Botones más grandes para tocar */
  button {
/* MÓVIL PEQUEÑO (< 480px) */
@media (max-width: 479px) {
  /* Mapa y panel con más espacio para el mapa */
  #layout {
    grid-template-rows: 65vh 35vh;
  }
  
  #map {
    height: 65vh !important;
  }
  
  aside {
    height: 35vh !important;
  }
  
  /* Panel aún más compacto */
  #sector-info {
    padding: 8px;
  }
}

/* MÓVIL PEQUEÑO (< 480px) */
@media (max-width: 479px) {
  /* Mapa y panel 50/50 */
  #layout {
    grid-template-rows: 45vh 55vh;
  }
  
  #map {
    height: 45vh !important;
  }
  /* Logos aún más pequeños */
  .cine-logo {
    max-height: 30px;
  }
  
  .logo-container {
    padding: 6px;
  }
  
  /* KPIs en 1 columna para muy pequeños */
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  
  /* Leyenda más compacta en móviles pequeños */
  .map-legend {
    min-width: 260px;
    max-width: 95%;
  }
  
  .tab {
    flex: 1 1 100%;
    text-align: center;
  }
  
  /* Estadísticas más pequeñas */
  .stat-card {
    padding: 8px;
  }
  
  .stat-label {
    font-size: 9px;
  }
  
  .stat-value {
    font-size: 14px;
  }
}

/* Mejoras táctiles para todos los dispositivos móviles */
@media (hover: none) and (pointer: coarse) {
  /* Aumentar área táctil de todos los botones */
  button,
  .tab,
  .kpi,
  select {
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(0, 119, 200, 0.2);
  }
  
  /* Sliders más fáciles de arrastrar */
  .legend-slider-handle {
    width: 24px;
    height: 24px;
  }
  
  /* Desactivar hover en móviles */
  .stat-card:hover,
  .kpi:hover,
  .tab:hover {
    transform: none;
  }
  
  /* Mantener solo active states */
  .stat-card:active {
    transform: scale(0.95);
  }
  
  .tab:active {
    transform: scale(0.98);
  }
}

