/* =====================================
   STUDENTS MODULE - MINIMAL CLAUDE STYLE
   Diseño minimalista inspirado en Claude
   ===================================== */

/* === VARIABLES - Paleta Claude === */
:root {
    /* Paleta alineada con Dashboard */
    --claude-bg: #f8fafc;
    --claude-surface: #ffffff;
    --claude-surface-hover: #f1f5f9;
    --claude-border: #e2e8f0;
    --claude-text: #1e293b;
    --claude-text-secondary: #475569;
    --claude-text-muted: #64748b;

    /* Acentos - Ociann Class (#020b47) */
    --primary-rgb: 2, 11, 71;
    --claude-accent: #020b47;
    --claude-accent-hover: #010824;
    --claude-accent-light: rgba(2, 11, 71, 0.12);
    --claude-success: #10b981;
    --claude-danger: #ef4444;
    --claude-info: #020b47;
    --claude-warning: #f59e0b;

    /* Mapping para compatibilidad */
    --bg-primary: var(--claude-bg);
    --bg-secondary: var(--claude-surface);
    --bg-tertiary: var(--claude-surface-hover);
    --text-primary: var(--claude-text);
    --text-secondary: var(--claude-text-secondary);
    --text-muted: var(--claude-text-muted);
    --border-color: var(--claude-border);
    --primary: var(--claude-accent);
    --primary-dark: var(--claude-accent-hover);
    --success: var(--claude-success);
    --danger: var(--claude-danger);
    --info: var(--claude-info);
    --warning: var(--claude-warning);

    /* Espaciado (escala 4px) - Fase 4 */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    /* Tipografía */
    --text-xs: 0.75rem;
    --text-sm: 0.8125rem;
    --text-base: 0.875rem;
    --text-md: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --line-tight: 1.35;
    --line-normal: 1.5;
    --radius-btn: 8px;
    --radius-card: 12px;
}

/* === TEMA OSCURO - Estilo alineado con Dashboard === */
[data-theme="dark"] {
    --claude-bg: #0f172a;
    --claude-surface: #1e293b;
    --claude-surface-hover: #334155;
    --claude-border: #334155;
    --claude-text: #f8fafc;
    --claude-text-secondary: #cbd5e1;
    --claude-text-muted: #94a3b8;
    --primary-rgb: 2, 11, 71;
    --claude-accent: #020b47;
    --claude-accent-hover: #010824;
    --claude-accent-light: rgba(2, 11, 71, 0.16);

    --bg-primary: var(--claude-bg);
    --bg-secondary: var(--claude-surface);
    --bg-tertiary: var(--claude-surface-hover);
    --text-primary: var(--claude-text);
    --text-secondary: var(--claude-text-secondary);
    --text-muted: var(--claude-text-muted);
    --border-color: var(--claude-border);
    --primary: var(--claude-accent);
    --primary-dark: var(--claude-accent-hover);
}

/* === TEMA CLAUDE CLARO === */
[data-theme="claude"] {
    --claude-bg: #f5f2ed;
    --claude-surface: #e8e4db;
    --claude-surface-hover: #dfd8cb;
    --claude-border: #d1c7b7;
    --claude-text: #2c2c2c;
    --claude-text-secondary: #5a5a5a;
    --claude-text-muted: #8a8a8a;
    --claude-accent: #d97757;
    --claude-accent-hover: #c46648;
    --claude-accent-light: rgba(217, 119, 87, 0.12);
    --claude-success: #6b8e6b;
    --claude-danger: #b56b6b;
    --claude-info: #6b8ea3;
    --claude-warning: #c4a45b;

    --bg-primary: var(--claude-bg);
    --bg-secondary: var(--claude-surface);
    --bg-tertiary: var(--claude-surface-hover);
    --text-primary: var(--claude-text);
    --text-secondary: var(--claude-text-secondary);
    --text-muted: var(--claude-text-muted);
    --border-color: var(--claude-border);
    --primary: var(--claude-accent);
    --primary-dark: var(--claude-accent-hover);
    --success: var(--claude-success);
    --danger: var(--claude-danger);
    --info: var(--claude-info);
    --warning: var(--claude-warning);
}

/* === TEMA DEEP-DARK === */
[data-theme-variant="deep-dark"] {
    --claude-bg: #020617;
    --claude-surface: #0f172a;
    --claude-surface-hover: #1e293b;
    --claude-border: #1e293b;
    --claude-text: #f8fafc;
    --claude-text-secondary: #94a3b8;
    --claude-text-muted: #64748b;

    --claude-accent: #020b47;
    --claude-accent-hover: #010824;
    --claude-accent-light: rgba(2, 11, 71, 0.16);
}

/* === TEMA CLAUDE OSCURO === */
[data-theme-variant="claude-dark"] {
    --claude-bg: #171717;
    --claude-surface: #212121;
    --claude-surface-hover: #2a2a2a;
    --claude-border: #333333;
    --claude-text: #e3e3e3;
    --claude-text-secondary: #b4b4b4;
    --claude-text-muted: #737373;

    --claude-accent: #d97757;
    --claude-accent-hover: #c46648;
    --claude-accent-light: rgba(217, 119, 87, 0.16);

    --claude-success: #6b8e6b;
    --claude-danger: #b56b6b;
    --claude-info: #0f3d8c;
    --claude-warning: #c4a45b;
}

/* === TEMA AURORA === */
[data-theme-variant="aurora"] {
    --claude-bg: #071a17;
    --claude-surface: #0d2420;
    --claude-surface-hover: #12312c;
    --claude-border: #14443d;
    --claude-text: #e6fffb;
    --claude-text-secondary: #a7f3d0;
    --claude-text-muted: #7dd3fc;

    --claude-accent: #22c55e;
    --claude-accent-hover: #16a34a;
    --claude-accent-light: rgba(34, 197, 94, 0.14);

    --claude-success: #34d399;
    --claude-danger: #f87171;
    --claude-info: #06b6d4;
    --claude-warning: #fbbf24;
}

/* === TEMA COBALT === */
[data-theme-variant="cobalt"] {
    --claude-bg: #f1f7ff;
    --claude-surface: #ffffff;
    --claude-surface-hover: #e8f0ff;
    --claude-border: #dbeafe;
    --claude-text: #0f172a;
    --claude-text-secondary: #334155;
    --claude-text-muted: #64748b;

    --claude-accent: #2563eb;
    --claude-accent-hover: #1d4ed8;
    --claude-accent-light: rgba(37, 99, 235, 0.12);

    --claude-success: #10b981;
    --claude-danger: #ef4444;
    --claude-info: #2563eb;
    --claude-warning: #f59e0b;
}

/* === TEMA ROSE === */
[data-theme-variant="rose"] {
    --claude-bg: #fff1f5;
    --claude-surface: #ffffff;
    --claude-surface-hover: #ffe4e6;
    --claude-border: #fecdd3;
    --claude-text: #111827;
    --claude-text-secondary: #374151;
    --claude-text-muted: #6b7280;

    --claude-accent: #ec4899;
    --claude-accent-hover: #db2777;
    --claude-accent-light: rgba(236, 72, 153, 0.12);

    --claude-success: #10b981;
    --claude-danger: #ef4444;
    --claude-info: #a78bfa;
    --claude-warning: #f59e0b;
}

/* === RESET OPTIMIZADO === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Solo transiciones en elementos interactivos */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* === LAYOUT === */
.app-container {
    max-width: 100%;
    padding: var(--space-4);
}

@media (min-width: 768px) {
    .app-container { padding: var(--space-6); }
}

/* === HEADER MINIMALISTA === */
.students-page-top {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}
.students-page-top .main-header {
    margin-bottom: 0;
    padding: var(--space-4) var(--space-5);
}
.students-page-top .period-indicator {
    margin-top: 0;
    margin-bottom: 0;
}

/* Marco exterior; la fila flex vive en .students-header-unified-row (tres columnas misma altura) */
.students-page-top--unified {
    display: block;
    margin-bottom: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    overflow: visible;
}
.students-page-top--unified .students-header-unified-row {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: stretch;
    align-content: stretch;
    gap: 0;
    width: 100%;
    min-height: 52px;
    /* Un solo “aire” lateral para toda la franja (evita triple caja y huecos raros) */
    padding: 0.45rem clamp(0.5rem, 1.4vw, 0.95rem);
    box-sizing: border-box;
}
@media (min-width: 1025px) {
    .students-page-top--unified .students-header-unified-row {
        flex-wrap: nowrap;
    }
}
.students-page-top--unified .students-top-title {
    flex: 0 1 auto;
    min-width: 0;
    max-width: min(280px, 34vw);
    padding: 0.35rem 0.6rem 0.35rem 0;
    display: flex;
    align-items: center;
    align-self: stretch;
    border-right: 1px solid var(--border-color);
}
.students-page-top--unified .students-top-title .header-left {
    gap: var(--space-2);
}
.students-page-top--unified .students-top-title .header-icon {
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
}
.students-page-top--unified .students-top-title .header-info h1 {
    font-size: clamp(1rem, 1.8vw, 1.2rem);
    margin: 0;
}
/* Período: un solo bloque interno (.students-period-inner) alinea texto + stats en vertical */
.students-page-top--unified .students-top-period.period-indicator {
    flex: 1 1 0;
    min-width: min(100%, 200px);
    margin: 0;
    border-radius: 0;
    border: none;
    min-height: 0;
    padding: 0.35rem 0.6rem;
    align-self: stretch;
    align-items: center;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 0.5rem 0.75rem;
    overflow: visible;
}
.students-page-top--unified .students-period-inner {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    align-content: center;
    justify-content: space-between;
    gap: 0.5rem 0.75rem;
    flex: 1 1 auto;
    min-width: 0;
}

