/* =========================================================
   Estadísticas Hospitalarias — sistema visual
   ========================================================= */

:root {
    /* Marca */
    --eh-brand-900: #0b3049;
    --eh-brand-800: #0d3d5c;
    --eh-brand-700: #114d72;
    --eh-brand-600: #155e8a;

    /* Acento / interacción (alineado con la serie 1 de las gráficas) */
    --eh-primary: #2a78d6;
    --eh-primary-dark: #1c5cab;
    --eh-primary-soft: #eaf2fc;

    /* Superficies */
    --eh-page: #f5f7fa;
    --eh-surface: #ffffff;
    --eh-border: rgba(11, 20, 30, 0.09);
    --eh-border-strong: rgba(11, 20, 30, 0.14);

    /* Texto */
    --eh-ink: #10151c;
    --eh-ink-soft: #4c5a68;
    --eh-ink-muted: #8993a1;

    /* Estado (paleta fija, no se reutiliza para series de datos) */
    --eh-good: #0ca30c;
    --eh-good-bg: #e6f6e6;
    --eh-warning: #b8780c;
    --eh-warning-bg: #fdf1de;
    --eh-serious: #c7602f;
    --eh-serious-bg: #fbe9e1;
    --eh-critical: #d03b3b;
    --eh-critical-bg: #fbe6e6;

    /* Radios y sombras */
    --eh-radius: 0.85rem;
    --eh-radius-sm: 0.55rem;
    --eh-shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
    --eh-shadow: 0 2px 10px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.05);
    --eh-shadow-lg: 0 12px 28px rgba(16, 24, 40, 0.10), 0 2px 6px rgba(16, 24, 40, 0.06);
}

/* Paleta categórica validada (uso: series de gráficas, en este orden fijo) */
:root {
    --serie-1: #2a78d6; /* azul */
    --serie-2: #eb6834; /* naranja */
    --serie-3: #1baf7a; /* aqua */
    --serie-4: #eda100; /* amarillo */
    --serie-5: #e87ba4; /* magenta */
    --serie-6: #4a3aa7; /* violeta */
    --serie-7: #e34948; /* rojo */
    --serie-8: #008300; /* verde */
}

* {
    -webkit-font-smoothing: antialiased;
}

html, body {
    height: 100%;
}

body {
    background-color: var(--eh-page);
    color: var(--eh-ink);
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 0.9rem;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--eh-ink);
}

a {
    color: var(--eh-primary);
}

/* ---------------------------------------------------------
   Layout general
   --------------------------------------------------------- */

#layout {
    min-height: 100vh;
}

.sidebar {
    width: 248px;
    min-width: 248px;
    height: 100vh;
    position: sticky;
    top: 0;
    background: linear-gradient(180deg, var(--eh-brand-900) 0%, var(--eh-brand-700) 100%);
}

.sidebar-brand {
    padding: 1.35rem 1.25rem 1rem 1.25rem;
}

.sidebar-brand-icon {
    width: 40px;
    height: 40px;
    border-radius: 0.65rem;
    background: rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-brand-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
}

.sidebar-brand-subtitle {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.55);
    letter-spacing: 0.02em;
}

.sidebar-nav {
    padding: 0 0.75rem;
}

.sidebar-section-label {
    font-size: 0.66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.38);
    padding: 1rem 0.75rem 0.35rem 0.75rem;
}

.sidebar .nav-link {
    border-radius: 0.6rem;
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.855rem;
    font-weight: 500;
    padding: 0.55rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    transition: background-color .15s ease, color .15s ease;
}

.sidebar .nav-link i {
    font-size: 1rem;
    width: 1.1rem;
    text-align: center;
    opacity: 0.9;
}

.sidebar .nav-link:hover:not(.active) {
    background-color: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.sidebar .nav-link.active {
    background-color: rgba(255, 255, 255, 0.14);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--serie-3);
}

.sidebar-footer {
    padding: 0.9rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.10);
}

.sidebar-user {
    color: rgba(255, 255, 255, 0.85);
}

