:root {
    --bg-quantum: #000000;
    /* Fondo espacial más profundo */
    --color-primario: #26a69a;
    /* Aqua/Teal del logo */
    --color-secundario: #f9a825;
    /* Naranja/Oro del logo */
    --color-terciario: #1e293b;
    /* Slate profundo */
    --color-luz: #4ade80;
    /* Verde brillante */

    --glass-bg: rgba(15, 23, 42, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    --accent-glow: rgba(38, 166, 154, 0.3);

    --gradiente-main: linear-gradient(135deg, #26a69a 0%, #1e40af 100%);
    --gradiente-premium: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.02) 100%);
    --sidebar-width: 320px; /* Sidebar ampliada para mayor presencia premium */

    /* Tokens de fusión */
    --glow-fusion: radial-gradient(circle, rgba(38, 166, 154, 0.4) 0%, transparent 70%);
}

/* Base Quantum */
body {
    background: var(--bg-quantum);
    color: white;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    margin: 0;
    overflow-x: hidden;
    min-height: 100vh;
}

body.quantum-ready {
    opacity: 1;
    transition: opacity 1s ease;
}

/* Animaciones de Entrada Quark */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.anim-up {
    animation: slideUp 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.anim-fade {
    animation: fadeIn 1s ease-out forwards;
}

.pantalla-login-quantum {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    position: relative;
    overflow: hidden;
    background: #000000;
}

.floating-meshes {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

.mesh {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.15;
    /* animation: floatingMesh 20s infinite alternate ease-in-out; */
    /* DESACTIVADO: Causaba parpadeo */
}

@keyframes floatingMesh {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(100px, 50px) scale(1.2);
    }
}


@keyframes animDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hidden {
    display: none !important;
}

body {
    background: var(--bg-quantum);
    color: white;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    line-height: 1.7;
    /* Mejor distribución de lectura */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: 'Outfit', sans-serif;
    letter-spacing: -0.02em;
    font-weight: 700;
    margin-bottom: 1.2rem;
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    color: #f8fafc;
}

p {
    margin-bottom: 1.6rem;
    color: rgba(226, 232, 240, 0.9);
    font-size: 1.05rem;
    letter-spacing: 0.015em;
    line-height: 1.8;
}

.mesh-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 10% 10%, rgba(38, 166, 154, 0.12) 0%, transparent 45%),
        radial-gradient(circle at 90% 90%, rgba(249, 168, 37, 0.08) 0%, transparent 45%),
        radial-gradient(circle at 50% 50%, rgba(43, 75, 116, 0.04) 0%, transparent 65%);
    z-index: -1;
    filter: blur(100px);
}

.quantum-layout {
    display: flex !important;
    min-height: 100vh;
    width: 100%;
    background: transparent;
}

.quantum-sidebar {
    width: var(--sidebar-width);
    background: rgba(2, 6, 23, 0.98);
    backdrop-filter: blur(40px);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 2.5rem 1.2rem;
    height: 100vh;
    /* [FIX SIDEBAR FIJO] Cambiado de sticky a fixed para que el menú
       permanezca siempre visible sin importar el scroll de la página */
    position: fixed;
    top: 0;
    left: 0;
    overflow-y: hidden;   /* El contenedor NO tiene scroll; el nav interno sí */
    overflow-x: hidden;
    z-index: 100;          /* Por encima del contenido principal */
}

.quantum-main {
    flex: 1;
    /* [FIX SIDEBAR FIJO] margin-left compensa el espacio del sidebar fixed
       para que el contenido no quede oculto debajo del menú */
    margin-left: var(--sidebar-width);
    padding: 3rem 5rem;
    overflow-y: auto;
    transition: padding 0.3s ease, margin-left 0.3s ease;
}

@media (max-width: 1400px) {
    .quantum-main {
        padding: 2rem 3rem;
    }
}

@media (max-width: 1024px) {
    h1 {
        font-size: 2.5rem !important;
    }

    h2 {
        font-size: 2rem !important;
    }

    h3 {
        font-size: 1.5rem !important;
    }
}

@media (max-width: 600px) {
    h1 {
        font-size: 2rem !important;
    }

    h2 {
        font-size: 1.5rem !important;
    }

    h3 {
        font-size: 1.2rem !important;
    }
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    /* [SIDEBAR COMPACTO] Padding reducido para que quepan todos los ítems sin scroll */
    padding: 0.65rem 1rem;
    border-radius: 14px;
    color: rgba(255, 255, 255, 0.65);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    background: transparent;
    text-align: left;
    width: 100%;
    font-size: 0.88rem;
    margin-bottom: 0.15rem;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: white;
    transform: translateX(6px);
}

