:root {
  --primary: #2d6a4f;
  --accent: #40916c;
  --muted: #64748b;
  --border: #e2e8f0;
  --background: #ffffff;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', sans-serif;
  line-height: 1.5;
  background: #f8fafc;
}

.page-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-header {
  background: linear-gradient(135deg, #e8f5e8 0%, #f0f8f0 100%);
  border: none;
  box-shadow: 0 2px 8px rgba(45, 106, 79, 0.1);
  padding: 0.4rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 2.5rem;
  min-height: 2.5rem;
  animation: slideInDown 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 999999 !important;
}

@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.header-left h1 {
  font-size: 0.85rem;
  color: #2d6a4f;
  margin: 0;
  font-weight: 600;
  line-height: 1.1;
}

.header-subtitle {
  font-size: 0.6rem;
  color: #6b7280;
  margin: 0;
  font-weight: 400;
  line-height: 1;
  opacity: 0.8;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Asegurar que en móviles el header-right esté oculto por defecto */
@media (max-width: 768px) {
  .header-right {
    display: none !important;
  }
}

.chip {
  padding: 0.15rem 0.5rem;
  font-size: 0.6rem;
  border-radius: 12px;
  margin-right: 0;
  background: rgba(45, 106, 79, 0.1);
  color: #2d6a4f;
  font-weight: 500;
  border: 1px solid rgba(45, 106, 79, 0.2);
  backdrop-filter: blur(10px);
}

.chip.muted {
  background: rgba(107, 114, 128, 0.1);
  color: #6b7280;
  border: 1px solid rgba(107, 114, 128, 0.2);
}

.dropdown {
    position: relative;
    display: inline-block;
    z-index: 999999 !important;
}

.dropdown-toggle {
    position: relative;
    background: rgba(255, 255, 255, 0.9);
    color: #2d6a4f;
    border: 1px solid rgba(45, 106, 79, 0.2);
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.65rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
}

.dropdown-toggle:hover {
    background: rgba(45, 106, 79, 0.1);
    transform: translateY(-1px);
}

.dropdown-toggle::after {
    content: '▼';
    font-size: 0.6rem;
    margin-left: 0.3rem;
    transition: transform 0.2s;
}

.dropdown.active .dropdown-toggle::after {
    transform: rotate(180deg);
}

.dropdown.active {
    z-index: 999999 !important;
}

.dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 0.25rem);
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(45, 106, 79, 0.2);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(45, 106, 79, 0.15);
    min-width: 180px;
    display: none;
    z-index: 999999 !important;
    backdrop-filter: blur(20px);
    padding: 0.5rem;
}

.dropdown.active .dropdown-menu {
    display: block !important;
    z-index: 999999 !important;
}

.dropdown-toggle {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.25rem);
  background: white;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
  min-width: 200px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s;
  z-index: 9999 !important;
}

.dropdown.active .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  z-index: 9999 !important;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.6rem;
  color: #374151;
  text-decoration: none;
  transition: all 0.2s;
  border-radius: 8px;
  font-size: 0.7rem;
  margin: 0.1rem 0;
}

.dropdown-item:hover {
  background: rgba(45, 106, 79, 0.1);
  color: #2d6a4f;
}

.dropdown-item:not(:last-child) {
  border-bottom: none;
}

/* Botón "Ir al mapa" minimalista */
.back-to-map {
  background: rgba(255, 255, 255, 0.9);
  color: #2d6a4f;
  text-decoration: none;
  padding: 0.25rem 0.6rem;
  border-radius: 12px;
  font-size: 0.65rem;
  font-weight: 500;
  border: 1px solid rgba(45, 106, 79, 0.2);
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  backdrop-filter: blur(10px);
}

.back-to-map:hover {
  background: rgba(45, 106, 79, 0.1);
  transform: translateY(-1px);
  text-decoration: none;
  color: #2d6a4f;
}

.back-to-map img {
  height: 14px;
  opacity: 0.7;
}

/* Asegurar que los menús de filtros tengan z-index alto */
.filter-menu {
  z-index: 9999 !important;
}

.filter-menu.dropdown-menu {
  z-index: 9999 !important;
}

.dashboard-grid {
    display: grid;
    gap: 1rem;
    padding: 0.75rem;
    height: calc(100vh - 60px);
}

.dashboard-precipitation {
    grid-template-rows: 45% 55%;
}

.dashboard-precipitation .top-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.dashboard-precipitation .bottom-row {
    grid-column: 1 / -1;
}

.dashboard-stations {
    grid-template-rows: 45% 55%;
    gap: 0.75rem;
    padding: 0.75rem;
}