/* Franja central: sin borde izquierdo (evita doble línea con .students-top-title) */
.students-page-top--unified .students-top-period.period-indicator.students-period-strip--neutral {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-left: none;
    border-right: 1px solid var(--border-color);
}
.students-page-top--unified .students-top-period.students-period-strip--neutral .period-label {
    color: var(--text-secondary) !important;
}
.students-page-top--unified .students-top-period.students-period-strip--neutral .period-info {
    color: var(--text-primary);
}
.students-page-top--unified .students-top-period.students-period-strip--neutral .period-badge {
    background: rgba(5, 150, 105, 0.14);
    color: var(--text-primary);
}
.students-page-top--unified .students-top-period.students-period-strip--neutral .pulse {
    background: #059669;
}
.students-page-top--unified .students-top-period.students-period-strip--neutral .period-refresh-btn {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.students-page-top--unified .students-top-period.students-period-strip--neutral .period-refresh-btn:hover {
    background: var(--border-color);
}
.students-page-top--unified .students-top-period.students-period-strip--neutral .stat-number {
    color: var(--text-primary) !important;
}
.students-page-top--unified .students-top-period.students-period-strip--neutral .stat-number[data-student-stat="total"] {
    color: var(--primary) !important;
}
.students-page-top--unified .students-top-period.students-period-strip--neutral .stat-number[data-student-stat="active"] {
    color: var(--success) !important;
}
.students-page-top--unified .students-top-period.students-period-strip--neutral .stat-number[data-student-stat="inactive"] {
    color: var(--warning) !important;
}
.students-page-top--unified .students-top-period.students-period-strip--neutral .stat-label {
    color: var(--text-secondary) !important;
}
.students-page-top--unified .students-top-period.students-period-strip--neutral .stat-item-context .stat-number {
    color: var(--text-secondary) !important;
}

/* Hijo directos de .students-period-inner (sin .period-content / .stats-grid) */
.students-page-top--unified .students-period-inner > .period-text {
    flex: 1 1 180px;
    min-width: 160px;
    max-width: none;
    overflow: visible;
    align-items: center;
}
.students-page-top--unified .students-period-inner > .stat-item:nth-child(4) {
    margin-left: auto;
}
.students-page-top--unified .students-top-period .period-text {
    writing-mode: horizontal-tb;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    overflow-wrap: break-word;
    word-break: normal;
}
.students-page-top--unified .students-top-period .period-info {
    line-height: 1.35;
}
.students-page-top--unified .students-top-period .period-badge {
    align-self: center;
    flex-shrink: 0;
}
.students-page-top--unified .students-period-inner.period-stats-inline {
    flex-wrap: wrap;
    row-gap: 0.25rem;
}
.students-page-top--unified .students-period-inner > .stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: min(100%, 3.5rem);
}
.students-page-top--unified .students-period-inner > .stats-context {
    flex: 1 1 100%;
    justify-content: flex-end;
    gap: var(--space-4);
}
.students-page-top--unified .students-top-period .period-refresh-btn {
    flex-shrink: 0;
    align-self: center;
}
/* Pantallas angostas: salto de línea antes de totales + fila de stats */
@media (max-width: 720px) {
    .students-page-top--unified .students-top-period.period-indicator {
        flex-wrap: wrap;
        align-items: flex-start;
        justify-content: flex-start;
    }
    .students-page-top--unified .students-period-inner {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        align-content: flex-start;
        width: 100%;
    }
    .students-page-top--unified .students-period-inner::before {
        content: "";
        flex: 1 0 100%;
        width: 100%;
        height: 0;
        order: 4;
    }
    .students-page-top--unified .students-period-inner > .period-icon {
        order: 1;
    }
    .students-page-top--unified .students-period-inner > .period-text {
        order: 2;
    }
    .students-page-top--unified .students-period-inner > .period-badge {
        order: 3;
    }
    .students-page-top--unified .students-period-inner > .stat-item:nth-child(5) {
        order: 6;
    }
    .students-page-top--unified .students-period-inner > .stat-item:nth-child(6) {
        order: 7;
    }
    .students-page-top--unified .students-period-inner > .stats-context {
        order: 8;
    }
    .students-page-top--unified .students-period-inner > .stat-item:nth-child(4) {
        order: 5;
        margin-left: 0 !important;
        flex: 1 1 30%;
        min-width: 72px;
        padding-top: 0.4rem;
        margin-top: 0.15rem;
        border-top: 1px solid var(--border-color);
        justify-content: center;
    }
    .students-page-top--unified .students-period-inner > .stat-item:nth-child(5),
    .students-page-top--unified .students-period-inner > .stat-item:nth-child(6) {
        flex: 1 1 30%;
        min-width: 72px;
        padding-top: 0.4rem;
        margin-top: 0.15rem;
        border-top: 1px solid var(--border-color);
        justify-content: center;
    }
    .students-page-top--unified .students-period-inner > .stats-context {
        flex-basis: 100%;
        justify-content: space-between;
    }
}
@media (min-width: 721px) {
    .students-page-top--unified .students-period-inner::before {
        display: none;
    }
}
.students-page-top--unified .students-top-actions {
    flex: 0 0 auto;
    min-width: 0;
    max-width: 100%;
    padding: 0.35rem 0 0.35rem 0.5rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    align-self: stretch;
    justify-content: flex-end;
    gap: var(--space-2);
    border-left: none;
    background: transparent;
}
.students-page-top--unified .students-top-actions .header-actions-primary {
    box-shadow: none;
}

/* Pantallas estrechas: apilar en 2–3 filas sin perder bloques */
@media (max-width: 1024px) {
    .students-page-top--unified .students-top-title {
        flex: 1 1 100%;
        max-width: none;
        padding: 0.35rem 0;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    .students-page-top--unified .students-top-period.period-indicator {
        flex: 1 1 auto;
        border-radius: 0;
    }
    .students-page-top--unified .students-top-period.period-indicator.students-period-strip--neutral {
        border-right: none;
    }
    .students-page-top--unified .students-top-actions {
        flex: 1 1 100%;
        padding: 0.35rem 0 0;
        border-left: none;
        border-top: 1px solid var(--border-color);
        justify-content: flex-start;
        flex-wrap: wrap;
        align-items: stretch;
        align-content: flex-start;
        gap: var(--space-2);
    }
    /* Dos controles por fila (Agregar+menú cuenta como un bloque) */
    .students-page-top--unified .students-top-actions > .header-actions-primary,
    .students-page-top--unified .students-top-actions > .btn:not(.sr-only),
    .students-page-top--unified .students-top-actions > .dropdown-wrapper {
        flex: 1 1 calc((100% - var(--space-2)) / 2);
        min-width: min(100%, 10rem);
        max-width: 100%;
        box-sizing: border-box;
    }
    .students-page-top--unified .students-top-actions .header-actions-primary {
        display: flex;
        flex-wrap: nowrap;
        align-items: stretch;
        gap: 0;
    }
    .students-page-top--unified .students-top-actions .header-actions-primary > .btn {
        flex: 1 1 auto;
        min-width: 0;
    }
    .students-page-top--unified .students-top-actions .header-actions-primary .btn-dropdown-toggle {
        flex: 0 0 auto;
    }
}

/* Compat: layout anterior con .main-header + .period-indicator en fila (SPA parcial) */
@media (min-width: 1200px) {
    .students-page-top:not(.students-page-top--unified) {
        flex-direction: row;
        align-items: stretch;
        gap: 0.75rem;
    }
    .students-page-top:not(.students-page-top--unified) .main-header {
        flex: 0 1 380px;
        max-width: 44%;
        display: flex;
        align-items: center;
    }
    .students-page-top:not(.students-page-top--unified) .main-header .header-content {
        width: 100%;
    }
    .students-page-top:not(.students-page-top--unified) .period-indicator {
        flex: 1 1 320px;
        min-height: 0;
    }
}
.main-header {
    background: var(--bg-secondary);
    border-radius: var(--radius-card);
    padding: var(--space-5);
    margin-bottom: var(--space-4);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-4);
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.header-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary), #22c55e);
    border-radius: var(--radius-btn);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-xl);
    color: white;
}

.header-info h1 {
    font-size: var(--text-xl);
    font-weight: 600;
    line-height: var(--line-tight);
    color: var(--text-primary);
}

.header-info p {
    color: var(--text-secondary);
    font-size: var(--text-sm);
    line-height: var(--line-normal);
}

.header-actions {
    display: flex;
    gap: var(--space-2);
    align-items: center;
    flex-wrap: wrap;
}

/* Agrupación visual: botón principal + dropdown como un solo bloque */
.header-actions-primary {
    display: inline-flex;
    align-items: stretch;
    border-radius: var(--radius-btn);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    /* Sin overflow:hidden para que el menú desplegable no se corte */
}
.header-actions-primary .btn-primary:first-child {
    border-radius: 8px 0 0 8px;
    min-height: 36px;
    padding-left: 14px;
    padding-right: 12px;
}
/* Wrapper del dropdown como parte del grupo, misma altura */
.header-actions-primary .dropdown-wrapper {
    display: flex;
}
.btn-dropdown-toggle {
    padding: 0 10px !important;
    min-height: 36px;
    height: auto;
    border-radius: 0 8px 8px 0 !important;
    border-left: 1px solid rgba(255, 255, 255, 0.3);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.header-actions-primary .btn-dropdown-toggle:hover {
    background: var(--primary-dark);
}

/* Contenedor dropdown genérico */
.dropdown-wrapper {
    position: relative;
    display: inline-block;
}
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: var(--space-1);
    min-width: 200px;
    padding: var(--space-2) 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
    z-index: 1050;
    list-style: none;
    display: none;
}
.dropdown-menu.show {
    display: block;
    animation: dropdownIn 0.15s ease;
}
.dropdown-menu-right {
    left: auto;
    right: 0;
}
/* Menú del botón Agregar: alineado al borde derecho del grupo */
.header-actions-primary .dropdown-menu {
    left: auto;
    right: 0;
}
@keyframes dropdownIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}
.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    width: 100%;
    padding: var(--space-2) var(--space-3);
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: var(--text-sm);
    line-height: var(--line-normal);
    text-align: left;
    cursor: pointer;
    transition: background-color 0.12s;
}
.dropdown-item:hover {
    background: var(--bg-tertiary);
}
.dropdown-item i {
    width: 18px;
    color: var(--text-secondary);
}
.dropdown-item-danger { color: var(--danger); }
.dropdown-item-danger i { color: inherit; }
.dropdown-divider {
    height: 1px;
    margin: 6px 0;
    background: var(--border-color);
}

/* Ocultar visualmente pero mantener para accesibilidad/JS */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* === BOTONES - Jerarquía unificada (Fase 4) === */
/* Base: todos los botones */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border: 1px solid transparent;
    border-radius: var(--radius-btn);
    font-size: var(--text-sm);
    font-weight: 500;
    line-height: var(--line-tight);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--bg-primary), 0 0 0 4px var(--primary);
}

/* Primario: acción principal (Agregar, Editar principal) */
.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

/* Secundario: acciones secundarias (Más acciones, Cancelar, Actualizar) */
.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-color);
}
.btn-secondary:hover { background: var(--border-color); border-color: var(--text-muted); }

/* Ghost: acciones terciarias, menús (solo borde o fondo muy suave) */
.btn-ghost {
    background: transparent;
    color: var(--text-primary);
    border-color: var(--border-color);
}
.btn-ghost:hover { background: var(--bg-tertiary); }

/* Semánticos: solo para acciones con significado (éxito, peligro, aviso) */
.btn-success {
    background: var(--success);
    color: white;
    border-color: var(--success);
}
.btn-success:hover { filter: brightness(1.05); }
.btn-danger {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}
.btn-danger:hover { filter: brightness(1.08); }
.btn-warning {
    background: var(--warning);
    color: white;
    border-color: var(--warning);
}
.btn-warning:hover { filter: brightness(1.05); }
.btn-info {
    background: var(--info);
    color: white;
    border-color: var(--info);
}
.btn-info:hover { filter: brightness(1.05); }