.nav-item.active {
    background: var(--color-primario);
    color: white;
    box-shadow: 0 10px 20px rgba(38, 166, 154, 0.2);
}

/* Barras de Desplazamiento Personalizadas - Estilo Inmersivo */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-primario);
    background-clip: padding-box;
}

.quantum-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    overflow-y: auto;
    overflow-x: hidden;
    /* [SIDEBAR COMPACTO] Scrollbar sutil pero visible para que el usuario
       sepa que puede desplazarse si hay más ítems */
    scrollbar-width: thin;
    scrollbar-color: rgba(38, 166, 154, 0.4) transparent;
    padding-right: 2px;
}
.quantum-nav::-webkit-scrollbar {
    width: 4px;
}
.quantum-nav::-webkit-scrollbar-track {
    background: transparent;
}
.quantum-nav::-webkit-scrollbar-thumb {
    background: rgba(38, 166, 154, 0.4);
    border-radius: 4px;
}
.quantum-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(38, 166, 154, 0.7);
}

/* Indicador de Número de Lista Estudiantil - V78 */
.student-number-circle {
    min-width: 60px;
    height: 60px;
    background: white;
    color: var(--bg-quantum);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    font-weight: 900;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.4), 0 0 15px rgba(255, 255, 255, 0.2);
    margin-right: 1.5rem;
    border: 3px solid var(--color-secundario);
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: scale(1);
}

.student-number-circle:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5), 0 0 20px rgba(251, 191, 36, 0.3);
}

.header-user-badge {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.8rem 1.5rem;
    border-radius: 25px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-item:hover,
.nav-item.active {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.nav-item.active {
    background: var(--gradiente-main);
}

/* ─── Header Principal de Pantalla ───────────────────────────────────── */
.quantum-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 3rem;
    flex-wrap: nowrap;
}

/* Selector global de contexto académico - ajuste en pantallas medianas */
@media (max-width: 900px) {
    .quantum-header {
        flex-wrap: wrap;
        gap: 1rem;
    }
    #selector-contexto-global {
        order: 3;
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    #selector-contexto-global {
        padding: 0.3rem 0.7rem !important;
    }
    #sel-global-anio {
        max-width: 52px !important;
        font-size: 0.75rem !important;
    }
    #sel-global-periodo {
        max-width: 78px !important;
        font-size: 0.75rem !important;
    }
}

.q-card {
    background: var(--glass-bg);
    backdrop-filter: blur(25px);
    border: 1px solid var(--glass-border);
    border-radius: 32px;
    padding: 2.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), border-color 0.3s;
}

.q-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
}

.banner-pro {
    background: var(--gradiente-main);
    background-size: 200% 200%;
    color: white;
    padding: 3rem !important;
    border-radius: 40px !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    margin-bottom: 3rem;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
}

.banner-pro::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    pointer-events: none;
}

.glass-premium {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0) 100%);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.logo-container-master {
    /* [PROFESIONAL] Sin margen excesivo, sin fondo visible */
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0.5rem 0;
}

.logo-master-main {
    /* [PROFESIONAL] Logo compacto con blend mode para eliminar la caja negra */
    width: auto;
    max-width: 110px;
    height: auto;
    object-fit: contain;
    /* mix-blend-mode: lighten hace que el fondo negro de la imagen sea
       invisible sobre el sidebar oscuro — el logo "flota" limpiamente */
    mix-blend-mode: lighten;
    box-shadow: none !important;
    transform: none !important;
    /* Quitamos el filter:none para permitir el blend */
    filter: drop-shadow(0 0 12px rgba(38,166,154,0.25));
    transition: filter 0.3s ease, transform 0.3s ease;
}

.logo-master-main:hover {
    filter: drop-shadow(0 0 20px rgba(38,166,154,0.5));
    transform: scale(1.04);
}

.logo-container-master:hover {
    transform: none; /* El hover ahora está en .logo-master-main:hover */
}

