body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #f8fafc;
    margin: 0;
    padding: 30px;
    color: #1e293b;
}

h1 {
    text-align: center;
    font-weight: 700;
    margin-bottom: 5px;
    color: #0f172a;
}

#actualizacion {
    text-align: center;
    font-size: 14px;
    color: #64748b;
    margin-top: 0;
    margin-bottom: 35px;
}

h2 {
    font-size: 20px;
    color: #334155;
    margin-top: 40px;
    margin-bottom: 15px;
    border-left: 4px solid #3b82f6;
    padding-left: 10px;
}

.panel {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    width: 200px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
    transition: transform 0.2s;
}

.card:hover {
    transform: translateY(-2px);
}

.card h3 {
    margin: 0 0 10px 0;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
}

.card p {
    margin: 0;
    font-size: 32px;
    font-weight: 700;
    color: #0f172a;
}

/* Contenedor para envolver el canvas y controlar su altura de forma responsiva */
.chart-container {
    background: white;
    padding: 20px;
    margin-top: 15px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
    position: relative;
    height: 350px; /* Altura controlada fija para evitar estiramientos raros en escritorio */
}

.rangos {
    text-align: center;
    margin: 25px 0;
    background: #f1f5f9;
    display: inline-block;
    padding: 6px;
    border-radius: 10px;
    position: relative;
    left: 50%;
    transform: translateX(-50%);
}

.rangos button {
    padding: 8px 16px;
    margin: 0 2px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: #475569;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.rangos button:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.rangos button.active {
    background: white;
    color: #3b82f6;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.rangos button:last-child {
    border-left: 1px solid #cbd5e1;
    border-radius: 0 8px 8px 0;
    margin-left: 8px;
    padding-left: 12px;
}

/* Controles de zoom flotantes dentro del gráfico */
.zoom-controls {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 10;
    display: flex;
    gap: 5px;
}

.zoom-controls button {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid #cbd5e1;
    color: #475569;
    border-radius: 6px;
    width: 28px;
    height: 28px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.zoom-controls button:hover {
    background: #ffffff;
    color: #0f172a;
    border-color: #94a3b8;
    transform: scale(1.05);
}

/* ==========================================================================
   BANNER INSTITUCIONAL (HERO)
   ========================================================================== */

.estacion-hero {
    position: relative;
    width: 100%;
    min-height: 160px;
    background-image: url('estacion.png') !important; 
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 8px;
    margin-bottom: 25px;
    overflow: hidden;
    display: flex;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    background-color: #181c24;
}

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, rgba(24, 28, 36, 0.95) 0%, rgba(24, 28, 36, 0.7) 50%, rgba(24, 28, 36, 0.3) 100%) !important;
    z-index: 1;
}

.hero-content {
    position: relative;
    z-index: 2;
    padding: 25px 30px;
    text-align: left !important;
}

.hero-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 0 0 6px 0;
    letter-spacing: -0.5px;
    color: #ffffff !important;
}

.hero-subtitle {
    font-size: 1.05rem;
    font-weight: 400;
    color: #bdc3c7 !important;
    margin: 0 0 12px 0;
}

.hero-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    font-size: 0.9rem;
    color: #ecf0f1 !important;
    background: rgba(255, 255, 255, 0.1);
    padding: 6px 14px;
    border-radius: 4px;
    width: fit-content;
}

.hero-meta span {
    color: #ecf0f1 !important;
}

.hero-meta strong {
    color: #3498db !important;
}

.meta-divider {
    margin: 0 10px;
    color: rgba(255, 255, 255, 0.4) !important;
}

/* ==========================================================================
   TABLERO LINEAL COMPACTO (5 TARJETAS EN UNA FILA)
   ========================================================================== */

.panel-lineal {
    display: flex !important;
    flex-direction: row !important;
    gap: 10px !important;
    width: 100% !important;
    margin-bottom: 20px !important;
}

.card-compacta {
    flex: 1 1 0% !important;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 10px 10px !important;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
    box-sizing: border-box !important;
}

.card-compacta h3 {
    margin: 0 0 4px 0 !important;
    font-size: 1.0rem !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #7f8c8d;
}