.btn-sm {
    padding: var(--space-1) var(--space-2);
    font-size: var(--text-xs);
    gap: var(--space-1);
}

.btn-toggle-inactive {
    background: var(--warning);
    color: white;
    border-color: var(--warning);
}
.btn-toggle-inactive.viewing-inactive {
    background: var(--success);
    border-color: var(--success);
}

/* Toggle tema */
.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s;
}
.theme-toggle:hover { background: var(--border-color); }

/* === INDICADOR PERÍODO === */
.period-indicator {
    background: #059669;
    color: white;
    padding: 0.65rem 1rem;
    min-height: 52px;
    border-radius: var(--radius-btn);
    margin-bottom: 1rem;
    margin-top: 1rem;
    display: flex;
    flex-direction: row; /* Explicit row direction */
    align-items: center;
    justify-content: space-between; /* Space between period and stats */
    gap: var(--space-3);
    flex-wrap: wrap;
    overflow: hidden; /* No scroll */
}
.period-indicator .period-refresh-btn {
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.35);
}
.period-indicator .period-refresh-btn:hover {
    background: rgba(255, 255, 255, 0.28);
    border-color: rgba(255, 255, 255, 0.5);
}
.period-stats-inline .stats-context.visible {
    display: flex;
    gap: var(--space-4);
    align-items: center;
}
.period-indicator .stat-item-context .stat-number {
    color: rgba(255, 255, 255, 0.98) !important;
}
.period-indicator .stat-item-context .stat-label {
    color: rgba(255, 255, 255, 0.85);
}

/* Contenedor del período (izquierda) */
.period-content {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--space-3);
    flex: 0 0 auto; /* Don't grow, don't shrink */
    min-width: 0;
    max-width: 60%; /* Limit max width to prevent overlap */
    overflow: hidden; /* Prevent overflow */
}

.period-icon { 
    font-size: var(--text-lg);
    flex-shrink: 0; /* Don't shrink icon */
}
.period-text { 
    flex: 0 1 auto; /* Don't grow, allow shrink, auto basis */
    min-width: 0; /* Allow text to shrink */
    white-space: nowrap; /* Keep text in one line */
    overflow: hidden; /* Prevent overflow */
    text-overflow: ellipsis; /* Show ellipsis if text is too long */
}
.period-indicator .period-label {
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.95) !important;
    opacity: 1 !important;
}
.period-info {
    font-size: var(--text-base);
    font-weight: 600;
    line-height: var(--line-tight);
}
.period-badge {
    background: rgba(255,255,255,0.2);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-btn);
    font-size: var(--text-xs);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0; /* Don't shrink badge */
    white-space: nowrap; /* Keep badge text in one line */
}
.pulse {
    width: 6px;
    height: 6px;
    background: white;
    border-radius: 50%;
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* === CONTENT CARD === */
.content-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-card);
    overflow: visible;
    display: flex;
    flex-direction: column;
}

/* Permitir que los menús de acciones de fila se muestren fuera del content-card */
.content-card .row-actions-menu {
    overflow: visible !important;
}

/* Con dashboard-layout: mismo criterio que Asistencia (padding, centrado, footer abajo) */
.app-container:has(.dashboard-layout) .dashboard-main .main-header,
.app-container:has(.dashboard-layout) .dashboard-main .period-indicator,
.app-container:has(.dashboard-layout) .dashboard-main .main-content {
    max-width: 1800px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    padding-left: clamp(1rem, 3vw, 2.5rem);
    padding-right: clamp(1rem, 3vw, 2.5rem);
    box-sizing: border-box;
}
.app-container:has(.dashboard-layout) .dashboard-main .main-header {
    padding-top: 1rem;
}
/* Cabecera unificada: sin hueco lateral (compensa el padding horizontal del main.content-card) */
.app-container:has(.dashboard-layout) .dashboard-main .main-content.content-card > #studentsModuleHeader.students-page-top--unified {
    max-width: none;
    width: calc(100% + 2 * clamp(1rem, 3vw, 2.5rem));
    margin-left: calc(-1 * clamp(1rem, 3vw, 2.5rem));
    margin-right: calc(-1 * clamp(1rem, 3vw, 2.5rem));
    margin-top: 0.5rem;
    padding-left: 0;
    padding-right: 0;
    box-sizing: border-box;
    border-radius: 1rem 1rem var(--radius-card) var(--radius-card);
}
.app-container:has(.dashboard-layout) .dashboard-main .main-content {
    padding-bottom: 4rem;
    padding-top: 0; /* Added padding-top: 0 */
    margin-top: 0; /* Added margin-top: 0 */
    margin-bottom: 0;
}
/* dashboard-main es el scroll container; main-content crece con su contenido */
.app-container:has(.dashboard-layout) .dashboard-main {
    overflow-x: hidden;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.app-container:has(.dashboard-layout) .dashboard-main .main-content {
    flex: 1 0 auto;
    overflow: visible;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
}
/* Tarjeta principal con mismo aspecto que Asistencia (borde, radio, sombra) */
.app-container:has(.dashboard-layout) .dashboard-main .main-content.content-card {
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Footer al final del flujo: solo visible al hacer scroll hasta abajo */
.app-container:has(.dashboard-layout) .dashboard-main #dashboard-footer-placeholder {
    flex-shrink: 0;
    margin-top: auto;
    padding: 2rem 1rem 1rem;
}


/* === ESTADÍSTICAS === */
.stats-header {
    padding: var(--space-4) var(--space-5);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-4);
    border-bottom: 1px solid var(--border-color);
}

.stats-grid {
    display: flex;
    gap: var(--space-6);
    flex-wrap: wrap;
    align-items: center;
}

/* Estadísticas dentro del period-indicator (derecha) */
.period-indicator .stats-grid {
    gap: var(--space-4);
    flex: 0 0 auto; /* Don't grow, don't shrink */
    flex-shrink: 0; /* Don't shrink stats */
    display: flex;
    flex-wrap: nowrap; /* Keep stats in one row */
    align-items: center;
    min-width: 0; /* Allow to shrink if absolutely necessary */
}
.period-indicator .stat-item {
    min-width: auto;
    flex-shrink: 0; /* Don't shrink individual stat items */
    white-space: nowrap; /* Keep stat text in one line */
}
.period-indicator .stat-number {
    color: white !important; /* Force white color for all stats in period-indicator */
    font-size: var(--text-lg);
}
/* Sobrescribir colores específicos para que todos sean blancos */
.period-indicator .stat-item:nth-child(1) .stat-number,
.period-indicator .stat-item:nth-child(2) .stat-number,
.period-indicator .stat-item:nth-child(3) .stat-number {
    color: white !important;
}
.period-indicator .stat-label {
    color: rgba(255, 255, 255, 0.9);
    font-size: var(--text-xs);
}

.stat-item {
    text-align: center;
    min-width: 72px;
}

.stat-number {
    font-size: var(--text-xl);
    font-weight: 700;
    line-height: var(--line-tight);
    color: var(--primary);
}

.stat-item:nth-child(2) .stat-number { color: var(--success); }
.stat-item:nth-child(3) .stat-number { color: var(--warning); }
.stat-item-context .stat-number { color: var(--text-secondary); font-size: var(--text-lg); }

.stats-context {
    display: none;
    gap: var(--space-5);
    align-items: center;
}
.stats-context.visible {
    display: flex;
}
.stats-context .stat-label {
    font-size: var(--text-xs);
}

.stat-label {
    color: var(--text-secondary);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: var(--line-tight);
}

/* === ACCIONES MASIVAS === */
.bulk-actions {
    padding: var(--space-3) var(--space-5);
    background: var(--bg-tertiary);
    display: none;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}
.bulk-actions.show { display: flex; }
.bulk-text {
    font-weight: 500;
    font-size: var(--text-sm);
    line-height: var(--line-normal);
}

/* === FILTROS === */
.filters-section {
    padding: var(--space-3) var(--space-5);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--space-3);
}
/* Una sola fila de filtros (todos los controles en línea con wrap) */
.filters-section--compact {
    padding-top: var(--space-2);
    padding-bottom: var(--space-2);
}
.filters-row-all {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    align-items: flex-end;
    width: 100%;
}
.filters-row-all .filter-school {
    min-width: 160px;
    flex: 0 1 200px;
    max-width: 280px;
}
.filters-row-all .filter-search {
    flex: 1 1 220px;
    min-width: 180px;
    max-width: 420px;
}
.filters-row-all .filter-select-wrapper:not(.filter-school) {
    min-width: 110px;
    flex: 0 1 140px;
}
.filters-row-all .filters-active-bar {
    margin-left: auto;
}

.filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    align-items: flex-end;
}

.filters-row-main {
    margin-bottom: 0;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    align-items: flex-end;
}

.filters-row-main .filter-school { 
    min-width: 180px; 
    flex: 0 0 auto; 
    max-width: 280px; 
}

.filters-row-main .filter-search { 
    flex: 1; 
    min-width: 200px; 
    max-width: 360px; 
}

.filters-row-secondary {
    margin-top: 0;
    margin-left: 0;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    align-items: flex-end;
}

.filters-active-bar {
    display: none;
    align-items: center;
    gap: var(--space-2);
    margin-left: auto;
}
.filters-active-bar.visible {
    display: flex;
}
.filters-active-bar .filters-active-badge {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    background: var(--bg-secondary);
    padding: var(--space-2) var(--space-2);
    border-radius: var(--radius-btn);
    border: 1px solid var(--border-color);
    line-height: var(--line-tight);
}
.btn-clear-filters {
    white-space: nowrap;
}

.filters-row-secondary .filter-select-wrapper {
    min-width: 120px;
}
.filters-row-secondary .filter-select-wrapper:first-child { min-width: 140px; }

/* Botón Actualizar en barra de filtros (desktop: alineado a la derecha) */
.filters-refresh-btn {
    align-self: flex-end;
    margin-left: auto;
}