/* ─── Separador degradado entre logo y navegación ─────────────────────── */
.inst-badge-sidebar {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    /* Línea decorativa superior — separa el logo del contenido */
    border-top: 1px solid rgba(38,166,154,0.25);
    padding-top: 1rem;
    margin-top: 0.2rem;
    margin-bottom: 0.8rem;
}

.inst-badge-sidebar .nav-icon {
    font-size: 1.1rem;
    opacity: 0.8;
    flex-shrink: 0;
}

.inst-badge-sidebar .inst-info small {
    display: block;
    font-size: 0.6rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--color-primario);
    opacity: 0.8;
    margin-bottom: 0.15rem;
}

.inst-badge-sidebar .inst-name {
    font-size: 0.8rem;
    font-weight: 700;
    color: rgba(255,255,255,0.9);
    line-height: 1.2;
    /* Línea de acento izquierda teal */
    border-left: 2px solid var(--color-primario);
    padding-left: 0.5rem;
}

/* Eliminada duplicación de nav-item */
.nav-icon {
    font-size: 1.3rem;
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.15));
}

.top-bar-login {
    position: absolute;
    top: 2rem;
    right: 2rem;
    z-index: 100;
}

.btn-super-admin {
    padding: 1rem 1.5rem;
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 800;
    color: white;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.btn-super-admin:hover {
    background: #000;
    border-color: var(--color-primario);
    box-shadow: 0 0 30px rgba(38, 166, 154, 0.3);
    transform: translateY(-2px);
}

.btn-super-admin .nav-icon {
    font-size: 1.2rem;
}

.btn-super-admin:active {
    transform: scale(0.95);
}

.sel-inst {
    border-color: var(--color-primario) !important;
    font-weight: 800;
    color: var(--color-primario) !important;
}

.nav-icon {
    font-size: 1.2rem;
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.2));
}

/* FIX: Opciones de Select visibles en fondo oscuro */
.in-pro option {
    background: #0f172a;
    color: white;
    padding: 10px;
}

.boton-brillante {
    background: var(--gradiente-main);
    color: white;
    padding: 1.2rem;
    border-radius: 20px;
    font-weight: 900;
    border: none;
    cursor: pointer;
    box-shadow: 0 10px 30px var(--accent-glow);
}

.periodos-toggle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

.p-toggle-box {
    background: rgba(255, 255, 255, 0.03);
    padding: 2rem;
    border-radius: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid transparent;
}

.p-toggle-box.active {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--color-primario);
}

/* Dashboard Interactivo V24 */
.stat-c-pro {
    position: relative;
    padding: 0 !important;
    overflow: hidden;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.stat-main {
    padding: 2rem;
    cursor: pointer;
    flex: 1;
}

.stat-c-pro:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.08);
}

.link-dash {
    display: block;
    margin-top: 1rem;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-primario);
    opacity: 0.7;
}

.btn-reset-mini {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: none;
    border-top: 1px solid rgba(239, 68, 68, 0.2);
    padding: 0.8rem;
    font-size: 0.75rem;
    font-weight: 800;
    cursor: pointer;
    transition: 0.3s;
    width: 100%;
}

.btn-reset-mini:hover {
    background: #ef4444;
    color: white;
}

.stat-main h4 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    background: var(--gradiente-main);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.q-switch {
    position: relative;
    width: 50px;
    height: 26px;
}

.q-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.q-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.1);
    transition: 0.4s;
    border-radius: 34px;
}

.q-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    transition: 0.4s;
    border-radius: 50%;
}

input:checked+.q-slider {
    background: var(--color-primario);
}

input:checked+.q-slider:before {
    transform: translateX(24px);
}

.tabla-moderna {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 10px;
    /* Distribución por filas */
}

.tabla-moderna th {
    text-align: left;
    padding: 1rem 1.5rem;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    border: none;
}

.tabla-moderna td {
    padding: 1.2rem 1.5rem;
    background: rgba(255, 255, 255, 0.02);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.9);
}

.tabla-moderna tr td:first-child {
    border-left: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px 0 0 16px;
}

.tabla-moderna tr td:last-child {
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 0 16px 16px 0;
}

