:root {
    --uas-blue: #002F6C;
    --uas-gold: #D4AF37;
    --light-bg: #e9ecef;
}

* {
    box-sizing: border-box;
    font-family: 'Segoe UI', Arial, sans-serif;
}

body {
    background-color: var(--light-bg);
    margin: 0;
    padding: 0;
    display: block;
    /* Changed from flex to block to fix layout issues */
    height: 100vh;
    overflow: hidden;
}

/* BIENVENIDA */
#welcome-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--uas-blue) 0%, #001a3d 100%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
}

.login-card {
    background: white;
    width: 450px;
    padding: 40px;
    border-radius: 12px;
    text-align: center;
    border-top: 6px solid var(--uas-gold);
}

.login-logos img {
    height: 80px;
    object-fit: contain;
    margin: 0 10px;
}

.login-card h1 {
    color: var(--uas-blue);
    margin: 10px 0;
    font-size: 22px;
    font-weight: 800;
}

.form-group {
    text-align: left;
    margin-bottom: 15px;
}

.form-group label {
    font-size: 12px;
    font-weight: bold;
    color: var(--uas-blue);
    display: block;
    margin-bottom: 5px;
}

.form-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid #eee;
    border-radius: 6px;
}

.btn-start {
    width: 100%;
    padding: 15px;
    background: var(--uas-blue);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 10px;
}

.btn-start:hover {
    background: #004090;
}

/* APP LAYOUT */
#app-container {
    display: flex;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.5s;
    pointer-events: none;
}

#app-container.active {
    opacity: 1;
    pointer-events: all;
}

.sidebar {
    width: 360px;
    background: white;
    border-right: 1px solid #ccc;
    display: flex;
    flex-direction: column;
    padding: 20px;
    z-index: 100;
    overflow-y: auto;
}

.control-group {
    margin-bottom: 15px;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #eee;
}

.nav-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    align-items: center;
}

.btn {
    width: 100%;
    padding: 10px;
    margin-bottom: 5px;
    cursor: pointer;
    color: white;
    border: none;
    border-radius: 4px;
    font-weight: bold;
    font-size: 12px;
}

.btn-print {
    background: var(--uas-blue);
}

.btn-print-all {
    background: #2c3e50;
}

.btn-teacher {
    background: #8e44ad;
    border: 1px solid #732d91;
}

.btn-save {
    background: #27ae60;
}

.btn-backup {
    background: #e67e22;
}

.btn-upload {
    background: #2980b9;
}

.btn-reset {
    background: #c0392b;
}

.btn-nav {
    background: var(--uas-blue);
    color: white;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.preview-area {
    flex: 1;
    padding: 40px;
    overflow: auto;
    background: #5a6b7c;
    display: flex;
    justify-content: center;
    position: relative;
}

/* HOJAS EN PANTALLA (VISTA WEB) */
.sheet-container {
    background: white;
    padding: 40px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    font-family: Arial, sans-serif;
    margin-bottom: 30px;
    width: 1100px;
    min-height: 800px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* ESTILOS COMUNES */
.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.logo-left,
.logo-right {
    width: 90px;
    height: 90px;
    object-fit: contain;
}

.header-center {
    text-align: center;
    flex: 1;
}

.header-center h1 {
    color: var(--uas-blue);
    font-size: 22px;
    font-weight: 900;
    margin: 0;
    letter-spacing: 1px;
    font-family: Arial, sans-serif;
}

.header-center h2 {
    color: #666;
    font-size: 15px;
    margin: 5px 0 0 0;
    font-weight: 600;
    font-family: Arial, sans-serif;
}

.info-bar {
    border-top: 3px solid var(--uas-blue);
    border-bottom: 3px solid var(--uas-blue);
    padding: 4px 0;
    display: flex;
    justify-content: space-between;
    font-weight: bold;
    font-size: 13px;
    margin-bottom: 10px;
    font-family: Arial, sans-serif;
}

.group-title {
    text-align: center;
    color: #7f8c8d;
    font-size: 20px;
    font-weight: bold;
    margin: 10px 0;
    text-transform: uppercase;
    font-family: Arial, sans-serif;
}

.control-box {
    border: 1px solid #000;
    text-align: center;
    font-weight: bold;
    padding: 4px;
    margin-bottom: 15px;
    font-size: 13px;
    background: #fff;
    font-family: Arial, sans-serif;
}

/* New membrete elements (screen view) */
.linea-azul {
    border-bottom: 4px solid #002b5c;
    margin-bottom: 5px;
}

.fila-ciclo-semestre {
    display: flex;
    justify-content: space-between;
    font-weight: bold;
    font-size: 13px;
    margin-bottom: 5px;
    color: #333;
    font-family: Arial, sans-serif;
}

.linea-dorada {
    border-bottom: 4px solid #c5911e;
    margin-bottom: 10px;
}

.titulo-grupo {
    text-align: center;
    color: #7f8c8d;
    font-size: 20px;
    font-weight: bold;
    margin: 10px 0;
    text-transform: uppercase;
    font-family: Arial, sans-serif;
}

.subtitulo-control {
    border: 1px solid #000;
    text-align: center;
    font-weight: bold;
    padding: 4px;
    margin-bottom: 15px;
    font-size: 13px;
    background: #fff;
    font-family: Arial, sans-serif;
}

/* TABLA GRUPAL */
.schedule-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    margin-bottom: 20px;
    table-layout: fixed;
    flex-grow: 1;
    font-family: Arial, sans-serif;
}

.schedule-table th,
.schedule-table td {
    border: 2px solid #000 !important;
    padding: 6px 4px;
    text-align: center;
    vertical-align: middle;
    word-wrap: break-word;
}

.schedule-table th {
    height: 40px;
    background: #fff;
    color: #000;
    font-weight: 800;
    text-transform: uppercase;
}

.schedule-table td {
    height: 60px;
    font-size: 11px;
}

.screen-only-color th {
    background: #f0f0f0;
}

.schedule-table td:hover {
    background-color: #fff9c4;
    cursor: pointer;
}

.doc-footer {
    text-align: center;
    margin-top: 20px;
    padding-bottom: 10px;
    font-family: Arial, sans-serif;
}

.director-name {
    font-weight: bold;
    font-size: 13px;
    margin-bottom: 5px;
    text-transform: uppercase;
}

.director-title {
    font-size: 13px;
    margin-bottom: 15px;
}

.date-line {
    border-top: 1px solid #000;
    display: inline-block;
    padding-top: 5px;
    min-width: 400px;
    font-weight: bold;
    font-size: 12px;
}

/* ESTILOS VISTA PREVIA MAESTRO (WEB) */
#teacher-preview-area {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #5a6b7c;
    z-index: 500;
    display: none;
    flex-direction: column;
    align-items: center;
    padding: 40px;
    overflow: auto;
}