.dashboard-stations .top-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.dashboard-stations .bottom-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
    padding: 0.5rem;
}

.dashboard-trends {
    grid-template-rows: repeat(2, 1fr);
    gap: 1.5rem;
    padding: 1.5rem;
}

.dashboard-trends .chart-box {
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: 15px;
}

.dashboard-stations .bottom-row .chart-box {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-box {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--background);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 10px;
    min-height: 200px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    z-index: 1 !important;
}

/* Efectos de hover para las tarjetas de gráficas */
.chart-box:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(46, 199, 201, 0.2);
}

/* Animación de entrada para las tarjetas */
.chart-box {
    animation: slideInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Efecto de brillo sutil en hover */
.chart-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.6s;
    z-index: 1;
    pointer-events: none;
}

.chart-box:hover::before {
    left: 100%;
}

/* Animación de pulso para gráficas líquidas */
.chart-box[id^="liquid"] {
    animation: gentlePulse 4s ease-in-out infinite;
}

@keyframes gentlePulse {
    0%, 100% {
        box-shadow: var(--shadow);
    }
    50% {
        box-shadow: 0 4px 20px rgba(46, 199, 201, 0.2);
    }
}

.chart-box {
    position: relative;
    overflow: visible !important;
    z-index: 1 !important;
}

.chart-box.span-2 {
    grid-column: span 2; 
}
.chart-content {
    flex-grow: 1;
    min-height: 0;
}

.dashboard-stations .bottom-row .chart-box {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    z-index: 1 !important;
    padding: 8px;
    min-height: 150px;
    background: var(--background);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.dashboard-stations .bottom-row .chart-box > div {
    position: absolute !important;
    top: 8px !important;
    left: 8px !important;
    right: 8px !important;
    bottom: 8px !important;
    width: auto !important;
    height: auto !important;
    overflow: visible;
}

/* Asegurar que los liquid charts se posicionen correctamente */
.dashboard-stations .bottom-row .chart-box .echarts-container {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
}

/* Forzar posicionamiento de liquid charts específicamente */
.dashboard-stations .bottom-row .chart-box[id^="liquid"] {
    position: relative !important;
    overflow: hidden !important;
}

.dashboard-stations .bottom-row .chart-box[id^="liquid"] > div {
    position: absolute !important;
    top: 8px !important;
    left: 8px !important;
    right: 8px !important;
    bottom: 8px !important;
    width: auto !important;
    height: auto !important;
}

.dashboard-stations .bottom-row .chart-box[id^="liquid"] .echarts-container {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    transform: none !important;
}

.echarts-tooltip {
    z-index: 1000 !important;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}

.data-table th,
.data-table td {
    padding: 0.4rem 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--primary);
}

#variables-table {
    max-height: 100%;
    overflow-y: auto;
}

.main-footer {
    margin-top: auto;
    padding: 0.5rem;
    text-align: center;
    color: var(--muted);
    border-top: 1px solid var(--border);
}

#line-chart {
    height: 100% !important;
    min-height: 200px;
    position: relative;
}

.chart-box {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    z-index: 1 !important;
}

.dashboard-container {
    background-color: #f5f5f5;
    padding: 20px;
    position: relative;
    z-index: 1 !important;
}

.table-scroll-container {
    max-height: 250px; 
    overflow-y: auto; 
    width: 100%; 
}

.table-scroll-container .data-table {
    width: 100%;
}

.dashboard-container.grid-4x2 {
    display: grid;
    grid-template-columns: repeat(4, 1fr); 
    grid-template-rows: 1fr 1fr; 
    gap: 15px;
    padding: 15px;
    flex-grow: 1; 
    overflow-y: auto;
}

/* Reducir padding específico para tablero 5 */
.dashboard-container.grid-4x2 .chart-box {
    padding: 8px;
}

.dashboard-container.grid-4x2 .chart-box.full-height {
    padding: 8px;
}
.thermometer-row {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
}

