/* ============================================================
   Sistema de Notas – Colegio Santa Lucía de Sutiaba
   Hoja de estilos principal | Mobile-First | Paleta azul oscuro
   ============================================================ */

/* --- Variables globales ------------------------------------ */
:root {
    --azul-oscuro:   #0f2040;
    --azul-medio:    #1e3a5f;
    --azul-vivo:     #2563eb;
    --azul-claro:    #3b82f6;
    --azul-palido:   #dbeafe;
    --blanco:        #ffffff;
    --gris-fondo:    #f1f5f9;
    --gris-borde:    #cbd5e1;
    --gris-texto:    #475569; /* slate-600 (antes #64748b) — mejor contraste sobre blanco y --gris-fondo */
    --texto-oscuro:  #1e293b;
    --error:         #dc2626;
    --error-fondo:   #fee2e2;
    --exito:         #16a34a;
    --exito-fondo:   #dcfce7;
    --advertencia:   #d97706;
    --adv-fondo:     #fef3c7;

    --radio:         0.5rem;
    --radio-lg:      1rem;
    --sombra:        0 4px 6px -1px rgba(0,0,0,.15), 0 2px 4px -2px rgba(0,0,0,.1);
    --sombra-lg:     0 10px 25px -5px rgba(0,0,0,.2), 0 8px 10px -6px rgba(0,0,0,.1);
    --transicion:    all .2s ease;
}

/* --- Reset y base ----------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Garantiza que el atributo HTML [hidden] nunca sea anulado por CSS */
[hidden] { display: none !important; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--gris-fondo);
    color: var(--texto-oscuro);
    line-height: 1.6;
    min-height: 100vh;
}

img { max-width: 100%; display: block; }
a  { color: var(--azul-vivo); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Tipografía ------------------------------------------- */
h1 { font-size: 1.75rem; }
h2 { font-size: 1.4rem;  }
h3 { font-size: 1.15rem; }
h1, h2, h3 { font-weight: 700; color: var(--azul-medio); line-height: 1.25; }

/* ============================================================
   PÁGINA DE LOGIN
   ============================================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, var(--azul-oscuro) 0%, var(--azul-medio) 60%, #1a4080 100%);
    padding: 1.5rem;
}

.login-card {
    background: var(--blanco);
    border-radius: var(--radio-lg);
    box-shadow: var(--sombra-lg);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 420px;
    animation: fadeInUp .4s ease both;
}

.login-logo {
    text-align: center;
    margin-bottom: 1.75rem;
}

.login-logo .escudo {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, var(--azul-medio), var(--azul-vivo));
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: .875rem;
    box-shadow: 0 4px 12px rgba(37,99,235,.35);
}

.login-logo .escudo svg { width: 38px; height: 38px; fill: var(--blanco); }

.login-logo h1 {
    font-size: 1.1rem;
    color: var(--azul-oscuro);
    line-height: 1.3;
}

.login-logo p {
    font-size: .8rem;
    color: var(--gris-texto);
    margin-top: .25rem;
}

.login-divider {
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--azul-palido), transparent);
    margin: 1.25rem 0;
}

/* --- Formulario ------------------------------------------- */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: .875rem;
    font-weight: 600;
    color: var(--azul-medio);
    margin-bottom: .375rem;
}

.form-input {
    width: 100%;
    padding: .625rem .875rem;
    border: 1.5px solid var(--gris-borde);
    border-radius: var(--radio);
    font-size: .9rem;
    color: var(--texto-oscuro);
    background: var(--blanco);
    transition: var(--transicion);
    outline: none;
}

.form-input:focus {
    border-color: var(--azul-vivo);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

.input-icon-wrapper {
    position: relative;
}

.input-icon-wrapper .form-input {
    padding-left: 2.5rem;
}

.input-icon {
    position: absolute;
    left: .75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gris-texto);
    width: 18px;
    height: 18px;
    pointer-events: none;
}

