﻿:root {
    --bg: #f4f4f5;
    --surface: #ffffff;
    --text: #1f1f1f;
    --muted: #666;
    --border: #d4d4d8;
    --primary: #1f4b99;
    --primary-text: #fff;
    --danger: #9b1c1c;
    --danger-bg: #fee2e2;
    --info-bg: #e0f2fe;
    --ok: #166534;
    --warn: #9a3412;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Cairo", "Segoe UI", Tahoma, Arial, sans-serif;
    line-height: 1.7;
}

a {
    color: var(--primary);
}

.admin-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.admin-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.25rem;
    background: #111827;
    color: #fff;
    flex-wrap: wrap;
}

.admin-brand {
    color: #fff;
    text-decoration: none;
    font-weight: 700;
}

/* The header keeps the brand and the account; the pages are in the side menu under it. */
.admin-user {
    margin-inline-start: auto;
}

.admin-body {
    display: flex;
    flex: 1;
    align-items: flex-start;
}

/* Sticky, so the menu stays in reach at the bottom of a long book or report page. */
.admin-sidebar {
    position: sticky;
    top: 0;
    flex: 0 0 13rem;
    box-sizing: border-box;
    max-height: 100vh;
    overflow-y: auto;
    padding: 1rem 0.75rem;
    background: var(--surface);
    border-inline-end: 1px solid var(--border);
}

.admin-nav-group + .admin-nav-group {
    margin-top: 1rem;
}

.admin-nav-heading {
    padding: 0 0.75rem 0.25rem;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 700;
}

.admin-sidebar a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.35rem 0.75rem;
    border-inline-start: 3px solid transparent;
    border-radius: 6px;
    color: var(--text);
    text-decoration: none;
}

.admin-sidebar a:hover {
    background: var(--bg);
}

.admin-sidebar a:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.admin-sidebar a.active {
    border-inline-start-color: var(--primary);
    background: #e8eef9;
    color: var(--primary);
    font-weight: 700;
}

.admin-menu-toggle {
    display: none;
    padding: 0.3rem 0.75rem;
    border: 1px solid #4b5563;
    border-radius: 6px;
    background: transparent;
    color: #fff;
    font: inherit;
    cursor: pointer;
}

/* A narrow window has no room for a column beside a table: the menu folds behind «القائمة». */
@media (max-width: 900px) {
    .admin-menu-toggle {
        display: inline-block;
    }

    .admin-body {
        flex-direction: column;
        align-items: stretch;
    }

    .admin-sidebar {
        display: none;
        position: static;
        /* In a column the 13rem basis would become a height and cut the menu off. */
        flex: none;
        max-height: none;
        border-inline-end: 0;
        border-bottom: 1px solid var(--border);
    }

    .admin-sidebar.is-open {
        display: block;
    }
}

.nav-count-badge {
    display: inline-block;
    margin-inline-start: 0.35rem;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    background: #b91c1c;
    color: #fff;
    vertical-align: middle;
}

.device-alert-high {
    border-color: #b91c1c;
    border-width: 2px;
}

.device-alert-warn {
    border-color: #d97706;
}

.admin-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.admin-user-email {
    color: #fff;
    font-weight: 600;
}

.admin-user-roles {
    color: #9ca3af;
    font-size: 0.85rem;
}

.admin-signout {
    background: transparent;
    border-color: #4b5563;
    color: #e5e7eb;
}

.admin-signout:hover {
    border-color: #9ca3af;
    color: #fff;
}

.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.login-panel {
    width: 100%;
    max-width: 26rem;
    margin: 0;
}

.login-panel h1 {
    margin-top: 0;
}

