:root {
    --azul-principal: #1565c0;
    --azul-oscuro: #0d47a1;
    --azul-claro: #e8f1fc;

    --verde: #168447;
    --verde-fondo: #e3f7eb;

    --rojo: #c62828;
    --rojo-fondo: #fde8e8;

    --amarillo: #a86400;

    --texto: #172033;
    --texto-secundario: #667085;

    --fondo: #f2f6fa;
    --blanco: #ffffff;

    --borde: #e3e8ef;

    --sombra:
        0 12px 30px rgba(21, 55, 91, 0.10);
}


/* ==============================
   CONFIGURACIÓN GENERAL
============================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}


body {
    min-height: 100vh;

    background: var(--fondo);
    color: var(--texto);

    font-family:
        Arial,
        Helvetica,
        sans-serif;
}


button,
select {
    font: inherit;
}


/* ==============================
   ENCABEZADO
============================== */

.encabezado {
    display: flex;
    justify-content: space-between;
    align-items: center;

    gap: 25px;

    padding: 30px 7%;

    color: var(--blanco);

    background:
        linear-gradient(
            120deg,
            var(--azul-oscuro),
            var(--azul-principal)
        );
}


.encabezado h1 {
    font-size: clamp(
        1.6rem,
        3vw,
        2.4rem
    );
}


.encabezado p {
    margin-top: 8px;

    color: rgba(
        255,
        255,
        255,
        0.84
    );
}


.fecha-hora {
    min-width: 155px;

    display: flex;
    flex-direction: column;
    align-items: flex-end;

    gap: 5px;

    font-weight: bold;
}


.fecha-hora #hora {
    font-size: 1.3rem;
}

/* ==============================
   BOTÓN CERRAR SESIÓN
============================== */

.boton-cerrar-sesion {
    margin-top: 10px;

    padding: 9px 16px;

    color: var(--blanco);
    background:
        rgba(
            255,
            255,
            255,
            0.12
        );

    border:
        1px solid
        rgba(
            255,
            255,
            255,
            0.45
        );

    border-radius: 10px;

    font-size: 0.84rem;
    font-weight: bold;

    cursor: pointer;

    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        transform 0.2s ease,
        opacity 0.2s ease;
}


.boton-cerrar-sesion:hover:not(:disabled) {
    background:
        rgba(
            255,
            255,
            255,
            0.22
        );

    border-color:
        rgba(
            255,
            255,
            255,
            0.7
        );

    transform:
        translateY(-1px);
}


.boton-cerrar-sesion:active:not(:disabled) {
    transform:
        translateY(0);
}


.boton-cerrar-sesion:disabled {
    opacity: 0.6;

    cursor: not-allowed;
}
/* ==============================
   CONTENEDOR PRINCIPAL
============================== */

.contenedor {
    width: min(
        1400px,
        92%
    );

    margin: 35px auto;
}


/* ==============================
   RESUMEN GENERAL
============================== */

.resumen {
    display: grid;

    grid-template-columns:
        repeat(
            3,
            minmax(0, 1fr)
        );

    gap: 20px;

    margin-bottom: 28px;
}


.resumen-card {
    display: flex;
    align-items: center;

    gap: 18px;

    padding: 24px;

    background: var(--blanco);

    border: 1px solid var(--borde);
    border-radius: 18px;

    box-shadow: var(--sombra);
}


.resumen-icono {
    width: 58px;
    height: 58px;

    display: grid;
    place-items: center;

    flex-shrink: 0;

    border-radius: 16px;

    background: var(--azul-claro);

    font-size: 1.8rem;
}


.resumen-card p {
    margin-bottom: 6px;

    color: var(--texto-secundario);

    font-size: 0.93rem;
}


.resumen-card strong {
    font-size: 1.55rem;
}


/* ==============================
   TARJETAS DE SENSORES
============================== */

.sensores {
    display: grid;

    grid-template-columns:
        repeat(
            3,
            minmax(0, 1fr)
        );

    gap: 22px;

    margin-bottom: 30px;
}