/* --- Botón principal -------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .625rem 1.25rem;
    border: none;
    border-radius: var(--radio);
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transicion);
    text-decoration: none;
    line-height: 1;
}

.btn-primary {
    background: var(--azul-vivo);
    color: var(--blanco);
    width: 100%;
    padding: .75rem;
    font-size: 1rem;
    border-radius: var(--radio);
    box-shadow: 0 2px 8px rgba(37,99,235,.35);
}

.btn-primary:hover {
    background: #1d4ed8;
    box-shadow: 0 4px 14px rgba(37,99,235,.45);
    transform: translateY(-1px);
    text-decoration: none;
    color: var(--blanco);
}

.btn-primary:active { transform: translateY(0); }

.btn-secondary {
    background: var(--gris-fondo);
    color: var(--texto-oscuro);
    border: 1.5px solid var(--gris-borde);
}

.btn-secondary:hover { background: #e2e8f0; text-decoration: none; }

.btn-danger  { background: var(--error); color: var(--blanco); }
.btn-danger:hover { background: #b91c1c; text-decoration: none; color: var(--blanco); }

.btn-sm { padding: .5rem 1rem; font-size: .8rem; min-height: 40px; }
.btn-icon { padding: .375rem; border-radius: var(--radio); min-width: 40px; min-height: 40px; }

/* --- Alertas ---------------------------------------------- */
.alert {
    padding: .75rem 1rem;
    border-radius: var(--radio);
    font-size: .875rem;
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    margin-bottom: 1rem;
}

.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }

.alert-error   { background: var(--error-fondo);   color: #991b1b; border-left: 4px solid var(--error); }
.alert-success { background: var(--exito-fondo);   color: #166534; border-left: 4px solid var(--exito); }
.alert-warning { background: var(--adv-fondo);     color: #92400e; border-left: 4px solid var(--advertencia); }
.alert-info    { background: var(--azul-palido);   color: var(--azul-medio); border-left: 4px solid var(--azul-vivo); }

/* ============================================================
   LAYOUT PRINCIPAL (páginas autenticadas)
   ============================================================ */

/* --- Sidebar ---------------------------------------------- */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 260px;
    height: 100vh;
    background: linear-gradient(180deg, var(--azul-oscuro) 0%, var(--azul-medio) 100%);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform .3s ease;
    overflow-y: auto;
}

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

.sidebar-header {
    padding: 1.5rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.1);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    color: var(--blanco);
}

.sidebar-brand .brand-icon {
    width: 40px; height: 40px;
    background: rgba(255,255,255,.15);
    border-radius: var(--radio);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.sidebar-brand svg { width: 22px; height: 22px; fill: var(--blanco); }
.sidebar-brand span { font-size: .85rem; font-weight: 700; line-height: 1.2; }

.sidebar-user {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    color: rgba(255,255,255,.7);
    font-size: .78rem;
}

.sidebar-user strong { display: block; color: var(--blanco); font-size: .9rem; }

.sidebar-nav { padding: .75rem 0; flex: 1; }

.nav-section-title {
    padding: .5rem 1.25rem .25rem;
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .08em;
    color: rgba(255,255,255,.4);
    text-transform: uppercase;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .625rem 1.25rem;
    color: rgba(255,255,255,.75);
    font-size: .875rem;
    font-weight: 500;
    transition: var(--transicion);
    text-decoration: none;
    border-left: 3px solid transparent;
}

.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }

.nav-link:hover, .nav-link.activo {
    color: var(--blanco);
    background: rgba(255,255,255,.08);
    border-left-color: var(--azul-claro);
    text-decoration: none;
}

/* --- Topbar ------------------------------------------------ */
.topbar {
    position: sticky;
    top: 0;
    height: 56px;
    background: var(--blanco);
    border-bottom: 1px solid var(--gris-borde);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    gap: 1rem;
    z-index: 50;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.topbar-menu-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--texto-oscuro);
    display: flex;
    align-items: center;
    padding: .25rem;
    border-radius: var(--radio);
}

.topbar-menu-btn:hover { background: var(--gris-fondo); }
.topbar-menu-btn svg { width: 22px; height: 22px; }

.topbar-title { font-weight: 700; color: var(--azul-medio); font-size: 1rem; flex: 1; }

.topbar-actions { display: flex; align-items: center; gap: .5rem; }

.topbar-user {
    display: flex; align-items: center; gap: .5rem;
    font-size: .85rem; color: var(--gris-texto);
}

.badge-rol {
    font-size: .65rem;
    font-weight: 700;
    padding: .15rem .45rem;
    border-radius: 999px;
    background: var(--azul-palido);
    color: var(--azul-medio);
    text-transform: capitalize;
}

/* --- Contenido principal ---------------------------------- */
.main-wrapper { display: flex; min-height: 100vh; }

