* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: #F7F5F0;
    color: #333;
    overflow-x: hidden;
    width: 100%;
    transition: background 0.3s ease, color 0.3s ease;
}

/* ================= OFFLINE BANNER ================= */
.offline-banner {
    background-color: #fbc02d;
    color: #333;
    text-align: center;
    padding: 10px;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 2001;
    width: 100%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.offline-icon {
    font-size: 18px;
}

body.dark-mode .offline-banner {
    background-color: #f57f17;
    color: #fff;
}

/* ================= DARK MODE ================= */
body.dark-mode {
    background: #121212;
    color: #e0e0e0;
}

body.dark-mode .navbar {
    background-color: #1b1b1b;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

body.dark-mode .nav-left,
body.dark-mode .modal-content {
    background-color: #1e1e1e;
    color: #e0e0e0;
}

body.dark-mode .close { color: #e0e0e0; }

body.dark-mode .form-container,
body.dark-mode #grafico-contenedor,
body.dark-mode #grafico-contenedor-prediccion {
    background-color: #1e1e1e;
    border-color: #333;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

body.dark-mode .logo img {
    background-color: #ffffff;
    border-radius: 50px;
    padding: 4px;
}

body.dark-mode .image,
body.dark-mode .image img {
    background-color: #1e1e1e;
}

body.dark-mode .title, body.dark-mode .dato-valor, body.dark-mode .titulo {
    color: #ffffff;
}

body.dark-mode .desc, body.dark-mode .subtitulo, body.dark-mode .dato-label {
    color: #b0b0b0;
}

body.dark-mode .user-name {
    color: #e0e0e0;
}

body.dark-mode .selector, body.dark-mode input {
    background: #2c2c2c;
    color: #fff;
    border-color: #444;
}

/* Datos meteo colores en dark mode */
body.dark-mode #dato-fecha { background-color: #2a2a2a; border-left-color: #555; }
body.dark-mode #dato-temperatura, 
body.dark-mode .sensor-temperatura { background-color: #3a3220 !important; border-left-color: #fbc02d !important; }
body.dark-mode #dato-humedad, 
body.dark-mode .sensor-hum-aire { background-color: #1a2a36 !important; border-left-color: #2196f3 !important; }
body.dark-mode #dato-viento { background-color: #302b28; border-left-color: #8d6e63; }
body.dark-mode #dato-lluvia, 
body.dark-mode .sensor-hum-suelo { background-color: #1d3021 !important; border-left-color: #4caf50 !important; }

/* ================= NAVBAR ================= */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 40px;
    height: 90px;
    background-color: #3A7758;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.logo img {
    height: 60px; /* Un poco más pequeño para que quepa mejor en grupo */
    border-radius: 50px;
    padding: 4px;
    background-color: white;
}

.nav-left-placeholder {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 15px !important;
    flex: 1;
}

.logo {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.user-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 16px;
    font-weight: 500;
    color: #ffffff;
    padding-left: 5px;
}

.nav-right {
    display: flex;
    gap: 25px;
    align-items: center;
}

.nav-left {
    position: fixed;
    top: 90px;
    left: 0;
    width: 280px;
    height: calc(100vh - 90px);
    background-color: #3A7758;
    flex-direction: column;
    align-items: flex-start;
    padding: 20px;
    display: none;
    z-index: 1000;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
}

.nav-left.active {
    display: flex;
}

.nav-left a {
    width: 100%;
    padding: 15px;
    margin-bottom: 5px;
    color: #FAFAFA;
    font-size: 18px;
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.nav-right a {
    color: #FAFAFA;
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 8px 12px;
    border-radius: 4px;
}

.nav-left a:hover,
.nav-right a:hover {
    color: #FFF;
    background: rgba(182, 210, 193, 0.4);
}

.user-name {
    color: #ffffff;
    font-weight: 500;
}

#datosMeteorologicos, #datosSensores {
    width: 100%;
    box-sizing: border-box;
    padding: 30px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.titulo {
    font-size: 26px;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 5px;
}

.subtitulo {
    font-size: 15px;
    color: #7f8c8d;
    margin-bottom: 20px;
}

.selector {
    padding: 10px 15px;
    font-size: 14px;
    border-radius: 8px;
    border: 1px solid #ddd;
    max-width: 320px;
    width: 100%;
    margin-bottom: 25px;
}

/* Contenedor de los bloques de datos */
#datos-meteo {
    display: block;
    width: 100%;
}

/* Bloques individuales */
.dato {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 15px;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s ease;
    border-left: 5px solid transparent;
    min-width: 120px;
    text-align: center;
}

.dato:hover {
    transform: translateY(-3px);
}

.imagenes {
    width: 40px;
    height: 40px;
    object-fit: contain;
    margin-bottom: 5px;
}

.dato-label {
    font-size: 14px;
    font-weight: 500;
    color: #444;
    margin-bottom: 3px;
}

.dato-valor {
    font-weight: 700;
    font-size: 15px;
    color: #222;
}

/* Colores temáticos */
#dato-fecha { background-color: #f8f9fa; border-left-color: #95a5a6; }

#dato-temperatura, 
.sensor-temperatura { background-color: #fff9c4; border-left-color: #fbc02d; }

#dato-humedad, 
.sensor-hum-aire { background-color: #e3f2fd; border-left-color: #2196f3; }

#dato-viento { background-color: #efebe9; border-left-color: #8d6e63; }

#dato-lluvia, 
.sensor-hum-suelo { background-color: #e8f5e9; border-left-color: #4caf50; }

/* Contenedor de los bloques de datos dinámicos (Móvil usa este por defecto) */
.datos {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    width: 100%;
    gap: 15px;
    margin-bottom: 20px;
}

#dato-fecha { flex: 1 1 100%; order: 1; margin-bottom: 5px; }
#dato-temperatura { flex: 1 1 calc(50% - 15px); order: 2; margin-bottom: 5px; }
#dato-humedad { flex: 1 1 calc(50% - 15px); order: 3; margin-bottom: 5px; }
#dato-viento { flex: 1 1 calc(50% - 15px); order: 4; margin-bottom: 5px; }
#dato-lluvia { flex: 1 1 calc(50% - 15px); order: 5; margin-bottom: 5px; }

/* Sensores Móvil */
#datosSensores .datos {
    justify-content: center;
}

#sensor-temperatura, #sensor-hum-aire, #sensor-hum-suelo {
    flex: 1 1 100%;
    margin-bottom: 10px;
}

/* TABLET Y ESCRITORIO (> 768px): Todo en una fila */
@media screen and (min-width: 769px) {
    .datos {
        flex-wrap: nowrap;
    }
    #dato-fecha,
    #dato-temperatura,
    #dato-humedad,
    #dato-viento,
    #dato-lluvia {
        flex: 1 1 calc(20% - 15px) !important;
        margin-bottom: 0 !important;
        order: unset !important;
    }
    
    #sensor-temperatura, #sensor-hum-aire, #sensor-hum-suelo {
        flex: 1 1 calc(33.333% - 15px) !important;
        margin-bottom: 0 !important;
    }
}

/* Estilos específicos para los bloques de sensores (Demo) */
.sensor-block {
    background: #ffffff;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 30px;
    width: 100%;
    max-width: 850px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    border: 1px solid #e0e0e0;
    transition: background 0.3s ease, border-color 0.3s ease;
}

body.dark-mode .sensor-block {
    background: #1e1e1e;
    border-color: #333;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.sensor-header-simple {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

body.dark-mode .sensor-header-simple {
    border-bottom-color: #333;
}

.sensor-name {
    font-size: 20px;
    font-weight: 700;
    color: #3a7758;
}

body.dark-mode .sensor-name {
    color: #4caf50;
}

.sensor-footer {
    margin-top: 15px;
    font-size: 13px;
    color: #7f8c8d;
    text-align: right;
}

body.dark-mode .sensor-footer {
    color: #b0b0b0;
}

/* Contenedor del gráfico compartida */
#grafico-contenedor, #grafico-contenedor-prediccion {
    width: 100%;
    background: white;
    padding: 15px;
    border-radius: 15px;
    box-sizing: border-box;
    margin: 20px auto;
}

/* Canvas del gráfico base (móvil) */
#grafico-contenedor canvas, #grafico-contenedor-prediccion canvas {
    width: 100% !important;
    height: 400px !important;
    display: block;
}

/* Gráfico Desktop/Tablet adaptativo */
@media screen and (min-width: 769px) {
    #grafico-contenedor, #grafico-contenedor-prediccion {
        max-width: 800px !important;
        margin: 30px auto !important;
    }
    #grafico-contenedor canvas, #grafico-contenedor-prediccion canvas {
        height: 320px !important;
    }
}

/* Responsive */

/* Escritorio */
@media (min-width: 1024px) {
    #grafico-contenedor, #grafico-contenedor-prediccion {
        padding: 15px;
    }
}