.sensor-card {
    padding: 25px;

    background: var(--blanco);

    border: 1px solid var(--borde);
    border-radius: 20px;

    box-shadow: var(--sombra);

    transition:
        transform 0.25s ease,
        box-shadow 0.25s ease;
}


.sensor-card:hover {
    transform: translateY(-5px);

    box-shadow:
        0 18px 35px
        rgba(21, 55, 91, 0.16);
}


.sensor-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;

    gap: 12px;

    padding-bottom: 20px;

    border-bottom:
        1px solid var(--borde);
}


.sensor-numero {
    margin-bottom: 5px;

    color: var(--azul-principal);

    font-size: 0.8rem;
    font-weight: bold;
    letter-spacing: 1px;
    text-transform: uppercase;
}


.sensor-header h2 {
    font-size: 1.35rem;
}


/* ==============================
   ESTADOS
============================== */

.estado {
    display: inline-flex;
    align-items: center;

    padding: 7px 11px;

    border-radius: 999px;

    font-size: 0.78rem;
    font-weight: bold;
}


.estado-online {
    color: var(--verde);
    background: var(--verde-fondo);
}


.estado-offline {
    color: var(--rojo);
    background: var(--rojo-fondo);
}


.estado-espera {
    color: var(--texto-secundario);
    background: #eef1f5;
}


/* ==============================
   MEDICIONES
============================== */

.mediciones {
    display: grid;

    gap: 16px;

    margin-top: 22px;
}


.medicion {
    display: flex;
    align-items: center;

    gap: 15px;

    padding: 16px;

    background: #f8fafc;

    border-radius: 15px;
}


.medicion-icono {
    width: 45px;
    height: 45px;

    display: grid;
    place-items: center;

    flex-shrink: 0;

    border-radius: 13px;

    background: var(--azul-claro);

    font-size: 1.4rem;
}


.medicion p {
    margin-bottom: 5px;

    color: var(--texto-secundario);

    font-size: 0.84rem;
}


.medicion strong {
    font-size: 1.45rem;
}


/* ==============================
   ÚLTIMA ACTUALIZACIÓN
============================== */

.ultima-actualizacion {
    margin-top: 18px;
    padding-top: 15px;

    border-top:
        1px solid var(--borde);

    color: var(--texto-secundario);

    font-size: 0.82rem;
}


.ultima-actualizacion span {
    color: var(--texto);
    font-weight: bold;
}


/* ==============================
   GRÁFICAS
============================== */

.graficas {
    display: grid;

    grid-template-columns:
        repeat(
            2,
            minmax(0, 1fr)
        );

    gap: 22px;
}


.grafica-card {
    min-width: 0;

    padding: 25px;

    background: var(--blanco);

    border: 1px solid var(--borde);
    border-radius: 20px;

    box-shadow: var(--sombra);
}


.grafica-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;

    gap: 20px;

    margin-bottom: 22px;
}


.grafica-subtitulo {
    margin-bottom: 5px;

    color: var(--azul-principal);

    font-size: 0.78rem;
    font-weight: bold;
    letter-spacing: 0.8px;
    text-transform: uppercase;
}


.grafica-header h2 {
    font-size: 1.25rem;
}


.grafica-unidad {
    min-width: 45px;
    height: 45px;

    display: grid;
    place-items: center;

    flex-shrink: 0;

    border-radius: 13px;

    color: var(--azul-principal);
    background: var(--azul-claro);

    font-size: 1rem;
    font-weight: bold;
}


.contenedor-canvas {
    position: relative;

    width: 100%;
    height: 330px;
}


/* ==============================
   HISTORIAL AMBIENTAL
============================== */

.historial-seccion {
    margin-top: 30px;
    padding: 28px;

    background: var(--blanco);

    border: 1px solid var(--borde);
    border-radius: 20px;

    box-shadow: var(--sombra);
}


.historial-encabezado {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;

    gap: 20px;

    margin-bottom: 24px;
}