.thermometer-cell {
    flex: 1;
    background: white;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.liquid-chart {
    height: 300px;
    width: 100%;
}

.trend-row {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 4px #0000001a;
}

.full-width-chart {
    height: 400px;
    width: 100%;
}

h3 {
    margin: 0 0 15px 0;
    font-size: 14px;
    color: #333;
    text-align: center;
}

.dashboard-container.grid-4x3 {
    display: grid;
    grid-template-columns: repeat(4, 1fr); 
    grid-template-rows: 1fr 1fr 1fr; 
    gap: 20px;
    padding: 20px;
    flex-grow: 1; 
    overflow-y: auto;
}

.span-4 {
    grid-column: 1 / span 4;
}

.gauge-row-flex {
    grid-column: 1 / span 4;
    display: flex;
    gap: 20px;
    justify-content: space-between;
}

.gauge-box {
    flex: 1 1 20%;
    min-width: 0; 
}

/* ============================================== */
/* === ADICIONES RESPONSIVE (MEDIA QUERIES) === */
/* ============================================== */

/* ---------------------------------------------- */
/* 1. Pantallas medianas (Tabletas, ~768px a 1024px) */
/* ---------------------------------------------- */
@media (max-width: 1024px) {
    /* Ajustes generales */
    .dashboard-container {
        padding: 15px;
    }
    
    /* Dashboard 1 (Precipitacion) - Se mantiene el diseño 2x2 */
    .dashboard-precipitation .top-row {
        gap: 0.75rem;
    }

    /* Dashboard 2 (Estaciones) - Reduce a 3 columnas para los gauges inferiores */
    .dashboard-stations .bottom-row {
        grid-template-columns: repeat(3, 1fr);
    }
    .dashboard-stations .top-row {
        gap: 0.75rem;
    }

    /* Dashboard 5 (4x2) - Reduce a 2 columnas */
    .dashboard-container.grid-4x2 {
        grid-template-columns: repeat(2, 1fr); 
        /* Deja las filas en automático o más flexibles si es necesario */
        grid-template-rows: auto; 
        gap: 15px;
    }
    
    /* Dashboard 7 (4x3) - Reduce a 2 columnas en la parte superior/inferior */
    .dashboard-container.grid-4x3 {
        grid-template-columns: repeat(2, 1fr); 
        grid-template-rows: auto; /* Filas se ajustan al contenido */
        gap: 15px;
    }
    
    /* Clases de utilidad responsive para grids */
    .span-4 {
        /* En tabletas, la celda span-4 ahora ocupa 2 columnas */
        grid-column: 1 / span 2; 
    }
    
    /* Ajuste para la fila de gauges (Dashboard 7) - Pasa a flex-wrap */
    .gauge-row-flex {
        flex-wrap: wrap; /* Permite que los elementos se envuelvan */
        grid-column: 1 / span 2; /* Ocupa las 2 columnas del nuevo grid */
    }
    
    .gauge-box {
        /* Cada gauge ocupa la mitad del ancho menos el gap */
        flex: 1 1 calc(50% - 10px); 
    }
}

/* ---------------------------------------------- */
/* 2. Pantallas pequeñas (Móviles, hasta ~767px) */
/* ---------------------------------------------- */
@media (max-width: 767px) {
    /* Header - Ajuste para pantallas muy pequeñas */
    .main-header {
        height: auto;
        flex-direction: column;
        align-items: flex-start;
        padding-bottom: 0.75rem;
    }
    .header-left h1 {
        font-size: 1.1rem;
    }
    .header-subtitle {
        font-size: 0.65rem;
    }
    
    /* Dropdown - Asegura que se muestre en todo el ancho en móvil */
    .dropdown {
        width: 100%;
    }
    .dropdown-toggle {
        width: 100%;
        justify-content: center;
        margin-top: 0.5rem;
    }
    .dropdown-menu {
        left: 0;
        right: 0;
        min-width: 90vw; /* Ocupa casi todo el ancho de la ventana */
        width: auto;
    }

    /* Dashboard Grid - Diseño de una sola columna (pila vertical) */
    .dashboard-grid {
        padding: 0.5rem;
        height: auto; /* Permitir que la altura crezca */
    }
    
    /* Dashboard 1 (Precipitacion) - Se apila la fila superior */
    .dashboard-precipitation .top-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    /* Dashboard 2 (Estaciones) - Se apila la fila superior e inferior */
    .dashboard-stations .top-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    .dashboard-stations .bottom-row {
        grid-template-columns: 1fr; /* Una columna para todos los gauges */
        gap: 0.5rem;
    }

    /* Dashboard 3 (Tendencias) - Se apilan las filas */
    .dashboard-trends {
        grid-template-rows: auto;
        padding: 0.5rem;
    }
    
    /* Dashboard 5 (4x2) - Reduce a 1 columna */
    .dashboard-container.grid-4x2 {
        grid-template-columns: 1fr; 
        gap: 10px;
        padding: 10px;
    }
    
    /* Dashboard 7 (4x3) - Reduce a 1 columna */
    .dashboard-container.grid-4x3 {
        grid-template-columns: 1fr; 
        gap: 10px;
        padding: 10px;
    }
    
    /* Clases de utilidad responsive para grids */
    .chart-box.span-2,
    .span-4 {
        /* En móviles, todas las celdas ocupan una sola columna */
        grid-column: 1 / -1; 
    }
    
    /* Ajuste para la fila de gauges (Dashboard 7) - Pasa a una columna */
    .gauge-row-flex {
        flex-direction: column; 
        gap: 10px;
    }
    
    .gauge-box {
        flex: 1 1 100%; /* Ocupa el 100% del ancho */
    }
    
    /* Tablas */
    .data-table th,
    .data-table td {
        padding: 0.3rem 0.5rem;
    }
    
    /* Contenedor de scroll para tablas - puede ser necesario más pequeño */
    .table-scroll-container {
        max-height: 200px; 
    }
    
    /* Ajuste de padding en las tarjetas */
    .chart-box {
        padding: 10px;
    }
}


/* Nuevo layout para el Tablero 8 (3 columnas x 3 filas) */
.dashboard-container.grid-3x3-map {
    display: grid;
    /* 3 columnas: 2 para gráficas, 1 para mapa */
    grid-template-columns: 1fr 1fr 1fr; 
    /* 3 filas de altura igual */
    grid-template-rows: 1fr 1fr 1fr; 
    gap: 15px;
    padding: 15px;
    flex-grow: 1; 
    overflow-y: auto;
}

/* Posicionamiento específico para los elementos del Tablero 8 */

/* Mapa que abarca las 3 filas */
.dashboard-8 .chart-box.map-span-3 {
    grid-column: 3;
    grid-row: 1 / span 3;
    min-height: 400px;
}


/* ============================================== */
/* === ADICIONES RESPONSIVE para Tablero 8 === */
/* ============================================== */

/* 1. Pantallas medianas (Tabletas, ~768px a 1024px) */
@media (max-width: 1024px) {
    /* Dashboard 8: Reducir a 2 columnas */
    .dashboard-container.grid-3x3-map {
        grid-template-columns: repeat(2, 1fr); /* Reducir a 2 columnas */
        grid-template-rows: auto;
        gap: 15px;
    }

    .dashboard-8 .chart-box.map-span-3 {
        /* El mapa se va al final, ocupando 2 columnas (ancho completo) */
        grid-column: 1 / span 2;
        grid-row: auto;
        min-height: 300px;
    }
}

/* 2. Pantallas pequeñas (Móviles, hasta ~767px) */
@media (max-width: 767px) {
    .dashboard-container.grid-3x3-map {
        grid-template-columns: 1fr; /* Una sola columna */
        gap: 10px;
        padding: 10px;
    }

    .dashboard-8 .chart-box.map-span-3 {
        grid-column: 1 / -1; 
        grid-row: auto; 
        min-height: 250px;
    }
}

/* Nuevo layout para Tablero 9 (3x3) */
.dashboard-container.grid-3x3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* 3 columnas iguales */
    gap: 15px; /* Espacio entre los elementos */
    padding: 15px;
    height: calc(100vh - 2.5rem - 1px); /* Altura completa menos el header */
    overflow-y: auto;
}

