:root {
    /* Paleta unificada con el Login (Violeta / Espacio Profundo / Neón) */
    --bg-main: #03040a;
    --bg-card: #080918;
    --bg-card-gradient: linear-gradient(180deg, rgba(12, 14, 34, 0.98) 0%, rgba(7, 8, 20, 0.95) 100%);
    --border-color: rgba(255, 255, 255, 0.09);
    --border-focus: #38bdf8;
    --accent: #38bdf8;
    --accent-gradient: linear-gradient(90deg, #1cb5e0 0%, #5d38f8 100%);
    --accent-glow: rgba(93, 56, 248, 0.35);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --danger: #dc2626;
    --success: #16a34a;
    --font-family: 'Montserrat', sans-serif;
    --th-bg: #050612;
    --tr-hover: rgba(93, 56, 248, 0.08);
    --shadow-card: 0 30px 60px -15px rgba(0, 0, 0, 0.85), 0 0 40px -10px rgba(99, 102, 241, 0.12);
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    font-family: var(--font-family); 
}

html, body { 
    height: 100vh; 
    overflow: hidden; 
    background-color: var(--bg-main); 
    color: var(--text-main); 
    display: flex; 
    flex-direction: column; 
    background-image: radial-gradient(circle at 50% 0%, #0e102b 0%, #03040a 65%);
}

/* Scrollbars estilizadas y sutiles */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(3, 4, 10, 0.5);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(56, 189, 248, 0.4);
}

#toast { 
    position: fixed; 
    top: 24px; 
    right: 24px; 
    z-index: 5000; 
    padding: 12px 22px; 
    border-radius: 12px; 
    font-size: 12.5px; 
    font-weight: 700; 
    display: none; 
    background: var(--accent-gradient); 
    color: #020617; 
    box-shadow: 0 20px 40px -10px var(--accent-glow); 
    max-width: 450px; 
    letter-spacing: 0.2px;
}

/* =========================================================================
   LOGIN SCREEN (EXACTO)
   ========================================================================= */
#login-container { 
    flex: 1; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    background: radial-gradient(circle at center, #090a1f 0%, #03040a 100%);
    padding: 16px;
}

#login-container .card { 
    background: #080918;
    border: 1px solid rgba(255, 255, 255, 0.08); 
    padding: 44px 38px 40px 38px; 
    border-radius: 24px; 
    width: 100%; 
    max-width: 430px; 
    text-align: center; 
    box-shadow: 0 30px 70px -15px rgba(0, 0, 0, 0.9), 0 0 50px -10px rgba(99, 102, 241, 0.15); 
}

.login-badge-icon {
    width: 52px;
    height: 52px;
    margin: 0 auto 20px auto;
    background: rgba(14, 165, 233, 0.08);
    border: 1px solid rgba(56, 189, 248, 0.25);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #38bdf8;
    box-shadow: 0 8px 20px -4px rgba(56, 189, 248, 0.2);
}

.login-title {
    font-size: 17.5px;
    font-weight: 800;
    color: #ffffff;
    margin-bottom: 6px;
    letter-spacing: -0.2px;
}

.login-sub-cyan {
    font-size: 11px;
    font-weight: 800;
    color: #22d3ee;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 4px;
}

.login-sub-muted {
    font-size: 11.5px;
    font-weight: 500;
    color: #94a3b8;
    margin-bottom: 28px;
}

.form-group { 
    margin-bottom: 14px; 
    text-align: left; 
}

#login-container label { 
    display: block; 
    font-size: 11.5px; 
    font-weight: 500; 
    text-transform: none; 
    color: #94a3b8; 
    margin-bottom: 7px; 
}

#login-container input { 
    width: 100%; 
    background: #050612; 
    border: 1px solid rgba(255, 255, 255, 0.09); 
    border-radius: 10px; 
    padding: 12px 14px; 
    color: #f8fafc; 
    font-size: 13px; 
    outline: none; 
    transition: all 0.2s ease;
}