.historial-encabezado h2 {
    font-size: 1.45rem;
}


/* ==============================
   FILTROS DEL HISTORIAL
============================== */

.historial-filtros {
    display: grid;

    grid-template-columns:
        minmax(210px, 1fr)
        minmax(210px, 1fr)
        auto;

    align-items: end;

    gap: 16px;

    padding: 20px;

    background: #f8fafc;

    border: 1px solid var(--borde);
    border-radius: 16px;
}


.campo-filtro {
    display: flex;
    flex-direction: column;

    gap: 8px;
}


.campo-filtro label {
    color: var(--texto-secundario);

    font-size: 0.85rem;
    font-weight: bold;
}


.campo-filtro select {
    width: 100%;

    padding: 12px 13px;

    color: var(--texto);
    background: var(--blanco);

    border: 1px solid #cfd7e3;
    border-radius: 10px;

    outline: none;
}


.campo-filtro select:focus {
    border-color: var(--azul-principal);

    box-shadow:
        0 0 0 3px
        rgba(21, 101, 192, 0.12);
}


/* ==============================
   BOTONES
============================== */

.boton {
    min-height: 43px;

    padding: 11px 18px;

    border: 0;
    border-radius: 10px;

    font-weight: bold;

    cursor: pointer;

    transition:
        transform 0.18s ease,
        opacity 0.18s ease,
        background 0.18s ease;
}


.boton:hover:not(:disabled) {
    transform: translateY(-1px);
}


.boton:disabled {
    opacity: 0.55;

    cursor: not-allowed;
}


.boton-principal {
    color: var(--blanco);
    background: var(--azul-principal);
}


.boton-principal:hover:not(:disabled) {
    background: var(--azul-oscuro);
}


.boton-secundario {
    color: var(--azul-principal);
    background: var(--azul-claro);
}


/* ==============================
   MENSAJES DEL HISTORIAL
============================== */

.mensaje-historial {
    margin: 18px 0;

    color: var(--texto-secundario);

    font-size: 0.9rem;
}


.mensaje-cargando {
    color: var(--azul-principal);
}


.mensaje-exito {
    color: var(--verde);
}


.mensaje-error {
    color: var(--rojo);
}


.mensaje-vacio {
    color: var(--amarillo);
}


/* ==============================
   ESTADÍSTICAS DEL HISTORIAL
============================== */

.estadisticas-historial {
    display: grid;

    grid-template-columns:
        repeat(
            3,
            minmax(0, 1fr)
        );

    gap: 15px;

    margin-bottom: 22px;
}


.estadistica-card {
    padding: 18px;

    background: #f8fafc;

    border: 1px solid var(--borde);
    border-radius: 14px;
}


.estadistica-card p {
    margin-bottom: 7px;

    color: var(--texto-secundario);

    font-size: 0.82rem;
}


.estadistica-card strong {
    font-size: 1.25rem;
}


/* ==============================
   TABLA DEL HISTORIAL
============================== */

.tabla-contenedor {
    width: 100%;

    overflow-x: auto;

    border: 1px solid var(--borde);
    border-radius: 14px;
}


.tabla-historial {
    width: 100%;

    min-width: 720px;

    border-collapse: collapse;
}


.tabla-historial th,
.tabla-historial td {
    padding: 14px 16px;

    text-align: left;

    border-bottom: 1px solid var(--borde);
}


.tabla-historial th {
    color: var(--texto-secundario);
    background: #f8fafc;

    font-size: 0.8rem;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}


.tabla-historial tbody tr:hover {
    background: #f8fbff;
}


.tabla-historial tbody tr:last-child td {
    border-bottom: 0;
}


.tabla-vacia {
    padding: 30px !important;

    text-align: center !important;

    color: var(--texto-secundario);
}


/* ==============================
   PAGINACIÓN
============================== */

.paginacion {
    display: flex;
    justify-content: center;
    align-items: center;

    gap: 16px;

    margin-top: 20px;
}


