:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --purple: #8b5cf6;
    --success: #10b981;
    --danger: #ef4444;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #1e293b;
    --border: #e2e8f0;
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    font-family: 'Plus Jakarta Sans', sans-serif; 
}

body { 
    background: var(--bg); 
    color: var(--text); 
    line-height: 1.6; 
}

/* =========================================
   DASHBOARD ESTADÍSTICO Y GRÁFICOS (V6.0)
========================================= */
.dashboard-grid { 
    display: grid; 
    grid-template-columns: 1fr; 
    gap: 15px; 
    margin: 15px; 
}

@media(min-width: 1024px) { 
    .dashboard-grid { grid-template-columns: 1fr 1fr; } 
}

.chart-container { 
    height: 200px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
}

/* =========================================
   BOTONES Y UI BASE
========================================= */
.btn { 
    padding: 10px 15px; 
    border-radius: 8px; 
    font-weight: 700; 
    cursor: pointer; 
    border: none; 
    font-size: 13px; 
    transition: all 0.3s ease; 
    display: inline-flex; 
    align-items: center; 
    justify-content: center; 
    gap: 8px;
}
.btn:hover { filter: brightness(0.9); transform: translateY(-1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-purple { background: var(--purple); color: #fff; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-full { width: 100%; }

/* =========================================
   LAYOUT PRINCIPAL Y TARJETAS
========================================= */
.header-main { 
    background: var(--card); 
    padding: 15px 20px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    box-shadow: 0 1px 3px rgba(0,0,0,0.1); 
    flex-wrap: wrap; 
    gap: 10px; 
    position: sticky; 
    top: 0; 
    z-index: 100;
}
.institution-name { font-weight: 800; font-size: 1.2rem; display: inline-block; margin-right: 15px; }
.clock { color: #64748b; font-size: 0.9rem; font-weight: 600; }

.card { 
    background: var(--card); 
    margin: 15px; 
    padding: 20px; 
    border-radius: 12px; 
    box-shadow: 0 1px 3px rgba(0,0,0,0.05); 
    border: 1px solid var(--border);
}

/* Sistema de Grillas */
.grid-6 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 15px; }
.grid-controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; }
.mt-15 { margin-top: 15px; }

/* =========================================
   FORMULARIOS Y BUSCADORES
========================================= */
.input-group label { 
    display: block; 
    font-size: 11px; 
    font-weight: 800; 
    text-transform: uppercase; 
    color: #64748b; 
    margin-bottom: 5px; 
}
.input-group input, 
.input-group select, 
.input-group textarea { 
    width: 100%; 
    padding: 10px; 
    border: 1.5px solid var(--border); 
    border-radius: 8px; 
    font-size: 13px; 
    outline: none; 
    transition: border-color 0.2s, box-shadow 0.2s;
}
.input-group input:focus, 
.input-group select:focus, 
.input-group textarea:focus { 
    border-color: var(--primary); 
    box-shadow: 0 0 0 3px rgba(79,70,229,0.1); 
}

.search-box input { padding-left: 35px; min-width: 250px; }

/* =========================================
   BARRA DE ESTADÍSTICAS
========================================= */
.stats-bar { 
    display: grid; 
    grid-template-columns: repeat(4, 1fr); 
    text-align: center; 
    gap: 10px; 
    margin: 0;
}
.stat-item span { font-size: 10px; font-weight: 800; color: #64748b; text-transform: uppercase; }
.stat-item strong { display: block; font-size: 1.5rem; }

/* =========================================
   TABLA PRINCIPAL (UX MEJORADA)
========================================= */
.table-responsive { 
    overflow-x: auto; 
    margin: 15px; 
    background: #fff; 
    border-radius: 12px; 
    border: 1px solid var(--border); 
    box-shadow: 0 1px 3px rgba(0,0,0,0.05); 
    max-height: 60vh; 
    position: relative;
}
table { width: 100%; border-collapse: collapse; min-width: 800px; }
th { 
    background: #f8fafc; 
    padding: 14px 12px; 
    text-align: left; 
    font-size: 12px; 
    color: #64748b; 
    text-transform: uppercase; 
    position: sticky; 
    top: 0; 
    z-index: 10; 
    border-bottom: 2px solid var(--border);
}
td { padding: 12px; border-bottom: 1px solid #f1f5f9; font-size: 13px; transition: background 0.3s; }

.asist-opt { padding: 8px; border-radius: 6px; border: 1px solid var(--border); width: 100%; font-size: 13px; cursor: pointer; }
.obs-input { padding: 8px; border: 1px solid var(--border); border-radius: 6px; width: 100%; font-size: 13px; }
.fw-bold { font-weight: 700; }

/* Feedback Visual (Pintado Dinámico de Filas) */
.row-F td { background-color: #fee2e2 !important; } /* Inasistencia */
.row-T td { background-color: #fef3c7 !important; } /* Atraso */
.row-R td, .row-I td { background-color: #ffedd5 !important; } /* Retirado / Injustificado */
.row-P td, .row-J td, .row-C td { background-color: #e0e7ff !important; } /* Permiso / Justificado / Contingencia */

/* =========================================
   DISEÑO PARA REPORTES (PDF / WORD)
========================================= */
.vertical-text { 
    writing-mode: vertical-lr; 
    transform: rotate(180deg); 
    white-space: nowrap; 
    padding: 10px 5px; 
    font-size: 11px; 
    max-height: 100px; 
    text-align: center; 
}
.initial-box { 
    width: 25px; 
    height: 25px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    border-radius: 4px; 
    font-weight: 800; 
    font-size: 12px; 
    margin: auto; 
}
/* Colores de las iniciales en el PDF */
.bg-A { background: #dcfce7; color: #166534; }
.bg-F { background: #fee2e2; color: #991b1b; }
.bg-T { background: #fef3c7; color: #92400e; }
.bg-C { background: #e0e7ff; color: #3730a3; }
.bg-P { background: #fef08a; color: #854d0e; }
.bg-J { background: #bfdbfe; color: #1e3a8a; }
.bg-I { background: #fca5a5; color: #7f1d1d; }
.bg-R { background: #e5e7eb; color: #374151; }

/* =========================================
   BOTÓN FLOTANTE (FAB)
========================================= */
.fab { 
    position: fixed; 
    bottom: 20px; 
    right: 20px; 
    background: var(--success); 
    color: #fff; 
    padding: 15px 25px; 
    border-radius: 50px; 
    font-weight: 800; 
    border: none; 
    cursor: pointer; 
    box-shadow: 0 10px 15px -3px rgba(16, 185, 129, 0.4); 
    display: flex; 
    align-items: center; 
    gap: 10px; 
    z-index: 1000; 
    font-size: 15px; 
    transition: all 0.3s ease; 
}
.fab:hover { 
    transform: scale(1.05) translateY(-2px); 
    box-shadow: 0 20px 25px -5px rgba(16, 185, 129, 0.5); 
}

/* =========================================
   MODALES (VENTANAS EMERGENTES)
========================================= */
.modal { 
    display: none; 
    position: fixed; 
    inset: 0; 
    background: rgba(0,0,0,0.5); 
    z-index: 2000; 
    align-items: center; 
    justify-content: center; 
    backdrop-filter: blur(4px); 
}
.modal-content { 
    background: #fff; 
    padding: 2rem; 
    border-radius: 16px; 
    width: 95%; 
    max-width: 800px; 
    max-height: 90vh; 
    overflow-y: auto; 
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

/* =========================================
   PANTALLA DE LOGIN
========================================= */
#login-overlay { 
    position: fixed; 
    inset: 0; 
    background: #fff; 
    z-index: 9999; 
    display: flex; 
}
.login-side { 
    flex: 1; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    padding: 2rem; 
}
.login-card { 
    width: 100%; 
    max-width: 350px; 
}
.login-bg { 
    flex: 1.5; 
    background: linear-gradient(135deg, var(--primary), var(--purple)); 
    display: none; 
    align-items: center; 
    justify-content: center; 
    color: #fff; 
    text-align: center;
}
.login-bg h1 { font-size: 3rem; margin-bottom: 10px; font-weight: 800; }
.login-bg p { font-size: 1.2rem; opacity: 0.9; }

@media (min-width: 768px) { 
    .login-bg { display: flex; clip-path: polygon(10% 0, 100% 0, 100% 100%, 0% 100%); } 
}

/* =========================================
   MEDIA QUERIES (ADAPTACIÓN A CELULARES)
========================================= */
@media (max-width: 768px) {
    .header-main { 
        flex-direction: column; 
        gap: 10px; 
        padding: 1rem; 
        align-items: flex-start; 
    }
    .header-actions { 
        width: 100%; 
        display: flex; 
        flex-wrap: wrap; 
        gap: 5px;
    }
    .card, .table-responsive { margin: 1rem; }
    .stats-bar { grid-template-columns: 1fr 1fr; gap: 10px; }
    .quick-actions-panel { flex-direction: column; align-items: stretch; }
    .search-box input { width: 100%; }
    
    /* Evitar Zoom Automático en iOS al tocar inputs */
    .input-group input, 
    .input-group select { 
        padding: 14px 10px; 
        font-size: 16px; 
    }
    
    .btn { padding: 14px; width: 100%; margin-bottom: 5px; }
    .fab { 
        bottom: 15px; 
        right: 15px; 
        padding: 15px; 
        width: calc(100% - 30px); 
        justify-content: center; 
    }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}