.teacher-sheet {
    background: white;
    width: 21.59cm;
    min-height: 27.94cm;
    max-height: 27.94cm;
    padding: 2cm 2.5cm;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    font-family: 'Times New Roman', Times, serif;
    font-size: 12pt;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    page-break-after: always;
    overflow: hidden;
}

.teacher-toolbar {
    width: 21.59cm;
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    justify-content: flex-end;
}

.oficio-spacer {
    height: 60px;
    flex-shrink: 0;
}

.oficio-header {
    margin-bottom: 30px;
    font-weight: bold;
    text-transform: uppercase;
    line-height: 1.5;
    font-size: 12pt;
}

.oficio-body {
    text-align: justify;
    margin-bottom: 18px;
    line-height: 1.8;
    font-size: 12pt;
}

.oficio-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 18px;
    font-family: Arial, sans-serif;
    font-size: 9pt;
}

.oficio-table th,
.oficio-table td {
    border: 1px solid #000;
    padding: 5px 4px;
    text-align: center;
    vertical-align: middle;
}

.oficio-table th {
    background: #f0f0f0;
    font-weight: bold;
    font-size: 8.5pt;
    text-transform: uppercase;
}

.oficio-table td {
    font-size: 8.5pt;
}

.oficio-footer {
    text-align: center;
    margin-top: auto;
    font-weight: bold;
    padding-bottom: 10px;
}

.oficio-atentamente {
    letter-spacing: 3px;
    font-size: 11pt;
    margin-bottom: 2px;
}

.oficio-lema {
    font-style: italic;
    font-weight: normal;
    margin-bottom: 12px;
    font-size: 11pt;
}

.oficio-sign {
    margin-top: 60px;
    border-top: 1px solid #000;
    display: inline-block;
    padding-top: 8px;
    min-width: 320px;
    font-size: 11pt;
    line-height: 1.4;
}

/* --- IMPRESIÓN (LÓGICA CRÍTICA) --- */
@page landscapePage {
    size: landscape;
    margin: 0.5cm;
}

@page portraitPage {
    size: portrait;
    margin: 0;
}

/* ========================================= */
/* ESTILOS DE ENCABEZADOS (PANTALLA - RAINBOW) */
/* ========================================= */