/* === FILTROS — responsive === */
@media (max-width: 1024px) {
    .filters-section {
        flex-direction: column;
        align-items: stretch;
        padding-left: var(--space-3);
        padding-right: var(--space-3);
        gap: var(--space-3);
    }
    .filters-row,
    .filters-row-main,
    .filters-row-secondary,
    .filters-row-all {
        width: 100%;
        align-items: stretch;
    }
    .filters-row-main .filter-school,
    .filters-row-main .filter-search {
        flex: 1 1 calc(50% - var(--space-3) / 2);
        max-width: none;
        min-width: 0;
    }
    .filters-row-main .filters-active-bar {
        margin-left: 0;
        justify-content: flex-start;
        flex-wrap: wrap;
        width: 100%;
        flex-basis: 100%;
    }
    .filters-row-secondary {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: var(--space-3);
    }
    .filters-row-secondary .filter-select-wrapper {
        min-width: 0;
    }
    .filters-row-all {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: end;
    }
    .filters-row-all .filter-school,
    .filters-row-all .filter-select-wrapper:not(.filter-school) {
        min-width: 0;
        max-width: none;
        flex: unset;
    }
    .filters-row-all .filter-search {
        grid-column: 1 / -1;
        min-width: 0;
        max-width: none;
        flex: unset;
    }
    .filters-row-all .filters-active-bar {
        grid-column: 1 / -1;
        margin-left: 0;
        justify-content: flex-start;
        flex-wrap: wrap;
    }
    .filters-refresh-btn {
        align-self: stretch;
        margin-left: 0;
        width: 100%;
        justify-content: center;
    }
}
@media (max-width: 560px) {
    .filters-row-main {
        flex-direction: column;
    }
    .filters-row-main .filter-school,
    .filters-row-main .filter-search {
        flex: 1 1 100%;
        width: 100%;
        min-width: 0;
    }
    .filters-row-secondary {
        grid-template-columns: 1fr;
    }
    .filters-row-all {
        grid-template-columns: 1fr;
    }
}

.search-wrapper {
    position: relative;
}

.search-input {
    width: 100%;
    padding: var(--space-2) var(--space-3) var(--space-2) 40px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-btn);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: var(--text-base);
    line-height: var(--line-normal);
}
.search-input:focus {
    outline: none;
    border-color: var(--primary);
}
.search-input:focus-visible {
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb, 2, 11, 71), 0.2);
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.filter-label {
    display: block;
    font-size: var(--text-xs);
    color: var(--text-secondary);
    margin-bottom: var(--space-1);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    line-height: var(--line-tight);
}

.filter-select {
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-btn);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: var(--text-sm);
    line-height: var(--line-normal);
    cursor: pointer;
    min-width: 100%;
    width: 100%;
}

.filter-select-pair {
    display: flex;
    gap: 8px;
}

/* === TABLA === */
.table-container {
    overflow-x: auto;
    overflow-y: visible;
    flex: 1 1 auto;
    min-height: 200px;
    position: relative;
    z-index: 1;
}

/* Asegurar que los menús de acciones no sean cortados por el table-container */
.table-container .row-actions-menu {
    overflow: visible !important;
}

.students-table {
    width: 100%;
    border-collapse: collapse;
}

.students-table th,
.students-table td {
    padding: var(--space-3) var(--space-4);
    text-align: left;
}

.students-table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-primary);
    font-size: var(--text-xs);
    line-height: var(--line-tight);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.students-table th.th-sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}
.students-table th.th-sortable:hover {
    background: var(--bg-secondary);
    color: var(--accent);
}
.students-table th.th-sortable.sort-active {
    color: var(--accent);
}
.students-table th.th-sortable .sort-icon {
    display: inline-block;
    margin-left: 4px;
    font-size: 10px;
    opacity: 0.45;
    vertical-align: middle;
    transition: opacity 0.15s;
}
.students-table th.th-sortable:hover .sort-icon,
.students-table th.th-sortable.sort-active .sort-icon {
    opacity: 1;
}
.students-table th.th-sortable.sort-active .sort-icon {
    color: var(--accent);
}

.students-table tbody tr {
    border-bottom: 1px solid var(--border-color);
}
.students-table tbody tr:hover {
    background: var(--bg-tertiary);
}
.students-table tbody tr.selected {
    background: var(--claude-accent-light);
}

/* Estudiantes inactivos */
.student-row-inactive {
    opacity: 0.7;
}
[data-theme="dark"] .student-row-inactive {
    border-left: 2px solid var(--warning);
}

.badge-inactive {
    background: var(--warning);
    color: white;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 8px;
    margin-left: 6px;
}

/* Info estudiante */
.student-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.student-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
}

.student-row-inactive .student-avatar {
    background: var(--warning);
}

.student-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: var(--text-base);
    line-height: var(--line-tight);
}

.student-name-link {
    font-weight: 600;
    color: var(--text-primary);
    font-size: var(--text-base);
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    line-height: inherit;
    text-decoration: none;
    display: inline;
}
.student-name-link:hover {
    color: var(--primary);
    text-decoration: underline;
}
.student-name-link:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.student-id {
    color: var(--text-secondary);
    font-size: var(--text-xs);
    line-height: var(--line-tight);
}

.grade-badge {
    background: var(--primary);
    color: white;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}

.student-row-inactive .grade-badge {
    background: var(--warning);
}

/* Grado no parametrizado en tabla */
.grade-badge-unassigned {
    background: rgba(234, 179, 8, 0.2);
    color: var(--warning, #b45309);
    border: 1px solid rgba(234, 179, 8, 0.5);
    font-style: italic;
}

/* Aviso en modal cuando el estudiante tiene grado no parametrizado */
.student-grade-disclaimer {
    margin: 0.75rem 0;
    padding: 0.75rem 1rem;
    background: rgba(234, 179, 8, 0.12);
    border: 1px solid rgba(234, 179, 8, 0.4);
    border-radius: 8px;
    font-size: 0.9rem;
}
.student-grade-disclaimer .disclaimer-label {
    margin: 0 0 0.5rem 0;
    color: var(--text-primary, #1a1a1a);
}
.student-grade-disclaimer .disclaimer-grade-value {
    font-style: italic;
    color: var(--warning, #b45309);
}
.student-grade-disclaimer .disclaimer-text {
    margin: 0;
    color: var(--text-secondary, #555);
    line-height: 1.4;
}

.section-split-mini-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 5px;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: 0.3px;
    vertical-align: middle;
}

.section-split-mini-badge--a {
    background: var(--claude-accent-light, rgba(79, 70, 229, 0.12));
    color: var(--claude-accent, #020b47);
    border: 1px solid rgba(79, 70, 229, 0.2);
}

.section-split-mini-badge--b {
    background: rgba(245, 158, 11, 0.12);
    color: var(--claude-warning, #f59e0b);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.contact-info { font-size: 13px; }
.contact-primary { color: var(--text-primary); }
.contact-secondary { color: var(--text-secondary); }

/* === ACCIONES POR FILA (Fase 3) === */
.row-actions-cell {
    width: 1%;
    white-space: nowrap;
    vertical-align: middle;
}
.row-actions-inner {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-row-edit .btn-row-label {
    margin-left: 4px;
}
.row-actions-dropdown {
    position: relative;
    z-index: 20003 !important;
}
.row-actions-menu {
    z-index: 30000 !important;
    min-width: 180px;
    position: fixed !important;
    margin-top: 4px !important;
    isolation: isolate;
    overflow: visible !important;
    clip: unset !important;
    clip-path: none !important;
}

/* Cuando el menú está abierto, usar fixed para que aparezca por encima de todo */
.row-actions-menu.show {
    position: fixed !important;
    z-index: 30000 !important; /* Increased z-index to ensure it's above everything */
    isolation: isolate; /* Create new stacking context */
    overflow: visible !important; /* Ensure menu is not clipped */
    clip: unset !important; /* Remove any clipping */
    clip-path: none !important; /* Remove any clip-path */
}

/* Cuando el menú está en el body, asegurar que no sea cortado */
body > .row-actions-menu.show {
    position: fixed !important;
    z-index: 30000 !important;
    overflow: visible !important;
    clip: unset !important;
    clip-path: none !important;
    pointer-events: auto !important;
}
@media (max-width: 768px) {
    .btn-row-label { display: none; }
}

/* === ESTADOS === */
.state-container {
    padding: var(--space-6) var(--space-6);
    text-align: center;
}

.state-icon {
    font-size: 2.5rem;
    color: var(--text-muted);
    margin-bottom: var(--space-3);
}

.state-title {
    font-size: var(--text-lg);
    font-weight: 600;
    line-height: var(--line-tight);
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.state-description {
    color: var(--text-secondary);
    margin-bottom: var(--space-5);
    font-size: var(--text-base);
    line-height: var(--line-normal);
}

.state-actions {
    display: flex;
    gap: var(--space-2);
    justify-content: center;
    flex-wrap: wrap;
}

/* === MODALES LIMPIOS === */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1300;
    justify-content: center;
    align-items: center;
    overscroll-behavior: contain;
}
[data-theme="dark"] .modal {
    background: rgba(0, 0, 0, 0.7);
}

.modal.show { display: flex; }

/* Modal de importación masiva debe estar por encima de todo (sidebar, botones flotantes z-index:9999) */
#bulkAddModal {
    z-index: 10100 !important;
}

/* Evitar overflow horizontal en página cuando el modal bulk está abierto */
body:has(#bulkAddModal.show) {
    overflow-x: hidden;
}

/* Modales hijos del modal de importación masiva deben estar por encima */
#bulkMappingModal,
#bulkConfirmModal,
#gradeDecisionModal {
    z-index: 10200 !important;
}

/* Modal de traslado de estudiantes debe estar por encima del sidebar (z-index: 1100) */
#transferModal {
    z-index: 1200 !important;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 12px;
    width: 90%;
    max-width: 560px;
    max-height: 90vh;
    overflow: hidden;
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-tertiary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background-color 0.15s;
}
.modal-close:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(90vh - 140px);
}

.modal-footer {
    padding: 16px 20px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    border-top: 1px solid var(--border-color);
}

/* === EXPORTACIÓN EXCEL === */
.export-modal-content {
    max-width: 620px;
}

.export-option-group {
    margin-bottom: 20px;
}

.export-option-group:last-child {
    margin-bottom: 0;
}

.export-option-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.export-option-title i {
    font-size: 12px;
    color: var(--primary);
    opacity: 0.7;
}

/* --- Selects de grado/sección --- */
.export-selects-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.export-select-wrapper {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.export-select-wrapper label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

.export-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.export-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb, 22, 101, 52), 0.12);
}

/* --- Format chips (lista/hoja por grado) --- */
.export-format-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.export-format-chip {
    cursor: pointer;
}

.export-format-chip input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.export-format-chip-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px 10px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-primary);
    transition: all 0.2s;
    text-align: center;
}