.card-compacta p {
    margin: 0 !important;
    font-size: 1.45rem !important;
    font-weight: bold;
    color: #2c3e50;
    line-height: 1.2 !important;
}

.card-compacta p div {
    font-size: 0.9rem !important;
    margin-top: 1px !important;
}

/* ==========================================================================
   OPTIMIZACIÓN DE ESPACIO (FILTROS Y GRÁFICOS)
   ========================================================================== */

.rangos {
    margin-bottom: 5px !important; 
}

.rangos + h2,
.rangos + h3,
.rangos + div,
[id="grafTemp"], 
canvas {
    margin-top: 5px !important;
}

.panel-grafico, 
h2, 
h3 {
    margin-top: 5px !important;
    padding-top: 0 !important;
}

/* ==========================================================================
   SEPARACIÓN SELECTIVA DE GRÁFICOS
   ========================================================================== */

.panel-grafico + .panel-grafico,
div:has(> canvas) + div:has(> canvas),
canvas + canvas {
    margin-top: 40px !important;
}

.panel-grafico h2,
.panel-grafico h3 {
    margin-top: 0 !important;
}

* + .panel-grafico h2,
* + .panel-grafico h3,
div + h2,
div + h3 {
    margin-top: 35px !important; 
}

/* Selector de agrupación dentro del gráfico de lluvia */
.selector-acumulado {
    position: absolute;
    top: 7px;
    left: 15px;
    z-index: 10;
    display: flex;
    gap: 4px;
    background: #f1f5f9;
    padding: 3px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
}

.btn-agrupa {
    border: none;
    background: transparent;
    color: #475569;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-agrupa:hover {
    color: #0f172a;
}

.btn-agrupa.active {
    background: #ffffff;
    color: #3b82f6;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* ==========================================================================
   ADAPTACIÓN RESPONSIVA PARA CELULARES Y TABLETS
   ========================================================================== */
@media (max-width: 768px) {
    body {
        padding: 12px;
    }

    /* Hero en móviles */
    .estacion-hero {
        min-height: 180px;
    }
    .hero-overlay {
        background: rgba(24, 28, 36, 0.88) !important;
    }
    .hero-content {
        padding: 15px;
    }
    .hero-title {
        font-size: 1.35rem;
    }
    .hero-subtitle {
        font-size: 0.95rem;
    }
    .meta-divider {
        display: none !important;
    }
    .hero-meta span {
        display: block;
        margin-right: 15px;
        margin-bottom: 2px;
    }

    /* Tarjetas en cuadrícula de 2 columnas para no hacer scroll infinito */
    .panel-lineal {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }
    
    /* La 5ta tarjeta (Presión) ocupa el ancho entero abajo */
    .card-compacta:last-child {
        grid-column: span 2;
    }

    .card-compacta {
        width: 100% !important;
        padding: 10px 6px !important;
    }
    
    .card-compacta h3 {
        font-size: 0.8rem !important;
    }

    .card-compacta p {
        font-size: 1.2rem !important;
    }

    /* Contenedores de gráficos con altura adaptada */
    .chart-container {
        height: 280px;
        padding: 10px 5px 10px 5px;
    }

    /* Ajuste de filtros de tiempo */
    .rangos {
        display: flex;
        width: 100%;
        box-sizing: border-box;
        justify-content: space-between;
        left: 0;
        transform: none;
    }

    .rangos button {
        padding: 6px 8px;
        font-size: 12px;
        flex: 1;
    }

    .rangos button:last-child {
        margin-left: 0;
    }

    /* Reposicionamiento de controles flotantes sobre el gráfico */
    .selector-acumulado {
        top: 5px;
        left: 5px;
        padding: 2px;
    }

    .btn-agrupa {
        font-size: 10px;
        padding: 3px 5px;
    }

    .zoom-controls {
        top: 5px;
        right: 5px;
    }

    .zoom-controls button {
        width: 24px;
        height: 24px;
        font-size: 12px;
    }
}



.hero-title a {
    color: inherit;
    text-decoration: none;
}

.hero-title a:hover {
    text-decoration: underline; /* opcional */
}