/* Solo aplicar estos colores en PANTALLA, no en impresión */
@media screen {

    /* === OCULTAR SECCIONES DE IMPRESIÓN EN PANTALLA === */
    .doc-footer {
        display: none !important;
    }

    .control-box {
        display: none !important;
    }

    .schedule-table th:nth-child(1) {
        background-color: #800000 !important;
        color: white;
    }

    /* Unidad */
    .schedule-table th:nth-child(2) {
        background-color: #C8A2C8 !important;
        color: black;
    }

    /* Docente */
    .schedule-table th:nth-child(3) {
        background-color: #9ACD32 !important;
        color: black;
    }

    /* Lunes */
    .schedule-table th:nth-child(4) {
        background-color: #FFD700 !important;
        color: black;
    }

    /* Martes */
    .schedule-table th:nth-child(5) {
        background-color: #FFC0CB !important;
        color: black;
    }

    /* Miércoles */
    .schedule-table th:nth-child(6) {
        background-color: #00FFFF !important;
        color: black;
    }

    /* Jueves */
    .schedule-table th:nth-child(7) {
        background-color: #FFA500 !important;
        color: black;
    }

    /* Viernes */
    .schedule-table th:nth-child(8) {
        background-color: #FFFF00 !important;
        color: black;
    }

    /* Total */
}