.tabla-moderna tr:hover td {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.exito-msg {
    color: #10b981;
    margin-top: 1rem;
    font-weight: 800;
    text-align: center;
}

.btn-quantum-s {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 0.6rem 1rem;
    border-radius: 12px;
    cursor: pointer;
}

.btn-quantum-s:hover {
    background: #fee2e2;
    color: #ef4444;
    border-color: #ef4444;
}

/* .anim-up movido arriba */

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Grid Registro Horizontal */
.grid-registro-horizontal {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.modal-footer-dual {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.modal-footer-dual button {
    flex: 1;
    margin-top: 0 !important;
}

/* --- Componentes de Listas Modernas (V81) --- */
.tabla-moderna-v2 {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.tabla-moderna-v2 th {
    text-align: left;
    padding: 1rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.4);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.tabla-moderna-v2 td {
    padding: 1.2rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    vertical-align: middle;
}

.tabla-moderna-v2 tr:last-child td {
    border-bottom: none;
}

.tabla-moderna-v2 tr:hover td {
    background: rgba(255, 255, 255, 0.01);
}

.grade-icon-mini {
    width: 35px;
    height: 35px;
    background: var(--gradiente-main);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 1rem;
    color: white;
    box-shadow: 0 5px 15px rgba(38, 166, 154, 0.2);
}

.pill-filter {
    padding: 0.5rem 1rem;
    border-radius: 50px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.pill-filter:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: translateY(-2px);
}

.pill-filter.active {
    background: var(--color-primario);
    color: white;
    border-color: var(--color-primario);
    box-shadow: 0 5px 15px rgba(38, 166, 154, 0.3);
}

.badg-v-ia {
    padding: 0.25rem 0.7rem;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 800;
}

.input-moderno {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 0.8rem 1.2rem;
    color: white;
    font-family: inherit;
    transition: 0.3s;
}

.input-moderno:focus {
    border-color: var(--color-primario);
    background: rgba(0, 0, 0, 0.5);
    outline: none;
    box-shadow: 0 0 15px rgba(38, 166, 154, 0.2);
}

/* --- DISEÑO RESPONSIVO (MOBILE FIRST & TRAPPING) --- */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 100%;
    }

    .quantum-sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        z-index: 10000;
        width: 300px;
        transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 20px 0 50px rgba(0, 0, 0, 0.5);
    }

    .quantum-sidebar.open {
        left: 0;
    }

    .quantum-main {
        padding: 1.5rem 1rem !important;
        margin-left: 0 !important;
        width: 100% !important;
    }

    #q-sidebar-toggle,
    #q-sidebar-close {
        display: block !important;
    }

    .quantum-header {
        flex-wrap: wrap;
        gap: 1rem;
        align-items: center;
    }

    .header-user-badge {
        width: 100%;
        justify-content: space-between;
    }
}

@media (max-width: 600px) {
    .q-card {
        padding: 1.5rem;
        border-radius: 20px;
    }

    .stat-main h4 {
        font-size: 2rem;
    }

    .tabla-moderna-v2 th,
    .tabla-moderna-v2 td {
        padding: 0.8rem 0.5rem;
        font-size: 0.8rem;
    }

    /* Tablas responsivas */
    .tabla-moderna-v2,
    .tabla-moderna {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    /* Grid layouts */
    .stats-grid,
    .grid-retos-v7,
    .periodos-toggle-grid {
        grid-template-columns: 1fr !important;
    }

    .banner-anuncio-ie {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .banner-anuncio-ie marquee {
        width: 100%;
    }
}

/* --- BIBLIOTECAS PREMIUM (V8.30) --- */
.card-premium-ie {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.01) 100%),
        url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 240px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.card-premium-ie::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle at top right, rgba(38, 166, 154, 0.15) 0%, transparent 70%);
    pointer-events: none;
}

.card-premium-ie:hover {
    transform: translateY(-8px) scale(1.02);
    border-color: var(--color-primario);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), 0 0 20px rgba(38, 166, 154, 0.2);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.02) 100%);
}

.card-premium-ie::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(38, 166, 154, 0.05) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.icon-bubble-ie {
    width: 50px;
    height: 50px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1rem;
    position: relative;
    z-index: 1;
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);
}

.btn-accion-card {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: white;
    font-size: 1rem;
}