.dashboard-container.grid-3x3 .chart-box {
    min-height: 250px; /* Altura mínima para cada celda */
}


/* Media Query para Tablet (768px a 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
    .dashboard-container.grid-3x3 {
        grid-template-columns: repeat(2, 1fr); /* 2 columnas en tablet */
        grid-auto-rows: minmax(220px, auto);
    }
}

/* Media Query para Móvil (hasta 767px) */
@media (max-width: 767px) {
    .dashboard-container.grid-3x3 {
        grid-template-columns: 1fr; /* 1 columna en móvil */
        grid-auto-rows: minmax(200px, auto);
    }
}

/* Estilos específicos para mapas Leaflet */
.leaflet-container {
    height: 100% !important;
    width: 100% !important;
    z-index: 1;
}

/* Asegurar que los contenedores de mapas tengan altura mínima */
.chart-box.full-height.span-2 {
    min-height: 400px;
}

/* Estilos para el Tablero 6 específicamente */
.dashboard-container.grid-4x2 .chart-box.span-2 {
    min-height: 400px;
}

/* Estilos específicos para mejorar legibilidad en gráficos */
.dashboard-trends .chart-box {
    overflow: visible;
}

/* Mejorar espaciado de títulos en gráficos */
.echarts-title {
    font-family: 'Inter', sans-serif !important;
}