/* MARGENES DE IMPRESION SANOS */
@media print {
    @page {
        size: letter portrait;
        margin: 15mm 20mm 15mm 20mm;
    }

    /* Global table containment for clean print */
    table {
        width: 100% !important;
        max-width: 100% !important;
        border-collapse: collapse !important;
        page-break-inside: auto;
    }

    tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }

    body {
        background: white;
        margin: 0;
        padding: 0;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        width: 100%;
        height: auto;
        overflow: visible;
    }

    * {
        box-sizing: border-box !important;
    }

    /* Ocultar elementos de interfaz */
    .sidebar,
    #welcome-screen,
    .modal-overlay,
    .btn,
    .teacher-toolbar,
    .modal,
    #admin-panel,
    #teacher-catalog {
        display: none !important;
    }

    /* Asegurar que el contenedor principal ocupe lo necesario */
    #app-container {
        width: 100%;
        height: auto;
        display: block;
    }

    .preview-area {
        position: static;
        display: block !important;
        padding: 0;
        margin: 0;
        overflow: visible;
        background: white;
        width: 100%;
        height: auto;
    }

    /* --- ESTILOS ESPECÍFICOS PARA LA HOJA DE HORARIO EN HORIZONTAL --- */
    .sheet-container {
        width: 95% !important;
        /* 95% para evitar bordes cortados */
        max-width: 95% !important;
        margin: 0 auto !important;
        /* Centrado */
        height: auto !important;
        /* Permitir flujo natural */
        padding: 0 !important;
        border: none;
        box-shadow: none;
        display: block;
        /* Flujo normal, no Flex forzado */
        page-break-after: always;
    }

    /* HEADER */
    .header-top {
        margin-bottom: 5px;
    }

    .logo-left,
    .logo-right {
        width: 70px;
        height: 70px;
        opacity: 1 !important;
    }

    .header-center h1 {
        font-size: 16px;
        color: #00274C !important;
    }

    .header-center h2 {
        font-size: 12px;
        color: #000 !important;
    }

    /* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
       CONTROL DE ASISTENCIA — Cloned Membrete Format
       ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

    /* Sheet container: simulates physical page via padding (browser-proof) */
    .official-sheet {
        width: 279.4mm !important;
        /* Landscape letter width */
        height: 215.9mm !important;
        /* Landscape letter height */
        box-sizing: border-box !important;
        padding: 30mm 20mm 15mm 20mm !important;
        /* TOP RIGHT BOTTOM LEFT */
        margin: 0 auto !important;
        background: white !important;
    }

    /* Header logos row */
    .header-top {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        margin-bottom: 5px !important;
        border-bottom: none !important;
        padding-bottom: 0 !important;
    }

    /* Blue institutional line */
    .linea-azul {
        border-bottom: 4px solid #002b5c !important;
        margin-bottom: 5px !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Ciclo / Semestre row */
    .fila-ciclo-semestre {
        display: flex !important;
        justify-content: space-between !important;
        font-weight: bold !important;
        font-size: 11pt !important;
        margin-bottom: 5px !important;
        color: black !important;
    }

    /* Gold institutional line */
    .linea-dorada {
        border-bottom: 4px solid #c5911e !important;
        margin-bottom: 10px !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Group title (centered gray) */
    .titulo-grupo {
        text-align: center !important;
        font-weight: bold !important;
        font-size: 12pt !important;
        color: #555 !important;
        margin-bottom: 5px !important;
    }

    /* Control de Asistencia subtitle (bordered) */
    .subtitulo-control {
        text-align: center !important;
        font-weight: bold !important;
        font-size: 10pt !important;
        border: 1px solid #000 !important;
        padding: 3px !important;
        margin-bottom: 10px !important;
    }

    /* TABLA EXPANDIDA */
    .schedule-table {
        margin-bottom: 0;
        font-size: 10px;
        border-collapse: collapse !important;
        width: 100% !important;
        flex-grow: 1;
        /* CRECER para ocupar todo el espacio disponible */
        display: table;
        /* Mantener comportamiento de tabla */
        height: auto !important;
    }

    /* Forzar filas a expandirse */
    .schedule-table tbody {
        display: table-row-group;
        height: 100%;
    }

    .schedule-table tr {
        height: 1fr;
        /* Intentar distribuir espacio */
    }

    /* AHORRO DE TINTA: Headers blanco y negro */
    .th-materia,
    .th-docente,
    .th-lunes,
    .th-martes,
    .th-miercoles,
    .th-jueves,
    .th-viernes,
    .th-total,
    .schedule-table th:nth-child(n) {
        background: white !important;
        color: black !important;
        border: 1px solid black !important;
        text-align: center;
        vertical-align: middle;
        font-weight: bold;
    }

    .schedule-table td {
        background: white !important;
        border: 1px solid black !important;
        color: black !important;
        vertical-align: middle;
        /* Increase height/padding for signatures */
        padding: 0 4px !important;
        height: 50px !important;
        /* Altura forzada para firmas */
    }

    .schedule-table tr {
        height: 50px !important;
        /* Altura mínima de fila */
    }

    /* Footer — VISIBLE en impresión, separado de la tabla */
    .doc-footer {
        display: block !important;
        margin-top: 45px !important;
        padding-bottom: 0 !important;
        width: 100%;
    }

    .control-box {
        display: block !important;
        margin-bottom: 5px !important;
    }


    /* --- LÓGICA DE IMPRESIÓN POR TIPO --- */

    /* GRUPO INDIVIDUAL */
    body.printing-group .preview-area {
        display: block !important;
    }

    body.printing-group #single-sheet {
        display: block !important;
        /* transform: scale(0.95);  Opcional: escalar si se corta */
    }

    body.printing-group #teacher-preview-area,
    body.printing-group #batch-print-container {
        display: none !important;
    }

    /* BATCH */
    body.batch-printing #batch-print-container {
        display: block !important;
    }

    body.batch-printing .preview-area,
    body.batch-printing #teacher-preview-area {
        display: none !important;
    }

    body.batch-printing .sheet-container {
        height: 100vh !important;
        page-break-after: always;
    }

    /* ══════════════════════════════════════════════════════════════
       CARGA DOCENTE (VERTICAL/PORTRAIT) — Institutional Print Mode
       ══════════════════════════════════════════════════════════════ */

    /* 1. HIDE everything except the teacher report */
    body.printing-teacher #dashboard-menu,
    body.printing-teacher #matrix-view,
    body.printing-teacher #batch-print-container,
    body.printing-teacher #single-sheet,
    body.printing-teacher #app-container>.sidebar,
    body.printing-teacher #app-container>.controls-bar,
    body.printing-teacher .teacher-toolbar,
    body.printing-teacher .modal-overlay,
    body.printing-teacher #teacher-catalog,
    body.printing-teacher #plantilla-view,
    body.printing-teacher #welcome-screen {
        display: none !important;
    }

    /* 2. Reset body for clean white print */
    body.printing-teacher {
        background: white !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* 3. Preview area: full width, no overflow constraints */
    body.printing-teacher .preview-area {
        display: block !important;
        position: static;
        overflow: visible;
        width: 100%;
        height: auto;
        padding: 0;
        margin: 0;
        background: white;
    }

    body.printing-teacher #teacher-preview-area {
        display: block !important;
        position: static;
        width: 100%;
        height: auto;
        overflow: visible;
        background: white;
        padding: 0;
        margin: 0;
    }

    /* 4. Teacher sheet: simulates physical margins via padding (browser-proof) */
    body.printing-teacher .teacher-sheet {
        width: 215.9mm !important;
        /* Exact US Letter width */
        min-height: 279.4mm !important;
        /* Exact US Letter height */
        max-width: none;
        max-height: none;
        margin: 0 auto !important;
        /* TOP (letterhead space), RIGHT, BOTTOM, LEFT */
        padding: 45mm 20mm 25mm 20mm !important;
        box-shadow: none;
        border: none;
        background: white;
        page-break-after: always;
        overflow: visible;
        box-sizing: border-box !important;
        font-family: Arial, sans-serif;
    }

    /* 5. Spacer: no top gap (padding handles spacing) */
    body.printing-teacher .oficio-spacer {
        height: 0;
    }

    /* 6. Header styling */
    body.printing-teacher .oficio-header {
        font-size: 12pt;
        line-height: 1.6;
        margin-bottom: 20px;
    }

    body.printing-teacher .oficio-header #t-name {
        font-size: 12pt;
        font-weight: bold;
    }

    /* 7. Body text */
    body.printing-teacher .oficio-body {
        font-size: 11pt;
        line-height: 1.5;
        margin-bottom: 15px;
        text-align: justify;
    }

    /* 8. TABLE — Institutional formal style, overflow-proof */
    body.printing-teacher .oficio-table {
        width: 100% !important;
        max-width: 100% !important;
        border-collapse: collapse !important;
        table-layout: fixed !important;
        margin: 20px 0 !important;
        font-family: Arial, sans-serif !important;
        font-size: 11pt !important;
        word-wrap: break-word !important;
    }

    body.printing-teacher .oficio-table th,
    body.printing-teacher .oficio-table td {
        border: 1px solid #000 !important;
        padding: 8px !important;
        text-align: center !important;
        vertical-align: middle !important;
    }

    body.printing-teacher .oficio-table th {
        background-color: #f2f2f2 !important;
        font-weight: bold !important;
        font-size: 10pt !important;
        text-transform: uppercase !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    body.printing-teacher .oficio-table td {
        font-size: 10pt !important;
    }

    /* First column (MATERIA): left-aligned for readability */
    body.printing-teacher .oficio-table td:first-child {
        text-align: left !important;
        padding-left: 10px !important;
    }

    /* 9. Footer & Signature */
    body.printing-teacher .oficio-footer {
        margin-top: 30px;
        text-align: center;
        font-size: 11pt;
    }

    body.printing-teacher .oficio-atentamente {
        font-size: 11pt;
        letter-spacing: 4px;
    }

    body.printing-teacher .oficio-lema {
        font-size: 10pt;
        margin-top: 5px;
    }

    body.printing-teacher .oficio-sign {
        margin-top: 50px;
        font-size: 11pt;
    }
}