.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: saturate(180%) blur(6px);
    border-bottom: 1px solid var(--eh-border);
    padding: 0.85rem 1.75rem;
}

.topbar h1 {
    font-size: 1.05rem;
    margin-bottom: 0;
}

.hospital-pill {
    background: var(--eh-primary-soft);
    color: var(--eh-brand-700);
    border-radius: 999px;
    padding: 0.3rem 0.9rem;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid rgba(42, 120, 214, 0.18);
}

main.contenido {
    padding: 1.75rem;
}

/* ---------------------------------------------------------
   Tarjetas
   --------------------------------------------------------- */

.card {
    border: 1px solid var(--eh-border);
    border-radius: var(--eh-radius);
    box-shadow: var(--eh-shadow-sm);
}

.card-header {
    font-weight: 600;
    font-size: 0.87rem;
    border-bottom: 1px solid var(--eh-border);
}

.card-indicador {
    transition: box-shadow .15s ease, transform .15s ease;
}

.card-indicador:hover {
    box-shadow: var(--eh-shadow);
    transform: translateY(-1px);
}

.card-indicador .card-body {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
}

.card-indicador .icono {
    width: 38px;
    height: 38px;
    border-radius: 0.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    flex-shrink: 0;
    background: var(--eh-primary-soft);
    color: var(--eh-primary-dark);
}

.card-indicador .etiqueta {
    font-size: 0.76rem;
    color: var(--eh-ink-soft);
    font-weight: 500;
    margin-bottom: 0.15rem;
}

.card-indicador .valor {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--eh-ink);
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-indicador .nota {
    font-size: 0.72rem;
    color: var(--eh-ink-muted);
}