/* Tablet */
@media (min-width: 600px) and (max-width: 1023px) {
    #grafico-contenedor, #grafico-contenedor-prediccion {
        width: 100%;
        padding: 15px;
        max-width: 700px;
    }
}

/* Móvil */
@media (max-width: 599px) {
    #grafico-contenedor, #grafico-contenedor-prediccion {
        width: 100%;
        padding: 10px;
        max-width: 300px;
    }
}


/* ================= MODALES ================= */
.modal {
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal.show {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: #fff;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    position: relative;
    transform: translateY(-30px);
    transition: transform 0.3s ease;
}

.modal.show .modal-content {
    transform: translateY(0);
}

input, select, textarea {
    width: 100%;
    padding: 12px;
    margin: 10px 0 20px;
    border-radius: 6px;
    border: 1px solid #ddd;
    box-sizing: border-box;
    font-size: 16px; /* Evita zoom en iOS */
}

.input-eye {
    position: relative;
}

.input-eye img {
    position: absolute;
    right: 12px;
    top: 35%;
    width: 22px;
    cursor: pointer;
}

button {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 6px;
    background: #3A7758;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

button:hover {
    background: #B6D2C1;
    color: #333;
}

/* ========================= */
/* FORMULARIOS LOGIN / REGISTRO */
/* ========================= */

.form-container {
    background: #fff;
    padding: 40px;
    border-radius: 12px;
    width: 90%;
    max-width: 450px;
    margin: 40px auto;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
}

.form-container h3 {
    font-size: 24px;
    margin-bottom: 20px;
    color: #3a7758;
}

.toggle-form {
    margin-top: 20px;
    font-size: 14px;
    color: #666;
}

.toggle-form a {
    color: #3a7758;
    text-decoration: none;
    font-weight: 600;
}

.toggle-form a:hover {
    text-decoration: underline;
}

.error-msg:empty,
.success-msg:empty {
    display: none !important;
}

.error-msg, .success-msg {
    display: none; /* Oculto por defecto */
    color: #d32f2f;
    background: #ffebee;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 15px;
    font-size: 14px;
}

.error-msg:not(:empty), .success-msg:not(:empty) {
    display: block; /* Solo mostrar si tiene texto */
}

.success-msg {
    color: #388e3c;
    background: #e8f5e9;
}

/* ========================= */
/* MENÚ HAMBURGUESA BÁSICO */
/* ========================= */

.menu-toggle {
    display: block; /* Siempre visible por requerimiento */
    font-size: 28px;
    color: white;
    cursor: pointer;
    margin-left: auto;
}

/* BOTÓN CERRAR (X) */
.close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 26px;
    font-weight: bold;
    color: #000;
    cursor: pointer;
}

/* ========================================= */
/* RESPONSIVE: TABLET (769px - 1024px)       */
/* ========================================= */

/* ========================================= */
/* RESPONSIVE COMMON TABLET/MOBILE (< 1024px) */
/* ========================================= */
@media screen and (max-width: 1024px) {
    /* Ajustes generales Meteo Compartidos */
    #datosMeteorologicos, #datosSensores {
        width: 100%;
        padding: 20px 25px;
        margin: 0 auto 20px;
    }

    #titulo-estacion {
        font-size: 28px;
        font-weight: 700;
        text-align: center;
        margin-bottom: 15px;
    }

    #titulo-estacion .subtitulo {
        font-size: 20px;
        margin-bottom: 20px;
    }

    .selector {
        font-size: 18px;
        padding: 12px 15px;
        border-radius: 8px;
        max-width: 100%;
        margin-bottom: 20px;
    }

    .dato {
        padding: 15px;
        text-align: center;
    }

    .dato-label { font-size: 14px; font-weight: 600; }
    .dato-valor { font-size: 16px; font-weight: 700; }
    .imagenes { width: 40px; height: 40px; margin-bottom: 8px; }

}

