/* Puntos de corte. Los @media nuevos o que se modifiquen usan solo estos:
   - max-width: 640px  celular
   - max-width: 900px  tableta vertical y menú compacto
   - max-width: 1100px tableta horizontal y portátil pequeño
   - max-height: 540px celular acostado
   Los anchos antiguos (480, 520, 600, 720, 760, 768, 960) se migran cuando se toque su regla. */
html {
    --font: "Segoe UI", system-ui, sans-serif;
    --radius: 10px;
}

html[data-theme="dark"] {
    --bg: #0f1419;
    --surface: #1a2332;
    --surface2: #243044;
    --border: #2d3f56;
    --text: #e8eef4;
    --muted: #8ba3bc;
    --accent: #5b9cf8;
    --accent-hover: #82b4fa;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    --editor-bg: #243044;
    /* Fondos con texto blanco y borde de campos: contraste mínimo WCAG AA (4,5:1 y 3:1). */
    --accent-strong: #2563eb;
    --accent-strong-hover: #1d4ed8;
    --danger-strong: #dc2626;
    --input-border: #6b84a3;
}

html[data-theme="light"] {
    --bg: #eef2f7;
    --surface: #ffffff;
    --surface2: #f8fafc;
    --border: #cbd5e1;
    --text: #0f172a;
    --muted: #5b6b80;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --success: #15803d;
    --warning: #b45309;
    --danger: #dc2626;
    --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    --editor-bg: #ffffff;
    --accent-strong: #2563eb;
    --accent-strong-hover: #1d4ed8;
    --danger-strong: #dc2626;
    --input-border: #7b8ba0;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Contenedores (móvil primero): en pantallas pequeñas ocupan todo el ancho con poco margen. */
.container,
.container-narrow,
.container-form,
.container-form-compact {
    margin: 0 auto;
    padding: 1rem 0.75rem;
}

.container {
    max-width: 1100px;
}

.container-dashboard {
    max-width: min(98vw, 1720px);
}

/* Acceso y cambio de contraseña: pocos campos, lectura centrada. */
.container-narrow {
    max-width: 520px;
}

/* Formularios cortos (3 a 5 campos). */
.container-form-compact {
    max-width: 760px;
}

/* Formularios con muchos campos, editor o tablas. */
.container-form {
    max-width: 1040px;
}

@media (min-width: 640px) {
    .container,
    .container-narrow,
    .container-form,
    .container-form-compact {
        padding: 2rem 1.25rem;
    }
}

/* Grilla de formulario: una columna en móvil, dos desde tableta. */
.form-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0 1.25rem;
}

.form-grid > .checkbox-row {
    align-self: center;
}

@media (min-width: 720px) {
    .form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .form-grid > .form-span-2 {
        grid-column: 1 / -1;
    }
}

/* Listas de casillas (programas, salones): se reparten en columnas según el ancho. */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
    gap: 0.35rem 1.25rem;
}

.container-student-form .filter-bar {
    margin-bottom: 1rem;
}

.container-students-list {
    max-width: min(98vw, 1400px);
}

#studentsTable .col-actions {
    width: 7.5rem;
    white-space: nowrap;
}

#studentsTable .table-actions {
    vertical-align: middle;
    white-space: nowrap;
}

#studentsTable .table-actions > * {
    vertical-align: middle;
    margin-right: 0.35rem;
}

#studentsTable .table-actions > :last-child {
    margin-right: 0;
}

#studentsTable .table-actions > form {
    display: inline-flex;
    margin-top: 0;
    margin-bottom: 0;
}

/* Icon buttons: mayor especificidad que .btn (inline-block) para centrar SVG */
.btn.btn-icon,
button.btn.btn-icon,
a.btn.btn-icon {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 2rem !important;
    width: 2rem;
    height: 2rem !important;
    padding: 0 !important;
    line-height: 0 !important;
    text-align: center;
    vertical-align: middle;
}

.btn.btn-icon .icon,
.btn.btn-icon svg {
    display: block;
    width: 1.05rem;
    height: 1.05rem;
    flex-shrink: 0;
}

.btn.btn-icon-labeled,
a.btn.btn-icon-labeled,
button.btn.btn-icon-labeled {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: auto !important;
    min-width: auto !important;
    height: 2.5rem !important;
    padding: 0 1rem 0 0.85rem !important;
    gap: 0.5rem;
    line-height: 1 !important;
    text-align: center;
    vertical-align: middle;
}

.btn.btn-icon-labeled .icon,
.btn.btn-icon-labeled svg {
    display: block;
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

.btn.btn-icon-labeled .btn-icon-label {
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.2;
}

#studentsTable .table-actions form {
    display: inline-flex;
    margin: 0;
}

.list-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.page-size-form {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
}

.page-size-form label {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
    white-space: nowrap;
}

.page-size-form select {
    width: auto;
    min-width: 4.5rem;
    padding: 0.35rem 0.6rem;
}

.list-footer .pagination {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
    flex: 1;
    justify-content: center;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.pagination-info {
    color: var(--muted);
    font-size: 0.9rem;
}

.pagination-summary {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
    flex: 1;
    text-align: right;
}

.list-search {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.list-search input[type="search"] {
    flex: 1;
    min-width: 12rem;
    max-width: 28rem;
    margin: 0;
}

.list-search-clear {
    color: var(--accent);
    font-size: 0.9rem;
}

.pagination .btn.disabled,
.pagination .btn[aria-disabled='true'] {
    pointer-events: none;
    opacity: 0.45;
}

@media (max-width: 720px) {
    .list-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .pagination-summary {
        text-align: center;
    }
}

.import-card {
    padding-bottom: 2rem;
}

.import-subtitle {
    line-height: 1.55;
}

.import-subtitle code {
    font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
    font-size: 0.85em;
    padding: 0.12em 0.4em;
    border-radius: 4px;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--accent);
    word-break: break-word;
}

.import-example {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.import-example-title {
    margin: 0 0 0.75rem;
    font-size: 0.9rem;
    color: var(--muted);
}

.import-example-table-wrap {
    overflow-x: auto;
    margin: 0 -0.15rem;
}

.import-example-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 0.78rem;
    margin: 0;
}

.import-example-table th,
.import-example-table td {
    padding: 0.5rem 0.45rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: top;
}

.import-example-table thead th {
    font-size: 0.72rem;
    letter-spacing: 0.02em;
    white-space: normal;
    word-break: break-all;
}

.import-example-table tbody tr:last-child td {
    border-bottom: none;
}

.import-form .form-group {
    margin-bottom: 1.25rem;
}

input[type="file"].file-input,
.file-attachment-block input[type="file"] {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface2);
    color: var(--muted);
    font-size: 0.875rem;
    font-family: var(--font);
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}

html[data-theme="dark"] input[type="file"].file-input,
html[data-theme="dark"] .file-attachment-block input[type="file"] {
    color-scheme: dark;
}