.page-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.content-area {
    padding: 1.5rem 1.25rem;
    flex: 1;
}

/* --- Overlay sidebar (móvil) ------------------------------ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 99;
}

.sidebar-overlay.show { display: block; }

/* --- Cards ------------------------------------------------ */
.card {
    background: var(--blanco);
    border-radius: var(--radio-lg);
    box-shadow: var(--sombra);
    overflow: hidden;
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gris-borde);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    flex-wrap: wrap;
}

.card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--azul-medio);
    display: flex;
    align-items: center;
    gap: .5rem;
}

.card-title svg { width: 20px; height: 20px; color: var(--azul-vivo); }
.card-body { padding: 1.25rem; }

/* --- Tablas ----------------------------------------------- */
.table-wrapper { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

thead {
    background: var(--azul-oscuro);
    color: var(--blanco);
}

thead th {
    padding: .75rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: .78rem;
    letter-spacing: .04em;
    white-space: nowrap;
}

tbody tr { border-bottom: 1px solid var(--gris-borde); transition: background .15s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--gris-fondo); }
tbody td { padding: .75rem 1rem; vertical-align: middle; }

/* --- Badges de estado ------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .2rem .6rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-pendiente        { background: #fef9c3; color: #854d0e; }
.badge-aprobado         { background: var(--exito-fondo); color: #166534; }
.badge-rechazado        { background: var(--error-fondo); color: #991b1b; }
.badge-bloqueada        { background: #f3e8ff; color: #6b21a8; }
.badge-esperando        { background: #fff7ed; color: #9a3412; }
.badge-activo           { background: var(--exito-fondo); color: #166534; }
.badge-inactivo         { background: var(--gris-fondo);  color: var(--gris-texto); }

/* --- Formularios interiores ------------------------------- */
.form-row { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 1rem; }
.form-actions { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: 1.25rem; }
.form-hint { font-size: .78rem; color: var(--gris-texto); margin-top: .25rem; }
.form-input.error { border-color: var(--error); }
.form-error { font-size: .78rem; color: var(--error); margin-top: .25rem; }

/* --- Páginas de error ------------------------------------- */
.error-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 1rem;
    text-align: center;
    padding: 2rem;
    background: var(--gris-fondo);
}

.error-code {
    font-size: 5rem;
    font-weight: 900;
    color: var(--azul-medio);
    line-height: 1;
}

.error-page p { color: var(--gris-texto); max-width: 360px; }

/* --- Badges de rol ---------------------------------------- */
.badge-maestro      { background: var(--azul-palido); color: var(--azul-medio); }
.badge-subdireccion { background: #f3e8ff; color: #6b21a8; }
.badge-registro     { background: #fff7ed; color: #9a3412; }
.badge-direccion    { background: var(--azul-oscuro); color: var(--blanco); }

/* --- Helpers de tabla ------------------------------------- */
.table-loading,
.table-empty {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--gris-texto);
    font-size: .9rem;
}

.text-muted  { color: var(--gris-texto); font-size: .85rem; }
.text-error  { color: var(--error); }

code.user-code {
    background: var(--gris-fondo);
    padding: .15rem .4rem;
    border-radius: .25rem;
    font-size: .82rem;
    color: var(--azul-medio);
}

.acciones-grupo {
    display: flex;
    gap: .5rem;
    align-items: center;
}

.btn-accion { min-width: 40px; min-height: 40px; }

/* --- Page header ------------------------------------------ */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-title-inner {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: 1.25rem;
    color: var(--azul-medio);
    margin: 0;
}

.page-title-inner svg { color: var(--azul-vivo); }
.page-subtitle { color: var(--gris-texto); font-size: .875rem; margin-top: .25rem; }

/* --- Búsqueda en card ------------------------------------- */
.search-box {
    display: flex;
    align-items: center;
    gap: .5rem;
    background: var(--gris-fondo);
    border: 1.5px solid var(--gris-borde);
    border-radius: var(--radio);
    padding: .375rem .75rem;
}

.search-box svg { color: var(--gris-texto); flex-shrink: 0; }

.search-input {
    border: none;
    background: none;
    outline: none;
    font-size: .875rem;
    color: var(--texto-oscuro);
    width: 200px;
}

/* --- Modal ------------------------------------------------ */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn .2s ease;
}

