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: #3b82f6;
    --accent-hover: #2563eb;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    --editor-bg: #243044;
}

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

* {
    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;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.25rem;
}

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

.container-narrow {
    max-width: 520px;
    margin: 0 auto;
    padding: 2rem 1.25rem;
}

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

.container-import {
    max-width: 640px;
}

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

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

#studentsTable .table-actions {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.35rem;
}

/* 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;
}

.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.75rem;
    box-shadow: var(--shadow);
}

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

.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[type="text"],
input[type="password"],
input[type="email"],
textarea,
select {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface2);
    color: var(--text);
    font-size: 1rem;
}

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);
    color: #fff;
}

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

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

.btn-danger {
    background: var(--danger);
    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 {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--danger);
    color: #fca5a5;
}

html[data-theme="light"] .alert-error {
    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);
}

.nav-admin {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.85rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

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

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

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

.nav-admin-links {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.nav-admin .brand {
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
}

.nav-admin a {
    color: var(--muted);
    font-size: 0.9rem;
    text-decoration: none;
}

.nav-admin a:hover, .nav-admin a.active {
    color: var(--text);
}

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

@media (max-width: 768px) {
    .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:hover {
        background: rgba(255, 255, 255, 0.06);
    }

    html[data-theme="light"] .nav-admin-toggle:hover {
        background: rgba(0, 0, 0, 0.05);
    }

    .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: none;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        width: 100%;
        margin-top: 0;
        padding-top: 0;
        border-top: none;
    }

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

    .nav-admin-links {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
    }

    .nav-admin-links a {
        padding: 0.7rem 0;
        border-bottom: 1px solid var(--border);
    }

    .nav-admin-links a:last-child {
        border-bottom: none;
    }

    .nav-admin-actions {
        margin-left: 0;
        margin-top: 0.75rem;
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .nav-admin-actions form {
        width: 100%;
    }

    .nav-admin-actions .btn {
        width: 100%;
    }

    .nav-admin-actions .theme-toggle {
        width: 100%;
        justify-content: center;
    }
}

.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;
}

.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-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: var(--success);
}

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

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

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

.badge-info {
    background: rgba(59, 130, 246, 0.2);
    color: var(--accent);
}

.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-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;
}

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

.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;
}

.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,
.card-actions > .btn.btn-icon,
.card-actions > form > .btn.btn-icon,
.card-actions > form > button.btn.btn-icon {
    min-width: 2rem !important;
    width: 2rem;
    height: 2rem !important;
    padding: 0 !important;
}

.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;
}

td.actions {
    white-space: nowrap;
}

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

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

.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: 1.25rem;
}

.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-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;
}