.btn-accion-card:hover {
    transform: scale(1.15);
    filter: brightness(1.2);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.tag-premium {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 6px;
    letter-spacing: 0.5px;
}

/* Banner de Bienvenida Estudiante (Premium) */
.est-welcome-banner {
    background: var(--gradiente-main);
    color: white;
    border: none !important;
    box-shadow: 0 20px 50px -15px rgba(38, 166, 154, 0.5) !important;
}

/* Banner de Anuncios */
.banner-anuncio-ie {
    background: rgba(38, 166, 154, 0.1);
    border: 1px solid var(--color-primario);
    color: white;
    padding: 1.2rem;
    margin-top: 2rem;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
    animation: slideUp 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

/* Banner de Bienvenida Estudiante (Premium - Restaurado) */
.est-welcome-banner {
    background: var(--gradiente-main);
    color: white;
    border: none !important;
    box-shadow: 0 20px 50px -15px rgba(38, 166, 154, 0.5) !important;
}

/* --- OPTIMIZACIÓN MÓVIL Y TABLET (V230) --- */
@media (max-width: 1024px) {
    .quantum-layout {
        flex-direction: column !important;
    }

    /* Transformar Sidebar Vertical a Navbar Horizontal */
    .quantum-sidebar {
        width: 100% !important;
        height: auto !important;
        position: relative !important;
        border-right: none !important;
        border-bottom: 1px solid var(--glass-border);
        padding: 1rem !important;
        flex-direction: row !important;
        /* Items en fila */
        align-items: center;
        gap: 1rem;
        z-index: 50;
    }

    .logo-container-master {
        margin-bottom: 0 !important;
        width: 50px;
        height: 50px;
        padding: 5px;
        flex-shrink: 0;
        border-radius: 12px;
    }

    .logo-master-main {
        width: 100%;
        height: 100%;
    }

    .quantum-nav {
        flex-direction: row !important;
        overflow-x: auto;
        padding-bottom: 5px;
        width: 100%;
        gap: 0.5rem;
        align-items: center;
    }

    .nav-item {
        white-space: nowrap;
        padding: 0.6rem 1rem !important;
        margin-bottom: 0 !important;
        width: auto !important;
        flex-shrink: 0;
        font-size: 0.85rem !important;
        border-radius: 12px;
    }

    .quantum-main {
        padding: 1.5rem !important;
        width: 100% !important;
    }

    /* Ajustes específicos para elementos que podrían romper layout */
    .btn-super-admin {
        position: static !important;
        margin-left: auto;
    }

    .student-number-circle {
        display: none;
        /* Ocultar en móvil para ganar espacio */
    }
}

@media (max-width: 480px) {
    .quantum-main {
        padding: 1rem !important;
    }

    h1 {
        font-size: 1.8rem !important;
    }

    h2 {
        font-size: 1.4rem !important;
    }

    h3 {
        font-size: 1.2rem !important;
    }

    .q-card {
        padding: 1.2rem !important;
        border-radius: 20px !important;
    }

    .banner-pro {
        padding: 1.5rem !important;
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }

    .banner-pro::after {
        display: none;
    }

    .tabla-moderna,
    .tabla-moderna-v2 {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    /* Ajuste de Modales en Quantum */
    .modal-v7 {
        padding: 0 !important;
    }

    .modal-c-clase,
    .q-card.anim-up {
        width: 100% !important;
        border-radius: 0 !important;
        margin: 0 !important;
        box-shadow: none !important;
    }

    .input-moderno {
        width: 100% !important;
    }

    .grid-registro-horizontal {
        grid-template-columns: 1fr;
    }
}

/* Autocomplete suggestions dropdown styles */
.campo-pro {
    position: relative;
}

.suggestions-container {
    position: absolute;
    top: 105%;
    left: 0;
    width: 100%;
    max-height: 220px;
    overflow-y: auto;
    background: rgba(15, 23, 42, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(38, 166, 154, 0.3);
    border-radius: 16px;
    z-index: 1000;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.7), 0 0 15px rgba(38, 166, 154, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.suggestions-container.hidden {
    display: none;
    opacity: 0;
    transform: translateY(-5px);
    pointer-events: none;
}

.suggestion-item {
    padding: 0.9rem 1.4rem;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background: rgba(38, 166, 154, 0.15);
    color: white;
    padding-left: 1.7rem;
}

.suggestion-item.no-matches {
    color: rgba(255, 255, 255, 0.4);
    font-style: italic;
    cursor: default;
    justify-content: center;
}

.suggestion-item .item-badge {
    font-size: 0.75rem;
    background: rgba(38, 166, 154, 0.15);
    color: var(--color-primario);
    padding: 0.25rem 0.6rem;
    border-radius: 8px;
    font-weight: 700;
    border: 1px solid rgba(38, 166, 154, 0.2);
}