/* MODALS */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal {
    background: white;
    padding: 25px;
    border-radius: 8px;
    width: 500px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.grid-view-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
    margin-top: 15px;
}

.grid-item {
    padding: 10px;
    border: 1px solid #ccc;
    text-align: center;
    cursor: pointer;
}

.grid-item.has-data {
    background: #e8f5e9;
    border: 2px solid #27ae60;
    font-weight: bold;
    color: #27ae60;
}

#file-input {
    display: none;
}

#batch-print-container {
    display: none;
}

/* =====================================================
   PLANTILLA (Cátedras y Titularidades) STYLES
   ===================================================== */

.plantilla-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    font-family: 'Arial', sans-serif;
    position: relative;
}

.plantilla-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.plantilla-table thead th {
    background: #00274C;
    color: white;
    padding: 8px 6px;
    text-align: center;
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 0.5px;
    border: 1px solid #001a33;
    white-space: nowrap;
}

.plantilla-table tbody tr {
    border-bottom: 1px solid #e0e0e0;
    transition: background 0.15s;
}

.plantilla-table tbody tr:nth-child(even) {
    background: #f8f9fa;
}

.plantilla-table tbody tr:hover {
    background: #e8f0fe !important;
}

.plantilla-table tbody td {
    padding: 3px 5px;
    border: 1px solid #e0e0e0;
    vertical-align: middle;
}

/* Mismatch: titular ≠ docente */
.row-mismatch {
    background: #fff3cd !important;
    border-left: 3px solid #f39c12 !important;
}

.row-mismatch:hover {
    background: #ffeaa7 !important;
}

/* Inline-edit inputs */
.plantilla-input {
    width: 100%;
    border: none;
    background: transparent;
    padding: 3px 4px;
    font-size: 11px;
    font-family: 'Arial', sans-serif;
    color: #222;
    box-sizing: border-box;
    outline: none;
}

.plantilla-input:focus {
    background: white;
    border: 1px solid #00274C;
    border-radius: 2px;
    box-shadow: 0 0 0 2px rgba(0, 39, 76, 0.15);
}

.plantilla-input.unsaved {
    background: #fff9c4;
    font-style: italic;
}

/* Grade separator rows */
.plantilla-grade-header td {
    background: #00274C;
    color: white;
    font-weight: bold;
    font-size: 12px;
    padding: 6px 10px;
    letter-spacing: 1px;
}

/* Report table (screen + print) */
.report-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    font-family: 'Arial', sans-serif;
    margin-bottom: 10px;
}

.report-table thead th {
    background: #00274C;
    color: white;
    padding: 6px 8px;
    text-align: center;
    font-size: 10px;
    font-weight: bold;
    border: 1px solid #001a33;
}

.report-table tbody td {
    padding: 4px 6px;
    border: 1px solid #ccc;
    font-size: 11px;
}

.report-table tbody tr:nth-child(even) {
    background: #f8f9fa;
}

.plantilla-report-page {
    max-width: 700px;
    margin: 0 auto;
    padding: 30px;
    font-family: 'Arial', sans-serif;
}