#login-container input:focus { 
    border-color: #38bdf8; 
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12);
}

#login-container button[type="submit"] { 
    width: 100%; 
    background: var(--accent-gradient); 
    color: #020617; 
    font-weight: 800; 
    padding: 13px; 
    border: none; 
    border-radius: 10px; 
    cursor: pointer; 
    font-size: 13px; 
    margin-top: 10px;
    letter-spacing: 0.2px;
    box-shadow: 0 10px 25px -4px rgba(93, 56, 248, 0.5), 0 4px 12px rgba(28, 181, 224, 0.3);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

#login-container button[type="submit"]:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 30px -4px rgba(93, 56, 248, 0.6), 0 6px 16px rgba(28, 181, 224, 0.4);
}

/* =========================================================================
   ELEMENTOS GLOBALES DE FORMULARIO
   ========================================================================= */
label { 
    display: block; 
    font-size: 10px; 
    font-weight: 700; 
    text-transform: uppercase; 
    color: var(--text-muted); 
    margin-bottom: 5px; 
    letter-spacing: 0.4px;
}

input, select, textarea { 
    width: 100%; 
    background: #050612; 
    border: 1px solid var(--border-color); 
    border-radius: 9px; 
    padding: 8px 12px; 
    color: var(--text-main); 
    font-size: 12px; 
    outline: none; 
    transition: all 0.2s ease;
}

input:focus, select:focus, textarea:focus { 
    border-color: var(--border-focus); 
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.15);
}

button { 
    width: 100%; 
    background: var(--accent-gradient); 
    color: #020617; 
    font-weight: 700; 
    padding: 9px 16px; 
    border: none; 
    border-radius: 9px; 
    cursor: pointer; 
    font-size: 12.5px; 
    transition: all 0.15s ease;
}

button:hover {
    filter: brightness(1.08);
}

/* =========================================================================
   HEADER INSTITUCIONAL Y NAVEGACIÓN
   ========================================================================= */
#app-container { 
    display: none; 
    flex: 1; 
    flex-direction: column; 
    height: 100vh; 
    overflow: hidden; 
}

header { 
    background: rgba(8, 9, 24, 0.85); 
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color); 
    padding: 12px 28px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    flex-shrink: 0; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.header-nav { 
    background: rgba(5, 6, 18, 0.75); 
    border: 1px solid var(--border-color); 
    padding: 4px; 
    border-radius: 12px; 
    display: inline-flex; 
    gap: 5px; 
}

.btn-nav { 
    padding: 7px 16px; 
    border-radius: 9px; 
    font-size: 12px; 
    font-weight: 600; 
    cursor: pointer; 
    border: none; 
    background: transparent; 
    color: var(--text-muted); 
    width: auto; 
    display: inline-flex; 
    align-items: center; 
    transition: all 0.15s ease;
}

.btn-nav:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.04);
}

.btn-nav.active { 
    background: var(--accent-gradient); 
    color: #020617; 
    font-weight: 800; 
    box-shadow: 0 4px 15px -3px rgba(93, 56, 248, 0.45);
}

/* =========================================================================
   ESTRUCTURA PRINCIPAL Y TABLAS
   ========================================================================= */
main { 
    flex: 1; 
    padding: 16px 28px; 
    max-width: 1750px; 
    width: 100%; 
    margin: 0 auto; 
    display: flex; 
    flex-direction: column; 
    overflow: hidden; 
    min-height: 0; 
    position: relative; 
}

.view-section { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    min-height: 0; 
    overflow: hidden; 
}

.view-section.hidden { 
    display: none !important; 
}

.table-container { 
    background: var(--bg-card-gradient); 
    border: 1px solid var(--border-color); 
    border-radius: 18px; 
    overflow: hidden; 
    display: flex; 
    flex-direction: column; 
    flex: 1; 
    min-height: 0; 
    box-shadow: var(--shadow-card);
}

