:root {
    --bg: #f4f7fb;
    --panel: #ffffff;
    --text: #152238;
    --muted: #6f7c91;

    --navy: #0d2b50;
    --navy-2: #163d68;

    --ok: #198754;
    --ok-bg: #e8f5ee;

    --warning: #c98200;
    --warning-bg: #fff4d6;

    --critical: #c62828;
    --critical-bg: #fde8ea;

    --border: #dfe5ec;
    --shadow: 0 8px 24px rgba(17, 39, 70, 0.08);
}


/* ========================================================= */
/* RESET */
/* ========================================================= */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family:
        "Segoe UI",
        Arial,
        Helvetica,
        sans-serif;
}


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

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 30px;

    padding: 24px 36px;

    background:
        linear-gradient(
            135deg,
            #0b2749,
            #123b68
        );

    color: white;
}

.header h1 {
    margin: 0;
    font-size: 28px;
    font-weight: 700;
}

.header p {
    margin: 6px 0 0 0;

    color: #cbd8e7;
    font-size: 14px;
}

.header-info {
    display: flex;
    gap: 30px;
}

.header-info div {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.header-info span {
    color: #c7d4e4;
    font-size: 12px;
}

.header-info strong {
    font-size: 15px;
}


/* ========================================================= */
/* CONTENEDOR */
/* ========================================================= */

.container {
    width: min(
        1600px,
        calc(100% - 40px)
    );

    margin: 24px auto 40px auto;
}


/* ========================================================= */
/* RESUMEN */
/* ========================================================= */

.resumen {
    display: grid;

    grid-template-columns:
        repeat(5, minmax(0, 1fr));

    gap: 16px;

    margin-bottom: 30px;
}

.resumen-card {
    background: var(--panel);

    border: 1px solid var(--border);

    border-radius: 12px;

    padding: 18px 20px;

    box-shadow: var(--shadow);

    display: flex;
    flex-direction: column;

    gap: 6px;
}

.resumen-card span {
    color: var(--muted);
    font-size: 13px;
}

.resumen-card strong {
    font-size: 30px;
    line-height: 1;
}


/* ========================================================= */
/* COLORES RESUMEN */
/* ========================================================= */

.resumen-card.ok {
    border-left: 5px solid var(--ok);
}

.resumen-card.ok strong {
    color: var(--ok);
}


.resumen-card.warning {
    border-left: 5px solid var(--warning);
}

.resumen-card.warning strong {
    color: var(--warning);
}


.resumen-card.critical {
    border-left: 5px solid var(--critical);
}

.resumen-card.critical strong {
    color: var(--critical);
}


.resumen-card.estado-general {
    border-left: 5px solid var(--navy-2);
}


/* ========================================================= */
/* TITULO SECCIÓN */
/* ========================================================= */

.section-title {
    margin-bottom: 16px;
}

.section-title h2 {
    margin: 0;

    font-size: 22px;
}

.section-title p {
    margin: 5px 0 0 0;

    color: var(--muted);

    font-size: 14px;
}


/* ========================================================= */
/* GRID */
/* ========================================================= */

.dashboard-grid {
    display: grid;

    grid-template-columns:
        repeat(3, minmax(0, 1fr));

    gap: 18px;
}


/* ========================================================= */
/* TARJETA QUERY */
/* ========================================================= */

.query-card {
    background: var(--panel);

    border: 1px solid var(--border);

    border-radius: 14px;

    box-shadow: var(--shadow);

    overflow: hidden;

    transition:
        transform 0.18s ease,
        box-shadow 0.18s ease;
}

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

    box-shadow:
        0 12px 30px
        rgba(17, 39, 70, 0.12);
}


/* ========================================================= */
/* BORDE POR ESTADO */
/* ========================================================= */

.query-card.status-ok {
    border-top: 5px solid var(--ok);
}

.query-card.status-warning {
    border-top: 5px solid var(--warning);
}

.query-card.status-critical {
    border-top: 5px solid var(--critical);
}


/* ========================================================= */
/* HEADER TARJETA */
/* ========================================================= */

.query-header {
    display: flex;

    align-items: flex-start;

    justify-content: space-between;

    gap: 15px;

    padding: 18px 20px 12px 20px;
}

.query-number {
    display: inline-flex;

    align-items: center;

    justify-content: center;

    min-width: 30px;
    height: 30px;

    border-radius: 8px;

    background: var(--navy-2);

    color: white;

    font-size: 13px;

    font-weight: 700;
}

.query-title-wrapper {
    flex: 1;
}

.query-title {
    margin: 0;

    font-size: 17px;

    line-height: 1.25;

    word-break: break-word;
}

.query-subtitle {
    margin-top: 5px;

    color: var(--muted);

    font-size: 11px;
}


/* ========================================================= */
/* BADGE ESTADO */
/* ========================================================= */

.status-badge {
    padding: 6px 10px;

    border-radius: 999px;

    font-size: 11px;

    font-weight: 700;

    white-space: nowrap;
}

.status-badge.ok {
    color: var(--ok);
    background: var(--ok-bg);
}

.status-badge.warning {
    color: var(--warning);
    background: var(--warning-bg);
}

.status-badge.critical {
    color: var(--critical);
    background: var(--critical-bg);
}


/* ========================================================= */
/* VALORES */
/* ========================================================= */

.query-values {
    display: grid;

    grid-template-columns:
        repeat(3, minmax(0, 1fr));

    gap: 10px;

    padding: 6px 20px 14px 20px;
}