/* ================= LANDING PAGE ================= */
.landing-page-container {
    width: 100%;
    max-width: 1400px; /* Aumentado para albergar 4 en línea */
    margin: 40px auto;
    text-align: center;
    padding: 0 40px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.landing-header img {
    width: 120px;
    margin-bottom: 20px;
    background-color: white;
    border-radius: 50%;
    padding: 10px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.landing-header h2 {
    font-weight: 400;
    font-size: 28px;
    margin-bottom: 40px;
    color: #2c3e50;
}

.landing-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 4 en línea para PC */
    gap: 25px;
    width: 100%;
    max-width: 1300px;
    margin: 0 auto;
    justify-items: center;
    align-items: center;
}

.landing-square {
    position: relative;
    background-color: #3A7758;
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
    width: 100%; /* Flexible para el grid */
    max-width: 300px; /* Tamaño equilibrado para 4 en línea */
    height: 280px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px; /* Un poco más pequeño para caber bien */
    font-weight: 900;
    color: #ffffff !important;
    cursor: pointer;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
    text-align: center;
    border-radius: 25px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    border: none;
}

.landing-square::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0.2) 100%); /* Graduado profesional */
    transition: background 0.3s ease;
    z-index: 1;
}

.landing-square:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.landing-square:hover::before {
    background: rgba(0, 0, 0, 0.4); /* Se aclara ligeramente pero mantiene legibilidad */
}

.landing-square span {
    position: relative;
    z-index: 2;
    text-shadow: 0 4px 15px rgba(0, 0, 0, 1), 0 0 20px rgba(0,0,0,0.5); /* Súper legible */
    padding: 10px 15px;
    border-radius: 10px;
}

/* Imágenes de fondo para cada carta */
#btnDemo { background-image: url('../img/demo (2).png'); }
#btnEstaciones { background-image: url('../img/estaciones.png'); }
#btnMeteorologicos { background-image: url('../img/datosmeteo.png'); }
#btnPerfil { background-image: url('../img/perfil.png'); }

body.dark-mode .landing-square {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}


/* ========================================= */
/* RESPONSIVE: MÓVIL (<= 768px)              */
/* ========================================= */
@media screen and (max-width: 768px) {
    /* Navegación */
    .logo img {
        height: 35px;
    }
    .navbar {
        height: auto;
        min-height: 60px;
        flex-wrap: nowrap;
        justify-content: space-between;
        padding: 5px 15px;
        width: 100%;
    }
    .nav-left, .nav-right {
        gap: 8px;
        flex-wrap: nowrap;
        align-items: center;
    }
    .nav-right {
        display: flex;
        flex-direction: row;
    }
    .nav-right a {
        font-size: 12px;
        padding: 4px;
        white-space: nowrap;
    }
    .separador {
        color: #FAFAFA;
        font-size: 13px;
        margin: 0 -2px;
        user-select: none;
    }
    .menu-toggle {
        display: block;
    }
    .navbar {
        height: 70px;
    }
    .nav-left {
        top: 70px; 
        height: calc(100vh - 70px);
        width: 100%;
        padding: 15px;
    }
    .nav-left.active {
        display: flex;
    }
    .nav-left a {
        width: 100%;
        padding: 10px 0;
        font-size: 16px;
    }

    /* Modales */
    /* Formularios y contenedores */
    .form-container {
        padding: 20px;
        margin: 20px auto;
        width: 95%;
    }
    .form-container h3 {
        font-size: 20px;
    }
    input, select, textarea, button {
        font-size: 16px !important; /* Forzar 16px para evitar zoom en iPhone */
        padding: 12px !important;
    }

    /* Tarjetas principales */
    .main {
        flex-direction: column;
        padding: 20px;
        gap: 15px;
    }
    .card {
        flex: 1 1 100%;
        max-width: 100%;
        padding: 12px;
    }
    .image img { max-height: 140px; }
    .title { font-size: 1.3rem; line-height: 1.5rem; }
    .desc { font-size: 1rem; line-height: 1.5rem; }
    .action { font-size: 0.9rem; padding: 6px 10px; }
    ul, ol { font-size: 1rem; }

    .landing-page-container {
        margin: 10px auto; /* Reducido de 20px */
        padding: 0 10px;
    }
    .landing-header img {
        width: 100px; /* Un poco más pequeño */
        margin-bottom: 10px; /* Reducido de 20px */
        padding: 8px;
    }
    .landing-header h2 {
        font-size: 22px; /* Un poco más pequeño */
        margin-bottom: 20px; /* Reducido de 40px */
    }
    .landing-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important; /* Más compacto */
        padding: 5px !important;
        justify-items: center;
        width: 100%;
        max-width: 400px;
        margin: 0 auto !important;
    }
    .landing-square {
        width: 150px !important; 
        height: 165px !important; /* Un poco más bajo para ahorrar espacio vertical */
        font-size: 17px !important;
        padding: 5px !important;
        border-radius: 18px !important;
        background-size: cover !important;
    }

    /* Ajuste para pantallas un poco más grandes (iPhone Pro Max, etc) */
    @media screen and (min-width: 400px) {
        .landing-grid {
            max-width: 450px;
            gap: 20px !important;
        }
        .landing-square {
            width: 175px !important;
            height: 195px !important;
            font-size: 20px !important;
        }
    }
}
/* ================= BACK NAVIGATION (PROFESIONAL) ================= */
.nav-back {
    width: 90px;
    height: 90px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #2a5640; /* Verde más oscuro integrado */
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-back:hover {
    background-color: #1e3d2e;
}

.nav-back svg {
    transition: transform 0.2s ease;
}

.nav-back:hover svg {
    transform: translateX(-4px);
}

/* Ajustes Navbar para el botón y centrado profesional */
.navbar {
    padding: 0 !important;
    display: flex;
    justify-content: space-between !important;
    align-items: center;
    position: relative;
    overflow: visible !important;
}

.nav-left-placeholder {
    display: flex !important;
    align-items: center !important;
    flex-direction: row !important;
    gap: 10px !important;
}

.nav-back {
    width: 90px;
    height: 90px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #2a5640;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.user-name {
    color: #ffffff;
    font-weight: 500;
    white-space: nowrap;
}

#userNameLeft {
    font-size: 18px;
    padding-left: 20px;
}