/* colores de icono por categoría */
.icono-bg-1 { background: #eaf2fc; color: var(--serie-1); }
.icono-bg-2 { background: #fdeee6; color: var(--serie-2); }
.icono-bg-3 { background: #e5f7f0; color: var(--serie-3); }
.icono-bg-4 { background: #fdf3de; color: #a87200; }
.icono-bg-5 { background: #fbebf1; color: #c85685; }
.icono-bg-6 { background: #ece9f8; color: var(--serie-6); }
.icono-bg-7 { background: #fbe9e9; color: var(--serie-7); }
.icono-bg-8 { background: #e5f3e5; color: var(--serie-8); }

/* ---------------------------------------------------------
   Tablas
   --------------------------------------------------------- */

.table {
    font-size: 0.85rem;
    --bs-table-border-color: var(--eh-border);
}

.table thead th {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--eh-ink-muted);
    font-weight: 700;
    border-bottom-width: 1px;
    background: #fbfbfc;
}

.table-hover tbody tr:hover {
    background-color: var(--eh-primary-soft);
}

.table-sticky thead th {
    position: sticky;
    top: 0;
    background: #fbfbfc;
    z-index: 1;
}

/* ---------------------------------------------------------
   Botones y formularios
   --------------------------------------------------------- */

.btn {
    font-weight: 600;
    font-size: 0.85rem;
    border-radius: var(--eh-radius-sm);
}

.btn-primary {
    background-color: var(--eh-primary);
    border-color: var(--eh-primary);
    box-shadow: 0 1px 2px rgba(42, 120, 214, 0.25);
}

.btn-primary:hover, .btn-primary:focus {
    background-color: var(--eh-primary-dark);
    border-color: var(--eh-primary-dark);
}

.btn-outline-secondary {
    color: var(--eh-ink-soft);
    border-color: var(--eh-border-strong);
}

.form-control, .form-select {
    border-radius: var(--eh-radius-sm);
    border-color: var(--eh-border-strong);
    font-size: 0.85rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--eh-primary);
    box-shadow: 0 0 0 0.2rem rgba(42, 120, 214, 0.15);
}

.form-label {
    font-weight: 600;
    color: var(--eh-ink-soft);
}

.nav-tabs .nav-link {
    font-weight: 600;
    color: var(--eh-ink-muted);
    border: none;
    border-bottom: 2px solid transparent;
}

.nav-tabs .nav-link.active {
    color: var(--eh-primary);
    border-bottom-color: var(--eh-primary);
    background: transparent;
}

/* ---------------------------------------------------------
   Insignias de estado (paleta de estado fija)
   --------------------------------------------------------- */

.badge-estado {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
}

.badge-estado i {
    font-size: 0.8rem;
}

.badge-good { background: var(--eh-good-bg); color: var(--eh-good); }
.badge-warning { background: var(--eh-warning-bg); color: var(--eh-warning); }
.badge-serious { background: var(--eh-serious-bg); color: var(--eh-serious); }
.badge-critical { background: var(--eh-critical-bg); color: var(--eh-critical); }
.badge-neutral { background: #eef0f3; color: var(--eh-ink-soft); }

/* ---------------------------------------------------------
   Estados vacíos
   --------------------------------------------------------- */

.estado-vacio {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--eh-ink-muted);
}

.estado-vacio i {
    font-size: 2rem;
    color: var(--eh-border-strong);
    margin-bottom: 0.5rem;
    display: block;
}

/* ---------------------------------------------------------
   Barras de progreso (informe / comparativos)
   --------------------------------------------------------- */

.barra-fondo {
    background: #eef1f5;
    height: 10px;
    border-radius: 999px;
    overflow: hidden;
}

.barra-valor {
    background: var(--eh-primary);
    height: 100%;
    border-radius: 999px;
}

/* ---------------------------------------------------------
   Pantalla de autenticación
   --------------------------------------------------------- */

.auth-screen {
    min-height: 100vh;
    display: flex;
}

.auth-brand-panel {
    width: 44%;
    background:
        radial-gradient(circle at 15% 15%, rgba(255,255,255,0.10) 0, transparent 45%),
        radial-gradient(circle at 85% 85%, rgba(255,255,255,0.08) 0, transparent 40%),
        linear-gradient(160deg, var(--eh-brand-900) 0%, var(--eh-brand-700) 55%, var(--eh-primary) 130%);
    color: #fff;
    padding: 3.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.auth-brand-icon {
    width: 56px;
    height: 56px;
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.14);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
}

.auth-brand-panel h2 {
    color: #fff;
    font-size: 1.7rem;
    max-width: 22rem;
}

.auth-brand-panel p {
    color: rgba(255, 255, 255, 0.75);
    max-width: 22rem;
}

.auth-brand-feature {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    color: rgba(255, 255, 255, 0.88);
    font-size: 0.85rem;
    margin-bottom: 0.9rem;
}

.auth-brand-feature i {
    color: var(--serie-3);
    font-size: 1.05rem;
    margin-top: 0.1rem;
}

.auth-form-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--eh-page);
}

.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--eh-surface);
    border: 1px solid var(--eh-border);
    border-radius: var(--eh-radius);
    box-shadow: var(--eh-shadow-lg);
    padding: 2.25rem;
}

@media (max-width: 900px) {
    .auth-brand-panel {
        display: none;
    }
}

/* ---------------------------------------------------------
   Sidebar responsiva (fuera de canvas en pantallas angostas)
   --------------------------------------------------------- */

.sidebar-toggle {
    display: none;
    border: none;
    background: transparent;
    font-size: 1.3rem;
    color: var(--eh-ink-soft);
    padding: 0.25rem 0.5rem;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(11, 20, 30, 0.45);
    z-index: 1039;
}

@media (max-width: 991.98px) {
    .sidebar-toggle {
        display: inline-flex;
        align-items: center;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 1040;
        transform: translateX(-100%);
        transition: transform .22s ease;
        box-shadow: var(--eh-shadow-lg);
    }

    .sidebar.mostrar {
        transform: translateX(0);
    }

    .sidebar-backdrop.mostrar {
        display: block;
    }
}

/* ---------------------------------------------------------
   Utilidades
   --------------------------------------------------------- */

.text-ink-soft { color: var(--eh-ink-soft); }
.text-ink-muted { color: var(--eh-ink-muted); }