.paginacion span {
    color: var(--texto-secundario);

    font-size: 0.9rem;
    font-weight: bold;
}


.boton-pagina {
    padding: 9px 15px;

    color: var(--azul-principal);
    background: var(--blanco);

    border: 1px solid var(--azul-principal);
    border-radius: 9px;

    font-weight: bold;

    cursor: pointer;
}


.boton-pagina:hover:not(:disabled) {
    color: var(--blanco);
    background: var(--azul-principal);
}


.boton-pagina:disabled {
    color: #9ca3af;

    background: var(--blanco);

    border-color: #d1d5db;

    cursor: not-allowed;
}


/* ==============================
   COLORES DEL ESTADO GENERAL
============================== */

.texto-online {
    color: var(--verde);
}


.texto-advertencia {
    color: var(--amarillo);
}


.texto-offline {
    color: var(--rojo);
}


/* ==============================
   ANIMACIÓN AL RECIBIR DATOS
============================== */

.sensor-actualizado {
    animation:
        recibirDato 0.65s ease;
}


@keyframes recibirDato {

    0% {
        box-shadow:
            0 0 0
            rgba(21, 101, 192, 0);
    }

    45% {
        box-shadow:
            0 0 0 5px
            rgba(21, 101, 192, 0.16),
            var(--sombra);
    }

    100% {
        box-shadow:
            var(--sombra);
    }
}


/* ==============================
   PIE DE PÁGINA
============================== */

footer {
    padding: 24px;

    text-align: center;

    color: var(--texto-secundario);

    font-size: 0.86rem;
}


/* ==============================
   TABLET
============================== */

@media (max-width: 1000px) {

    .resumen,
    .sensores {
        grid-template-columns:
            repeat(
                2,
                minmax(0, 1fr)
            );
    }


    .graficas {
        grid-template-columns: 1fr;
    }


    .historial-filtros {
        grid-template-columns:
            repeat(
                2,
                minmax(0, 1fr)
            );
    }


    .historial-filtros .boton {
        grid-column: 1 / -1;
    }

}


/* ==============================
   CELULAR
============================== */

@media (max-width: 700px) {

    .encabezado {
        align-items: flex-start;
        flex-direction: column;
    }


    .fecha-hora {
        align-items: flex-start;
    }


    .resumen,
    .sensores,
    .estadisticas-historial {
        grid-template-columns: 1fr;
    }


    .contenedor {
        width: 90%;

        margin-top: 25px;
    }


    .grafica-card,
    .historial-seccion {
        padding: 18px;
    }


    .contenedor-canvas {
        height: 290px;
    }


    .historial-encabezado {
        flex-direction: column;
    }


    .historial-encabezado .boton {
        width: 100%;
    }


    .historial-filtros {
        grid-template-columns: 1fr;
    }


    .historial-filtros .boton {
        grid-column: auto;
    }


    .paginacion {
        flex-wrap: wrap;
    }

}
/* ==============================
   LOGIN
============================== */

.login-body {
    min-height: 100vh;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 30px 20px;

    background:
        linear-gradient(
            135deg,
            #eaf2fb,
            #f6f9fc
        );
}


.login-contenedor {
    width: 100%;
    max-width: 460px;
}


.login-card {
    overflow: hidden;

    background: var(--blanco);

    border:
        1px solid
        var(--borde);

    border-radius: 24px;

    box-shadow:
        0 20px 50px
        rgba(21, 55, 91, 0.16);
}


.login-encabezado {
    padding:
        34px
        34px
        24px;

    text-align: center;
}


.login-logo {
    width: 150px;
    max-width: 70%;

    margin-bottom: 18px;
}


.login-encabezado h1 {
    margin-bottom: 10px;

    color: var(--texto);

    font-size: 1.8rem;
}


.login-descripcion {
    color: var(--texto-secundario);

    font-size: 0.96rem;
    line-height: 1.5;
}


.login-indicacion {
    margin-top: 10px;

    color: var(--azul-principal);

    font-size: 0.86rem;
    font-weight: bold;
}