.modal {
    background: var(--blanco);
    border-radius: var(--radio-lg);
    box-shadow: var(--sombra-lg);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: fadeInUp .25s ease;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.5rem;
    border-bottom: 1px solid var(--gris-borde);
}

.modal-titulo {
    font-size: 1rem;
    font-weight: 700;
    color: var(--azul-medio);
    margin: 0;
}

.modal-cerrar {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gris-texto);
    padding: .25rem;
    border-radius: var(--radio);
    display: flex;
    align-items: center;
    transition: var(--transicion);
}

.modal-cerrar:hover { background: var(--gris-fondo); color: var(--texto-oscuro); }

/* El SVG dentro del botón X no debe capturar clicks (Error #2) */
.modal-cerrar svg { pointer-events: none; }

/* El header no debe encogerse cuando el modal está restringido por max-height */
.modal-header { flex-shrink: 0; }

/* El <form> dentro del modal debe participar en el layout flex para que
   .modal-body pueda hacer scroll correctamente (Error #4) */
.modal > form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
    min-height: 0; /* crítico: permite al flex-child reducirse por debajo del contenido */
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gris-borde);
    display: flex;
    justify-content: flex-end;
    gap: .75rem;
    flex-shrink: 0; /* el footer siempre visible, nunca se encoge */
}

.req { color: var(--error); }

/* --- Toggle switch ---------------------------------------- */
.toggle-label {
    display: flex;
    align-items: center;
    gap: .75rem;
    cursor: pointer;
    user-select: none;
    font-size: .9rem;
}

.toggle-label input { display: none; }

.toggle-track {
    width: 42px;
    height: 24px;
    background: var(--gris-borde);
    border-radius: 999px;
    position: relative;
    transition: background .2s;
    flex-shrink: 0;
}

.toggle-thumb {
    position: absolute;
    top: 3px; left: 3px;
    width: 18px; height: 18px;
    background: var(--blanco);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
    transition: transform .2s;
}

.toggle-label input:checked ~ .toggle-track           { background: var(--azul-vivo); }
.toggle-label input:checked ~ .toggle-track .toggle-thumb { transform: translateX(18px); }

/* --- Radio group (sexo) ----------------------------------- */
.radio-group {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
}
.radio-label {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .9rem;
    cursor: pointer;
}
.radio-label input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: var(--azul-vivo);
    cursor: pointer;
}

/* --- Spinner ---------------------------------------------- */
.spinner {
    display: inline-block;
    width: 20px; height: 20px;
    border: 3px solid rgba(37,99,235,.2);
    border-top-color: var(--azul-vivo);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    vertical-align: middle;
}

.spinner-sm { width: 14px; height: 14px; border-width: 2px; }

@keyframes spin { to { transform: rotate(360deg); } }

/* --- Toast ------------------------------------------------ */
#toastContainer {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .75rem 1.1rem;
    border-radius: var(--radio);
    font-size: .875rem;
    font-weight: 500;
    box-shadow: var(--sombra-lg);
    min-width: 240px;
    max-width: 340px;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity .3s ease, transform .3s ease;
}