#userNameRight {
    font-size: 16px;
}

.logo {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    justify-content: center;
    transition: opacity 0.3s ease;
    z-index: 5;
    margin: 0 !important;
}

.logo.hidden {
    display: none !important;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-left: auto;
    padding-right: 30px;
    z-index: 10;
}

@media screen and (max-width: 768px) {
    .nav-left-placeholder {
        min-width: 70px;
        height: 70px;
    }
    .nav-back {
        width: 70px;
        height: 70px;
    }
    .navbar {
        height: 70px;
    }
    .logo img {
        height: 50px !important;
    }
    .nav-right {
        padding-right: 15px;
        gap: 10px;
    }
    #userNameLeft {
        font-size: 15px;
        padding-left: 15px;
    }

    /* Forzar apilado vertical de datos en móvil */
    /* No forzar aquí, usar el sistema original */

    .user-name {
        font-size: 14px;
        display: inline-block;
        max-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}




/* ================= SENSORES RESTAURADO (PROFESIONAL) ================= */
.datos-wrapper {
    width: 100%;
    max-width: 1000px;
    margin: 20px auto;
}

.sensor-block {
    background: #fff;
    border-radius: 20px;
    padding: 25px;
    margin-bottom: 40px !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(58, 119, 88, 0.1);
    width: 100%;
    position: relative;
}

#datosSensores .datos {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    width: 100%;
}

/* Estilo original de tarjeta con borde izquierdo grueso */
.sensor-block .dato {
    flex: 1 1 100%; /* Por defecto en móvil una debajo de otra */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.2s ease;
    border-left: 5px solid transparent;
    min-width: 140px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
    margin-bottom: 10px;
}

.sensor-block .dato:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.06);
}

.sensor-block .imagenes {
    width: 45px;
    height: 45px;
    object-fit: contain;
    margin-bottom: 10px;
}

.sensor-block .dato-label {
    font-size: 15px;
    font-weight: 500;
    color: #555;
    margin-bottom: 5px;
}

.sensor-block .dato-valor {
    font-weight: 700;
    font-size: 18px;
    color: #222;
}

/* Mapeo de colores EXACTO solicitado por el usuario (Patrón Profesional) */
#sensor-temperatura { 
    background-color: #fee2e2 !important; /* Rojo clarito */
    border-left-color: #ef4444 !important; /* Rojo fuerte */
}
#sensor-hum-suelo { 
    background-color: #e0f2fe !important; /* Azul clarito */
    border-left-color: #0ea5e9 !important; /* Azul fuerte */
}
#sensor-hum-aire { 
    background-color: #fef3c7 !important; /* Amarillo/Naranja clarito */
    border-left-color: #f59e0b !important; /* Amarillo/Naranja fuerte */
}

/* Desktop/Tablet (> 768px): Volver a grid horizontal */
@media screen and (min-width: 769px) {
    #datosSensores .datos {
        flex-wrap: nowrap;
    }
    .sensor-block .dato {
        flex: 1 1 calc(33.333% - 15px);
        margin-bottom: 0;
    }
}


.sensor-chart-container {
    margin-top: 25px;
    padding: 25px;
    background: #ffffff;
    border-radius: 15px;
    border: 1px solid #eee;
    width: 100%;
    height: 400px;
    min-height: 350px;
    box-sizing: border-box;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.02);
}

.sensor-chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

.sensor-chart-title {
    color: #1a1a1a;
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 20px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 1px;
}


.sensor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.sensor-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sensor-title h3 {
    margin: 0;
    font-size: 20px;
    color: #1a1a1a;
    font-weight: 700;
}