.login-form {
    display: grid;

    gap: 20px;

    padding:
        0
        34px
        30px;
}


.login-campo {
    display: grid;

    gap: 8px;
}


.login-campo label {
    color: var(--texto);

    font-size: 0.9rem;
    font-weight: bold;
}


.login-campo input {
    width: 100%;

    padding:
        13px
        14px;

    color: var(--texto);
    background: #f9fbfd;

    border:
        1px solid
        #cfd7e3;

    border-radius: 11px;

    outline: none;

    font-size: 0.95rem;

    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        background 0.2s ease;
}


.login-campo input:focus {
    background: var(--blanco);

    border-color:
        var(--azul-principal);

    box-shadow:
        0 0 0 3px
        rgba(21, 101, 192, 0.12);
}


.password-contenedor {
    display: grid;

    grid-template-columns:
        1fr
        auto;

    align-items: stretch;
}


.password-contenedor input {
    border-radius:
        11px
        0
        0
        11px;
}


.boton-password {
    min-width: 48px;

    display: grid;
    place-items: center;

    background:
        var(--azul-claro);

    border:
        1px solid
        #cfd7e3;

    border-left: 0;

    border-radius:
        0
        11px
        11px
        0;

    cursor: pointer;

    font-size: 1rem;
}


.boton-password:hover {
    background: #dbeafe;
}


.boton-login {
    width: 100%;

    min-height: 47px;

    padding:
        12px
        18px;

    color: var(--blanco);

    background:
        linear-gradient(
            120deg,
            var(--azul-oscuro),
            var(--azul-principal)
        );

    border: 0;

    border-radius: 11px;

    font-size: 0.95rem;
    font-weight: bold;

    cursor: pointer;

    transition:
        transform 0.18s ease,
        opacity 0.18s ease,
        box-shadow 0.18s ease;
}


.boton-login:hover:not(:disabled) {
    transform:
        translateY(-1px);

    box-shadow:
        0 8px 20px
        rgba(21, 101, 192, 0.22);
}


.boton-login:disabled {
    opacity: 0.65;

    cursor: not-allowed;
}


.login-mensaje {
    min-height: 20px;

    margin: 0;

    text-align: center;

    font-size: 0.86rem;
    font-weight: bold;
}


.login-mensaje-error {
    color: var(--rojo);
}


.login-mensaje-exito {
    color: var(--verde);
}


.login-mensaje-cargando {
    color: var(--azul-principal);
}


.login-pie {
    padding:
        18px
        25px;

    text-align: center;

    color: var(--texto-secundario);

    background: #f8fafc;

    border-top:
        1px solid
        var(--borde);

    font-size: 0.8rem;
}


/* ==============================
   LOGIN RESPONSIVE
============================== */

@media (max-width: 520px) {

    .login-body {
        padding: 18px;
    }


    .login-encabezado {
        padding:
            28px
            22px
            20px;
    }


    .login-form {
        padding:
            0
            22px
            25px;
    }


    .login-logo {
        width: 130px;
    }


    .login-encabezado h1 {
        font-size: 1.55rem;
    }
}


/* =========================================================
   AJUSTES RESPONSIVE ADICIONALES
   Adaptación para escritorio, tabletas y teléfonos
   Se conservan los estilos y colores originales.
========================================================= */

html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

.contenedor,
.resumen-card,
.sensor-card,
.grafica-card,
.historial-seccion,
.estadistica-card,
.encabezado > *,
.historial-encabezado > *,
.grafica-header > * {
    min-width: 0;
}

button,
select {
    max-width: 100%;
}

@media (max-width: 1200px) {
    .encabezado {
        padding-left: 4%;
        padding-right: 4%;
    }

    .contenedor {
        width: 94%;
    }

    .resumen-card,
    .sensor-card,
    .grafica-card {
        padding: 20px;
    }

    .historial-seccion {
        padding: 24px;
    }
}