.export-format-chip-inner i {
    font-size: 20px;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.export-format-chip-inner span {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.export-format-chip-inner small {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.2;
}

.export-format-chip input[type="radio"]:checked + .export-format-chip-inner {
    border-color: var(--primary);
    background: rgba(var(--primary-rgb, 22, 101, 52), 0.06);
}

.export-format-chip input[type="radio"]:checked + .export-format-chip-inner i {
    color: var(--primary);
}

.export-format-chip-inner:hover {
    border-color: var(--primary);
}

/* --- Status chips --- */
.export-status-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.export-status-chip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 8px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.export-status-chip:hover {
    border-color: var(--primary);
}

.export-status-chip input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.export-status-chip input[type="radio"]:checked ~ span {
    color: var(--primary);
    font-weight: 700;
}

.export-status-chip input[type="radio"]:checked ~ span i {
    color: var(--primary);
}

.export-status-chip:has(input[type="radio"]:checked) {
    border-color: var(--primary);
    background: rgba(var(--primary-rgb, 22, 101, 52), 0.06);
}

.export-status-chip span {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 5px;
}

.export-status-chip span i {
    font-size: 12px;
    color: var(--text-secondary);
}

/* --- Column chips --- */
.export-columns-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.export-column-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.export-column-chip:hover {
    border-color: var(--primary);
}

.export-column-chip input[type="checkbox"] {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
    cursor: pointer;
    flex-shrink: 0;
}

.export-column-chip:has(input[type="checkbox"]:checked) {
    border-color: var(--primary);
    background: rgba(var(--primary-rgb, 22, 101, 52), 0.05);
}

.export-column-chip span {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

/* --- Style selector cards --- */
.export-style-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.export-style-card {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-primary);
    transition: all 0.2s;
}

.export-style-card:hover {
    border-color: var(--primary);
}

.export-style-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.export-style-card:has(input[type="radio"]:checked) {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb, 22, 101, 52), 0.12);
}

.export-style-preview {
    padding: 10px 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.export-style-preview .esp-header,
.export-style-preview .esp-row {
    display: flex;
    gap: 4px;
}

.export-style-preview .esp-header span,
.export-style-preview .esp-row span {
    flex: 1;
    height: 6px;
    border-radius: 2px;
}

/* -- Colored style preview -- */
.export-style-preview--colored .esp-header span {
    background: #1976D2;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.export-style-preview--colored .esp-row span {
    background: #e8e8e8;
    border: 1px solid #e0e0e0;
}

.export-style-preview--colored .esp-row.esp-row--even span {
    background: #BBDEFB;
    border: 1px solid #90CAF9;
}

/* -- Clean style preview -- */
.export-style-preview--clean .esp-header span {
    background: #333333;
}

.export-style-preview--clean .esp-row span {
    background: #f8f8f8;
    border: none;
}

.export-style-label {
    padding: 8px 12px 10px;
}

.export-style-label strong {
    display: block;
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 1px;
}

.export-style-label small {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.3;
}

/* --- Export preview strip --- */
.export-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(var(--primary-rgb, 22, 101, 52), 0.06);
    border-radius: 10px;
    border: 1px solid rgba(var(--primary-rgb, 22, 101, 52), 0.15);
    margin-top: 4px;
}

.export-preview i {
    color: var(--primary);
    font-size: 14px;
    flex-shrink: 0;
}

.export-preview span {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

@media (max-width: 640px) {
    .export-selects-row {
        grid-template-columns: 1fr;
    }
    .export-format-grid {
        grid-template-columns: 1fr;
    }
    .export-status-grid {
        grid-template-columns: 1fr;
    }
    .export-columns-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .export-style-grid {
        grid-template-columns: 1fr;
    }
}

/* === LIMPIEZA DEL SISTEMA === */
.cleanup-main-modal {
    max-width: 640px;
}

.cleanup-warning-card {
    background: rgba(245, 158, 11, 0.12);
    padding: 16px;
    border-radius: 10px;
    margin-bottom: 16px;
    border-left: 4px solid var(--warning);
}

.cleanup-warning-card h4 {
    color: var(--warning);
    margin-bottom: 8px;
    display: flex;
    gap: 8px;
    align-items: center;
}

.cleanup-warning-card p {
    color: var(--text-secondary);
    line-height: 1.45;
}

.cleanup-scope-note {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    margin-bottom: 16px;
}

.cleanup-scope-note i {
    color: #22c55e;
    margin-top: 2px;
}

.cleanup-scope-note div {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cleanup-scope-note span {
    color: var(--text-secondary);
    font-size: 13px;
}

.cleanup-options-title {
    margin: 0 0 10px;
    font-size: 14px;
}

.cleanup-main-option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    border: 1px solid rgba(245, 158, 11, 0.4);
    border-radius: 10px;
    cursor: pointer;
    background: rgba(245, 158, 11, 0.06);
}

.cleanup-main-option strong {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--warning);
}

.cleanup-main-option div div {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.35;
}

.cleanup-confirm-modal {
    max-width: 660px;
}

.cleanup-confirm-intro {
    color: var(--text-secondary);
    margin-bottom: 14px;
}

.cleanup-confirm-scope {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px;
    display: grid;
    gap: 6px;
    margin-bottom: 14px;
}

.cleanup-confirm-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.cleanup-stat-item {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px;
    display: grid;
    gap: 2px;
}

.cleanup-stat-item span {
    font-size: 12px;
    color: var(--text-secondary);
}

.cleanup-stat-item strong {
    font-size: 21px;
    color: var(--text-primary);
}

.cleanup-stat-item small {
    font-size: 11px;
    color: var(--text-secondary);
}

.cleanup-ack {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.cleanup-ack input[type="checkbox"] {
    margin-top: 3px;
}

.cleanup-progress-modal {
    max-width: 420px;
    text-align: center;
    padding: 24px;
}

.cleanup-progress-icon {
    width: 62px;
    height: 62px;
    margin: 0 auto 12px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    animation: cleanupPulse 1.4s ease-in-out infinite;
    box-shadow: 0 12px 24px rgba(239, 68, 68, 0.24);
}

.cleanup-progress-icon i {
    font-size: 24px;
    animation: cleanupRotate 1.1s linear infinite;
}

.cleanup-progress-modal h3 {
    margin: 0 0 6px;
    font-size: 20px;
}

.cleanup-progress-modal p {
    margin: 0 0 14px;
    color: var(--text-secondary);
    font-size: 14px;
}

.cleanup-progress-bar {
    height: 10px;
    border-radius: 999px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.cleanup-progress-bar span {
    display: block;
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, #f59e0b, #ef4444);
    transition: width 0.35s ease;
}

.cleanup-progress-meta {
    margin-top: 8px;
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
}

.cleanup-result-modal {
    max-width: 640px;
}

.cleanup-result-intro {
    margin: 0 0 12px;
    color: var(--text-secondary);
}

.cleanup-result-summary {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px;
    display: grid;
    gap: 5px;
    margin-bottom: 14px;
}

.cleanup-result-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.cleanup-result-item {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px;
    background: var(--bg-primary);
}

.cleanup-result-item span {
    font-size: 12px;
    color: var(--text-secondary);
    display: block;
}

.cleanup-result-item strong {
    font-size: 22px;
    color: var(--text-primary);
}

@keyframes cleanupPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.06); }
}

@keyframes cleanupRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@media (max-width: 768px) {
    .cleanup-confirm-stats {
        grid-template-columns: 1fr;
    }

    .cleanup-result-grid {
        grid-template-columns: 1fr;
    }
}

/* === FORMULARIOS === */
.form-group { margin-bottom: 16px; }

.form-label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 13px;
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
}
.form-input:focus {
    outline: none;
    border-color: var(--primary);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* === CHECKBOX === */
.checkbox-cell {
    text-align: center;
    width: 44px;
}

.custom-checkbox {
    position: relative;
    display: inline-block;
    width: 18px;
    height: 18px;
}

.custom-checkbox input {
    opacity: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    cursor: pointer;
}

.custom-checkbox .checkmark {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-secondary);
    transition: all 0.15s;
}

.custom-checkbox input:checked + .checkmark {
    background: var(--success);
    border-color: var(--success);
}

.custom-checkbox .checkmark::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 5px;
    width: 5px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    opacity: 0;
}

.custom-checkbox input:checked + .checkmark::after {
    opacity: 1;
}

/* === TOASTS === */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 360px;
}

.toast {
    background: var(--bg-secondary);
    border-radius: 10px;
    padding: 14px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.25s ease;
}
.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info { border-left: 3px solid var(--info); }

.toast-icon { font-size: 18px; }
.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--danger); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.info .toast-icon { color: var(--info); }

.toast-content { flex: 1; }
.toast-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
    margin-bottom: 2px;
}
.toast-message {
    color: var(--text-secondary);
    font-size: 13px;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    width: 20px;
    height: 20px;
}
.toast-close:hover { color: var(--text-primary); }

/* === BULK ADD MODAL === */
.bulk-modal-content {
    width: 95%;
    max-width: 1200px;
}

.instruction-box {
    background: var(--claude-accent-light);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 20px;
}

.instruction-title {
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 6px;
}

.bulk-table-container {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin: 20px 0;
    height: calc(100vh - 430px);
    overflow-x: auto;
    overflow-y: auto;
    background: var(--bg-secondary);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
    max-width: 100%;
}

.bulk-table {
    width: 100%;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: auto;
}

.bulk-table th {
    position: sticky;
    top: 0;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 14px 10px;
    border-bottom: 2px solid var(--border-color);
    z-index: 10;
    text-align: center;
}

.bulk-table td {
    padding: 2px;
    border-bottom: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.bulk-table tr:hover td {
    background: var(--bg-tertiary);
}

.bulk-cell-input {
    width: 100%;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 10px 12px;
    background: transparent;
    color: var(--text-primary);
    font-size: 13.5px;
    outline: none;
    transition: all 0.2s;
}

.bulk-cell-input:hover {
    background: var(--bg-tertiary);
}

.bulk-cell-input:focus {
    background: var(--bg-secondary);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--claude-accent-light);
    z-index: 5;
    position: relative;
}

.bulk-cell-input.invalid {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.4);
    color: #ef4444;
}