input[type="file"].file-input::file-selector-button,
.file-attachment-block input[type="file"]::file-selector-button {
    margin-right: 0.85rem;
    padding: 0.45rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

input[type="file"].file-input::file-selector-button:hover,
.file-attachment-block input[type="file"]::file-selector-button:hover {
    background: var(--border);
    border-color: var(--accent);
    color: var(--text);
}

input[type="file"].file-input::-webkit-file-upload-button,
.file-attachment-block input[type="file"]::-webkit-file-upload-button {
    margin-right: 0.85rem;
    padding: 0.45rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
}

input[type="file"].file-input:focus,
.file-attachment-block input[type="file"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.question-file-block {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.import-form-actions {
    margin-top: 0.25rem;
    padding-top: 0.25rem;
}

.container-exam {
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1.25rem;
    display: flex;
    justify-content: center;
}

.container-exam .card-exam {
    width: fit-content;
    max-width: min(92vw, 56rem);
    min-width: min(92vw, 22rem);
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.25rem;
}

@media (min-width: 640px) {
    .card {
        padding: 1.75rem;
        margin-bottom: 1.5rem;
    }
}

.card:last-child,
.stats-grid > .card,
.stats-grid-compact > .card,
.comm-grid > .card,
.dashboard-grid > .card,
.monitor-grid > .card,
.attendance-top > .card {
    margin-bottom: 0;
}

.card-exam > .card,
.card-exam > section.card {
    background: var(--surface2);
    box-shadow: none;
    margin-bottom: 1.25rem;
}

.card-exam > .card:last-child,
.card-exam > section.card:last-child {
    margin-bottom: 0;
}

.card h1, .card h2 {
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
}

.card h3 {
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
    font-size: 1.15rem;
}

.card h1:first-child,
.card h2:first-child,
.card h3:first-child {
    margin-top: 0;
}

.card > p:not(.subtitle):not(.form-hint) {
    margin-bottom: 0.85rem;
}

.card > p:last-child {
    margin-bottom: 0;
}

.subtitle {
    color: var(--muted);
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

.form-group {
    margin-bottom: 1.1rem;
}

label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.9rem;
    color: var(--muted);
}

input:not([type]),
input[type="text"],
input[type="password"],
input[type="email"],
input[type="search"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="date"],
input[type="datetime-local"],
input[type="time"],
input[type="month"],
input[type="week"],
textarea,
select {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    background: var(--surface2);
    color: var(--text);
    font-size: 1rem;
    font-family: var(--font);
    line-height: 1.4;
}

input::placeholder,
textarea::placeholder {
    color: var(--muted);
    opacity: 0.8;
}

/* Calendario, reloj y flechas nativas acordes al tema */
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
    color-scheme: dark;
}

html[data-theme="light"] input,
html[data-theme="light"] select,
html[data-theme="light"] textarea {
    color-scheme: light;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator,
input[type="week"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.75;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover,
input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover,
input[type="time"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

input[type="search"]::-webkit-search-cancel-button {
    cursor: pointer;
}

input:disabled,
textarea:disabled,
select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

textarea {
    min-height: 140px;
    resize: vertical;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.btn {
    display: inline-block;
    padding: 0.65rem 1.25rem;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
}

.btn-primary {
    background: var(--accent-strong);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-strong-hover);
}

.btn-secondary {
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-danger {
    background: var(--danger-strong);
    color: #fff;
}

.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-error,
.alert-danger {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--danger);
    color: #fca5a5;
}

html[data-theme="light"] .alert-error,
html[data-theme="light"] .alert-danger {
    color: #991b1b;
    background: rgba(220, 38, 38, 0.12);
}

.alert-success {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid var(--success);
    color: #86efac;
}

html[data-theme="light"] .alert-success {
    color: #166534;
    background: rgba(22, 163, 74, 0.12);
}

.alert-info {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid var(--accent);
    color: #93c5fd;
}

html[data-theme="light"] .alert-info {
    color: #1e40af;
    background: rgba(37, 99, 235, 0.12);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid var(--warning);
    color: #fcd34d;
}

html[data-theme="light"] .alert-warning {
    color: #92400e;
    background: rgba(245, 158, 11, 0.12);
}

.btn-block {
    display: block;
    width: 100%;
}

/* Visible solo al llegar con el teclado: primer elemento enfocable de cada página. */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
}

.skip-link:focus {
    position: fixed;
    left: 0.75rem;
    top: 0.75rem;
    z-index: 2000;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    background: var(--accent-strong);
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    box-shadow: var(--shadow);
}

main:focus {
    outline: none;
}

p a:not([class]),
.form-hint a:not([class]),
.alert a:not([class]) {
    text-decoration: underline;
}

a:focus-visible,
button:focus-visible,
summary:focus-visible,
.btn:focus-visible,
[tabindex]:not([tabindex="-1"]):focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.password-field {
    position: relative;
}

.password-field input {
    padding-right: 6.5rem;
}

.password-toggle {
    position: absolute;
    right: 0.35rem;
    top: 50%;
    transform: translateY(-50%);
    padding: 0.35rem 0.6rem;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
}

.password-toggle:hover {
    background: var(--surface);
}

/* Ventana de confirmación propia (ui-dialog.js). */
.ui-dialog {
    width: min(92vw, 28rem);
    margin: auto;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
}

.ui-dialog::backdrop {
    background: rgba(0, 0, 0, 0.55);
}

.ui-dialog-body {
    padding: 1.25rem 1.25rem 1rem;
}

.ui-dialog-title {
    margin: 0 0 0.5rem;
    font-size: 1.15rem;
}

.ui-dialog-text {
    margin: 0 0 1.25rem;
    line-height: 1.5;
    white-space: pre-line;
}

.ui-dialog-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* Avisos flotantes (QavenoUi.toast). */
.toast-region {
    position: fixed;
    top: 4.25rem;
    right: 1rem;
    z-index: 1500;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: min(92vw, 24rem);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
    font-size: 0.9rem;
    pointer-events: auto;
}

.toast span {
    flex: 1;
}

.toast-success {
    border-left-color: var(--success);
}

.toast-error {
    border-left-color: var(--danger);
}

.toast-warning {
    border-left-color: var(--warning);
}

.toast-close {
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ---------- Barra del panel: menús con submenús ---------- */
.nav-admin {
    position: relative;
    z-index: 50;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.55rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1.75rem;
}

.nav-admin-top {
    display: contents;
}

.nav-admin-toggle {
    display: none;
}

.nav-admin .brand {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
}

.nav-admin-panel {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 1rem;
    min-width: 0;
}

.nav-menus {
    display: flex;
    align-items: center;
    gap: 0.15rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-menus > li {
    position: relative;
}

.nav-menu-link,
.nav-menu > summary {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.75rem;
    border-radius: 8px;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

.nav-menu > summary {
    list-style: none;
}

.nav-menu > summary::-webkit-details-marker {
    display: none;
}

.nav-menu > summary::after {
    content: "";
    width: 0.4rem;
    height: 0.4rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
    transition: transform 0.15s ease;
}

.nav-menu[open] > summary::after {
    transform: translateY(1px) rotate(225deg);
}

.nav-menu-link:hover,
.nav-menu > summary:hover,
.nav-menu[open] > summary {
    color: var(--text);
    background: var(--surface2);
}

.nav-menu-link.is-current,
.nav-menu.is-current > summary {
    color: var(--text);
    box-shadow: inset 0 -2px 0 var(--accent);
}

.nav-menu {
    position: relative;
}

.nav-submenu {
    position: absolute;
    top: calc(100% + 0.35rem);
    left: 0;
    min-width: 13rem;
    display: flex;
    flex-direction: column;
    padding: 0.35rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
}

.nav-submenu-right {
    left: auto;
    right: 0;
}

.nav-submenu a,
.nav-submenu-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.7rem;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 500;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.nav-submenu a:hover,
.nav-submenu-item:hover {
    background: var(--surface2);
}

.nav-submenu a.is-current {
    color: var(--accent);
    font-weight: 600;
}

.nav-submenu form {
    margin: 0;
}

.nav-submenu-danger {
    color: var(--danger);
}

.nav-submenu-sep {
    margin: 0.3rem 0.4rem;
    border: none;
    border-top: 1px solid var(--border);
}

.nav-submenu-header {
    display: block;
    padding: 0.45rem 0.75rem 0.55rem;
    margin-bottom: 0.2rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 18rem;
}

.nav-student .nav-submenu {
    max-height: min(70vh, 28rem);
    overflow-y: auto;
}

.nav-submenu-grouped {
    min-width: 15rem;
    max-height: calc(100vh - 4.5rem);
    overflow-y: auto;
}

.nav-submenu-group {
    display: block;
    padding: 0.6rem 0.7rem 0.25rem;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.nav-submenu-group:not(:first-child) {
    margin-top: 0.3rem;
    border-top: 1px solid var(--border);
}

/* Mientras presenta una actividad: sin enlaces que lo saquen de ella (queda Cerrar sesión, que la pone en espera). */
body.exam-in-progress [data-exam-hide] {
    display: none !important;
}

body.exam-in-progress [data-exam-show][hidden] {
    display: inline !important;
}

.nav-student .brand-locked {
    cursor: default;
}

.nav-submenu .streamer-mode-toggle.streamer-mode-active {
    background: rgba(155, 89, 182, 0.2);
}

.nav-menu-account:has(.streamer-mode-active) > summary::before {
    content: "";
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: #9b59b6;
}

.nav-admin-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-left: auto;
}

@media (max-width: 1100px) {
    .nav-admin {
        gap: 1rem;
    }

    .nav-admin-panel,
    .nav-menus {
        flex-wrap: wrap;
    }

    .nav-admin-panel {
        row-gap: 0.35rem;
    }

    .nav-menu-link,
    .nav-menu > summary {
        padding: 0.45rem 0.55rem;
    }
}

@media (max-width: 900px) {
    .nav-admin {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 0.75rem 1rem;
    }

    .nav-admin-top {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        width: 100%;
    }

    .nav-admin-toggle {
        display: inline-flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 5px;
        width: 2.5rem;
        height: 2.5rem;
        padding: 0;
        border: 1px solid var(--border);
        border-radius: 0.4rem;
        background: transparent;
        color: var(--text);
        cursor: pointer;
        flex-shrink: 0;
    }

    .nav-admin-toggle-bar {
        display: block;
        width: 1.15rem;
        height: 2px;
        background: currentColor;
        border-radius: 1px;
        transition: transform 0.2s ease, opacity 0.2s ease;
    }

    .nav-admin.is-open .nav-admin-toggle-bar:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }

    .nav-admin.is-open .nav-admin-toggle-bar:nth-child(2) {
        opacity: 0;
    }

    .nav-admin.is-open .nav-admin-toggle-bar:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }

    .nav-admin-panel {
        display: none;
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        width: 100%;
    }

    .nav-admin.is-open .nav-admin-panel {
        display: flex;
        margin-top: 0.65rem;
        padding-top: 0.65rem;
        border-top: 1px solid var(--border);
    }

    .nav-menus {
        flex-direction: column;
        align-items: stretch;
        gap: 0.1rem;
    }

    .nav-menu-link,
    .nav-menu > summary {
        display: flex;
        justify-content: space-between;
        width: 100%;
        padding: 0.65rem 0.5rem;
    }

    .nav-submenu {
        position: static;
        min-width: 0;
        margin: 0.1rem 0 0.4rem 0.75rem;
        border: none;
        border-left: 2px solid var(--border);
        border-radius: 0;
        box-shadow: none;
        background: transparent;
    }

    .nav-admin-actions {
        flex-direction: column;
        align-items: stretch;
        margin-left: 0;
    }
}

.nav-term-scope {
    margin: 0;
}

.nav-term-scope select {
    width: auto;
    max-width: 14rem;
    margin: 0;
    padding: 0.45rem 2rem 0.45rem 0.85rem;
    border-radius: 8px;
    background-color: var(--surface2);
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
}

.nav-term-current {
    display: inline-flex;
    align-items: baseline;
    gap: 0.35rem;
    padding: 0.45rem 0.85rem;
    border-radius: 8px;
    background: var(--surface2);
    font-size: 0.85rem;
    white-space: nowrap;
}

.nav-term-current-label {
    color: var(--muted);
}

@media (max-width: 900px) {
    .nav-term-scope select {
        width: 100%;
        max-width: none;
    }
}

.theme-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0.65rem 1.25rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface2);
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
    transition: background 0.15s, border-color 0.15s;
}

.theme-toggle:hover {
    background: var(--border);
    border-color: var(--accent);
}

.theme-toggle [data-theme-icon] {
    font-size: 1rem;
    line-height: 1;
}

[data-theme-icon] .icon,
.nav-bell-icon .icon {
    width: 1.05rem;
    height: 1.05rem;
    vertical-align: middle;
}

[data-theme-icon] .icon-moon,
html[data-theme="light"] [data-theme-icon] .icon-sun {
    display: none;
}

html[data-theme="light"] [data-theme-icon] .icon-moon {
    display: inline;
}

.streamer-mode-toggle.streamer-mode-active {
    background: rgba(155, 89, 182, 0.2);
    border-color: #9b59b6;
    color: #d7bde2;
}

.streamer-mode-toggle [data-streamer-icon] {
    font-size: 0.95rem;
    line-height: 1;
}

.exam-select-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.85rem;
}

.exam-select-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.1rem;
    flex-wrap: wrap;
}

.exam-select-item h2 {
    margin: 0;
    font-size: 1.05rem;
}

.exam-select-info {
    flex: 1;
    min-width: 12rem;
}

.exam-panel[hidden] {
    display: none !important;
}

.proctor-overlay {
    max-width: 560px;
    margin: 2rem auto 1rem;
    text-align: center;
}

.proctor-overlay-error {
    border-color: var(--danger, #c0392b);
}

.container-monitor {
    max-width: 1600px;
}

.monitor-filter-bar {
    margin-bottom: 1rem;
    padding: 1rem;
}

.monitor-empty-state[hidden] {
    display: none !important;
}

.monitor-detail-panel {
    margin-bottom: 1rem;
    padding: 1rem 1.15rem;
    border: 1px solid var(--accent);
}

.monitor-detail-layout {
    display: grid;
    grid-template-columns: minmax(0, 2.2fr) minmax(220px, 1fr);
    gap: 1rem;
    align-items: start;
}

.monitor-detail-video-wrap {
    position: relative;
    background: #000;
    border-radius: var(--radius, 8px);
    overflow: hidden;
    min-height: 360px;
}

.monitor-detail-video {
    width: 100%;
    display: block;
    background: #000;
    aspect-ratio: 16 / 9;
    max-height: min(70vh, 720px);
    object-fit: contain;
}

.monitor-detail-status {
    font-size: 0.85rem;
}

.monitor-detail-play-fallback {
    z-index: 2;
}

.monitor-detail-info {
    min-width: 0;
}

.monitor-observe-only .monitor-invalidate-form,
.monitor-observe-only .monitor-detail-invalidate-form,
.monitor-observe-only .monitor-invalidate-hint {
    display: none !important;
}

.monitor-detail-invalidate-form {
    margin-top: 1rem;
}

.monitor-detail-invalidate-btn {
    width: 100%;
    justify-content: center;
}

.monitor-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.monitor-detail-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem 1.25rem;
    margin-bottom: 0.75rem;
}

.monitor-detail-meta dt {
    margin-top: 0;
}

.monitor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.monitor-grid-item {
    padding: 0;
    overflow: hidden;
}

.monitor-grid-item-active {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.monitor-grid-video-wrap {
    position: relative;
    background: #000;
    aspect-ratio: 16 / 9;
}

.monitor-grid-video {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    background: #000;
}

.monitor-grid-status {
    font-size: 0.72rem;
    left: 0.5rem;
    bottom: 0.5rem;
    max-width: calc(100% - 1rem);
}

.monitor-grid-play-fallback {
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
}

.monitor-grid-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.65rem 0.75rem;
}

.monitor-grid-name {
    font-weight: 600;
    font-size: 0.92rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.monitor-grid-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.monitor-invalidate-form {
    margin: 0;
    display: inline-flex;
}

.monitor-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 1rem;
    padding: 1rem;
}

.monitor-video-wrap {
    position: relative;
    background: #000;
    border-radius: var(--radius, 8px);
    overflow: hidden;
    min-height: 360px;
}

.monitor-video {
    width: 100%;
    display: block;
    background: #000;
    aspect-ratio: 16 / 9;
    object-fit: contain;
}

.monitor-status {
    position: absolute;
    left: 0.75rem;
    bottom: 0.75rem;
    margin: 0;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 0.8rem;
    max-width: calc(100% - 1.5rem);
}

.monitor-play-fallback[hidden] {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.monitor-play-fallback {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
}

.monitor-meta {
    margin: 0 0 1rem;
}

.monitor-meta dt {
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 0.65rem;
}

.monitor-meta dd {
    margin: 0.15rem 0 0;
}

@media (max-width: 900px) {
    .monitor-detail-layout {
        grid-template-columns: 1fr;
    }

    .monitor-layout {
        grid-template-columns: 1fr;
    }
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stats-grid-compact {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    align-items: stretch;
}

.stats-grid-compact .stat-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 0.75rem 1rem;
    gap: 0.15rem;
    min-height: 5.5rem;
}

.stats-grid-compact .stat-card .label {
    margin-top: 0;
}

.stats-grid-compact .stat-hint {
    margin: 0;
}

.stat-ratio {
    display: flex;
    align-items: baseline;
    gap: 0.15rem;
}

.stat-ratio-sep {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--muted);
}

.stat-ratio-total {
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--muted);
}

.stat-card-assignments {
    grid-column: span 1;
}

.stats-grid-compact .stat-card.stat-card-assignments,
.stats-grid-compact .stat-card.stat-card-split {
    gap: 0;
    padding: 0.6rem 0.85rem;
    min-height: auto;
}

.stat-assignment-row-primary {
    gap: 0.15rem;
}

.stat-assignment-row-primary .label {
    margin-top: 0;
}

.stat-assignment-row-primary .stat-hint {
    margin: 0.15rem 0 0;
    max-width: none;
}

.stat-assignment-row {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.3rem 0;
}

.stat-assignment-row-today {
    border-top: 1px solid var(--border);
    margin-top: 0.2rem;
    padding-top: 0.45rem;
}

.stat-assignment-row-label {
    margin: 0 0 0.2rem;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-assignment-metrics {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.75rem 1.25rem;
    width: 100%;
}

.stat-assignment-metric {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    min-width: 4.75rem;
}

.stat-assignment-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.1;
}

.stat-assignment-metric-live .stat-assignment-value {
    color: var(--warning);
}