/* Mejorar espaciado de leyendas */
.echarts-legend {
    font-family: 'Inter', sans-serif !important;
}

/* Asegurar que los contenedores de gráficas mantengan sus dimensiones */
.chart-box {
    position: relative;
    overflow: hidden;
    z-index: 1 !important;
}

.chart-box > div {
    width: 100% !important;
    height: 100% !important;
    min-height: 200px;
}

/* Forzar redimensionamiento de ECharts */
.echarts-container {
    width: 100% !important;
    height: 100% !important;
}

/* Mejorar el manejo de zoom */
@media screen {
    .chart-box {
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
    }
}

/* Estilos para tooltips de ECharts */
.echarts-tooltip {
    background: rgba(255, 255, 255, 0.95) !important;
    border: 1px solid #e6e6e6 !important;
    border-radius: 4px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12) !important;
    padding: 4px 6px !important;
    font-size: 10px !important;
    line-height: 1.2 !important;
    max-width: 160px !important;
    z-index: 1000 !important;
    position: absolute !important;
    pointer-events: none !important;
    word-wrap: break-word !important;
    overflow: visible !important;
    white-space: nowrap !important;
}

/* Contener tooltips dentro de sus contenedores */
.chart-box {
    position: relative !important;
    overflow: visible !important;
    z-index: 1 !important;
}

.chart-box .echarts-container {
    position: relative !important;
    overflow: visible !important;
}

/* Centrar tooltips fuera de las gráficas */
.echarts-tooltip {
    transform: translate(-50%, -100%) !important;
    margin-top: -8px !important;
}

.echarts-tooltip .tooltip-title {
    font-weight: 600 !important;
    color: #333 !important;
    margin-bottom: 8px !important;
    font-size: 13px !important;
}

.echarts-tooltip .tooltip-item {
    margin: 4px 0 !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
}

.echarts-tooltip .tooltip-marker {
    width: 10px !important;
    height: 10px !important;
    border-radius: 50% !important;
    display: inline-block !important;
}

.echarts-tooltip .tooltip-name {
    color: #666 !important;
    font-size: 11px !important;
    min-width: 80px !important;
}

.echarts-tooltip .tooltip-value {
    color: #333 !important;
    font-weight: 600 !important;
    font-size: 12px !important;
}

/* Ajustes específicos para diferentes tipos de gráficos */
.echarts-tooltip-axis {
    background: rgba(255, 255, 255, 0.98) !important;
    border: 1px solid #d0d0d0 !important;
    border-radius: 6px !important;
    padding: 10px !important;
    font-size: 11px !important;
    max-width: 250px !important;
}

.echarts-tooltip-item {
    background: rgba(255, 255, 255, 0.9) !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 4px !important;
    padding: 8px !important;
    font-size: 11px !important;
    max-width: 200px !important;
}

/* Tooltips específicos para liquid charts */
.dashboard-stations .bottom-row .chart-box[id^="liquid"] .echarts-tooltip {
    background: rgba(255, 255, 255, 0.98) !important;
    border: 1px solid #d0d0d0 !important;
    border-radius: 4px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12) !important;
    padding: 4px 6px !important;
    font-size: 10px !important;
    line-height: 1.1 !important;
    max-width: 140px !important;
    white-space: normal !important;
    word-wrap: break-word !important;
    text-align: center !important;
}

/* Tooltips específicos para el tablero 3 (tendencias) */
.dashboard-trends .chart-box .echarts-tooltip {
    background: rgba(255, 255, 255, 0.98) !important;
    border: 1px solid #d0d0d0 !important;
    border-radius: 4px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12) !important;
    padding: 4px 6px !important;
    font-size: 10px !important;
    line-height: 1.2 !important;
    max-width: 150px !important;
    white-space: nowrap !important;
    word-wrap: break-word !important;
    text-align: left !important;
    position: absolute !important;
    z-index: 1000 !important;
    transform: translate(-50%, -100%) !important;
    margin-top: -10px !important;
}

/* Contenedores del tablero 3 para tooltips */
.dashboard-trends .chart-box {
    position: relative !important;
    overflow: visible !important;
    z-index: 1 !important;
}

.dashboard-trends .chart-box .echarts-container {
    position: relative !important;
    overflow: visible !important;
}

/* ============================================== */
/* === RESPONSIVE DESIGN - APILADO GRADUAL === */
/* ============================================== */

/* Transiciones suaves para todos los contenedores */
.dashboard-container,
.dashboard-grid {
    transition: all 0.3s ease-in-out;
}

/* ============================================== */
/* === HEADER RESPONSIVE === */
/* ============================================== */