.bulk-row-number {
    background: var(--bg-tertiary);
    text-align: center;
    font-weight: 700;
    color: var(--text-secondary);
    font-size: 11px;
    width: 40px;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .app-container { padding: 12px; }

    .header-content {
        flex-direction: column;
        text-align: center;
    }

    .header-actions {
        justify-content: center;
    }

    .filters-row-main,
    .filters-row-secondary,
    .filters-row-all {
        flex-direction: column;
    }
    .filters-row-main .filter-school,
    .filters-row-main .filter-search,
    .filters-row-all .filter-school,
    .filters-row-all .filter-search {
        max-width: none;
    }
    .filters-row-all .filters-active-bar {
        margin-left: 0;
        width: 100%;
        justify-content: flex-start;
    }
    .filters-active-bar {
        margin-left: 0;
        width: 100%;
    }

    .stats-grid {
        justify-content: center;
        gap: 16px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .modal-content,
    .bulk-modal-content {
        margin: 10px;
        width: calc(100% - 20px);
    }

    .toast-container {
        left: 12px;
        right: 12px;
        max-width: none;
    }

    .btn .btn-text { display: none; }
    .btn { padding: 8px 10px; min-width: 40px; justify-content: center; }

    .period-indicator {
        flex-wrap: nowrap; /* Keep in one row even on mobile */
        gap: var(--space-2);
        overflow-x: auto; /* Allow horizontal scroll if needed */
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    }
    .period-indicator .stats-grid {
        margin-left: auto;
        gap: var(--space-2); /* Smaller gap on mobile */
        flex-shrink: 0;
    }
    .period-text {
        font-size: var(--text-sm); /* Slightly smaller text on mobile */
    }
    .period-badge { 
        flex-shrink: 0;
    }
}

@media (max-width: 480px) {
    .students-table th:nth-child(5),
    .students-table td:nth-child(5),
    .students-table th:nth-child(6),
    .students-table td:nth-child(6) {
        display: none;
    }

    .stats-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        width: 100%;
    }

    .stat-item { min-width: auto; }
    .stat-number { font-size: 20px; }
}

/* === MODAL DE TRASLADO === */
.transfer-modal-glass {
    background: var(--bg-secondary) !important;
    animation: modalIn 0.25s ease !important;
}

.transfer-student-card {
    margin-bottom: 16px;
    background: var(--primary) !important;
    padding: 16px;
    border-radius: 12px;
    color: white !important;
}

.transfer-icon-container {
    background: rgba(255, 255, 255, 0.2) !important;
    padding: 10px;
    border-radius: 10px;
}

.transfer-form-group {
    background: var(--claude-accent-light) !important;
    padding: 14px;
    border-radius: 10px;
    border: none !important;
}

.transfer-select {
    font-size: 14px;
    padding: 10px;
    background: var(--bg-primary) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 8px;
    color: var(--text-primary) !important;
}

.transfer-warning {
    margin-top: 10px;
    padding: 12px;
    background: rgba(220, 38, 38, 0.1) !important;
    color: var(--danger) !important;
    border-radius: 8px;
    font-size: 13px;
    border: none !important;
}

.transfer-footer {
    border-top: 1px solid var(--border-color) !important;
    padding: 16px !important;
    background: transparent !important;
}

.transfer-submit-btn {
    background: var(--success) !important;
    color: white !important;
    font-weight: 600;
}

.transfer-chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    margin: 3px 3px 0 0;
    background: var(--claude-accent-light);
    color: var(--primary);
}
.transfer-chip.success { background: rgba(5,150,105,0.15); color: var(--success); }
.transfer-chip.warning { background: rgba(217,119,6,0.15); color: var(--warning); }
.transfer-chip.danger { background: rgba(220,38,38,0.15); color: var(--danger); }
.transfer-chip.muted { background: var(--bg-tertiary); color: var(--text-secondary); }

/* === MODAL DE TRASLADO PANTALLA COMPLETA === */
.transfer-modal-fullscreen {
    width: 98vw !important;
    max-width: 98vw !important;
    height: 98vh !important;
    max-height: 98vh !important;
    margin: 1vh auto !important;
    border-radius: 16px !important;
}

.transfer-comparison-tabs {
    display: flex;
    gap: 0;
    width: 100%;
}

.transfer-comparison-tab {
    appearance: none;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
}

.transfer-comparison-tab:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.transfer-comparison-tab.active {
    background: var(--bg-secondary);
    color: var(--primary);
    border-color: var(--primary);
    border-bottom-color: var(--bg-secondary);
    position: relative;
    z-index: 1;
}

.transfer-comparison-content {
    border: 2px solid var(--border-color);
    border-radius: 0 0 12px 12px;
    padding: 20px;
    background: var(--bg-secondary);
    min-height: 400px;
    max-height: calc(98vh - 400px);
    overflow-y: auto;
}

.transfer-comparison-panel {
    display: none;
}

.transfer-comparison-panel[style*="display: block"] {
    display: block;
}

/* === BULK MODAL FULLSCREEN === */
.bulk-modal-fullscreen {
    width: 100% !important;
    max-width: 100% !important;
    height: 100vh !important;
    max-height: 100vh !important;
    margin: 0 !important;
    border-radius: 0 !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.bulk-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    position: relative;
    z-index: 30;
}

.bulk-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bulk-brand-icon {
    width: 44px;
    height: 44px;
    background: #437799;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
}

.bulk-title-section h2.bulk-main-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.bulk-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
}

.bulk-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bulk-mobile-toggles { display: none; gap: 6px; }

.btn-bulk-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-bulk-toggle.active {
    background: #437799;
    color: white;
    border-color: #437799;
}

.bulk-close-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.bulk-close-btn:hover { background: var(--danger); color: white; }

.bulk-modal-body {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr;
    overflow: hidden;
    position: relative;
    background: var(--bg-primary);
    min-height: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.bulk-form-section {
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--bg-primary);
    padding: 0;
    min-width: 0;
    max-width: 100%;
}

.bulk-form-wrapper {
    padding: 24px;
    max-width: 1400px; /* Aumentado para pantallas anchas */
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

.bulk-info-banner {
    display: flex;
    align-items: center;
    gap: 16px;
    background: linear-gradient(135deg, rgba(67, 119, 153, 0.08) 0%, rgba(67, 119, 153, 0.08) 100%);
    padding: 16px 20px;
    border-radius: 14px;
    border: 1px solid rgba(67, 119, 153, 0.15);
    margin-bottom: 25px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

[data-theme="dark"] .bulk-info-banner {
    background: linear-gradient(135deg, rgba(67, 119, 153, 0.12) 0%, rgba(67, 119, 153, 0.12) 100%);
    border-color: rgba(67, 119, 153, 0.2);
}

.bulk-info-banner i {
    color: #437799;
    font-size: 20px;
    background: var(--bg-primary);
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.04);
    flex-shrink: 0;
}

.bulk-info-banner .banner-content {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.bulk-info-banner strong {
    color: var(--text-primary);
    font-weight: 700;
    font-size: 14.5px;
    letter-spacing: -0.2px;
}

.bulk-info-banner span {
    color: var(--text-secondary);
    font-size: 13.5px;
    line-height: 1.4;
}

/* === ZONA DE SUBIDA DE ARCHIVOS === */
.bulk-file-upload-section {
    margin-bottom: 16px;
}

.bulk-file-dropzone {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 28px 20px;
    text-align: center;
    background: var(--bg-secondary);
    transition: all 0.2s ease;
    cursor: pointer;
}

.bulk-file-dropzone:hover,
.bulk-file-dropzone.dragover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.04);
}

.bulk-file-dropzone i.fa-file-upload {
    font-size: 32px;
    color: var(--primary);
    margin-bottom: 8px;
}

.bulk-file-dropzone p {
    margin: 4px 0;
    color: var(--text-primary);
    font-size: 14px;
}

.bulk-file-dropzone .bulk-dropzone-hint {
    font-size: 12px;
    color: var(--text-secondary);
}

.bulk-file-btn {
    margin-top: 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.bulk-file-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 8px;
}

/* === MODAL DE MAPEO === */
.bulk-mapping-table th {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.bulk-mapping-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.bulk-mapping-table .mapping-header-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 13.5px;
}

.bulk-mapping-table .mapping-example {
    font-size: 12px;
    color: var(--text-secondary);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
}

.bulk-mapping-table select {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 13px;
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
}

.bulk-mapping-table select.mapping-unmapped {
    border-color: var(--warning, #f59e0b);
    background: rgba(245, 158, 11, 0.06);
}

.bulk-mapping-table select.mapping-matched {
    border-color: var(--success, #10b981);
    background: rgba(16, 185, 129, 0.06);
}

.bulk-mapping-preview-table th,
.bulk-mapping-preview-table td {
    padding: 5px 8px;
    border: 1px solid var(--border-color);
    font-size: 12px;
    white-space: nowrap;
}

.bulk-mapping-preview-table th {
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-secondary);
    position: sticky;
    top: 0;
}

.bulk-mapping-preview-table td {
    color: var(--text-primary);
}

/* === NUEVO SELECTOR DE MODOS (TABS) === */
.bulk-mode-tabs {
    display: flex;
    background: var(--bg-tertiary);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.bulk-mode-tab {
    padding: 8px 16px;
    border: none;
    background: transparent;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.bulk-mode-tab i { font-size: 14px; opacity: 0.7; }

.bulk-mode-tab.active {
    background: var(--bg-secondary);
    color: #437799;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.bulk-mode-tab.active i { opacity: 1; }

.bulk-config-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02);
}

.bulk-config-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.bulk-config-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}
.btn-outline:hover { background: var(--bg-tertiary); }

.bulk-config-mode { display: none; }
.bulk-config-mode.active { display: block; }

.bulk-info-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    background: rgba(37,99,235,0.08);
    border-radius: 8px;
}
.bulk-info-card i { color: var(--info); font-size: 16px; flex-shrink: 0; }
.bulk-info-card p { margin: 0; color: var(--text-secondary); font-size: 13px; }

.bulk-table-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 16px;
}

.bulk-table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}
.bulk-table-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}

.bulk-table-actions { display: flex; gap: 6px; }



.bulk-errors-section {
    background: rgba(220,38,38,0.1);
    border-radius: 8px;
    padding: 12px;
    margin-top: 12px;
}

.bulk-modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 32px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.04);
    position: relative;
    z-index: 1;
    width: 100%;
}

.bulk-footer-left { 
    display: flex; 
    align-items: center; 
    gap: 16px; 
}
.bulk-stats { 
    font-size: 13.5px; 
    color: #437799; 
    font-weight: 700;
    padding: 8px 18px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    border: 1px solid rgba(67, 119, 153, 0.2);
}
.bulk-footer-actions { 
    display: flex; 
    gap: 12px; 
}

/* Mejora botones en footer para que se vean más profesionales */
.bulk-modal-footer .btn {
    height: 46px;
    padding: 0 28px;
    font-size: 14.5px;
    font-weight: 700;
    border-radius: 12px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 10px;
}

.bulk-modal-footer .btn-primary {
    background: linear-gradient(135deg, #437799 0%, #35607a 100%);
    color: white;
    border: none;
    box-shadow: 0 6px 15px rgba(67, 119, 153, 0.25);
}

.bulk-modal-footer .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(67, 119, 153, 0.35);
    filter: brightness(1.1);
}

.bulk-table-actions .btn-info {
    background: #437799;
    color: white;
    border-color: #437799;
}