.table-scroll { 
    flex: 1; 
    overflow-y: auto; 
    overflow-x: auto; 
}

table { 
    width: 100%; 
    border-collapse: separate; 
    border-spacing: 0; 
    font-size: 12px; 
}

th, td { 
    padding: 11px 15px; 
    border-bottom: 1px solid var(--border-color); 
    white-space: nowrap; 
    color: var(--text-main); 
    text-align: left; 
}

th { 
    background: var(--th-bg); 
    color: var(--text-muted); 
    font-weight: 700; 
    letter-spacing: 0.3px;
    position: sticky; 
    top: 0; 
    z-index: 10; 
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

tr:hover td { 
    background: var(--tr-hover); 
    cursor: pointer; 
}

.th-filter { 
    padding: 5px 8px; 
    background: var(--th-bg); 
    position: sticky; 
    top: 40px; 
    z-index: 9; 
}

.th-filter input { 
    width: 100%; 
    padding: 5px 10px; 
    font-size: 11px; 
    background: #03040a; 
    border: 1px solid var(--border-color); 
    border-radius: 7px; 
    color: var(--text-main); 
}

/* =========================================================================
   VENTANAS MODALES
   ========================================================================= */
.modal-overlay { 
    position: fixed; 
    inset: 0; 
    background: rgba(3, 4, 10, 0.85); 
    backdrop-filter: blur(10px); 
    z-index: 2000; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    opacity: 0; 
    pointer-events: none; 
    transition: opacity 0.2s ease; 
    padding: 14px; 
}

.modal-overlay.active { 
    opacity: 1; 
    pointer-events: auto; 
}

.modal-box { 
    background: var(--bg-card-gradient); 
    border: 1px solid rgba(255, 255, 255, 0.12); 
    padding: 24px 28px; 
    border-radius: 20px; 
    width: 98vw; 
    max-width: 1450px; 
    display: flex; 
    flex-direction: column; 
    max-height: 95vh; 
    overflow-y: auto; 
    box-shadow: 0 35px 80px -15px rgba(0, 0, 0, 0.95), 0 0 50px -10px rgba(99, 102, 241, 0.15); 
}

/* =========================================================================
   ESTADÍSTICAS Y TARJETAS
   ========================================================================= */
.stats-menu-grid { 
    display: grid; 
    grid-template-columns: repeat(4, 1fr); 
    gap: 16px; 
    width: 100%; 
    height: 100%; 
    min-height: 0; 
}

.stat-menu-card { 
    background: var(--bg-card-gradient); 
    border: 1px solid var(--border-color); 
    padding: 18px 22px; 
    border-radius: 16px; 
    display: flex; 
    flex-direction: column; 
    justify-content: space-between; 
    cursor: pointer; 
    transition: all 0.2s ease; 
    min-height: 0; 
    box-shadow: var(--shadow-card);
}

.stat-menu-card:hover { 
    border-color: var(--border-focus); 
    transform: translateY(-3px); 
    box-shadow: 0 25px 45px -10px rgba(0,0,0,0.8), 0 0 25px -5px rgba(56, 189, 248, 0.25);
}

.stat-detail-container { 
    position: absolute; 
    inset: 16px 28px; 
    background: var(--bg-card-gradient); 
    border: 1px solid var(--border-color); 
    border-radius: 18px; 
    padding: 22px; 
    display: flex; 
    flex-direction: column; 
    z-index: 100; 
    box-shadow: 0 35px 70px rgba(0,0,0,0.85); 
}

.stat-detail-container.hidden { 
    display: none !important; 
}

.stat-detail-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 16px; 
    flex-shrink: 0; 
}

.stat-detail-canvas-box { 
    flex: 1; 
    position: relative; 
    width: 100%; 
    height: 100%; 
    min-height: 0; 
}

.hidden { 
    display: none !important; 
}