.stat-assignment-label {
    font-size: 0.75rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.stat-hint {
    margin: 0.35rem 0 0;
    font-size: 0.72rem;
    color: var(--muted);
    line-height: 1.3;
    max-width: 14rem;
}

.stat-card {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem;
}

.stat-card .value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-card .label {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.25rem;
}

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

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    color: var(--muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: rgba(34, 197, 94, 0.2);
    color: #86efac;
}

.badge-danger {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.badge-warning {
    background: rgba(245, 158, 11, 0.2);
    color: #fcd34d;
}

.badge-muted {
    background: var(--surface2);
    color: var(--muted);
}

.badge-info {
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
}

html[data-theme="light"] .badge-success {
    color: #166534;
}

html[data-theme="light"] .badge-danger {
    color: #991b1b;
}

html[data-theme="light"] .badge-warning {
    color: #92400e;
}

html[data-theme="light"] .badge-info {
    color: #1e40af;
}

.stat-card-live .value {
    color: var(--warning);
}

.dashboard-section {
    margin-bottom: 1.5rem;
}

.dashboard-section-header {
    margin-bottom: 1rem;
    align-items: flex-start;
}

.assignments-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.dashboard-panels {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 1.25rem;
    align-items: stretch;
}

.dashboard-panel {
    margin: 0;
    min-height: 0;
}

.assignments-panel {
    border-color: var(--accent);
}

.activity-log-panel {
    display: flex;
    flex-direction: column;
}

.activity-log-title {
    margin: 0 0 0.25rem;
    font-size: 1rem;
}

.activity-log-hint {
    margin: 0 0 0.75rem;
    font-size: 0.8rem;
    color: var(--muted);
}

.dashboard-panel-scroll {
    flex: 1;
    min-height: 320px;
    max-height: 420px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface2);
}

.assignments-panel .dashboard-panel-scroll {
    background: transparent;
    border: none;
    border-radius: 0;
    overflow-x: hidden;
    overflow-y: auto;
}

#assignmentsTable {
    width: 100%;
    table-layout: fixed;
}

#assignmentsTable th,
#assignmentsTable td {
    padding: 0.55rem 0.5rem;
    font-size: 0.875rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

#assignmentsTable th:nth-child(1),
#assignmentsTable td:nth-child(1) {
    width: 16%;
}

#assignmentsTable th:nth-child(2),
#assignmentsTable td:nth-child(2) {
    width: 9%;
}

#assignmentsTable th:nth-child(3),
#assignmentsTable td:nth-child(3) {
    width: 11%;
}

#assignmentsTable th:nth-child(4),
#assignmentsTable td:nth-child(4) {
    width: 22%;
}

#assignmentsTable th:nth-child(5),
#assignmentsTable td:nth-child(5) {
    width: 12%;
}

#assignmentsTable th:nth-child(6),
#assignmentsTable td:nth-child(6),
#assignmentsTable th:nth-child(7),
#assignmentsTable td:nth-child(7) {
    width: 15%;
    white-space: nowrap;
}

#assignmentsTable .assignment-status-cell {
    overflow: visible;
}

.panel-empty-msg {
    color: var(--muted);
    font-size: 0.9rem;
    margin: 0;
    padding: 1rem;
}

.panel-empty-msg.hidden {
    display: none;
}

#assignmentsTable tbody tr.row-live-updated {
    animation: assignment-row-highlight 1.2s ease-out;
}

@keyframes assignment-row-highlight {
    from {
        background: rgba(59, 130, 246, 0.22);
    }
    to {
        background: transparent;
    }
}

.activity-log {
    list-style: none;
    margin: 0;
    padding: 0.35rem 0;
    font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
    font-size: 0.78rem;
    line-height: 1.45;
}

.activity-log-entry {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.35rem 0.65rem;
    border-bottom: 1px solid var(--border);
}

.activity-log-entry:last-child {
    border-bottom: none;
}

.activity-log-started .activity-log-time {
    color: var(--warning);
}

.activity-log-completed .activity-log-time {
    color: var(--success);
}

.activity-log-cancelled .activity-log-time {
    color: #ef4444;
}

.activity-log-paused .activity-log-time {
    color: var(--muted);
    font-style: italic;
}

.activity-log-time {
    flex-shrink: 0;
    min-width: 4.6rem;
    color: var(--muted);
}

.activity-log-line {
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

.activity-log-line em {
    font-style: normal;
    color: var(--accent);
}

.activity-log-meta {
    color: var(--muted);
}

@media (max-width: 1100px) {
    .dashboard-panels {
        grid-template-columns: 1fr;
    }

    .activity-log-panel .dashboard-panel-scroll {
        max-height: 240px;
        min-height: 200px;
    }
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

/* Encabezado común de página: h1, subtítulo opcional y zona .actions. */
.toolbar .subtitle {
    margin: 0.35rem 0 0;
}

.question-block {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.question-block-inactive {
    opacity: 0.6;
    border-style: dashed;
}

.question-block-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.question-block-toolbar .question-block-heading {
    margin: 0;
}

.question-block .btn-remove-question:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.exam-meta {
    background: var(--surface2);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.25rem;
}

.exam-meta h3 {
    font-size: 1.1rem;
    margin-bottom: 0.35rem;
}

.question-text {
    font-size: 1.05rem;
    margin: 1rem 0;
    padding: 1rem;
    background: var(--surface2);
    border-left: 4px solid var(--accent);
    border-radius: 0 8px 8px 0;
    width: max-content;
    max-width: min(88vw, 52rem);
    box-sizing: border-box;
}

.container-exam .card-exam .toolbar,
.container-exam .card-exam form,
.container-exam .card-exam .exam-meta,
.container-exam .card-exam .alert {
    width: 100%;
}

.footer-link {
    margin-top: 1.5rem;
    text-align: center;
    font-size: 0.85rem;
}

.file-download-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
    word-break: break-word;
}

.file-download-link:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.current-file-row {
    margin-bottom: 0.65rem;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-row input {
    width: auto;
}

.role-options {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin: 0 0 1rem;
}

.role-options[hidden] {
    display: none;
}

.role-options legend {
    font-weight: 600;
    padding: 0 0.35rem;
}

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

.actions form {
    display: inline-flex;
    margin: 0;
}

.exam-list-card {
    margin-bottom: 1rem;
}

.card-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.card-toolbar-text {
    flex: 1;
    min-width: 0;
}

.exam-list-title {
    font-size: 1.15rem;
    margin: 0 0 0.25rem;
}

.exam-list-desc {
    color: var(--muted);
    font-size: 0.9rem;
    margin: 0;
}

.card-actions {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.card-actions form {
    display: inline-flex;
    margin: 0;
}

/* Estado y botones con el mismo tamaño en listas tipo tarjeta */
.card-actions > .badge,
.card-actions > .btn,
.card-actions > form > .btn,
.card-actions > form > button,
td.actions > .badge,
td.actions > .btn,
td.actions > form > .btn,
td.actions > form > button,
#studentsTable .table-actions > .btn,
#studentsTable .table-actions > form > .btn,
#studentsTable .table-actions > form > button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 5.5rem;
    height: 2rem;
    padding: 0 0.75rem;
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1;
    border-radius: 8px;
    box-sizing: border-box;
}

#studentsTable .table-actions > .btn.btn-icon,
#studentsTable .table-actions > form > .btn.btn-icon,
#studentsTable .table-actions > form > button.btn.btn-icon,
.table-actions > .btn.btn-icon,
.table-actions > form > .btn.btn-icon,
.table-actions > form > button.btn.btn-icon,
.card-actions > .btn.btn-icon,
.card-actions > form > .btn.btn-icon,
.card-actions > form > button.btn.btn-icon,
td.actions > .btn.btn-icon {
    min-width: 2rem !important;
    width: 2rem;
    height: 2rem !important;
    padding: 0 !important;
}

/* Una celda con display:flex deja de ser celda de tabla y descuadra las líneas de la fila. */
td.actions {
    display: table-cell;
    vertical-align: middle;
    white-space: normal;
}

td.actions > *,
td.actions > form {
    vertical-align: middle;
    margin: 0.15rem 0.5rem 0.15rem 0;
}

td.actions > :last-child {
    margin-right: 0;
}

td.actions.actions-nowrap {
    white-space: nowrap;
}

td.actions > .row-menu {
    display: inline-block;
}

/* Menú «Más» de una fila: agrupa las acciones secundarias en un desplegable. */
.row-menu {
    position: relative;
}

.row-menu > summary {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    height: 2rem;
    padding: 0 0.75rem;
    font-size: 0.8125rem;
    line-height: 1;
    box-sizing: border-box;
    list-style: none;
    user-select: none;
}

.row-menu > summary::-webkit-details-marker {
    display: none;
}

.row-menu > summary::after {
    content: "";
    width: 0.4rem;
    height: 0.4rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
    transition: transform 0.15s ease;
}

.row-menu[open] > summary::after {
    transform: translateY(1px) rotate(-135deg);
}

.row-menu-list {
    position: absolute;
    right: 0;
    top: calc(100% + 0.3rem);
    z-index: 40;
    min-width: 13rem;
    padding: 0.35rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
}

.row-menu-list a,
.row-menu-list button {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--text);
    font: inherit;
    font-size: 0.875rem;
    text-align: left;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}

.row-menu-list a:hover,
.row-menu-list button:hover {
    background: var(--surface2);
}

.row-menu-list form {
    margin: 0;
}

.row-menu-list .row-menu-danger {
    color: var(--danger);
}

.card-actions > .badge,
td.actions > .badge {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    height: 2rem;
    padding: 0 0.65rem;
    line-height: 1;
    box-sizing: border-box;
    border-radius: 8px;
    border: 1px solid transparent;
}

.toolbar > .btn.btn-icon-labeled,
.toolbar .actions > .btn.btn-icon-labeled {
    flex-shrink: 0;
}

.card-actions > .badge-success,
td.actions > .badge-success {
    border-color: rgba(34, 197, 94, 0.35);
}

.card-actions > .badge-muted,
td.actions > .badge-muted {
    border-color: var(--border);
}

.exam-list-meta {
    font-size: 0.85rem;
    color: var(--muted);
    margin: 0;
}

.filter-bar {
    margin-bottom: 1.25rem;
}

.exam-filter-form select,
.students-filter-form select {
    max-width: 480px;
}

.responses-filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
}

.responses-filter-form .form-group {
    flex: 1 1 260px;
}

.exam-summary {
    margin-bottom: 1.25rem;
}

.exam-summary h2 {
    font-size: 1.15rem;
    margin: 0 0 0.5rem;
}

.exam-summary-desc {
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0 0 1.25rem;
}

.exam-summary-meta {
    color: var(--muted);
    font-size: 0.85rem;
    margin: 0;
    padding-top: 0.25rem;
}

.responses-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.response-accordion {
    padding: 0;
    overflow: hidden;
}

.response-accordion-summary {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
    list-style: none;
    cursor: pointer;
    padding: 1rem 1.15rem;
    user-select: none;
}

.response-accordion-summary::-webkit-details-marker {
    display: none;
}

.response-accordion-summary::marker {
    content: "";
}

.response-accordion-summary-main {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
    flex: 1 1 14rem;
    padding-left: 1.4rem;
    position: relative;
}

.response-accordion-summary-main::before {
    content: "";
    position: absolute;
    left: 0.15rem;
    top: 0.45rem;
    width: 0.45rem;
    height: 0.45rem;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(-45deg);
    transition: transform 0.15s ease;
}

.response-accordion[open] > .response-accordion-summary .response-accordion-summary-main::before {
    top: 0.35rem;
    transform: rotate(45deg);
}

.response-accordion-kicker {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.response-accordion-title {
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.35;
}

.response-accordion-summary-badges {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.4rem;
}

.response-accordion-body {
    padding: 0 1.15rem 1.15rem;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

.response-pair-banner {
    margin-bottom: 1rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--border);
}

.response-pair-title {
    margin: 0;
    font-size: 1.05rem;
}

.response-pair-subtitle {
    margin: 0.25rem 0 0;
    color: var(--muted);
    font-size: 0.85rem;
}

.response-pair-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 900px) {
    .response-pair-grid {
        grid-template-columns: 1fr;
    }
}

.response-member {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    background: var(--surface);
}

.response-member .response-card-header {
    margin-bottom: 1rem;
}

.response-member-missing {
    display: flex;
    align-items: center;
    min-height: 6rem;
    color: var(--muted);
}

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

.response-card-header h3 {
    font-size: 1.1rem;
    margin: 0;
}

.response-meta {
    color: var(--muted);
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

.response-card-badges {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.35rem;
}

.response-card-header-compact {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
}

.response-card-header-compact .response-card-badges {
    flex-direction: row;
    align-items: center;
    width: 100%;
    justify-content: flex-end;
}

.response-reset-form {
    margin: 0;
}

.response-assignment-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: flex-end;
}

.response-reset-spacer {
    flex: 1;
}

.response-date {
    font-size: 0.8rem;
    color: var(--muted);
}

.response-block {
    margin-bottom: 1rem;
}

.response-block:last-child {
    margin-bottom: 0;
}

.response-block label {
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.response-text-box {
    padding: 1rem 1.1rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.6;
    font-size: 0.95rem;
    max-height: 420px;
    overflow-y: auto;
}

.response-text-box.question-box {
    border-left: 4px solid var(--accent);
}

.response-text-box.answer-box {
    border-left: 4px solid var(--success);
    min-height: 4rem;
}

.response-text-box.answer-empty {
    color: var(--muted);
    font-style: italic;
    border-left-color: var(--warning);
}

.response-cancelled {
    border-color: rgba(239, 68, 68, 0.35);
    background: rgba(239, 68, 68, 0.06);
    border-left-color: var(--danger);
}

.response-cancelled-message {
    margin: 0 0 0.5rem;
    color: var(--text);
    font-weight: 600;
    font-style: normal;
}

.response-cancelled-date {
    margin: 0 0 0.85rem;
    color: var(--muted);
    font-size: 0.85rem;
}

.response-evidence {
    margin: 0;
}

.response-evidence-image {
    display: block;
    width: 100%;
    max-width: 960px;
    height: auto;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #000;
}

.response-evidence-caption {
    margin: 0.5rem 0 0;
    color: var(--muted);
    font-size: 0.85rem;
}

.response-evidence-missing {
    margin: 0.5rem 0 0;
    color: var(--muted);
    font-size: 0.85rem;
    font-style: italic;
}

/* Calificación manual (Respuestas) */
.grading-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 0.85rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border);
}