@media (max-width: 900px) {
    .encabezado {
        gap: 18px;
        padding: 24px 4%;
    }

    .encabezado h1 {
        font-size: clamp(1.45rem, 3.5vw, 2rem);
    }

    .resumen,
    .sensores {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .graficas {
        grid-template-columns: minmax(0, 1fr);
    }

    .contenedor-canvas {
        height: 300px;
    }

    .estadisticas-historial {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .historial-filtros {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .historial-filtros .boton {
        grid-column: 1 / -1;
    }

    .tabla-contenedor {
        max-width: 100%;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 700px) {
    .encabezado {
        padding: 22px 5%;
        gap: 14px;
    }

    .encabezado h1 {
        font-size: 1.45rem;
        line-height: 1.25;
        overflow-wrap: anywhere;
    }

    .encabezado p {
        font-size: 0.9rem;
        line-height: 1.4;
    }

    .fecha-hora {
        min-width: 0;
        width: 100%;
        align-items: flex-start;
    }

    .fecha-hora #hora {
        font-size: 1.15rem;
    }

    .boton-cerrar-sesion {
        margin-top: 5px;
    }

    .contenedor {
        width: 92%;
        margin: 20px auto;
    }

    .resumen,
    .sensores {
        grid-template-columns: minmax(0, 1fr);
        gap: 14px;
    }

    .resumen-card {
        gap: 14px;
        padding: 18px;
    }

    .resumen-icono {
        width: 50px;
        height: 50px;
        font-size: 1.55rem;
    }

    .resumen-card strong {
        font-size: 1.35rem;
        overflow-wrap: anywhere;
    }

    .sensor-card {
        padding: 20px;
    }

    .sensor-header {
        gap: 8px;
        flex-wrap: wrap;
    }

    .sensor-header h2 {
        font-size: 1.2rem;
    }

    .estado {
        white-space: nowrap;
    }

    .medicion {
        gap: 12px;
        padding: 14px;
    }

    .medicion strong {
        font-size: 1.3rem;
    }

    .graficas {
        gap: 16px;
    }

    .grafica-card,
    .historial-seccion {
        padding: 16px;
        border-radius: 16px;
    }

    .grafica-header {
        gap: 12px;
        margin-bottom: 16px;
    }

    .grafica-header h2 {
        font-size: 1.1rem;
    }

    .contenedor-canvas {
        height: 260px;
    }

    .historial-encabezado {
        gap: 14px;
        margin-bottom: 18px;
    }

    .historial-encabezado h2 {
        font-size: 1.25rem;
    }

    .historial-filtros {
        grid-template-columns: minmax(0, 1fr);
        gap: 13px;
        padding: 15px;
    }

    .historial-filtros .boton {
        grid-column: auto;
        width: 100%;
    }

    .estadisticas-historial {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .estadistica-card {
        padding: 14px;
    }

    .estadistica-card p {
        font-size: 0.78rem;
        line-height: 1.35;
    }

    .estadistica-card strong {
        font-size: 1.1rem;
        overflow-wrap: anywhere;
    }

    .tabla-historial {
        min-width: 680px;
    }

    .tabla-historial th,
    .tabla-historial td {
        padding: 11px 12px;
        font-size: 0.82rem;
        white-space: nowrap;
    }

    .paginacion {
        gap: 10px;
    }

    .paginacion span {
        font-size: 0.82rem;
        text-align: center;
    }

    .boton-pagina {
        padding: 9px 12px;
    }

    footer {
        padding: 20px 5%;
        font-size: 0.8rem;
        line-height: 1.45;
    }
}

@media (max-width: 380px) {
    .contenedor {
        width: 94%;
    }

    .encabezado h1 {
        font-size: 1.3rem;
    }

    .resumen-card,
    .sensor-card {
        padding: 16px;
    }

    .estadisticas-historial {
        grid-template-columns: minmax(0, 1fr);
    }

    .contenedor-canvas {
        height: 230px;
    }

    .paginacion {
        gap: 7px;
    }

    .boton-pagina {
        padding: 8px 10px;
        font-size: 0.82rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