/* Header en tablets */
@media (max-width: 1024px) {
    .main-header {
        padding: 0.4rem 0.8rem;
        flex-wrap: wrap;
        gap: 0.4rem;
        height: 2.2rem;
        min-height: 2.2rem;
    }
    
    .header-left h1 {
        font-size: 0.8rem;
    }
    
    .header-subtitle {
        font-size: 0.6rem;
    }
    
    .chip {
        font-size: 0.6rem;
        padding: 0.1rem 0.4rem;
    }
    
    .dropdown-toggle, .back-to-map {
        padding: 0.2rem 0.5rem;
        font-size: 0.6rem;
    }
}

/* ============================================== */
/* === NAVBAR RESPONSIVE - MENÚ HAMBURGUESA === */
/* ============================================== */

/* Botón hamburguesa minimalista */
.hamburger {
    display: none;
    flex-direction: column;
    cursor: pointer;
    padding: 0.5rem;
    background: var(--primary);
    border: none;
    border-radius: 0.375rem;
    z-index: 1001;
    transition: background-color 0.2s ease;
    min-width: 2.5rem;
    min-height: 2.5rem;
    justify-content: center;
    align-items: center;
}

.hamburger:hover {
    background: var(--accent);
}

.hamburger span {
    width: 20px;
    height: 2px;
    background: white;
    margin: 2px 0;
    transition: all 0.2s ease;
    border-radius: 1px;
}

.hamburger.active span:nth-child(1) {
    transform: rotate(-45deg) translate(-5px, 6px);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: rotate(45deg) translate(-5px, -6px);
}

/* Header en tablets */
@media (max-width: 1024px) {
    .main-header {
        padding: 0.4rem 0.8rem;
        flex-wrap: wrap;
        gap: 0.4rem;
        height: 2.2rem;
        min-height: 2.2rem;
    }
    
    .header-left h1 {
        font-size: 0.8rem;
    }
    
    .header-subtitle {
        font-size: 0.6rem;
    }
    
    .chip {
        font-size: 0.6rem;
        padding: 0.1rem 0.4rem;
    }
    
    .dropdown-toggle, .back-to-map {
        padding: 0.2rem 0.5rem;
        font-size: 0.6rem;
    }
}

/* Header en móviles - Menú hamburguesa */
@media (max-width: 768px) {
    .main-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 0.4rem 0.8rem;
        height: 2.2rem;
        min-height: 2.2rem;
        position: relative;
    }
    
    .header-left {
        flex: 1;
        text-align: left;
    }
    
    .header-left h1 {
        font-size: 0.75rem;
        margin-bottom: 0;
        line-height: 1.1;
    }
    
    .header-subtitle {
        font-size: 0.55rem;
        display: none; /* Ocultar subtítulo en móvil */
    }
    
    .header-right {
        display: none !important; /* Ocultar elementos del header en móvil */
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: white;
        border-top: 1px solid #e5e7eb;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        flex-direction: column;
        padding: 1rem;
        gap: 0.75rem;
        z-index: 1000;
    }
    
    .header-right.active {
        display: flex !important;
    }
    
    .hamburger {
        display: flex;
    }
    
    .chip {
        font-size: 0.7rem;
        padding: 0.2rem 0.5rem;
        margin: 0.25rem 0;
        text-align: center;
    }
    
    /* Dropdowns en móvil */
    .dropdown {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .dropdown-toggle {
        width: 100%;
        justify-content: center;
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }
    
    .dropdown-menu {
        position: static;
        box-shadow: none;
        border: 1px solid #e5e7eb;
        border-radius: 0.375rem;
        margin-top: 0.5rem;
        width: 100%;
    }
    
    .dropdown-item {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
        transition: background-color 0.2s ease;
    }
    
    .dropdown-item:hover {
        background: #f3f4f6;
    }
}

/* Header en móviles muy pequeños */
@media (max-width: 480px) {
    .main-header {
        padding: 0.3rem 0.6rem;
        height: 2rem;
        min-height: 2rem;
    }
    
    .header-left h1 {
        font-size: 0.7rem;
    }
    
    .hamburger span {
        width: 18px;
        height: 2px;
    }
    
    .header-right {
        padding: 0.6rem;
        gap: 0.5rem;
    }
    
    .dropdown-toggle, .back-to-map {
        padding: 0.2rem 0.4rem;
        font-size: 0.55rem;
    }
    
    .dropdown-item {
        padding: 0.3rem 0.5rem;
        font-size: 0.65rem;
    }
    
    .chip {
        font-size: 0.55rem;
        padding: 0.1rem 0.3rem;
    }
}