.grading-summary-info {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    font-size: 0.9rem;
}

.grading-summary-scale {
    color: var(--muted);
}

.grading-item {
    display: grid;
    grid-template-columns: 8rem 1fr;
    gap: 0.75rem;
    margin-top: 0.75rem;
    padding: 0.75rem;
    border: 1px dashed var(--border);
    border-radius: 8px;
}

.grading-item textarea,
.grading-form textarea {
    width: 100%;
    resize: vertical;
}

.grading-score-input {
    width: 100%;
    font-weight: 600;
    text-align: center;
}

.grading-form {
    padding: 0.85rem;
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    background: var(--surface2);
}

.grading-form-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.grading-total-hint {
    color: var(--muted);
    font-size: 0.85rem;
}

@media (max-width: 640px) {
    .grading-item {
        grid-template-columns: 1fr;
    }
}

.transfer-incompatible {
    border-left: 4px solid var(--danger);
}

.transfer-incompatible ul {
    margin: 0.5rem 0 0;
    padding-left: 1.25rem;
    line-height: 1.6;
}

.transfer-ok {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.5rem;
}

.transfer-select-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.75rem 0;
}

.transfer-table tr.is-disabled td {
    color: var(--muted);
}

.transfer-note {
    font-size: 0.85rem;
    color: var(--muted);
}

.grade-all-bar {
    position: sticky;
    bottom: 0.75rem;
    z-index: 20;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 1rem;
    padding: 0.7rem 1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.grade-all-bar[hidden] {
    display: none;
}

.grade-all-status {
    color: var(--muted);
    font-size: 0.9rem;
}

.grade-all-bar.has-changes {
    border-color: var(--warning);
}

.grade-all-bar.has-changes .grade-all-status {
    color: var(--warning);
    font-weight: 600;
}

.response-accordion.has-unsaved {
    border-left: 4px solid var(--warning);
}

/* Portal de calificaciones del estudiante */
.grades-table td.grade-score {
    font-weight: 700;
    font-size: 1.05rem;
    white-space: nowrap;
}

.grade-score-pass {
    color: var(--success);
}

.grade-score-fail {
    color: var(--danger);
}

.grade-detail-score {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    font-size: 1.1rem;
}

.grade-detail-score strong {
    font-size: 2rem;
}

.grade-feedback {
    border-left: 4px solid var(--accent);
}

/* Libro de calificaciones (ponderado por grupo) */
.gradebook-hint {
    color: var(--muted);
    font-size: 0.88rem;
    margin: 0 0 0.85rem;
}

.gradebook-weight-input {
    width: 100%;
    text-align: center;
    font-weight: 600;
}

.gradebook-scroll {
    overflow-x: auto;
}

.gradebook-table th,
.gradebook-table td {
    white-space: nowrap;
    vertical-align: middle;
}

.gradebook-table .gradebook-sticky {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--surface);
}

.gradebook-exam-col a {
    display: block;
    color: inherit;
}

.gradebook-weight,
.gradebook-doc {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 400;
}

.gradebook-cell {
    text-align: center;
}

.gradebook-cell .badge {
    font-size: 0.72rem;
}

.gradebook-cell-unweighted {
    opacity: 0.6;
}

.gradebook-score {
    font-weight: 700;
    margin-right: 0.25rem;
}

/* Seguimientos */
.period-list-head,
.period-row {
    display: grid;
    grid-template-columns: 2rem minmax(10rem, 1fr) 8rem minmax(9rem, 12rem) auto;
    align-items: center;
    gap: 0.6rem;
}

.period-list.has-report-periods .period-list-head,
.period-list.has-report-periods .period-row,
.period-row:has(select[name="reportPeriodId"]) {
    grid-template-columns: 2rem minmax(9rem, 1fr) 6.5rem minmax(9rem, 12rem) minmax(8.5rem, 11rem) auto;
}

.period-row select[name="reportPeriodId"] {
    width: 100%;
}

.period-list-head {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0 0 0.35rem;
    border-bottom: 1px solid var(--border);
}

.period-row {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.period-row input {
    margin: 0;
}

.period-row-new {
    border-bottom: none;
    margin-top: 0.5rem;
    padding: 0.6rem 0.5rem;
    border: 1px dashed var(--border);
    border-radius: 8px;
}

.period-order {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: var(--surface2);
    font-weight: 700;
    font-size: 0.85rem;
}

.period-activities {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    color: var(--muted);
    font-size: 0.85rem;
}

.period-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.35rem;
}

.period-total {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0 0 2.6rem;
}

.period-group-row th {
    background: var(--surface2);
    text-align: left;
    font-size: 0.9rem;
}

.period-group-row .badge {
    margin-left: 0.4rem;
}

.gradebook-period-head {
    text-align: center;
    border-bottom: 2px solid var(--accent);
}

.gradebook-period-total {
    background: var(--surface2);
    text-align: center;
}

.online-only[hidden],
.manual-only[hidden] {
    display: none !important;
}

.manual-sheet-counts {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-left: 0.25rem;
}

.manual-sheet-fieldset {
    border: 0;
    margin: 0;
    padding: 0;
    min-width: 0;
}

.manual-sheet {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.manual-sheet-row {
    display: grid;
    grid-template-columns: minmax(12rem, 2fr) 6rem 8.5rem minmax(10rem, 2fr);
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0.75rem;
    border-top: 1px solid var(--border);
}

.manual-sheet-row:first-child {
    border-top: 0;
}

.manual-sheet-head {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    background: var(--surface2);
}

.manual-sheet-row.is-absent {
    background: color-mix(in srgb, var(--danger) 8%, transparent);
}

.manual-sheet-student {
    min-width: 0;
    overflow-wrap: anywhere;
}

.manual-absent {
    margin: 0;
    font-size: 0.88rem;
}

.manual-feedback-input {
    width: 100%;
}

@media (max-width: 760px) {
    .manual-sheet-head {
        display: none;
    }

    .manual-sheet-row {
        grid-template-columns: 1fr auto;
    }

    .manual-sheet-student,
    .manual-feedback-input {
        grid-column: 1 / -1;
    }
}

.gradebook-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
}

.gradebook-toolbar-actions {
    display: flex;
    gap: 0.4rem;
}

.gradebook-summary-table {
    width: 100%;
}

.gradebook-summary-table th:first-child,
.gradebook-summary-table .gradebook-student-row td:first-child {
    width: 100%;
    white-space: normal;
}

.gradebook-expand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.gradebook-expand-icon {
    display: inline-block;
    color: var(--muted);
    transition: transform 0.15s ease;
}

.gradebook-expand[aria-expanded="true"] .gradebook-expand-icon {
    transform: rotate(90deg);
}

.gradebook-student-row:hover td {
    background: var(--surface2);
}

.gradebook-summary-table .gradebook-detail-row > td {
    white-space: normal;
    background: var(--surface2);
    padding: 0.75rem;
}

.gradebook-detail-period + .gradebook-detail-period {
    margin-top: 0.85rem;
}

.gradebook-detail-period h4 {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin: 0 0 0.45rem;
    font-size: 0.92rem;
}

.gradebook-detail-period h4 .gradebook-weight {
    display: inline;
}

.gradebook-activity-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 0.5rem;
}

.gradebook-activity {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.gradebook-activity-title {
    color: inherit;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.gradebook-activity-result {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
}

.gradebook-activity-result .gradebook-score {
    font-size: 1.15rem;
}

.gradebook-activity-result .badge {
    font-size: 0.72rem;
}

@media (max-width: 760px) {
    .period-list-head {
        display: none;
    }

    .period-row {
        grid-template-columns: 2rem 1fr 6rem;
    }

    .period-row select[name="reportPeriodId"],
    .period-activities,
    .period-actions {
        grid-column: 2 / -1;
        justify-content: flex-start;
    }
}

.student-period {
    margin-top: 1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}

.student-period-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--surface2);
}

.student-period-header h3 {
    margin: 0;
    font-size: 1rem;
}

.student-period-weight {
    display: block;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 400;
}

.student-period-score {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.student-period-score strong {
    font-size: 1.35rem;
}

.student-period-progress {
    height: 4px;
    background: var(--border);
}

.student-period-progress span {
    display: block;
    height: 100%;
    background: var(--accent);
}

.student-period .grades-table {
    margin: 0;
}

.student-period-empty {
    margin: 0;
    padding: 0.75rem 1rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.student-gradebook {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.student-gradebook-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.student-gradebook-header h2 {
    margin: 0;
    font-size: 1.15rem;
}

.student-gradebook-summary {
    display: flex;
    gap: 1.5rem;
}

.student-gradebook-metric {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.student-gradebook-metric strong {
    font-size: 1.6rem;
    line-height: 1.1;
}

.student-gradebook-metric-label,
.student-gradebook-metric-hint {
    color: var(--muted);
    font-size: 0.78rem;
}

/* Tipos de actividad, límite de tiempo y entrega tardía */
.exam-type-badge {
    margin-left: 0.4rem;
    vertical-align: middle;
    font-size: 0.72rem;
}

.exam-late-warning {
    margin: 0.5rem 0 0;
    padding: 0.5rem 0.75rem;
    border-left: 3px solid var(--warning);
    background: rgba(245, 158, 11, 0.1);
    border-radius: 4px;
    font-size: 0.85rem;
}

.exam-timer {
    position: sticky;
    top: 0;
    z-index: 5;
    margin: 0.75rem 0;
    padding: 0.6rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: 0.95rem;
    text-align: center;
}

.exam-timer[hidden] {
    display: none;
}

.exam-timer-value {
    font-variant-numeric: tabular-nums;
    font-size: 1.15rem;
}

.exam-timer-warning {
    border-color: var(--warning);
    color: var(--warning);
}

.exam-timer-critical {
    border-color: var(--danger);
    color: var(--danger);
}

.exam-form-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.exam-form-actions .btn {
    flex: 1 1 12rem;
}

.exam-draft-status {
    margin: 0.5rem 0 0;
    min-height: 1.2em;
    color: var(--muted);
    font-size: 0.85rem;
}

.late-policy-fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
}

.late-policy-fieldset legend {
    padding: 0 0.35rem;
    font-weight: 600;
}

.late-penalty-fields {
    margin-top: 0.75rem;
}

.response-late-note {
    margin: 0 0 0.5rem;
    color: var(--warning);
    font-size: 0.85rem;
}

/* Preguntas autocalificables */
.question-type-config {
    margin: 1rem 0 0.75rem;
}

.question-type-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.question-type-row .question-type-label {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.question-type-select {
    width: auto;
    min-width: 14rem;
}

.question-type-config.has-type-picker .question-type-row {
    display: block;
}

.question-type-config.has-type-picker .question-type-select {
    display: none;
}

.question-type-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.question-type-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    padding: 0.75rem 0.5rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface2);
    color: var(--text);
    font: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    text-align: center;
    transition: border-color 0.15s, background 0.15s;
}

.question-type-card:hover:not(:disabled) {
    border-color: var(--accent);
}

.question-type-card:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.question-type-card.is-active {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 14%, var(--surface));
    font-weight: 600;
}

.question-type-card:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.question-type-card-icon {
    font-size: 1.3rem;
    line-height: 1;
    font-weight: 700;
}

.question-type-hint {
    margin: 0.5rem 0 0;
    font-size: 0.95rem;
    color: var(--muted);
}

.question-options-block {
    margin-top: 0.75rem;
}

.quiz-editor {
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface2);
}

.quiz-editor-lead {
    margin: 0 0 0.75rem;
    font-size: 1rem;
    font-weight: 600;
}

.quiz-editor-note {
    margin: 0.5rem 0 0;
    font-size: 0.9rem;
    color: var(--muted);
}

.quiz-rows {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.quiz-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.quiz-row input[type="text"] {
    flex: 1;
    min-width: 0;
    font-size: 1rem;
    padding: 0.6rem 0.75rem;
}

.quiz-row-letter {
    width: 1.75rem;
    font-weight: 700;
    text-align: right;
    flex-shrink: 0;
}

.quiz-correct-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
    padding: 0.5rem 0.75rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}

.quiz-correct-toggle input {
    width: 1.2rem;
    height: 1.2rem;
    margin: 0;
    accent-color: var(--success);
}

.quiz-correct-toggle:has(input:checked) {
    border-color: var(--success);
    color: var(--success);
    font-weight: 600;
    background: color-mix(in srgb, var(--success) 12%, var(--surface));
}

.quiz-row-remove {
    flex-shrink: 0;
}