.bulk-modal-footer .btn-info {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.bulk-modal-footer .btn-info:hover {
    background: var(--bg-tertiary);
    border-color: var(--text-secondary);
}

/* Responsive bulk modal */
@media (max-width: 900px) {
    .bulk-mobile-toggles { display: flex; }
    .bulk-modal-body { grid-template-columns: 1fr; }

    .bulk-form-section {
        position: absolute;
        inset: 0;
        border-right: none;
        transition: transform 0.25s ease, opacity 0.25s ease;
    }
}

@media (max-width: 600px) {
    .bulk-modal-header { 
        padding: 12px 16px; 
        display: grid;
        grid-template-columns: 1fr auto;
        column-gap: 12px;
        row-gap: 8px; /* Espacio mínimo entre filas */
    }
    .bulk-header-left { 
        grid-column: 1;
        display: flex;
        align-items: center;
        gap: 10px;
    }
    .bulk-header-actions {
        grid-column: 1 / span 2;
        display: flex;
        width: 100%;
        margin-top: 0;
    }
    .bulk-close-btn {
        grid-column: 2;
        grid-row: 1;
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    .bulk-mobile-toggles {
        display: flex;
        flex: 1;
        background: var(--bg-tertiary);
        padding: 3px;
        border-radius: 12px;
        border: 1px solid var(--border-color);
        box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
    }
    .btn-bulk-toggle {
        flex: 1;
        justify-content: center;
        border: none;
        padding: 8px;
        font-size: 11.5px;
        font-weight: 600;
        border-radius: 9px;
        background: transparent;
        color: var(--text-secondary);
    }
    .btn-bulk-toggle.active {
        background: var(--bg-secondary);
        color: var(--primary);
        box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    }
    .btn-bulk-toggle span { display: inline-block !important; }

    .bulk-brand-icon { width: 34px; height: 34px; font-size: 14px; }
    .bulk-title-section h2.bulk-main-title { font-size: 14.5px; line-height: 1.2; font-weight: 700; color: var(--text-primary); }
    .bulk-subtitle { font-size: 10.5px; opacity: 0.8; line-height: 1.3; }
    .bulk-form-wrapper { padding: 12px; }

    .bulk-config-section {
        padding: 15px;
        margin-bottom: 15px;
    }

    /* Estilos mejorados para la configuración en móvil */
    .bulk-config-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 12px;
        margin-bottom: 15px;
    }

    .bulk-config-header h3 {
        font-size: 14px;
        width: 100%;
    }

    .bulk-mode-tabs {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        padding: 3px;
    }

    .bulk-mode-tab {
        padding: 10px 6px;
        font-size: 12px;
        justify-content: center;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .form-group {
        width: 100% !important;
        flex: none !important;
    }
    
    .bulk-modal-footer { 
        padding: 15px; 
        flex-direction: column !important; 
        gap: 12px; 
        height: auto;
        align-items: center;
    }
    
    .bulk-footer-left { 
        width: 100%; 
        display: flex;
        justify-content: center; 
    }
    
    .bulk-stats {
        width: 100%;
        text-align: center;
        font-size: 12px;
        padding: 6px 10px;
    }
    
    .bulk-footer-actions { 
        width: 100%; 
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    
    .bulk-modal-footer .btn { 
        width: 100%;
        padding: 0 8px;
        font-size: 12px;
        height: 40px;
        justify-content: center;
    }
    
    .bulk-modal-footer .btn-primary { grid-column: span 2; font-size: 13px; height: 44px; }
    
    .bulk-table-container { height: calc(100vh - 460px); }
    .btn-bulk-toggle span { display: inline-block !important; }
    
    .bulk-mode-tabs { width: 100%; overflow-x: auto; }
    .bulk-mode-tab { flex: 1; justify-content: center; white-space: nowrap; }
}

/* Scrollbars modernos */
.bulk-form-section::-webkit-scrollbar,
.bulk-table-container::-webkit-scrollbar,
.modal-body::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.bulk-form-section::-webkit-scrollbar-track,
.bulk-table-container::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track {
    background: transparent;
}
.bulk-form-section::-webkit-scrollbar-thumb,
.bulk-table-container::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb {
    background: rgba(115,115,115,0.3);
    border-radius: 10px;
}
.bulk-form-section::-webkit-scrollbar-thumb:hover,
.bulk-table-container::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover {
    background: rgba(115,115,115,0.5);
}

/* Firefox */
.bulk-form-section,
.bulk-table-container,
.modal-body {
    scrollbar-width: thin;
    scrollbar-color: rgba(115,115,115,0.3) transparent;
}

/* Ocultar botones flotantes cuando el modal está abierto */
#bulkAddModal.show ~ .quick-access-mini-trigger,
body:has(#bulkAddModal.show) .quick-access-mini-trigger {
    display: none !important;
}

/* Ocultar botones de soporte cuando el modal de importación masiva está abierto */
body:has(#bulkAddModal.show) .support-floating-btn,
body:has(#bulkAddModal.show) #supportFloatingBtn,
body:has(#bulkAddModal.show) .support-top-btn,
body:has(#bulkAddModal.show) #supportTopBtn {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* Reserva de espacio para que los botones flotantes no tapen la última fila */
body.students-module-page main.content-card {
    padding-bottom: 6rem;
}

/* Transfer tabs y herramientas avanzadas */
.transfer-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.transfer-tab-btn {
    flex: 1;
    min-width: 160px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 8px 14px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.15s;
}
.transfer-tab-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.transfer-tab-panels { display: flex; flex-direction: column; gap: 14px; }
.transfer-tab-panel { display: none; }
.transfer-tab-panel.active { display: block; }

.advanced-tool-card {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 14px;
    background: var(--bg-secondary);
}
.advanced-tool-header h3 { margin: 0; font-size: 14px; color: var(--text-primary); }
.advanced-tool-header p { margin: 3px 0 0; font-size: 12px; color: var(--text-secondary); }
.advanced-tool-body { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }

.split-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px dashed var(--border-color);
    font-size: 11px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
.split-students-table {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}
.split-students-table table { width: 100%; border-collapse: collapse; font-size: 12px; }
.split-students-table th,
.split-students-table td { padding: 6px 8px; border-bottom: 1px solid var(--border-color); }
.split-students-table thead { background: var(--bg-tertiary); position: sticky; top: 0; z-index: 1; }

.advanced-actions { display: flex; justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
.advanced-feedback { font-size: 11px; }
.transfer-error { color: var(--danger); }
.transfer-success { color: var(--success); }

/* Animaciones para filtros colapsables (Secciones) */
.filter-select-wrapper {
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-origin: left center;
    max-width: 300px;
}

.filter-hidden {
    opacity: 0 !important;
    max-width: 0 !important;
    min-width: 0 !important;
    transform: scale(0.8) !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    pointer-events: none !important;
    overflow: hidden !important;
    border: none !important;
}

/* Confirmar Importación (bulk) */
.bulk-confirm-details {
    background: var(--bg-primary);
    border-radius: 14px;
    padding: 14px;
    margin-bottom: 20px;
    border: 1px dashed var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.bulk-confirm-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.bulk-confirm-icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: rgba(67, 119, 153, 0.12);
    color: #437799;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.bulk-confirm-title {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin: 2px 0 6px;
}

.bulk-confirm-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.5;
}

.bulk-confirm-text strong {
    font-weight: 800;
}

.bulk-confirm-list {
    margin: 6px 0 0;
    padding-left: 18px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.5;
}

.bulk-confirm-list li {
    margin: 4px 0;
}

.bulk-confirm-subtle {
    color: var(--text-secondary);
    font-weight: 600;
}

/* ============================================
   HERRAMIENTAS TSE - Modal Rediseñado
   ============================================ */
.tse-modal-content {
    max-width: 1200px !important;
    width: 96% !important;
}
.tse-modal-header {
    background: linear-gradient(135deg, var(--primary), #0f3d8c);
    padding: 18px 24px !important;
    border-bottom: none !important;
}
.tse-modal-header .modal-title {
    color: #fff !important;
    font-size: 18px;
}
.tse-modal-header .modal-close {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: none;
}
.tse-modal-header .modal-close:hover {
    background: rgba(255,255,255,0.3);
    color: #fff;
}
.tse-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}
.tse-header-icon {
    width: 42px;
    height: 42px;
    background: rgba(255,255,255,0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #fff;
}
.tse-header-subtitle {
    color: rgba(255,255,255,0.75);
    font-size: 12px;
    margin: 2px 0 0 0;
}

/* Pestañas */
.tse-tabs {
    display: flex;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    padding: 0 16px;
    gap: 4px;
}
.tse-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.tse-tab:hover {
    color: var(--text-primary);
    background: rgba(99,102,241,0.06);
}
.tse-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}
.tse-tab i {
    font-size: 14px;
}

/* Paneles de pestañas */
.tse-tab-panel {
    display: none;
}
.tse-tab-panel.active {
    display: block;
}
.tse-panel-inner {
    padding: 20px 24px;
}

/* Info cards */
.tse-info-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: rgba(99,102,241,0.08);
    border-left: 4px solid var(--primary);
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 18px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-primary);
}
.tse-info-card-blue {
    background: rgba(59,130,246,0.08);
    border-left-color: #3b82f6;
}
.tse-info-icon {
    font-size: 18px;
    color: var(--primary);
    margin-top: 1px;
    flex-shrink: 0;
}
.tse-info-card-blue .tse-info-icon { color: #3b82f6; }
.tse-info-text { flex: 1; }

/* Controls row */
.tse-controls-row {
    display: flex;
    align-items: flex-end;
    gap: 14px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.tse-control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.tse-actions-group {
    flex-direction: row;
    align-items: flex-end;
    gap: 8px;
}
.tse-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.tse-select {
    padding: 9px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
    min-width: 200px;
    transition: border-color 0.2s;
}
.tse-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

/* Buttons TSE */
.tse-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}
.tse-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.tse-btn-primary {
    background: var(--primary);
    color: #fff;
}
.tse-btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99,102,241,0.3);
}
.tse-btn-success {
    background: var(--success);
    color: #fff;
}
.tse-btn-success:hover:not(:disabled) {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

/* Note */
.tse-note {
    font-size: 12px;
    color: var(--warning);
    background: rgba(245,158,11,0.08);
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Progress */
.tse-progress-box {
    margin-bottom: 16px;
    background: var(--bg-tertiary);
    padding: 14px 16px;
    border-radius: 10px;
}
.tse-progress-header {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin-bottom: 8px;
    color: var(--text-primary);
}
.tse-progress-count {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.tse-progress-track {
    height: 8px;
    background: var(--bg-primary);
    border-radius: 6px;
    overflow: hidden;
}
.tse-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--success));
    border-radius: 6px;
    transition: width 0.3s ease;
}
.tse-progress-status {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 6px;
}

/* Results container */
.tse-results-container {
    background: var(--bg-tertiary);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    max-height: 380px;
    overflow-y: auto;
}

/* Table */
.tse-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.tse-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}
.tse-table th {
    padding: 10px 10px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--border-color);
    text-align: left;
    white-space: nowrap;
}
.tse-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}
.tse-table tbody tr:hover {
    background: rgba(99,102,241,0.04);
}
.tse-table .tse-input {
    padding: 5px 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 11px;
    width: 100%;
    min-width: 100px;
}
.tse-table .tse-input:focus {
    outline: none;
    border-color: var(--primary);
}
.tse-table .tse-input.tse-input-fix {
    border-color: #2563eb;
    background: rgba(59,130,246,0.06);
}
.tse-table .tse-input.tse-input-diff {
    border-color: #d97706;
    background: rgba(245,158,11,0.08);
}
.tse-table .tse-date-input {
    width: 130px;
}

/* Badges de estado */
.tse-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}
.tse-badge-pending { background: rgba(107,114,128,0.12); color: var(--text-secondary); }
.tse-badge-processing { background: rgba(245,158,11,0.15); color: #d97706; }
.tse-badge-success { background: rgba(34,197,94,0.12); color: #16a34a; }
.tse-badge-error { background: rgba(239,68,68,0.12); color: #dc2626; }
.tse-badge-notfound { background: rgba(234,179,8,0.15); color: #a16207; }
.tse-badge-skip { background: rgba(107,114,128,0.1); color: #6b7280; }
.tse-badge-ok { background: rgba(34,197,94,0.12); color: #16a34a; }
.tse-badge-fix { background: rgba(59,130,246,0.12); color: #2563eb; }
.tse-badge-mismatch { background: rgba(245,158,11,0.15); color: #d97706; }

/* Normalización: stats */
.tse-stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}
.tse-stat-card {
    padding: 12px;
    border-radius: 10px;
    text-align: center;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
}
.tse-stat-number {
    font-size: 22px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}
.tse-stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-top: 2px;
}
.tse-stat-total .tse-stat-number { color: var(--text-primary); }
.tse-stat-ok .tse-stat-number { color: #16a34a; }
.tse-stat-fix .tse-stat-number { color: #2563eb; }
.tse-stat-warn .tse-stat-number { color: #d97706; }

/* Name comparison cells */
.tse-name-current {
    font-family: 'SF Mono', 'Cascadia Code', monospace;
    font-size: 12px;
    padding: 4px 8px;
    background: rgba(239,68,68,0.06);
    border-radius: 4px;
    border: 1px solid rgba(239,68,68,0.15);
    color: var(--text-primary);
}
.tse-name-proposed {
    font-family: 'SF Mono', 'Cascadia Code', monospace;
    font-size: 12px;
    padding: 4px 8px;
    background: rgba(34,197,94,0.06);
    border-radius: 4px;
    border: 1px solid rgba(34,197,94,0.15);
    color: var(--text-primary);
    font-weight: 600;
}
.tse-name-match {
    background: rgba(34,197,94,0.04);
    border-color: rgba(34,197,94,0.1);
}
.tse-section-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.2px;
    text-transform: uppercase;
    background: rgba(99, 102, 241, 0.12);
    color: var(--primary);
    border: 1px solid rgba(99, 102, 241, 0.2);
}
.tse-section-pill-empty {
    text-transform: none;
    background: rgba(107, 114, 128, 0.12);
    color: var(--text-secondary);
    border-color: rgba(107, 114, 128, 0.2);
}

/* Norm detail tags */
.tse-detail-tag {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.2px;
}
.tse-state-details {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 5px;
}
.tse-detail-caps { background: rgba(59,130,246,0.12); color: #2563eb; }
.tse-detail-different { background: rgba(245,158,11,0.15); color: #d97706; }
.tse-detail-ok { background: rgba(34,197,94,0.12); color: #16a34a; }
.tse-detail-cache { background: rgba(99,102,241,0.12); color: #4338ca; }
.tse-detail-warn { background: rgba(234,179,8,0.15); color: #a16207; }

/* Word-level diff highlighting */
.tse-word-diff {
    background: rgba(239,68,68,0.18);
    color: #dc2626;
    padding: 1px 3px;
    border-radius: 3px;
    font-weight: 700;
    border-bottom: 2px solid rgba(239,68,68,0.5);
}
.tse-word-case {
    background: rgba(59,130,246,0.12);
    color: #2563eb;
    padding: 1px 3px;
    border-radius: 3px;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 2px;
}
.tse-word-added {
    background: rgba(34,197,94,0.15);
    color: #16a34a;
    padding: 1px 3px;
    border-radius: 3px;
    font-weight: 700;
}
.tse-word-removed {
    background: rgba(239,68,68,0.12);
    color: #dc2626;
    padding: 1px 3px;
    border-radius: 3px;
    text-decoration: line-through;
    opacity: 0.7;
}

/* Filters */
.tse-norm-filters {
    display: flex;
    gap: 6px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
}
.tse-filters-left {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}
.tse-filters-right {
    display: flex;
    gap: 5px;
    align-items: center;
    flex-wrap: wrap;
}
.tse-quick-label {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 600;
    margin-right: 2px;
}
.tse-quick-btn {
    padding: 4px 10px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.tse-quick-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(99,102,241,0.05);
}
.tse-filter-btn {
    padding: 5px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}
.tse-filter-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.tse-filter-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* Checkbox personalizado */
.tse-checkbox-wrap {
    display: flex;
    justify-content: center;
}
.tse-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* Arrow icon between names */
.tse-norm-table th.tse-norm-arrow-head,
.tse-norm-table td.tse-norm-arrow-cell {
    text-align: center;
    color: var(--text-secondary);
    width: 30px;
    padding: 0 4px;
}

/* Scrollbar for results */
.tse-results-container::-webkit-scrollbar { width: 6px; }
.tse-results-container::-webkit-scrollbar-track { background: transparent; }
.tse-results-container::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
.tse-results-container::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* Responsive */
@media (max-width: 768px) {
    .tse-modal-content { width: 100% !important; max-width: 100% !important; border-radius: 0 !important; max-height: 100vh; }
    .tse-controls-row { flex-direction: column; align-items: stretch; }
    .tse-actions-group { flex-direction: column; }
    .tse-stats-row { grid-template-columns: repeat(2, 1fr); }
    .tse-tab span { display: none; }
    .tse-tab { padding: 12px 16px; }
    .tse-panel-inner { padding: 16px; }
    .tse-select { min-width: auto; width: 100%; }
    .tse-norm-filters { flex-direction: column; gap: 8px; }
    .tse-filters-left, .tse-filters-right { flex-wrap: wrap; }
    .tse-quick-label { display: none; }
}

/* ============================================
   Sincronización de Teléfonos
   ============================================ */
.phone-sync-modal-content {
    max-width: 1100px !important;
    width: 95% !important;
    border-radius: 14px !important;
    overflow: hidden;
}
.sync-hub-modal-content {
    width: 98vw !important;
    max-width: 1420px !important;
    height: 94vh;
    max-height: 94vh;
    display: flex;
    flex-direction: column;
}
.sync-hub-tabs {
    display: flex;
    gap: 6px;
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}
.sync-hub-tab {
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-radius: 10px;
    padding: 9px 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.sync-hub-tab:hover {
    color: var(--text-primary);
    border-color: rgba(14, 165, 233, 0.4);
}
.sync-hub-tab.active {
    background: rgba(14, 165, 233, 0.15);
    color: #0369a1;
    border-color: rgba(14, 165, 233, 0.45);
}
.sync-hub-body {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}
.sync-hub-panel {
    display: none;
    height: 100%;
    overflow-y: auto;
}
.sync-hub-panel.active {
    display: block;
}
.sync-hub-panel .modal-body {
    max-height: none;
}
.phone-sync-modal-header {
    background: linear-gradient(135deg, #0ea5e9, #2563eb);
    padding: 18px 24px !important;
    border-bottom: none !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.phone-sync-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}
.phone-sync-header-icon {
    width: 42px;
    height: 42px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #fff;
    flex-shrink: 0;
}
.phone-sync-modal-header .modal-title {
    color: #fff !important;
    font-size: 18px;
}
.phone-sync-header-subtitle {
    color: rgba(255, 255, 255, 0.75);
    font-size: 12px;
    margin: 2px 0 0 0;
}
.phone-sync-modal-close {
    background: rgba(255, 255, 255, 0.15) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 8px !important;
    transition: background 0.2s;
}
.phone-sync-modal-close:hover {
    background: rgba(255, 255, 255, 0.3) !important;
}
.phone-sync-modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px 24px;
}
.phone-sync-info-card {
    border-left: 3px solid #0ea5e9 !important;
    background: rgba(14, 165, 233, 0.06) !important;
    border-top: 1px solid rgba(14, 165, 233, 0.2) !important;
    border-right: 1px solid rgba(14, 165, 233, 0.2) !important;
    border-bottom: 1px solid rgba(14, 165, 233, 0.2) !important;
    border-radius: 8px !important;
}
.phone-sync-info-icon {
    color: #0ea5e9 !important;
}
.phone-sync-controls {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(280px, 1.6fr);
    gap: 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 16px;
}
.phone-sync-control-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.phone-sync-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
}
.phone-sync-selected-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-left: auto;
}
.phone-sync-summary {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 16px;
    line-height: 1.6;
}
.phone-sync-table td {
    font-size: 12px;
    vertical-align: middle;
}
.phone-sync-student-name {
    font-weight: 600;
    color: var(--text-primary);
    display: block;
}
.phone-sync-source-name {
    color: var(--text-secondary);
    font-size: 11px;
}
.phone-sync-phone-current {
    color: var(--text-secondary);
    text-decoration: line-through;
    opacity: 0.7;
}
.phone-sync-phone-proposed {
    color: #0ea5e9;
    font-weight: 700;
}
.phone-sync-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
}
.phone-sync-badge-high {
    background: rgba(34, 197, 94, 0.12);
    color: #16a34a;
}
.phone-sync-badge-mid {
    background: rgba(14, 165, 233, 0.12);
    color: #0284c7;
}
.phone-sync-badge-low {
    background: rgba(245, 158, 11, 0.14);
    color: #d97706;
}
.phone-sync-modal-footer {
    padding: 14px 24px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
}

@media (max-width: 768px) {
    .phone-sync-modal-content { width: 100% !important; max-width: 100% !important; border-radius: 0 !important; }
    .sync-hub-modal-content { height: 100vh; max-height: 100vh; }
    .sync-hub-tabs { padding: 8px; }
    .sync-hub-tab { flex: 1; justify-content: center; padding: 10px 8px; }
    .sync-hub-tab span { font-size: 11px; }
    .phone-sync-controls { grid-template-columns: 1fr; }
    .phone-sync-actions { flex-direction: column; align-items: stretch; }
    .phone-sync-selected-count { margin-left: 0; }
}