/* Print styles */
@media print {

    /* Hide everything ONLY when plantilla is printing */
    body.plantilla-printing * {
        visibility: hidden;
    }

    /* Show only the print container */
    body.plantilla-printing #plantilla-print-container,
    body.plantilla-printing #plantilla-print-container * {
        visibility: visible;
    }

    body.plantilla-printing #plantilla-print-container {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
    }

    .plantilla-report-page {
        max-width: 100%;
        padding: 15mm 20mm;
        page-break-inside: avoid;
    }

    .report-table thead th {
        background: #00274C !important;
        color: white !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .report-table tbody tr:nth-child(even) {
        background: #f0f0f0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .report-header img {
        max-height: 90px !important;
        width: auto !important;
    }

    .report-header {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* ══════════════════════════════════════════════════════════════
       TITULARIDAD LICENCIATURA COMPLETA (LANDSCAPE) — Mass Print
       ══════════════════════════════════════════════════════════════ */

    /* Hide everything */
    body.print-mode-titularidad-lic * {
        visibility: hidden;
    }

    /* Show only the print container */
    body.print-mode-titularidad-lic #plantilla-print-container,
    body.print-mode-titularidad-lic #plantilla-print-container * {
        visibility: visible;
    }

    body.print-mode-titularidad-lic {
        background: white !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    body.print-mode-titularidad-lic #plantilla-print-container {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
    }

    /* Report container: internal padding simulates margins (browser-proof) */
    body.print-mode-titularidad-lic .titularidad-lic-report {
        width: 279.4mm;
        /* Landscape letter width */
        min-height: 215.9mm;
        /* Landscape letter height */
        padding: 15mm 15mm 10mm 15mm;
        box-sizing: border-box;
        margin: 0 auto;
        background: white;
    }

    /* Force color printing for grade headers and mismatch rows */
    body.print-mode-titularidad-lic table tr[style*="background:#00274C"],
    body.print-mode-titularidad-lic table thead tr {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    body.print-mode-titularidad-lic table tr[style*="background:#fff3cd"] {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Table cells: solid borders */
    body.print-mode-titularidad-lic table td,
    body.print-mode-titularidad-lic table th {
        border: 1px solid #000 !important;
        padding: 5px 6px !important;
    }

    /* Logos */
    body.print-mode-titularidad-lic .titularidad-lic-report img {
        max-height: 60px !important;
        width: auto !important;
    }
}

/* =====================================================
   SÁBANA GENERAL PRINT STYLES
   ===================================================== */

@media print {

    /* Hide everything first */
    body.sabana-printing * {
        visibility: hidden;
    }

    /* Show only matrix-view contents */
    body.sabana-printing #matrix-view,
    body.sabana-printing #matrix-view * {
        visibility: visible;
    }

    body.sabana-printing #matrix-view {
        display: block !important;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        padding: 5mm 8mm !important;
        background: white !important;
    }

    /* HIDE the duplicate print header — keep only the original web header */
    body.sabana-printing #sabana-print-header {
        display: none !important;
    }

    /* Hide ONLY the toolbar (selects + buttons bar), keep the title bar */
    body.sabana-printing #matrix-view>div:nth-child(2) {
        display: none !important;
    }

    /* Hide the back button inside the title bar */
    body.sabana-printing #matrix-view>div:first-child>button {
        display: none !important;
    }

    /* KILL SCROLLBAR — aggressive overflow fix */
    body.sabana-printing #matrix-view,
    body.sabana-printing #sabana-matrix-container {
        overflow: visible !important;
        overflow-x: hidden !important;
        overflow-y: visible !important;
        max-height: none !important;
        border: none !important;
        height: auto !important;
    }

    /* Hide webkit scrollbar pseudo-elements */
    body.sabana-printing ::-webkit-scrollbar {
        display: none !important;
        width: 0 !important;
        height: 0 !important;
    }

    /* Matrix table: full width, fixed layout, compact */
    body.sabana-printing #sabana-matrix-container table {
        width: 100% !important;
        table-layout: fixed !important;
        font-size: 8px !important;
    }

    /* Table header colors preserved */
    body.sabana-printing #sabana-matrix-container th {
        background: #00274C !important;
        color: white !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        padding: 3px 4px !important;
        font-size: 7px !important;
    }

    body.sabana-printing #sabana-matrix-container td {
        padding: 2px 3px !important;
        font-size: 8px !important;
        border: 1px solid #ccc !important;
    }

    /* First column (MATERIA) styling */
    body.sabana-printing #sabana-matrix-container td:first-child {
        background: #f5f5f5 !important;
        font-weight: bold !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Clean up selects to look like plain text */
    body.sabana-printing #sabana-matrix-container select {
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        border: none !important;
        background: transparent !important;
        font-size: 7px !important;
        padding: 0 !important;
        width: 100% !important;
    }
}

/* ===============================================
   ELEGANT SELECT — Ciclos Escolares Wizard
   =============================================== */
.elegant-select {
    width: 100%;
    padding: 10px 40px 10px 14px;
    font-size: 13px;
    font-family: 'Segoe UI', Arial, sans-serif;
    color: #333;
    background-color: #f9f9f9;
    border: 2px solid #dde2ea;
    border-radius: 8px;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23002b5c%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 11px auto;
    cursor: pointer;
    transition: border-color 0.25s ease, box-shadow 0.25s ease, background-color 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.elegant-select:hover {
    border-color: #002b5c;
    background-color: #ffffff;
}

.elegant-select:focus {
    outline: none;
    border-color: #002b5c;
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.30);
    background-color: #ffffff;
}