.quiz-add {
    margin-top: 0.75rem;
}

.quiz-tf {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.quiz-tf-option {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0;
    padding: 0.8rem 1.4rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1.05rem;
    cursor: pointer;
    user-select: none;
}

.quiz-tf-option input {
    width: 1.25rem;
    height: 1.25rem;
    margin: 0;
    accent-color: var(--success);
}

.quiz-tf-option:has(input:checked) {
    border-color: var(--success);
    color: var(--success);
    font-weight: 700;
    background: color-mix(in srgb, var(--success) 12%, var(--surface));
}

.quiz-pair-head {
    display: grid;
    grid-template-columns: 1fr 1.5rem 1fr auto;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--muted);
}

.quiz-pair-head span:last-child {
    width: 4.5rem;
}

.quiz-pair-arrow {
    width: 1.5rem;
    text-align: center;
    font-size: 1.2rem;
    color: var(--muted);
    flex-shrink: 0;
}

.quiz-distractors {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border);
}

.quiz-distractors-title {
    margin-bottom: 0;
}

.quiz-distractors .quiz-editor-note {
    margin: 0.2rem 0 0.6rem;
}

.quiz-editor-status {
    margin: 1rem 0 0;
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 600;
}

.quiz-editor-status.is-ok {
    color: var(--success);
    background: color-mix(in srgb, var(--success) 10%, transparent);
}

.quiz-editor-status.is-missing {
    color: var(--warning);
    background: color-mix(in srgb, var(--warning) 12%, transparent);
}

.question-block-attention {
    outline: 3px solid var(--warning);
    outline-offset: 4px;
}

@media (max-width: 640px) {
    .quiz-choice-row {
        flex-wrap: wrap;
    }

    .quiz-choice-row input[type="text"] {
        flex-basis: calc(100% - 2.25rem);
    }

    .quiz-pair-head {
        display: none;
    }

    .quiz-pair-row {
        flex-wrap: wrap;
    }
}

/* Formulario de actividad por pasos */
.form-section {
    margin: 0 0 1.5rem;
    padding: 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.form-section-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0 0 1rem;
    font-size: 1.15rem;
}

.form-step {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.9rem;
    height: 1.9rem;
    border-radius: 50%;
    background: var(--accent-strong);
    color: #fff;
    font-size: 1rem;
    flex-shrink: 0;
}

.form-row-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
    gap: 0 1rem;
}

.activity-type-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
    gap: 0.75rem;
}

.activity-type-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin: 0;
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface2);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.activity-type-card:hover {
    border-color: var(--accent);
}

.activity-type-card input {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 1.2rem;
    height: 1.2rem;
    margin: 0;
    accent-color: var(--accent);
}

.activity-type-card:has(input:focus-visible) {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.activity-type-card.is-selected,
.activity-type-card:has(input:checked) {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}

.activity-type-card-icon {
    font-size: 1.6rem;
    line-height: 1;
}

.activity-type-card-title {
    font-size: 1.1rem;
    font-weight: 700;
}

.activity-type-card-desc {
    font-size: 0.92rem;
    color: var(--muted);
    line-height: 1.4;
}

.form-advanced {
    margin: 0.5rem 0 1.25rem;
    padding: 0.75rem 1rem;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

.form-advanced > summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--accent);
}

.form-advanced[open] > summary {
    margin-bottom: 1rem;
}

.exam-choice-list {
    border: 0;
    margin: 0 0 0.75rem;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.exam-choice-option {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    margin: 0;
}

.exam-choice-option:has(input:checked) {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.08);
}

.exam-choice-option input {
    margin-top: 0.2rem;
    width: auto;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.quiz-answer-options {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.quiz-answer-options li {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    padding: 0.4rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
}

.quiz-option-mark {
    display: inline-block;
    min-width: 1rem;
    font-weight: 700;
}

.quiz-option-correct {
    border-color: var(--success) !important;
}

.quiz-option-correct .quiz-option-mark {
    color: var(--success);
}

.quiz-option-wrong {
    border-color: var(--danger) !important;
    background: rgba(239, 68, 68, 0.08);
}

.quiz-option-wrong .quiz-option-mark {
    color: var(--danger);
}

.quiz-option-selected.quiz-option-correct {
    background: rgba(34, 197, 94, 0.1);
}

.quiz-option-note {
    color: var(--muted);
    font-size: 0.8rem;
}

.quiz-accepted-answers {
    margin: 0.4rem 0 0;
    font-size: 0.85rem;
    color: var(--muted);
}

.grading-auto-note {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--muted);
}

.exam-match-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 0 0 0.75rem;
}