.admin-main {
    padding: 1.25rem;
    max-width: 1400px;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    margin: 0 auto;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.page-header h1 {
    margin: 0.25rem 0;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: flex-start;
}

.analyze-action {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    max-width: 18rem;
}

.analyze-action-wide {
    max-width: 22rem;
}

.analysis-selection-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.analysis-lesson-picker {
    margin: 0 0 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.analysis-lesson-picker legend {
    padding-inline: 0.35rem;
    font-weight: 700;
}

.analysis-lesson-picker .analysis-selection-controls {
    margin-block: 0.65rem;
}

.analysis-lesson-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
    gap: 0.45rem;
    max-height: 24rem;
    overflow-y: auto;
}

.analysis-lesson-option {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    min-height: 3.25rem;
    padding: 0.55rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
}

.analysis-lesson-option.is-selected {
    border-color: var(--primary);
    background: #f0f7ff;
}

.analysis-lesson-option input {
    flex: 0 0 auto;
    width: 1.1rem;
    height: 1.1rem;
    margin-block-start: 0.15rem;
    accent-color: var(--primary);
}

.analysis-lesson-copy {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.analysis-lesson-copy strong {
    overflow-wrap: anywhere;
}

.analysis-lesson-status {
    display: inline-flex;
    flex: 0 0 auto;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    background: #ecfdf3;
    color: #166534;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.node-analysis-check {
    display: inline-flex;
    align-items: center;
    margin: 0;
    cursor: pointer;
}

.node-analysis-check input {
    width: 1rem;
    height: 1rem;
    accent-color: var(--primary);
    cursor: pointer;
}

.analyze-hint {
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.35;
}

/* Pupils about to overtake the analysis. Loud enough to be read before the buttons
   beneath it are pressed, because it is the reason to press one of them. */
.near-end-warning {
    margin: 0 0 0.5rem;
    padding: 0.5rem 0.7rem;
    border-radius: 8px;
    border: 1px solid #E0A800;
    background-color: #FFF6DC;
    color: #6B4E00;
    font-size: 0.87rem;
    font-weight: 600;
    line-height: 1.5;
}

/* Quiet setting under the one analyse button: which depth to run, not a second action. */
.analyze-mode {
    margin: 0.15rem 0 0;
    padding: 0.35rem 0 0;
    border: 0;
    border-block-start: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.analyze-mode:disabled {
    opacity: 0.55;
}

.analyze-mode-option {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem 0.5rem;
    margin: 0;
    padding-inline: 0.1rem;
    font-size: 0.85rem;
    cursor: pointer;
}

.analyze-mode-option input {
    margin: 0;
    flex-shrink: 0;
}

.analyze-mode-label {
    font-weight: 600;
}

.analyze-mode-desc {
    flex-basis: 100%;
    margin-inline-start: 1.35rem;
    font-size: 0.8rem;
    line-height: 1.3;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* The three stages a book goes through, drawn in the header so that "which button now" is
   answered before anyone reaches for one. Reads right to left with the rest of the page. */
.workflow-steps {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.75rem;
    margin: 0 0 0 0.5rem;
    padding: 0;
    list-style: none;
    font-size: 0.85rem;
}

.workflow-steps .step {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
    color: var(--muted, #6b7280);
}

.workflow-steps .step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    border: 1px solid var(--border);
    font-weight: 700;
}

/* The step being worked on is the only one that carries weight; a finished one is confirmed but
   quiet, and one not reached yet says nothing at all. */
.workflow-steps .step-current {
    color: var(--primary, #1d4ed8);
    font-weight: 700;
}

.workflow-steps .step-current .step-num {
    border-color: currentColor;
    background: var(--primary, #1d4ed8);
    color: #fff;
}

.workflow-steps .step-done .step-num {
    border-color: var(--success, #16a34a);
    color: var(--success, #16a34a);
}

.workflow-steps .step-todo {
    opacity: 0.55;
}

.workflow-steps .step-blocked {
    color: var(--danger, #9b1c1c);
    font-weight: 700;
}

.workflow-steps .step-blocked .step-num {
    border-color: var(--danger, #9b1c1c);
    background: var(--danger-bg, #fee2e2);
    color: var(--danger, #9b1c1c);
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.panel-danger {
    border-color: #f0b4b4;
    background: #fff8f8;
}

.panel-danger h2 {
    color: var(--danger);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.panel h2, .panel h3 {
    margin: 0 0 0.75rem;
}

.panel summary {
    cursor: pointer;
    font-weight: 600;
}

.exam-review-pagination-toolbar,
.exam-review-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.exam-review-pagination-toolbar {
    margin-top: 1rem;
}

.exam-review-page-size {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.exam-review-page-size .input {
    width: auto;
    min-width: 5rem;
}

.exam-review-pagination {
    margin: 1rem 0 2rem;
}

.muted {
    color: var(--muted);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
}

th, td {
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 0.6rem;
    text-align: right;
    vertical-align: top;
}

th {
    background: #fafafa;
}

.btn {
    display: inline-block;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    padding: 0.35rem 0.7rem;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    font: inherit;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--primary-text);
}

.btn-secondary {
    background: #fff;
}

.btn-danger {
    color: var(--danger);
    border-color: #f0b4b4;
}

.btn-small {
    padding: 0.15rem 0.4rem;
    font-size: 0.85rem;
}

.banner {
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.banner-error {
    background: var(--danger-bg);
    color: var(--danger);
}

.banner-info {
    background: var(--info-bg);
}

.offer-plans {
    border: 0;
    margin-block: 0.75rem;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.banner ul {
    margin: 0.3rem 0 0;
}

.status-badge {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-size: 0.85rem;
    border: 1px solid var(--border);
}

.status-uploaded { background: #f4f4f5; }
.status-draft { background: #fef3c7; color: var(--warn); }
.status-approved { background: #dbeafe; }
.status-busy { background: #ede9fe; }
.status-done { background: #dcfce7; color: var(--ok); }
.status-failed { background: var(--danger-bg); color: var(--danger); }

.form-grid {
    display: grid;
    gap: 0.85rem;
    max-width: 40rem;
    margin-bottom: 1rem;
}

label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* A checkbox with its words beside it, not under it. */
label.check-label {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

input, select, textarea, .input-title {
    font: inherit;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.input-narrow {
    width: 5.5rem;
}

.inline-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: end;
}

.editor-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(16rem, 0.9fr);
    gap: 1rem;
    align-items: start;
}

@media (max-width: 900px) {
    .editor-layout {
        grid-template-columns: 1fr;
    }
}

.node-tree {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.node-block {
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.4rem;
    background: #fff;
}

.node-selected {
    outline: 2px solid var(--primary);
}

.node-invalid {
    border-color: var(--danger);
    background: #fff8f8;
}

.node-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
    cursor: pointer;
}

.node-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.warning-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
    white-space: nowrap;
}

.node-visibility-select {
    padding: 0.15rem 0.35rem;
    font-size: 0.82rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
}

.node-visibility-select.is-hidden {
    border-color: #f87171;
    background: #fef2f2;
    color: #991b1b;
}

.node-visibility-select.is-kept {
    border-color: #86efac;
    background: #f0fdf4;
    color: #166534;
}

.input-title {
    min-width: 12rem;
    flex: 1;
}

.node-pdf {
    font-size: 0.85rem;
}

.node-errors {
    color: var(--danger);
    margin: 0.35rem 0 0;
}

.preview-pane {
    position: sticky;
    top: 0.75rem;
}

.preview-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: end;
    margin-bottom: 0.75rem;
}

.page-image {
    width: 100%;
    height: auto;
    border: 1px solid var(--border);
}

.progress-track {
    height: 0.6rem;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
    margin: 0.4rem 0 0.75rem;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
}

.row-failed {
    background: #fff1f1;
}

.content-block {
    border-top: 1px solid var(--border);
    padding: 0.75rem 0;
}

.pre-wrap {
    white-space: pre-wrap;
}

.question-list {
    padding-right: 1.2rem;
}

.question-item {
    margin-bottom: 1rem;
}

.question-item pre {
    white-space: pre-wrap;
    background: #fafafa;
    padding: 0.5rem;
    border: 1px solid var(--border);
}

.question-figure-review {
    margin: 0.75rem 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 40rem;
}

.question-figure-crop {
    /* Large enough to tell a map from neighbouring paragraph text — a thumbnail cannot do that job. */
    width: 100%;
    max-height: 28rem;
    height: auto;
    object-fit: contain;
    object-position: top;
    border: 1px solid var(--border);
    background: #fafafa;
}

.question-figure-page-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.figure-page-with-box {
    position: relative;
    width: 100%;
    border: 1px solid var(--border);
}

.figure-page-with-box .page-image {
    display: block;
    width: 100%;
    height: auto;
    border: 0;
}

.figure-box-marker {
    position: absolute;
    box-sizing: border-box;
    border: 2px solid var(--danger);
    background: color-mix(in srgb, var(--danger) 12%, transparent);
    pointer-events: none;
}

.lookup-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.lookup-list li {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.subject-icon {
    width: 1.5rem;
    height: 1.5rem;
    object-fit: contain;
    vertical-align: middle;
    margin-left: 0.35rem;
}

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    left: 0.75rem;
    top: 0.5rem;
}

/* Teacher pages */
.attention-band {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.attention-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.85rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font: inherit;
    color: inherit;
    text-align: center;
}

.attention-card-active {
    outline: 2px solid var(--primary);
}

.attention-card-danger .attention-count {
    color: var(--danger);
}

.attention-count {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}

.attention-label {
    font-size: 0.9rem;
    color: var(--muted);
}

.attention-filter-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0 0 1rem;
}

.stuck-lessons-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.stuck-lessons-list p {
    margin: 0;
}

.stuck-lesson-book {
    font-size: 0.9rem;
    margin-top: 0.15rem;
}

.join-code-display {
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: 0.25em;
    color: var(--primary);
    margin: 0.5rem 0 0.75rem;
    user-select: all;
}

.join-code-closed {
    font-weight: 600;
    margin: 0.5rem 0 0.75rem;
}

.join-code-hint {
    margin: 0.75rem 0 0.5rem;
}

.auto-approve-toggle {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    cursor: pointer;
}

.auto-approve-toggle input {
    width: auto;
    margin: 0;
}

.saved-indicator {
    font-size: 0.85rem;
    margin-right: 0.5rem;
}

.roster-search {
    margin-bottom: 0.75rem;
    max-width: 20rem;
}

.never-started {
    color: var(--danger);
}

.num-cell {
    text-align: left;
}

.pupil-headline {
    font-size: 15px;
    margin: 0 0 1rem;
    line-height: 1.7;
}

.activity-strip-wrap {
    margin-bottom: 1rem;
}

.activity-strip {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 3rem;
}

.activity-bar {
    flex: 1;
    min-width: 4px;
    background: var(--primary);
    border-radius: 2px 2px 0 0;
    min-height: 4px;
}

.activity-bar-zero {
    background: #e5e7eb;
    height: 4px;
}

.activity-strip-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 0.35rem;
    font-size: 0.85rem;
}

.next-step-panel {
    border-inline-start: 4px solid var(--primary);
    border-radius: 0;
}

.pupil-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.pupil-card h3 {
    margin: 0 0 0.75rem;
    font-size: 1rem;
}

/* Exam requests on the teacher's pupil page. */
.exam-choice {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin: 0.5rem 0 0.75rem;
}

.exam-choice label {
    display: flex;
    flex-direction: row;
    gap: 0.45rem;
    align-items: flex-start;
    cursor: pointer;
}

.exam-choice input[type="radio"],
.exam-choice input[type="checkbox"] {
    width: auto;
    flex: 0 0 auto;
    margin: 0.3rem 0 0;
}

.exam-picker {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-inline-start: 1.5rem;
    max-height: 18rem;
    overflow-y: auto;
}

.exam-subtitle {
    margin: 1rem 0 0.4rem;
    font-size: 0.95rem;
}

.pupil-card-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.score-ok {
    color: var(--ok);
}

.score-warn {
    color: var(--warn);
}

.pupil-points {
    font-size: 0.9rem;
    margin: 0;
}

@media (max-width: 700px) {
    .teacher-table thead {
        display: none;
    }

    .teacher-table,
    .teacher-table tbody,
    .teacher-table tr,
    .teacher-table td {
        display: block;
        width: 100%;
    }

    .teacher-table tr {
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 6px;
        margin-bottom: 0.75rem;
        padding: 0.5rem 0.75rem;
    }

    .teacher-table td {
        border: none;
        padding: 0.35rem 0;
        text-align: right;
    }

    .teacher-table td::before {
        content: attr(data-label);
        display: block;
        font-weight: 600;
        font-size: 0.85rem;
        color: var(--muted);
        margin-bottom: 0.15rem;
    }

    .teacher-table td:last-child {
        padding-top: 0.5rem;
    }

    .teacher-table td:last-child::before {
        display: none;
    }

    .teacher-table .num-cell {
        text-align: right;
    }
}

/* ==========================================================================
   Global Print Stylesheet
   Why: When any admin or reviewer triggers browser printing (e.g. printing a lesson),
   the global shell chrome (dark admin top header, blazor error dialogs) must not
   appear on physical paper or PDF exports, and the main container must span full width.
   ========================================================================== */
@media print {
    .admin-header,
    .admin-sidebar,
    #blazor-error-ui {
        display: none !important;
    }

    .admin-main {
        padding: 0 !important;
        margin: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    body {
        background: #ffffff !important;
        color: #000000 !important;
    }
}

/* ── Question-type mix per grade ──
   Four percentages that must add to 100. The live total is the whole point of the
   layout: it turns "did I get that right?" into something the eye answers, and the
   save button stays disabled until it says 100. */
.mix-table .mix-input {
    width: 4.5rem;
    text-align: center;
    padding-inline: 0.3rem;
}

.mix-grade {
    white-space: nowrap;
    font-weight: 600;
}

.mix-default-tag {
    display: block;
    font-size: 0.75rem;
    font-weight: 400;
}

.mix-total {
    font-weight: 700;
    white-space: nowrap;
}

.mix-total.is-ok {
    color: #15803D;
}

.mix-total.is-off {
    color: #B45309;
}

.mix-blank-hint {
    font-size: 0.75rem;
    font-weight: 400;
}

.mix-actual {
    font-size: 0.82rem;
    white-space: nowrap;
}

.mix-actions {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

/* Essay is the only type that costs money every time a child answers one, so the
   warning sits above the table rather than in a tooltip nobody opens. */
.mix-cost-note {
    margin: 0 0 1rem;
    padding: 0.6rem 0.8rem;
    border-radius: 8px;
    border: 1px solid #E0A800;
    background-color: #FFF6DC;
    color: #6B4E00;
    font-size: 0.87rem;
    line-height: 1.6;
}

/* ── Books list: filters ──
   One row of controls above the table, each with its label above it rather than
   beside it, so the row stays readable when a select widens to fit «الدراسات
   الاجتماعية». The count line underneath is deliberately always shown: it is the
   answer to "where did my book go?", and that question gets asked exactly when
   someone has forgotten a filter is on. */
.book-filters {
    margin-bottom: 1rem;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
}

.filter-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 8.5rem;
}

.filter-field-wide {
    flex: 1 1 16rem;
    min-width: 12rem;
}

.filter-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: #52525B;
}

.filter-clear {
    margin-block-end: 0.1rem;
}

.filter-summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-block-start: 0.75rem;
    padding-block-start: 0.6rem;
    border-block-start: 1px solid var(--border);
}

.filter-count {
    margin-inline-end: auto;
    font-size: 0.87rem;
    color: #3F3F46;
}

/* A deleted book, in its own view. Faded rather than struck through: it is still
   fully readable, because the reason to be on this screen is to find one and
   bring it back. */
.row-deleted td {
    opacity: 0.7;
}

.confirm-text {
    max-width: 34rem;
    line-height: 1.6;
}

/* Questions on the row. The count is the reason a reviewer opens this list; the
   badge beside it is how many nobody has read yet, which is the work remaining. */
.book-questions {
    white-space: nowrap;
}

.pending-badge {
    display: inline-block;
    margin-inline-start: 0.35rem;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    background-color: #FEF3C7;
    color: #7C4A03;
    border: 1px solid #FCD34D;
    font-size: 0.75rem;
    font-weight: 700;
}

/* ── Subscription state on an account row ── */
.sub-cell { white-space: nowrap; }

.sub-on {
    padding: 0.1rem 0.45rem;
    border-radius: 6px;
    background-color: #DCFCE7;
    color: #166534;
    border: 1px solid #86EFAC;
    font-size: 0.75rem;
    font-weight: 700;
}

/* Marked distinctly from a paid subscription on purpose: a grant is not revenue, and
   the row should never let someone read it as one. */
.sub-comp {
    margin-inline-start: 0.25rem;
    padding: 0.1rem 0.4rem;
    border-radius: 6px;
    background-color: #EDE9FE;
    color: #5B21B6;
    border: 1px solid #C4B5FD;
    font-size: 0.72rem;
    font-weight: 700;
}

.sub-ends {
    display: block;
    font-size: 0.72rem;
}

/* ── Stage card (pipeline stage card with state accent border) ── */
.stage-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--border);
    border-inline-start: 4px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.stage-card.stage-done {
    border-left-color: var(--ok, #166534);
    border-inline-start-color: var(--ok, #166534);
}

.stage-card.stage-current {
    border-left-color: var(--primary, #1f4b99);
    border-inline-start-color: var(--primary, #1f4b99);
}

.stage-card.stage-blocked {
    border-left-color: var(--danger, #9b1c1c);
    border-inline-start-color: var(--danger, #9b1c1c);
}

.stage-card.stage-todo {
    border-left-color: var(--border, #d4d4d8);
    border-inline-start-color: var(--border, #d4d4d8);
}

.stage-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.stage-card-title-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.stage-card-title-group h2,
.stage-card-title-group h3 {
    margin: 0;
}

.stage-card-toggle {
    margin-inline-start: auto;
}

.stage-blocked-reason {
    margin: 0.5rem 0;
    padding: 0.6rem 0.75rem;
    border-radius: 6px;
}

.stage-hint {
    margin: 0.5rem 0;
}

.stage-primary-action {
    margin: 0.75rem 0;
}

.stage-card-content {
    margin-top: 0.75rem;
}

/* ── Overflow dropdown menu ── */
.overflow-menu-container {
    position: relative;
    display: inline-block;
}

.overflow-menu-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    background: transparent;
}

.overflow-menu-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    inset-inline-end: 0;
    margin: 0;
    padding: 0.35rem 0;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
    z-index: 101;
    min-width: 12rem;
}

.overflow-menu-dropdown .menu-item {
    display: block;
    width: 100%;
    box-sizing: border-box;
    text-align: start;
    padding: 0.5rem 0.85rem;
    font: inherit;
    font-size: 0.875rem;
    background: transparent;
    border: 0;
    cursor: pointer;
    color: var(--text);
    white-space: nowrap;
}

.overflow-menu-dropdown .menu-item:hover:not(:disabled) {
    background: var(--bg);
}

.overflow-menu-dropdown .menu-item:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.overflow-menu-dropdown .menu-item-danger {
    color: var(--danger);
}

.overflow-menu-dropdown .menu-item-danger:hover:not(:disabled) {
    background: var(--danger-bg);
}

.overflow-menu-disabled {
    pointer-events: none;
    opacity: 0.6;
}

/* ── Filter chips ── */
.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    line-height: 1.4;
    transition: all 0.15s ease;
}

.filter-chip:hover {
    border-color: var(--primary);
}

.filter-chip.chip-active {
    background: var(--primary);
    color: var(--primary-text, #fff);
    border-color: var(--primary);
    font-weight: 600;
}

.filter-chip.chip-danger {
    color: var(--danger);
    border-color: #f0b4b4;
}

.filter-chip.chip-danger.chip-active {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

/* ── Approval bar (sticky above drafts list) ── */
.approval-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.approval-bar-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.approval-bar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-inline-start: auto;
}


/* ── Text link verification & lesson evidence ── */
.link-verdict {
    margin: 0.5rem 0 0.25rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.link-verdict.ok {
    color: var(--ok);
}

.link-verdict.warn {
    color: var(--warn);
}

.evidence-quote {
    margin: 0.5rem 0 0.25rem;
    padding: 0.5rem 0.75rem;
    border-inline-start: 3px solid var(--ok);
    background: var(--info-bg);
    border-radius: 6px;
    font-size: 0.95rem;
    line-height: 1.8;
    white-space: pre-wrap;
}

.evidence-caption {
    font-size: 0.8rem;
    margin: 0 0 0.5rem;
}

.alt-candidates {
    margin: 0.5rem 0;
}

.alt-candidates summary {
    color: var(--muted);
    cursor: pointer;
    font-size: 0.9rem;
    user-select: none;
}

.tag {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 4px;
    vertical-align: middle;
}

.tag-info {
    background: var(--info-bg);
    color: var(--primary);
}

.bulk-approval-scope {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    border: none;
    padding: 0;
    margin: 0;
    flex-wrap: wrap;
}

.bulk-scope-legend {
    font-size: 0.85rem;
    font-weight: 600;
    margin-inline-end: 0.25rem;
    padding: 0;
}

.bulk-scope-option {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    cursor: pointer;
}

.bulk-scope-hint {
    font-size: 0.75rem;
}

.primary-stage-action {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
}

.stage-action-hint {
    font-size: 0.8rem;
    margin: 0;
}

/* ------------------------------------------------------------------
   Reports (/analytics and the payment exceptions on /payments)
   ------------------------------------------------------------------ */

.report-hub {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

.report-hub-card {
    display: block;
    color: inherit;
    text-decoration: none;
}

a.report-hub-card:hover {
    border-color: var(--primary);
}

.report-hub-card h2 {
    margin-top: 0;
}

.report-card.is-auto-stopped {
    border-inline-start: 4px solid var(--danger);
}

.report-badges,
.report-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.report-actions {
    margin-top: 0.75rem;
}

.stopped-badge {
    background: var(--danger-bg);
    color: var(--danger);
    border-radius: 999px;
    padding: 0 0.6rem;
    font-size: 0.85rem;
}

.report-question {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.report-facts th {
    width: 12rem;
    font-weight: 500;
}

.report-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.report-kpi {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
}

.report-kpi strong {
    display: block;
    font-size: 1.5rem;
}

.report-table-wrap {
    overflow-x: auto;
}

.report-urgent td {
    background: var(--danger-bg);
}

.report-soon td {
    background: #fef3c7;
}

.report-small td {
    color: var(--muted);
}

/* Cohort cells: shade by rate so the table reads at a glance. */
.cohort-cell {
    text-align: center;
    min-width: 4.5rem;
}

.cohort-high { background: #bbf7d0; }
.cohort-mid { background: #fef08a; }
.cohort-low { background: #fecaca; }
.cohort-pending { color: var(--muted); }

/* Second batch: two or three small tables side by side, a bar per day, a row id to copy. */
.report-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
    align-items: start;
}

.report-id {
    font-size: 0.75rem;
    color: var(--muted);
    word-break: break-all;
}

.pulse-bars {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 140px;
    padding-bottom: 1.25rem;
    position: relative;
}

.pulse-bar-col {
    flex: 1 1 0;
    min-width: 6px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    position: relative;
}

.pulse-bar {
    width: 100%;
    background: var(--primary);
    border-radius: 3px 3px 0 0;
    min-height: 1px;
}

.pulse-bar-label {
    position: absolute;
    bottom: -1.25rem;
    font-size: 0.65rem;
    color: var(--muted);
}

/* The «؟» beside a report's title, and the explanation it opens. */
.report-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.report-help-button {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--primary);
    font-weight: 700;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    flex: none;
}

.report-help-button:hover,
.report-help-button:focus-visible {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 2px var(--primary);
}

.report-help-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 900;
}

.report-help-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(680px, calc(100vw - 2rem));
    max-height: calc(100vh - 3rem);
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    z-index: 901;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.25);
    text-align: start;
}

.report-help-dialog:focus {
    outline: none;
}

.report-help-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.report-help-head h2 {
    margin: 0;
}

.report-help-answers {
    font-weight: 600;
}

.report-help-dialog h3 {
    margin: 1rem 0 0.25rem;
    font-size: 1rem;
}

.report-help-dialog ul {
    margin: 0;
    padding-inline-start: 1.25rem;
}

.report-help-dialog li {
    margin-bottom: 0.35rem;
}

/* ── Pager (Components/Shared/Pager.razor) ── */
.pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    margin: 1rem 0 2rem;
}

.pager .btn {
    min-height: 2.5rem;
}

.pager-number {
    min-width: 2.5rem;
    text-align: center;
}

.pager-number[aria-current="page"] {
    cursor: default;
}

.pager-gap {
    padding: 0 0.15rem;
    color: var(--muted);
}

/* A count above a list, focused after a page change so the new page is read from its top. */
.results-heading {
    margin: 1.25rem 0 0.5rem;
    font-size: 1.1rem;
}

.results-heading:focus,
.focus-target:focus {
    outline: none;
}

/* A confirmation panel that just took focus is outlined, so the eye lands on it. */
.panel[tabindex="-1"]:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ── Tables that become cards (class="table-cards") ──
   Under 900px, where the side menu folds, a wide table cannot fit: each row becomes a card. A
   cell with data-label shows that label above its value; .card-title-cell and .row-actions take
   the card's full width, and so does an editor row's single colspan cell. The grid puts two or
   three fields side by side when the card has room for them. */
@media (max-width: 900px) {
    .table-cards thead {
        display: none;
    }

    .table-cards,
    .table-cards tbody {
        display: block;
        width: 100%;
        background: transparent;
    }

    .table-cards tr {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
        gap: 0.35rem 1rem;
        margin-bottom: 0.75rem;
        padding: 0.6rem 0.75rem;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 6px;
    }

    .table-cards td {
        display: block;
        min-width: 0;
        padding: 0;
        border: none;
    }

    /* An address, a user name or a link has no spaces to break at; it would push the card wide. */
    .table-cards .wrap-anywhere {
        overflow-wrap: anywhere;
    }

    .table-cards td[data-label]::before {
        content: attr(data-label);
        display: block;
        color: var(--muted);
        font-size: 0.8rem;
        font-weight: 600;
    }

    .table-cards .card-title-cell,
    .table-cards .row-actions,
    .table-cards td[colspan] {
        grid-column: 1 / -1;
    }

    /* The name leads the card and the buttons close it, wherever their columns sit in the table. */
    .table-cards .card-title-cell {
        order: -1;
        font-weight: 700;
    }

    .table-cards .row-actions {
        order: 1;
    }

    .table-cards .row-actions {
        margin-top: 0.25rem;
        padding-top: 0.6rem;
        border-top: 1px solid var(--border);
    }

    /* Touch targets: the desktop's small buttons are too small for a finger. */
    .table-cards .row-actions .btn {
        min-height: 2.5rem;
        padding: 0.35rem 0.8rem;
        font-size: 0.9rem;
    }

    /* An editor opened under a card belongs to that card, not to a card of its own. */
    .table-cards tr.subjects-editor-row {
        display: block;
        margin-top: -0.5rem;
        padding: 0;
        background: transparent;
        border: none;
    }
}

/* Every other table under 900px: a report or a grid of inputs compares across rows, which cards
   would break, so it scrolls sideways inside itself instead of making the whole page wider. */
@media (max-width: 900px) {
    table:not(.table-cards) {
        display: block;
        max-width: 100%;
        overflow-x: auto;
    }
}

/* A phone: 16px gutters, the page header stacked, and each form field on a line of its own. */
@media (max-width: 600px) {
    .admin-main {
        padding: 1rem;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .inline-fields > label {
        flex: 1 1 100%;
    }

    .inline-fields > label input,
    .inline-fields > label select {
        width: 100%;
        box-sizing: border-box;
    }
}