.metric {
    min-width: 0;
}

.metric-label {
    display: block;

    margin-bottom: 5px;

    color: var(--muted);

    font-size: 11px;
}

.metric-value {
    display: block;

    font-size: 20px;

    font-weight: 700;

    overflow: hidden;

    text-overflow: ellipsis;
}

.metric-value.current {
    font-size: 25px;

    color: var(--navy);
}


/* ========================================================= */
/* CAMBIO */
/* ========================================================= */

.change-positive {
    color: var(--ok);
}

.change-negative {
    color: var(--critical);
}

.change-neutral {
    color: var(--muted);
}


/* ========================================================= */
/* UMBRALES */
/* ========================================================= */

.thresholds {
    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 10px;

    margin: 0 20px 16px 20px;

    padding: 12px;

    border-radius: 10px;

    background: #f7f9fc;

    border: 1px solid #e7ebf0;
}

.threshold-item {
    display: flex;

    justify-content: space-between;

    gap: 8px;

    font-size: 12px;
}

.threshold-item span {
    color: var(--muted);
}

.threshold-item strong {
    font-weight: 700;
}


/* ========================================================= */
/* GRÁFICA */
/* ========================================================= */

.chart-container {
    position: relative;

    height: 190px;

    padding: 5px 15px 15px 15px;
}

.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}


/* ========================================================= */
/* FOOTER DE TARJETA */
/* ========================================================= */

.query-footer {
    display: flex;

    justify-content: space-between;

    gap: 10px;

    padding: 10px 20px;

    background: #fafbfd;

    border-top: 1px solid #edf0f4;

    color: var(--muted);

    font-size: 11px;
}


/* ========================================================= */
/* MENSAJE DE ERROR */
/* ========================================================= */

.error-box {
    grid-column: 1 / -1;

    padding: 24px;

    background: var(--critical-bg);

    color: var(--critical);

    border: 1px solid #f2b8bd;

    border-radius: 12px;

    font-weight: 600;
}


/* ========================================================= */
/* FOOTER GENERAL */
/* ========================================================= */

footer {
    text-align: center;

    padding: 20px;

    color: var(--muted);

    font-size: 12px;
}


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

@media (max-width: 1200px) {

    .dashboard-grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    .resumen {
        grid-template-columns:
            repeat(3, minmax(0, 1fr));
    }

}


@media (max-width: 800px) {

    .header {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-info {
        width: 100%;

        justify-content: space-between;
    }

    .resumen {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    .dashboard-grid {
        grid-template-columns:
            1fr;
    }

}


@media (max-width: 520px) {

    .container {
        width: calc(100% - 20px);
    }

    .header {
        padding: 20px;
    }

    .header h1 {
        font-size: 22px;
    }

    .header-info {
        flex-direction: column;
        gap: 12px;
    }

    .resumen {
        grid-template-columns:
            1fr;
    }

    .query-values {
        grid-template-columns:
            1fr 1fr;
    }

}

/* ========================================================= */
/* LOGIN */
/* ========================================================= */

[hidden] {
    display: none !important;
}

.login-view {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(
            circle at top left,
            rgba(61, 117, 180, 0.22),
            transparent 34%
        ),
        linear-gradient(
            135deg,
            #081f3b 0%,
            #0d2b50 48%,
            #153f6c 100%
        );
}

.login-card {
    width: min(420px, 100%);
    padding: 34px;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 18px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.login-brand {
    margin-bottom: 28px;
    text-align: center;
}

.login-icon {
    width: 62px;
    height: 62px;
    display: grid;
    place-items: center;
    margin: 0 auto 16px auto;
    border-radius: 18px;
    background: #eef5fc;
    font-size: 28px;
}

.login-brand h1 {
    margin: 0;
    color: var(--navy);
    font-size: 24px;
}

.login-brand p {
    margin: 8px 0 0 0;
    color: var(--muted);
    font-size: 14px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.login-form label {
    margin-top: 7px;
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
}

.login-form input {
    width: 100%;
    height: 46px;
    padding: 0 13px;
    border: 1px solid var(--border);
    border-radius: 10px;
    outline: none;
    background: white;
    color: var(--text);
    font: inherit;
}

.login-form input:focus {
    border-color: #4a83bd;
    box-shadow: 0 0 0 4px rgba(74, 131, 189, 0.12);
}

.password-wrapper {
    position: relative;
}

.password-wrapper input {
    padding-right: 48px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 7px;
    transform: translateY(-50%);
    width: 36px;
    height: 34px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
}

.password-toggle:hover {
    background: #f0f4f8;
}

.login-error {
    min-height: 20px;
    margin-top: 4px;
    color: var(--critical);
    font-size: 12px;
    font-weight: 600;
}

.login-button {
    height: 46px;
    margin-top: 2px;
    border: 0;
    border-radius: 10px;
    background: linear-gradient(135deg, #0d2b50, #1e568f);
    color: white;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
}

.login-button:hover {
    box-shadow: 0 8px 20px rgba(13, 43, 80, 0.22);
}

.login-button:disabled {
    opacity: 0.65;
    cursor: wait;
}

.login-footer {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid #edf0f4;
    color: var(--muted);
    text-align: center;
    font-size: 11px;
}

.app-shell {
    min-height: 100vh;
}

.logout-button {
    align-self: center;
    height: 36px;
    padding: 0 13px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: white;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

.logout-button:hover {
    background: rgba(255, 255, 255, 0.16);
}