.toast.toast-show { opacity: 1; transform: translateY(0); }
.toast-exito { background: var(--exito-fondo); color: #166534; border-left: 4px solid var(--exito); }
.toast-error { background: var(--error-fondo); color: #991b1b; border-left: 4px solid var(--error); }

/* --- Código CUP ------------------------------------------- */
.cup-ayuda {
    font-size: .72rem;
    font-weight: 400;
    color: var(--gris-texto);
    margin-left: .25rem;
}

.cup-wrapper {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.cup-input { flex: 1; font-family: monospace; letter-spacing: .08em; font-size: 1rem; }

.cup-indicador {
    font-size: .75rem;
    font-weight: 600;
    white-space: nowrap;
    min-width: 160px;
}

.cup-valido   { color: var(--exito); }
.cup-invalido { color: var(--error); }

code.cup-code {
    background: var(--azul-palido);
    color: var(--azul-medio);
    padding: .2rem .5rem;
    border-radius: .3rem;
    font-size: .85rem;
    font-family: monospace;
    letter-spacing: .06em;
    font-weight: 700;
}

/* --- Barra de filtros ------------------------------------- */
.filtros-grid {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: center;
}

/* --- Módulo Asignaciones ---------------------------------- */
.maestro-selector-row {
    display: flex;
    align-items: flex-end;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.maestro-info {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .5rem .875rem;
    background: var(--azul-palido);
    border-radius: var(--radio);
    flex-shrink: 0;
}

.maestro-info-nombre {
    font-weight: 700;
    color: var(--azul-medio);
    font-size: .9rem;
}

.maestro-readonly {
    padding: .625rem .875rem;
    background: var(--gris-fondo);
    border: 1.5px solid var(--gris-borde);
    border-radius: var(--radio);
    font-size: .9rem;
    color: var(--texto-oscuro);
    font-weight: 600;
}

.asig-inicial,
.asig-vacio {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .875rem;
    padding: 3rem 1rem;
    color: var(--gris-texto);
    text-align: center;
}

.asig-vacio { padding: 2.5rem 1rem; }
.asig-inicial p, .asig-vacio p { max-width: 320px; font-size: .9rem; }

/* --- Botones adicionales ---------------------------------- */
.btn-success { background: var(--exito); color: var(--blanco); }
.btn-success:hover { background: #15803d; text-decoration: none; color: var(--blanco); }

.btn-warning { background: var(--advertencia); color: var(--blanco); }
.btn-warning:hover { background: #b45309; text-decoration: none; color: var(--blanco); }

/* --- Dashboard – Grid de estadísticas --------------------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--blanco);
    border-radius: var(--radio-lg);
    box-shadow: var(--sombra);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border-left: 4px solid transparent;
}

.stat-blue   { border-left-color: var(--azul-vivo); }
.stat-purple { border-left-color: #7c3aed; }
.stat-green  { border-left-color: var(--exito); }
.stat-orange { border-left-color: var(--advertencia); }

.stat-icon {
    width: 52px; height: 52px;
    border-radius: var(--radio);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.stat-blue   .stat-icon { background: var(--azul-palido); color: var(--azul-vivo); }
.stat-purple .stat-icon { background: #ede9fe; color: #7c3aed; }
.stat-green  .stat-icon { background: var(--exito-fondo); color: var(--exito); }
.stat-orange .stat-icon { background: var(--adv-fondo); color: var(--advertencia); }

.stat-info { display: flex; flex-direction: column; }

.stat-valor {
    font-size: 2rem;
    font-weight: 800;
    color: var(--texto-oscuro);
    line-height: 1;
}

.stat-label {
    font-size: .78rem;
    color: var(--gris-texto);
    margin-top: .25rem;
    font-weight: 500;
}

/* --- Módulo Notas – Filtros ------------------------------- */
.notas-filtros {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: flex-end;
}

/* --- Módulo Notas – Celdas de nota ------------------------ */
.nota-input {
    width: 90px;
    padding: .35rem .6rem;
    font-size: .9rem;
    text-align: center;
    font-weight: 600;
}

.nota-bloqueada {
    display: inline-block;
    min-width: 60px;
    text-align: center;
    font-weight: 700;
    color: #6b21a8;
    background: #f3e8ff;
    border-radius: var(--radio);
    padding: .2rem .6rem;
    font-size: .9rem;
}

.nota-valor {
    font-weight: 700;
    font-size: .95rem;
    color: var(--texto-oscuro);
}

.nota-nueva-solicitada {
    font-size: .8rem;
    font-weight: 600;
    color: var(--advertencia);
    background: var(--adv-fondo);
    border-radius: var(--radio);
    padding: .1rem .4rem;
    white-space: nowrap;
}

/* --- Tabla vacia (alias) ---------------------------------- */
.table-vacio {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--gris-texto);
    font-size: .9rem;
}

/* --- Modal Solicitud – info resumen ----------------------- */
.solicitud-info {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: .4rem .75rem;
    align-items: baseline;
    background: var(--gris-fondo);
    border-radius: var(--radio);
    padding: .875rem 1rem;
    font-size: .875rem;
    color: var(--gris-texto);
}

.solicitud-info strong { color: var(--texto-oscuro); font-weight: 700; }

/* --- Notas en tabla del director -------------------------- */
code.cup-code { font-family: monospace; }

/* --- Animaciones ------------------------------------------ */
@keyframes fadeIn    { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp  {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   MÓDULO BOLETA DE NOTAS
   ============================================================ */

/* Barra de búsqueda */
.boleta-search-row {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: flex-end;
}

/* Grid de info del estudiante */
.boleta-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: .75rem 1.5rem;
}

.boleta-info-item {
    display: flex;
    flex-direction: column;
    gap: .15rem;
}

.boleta-info-label {
    font-size: .72rem;
    font-weight: 600;
    color: var(--gris-texto);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.boleta-info-val {
    font-size: .95rem;
    color: var(--texto-oscuro);
}

/* Tabla boleta */
.boleta-th-nota   { width: 110px; text-align: center !important; }
.boleta-th-estado { width: 110px; text-align: center !important; }
.boleta-td-nota   { text-align: center; font-weight: 600; font-size: .9rem; }
.boleta-td-estado { text-align: center; }
.boleta-td-materia { font-weight: 600; }

.boleta-nota-prom {
    font-weight: 800;
    font-size: 1rem;
    color: var(--azul-medio);
}

.boleta-tfoot-row {
    border-top: 2px solid var(--azul-medio);
    background: var(--azul-palido);
}

.boleta-tfoot-row td { padding: .75rem 1rem; }

.boleta-row-reprobado td { color: var(--error); }
.boleta-row-reprobado td:first-child { color: var(--texto-oscuro); }

/* Firmas — ocultas en pantalla, visibles en impresión */
.boleta-firmas    { display: none; }
.boleta-footer-print { display: none; }
.solo-print       { display: none; }
.no-print         { /* visible por defecto */ }

/* Encabezado de impresión (oculto en pantalla) */
.boleta-print-header { display: none; }

/* ============================================================
   @MEDIA PRINT — Boleta tamaño Carta
   ============================================================ */
@media print {
    @page {
        size: letter portrait;
        margin: 1.5cm 2cm;
    }

    /* Preservar colores de fondo en impresión */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust:         exact !important;
        color-adjust:               exact !important;
    }

    /* Ocultar navegación y controles */
    .sidebar,
    .sidebar-overlay,
    .topbar,
    .no-print,
    #toastContainer { display: none !important; }

    /* Resetear layout */
    body { background: white !important; font-size: 10.5pt; color: #000; }
    .main-wrapper { display: block !important; }
    .page-content { margin-left: 0 !important; }
    .content-area { padding: 0 !important; }

    /* Cards sin sombra */
    .card {
        box-shadow: none !important;
        border: 1px solid #ccc;
        border-radius: 0 !important;
        margin-bottom: .6cm !important;
    }

    /* Mostrar elementos solo-print */
    .solo-print { display: block !important; }

    /* ── Encabezado institucional ── */
    .boleta-print-header {
        display: block !important;
        text-align: center;
        margin-bottom: .6cm;
        padding-bottom: .4cm;
        border-bottom: 3px double #0f2040;
    }

    .boleta-escudo-print { margin-bottom: .25cm; }
    .boleta-escudo-print svg { fill: #0f2040; }

    .boleta-colegio-nombre {
        font-size: 14pt;
        font-weight: 900;
        color: #0f2040;
        letter-spacing: .06em;
        margin: .1cm 0 .05cm;
    }

    .boleta-colegio-lugar {
        font-size: 10pt;
        color: #444;
        margin-bottom: .25cm;
    }

    .boleta-divider-print {
        height: 1px;
        background: #0f2040;
        margin: .2cm auto;
        width: 40%;
    }

    .boleta-titulo-doc {
        font-size: 13pt;
        font-weight: 800;
        color: #0f2040;
        letter-spacing: .04em;
        margin-bottom: .1cm;
    }

    .boleta-anio-doc { font-size: 11pt; color: #222; }

    /* ── Info del estudiante ── */
    .boleta-info-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: .3cm .8cm;
    }

    .boleta-info-label { font-size: 8pt; color: #555; }
    .boleta-info-val   { font-size: 10.5pt; }

    /* ── Tabla de notas ── */
    thead {
        background: #0f2040 !important;
        color: white !important;
    }

    thead th { font-size: 9pt; padding: .25cm .35cm; }

    tbody td { font-size: 10pt; padding: .2cm .35cm; }

    tfoot td { font-size: 10.5pt; }

    tbody tr { border-bottom: 1px solid #ddd; }
    tbody tr:nth-child(even) { background: #f8fafc !important; }

    /* Evitar cortes dentro de filas */
    tbody tr { page-break-inside: avoid; }

    /* ── Bloque de firmas ── */
    .boleta-firmas {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr);
        gap: 0 1.5cm;
        margin-top: 1.5cm;
        padding-top: .5cm;
        border-top: 1px solid #ccc;
        page-break-inside: avoid;
    }

    .firma-bloque { text-align: center; }

    .firma-linea {
        height: 1px;
        background: #000;
        margin: 1.5cm auto .2cm;
        width: 80%;
    }

    .firma-cargo {
        font-size: 9pt;
        color: #444;
        font-style: italic;
    }

    /* ── Pie de página de impresión ── */
    .boleta-footer-print {
        display: block !important;
        margin-top: .5cm;
        text-align: center;
        font-size: 8pt;
        color: #777;
        border-top: 1px solid #eee;
        padding-top: .2cm;
    }

    /* Links como texto normal */
    a { color: black !important; text-decoration: none; }
}

/* ============================================================
   MÓDULO BOLETAS POR GRADO
   ============================================================ */

/* Barra de navegación prev/next + acciones de impresión */
.bol-action-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: 1.25rem;
    padding: .875rem 1.25rem;
    background: var(--blanco);
    border-radius: var(--radio);
    box-shadow: var(--sombra);
}

.bol-nav-bar {
    display: flex;
    align-items: center;
    gap: .625rem;
}

.bol-nav-contador {
    font-size: .85rem;
    font-weight: 700;
    color: var(--azul-medio);
    min-width: 150px;
    text-align: center;
    padding: .3rem .625rem;
    background: var(--azul-palido);
    border-radius: var(--radio);
}

.bol-actions {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    align-items: center;
}

/* Fila activa en la tabla resumen */
.bol-fila-activa {
    background: var(--azul-palido) !important;
    outline: 2px solid var(--azul-vivo);
    outline-offset: -2px;
}

.bol-fila-activa td { color: var(--azul-medio); }

/* Alineación de texto central en tabla */
.text-center { text-align: center !important; }

/* Print: ocultar barra de acciones, solo mostrar boleta activa */
@media print {
    .bol-action-bar { display: none !important; }
    #bolCardLista   { display: none !important; }
}

/* ============================================================
   TABLAS → TARJETAS EN MÓVIL (opt-in)
   Agregar la clase "cards-mobile" al .table-wrapper de una tabla, y
   data-label="Columna" a cada <td>, para que en pantallas angostas la
   tabla se vea como una lista de tarjetas en vez de forzar scroll
   horizontal. Las tablas que NO tengan esta clase siguen igual que antes.
   ============================================================ */
@media screen and (max-width: 640px) {
    .table-wrapper.cards-mobile table,
    .table-wrapper.cards-mobile tbody,
    .table-wrapper.cards-mobile tfoot,
    .table-wrapper.cards-mobile tr,
    .table-wrapper.cards-mobile td { display: block; width: 100%; }

    .table-wrapper.cards-mobile thead { display: none; }

    .table-wrapper.cards-mobile tbody tr,
    .table-wrapper.cards-mobile tfoot tr {
        margin-bottom: .75rem;
        border: 1px solid var(--gris-borde);
        border-radius: var(--radio);
        padding: .5rem .75rem;
    }

    .table-wrapper.cards-mobile td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: .75rem;
        padding: .4rem 0;
        border-bottom: 1px solid var(--gris-fondo);
        text-align: right;
    }

    .table-wrapper.cards-mobile td:last-child { border-bottom: none; }

    .table-wrapper.cards-mobile td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--gris-texto);
        text-align: left;
        flex-shrink: 0;
    }

    /* Celdas sin dato visible (ej. checkbox/acción sin label) no muestran renglón vacío */
    .table-wrapper.cards-mobile td:empty { display: none; }
}

/* ============================================================
   RESPONSIVO – Tablet (≥ 768px)
   ============================================================ */
@media (min-width: 768px) {
    .form-row { flex-direction: row; }
    .form-row > * { flex: 1; }
    .content-area { padding: 2rem; }
}

/* ============================================================
   RESPONSIVO – Desktop (≥ 1024px)
   ============================================================ */
@media (min-width: 1024px) {
    .sidebar { transform: translateX(0); }
    .topbar-menu-btn { display: none; }
    .sidebar-overlay { display: none !important; }

    .page-content { margin-left: 260px; }
}