/* ===============================================
   MODAL DE CAPTURA DE HORARIOS — Diseño Premium
   =============================================== */

/* Pantalla de resultado */
.time-screen {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}

.time-screen-input {
    flex: 1;
    padding: 12px 16px;
    font-size: 18px;
    font-weight: 700;
    text-align: center;
    border: 2px solid #dde2ea;
    border-radius: 10px;
    background: #f0f4ff;
    color: #00274C;
    letter-spacing: 1px;
    cursor: default;
    transition: border-color 0.2s;
}

.time-screen-input:not(:placeholder-shown) {
    border-color: #00274C;
    background: #e8f0fe;
}

.time-clear-btn {
    background: #f1f1f1;
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 10px 12px;
    cursor: pointer;
    color: #777;
    font-size: 14px;
    transition: background 0.2s, color 0.2s;
}

.time-clear-btn:hover {
    background: #ffe0e0;
    color: #c0392b;
    border-color: #c0392b;
}

/* Etiquetas de sección */
.time-section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
    margin: 10px 0 6px 2px;
}

/* Grid de botones rápidos */
.time-quick-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-bottom: 4px;
}

.time-quick-btn {
    padding: 9px 6px;
    border: 2px solid #dde2ea;
    border-radius: 8px;
    background: #ffffff;
    color: #333;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: center;
    white-space: nowrap;
}

.time-quick-btn:hover {
    background: #00274C;
    color: #D4AF37;
    border-color: #00274C;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 39, 76, 0.20);
}

.time-quick-btn.active {
    background: #D4AF37;
    color: #00274C;
    border-color: #c5a424;
    font-weight: 800;
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.40);
}

/* Fila de selector personalizado */
.time-custom-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.time-custom-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.time-custom-label {
    font-size: 10px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.time-custom-sel {
    padding: 8px 10px;
    border: 2px solid #dde2ea;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #00274C;
    background: #f9f9f9;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
}

.time-custom-sel:focus {
    outline: none;
    border-color: #00274C;
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.25);
}

.time-separator {
    font-size: 16px;
    font-weight: 900;
    color: #00274C;
    padding-bottom: 8px;
}

/* ===============================================
   PLANTILLA — GROUP-BASED STRIPING ELEGANTE
   =============================================== */

/* Fondo 1: Blanco puro */
.bg-grupo-a {
    background-color: #ffffff;
}

/* Fondo 2: Gris azulado sutil (perla) */
.bg-grupo-b {
    background-color: #f4f6f9;
}

/* Línea divisoria elegante al terminar un grupo */
.border-bottom-grueso td {
    border-bottom: 2px solid #cbd5e1 !important;
}

/* Hover para no perderse en la lectura */
.bg-grupo-a:hover td,
.bg-grupo-b:hover td {
    background-color: #e8edf5 !important;
    transition: background-color 0.15s ease;
}

/* ===============================================
   SELECT DE DUEÑO DE PLAZA — Titularidad
   =============================================== */
.plantilla-select-dueno {
    width: 100%;
    padding: 5px 8px;
    border: 1.5px solid #c8d1db;
    border-radius: 6px;
    background-color: #fff;
    color: #00274C;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.plantilla-select-dueno:focus {
    outline: none;
    border-color: #00274C;
    box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.30);
}

.plantilla-select-dueno:hover {
    border-color: #00274C;
}

/* Opción "Sin asignar" en rojo suave */
.plantilla-select-dueno option[value=""] {
    color: #c0392b;
    font-style: italic;
}

/* ===============================================
   RBAC — ROLE BADGES & USER MANAGEMENT UI
   =============================================== */
.role-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .5px;
    white-space: nowrap;
}

/* Users admin split layout */
.users-admin-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 24px;
    align-items: start;
}

@media (max-width: 800px) {
    .users-admin-layout {
        grid-template-columns: 1fr;
    }
}

/* Users Table */
.users-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.users-table thead tr {
    background: #00274C;
    color: #FFD700;
}

.users-table th {
    padding: 9px 12px;
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.users-table tbody tr {
    border-bottom: 1px solid #eee;
    transition: background .15s;
}

.users-table tbody tr:hover {
    background: #f0f4fb;
}

.users-table td {
    padding: 8px 12px;
}

/* Form Panel */
.users-form-panel {
    background: #f8faff;
    border: 1.5px solid #dce3f0;
    border-radius: 10px;
    padding: 20px;
}

.user-form-group {
    margin-bottom: 14px;
}

.user-form-group label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: #00274C;
    text-transform: uppercase;
    letter-spacing: .4px;
    margin-bottom: 5px;
}