.sensor-edit-btn {
    background: #3A7758;
    color: #fff;
    border: none;
    padding: 8px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.sensor-edit-btn:hover {
    background: #2a5640;
}

.sensor-footer {
    margin-top: 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #777;
    background: #fdfdfd;
    padding: 12px 20px;
    border-radius: 12px;
    border: 1px solid #f0f0f0;
}

.sensor-id-badge {
    background: #f0f0f0;
    padding: 4px 10px;
    border-radius: 6px;
    font-family: 'Courier New', Courier, monospace;
    color: #555;
    font-weight: bold;
}

.sensor-header-simple {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin-bottom: 30px;
    min-height: 35px;
}

.sensor-name {
    font-size: 22px;
    font-weight: 800 !important; /* Forzado a Negrita */
    color: #1a1a1a;
    text-align: center;
    padding: 0 40px; /* Evitar que el nombre toque el lápiz si es largo */
    word-break: break-word;
}

.sensor-edit-container {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
}

/* Dark mode adjustments for sensors */
body.dark-mode .sensor-block {
    background: #1e1e1e;
    border-color: #333;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

body.dark-mode .sensor-name {
    color: #ffffff;
}

body.dark-mode .sensor-header {
    border-bottom-color: #333;
}

body.dark-mode .sensor-title h3 {
    color: #fff;
}

body.dark-mode .sensor-footer {
    background: #181818;
    color: #999;
    border-color: #2a2a2a;
}

body.dark-mode .sensor-block .dato {
    background: #1a1a1a;
    border-color: #333;
    color: #eee;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

body.dark-mode .sensor-block .dato .dato-label {
    color: #bbb;
}

body.dark-mode .sensor-block .dato {
    background: #1a1a1a;
    border-color: #333;
}
body.dark-mode .sensor-block .dato .dato-label { color: #bbb; }
body.dark-mode .sensor-block .dato-temp .dato-valor { color: #ff6b6b; }
body.dark-mode .sensor-block .dato-hum-suelo .dato-valor { color: #5dade2; }
body.dark-mode .sensor-block .dato-hum-aire .dato-valor { color: #f4d03f; }



body.dark-mode .sensor-block .dato:hover {
    background: #2a2a2a;
    border-color: #3A7758;
}

body.dark-mode .sensor-chart-container {
    background: #1a1a1a;
    border-color: #333;
}

body.dark-mode .sensor-chart-title {
    color: #efefef;
}

/* ========================================= */
/* WELCOME SCREEN ESTILOS */
/* ========================================= */
.welcome-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 600px;
  max-width: 450px; 
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
  border-radius: 10px;
  background-color: #ffffff;
}

body.dark-mode .welcome-container {
  background-color: #1e1e1e;
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

.welcome-top {
  flex: 0 0 50%;
  background-color: #ffffff;
  position: relative;
  z-index: 2;
  border-bottom-left-radius: 50% 20%;
  border-bottom-right-radius: 50% 20%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 10px -5px rgba(0,0,0,0.1);
}

body.dark-mode .welcome-top {
  background-color: #2c2c2c;
  box-shadow: 0 8px 10px -5px rgba(0,0,0,0.5);
}

.welcome-logo-container {
  text-align: center;
}

.welcome-logo {
  max-width: 400px;
  max-height: 200px;
  object-fit: contain;
}

.welcome-phrase {
  font-size: 22px;
  color: #3A7758;
  font-weight: 700;
  margin-top: 10px;
  margin-bottom: 0;
}

body.dark-mode .welcome-phrase {
  color: #6bbe4c;
}

.welcome-bottom {
  flex: 0 0 50%;
  position: relative;
  background-image: url('../img/agri_backgroundc.png');
  background-size: cover;
  background-position: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  margin-top: -10%; 
  padding-top: 15%;
  z-index: 1;
}

.welcome-bottom::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255, 255, 255, 0.2);
  z-index: -1;
}

body.dark-mode .welcome-bottom::before {
  background: rgba(0, 0, 0, 0.4);
}

.btn-welcome {
  width: 80%;
  max-width: 300px;
  padding: 12px;
  border: none;
  border-radius: 25px;
  font-weight: bold;
  font-size: 16px;
  margin: 6px 0;
  cursor: pointer;
  transition: transform 0.2s, opacity 0.2s;
  color: white;
}

.btn-welcome:hover {
  transform: translateY(-2px);
  opacity: 0.9;
}

.btn-welcome-signup,
.btn-welcome-signin {
  background-color: #3A7758;
}

.forgot-pass {
  font-size: 13px;
  color: #333;
  margin-top: 8px;
  margin-bottom: 20px;
  text-decoration: none;
  font-weight: bold;
}

body.dark-mode .forgot-pass {
  color: #eee;
}

.welcome-separator {
  width: 70%;
  max-width: 250px;
  border: 0;
  height: 2px;
  background-color: #444;
  margin-bottom: 15px;
  border-radius: 2px;
}

body.dark-mode .welcome-separator {
  background-color: #ccc;
}

.btn-welcome-google {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80%;
  max-width: 300px;
  background: transparent;
  border: 2px solid #555;
  border-radius: 25px;
  padding: 10px;
  font-weight: bold;
  font-size: 14px;
  cursor: pointer;
  color: #333;
  margin-bottom: 10px;
  transition: background-color 0.2s;
}

.btn-welcome-google:hover {
  background-color: rgba(0,0,0,0.05);
}

body.dark-mode .btn-welcome-google {
  border-color: #ddd;
  color: #ddd;
}

body.dark-mode .btn-welcome-google:hover {
  background-color: rgba(255,255,255,0.05);
}

.welcome-footer-icon {
  margin-top: auto;
  margin-bottom: 5px;
}

@media (min-width: 768px) {
  .welcome-container {
    height: 700px;
    margin-top: 40px;
    margin-bottom: 40px;
    border: 1px solid #ddd;
  }
  body.dark-mode .welcome-container {
    border-color: #444;
  }
}

/* ================= PREGUNTAS FRECUENTES ================= */
.faq-container {
    padding: 30px 20px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
}

.faq-list {
    width: 100%;
    margin-top: 30px;
    text-align: left;
}

.faq-item {
    border-bottom: 1px solid #eee;
    margin-bottom: 5px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.faq-item:last-child {
    border-bottom: none;
}

.faq-question {
    font-size: 16px;
    font-weight: 600;
    padding: 18px 15px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #333;
    background: #fdfdfd;
    transition: background 0.3s ease, color 0.3s ease;
    border-radius: 8px;
}

.faq-question:hover {
    background-color: #f4f8f5;
    color: #3A7758;
}

.faq-icon {
    font-size: 24px;
    font-weight: 300;
    color: #3A7758;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.faq-answer {
    padding: 0 15px;
    max-height: 0;
    font-size: 15px;
    color: #666;
    line-height: 1.6;
    opacity: 0;
    visibility: hidden;
    transition: max-height 0.4s ease, padding 0.4s ease, opacity 0.4s ease, visibility 0.4s ease;
}

.faq-item.active .faq-answer {
    padding: 10px 15px 20px 15px;
    max-height: 500px;
    opacity: 1;
    visibility: visible;
}

  flex: 0 0 50%;
  position: relative;
  background-image: url('../img/agri_background.png');
  background-size: cover;
  background-position: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  margin-top: -10%; 
  padding-top: 15%;
  z-index: 1;
}

.welcome-bottom::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255, 255, 255, 0.2);
  z-index: -1;
}

body.dark-mode .welcome-bottom::before {
  background: rgba(0, 0, 0, 0.4);
}

.btn-welcome {
  width: 80%;
  max-width: 300px;
  padding: 12px;
  border: none;
  border-radius: 25px;
  font-weight: bold;
  font-size: 16px;
  margin: 6px 0;
  cursor: pointer;
  transition: transform 0.2s, opacity 0.2s;
  color: white;
}

.btn-welcome:hover {
  transform: translateY(-2px);
  opacity: 0.9;
}

.btn-welcome-signup,
.btn-welcome-signin {
  background-color: #3A7758;
}

.forgot-pass {
  font-size: 13px;
  color: #333;
  margin-top: 8px;
  margin-bottom: 20px;
  text-decoration: none;
  font-weight: bold;
}

body.dark-mode .forgot-pass {
  color: #eee;
}

.welcome-separator {
  width: 70%;
  max-width: 250px;
  border: 0;
  height: 2px;
  background-color: #444;
  margin-bottom: 15px;
  border-radius: 2px;
}

body.dark-mode .welcome-separator {
  background-color: #ccc;
}

.btn-welcome-google {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80%;
  max-width: 300px;
  background: transparent;
  border: 2px solid #555;
  border-radius: 25px;
  padding: 10px;
  font-weight: bold;
  font-size: 14px;
  cursor: pointer;
  color: #333;
  margin-bottom: 10px;
  transition: background-color 0.2s;
}

.btn-welcome-google:hover {
  background-color: rgba(0,0,0,0.05);
}

body.dark-mode .btn-welcome-google {
  border-color: #ddd;
  color: #ddd;
}

body.dark-mode .btn-welcome-google:hover {
  background-color: rgba(255,255,255,0.05);
}

.welcome-footer-icon {
  margin-top: auto;
  margin-bottom: 5px;
}

@media (min-width: 768px) {
  .welcome-container {
    height: 700px;
    margin-top: 40px;
    margin-bottom: 40px;
    border: 1px solid #ddd;
  }
  body.dark-mode .welcome-container {
    border-color: #444;
  }
}

/* ================= PREGUNTAS FRECUENTES ================= */
.faq-container {
    padding: 30px 20px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
}

.faq-list {
    width: 100%;
    margin-top: 30px;
    text-align: left;
}

.faq-item {
    border-bottom: 1px solid #eee;
    margin-bottom: 5px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.faq-item:last-child {
    border-bottom: none;
}

.faq-question {
    font-size: 16px;
    font-weight: 600;
    padding: 18px 15px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #333;
    background: #fdfdfd;
    transition: background 0.3s ease, color 0.3s ease;
    border-radius: 8px;
}

.faq-question:hover {
    background-color: #f4f8f5;
    color: #3A7758;
}

.faq-icon {
    font-size: 24px;
    font-weight: 300;
    color: #3A7758;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.faq-answer {
    padding: 0 15px;
    max-height: 0;
    font-size: 15px;
    color: #666;
    line-height: 1.6;
    opacity: 0;
    visibility: hidden;
    transition: max-height 0.4s ease, padding 0.4s ease, opacity 0.4s ease, visibility 0.4s ease;
}

.faq-item.active .faq-answer {
    padding: 10px 15px 20px 15px;
    max-height: 500px;
    opacity: 1;
    visibility: visible;
}

.faq-item.active .faq-icon {
    transform: rotate(45deg);
    color: #d32f2f;
}

body.dark-mode .faq-container { background: #1e1e1e; box-shadow: 0 4px 20px rgba(0,0,0,0.3); border: 1px solid #333; }
body.dark-mode .faq-item { border-bottom-color: #2c2c2c; }
body.dark-mode .faq-question { background: #252525; color: #ffffff; }
body.dark-mode .faq-question:hover { background-color: #2a312c; color: #b6d2c1; }
body.dark-mode .faq-answer { color: #ffffff; }


/* ================= CONTACTO ================= */
.contacto-info {
    max-width: 600px;
    margin: 30px auto 10px auto;
    font-size: 16px;
    color: #444;
}

.contacto-desc {
    margin-bottom: 35px;
    line-height: 1.6;
    color: #555;
    font-size: 17px;
}

.contacto-item {
    display: flex;
    align-items: center;
    background: #fff;
    padding: 20px 25px;
    margin-bottom: 20px;
    border-radius: 12px;
    border-left: 6px solid #3A7758;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
    text-align: left;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.contacto-item:hover {
    transform: translateX(5px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.06);
}

.contacto-icono {
    font-size: 28px;
    margin-right: 20px;
    background: #f4f8f5;
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
}

.contacto-texto {
    flex: 1;
    margin-left: 10px;
}

.contacto-texto strong {
    color: #2c3e50;
    display: block;
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

body.dark-mode .contacto-desc { color: #ffffff; }
body.dark-mode .contacto-info { color: #ffffff; }
body.dark-mode .contacto-item { background: #252525; border-left-color: #5bb385; box-shadow: 0 2px 10px rgba(0,0,0,0.3); }
body.dark-mode .contacto-item:hover { box-shadow: 0 4px 15px rgba(0,0,0,0.5); }
body.dark-mode .contacto-texto { color: #ffffff; }
body.dark-mode .contacto-texto strong { color: #ffffff; }
body.dark-mode .contacto-icono { background: #2a312c; }

/* ================= CHATBOT ================= */
.chatbot-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: #3A7758;
    color: white;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    cursor: pointer;
    z-index: 9999;
    transition: transform 0.3s ease, background-color 0.3s;
}

.chatbot-btn:hover {
    transform: scale(1.1);
    background-color: #2c5a43;
}

.chatbot-window {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 350px;
    max-width: calc(100vw - 40px);
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.3);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    border: 1px solid #e0e0e0;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.chatbot-window.active {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

.chatbot-header {
    background-color: #3A7758;
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

.chatbot-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chatbot-close {
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
}

.chatbot-messages {
    height: 350px;
    max-height: 60vh;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background-color: #f9f9f9;
}

.chat-message {
    padding: 10px 15px;
    border-radius: 15px;
    max-width: 85%;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.bot-message {
    background-color: #e3f2fd;
    color: #1565c0;
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}

.user-message {
    background-color: #3A7758;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

.chatbot-input {
    display: flex;
    padding: 10px;
    background-color: #fff;
    border-top: 1px solid #e0e0e0;
    align-items: center;
}

.chatbot-input input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 20px;
    outline: none;
    margin: 0;
    font-size: 14px;
}

.chatbot-input button {
    background-color: #3A7758;
    color: white;
    border: none;
    border-radius: 20px;
    padding: 10px 15px;
    margin-left: 10px;
    margin-bottom: 0px;
    margin-top: 0px;
    cursor: pointer;
    font-weight: 600;
    width: auto;
}

.chatbot-input button:hover {
    background-color: #2c5a43;
    color: white;
}

/* Chatbot Dark Mode */
body.dark-mode .chatbot-window { background-color: #1e1e1e; border-color: #333; box-shadow: 0 5px 25px rgba(0,0,0,0.8); }
body.dark-mode .chatbot-header { background-color: #2c2c2c; }
body.dark-mode .chatbot-messages { background-color: #181818; }
body.dark-mode .bot-message { background-color: #2c3e50; color: #e0e0e0; }
body.dark-mode .user-message { background-color: #4caf50; }
body.dark-mode .chatbot-input { background-color: #1e1e1e; border-color: #333; }
body.dark-mode .chatbot-input input { background-color: #2c2c2c; color: white; border-color: #444; }
body.dark-mode .chatbot-btn { background-color: #4caf50; }
body.dark-mode .chatbot-btn:hover { background-color: #388e3c; }


/* ================================================================
   PANEL HISTÓRICO DE SENSORES
   Añadir al final de style.css
   ================================================================ */

/* ── Panel contenedor ── */
.historico-panel {
    margin-top: 18px;
    border-top: 1px solid #e0ece6;
    padding-top: 16px;
}

.historico-titulo {
    font-size: 14px;
    font-weight: 600;
    color: #3A7758;
    margin-bottom: 12px;
    letter-spacing: 0.3px;
}

/* ── Filtros ── */
.historico-filtros {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    background: #f7faf8;
    border: 1px solid #d0e8db;
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 14px;
}

.historico-filtros label {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 11px;
    color: #3a4f66;
    font-weight: 500;
}

.historico-filtros select,
.historico-filtros input[type="date"] {
    padding: 7px 10px;
    border: 1px solid #B6D2C1;
    border-radius: 7px;
    font-size: 12px;
    background: #ffffff;
    color: #1f2d3d;
    cursor: pointer;
    min-width: 110px;
}

.historico-filtros select:focus,
.historico-filtros input:focus {
    outline: none;
    border-color: #3A7758;
    box-shadow: 0 0 0 2px rgba(58,119,88,0.12);
}

/* ── Botones filtros ── */
.hist-btn {
    padding: 8px 14px;
    border: none;
    border-radius: 7px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s;
    align-self: flex-end;
}

.hist-btn-aplicar {
    background: #3A7758;
    color: white;
}
.hist-btn-aplicar:hover { background: #2d5e44; }

.hist-btn-limpiar {
    background: #ffffff;
    color: #3A7758;
    border: 1.5px solid #3A7758;
}
.hist-btn-limpiar:hover { background: #B6D2C1; }

.hist-btn-pdf {
    background: #1565c0;
    color: white;
}
.hist-btn-pdf:hover  { background: #0d47a1; }
.hist-btn-pdf:disabled {
    background: #b0bec5;
    cursor: not-allowed;
}

/* ── Gráfica ── */
.historico-grafica-wrap {
    background: #ffffff;
    border-radius: 10px;
    border: 1px solid #e0ece6;
    padding: 14px;
    margin-bottom: 12px;
    height: 260px;
}

/* ── Stats ── */
.historico-stats {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.hist-stat-card {
    flex: 1;
    min-width: 140px;
    background: #ffffff;
    border: 1px solid #e0ece6;
    border-radius: 9px;
    padding: 12px 14px;
}

.hist-stat-periodo {
    font-size: 10px;
    color: #3A7758;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 7px;
}

.hist-stat-fila {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    padding: 2px 0;
    color: #3a4f66;
}

.hist-stat-val {
    font-weight: 700;
}

/* ── Tabla ── */
.historico-tabla-wrap {
    overflow-x: auto;
    margin-bottom: 8px;
}

.historico-tabla {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.historico-tabla th {
    background: #3A7758;
    color: white;
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
}

.historico-tabla td {
    padding: 6px 12px;
    border-bottom: 1px solid #eef3f0;
    color: #2c2c2c;
}

.historico-tabla tr:hover td { background: #f7faf8; }

.hist-badge-p1 {
    background: #e8f5e9;
    color: #2e7d32;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.hist-badge-p2 {
    background: #e3f2fd;
    color: #1565c0;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

/* ── Dark mode ── */
body.dark-mode .historico-panel      { border-top-color: #444; }
body.dark-mode .historico-filtros    { background: #1e2a1e; border-color: #3a5a3a; }
body.dark-mode .historico-filtros select,
body.dark-mode .historico-filtros input { background: #2a3a2a; color: #eee; border-color: #4a7a5a; }
body.dark-mode .historico-filtros label { color: #aaa; }
body.dark-mode .hist-stat-card       { background: #1e2a1e; border-color: #3a5a3a; }
body.dark-mode .hist-stat-fila       { color: #ccc; }
body.dark-mode .historico-grafica-wrap { background: #1e2a1e; border-color: #3a5a3a; }
body.dark-mode .historico-tabla th   { background: #2d5e44; }
body.dark-mode .historico-tabla td   { border-color: #333; color: #ddd; }
body.dark-mode .historico-tabla tr:hover td { background: #1e2a1e; }
body.dark-mode .hist-btn-limpiar     { background: #1e2a1e; color: #7BB6F9; border-color: #7BB6F9; }




/* ================================================================
   PANEL HISTÓRICO DE SENSORES — centrado en todos los dispositivos
   ================================================================ */

.historico-panel {
    margin-top: 20px;
    border-top: 2px solid #e0ece6;
    padding-top: 20px;
    width: 100%;
    box-sizing: border-box;
}

.historico-titulo {
    font-size: 16px;
    font-weight: 700;
    color: #3A7758;
    margin-bottom: 16px;
}

/* ── Contenedor filtros ── */
.historico-filtros {
    background: #f7faf8;
    border: 1px solid #d0e8db;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ── Grid de inputs: 1 columna en móvil ── */
.hist-fila-inputs {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    width: 100%;
}

/* ── Cada label ocupa todo el ancho ── */
.historico-filtros label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: #3a4f66;
    font-weight: 600;
    width: 100%;
    box-sizing: border-box;
}

/* ── Inputs y selects al 100% ── */
.historico-filtros select,
.historico-filtros input[type="date"] {
    padding: 12px 14px;
    border: 1.5px solid #B6D2C1;
    border-radius: 8px;
    font-size: 15px;
    background: #fff;
    color: #1f2d3d;
    width: 100%;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
}

.historico-filtros select:focus,
.historico-filtros input:focus {
    outline: none;
    border-color: #3A7758;
    box-shadow: 0 0 0 3px rgba(58,119,88,0.15);
}

/* ── Botones: columna, 100% ancho ── */
.hist-fila-botones {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.hist-btn {
    padding: 14px 10px;
    border: none;
    border-radius: 9px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 700;
    transition: all 0.2s;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    display: block;
}

.hist-btn-aplicar       { background: #3A7758; color: white; }
.hist-btn-aplicar:hover { background: #2d5e44; }
.hist-btn-limpiar       { background: #fff; color: #3A7758; border: 2px solid #3A7758; }
.hist-btn-limpiar:hover { background: #e8f5e9; }
.hist-btn-pdf           { background: #1565c0; color: white; }
.hist-btn-pdf:hover     { background: #0d47a1; }
.hist-btn-pdf:disabled  { background: #b0bec5; cursor: not-allowed; }

/* ── Gráfica ── */
.historico-grafica-wrap {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e0ece6;
    padding: 16px;
    margin-bottom: 14px;
    height: 280px;
    width: 100%;
    box-sizing: border-box;
}

/* ── Stats ── */
.historico-stats {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
    width: 100%;
}

.hist-stat-card {
    background: #fff;
    border: 1px solid #e0ece6;
    border-radius: 10px;
    padding: 14px 16px;
    width: 100%;
    box-sizing: border-box;
}

.hist-stat-periodo {
    font-size: 12px;
    color: #3A7758;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.hist-stat-fila {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    padding: 5px 0;
    color: #3a4f66;
    border-bottom: 1px solid #f0f4f2;
}
.hist-stat-fila:last-child { border-bottom: none; }
.hist-stat-val { font-weight: 700; font-size: 15px; }

/* ── Tabla ── */
.historico-tabla-wrap {
    overflow-x: auto;
    margin-bottom: 10px;
    border-radius: 10px;
    border: 1px solid #e0ece6;
    width: 100%;
    box-sizing: border-box;
}

.historico-tabla {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.historico-tabla th {
    background: #3A7758;
    color: white;
    padding: 12px 14px;
    text-align: left;
    font-weight: 700;
    font-size: 13px;
}

.historico-tabla td {
    padding: 10px 14px;
    border-bottom: 1px solid #eef3f0;
    color: #2c2c2c;
    font-size: 14px;
}

.historico-tabla tr:hover td { background: #f7faf8; }

.hist-badge-p1 {
    background: #e8f5e9;
    color: #2e7d32;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    display: inline-block;
}

.hist-badge-p2 {
    background: #e3f2fd;
    color: #1565c0;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    display: inline-block;
}

/* ── Tablet (≥ 600px): inputs en 2×2 ── */
@media (min-width: 600px) {
    .hist-fila-inputs {
        grid-template-columns: 1fr 1fr;
    }
    .hist-fila-botones {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        gap: 10px;
    }
    .historico-stats {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .hist-stat-card {
        flex: 1;
        min-width: 140px;
        width: auto;
    }
}

/* ── Escritorio (≥ 960px): todo en fila ── */
@media (min-width: 960px) {
    .historico-filtros {
        flex-direction: row;
        align-items: flex-end;
        gap: 16px;
    }
    .hist-fila-inputs {
        grid-template-columns: repeat(4, 1fr);
        flex: 1;
        margin-bottom: 0;
    }
    .hist-fila-botones {
        display: flex;
        flex-direction: column;
        gap: 8px;
        width: 160px;
        flex-shrink: 0;
    }
    .hist-btn {
        padding: 11px 14px;
        font-size: 13px;
    }
}

/* ── Dark mode ── */
body.dark-mode .historico-panel         { border-top-color: #3a5a3a; }
body.dark-mode .historico-filtros       { background: #1a2a1a; border-color: #3a5a3a; }
body.dark-mode .historico-filtros select,
body.dark-mode .historico-filtros input { background: #243024; color: #eee; border-color: #4a7a5a; }
body.dark-mode .historico-filtros label { color: #aac4aa; }
body.dark-mode .hist-btn-limpiar        { background: #1a2a1a; color: #7BB6F9; border-color: #7BB6F9; }
body.dark-mode .historico-grafica-wrap  { background: #1a2a1a; border-color: #3a5a3a; }
body.dark-mode .hist-stat-card          { background: #1a2a1a; border-color: #3a5a3a; }
body.dark-mode .hist-stat-fila          { color: #ccc; border-bottom-color: #2a3a2a; }
body.dark-mode .historico-tabla-wrap    { border-color: #3a5a3a; }
body.dark-mode .historico-tabla th      { background: #2d5e44; }
body.dark-mode .historico-tabla td      { border-color: #2a3a2a; color: #ddd; }
body.dark-mode .historico-tabla tr:hover td { background: #1a2a1a; }