.exam-match-row {
    display: grid;
    grid-template-columns: minmax(8rem, 1fr) minmax(10rem, 1fr);
    gap: 0.75rem;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.exam-match-premise {
    margin: 0;
    font-weight: 600;
}

@media (max-width: 600px) {
    .exam-match-row {
        grid-template-columns: 1fr;
    }
}

/* Emparejamiento interactivo */
.exam-match-enhanced .exam-match-row {
    display: none;
}

.match-hint {
    margin: 0 0 0.75rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.match-board {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    gap: 1.25rem;
    align-items: start;
}

.match-premises {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.match-row {
    display: grid;
    grid-template-columns: minmax(6rem, 1fr) minmax(8rem, 1.3fr);
    gap: 0.6rem;
    align-items: stretch;
}

.match-premise {
    display: flex;
    align-items: center;
    padding: 0.6rem 0.8rem;
    border-radius: var(--radius);
    background: var(--editor-bg);
    border: 1px solid var(--border);
    font-weight: 600;
    position: relative;
}

.match-premise::after {
    content: "→";
    position: absolute;
    right: -0.55rem;
    color: var(--muted);
    font-weight: 400;
}

.match-slot {
    --match-color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    min-height: 2.75rem;
    padding: 0.45rem 0.6rem 0.45rem 0.8rem;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.match-slot:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.match-board.is-picking .match-slot:not(.is-filled),
.match-slot.is-over {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.08);
}

.match-slot.is-over {
    transform: scale(1.02);
}

.match-slot.is-filled {
    border-style: solid;
    border-color: var(--match-color);
    background: color-mix(in srgb, var(--match-color) 14%, transparent);
    animation: match-pop 0.2s ease-out;
}

.match-slot-placeholder {
    font-size: 0.85rem;
    color: var(--muted);
}

.match-slot-text {
    font-weight: 600;
}

.match-slot-clear {
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 1.2rem;
    line-height: 1;
    padding: 0.1rem 0.35rem;
    border-radius: 50%;
    cursor: pointer;
    width: auto;
}

.match-slot-clear:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.12);
}

.match-bank {
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    position: sticky;
    top: 4rem;
}

.match-bank-title {
    margin: 0 0 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.match-bank-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.match-chip {
    --match-color: var(--accent);
    width: auto;
    padding: 0.45rem 0.85rem;
    border-radius: 999px;
    border: 2px solid var(--match-color);
    background: color-mix(in srgb, var(--match-color) 12%, transparent);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    cursor: grab;
    user-select: none;
    transition: transform 0.12s, box-shadow 0.12s, opacity 0.12s;
}

.match-chip:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.match-chip.is-selected {
    background: var(--match-color);
    color: #fff;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--match-color) 35%, transparent);
}

.match-chip.is-used:not(.is-selected) {
    opacity: 0.55;
}

.match-chip.is-dragging {
    opacity: 0.4;
    cursor: grabbing;
}

.match-color-0 { --match-color: #3b82f6; }
.match-color-1 { --match-color: #10b981; }
.match-color-2 { --match-color: #f59e0b; }
.match-color-3 { --match-color: #a855f7; }
.match-color-4 { --match-color: #ef4444; }
.match-color-5 { --match-color: #14b8a6; }

.match-progress {
    margin: 0.75rem 0 0;
    font-size: 0.85rem;
    color: var(--muted);
}

.match-progress.is-complete {
    color: var(--success);
    font-weight: 600;
}

.match-progress.is-complete::before {
    content: "✔ ";
}

@keyframes match-pop {
    from { transform: scale(0.96); }
    to { transform: scale(1); }
}

@media (max-width: 720px) {
    .match-board {
        grid-template-columns: 1fr;
    }

    .match-bank {
        position: static;
        order: -1;
    }
}

/* Formulario de una sola acción dentro de una barra de botones */
.inline-form {
    display: inline-flex;
    margin: 0;
}

.inline-form button {
    font-family: var(--font);
}

.form-hint {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.85rem;
    color: var(--muted);
}

/* Auditoría */
.audit-filters {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
    gap: 0.75rem 1rem;
    align-items: end;
    margin-bottom: 1rem;
}

.audit-filters .form-group {
    margin-bottom: 0;
}

.audit-filter-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.audit-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.audit-total {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.audit-card {
    padding: 0;
    overflow: hidden;
}

.audit-scroll {
    overflow-x: auto;
}

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

.audit-table th,
.audit-table td {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.audit-table th {
    font-weight: 600;
    white-space: nowrap;
}

.audit-table .audit-date {
    white-space: nowrap;
    color: var(--muted);
}

.audit-table .audit-score {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.audit-table .audit-details {
    min-width: 16rem;
}

.audit-table .audit-meta {
    margin-top: 0.2rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.audit-table .audit-meta.audit-score {
    text-align: left;
}

.audit-table .audit-ip {
    white-space: nowrap;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.audit-table tr.audit-row-rejected td {
    background: rgba(220, 38, 38, 0.06);
}

.audit-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.75rem;
}

/* ---------- Página del curso ---------- */
.course-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.course-section-header h2 {
    margin: 0;
}

.course-empty,
.course-meta {
    color: var(--muted);
}

.course-meta {
    font-size: 0.85rem;
}

.course-announcement {
    border-top: 1px solid var(--border);
    padding: 0.85rem 0;
}

.course-announcement:first-of-type {
    border-top: none;
}

.course-announcement-header,
.course-module-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.course-rich {
    margin-top: 0.5rem;
    overflow-wrap: anywhere;
}

.ann-summary {
    min-width: 0;
    flex: 1 1 16rem;
}

.ann-body {
    margin-top: 0.4rem;
}

.ann-body > summary {
    cursor: pointer;
    color: var(--accent);
    font-size: 0.85rem;
    width: fit-content;
}

/* Destinatarios del anuncio: modos apilados en móvil, en fila desde tableta. */
.ann-target-modes {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.85rem;
}

.ann-target-mode {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    padding: 0.55rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface2);
    cursor: pointer;
}

.ann-target-mode input {
    width: auto;
}

.ann-target-mode:has(input:checked) {
    border-color: var(--accent);
}

.ann-target-mode.is-disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

@media (min-width: 720px) {
    .ann-target-modes {
        flex-direction: row;
        flex-wrap: wrap;
    }
}

.ann-target-panel[hidden],
.ann-group-list > [hidden],
.ann-group-empty[hidden] {
    display: none;
}

.ann-group-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.65rem;
}

.ann-group-search {
    flex: 1 1 100%;
}

@media (min-width: 720px) {
    .ann-group-search {
        flex: 1 1 16rem;
    }
}

.ann-group-count {
    margin: 0 0 0 auto;
}

.ann-group-list {
    max-height: 18rem;
    overflow-y: auto;
    padding: 0.25rem 0.25rem 0.25rem 0;
}

.ann-group-hidden {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
}

.ann-batch-groups {
    list-style: none;
    margin: 0.5rem 0 0;
    padding: 0;
    max-height: 16rem;
    overflow-y: auto;
}

.ann-batch-groups li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.35rem 0;
    border-top: 1px solid var(--border);
}

.dashboard-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.course-rich img {
    max-width: 100%;
    height: auto;
}

.course-module {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.9rem 1rem;
    margin-bottom: 1rem;
    scroll-margin-top: 5rem;
}

.course-module-header h3 {
    display: inline;
    margin: 0 0.4rem 0 0;
    font-size: 1.1rem;
}

.course-module-hidden,
.course-item-hidden {
    opacity: 0.7;
    border-style: dashed;
}

.course-items {
    list-style: none;
    margin: 0.75rem 0 0;
    padding: 0;
}

.course-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.55rem 0;
    border-top: 1px solid var(--border);
}

.course-item-main {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
}

.course-item-type {
    min-width: 5.5rem;
    text-align: center;
}

.course-item-details {
    flex-basis: 100%;
}

.course-item-details summary {
    cursor: pointer;
    color: var(--muted);
    font-size: 0.9rem;
}

.course-add-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.75rem;
}

.course-new-module {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
    margin-top: 0.5rem;
}

.course-new-module h3 {
    margin-top: 0;
    margin-bottom: 0.85rem;
}

.rich-field .rich-field-mount {
    min-height: 9rem;
    background: var(--editor-bg);
}

.course-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
    gap: 1rem;
}

.course-card {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    text-decoration: none;
    color: inherit;
}

.course-card:hover {
    border-color: var(--accent);
}

.course-card h2 {
    font-size: 1.1rem;
    margin: 0;
}

[data-show-for][hidden] {
    display: none !important;
}

/* ---------- Inicio del estudiante ---------- */
.student-dashboard .sd-header h1 {
    margin: 0;
    font-size: 1.6rem;
}

.student-dashboard .sd-header .subtitle {
    margin: 0.3rem 0 1.25rem;
}

.sd-stats {
    margin-bottom: 1.5rem;
}

a.sd-stat {
    color: inherit;
    text-decoration: none;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

a.sd-stat:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
}

.sd-stat-alert .value {
    color: var(--warning);
}

.sd-grid {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    gap: 1.25rem;
    align-items: start;
}

.sd-column {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    min-width: 0;
}

.sd-panel {
    padding: 1.25rem 1.35rem;
}

.sd-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.sd-panel-header h2 {
    margin: 0;
    font-size: 1.05rem;
}

.sd-empty {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.sd-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sd-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.7rem 0;
    border-top: 1px solid var(--border);
}

.sd-list-item:first-child {
    border-top: none;
    padding-top: 0.2rem;
}

.sd-list-main {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.sd-list-title {
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
    overflow-wrap: anywhere;
}

a.sd-list-title:hover {
    color: var(--accent);
}

.sd-list-meta {
    color: var(--muted);
    font-size: 0.8rem;
}

.sd-list-badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.35rem;
}

.sd-list-main .sd-list-badges {
    justify-content: flex-start;
    margin-top: 0.15rem;
}

.sd-list-badges:empty {
    display: none;
}

.sd-more {
    margin: 0.75rem 0 0;
    font-size: 0.85rem;
}

.sd-course-grade {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
    min-width: 6.5rem;
    color: inherit;
    text-decoration: none;
    flex-shrink: 0;
}

.sd-course-grade strong {
    font-size: 1.3rem;
}

.sd-course-progress {
    display: block;
    width: 6.5rem;
    height: 4px;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
}

.sd-course-progress span {
    display: block;
    height: 100%;
    background: var(--accent);
}

.sd-grade {
    font-size: 1.15rem;
    flex-shrink: 0;
}

@media (max-width: 900px) {
    .sd-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 520px) {
    .sd-list-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .sd-list-badges,
    .sd-course-grade {
        justify-content: flex-start;
        align-items: flex-start;
    }
}

/* ---- Comunicación: campana, avisos, calendario, «Mi semana», módulo de correo ---- */
.form-optional {
    color: var(--muted);
    font-weight: 400;
    font-size: 0.85em;
}

.nav-bell {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 999px;
    text-decoration: none;
    color: var(--text);
    border: 1px solid transparent;
    filter: grayscale(1);
    opacity: 0.75;
}

.nav-bell:hover,
.nav-bell:focus-visible {
    border-color: var(--border);
    background: var(--surface2);
    opacity: 1;
}

.nav-bell-active {
    filter: none;
    opacity: 1;
}

.nav-bell-icon {
    font-size: 1.05rem;
    line-height: 1;
}

.nav-bell-count {
    position: absolute;
    top: -0.2rem;
    right: -0.25rem;
    min-width: 1.1rem;
    height: 1.1rem;
    padding: 0 0.3rem;
    border-radius: 999px;
    background: var(--danger-strong);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1.1rem;
    text-align: center;
}

.notif-toolbar {
    align-items: center;
    margin-bottom: 0.25rem;
}

.notif-toolbar h1 {
    margin: 0;
    font-size: 1.35rem;
}

.notif-list {
    list-style: none;
    padding: 0;
    margin: 1rem 0 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.notif-open {
    margin: 0;
}

.notif-button {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    width: 100%;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface2);
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.notif-button:hover,
.notif-button:focus-visible {
    border-color: var(--accent);
}

.notif-dot {
    flex: none;
    width: 0.55rem;
    height: 0.55rem;
    margin-top: 0.4rem;
    border-radius: 999px;
    background: transparent;
}

.notif-unread .notif-dot {
    background: var(--accent);
}

.notif-unread .notif-title {
    font-weight: 700;
}

.notif-read .notif-button {
    background: transparent;
}

.notif-main {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.notif-body {
    color: var(--text);
    font-size: 0.9rem;
    overflow-wrap: anywhere;
}

.notif-meta {
    color: var(--muted);
    font-size: 0.8rem;
}

.notif-footer {
    margin-top: 1rem;
}

/* Panel desplegable de la campana */
.nav-notif {
    position: relative;
    display: inline-flex;
}

.notif-popover {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    z-index: 1200;
    width: min(26rem, calc(100vw - 1.5rem));
    max-height: min(32rem, calc(100vh - 6rem));
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
}

.notif-popover[hidden] {
    display: none;
}

.notif-panel {
    display: flex;
    flex-direction: column;
}

.notif-panel-head {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.75rem 0.85rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.notif-panel-filters {
    display: flex;
    gap: 0.35rem;
}

.notif-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 0.82rem;
    line-height: 1.3;
    white-space: nowrap;
}

button.notif-chip {
    cursor: pointer;
}

.notif-chip.is-active {
    border-color: transparent;
    background: color-mix(in srgb, var(--accent) 16%, transparent);
    color: var(--accent);
    font-weight: 600;
}

.notif-panel-head form {
    margin: 0;
}

.notif-panel-action {
    border: 0;
    background: none;
    color: var(--accent);
    font: inherit;
    font-size: 0.82rem;
    cursor: pointer;
    padding: 0.25rem 0.35rem;
    border-radius: 6px;
}

.notif-panel-action:hover,
.notif-panel-action:focus-visible {
    background: var(--surface2);
}

.notif-panel-empty {
    margin: 0;
    padding: 1.25rem 1rem;
    color: var(--muted);
    font-size: 0.9rem;
    text-align: center;
}

.notif-cards {
    list-style: none;
    margin: 0;
    padding: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.notif-card {
    border-radius: 12px;
    background: var(--surface2);
    border: 1px solid transparent;
}

.notif-card[hidden] {
    display: none;
}

.notif-card.notif-unread {
    background: color-mix(in srgb, var(--accent) 10%, var(--surface));
    border-color: color-mix(in srgb, var(--accent) 25%, transparent);
}

.notif-card-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.6rem 0 0.85rem;
}

.notif-card-head .notif-dot {
    margin-top: 0;
    background: var(--accent);
}

.notif-type {
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--muted);
    background: var(--surface);
}

.notif-unread .notif-type {
    color: var(--accent);
    border-color: color-mix(in srgb, var(--accent) 35%, transparent);
}

.notif-when {
    margin-left: auto;
    color: var(--muted);
    font-size: 0.8rem;
    white-space: nowrap;
}

.notif-expand {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border: 0;
    border-radius: 999px;
    background: none;
    color: var(--muted);
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.notif-expand:hover,
.notif-expand:focus-visible {
    background: var(--surface);
    color: var(--text);
}

.notif-card.is-expanded .notif-expand {
    transform: rotate(180deg);
}

.notif-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    width: 100%;
    padding: 0.45rem 0.85rem 0.8rem;
    border: 0;
    background: none;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
    border-radius: 0 0 12px 12px;
}

.notif-card-body:hover .notif-title,
.notif-card-body:focus-visible .notif-title {
    text-decoration: underline;
}

.notif-card .notif-title {
    font-size: 0.92rem;
    line-height: 1.35;
}

.notif-card .notif-body {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--muted);
    font-size: 0.86rem;
    line-height: 1.4;
}

.notif-card.is-expanded .notif-body {
    display: block;
    -webkit-line-clamp: unset;
}

.notif-panel-foot {
    padding: 0.6rem 0.85rem 0.75rem;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 0.88rem;
}

@media (max-width: 900px) {
    .notif-popover {
        position: fixed;
        top: 4rem;
        left: 0.75rem;
        right: 0.75rem;
        width: auto;
    }
}

.cal-toolbar {
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.cal-toolbar h1 {
    margin: 0;
    font-size: 1.35rem;
}

.cal-nav {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.cal-month-name {
    min-width: 9.5rem;
    text-align: center;
}

.cal-filter {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.75rem 0;
}

.cal-filter select {
    width: auto;
    min-width: 14rem;
}

.cal-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0.5rem 0 0.75rem;
}

.cal-grid {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.cal-row {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
}

.cal-row + .cal-row {
    border-top: 1px solid var(--border);
}

.cal-head span {
    padding: 0.4rem;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
    background: var(--surface2);
}

.cal-day {
    min-height: 6.5rem;
    padding: 0.3rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.cal-day + .cal-day {
    border-left: 1px solid var(--border);
}

.cal-out {
    background: var(--surface2);
}

.cal-day-num {
    font-size: 0.8rem;
    color: var(--muted);
}

.cal-today .cal-day-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 999px;
    background: var(--accent-strong);
    color: #fff;
    font-weight: 700;
}

.cal-ev {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    max-width: 100%;
    padding: 0.1rem 0.4rem;
    border-radius: 6px;
    border-left: 3px solid var(--muted);
    color: var(--text);
    font-size: 0.75rem;
    line-height: 1.35;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: var(--surface2);
}

.cal-day .cal-ev span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
}

.cal-ev-time {
    font-variant-numeric: tabular-nums;
    opacity: 0.8;
}

.cal-ev-opens {
    border-left-color: var(--success);
}

.cal-ev-due {
    border-left-color: var(--danger);
}

.cal-ev-late {
    border-left-color: var(--warning);
}

.cal-ev-module {
    border-left-color: var(--accent);
}

.cal-ev-announcement {
    border-left-color: #a855f7;
}

.cal-agenda,
.cal-feed {
    margin-top: 1rem;
}

.cal-feed-url {
    margin: 0.75rem 0;
}

.cal-feed-url input {
    font-family: ui-monospace, monospace;
    font-size: 0.85rem;
}

@media (max-width: 720px) {
    .cal-day {
        min-height: 3.5rem;
    }

    .cal-day .cal-ev span:last-child,
    .cal-day .cal-ev-time {
        display: none;
    }

    .cal-day .cal-ev {
        width: 0.6rem;
        height: 0.6rem;
        padding: 0;
        border: none;
        border-radius: 999px;
        background: currentColor;
    }
}

.my-week {
    margin: 1rem 0;
}

.week-days {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.5rem;
}

.week-day {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem;
    min-width: 0;
}

.week-today {
    border-color: var(--accent);
}

.week-day-label {
    display: flex;
    justify-content: space-between;
    gap: 0.25rem;
    font-size: 0.85rem;
    margin-bottom: 0.35rem;
}

.week-day-label span {
    color: var(--muted);
}

.week-empty {
    color: var(--muted);
    font-size: 0.8rem;
}

.week-entries {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.week-entry {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    font-size: 0.85rem;
}

.week-entry .cal-ev {
    align-self: flex-start;
}

.week-entry-title {
    display: flex;
    flex-direction: column;
    color: var(--text);
    text-decoration: none;
    overflow-wrap: anywhere;
}

.week-entry-title:hover {
    color: var(--accent);
}

.week-entry .badge {
    align-self: flex-start;
}

@media (max-width: 960px) {
    .week-days {
        grid-template-columns: 1fr;
    }

    .week-day-label {
        justify-content: flex-start;
    }
}

.comm-page h1 {
    margin-bottom: 0.25rem;
}

.comm-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: 1rem;
    margin-top: 1rem;
}

.comm-grid > .card > .form-hint {
    margin-bottom: 1rem;
}

@media (min-width: 900px) {
    .comm-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .comm-grid > .comm-span {
        grid-column: 1 / -1;
    }
}

[data-provider-field][hidden] {
    display: none;
}

.comm-header {
    align-items: center;
    gap: 0.5rem;
    justify-content: flex-start;
}

.comm-header h2 {
    margin: 0;
}

.comm-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0 0.75rem;
    align-items: flex-end;
}

.comm-grow {
    flex: 1 1 14rem;
}

.comm-port {
    flex: 0 0 7rem;
}

.comm-updated {
    margin-top: 0.75rem;
}

.login-forgot {
    margin-top: 1rem;
    text-align: center;
    font-size: 0.9rem;
}

/* ---- Fase 3: asistencia, excusas, riesgo, reportes, rúbricas ---- */
.breadcrumb {
    margin: 0 0 0.35rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.card-title {
    font-size: 1.05rem;
    margin: 0 0 0.85rem;
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

th.num,
td.num {
    text-align: right;
    white-space: nowrap;
}

.attendance-group-list,
.attendance-session-list,
.attendance-counters,
.roll-call-list,
.excuse-files,
.report-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.attendance-group-list li + li,
.attendance-session-list li + li {
    border-top: 1px solid var(--border);
}

.attendance-group-link,
.attendance-session-list a {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.75rem 0.25rem;
    color: inherit;
    text-decoration: none;
}

.attendance-group-link:hover strong,
.attendance-session-list a:hover strong {
    color: var(--accent);
}

.attendance-top {
    display: grid;
    gap: 1rem;
    margin-bottom: 1rem;
}

.attendance-top > .card {
    margin-bottom: 0;
}

.attendance-planned {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.attendance-planned input {
    max-width: 8rem;
}

.attendance-counters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    font-size: 0.9rem;
}

.attendance-authorize form {
    display: grid;
    gap: 0.4rem;
    margin-top: 0.5rem;
    min-width: 14rem;
}

.attendance-authorize summary {
    list-style: none;
    cursor: pointer;
}

.attendance-authorize summary::-webkit-details-marker {
    display: none;
}

/* Tabla que en el celular se vuelve una tarjeta por fila. */
@media (max-width: 719px) {
    .table-cards thead {
        display: none;
    }

    .table-cards tr {
        display: block;
        padding: 0.6rem 0;
        border-bottom: 1px solid var(--border);
    }

    .table-cards td {
        display: flex;
        justify-content: space-between;
        gap: 1rem;
        padding: 0.3rem 0;
        border: 0;
        text-align: right;
    }

    .table-cards td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 0.8rem;
        text-align: left;
    }

    .table-cards td:first-child {
        display: block;
        text-align: left;
    }

    .table-cards td:first-child::before {
        content: none;
    }
}

@media (min-width: 900px) {
    .attendance-top {
        grid-template-columns: 3fr 2fr;
    }
}

.roll-call-list {
    display: grid;
    gap: 0.5rem;
    margin: 1rem 0 5.5rem;
}

.roll-call-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
    user-select: none;
    margin: 0;
}

.roll-call-item input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.roll-call-name {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.roll-call-state span {
    display: inline-block;
    padding: 0.35rem 0.8rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
}

.roll-call-present {
    background: rgba(34, 197, 94, 0.18);
    color: var(--success);
}

.roll-call-absent {
    display: none !important;
    background: rgba(239, 68, 68, 0.18);
    color: var(--danger);
}

.roll-call-item:has(input:checked) {
    border-color: var(--danger);
}

.roll-call-item:has(input:checked) .roll-call-present {
    display: none;
}

.roll-call-item:has(input:checked) .roll-call-absent {
    display: inline-block !important;
}

.roll-call-item:has(input:focus-visible) {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.roll-call-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.roll-call-delete {
    margin-bottom: 5rem;
}

.excuse-item {
    padding: 1rem 0;
    border-top: 1px solid var(--border);
}

.excuse-item:first-of-type {
    border-top: 0;
    padding-top: 0;
}

.excuse-item header {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.excuse-reason {
    white-space: pre-line;
    margin: 0.6rem 0;
}

.excuse-files {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1rem;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

.excuse-files a::before {
    content: "📎 ";
}

.excuse-decision {
    display: grid;
    gap: 0.4rem;
}

.excuse-form {
    display: grid;
    gap: 0.6rem;
    margin-top: 0.6rem;
}

.absence-item {
    padding: 0.85rem 0;
    border-top: 1px solid var(--border);
}

.absence-item:first-child {
    border-top: 0;
}

.absence-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.export-menu {
    position: relative;
}

.export-menu > summary {
    list-style: none;
    cursor: pointer;
}

.export-menu > summary::-webkit-details-marker {
    display: none;
}

.export-menu-list {
    position: absolute;
    right: 0;
    top: calc(100% + 0.35rem);
    z-index: 30;
    display: flex;
    flex-direction: column;
    min-width: 11rem;
    padding: 0.35rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.export-menu-list a {
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    color: var(--text);
    text-decoration: none;
}

.export-menu-list a:hover {
    background: var(--surface2);
}

.risk-help {
    margin-bottom: 1rem;
}

.report-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

@media (min-width: 720px) {
    .report-stats {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.report-bars {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.45rem;
}

.report-bar {
    display: grid;
    grid-template-columns: 6.5rem 1fr 4.5rem;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.9rem;
}

.report-bar-track {
    height: 0.8rem;
    background: var(--surface2);
    border-radius: 999px;
    overflow: hidden;
}

.report-bar-fill {
    display: block;
    height: 100%;
    background: var(--accent);
    border-radius: 999px;
}

.report-bar-fill.is-correct {
    background: var(--success);
}

.analysis-question {
    padding: 1rem 0;
    border-top: 1px solid var(--border);
}

.analysis-question:first-of-type {
    border-top: 0;
    padding-top: 0;
}

.analysis-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
}

.analysis-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1rem;
    margin: 0.5rem 0;
    font-size: 0.9rem;
}

.analysis-notes {
    margin: 0.5rem 0 0;
    padding-left: 1.1rem;
    color: var(--warning);
    font-size: 0.9rem;
}

/* Rúbricas */
.rubric-weight-total {
    margin: 1rem 0 0.75rem;
    font-size: 0.95rem;
}

.rubric-weight-total.is-invalid strong {
    color: var(--danger);
}

.rubric-criterion {
    margin: 0 0 1rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.rubric-criterion-head,
.rubric-level {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.6rem;
}

.rubric-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0.6rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.rubric-field input {
    width: 100%;
}

.rubric-field-grow {
    flex: 1 1 14rem;
}

.rubric-field-num {
    flex: 0 0 7.5rem;
}

.rubric-levels {
    margin: 0.25rem 0 0.5rem;
    padding-left: 0.75rem;
    border-left: 3px solid var(--border);
}

.rubric-level .btn {
    margin-bottom: 0.6rem;
}

.question-rubric {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.question-rubric select {
    max-width: 22rem;
}

.rubric-view {
    margin: 0.5rem 0 0.85rem;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.rubric-view summary {
    cursor: pointer;
}

.rubric-view-desc {
    display: block;
    margin: 0.25rem 0;
    color: var(--muted);
    font-weight: normal;
}

.rubric-table th[scope="row"] {
    text-align: left;
    vertical-align: top;
}

.rubric-level-list {
    margin: 0;
    padding-left: 1rem;
}

.rubric-level-percent {
    color: var(--muted);
}

.rubric-grading {
    margin: 0.85rem 0 0.5rem;
    padding: 0.75rem;
    border: 1px dashed var(--border);
    border-radius: 10px;
}

.rubric-grading-title {
    margin: 0 0 0.5rem;
}

.rubric-grading-hint {
    display: block;
    color: var(--muted);
    font-size: 0.85rem;
}

.rubric-grading-criterion {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0 0 0.6rem;
    padding: 0;
    border: 0;
}

.rubric-grading-criterion legend {
    width: 100%;
    margin-bottom: 0.3rem;
    font-weight: 600;
}

.rubric-grading-level {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: normal;
    letter-spacing: normal;
    text-transform: none;
    color: var(--text);
}

.rubric-grading-level:has(input:checked) {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 14%, transparent);
}

/* ---- Fase 4: inicio de sesión institucional e integraciones ---- */
.login-sso {
    margin-top: 1.25rem;
}

.login-sso-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0 0 0.85rem;
    color: var(--muted);
    font-size: 0.85rem;
}

.login-sso-divider::before,
.login-sso-divider::after {
    content: "";
    flex: 1;
    border-top: 1px solid var(--border);
}

.login-sso-btn {
    display: block;
    width: 100%;
    text-align: center;
    margin-top: 0.5rem;
}

tr.row-selected td {
    background: var(--surface-muted, rgba(127, 127, 127, 0.08));
}

.token-reveal {
    width: 100%;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.code-sample {
    overflow-x: auto;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
    white-space: pre;
}

/* ---------- Interacción: avatares, foros, mensajes, perfil ---------- */

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    overflow: hidden;
    background: color-mix(in srgb, var(--accent) 22%, var(--surface));
    color: var(--text);
    font-weight: 600;
    font-size: 0.9rem;
    border: 1px solid var(--border);
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-sm {
    width: 2rem;
    height: 2rem;
    font-size: 0.75rem;
}

.avatar-lg {
    width: 4rem;
    height: 4rem;
    font-size: 1.25rem;
}

.byline {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.nav-count {
    display: inline-block;
    min-width: 1.25rem;
    margin-left: 0.25rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: var(--accent-strong);
    color: #fff;
    font-size: 0.75rem;
    line-height: 1.25rem;
    text-align: center;
}

.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    color: var(--muted);
}

.forum-list,
.thread-list,
.conversation-list,
.participant-list,
.attachment-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.forum-card {
    border-top: 1px solid var(--border);
    padding: 0.75rem 0;
}

.forum-card:first-child {
    border-top: none;
}

.forum-card-main {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}

.forum-card-title,
.thread-row-title {
    font-weight: 600;
}

.thread-row {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    border-top: 1px solid var(--border);
    padding: 0.7rem 0;
}

.thread-row:first-child {
    border-top: none;
}

.thread-row-main {
    flex: 1;
    min-width: 0;
}

.thread-unread .thread-row-title,
.thread-unread .conversation-row strong {
    color: var(--accent);
}

.forum-post {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
    margin-bottom: 0.75rem;
    background: var(--surface);
}

.forum-post-lead {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.forum-post-solution {
    border-color: var(--success);
    box-shadow: inset 4px 0 0 var(--success);
}

.forum-post-header {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    margin-bottom: 0.5rem;
}

.forum-post-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.4rem;
    margin-top: 0.6rem;
}

.forum-inline-details > summary {
    list-style: none;
    cursor: pointer;
}

.forum-inline-details > summary::-webkit-details-marker {
    display: none;
}

.forum-inline-details[open] {
    flex-basis: 100%;
}

.forum-inline-details[open] > form {
    margin-top: 0.5rem;
}

.forum-quote {
    margin: 0 0 0.5rem;
    padding: 0.4rem 0.75rem;
    border-left: 3px solid var(--border);
    color: var(--muted);
    font-size: 0.9rem;
}

.forum-quote strong {
    margin-right: 0.35rem;
}

.forum-quote-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.forum-compose,
.forum-reports {
    margin-top: 1rem;
}

.forum-reports {
    border-color: var(--warning);
}

.forum-first-thread {
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin: 1rem 0;
}

.attachment-list {
    margin-top: 0.5rem;
}

.attachment-list li {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.15rem 0;
}

.chat-thread {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin: 1rem 0;
}

.chat-message {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    max-width: 85%;
}

.chat-message-mine {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-bubble {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.55rem 0.8rem;
    background: var(--surface);
    min-width: 0;
}

.chat-message-mine .chat-bubble {
    background: color-mix(in srgb, var(--accent) 14%, var(--surface));
}

.chat-text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    margin-top: 0.25rem;
}

.chat-report-link {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.35rem;
}

.chat-compose {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

.conversation-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.25rem;
    border-top: 1px solid var(--border);
    color: inherit;
    text-decoration: none;
}

.conversation-list li:first-child .conversation-row {
    border-top: none;
}

.conversation-row-main {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.conversation-row-main .course-meta {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-header,
.profile-header {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.recipient-picker {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    max-height: 22rem;
    overflow-y: auto;
}

.recipient-picker .checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.15rem 0;
}

.message-report {
    margin-bottom: 0.85rem;
}

.message-report-body {
    border-left: 3px solid var(--warning);
    padding-left: 0.75rem;
    margin: 0.5rem 0;
}

.profile-section {
    border-top: 1px solid var(--border);
    margin-top: 1.25rem;
    padding-top: 1rem;
}

.profile-section h2 {
    margin-top: 0;
}

.teacher-card {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.teacher-card-main {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
}

.teacher-card-bio {
    margin: 0;
    white-space: pre-wrap;
    color: var(--muted);
}

.participant-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0;
    border-top: 1px solid var(--border);
}

.participant-row:first-child {
    border-top: none;
}

.participant-name {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.progress-bar {
    display: block;
    height: 0.6rem;
    border-radius: 999px;
    background: var(--surface2);
    border: 1px solid var(--border);
    overflow: hidden;
}

.progress-bar > span {
    display: block;
    height: 100%;
    background: var(--success);
    transition: width 0.3s ease;
}

.progress-bar-sm {
    height: 0.4rem;
    width: 6rem;
    flex: none;
}

.course-progress {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    background: var(--surface2);
}

.course-progress-label {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.course-card-progress {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.course-module-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.course-module-head h3 {
    font-size: 1.1rem;
}

.course-module-locked {
    opacity: 0.75;
    border-style: dashed;
}

.course-module-conditions ul {
    margin: 0;
    padding-left: 1.25rem;
    color: var(--muted);
}

.course-item-check {
    display: inline-block;
    width: 1.1rem;
    text-align: center;
    color: var(--muted);
}

.course-item-done .course-item-check {
    color: var(--success);
    font-weight: 700;
}

.attempt-panel-title {
    font-size: 1.05rem;
    margin: 0 0 0.35rem;
}

.attempt-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.attempt-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0;
    border-top: 1px solid var(--border);
}

.attempt-row:first-child {
    border-top: none;
}

.attempt-row-current {
    font-weight: 600;
}

.attempt-history {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.5rem;
}

.certificate-revoke-form {
    display: inline;
}

.verify-details {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.25rem 0.75rem;
    margin: 0.5rem 0 0;
}

.verify-details dt {
    font-weight: 600;
}

.verify-details dd {
    margin: 0;
}

.policy-page {
    padding-top: 2rem;
    padding-bottom: 2rem;
}

.policy-text {
    white-space: pre-line;
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.policy-text-scroll {
    max-height: 55vh;
    overflow-y: auto;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface2);
}

.policy-accept-form {
    margin-top: 1rem;
}

.policy-stats {
    margin: 0.5rem 0 0;
    padding-left: 1.25rem;
}

.recovery-codes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 12rem));
    gap: 0.35rem 1.5rem;
    margin: 0.5rem 0 0.75rem;
    padding-left: 1.5rem;
    font-size: 1.05rem;
}

.totp-qr {
    display: inline-block;
    padding: 0.5rem;
    background: #fff;
    border-radius: 0.5rem;
    line-height: 0;
}

.request-overdue {
    color: var(--danger, #b91c1c);
    font-weight: 600;
}

.request-due-soon {
    color: var(--warning, #b45309);
    font-weight: 600;
}

/* Respaldos */
.backup-ok {
    color: var(--success);
}

.backup-failed {
    color: var(--danger);
}

/* Portal del acudiente */
.guardian-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.25rem;
}

.guardian-tabs a {
    padding: 0.5rem 0.85rem;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    text-decoration: none;
}

.guardian-tabs a:hover {
    color: var(--text);
}

.guardian-tabs a.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

.guardian-cards {
    list-style: none;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.75rem;
}

.guardian-card {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface2);
    color: var(--text);
    text-decoration: none;
}

.guardian-card:hover {
    border-color: var(--accent);
}

/* ---------- Asistente de estudio (Asistente IA para estudiante sin scroll vertical) ---------- */
body.study-assistant-body {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

body.study-assistant-body .nav-admin {
    flex-shrink: 0;
}

body.study-assistant-body > main {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

body.study-assistant-body .container-exam {
    flex: 1 1 0;
    min-height: 0;
    padding: 0.75rem 1.25rem 1rem;
    display: flex;
    justify-content: center;
    align-items: stretch;
    overflow: hidden;
    box-sizing: border-box;
}

body.study-assistant-body .card-exam {
    width: 100%;
    max-width: min(92vw, 56rem);
    height: 100%;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
    box-sizing: border-box;
    overflow: hidden;
    padding: 1rem 1.25rem;
}

body.study-assistant-body .toolbar {
    flex-shrink: 0;
    margin-bottom: 0.35rem;
}

body.study-assistant-body .card-exam > .form-hint {
    flex-shrink: 0;
    margin-bottom: 0.5rem;
}

body.study-assistant-body .alert {
    flex-shrink: 0;
    margin-bottom: 0.5rem;
}

.study-thread {
    flex: 1 1 0;
    min-height: 0;
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 0.35rem;
    margin: 0.35rem 0;
}

body.study-assistant-body .study-thread {
    max-height: none;
}

.chat-compose.study-compose,
body.study-assistant-body .chat-compose {
    flex-shrink: 0;
    border-top: 1px solid var(--border);
    padding-top: 0.65rem;
    overflow-y: hidden;
}

#study-message,
.study-compose textarea,
body.study-assistant-body .chat-compose textarea {
    min-height: 48px;
    height: 52px;
    max-height: 120px;
    resize: none;
    overflow-y: hidden !important;
    line-height: 1.4;
    padding: 0.5rem 0.75rem;
    box-sizing: border-box;
}

.study-clear {
    margin: 0;
    text-align: right;
}

@media (max-height: 540px) {
    body.study-assistant-body {
        height: auto;
        overflow-y: auto;
    }
    body.study-assistant-body .container-exam {
        height: auto;
        overflow: visible;
    }
    body.study-assistant-body .card-exam {
        height: auto;
        overflow: visible;
    }
    body.study-assistant-body .study-thread {
        max-height: 40vh;
    }
}

.study-answer {
    white-space: normal;
}

.study-answer h3,
.study-answer h4,
.study-answer h5 {
    margin: 0.75rem 0 0.35rem;
    font-size: 1.05rem;
}

.study-answer h4,
.study-answer h5 {
    font-size: 1rem;
}

.study-answer blockquote {
    margin: 0.5rem 0;
    padding-left: 0.75rem;
    border-left: 3px solid var(--border);
    color: var(--muted);
}

.study-answer .study-formula {
    text-align: center;
    overflow-x: auto;
}

.study-answer .study-table {
    overflow-x: auto;
    margin: 0.5rem 0;
}

.study-figure {
    display: block;
    margin: 0.5rem 0;
}

.study-answer .study-figure img {
    display: block;
    margin: 0;
    max-width: min(100%, 420px);
    max-height: 320px;
    height: auto;
    border-radius: var(--radius);
}

.study-figure-caption {
    display: block;
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.25rem;
}

/* ---------- Componentes de Boletines, Escalas, Informes y Formularios (WP-01 y Ajustes Visuales) ---------- */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 0.5rem;
}

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

.data-table th,
.data-table td {
    padding: 0.75rem 0.85rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table th {
    background: var(--surface2);
    color: var(--muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.data-table tbody tr:hover {
    background: color-mix(in srgb, var(--accent) 4%, transparent);
}

.data-table.scale-table td input[type="number"] {
    max-width: 6.5rem;
}

.data-table.scale-table td textarea {
    min-height: 3.8rem;
    resize: vertical;
    font-size: 0.88rem;
}

.form-label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.9rem;
    color: var(--muted);
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    background: var(--surface2);
    color: var(--text);
    font-size: 0.95rem;
    font-family: var(--font);
    line-height: 1.4;
    transition: border-color 0.15s ease-in-out;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.form-control-sm {
    padding: 0.35rem 0.55rem;
    font-size: 0.85rem;
    border-radius: 6px;
}

.text-muted {
    color: var(--muted) !important;
}

/* Utilidades para no repetir estilos en línea. Escala de márgenes: 1 = 0.25rem, 2 = 0.5rem, 3 = 0.75rem,
   4 = 1rem, 5 = 1.5rem. Llevan !important porque reemplazan a style="..." y deben ganar a las reglas del componente. */
.m-0 { margin: 0 !important; }
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 0.25rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 0.75rem !important; }
.mt-4 { margin-top: 1rem !important; }
.mt-5 { margin-top: 1.5rem !important; }
.ml-1 { margin-left: 0.25rem !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 0.75rem !important; }
.mb-4 { margin-bottom: 1rem !important; }
.mb-5 { margin-bottom: 1.5rem !important; }
.text-xs { font-size: 0.75rem !important; }
.text-sm { font-size: 0.85rem !important; }
.text-base { font-size: 1rem !important; }
.text-lg { font-size: 1.1rem !important; }
.text-xl { font-size: 1.35rem !important; }
.w-100 { width: 100% !important; }
.d-inline { display: inline !important; }
.d-block { display: block !important; }
.d-inline-block { display: inline-block !important; }
.nowrap { white-space: nowrap; }
.fw-600 { font-weight: 600; }
.grow { flex: 1; min-width: 12.5rem; }
.input-xs { max-width: 8rem; }
.input-sm { max-width: 12rem; }
.input-md { max-width: 14rem; }
.input-lg { max-width: 24rem; }
.form-narrow { max-width: 600px; }
.inline-field { margin-bottom: 0 !important; min-width: 13rem; }
.list-plain { list-style: none; padding: 0; margin: 0 0 1rem; }
.list-scroll { max-height: 18rem; overflow-y: auto; }
.card-compact { padding: 1rem; }
.form-hint-tight { margin-top: -0.5rem; }
.flex-between { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.5rem 1rem; }
.flex-end { display: flex; gap: 0.5rem; justify-content: flex-end; }
.filter-row { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; }
.actions-end { align-items: flex-end; gap: 0.75rem; }
.items-start { align-items: flex-start; }
.section-head { border-bottom: 1px solid var(--border); padding-bottom: 0.75rem; margin-bottom: 1rem; }
.divider-top { padding-top: 1rem; border-top: 1px solid var(--border); }
.section-divider { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.panel-soft { background: var(--surface2); border: 1px solid var(--border); padding: 0.75rem 1rem; border-radius: var(--radius); }
.panel-soft-accent { border-left: 4px solid var(--accent); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat-label { font-size: 0.75rem; text-transform: uppercase; font-weight: 600; }
.stat-value { font-size: 1.3rem; font-weight: 700; }
.dropdown-panel { position: absolute; right: 0; z-index: 20; min-width: 300px; padding: 1rem; margin-top: 0.5rem; box-shadow: var(--shadow); }
.empty-roomy { padding: 2.5rem 1rem; }
.col-w-5 { width: 5%; }
.col-w-6 { width: 6%; }
.col-w-8 { width: 8%; }
.col-w-10 { width: 10%; }
.col-w-12 { width: 12%; }
.col-w-14 { width: 14%; }
.col-w-15 { width: 15%; }
.col-w-18 { width: 18%; }
.col-w-20 { width: 20%; }
.col-w-24 { width: 24%; }
.col-w-28 { width: 28%; }
.col-w-30 { width: 30%; }
.col-w-34 { width: 34%; }
.col-w-38 { width: 38%; }
.input-num { width: 5rem; }

/* ==========================================================================
   COMPORTAMIENTO REACTIVO Y RESPONSIVO GLOBAL (Branch: Reactive)
   Garantiza adaptabilidad móvil/tablet y dinamismo sin alterar el estilo base.
   ========================================================================== */

/* Barra de progreso reactiva en la parte superior */
.reactive-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #60a5fa));
    z-index: 99999;
    pointer-events: none;
    transition: width 0.18s ease, opacity 0.25s ease;
    opacity: 0;
    box-shadow: 0 0 8px var(--accent);
}

/* Spinner sutil en botones ocupados */
.reactive-spinner {
    display: inline-block;
    width: 0.85rem;
    height: 0.85rem;
    margin-right: 0.45rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: reactive-spin 0.6s linear infinite;
    vertical-align: middle;
}

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

.btn-busy {
    opacity: 0.85;
    pointer-events: none;
    cursor: wait !important;
}

/* Botón flotante reactivo "Volver arriba" */
.reactive-back-to-top {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    transition: opacity 0.2s ease, transform 0.2s ease, background 0.15s ease, border-color 0.15s ease;
    z-index: 40;
}

.reactive-back-to-top.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.reactive-back-to-top:hover {
    background: var(--surface);
    border-color: var(--accent);
    color: var(--accent);
}

/* Feedback de copia */
.copy-success {
    border-color: #22c55e !important;
    color: #22c55e !important;
}

/* --------------------------------------------------------------------------
   MEJORAS RESPONSIVAS GLOBALES (Mobile & Tablet)
   -------------------------------------------------------------------------- */

/* Contenedores y espaciados responsivos fluidos */
@media (max-width: 900px) {
    .container-exam {
        padding: 1.25rem 1rem;
    }
}

@media (max-width: 768px) {
    /* Encabezados y barras de acciones adaptables */
    .toolbar {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    /* Grids a una sola columna en pantallas medianas/pequeñas */
    .form-row-2,
    .form-row-3 {
        grid-template-columns: 1fr !important;
        gap: 0.75rem;
    }

    .dashboard-grid,
    .stats-grid,
    .comm-grid {
        grid-template-columns: 1fr !important;
    }

    /* Tablas responsivas táctiles */
    .table-responsive,
    .table-wrap {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: var(--radius);
        margin-bottom: 1rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.6rem 0.65rem;
        font-size: 0.85rem;
    }

    /* Modales y popovers en pantallas reducidas */
    .modal-content,
    .dialog-content {
        width: min(94vw, 34rem) !important;
        max-width: 94vw !important;
        padding: 1rem;
    }

    .notif-popover {
        width: min(90vw, 22rem);
        right: -1rem;
    }
}

@media (max-width: 480px) {
    .container-exam {
        padding: 0.75rem 0.5rem;
    }

    .card {
        padding: 0.9rem;
    }

    .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }

    .reactive-back-to-top {
        bottom: 1rem;
        right: 1rem;
        width: 2.4rem;
        height: 2.4rem;
        font-size: 1rem;
    }
}

/* ==========================================================================
   Información institucional y Branding
   ========================================================================== */
.brand-logo {
    max-height: 28px;
    max-width: 140px;
    height: auto;
    width: auto;
    object-fit: contain;
    display: inline-block;
    vertical-align: middle;
}

.login-brand-header {
    text-align: center;
    margin-bottom: 0.75rem;
}

.login-shield {
    max-height: 72px;
    max-width: 140px;
    object-fit: contain;
    display: inline-block;
}

.inst-preview-card {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    padding: 1.25rem;
    background: var(--surface-secondary, rgba(0, 0, 0, 0.02));
    border: 1px solid var(--border);
    border-radius: var(--radius, 8px);
    margin-bottom: 1.5rem;
}

.inst-preview-shield {
    width: 80px;
    height: 80px;
    border: 1px dashed var(--border);
    border-radius: var(--radius, 8px);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: var(--bg);
    flex-shrink: 0;
}

.inst-preview-shield img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.inst-preview-info {
    flex: 1;
    min-width: 0;
}

.inst-preview-info h3 {
    margin: 0 0 0.25rem 0;
    font-size: 1.15rem;
}

.inst-preview-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.inst-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
}

.inst-file-box {
    border: 1px solid var(--border);
    border-radius: var(--radius, 8px);
    padding: 1rem;
    background: var(--surface-secondary, rgba(0, 0, 0, 0.01));
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.inst-file-preview {
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius, 6px);
    overflow: hidden;
}

.inst-file-preview img {
    max-height: 80px;
    max-width: 100%;
    object-fit: contain;
}