.user-form-group input,
.user-role-select {
    width: 100%;
    padding: 8px 10px;
    border: 1.5px solid #c8d1db;
    border-radius: 6px;
    font-size: 13px;
    color: #00274C;
    background: #fff;
    box-sizing: border-box;
    transition: border-color .2s, box-shadow .2s;
}

.user-form-group input:focus,
.user-role-select:focus {
    outline: none;
    border-color: #00274C;
    box-shadow: 0 0 0 2px rgba(212, 175, 55, .25);
}

/* Role contextual help box */
.role-help-box {
    background: #eef3fa;
    border-left: 3px solid #00274C;
    border-radius: 0 6px 6px 0;
    padding: 8px 12px;
    font-size: 11px;
    color: #444;
    line-height: 1.5;
    margin-top: 6px;
}

/* Small danger button */
.btn-danger-sm {
    background: #c0392b !important;
    color: white !important;
    padding: 4px 10px !important;
    font-size: 11px !important;
    border-radius: 5px !important;
    width: auto !important;
    cursor: pointer;
    border: none;
}

.btn-danger-sm:hover {
    background: #922b21 !important;
}

/* ==============================================
   CATÁLOGO DE DOCENTES — Diseño Institucional
   ============================================== */

/* Tabla general institucional (Estilo Sábana) */
.teacher-catalog-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 13px;
    border: 1px solid #e5e7eb;
    background: white;
}

/* Encabezado — Azul Marino Institucional (UAS) #00274C unificado */
.tc-header {
    background: #00274C !important;
    color: #ffffff !important;
}

.tc-header th {
    padding: 12px;
    font-weight: bold;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
    white-space: nowrap;
    border: 1px solid #001f3d !important;
    text-align: center;
}

/* Columnas sortables */
.tc-sortable {
    cursor: pointer;
    user-select: none;
    transition: background .15s;
}

.tc-sortable:hover {
    background: #003870 !important;
}

.tc-sort-icon {
    font-size: 10px;
    opacity: .75;
}

/* Filas — Zebra striping sutil (blanco / gris muy claro) */
.tc-row-even {
    background: #ffffff;
}

.tc-row-odd {
    background: #f9fafb;
    /* gris muy claro */
}

/* Efecto hover general nativo */
.tc-row-even:hover,
.tc-row-odd:hover {
    background: #eff6ff !important;
    /* hover azul claro */
}

tr.tc-row-even td,
tr.tc-row-odd td {
    padding: 10px 12px;
    border-bottom: 1px solid #eaeef5;
    /* borde sutil gris, ZERO dorado */
    border-right: 1px solid #f3f4f6;
    vertical-align: middle;
    color: #333;
}

/* Filas inactivas — atenuadas */
.tc-row-inactive {
    background: #fafafa;
    opacity: .65;
}

.tc-row-inactive td {
    padding: 8px 12px;
    border-bottom: 1px solid #eaeef5;
    color: #8a9ab0;
    font-style: italic;
}

.tc-row-inactive:hover {
    background: #f5f5f5;
    opacity: .8;
}

/* Badges de estatus */
.tc-badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .4px;
}

.tc-badge-active {
    background: #e8f5e9;
    color: #2e7d32;
}

.tc-badge-inactive {
    background: #f5f5f5;
    color: #9e9e9e;
}

/* Badges de tipo de contrato */
.tc-contract {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 5px;
    font-size: 10px;
    font-weight: 600;
}

.tc-contract-base {
    background: #e3f2fd;
    color: #1565c0;
}

.tc-contract-interino {
    background: #fff8e1;
    color: #e65100;
}

.tc-contract-honorarios {
    background: #f3e5f5;
    color: #6a1b9a;
}

.tc-contract-indeterminado {
    background: #eceff1;
    color: #546e7a;
}

/* BOTONES MINIMALISTAS (BOOTSTRAP UTILS MIMIC) */
.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
    line-height: 1.5;
    border-radius: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-weight: 500;
    transition: all 0.2s ease-in-out;
    background: transparent;
    border: 1px solid transparent;
}

.btn-outline-primary {
    color: #0d6efd;
    border-color: #0d6efd;
}

.btn-outline-primary:hover {
    color: #fff;
    background: #0d6efd;
}

.btn-outline-secondary {
    color: #6c757d;
    border-color: #6c757d;
}

.btn-outline-secondary:hover {
    color: #fff;
    background: #6c757d;
}

.btn-outline-danger {
    color: #dc3545;
    border-color: #dc3545;
}

.btn-outline-danger:hover {
    color: #fff;
    background: #dc3545;
}

.btn-outline-success {
    color: #198754;
    border-color: #198754;
}

.btn-outline-success:hover {
    color: #fff;
    background: #198754;
}

/* Texto "Solo vista" */
.tc-readonly {
    color: #b0b8c5;
    font-size: 11px;
    font-style: italic;
}