/* ============================================== */
/* === DROPDOWN RESPONSIVE === */
/* ============================================== */

/* Dropdown en móviles */
@media (max-width: 768px) {
    .dropdown {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .dropdown-toggle {
        width: 100%;
        justify-content: center;
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }
    
    .dropdown-menu {
        left: 0;
        right: 0;
        width: 100%;
        min-width: auto;
        max-width: 100vw;
    }
    
    .dropdown-item {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
}

/* ============================================== */
/* === DASHBOARD GRIDS RESPONSIVE === */
/* ============================================== */

/* Tablero 1 - Precipitación */
@media (max-width: 1024px) {
    .dashboard-precipitation {
        grid-template-rows: auto auto;
        gap: 1rem;
    }
    
    .dashboard-precipitation .top-row {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }
}

@media (max-width: 768px) {
    .dashboard-precipitation {
        grid-template-rows: auto auto;
        gap: 0.75rem;
        padding: 0.5rem;
    }
    
    .dashboard-precipitation .top-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .dashboard-precipitation .bottom-row {
        grid-column: 1;
    }
}

/* Tablero 2 - Estaciones */
@media (max-width: 1024px) {
    .dashboard-stations {
        grid-template-rows: auto auto;
        gap: 0.75rem;
    }
    
    .dashboard-stations .top-row {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }
    
    .dashboard-stations .bottom-row {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }
}

@media (max-width: 768px) {
    .dashboard-stations {
        grid-template-rows: auto auto;
        gap: 0.5rem;
        padding: 0.5rem;
    }
    
    .dashboard-stations .top-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .dashboard-stations .bottom-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
}

/* Tablero 3 - Tendencias */
@media (max-width: 1024px) {
    .dashboard-trends {
        grid-template-rows: auto auto;
        gap: 1rem;
        padding: 1rem;
        height: auto;
        min-height: 400px;
    }
    
    .dashboard-trends .chart-box {
        min-height: 200px;
        height: auto;
    }
}

@media (max-width: 768px) {
    .dashboard-trends {
        grid-template-rows: auto auto;
        gap: 0.75rem;
        padding: 0.5rem;
        height: auto;
        min-height: 300px;
    }
    
    .dashboard-trends .chart-box {
        min-height: 150px;
        height: auto;
        padding: 0.5rem;
    }
    
    .dashboard-trends .chart-box > div {
        height: 100% !important;
        min-height: 150px !important;
    }
    
    /* Asegurar que ECharts se redimensione correctamente */
    .dashboard-trends .chart-box .echarts-container {
        height: 100% !important;
        min-height: 150px !important;
        width: 100% !important;
    }
    
    /* Forzar redimensionamiento de gráficas en móvil */
    .dashboard-trends .chart-box {
        position: relative !important;
        overflow: hidden !important;
    }
}

/* ============================================== */
/* === GRID CONTAINERS RESPONSIVE === */
/* ============================================== */

/* Grid 4x2 - Tablero 4 */
@media (max-width: 1200px) {
    .dashboard-container.grid-4x2 {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        padding: 0.75rem;
    }
    
    .dashboard-container.grid-4x2 .chart-box.span-2 {
        grid-column: 1;
    }
}

/* Grid 4x3 - Tablero 5 */
@media (max-width: 1200px) {
    .dashboard-container.grid-4x3 {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        padding: 0.75rem;
    }
    
    .span-4 {
        grid-column: 1;
    }
    
    .gauge-row-flex {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .gauge-box {
        flex: 1 1 100%;
    }
}

/* Grid 3x3 - Tablero 7 */
@media (max-width: 1200px) {
    .dashboard-container.grid-3x3 {
        grid-template-columns: 1fr;
        grid-auto-rows: minmax(180px, auto);
        gap: 0.75rem;
        padding: 0.75rem;
    }
}

/* Grid 3x3 con Mapa - Tablero 8 */
@media (max-width: 1200px) {
    .dashboard-container.grid-3x3-map {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        padding: 0.75rem;
    }
    
    .dashboard-8 .chart-box.map-span-3 {
        grid-column: 1;
        grid-row: auto;
        min-height: 250px;
    }
}

/* ============================================== */
/* === TABLERO 6 - RUIDO RESPONSIVE === */
/* ============================================== */

/* Tablero 6 - Ruido (uno por renglón) */
@media (max-width: 1200px) {
    /* Sobrescribir estilos específicos del Tablero 6 */
    .dashboard-container.grid-4x2 {
        grid-template-columns: 1fr !important;
        grid-template-rows: auto !important;
        gap: 0.75rem !important;
        padding: 0.75rem !important;
    }
    
    .dashboard-container.grid-4x2 .chart-box {
        grid-column: 1 !important;
        grid-row: auto !important;
        width: 100% !important;
        min-height: 200px !important;
    }
    
    /* Mapa específico del Tablero 6 */
    .chart-box[style*="grid-row: span 2"] {
        grid-column: 1 !important;
        grid-row: auto !important;
        min-height: 300px !important;
    }
    
    /* Contenedor del mapa */
    #map-container {
        min-height: 300px !important;
        height: 300px !important;
    }
    
    /* Cards de contadores */
    .count-card, .time-date-widget {
        min-height: 120px !important;
        padding: 15px !important;
    }
    
    .count-card .card-value, .time-date-widget .time-value {
        font-size: 2rem !important;
    }
    
    /* Forzar que todos los elementos del Tablero 6 sean uno por renglón */
    .dashboard-container.grid-4x2 > * {
        grid-column: 1 !important;
        grid-row: auto !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* Gráficos específicos del Tablero 6 */
    #chart-gauge, #chart-spike, #count-max, #count-1, #count-2, #count-3 {
        grid-column: 1 !important;
        grid-row: auto !important;
        width: 100% !important;
    }
    
    /* Asegurar que el mapa también se comporte como una columna */
    .chart-box.full-height.span-2 {
        grid-column: 1 !important;
        grid-row: auto !important;
        width: 100% !important;
        min-height: 300px !important;
    }
}

/* ============================================== */
/* === CHART BOX RESPONSIVE === */
/* ============================================== */

@media (max-width: 1024px) {
    .chart-box {
        padding: 0.75rem;
        min-height: 180px;
    }
}

@media (max-width: 768px) {
    .chart-box {
        padding: 0.5rem;
        min-height: 160px;
    }
}

/* ============================================== */
/* === TABLAS RESPONSIVE === */
/* ============================================== */

@media (max-width: 1024px) {
    .data-table {
        font-size: 0.7rem;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.3rem 0.4rem;
    }
    
    .table-scroll-container {
        max-height: 200px;
    }
}

@media (max-width: 768px) {
    .data-table {
        font-size: 0.65rem;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.25rem 0.3rem;
    }
    
    .table-scroll-container {
        max-height: 150px;
    }
}

/* ============================================== */
/* === MAPAS RESPONSIVE === */
/* ============================================== */

@media (max-width: 1024px) {
    .leaflet-container {
        min-height: 300px;
    }
}

@media (max-width: 768px) {
    .leaflet-container {
        min-height: 250px;
    }
}

/* ============================================== */
/* === TOOLTIPS RESPONSIVE === */
/* ============================================== */

@media (max-width: 768px) {
    .echarts-tooltip {
        font-size: 9px !important;
        max-width: 120px !important;
        padding: 3px 5px !important;
    }
    
    .echarts-tooltip .tooltip-title {
        font-size: 10px !important;
    }
    
    .echarts-tooltip .tooltip-name {
        font-size: 9px !important;
    }
    
    .echarts-tooltip .tooltip-value {
        font-size: 10px !important;
    }
}

/* ============================================== */
/* === DROPDOWNS FUNCTIONALITY FIX === */
/* ============================================== */

/* Asegurar que los dropdowns funcionen en todas las pantallas */
.dropdown-menu {
    z-index: 1000 !important;
}

.dropdown.active .dropdown-menu {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important;
}

/* Dropdowns en tablets y desktop */
@media (min-width: 769px) {
    .dropdown-menu {
        position: absolute !important;
        top: calc(100% + 0.25rem) !important;
        right: 0 !important;
        left: auto !important;
        width: auto !important;
        min-width: 200px !important;
    }
}

/* Dropdowns en móviles y tablets */
@media (max-width: 1024px) {
    .dropdown-menu {
        position: static !important;
        display: none !important;
        width: 100% !important;
        margin-top: 0.5rem !important;
        box-shadow: none !important;
        border: 1px solid var(--border) !important;
        border-radius: 0.5rem !important;
        background: white !important;
    }
    
    .dropdown.active .dropdown-menu {
        display: block !important;
    }
    
    /* Asegurar que los dropdowns dentro del menú hamburguesa funcionen */
    .header-right.active .dropdown-menu {
        position: static !important;
        display: none !important;
    }
    
    .header-right.active .dropdown.active .dropdown-menu {
        display: block !important;
    }
}