.exams-stats { grid-template-columns: repeat(4, 1fr); }
.exams-stats .student-stat:nth-child(2) strong { color: var(--success); }
.exams-stats .student-stat:nth-child(3) strong { color: #d64545; }

.exam-table th,
.exam-table td { white-space: nowrap; }

.mark-input {
    width: 72px;
    padding: 7px 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font: inherit;
    text-align: center;
}
.mark-input.invalid { border-color: #d64545; background: #fdeaea; }
.mark-input.failing { color: #d64545; font-weight: 700; }

.exam-result {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 0.8rem;
    font-weight: 600;
}
.exam-result.pass { background: #e3f6ee; color: var(--success); }
.exam-result.fail { background: #fdeaea; color: #d64545; }
.exam-result.none { background: var(--background); color: var(--muted); }

.exam-banner {
    margin: 0 0 12px;
    padding: 10px 14px;
    border-radius: 10px;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-size: 0.9rem;
}

.exam-actions { display: inline-flex; gap: 10px; }

@media (max-width: 700px) {
    .exams-stats { grid-template-columns: repeat(2, 1fr); }
}

/* Excel marks import report */
#marksImportReport div { margin-top: 4px; font-size: 0.88rem; }
#marksImportReport[hidden] { display: none; }
.exam-banner-error { background: #fde8e8; color: #b53030; border-color: #f3b5b5; }

/* Admit cards */
.admit-batch { display: none; }
.admit-dialog { border: 1px solid var(--border); border-radius: 14px; padding: 20px 24px; width: calc(100% - 32px); max-width: 700px; }
.admit-dialog::backdrop { background: rgba(0, 0, 0, 0.4); }
.admit-dialog h2 { margin: 0 0 2px; }
.admit-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 14px 0; }
.admit-grid small { display: block; margin-top: 4px; font-size: 0.78rem; }
.admit-table { margin-bottom: 14px; }
.admit-table input { width: 100%; padding: 7px 8px; border: 1px solid var(--border); border-radius: 8px; font: inherit; }
.admit-dialog textarea { width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: 8px; font: inherit; resize: vertical; }
.admit-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.admit-dialog .set-error[hidden] { display: none; }

@media print {
    .printing-admit .student-page { display: none !important; }
    .printing-admit .admit-batch { display: block; }
    .admit-sheet { break-after: page; page-break-after: always; }
    .admit-sheet:last-child { break-after: auto; page-break-after: auto; }
    .admit-card { border: 1.5px solid #222; border-radius: 2mm; padding: 3mm 4mm; margin: 0 0 5mm; height: 131mm; box-sizing: border-box; overflow: hidden; font-size: 8.5pt; color: #111; background: #fff; }
    .ac-head { text-align: center; }
    .ac-logo { height: 11mm; width: 11mm; object-fit: contain; vertical-align: middle; margin-right: 2mm; }
    .ac-school { display: inline-block; vertical-align: middle; text-align: left; }
    .ac-school strong { display: block; font-size: 12pt; }
    .ac-school span { font-size: 7.5pt; color: #444; }
    .ac-banner { background: #1e3a8a; color: #fff; text-align: center; font-weight: 700; padding: 1.2mm; margin: 2mm 0; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .ac-student { width: 100%; border-collapse: collapse; margin-bottom: 2mm; }
    .ac-student th { width: 14mm; text-align: left; font-weight: 400; color: #555; padding: 0.6mm 1mm; vertical-align: top; }
    .ac-student td { font-weight: 600; padding: 0.6mm 1mm; vertical-align: top; }
    .ac-student td.ac-ph { width: 25mm; padding-right: 2mm; }
    .ac-photo { width: 22mm; height: 27mm; border: 1px solid #222; background-size: cover; background-position: center; text-align: center; line-height: 27mm; font-size: 7pt; color: #666; }
    .ac-sched { width: 100%; border-collapse: collapse; margin-bottom: 1.5mm; }
    .ac-sched th, .ac-sched td { border: 1px solid #222; padding: 0.8mm 1.5mm; text-align: left; }
    .ac-sched th { background: #eef2ff; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .ac-report { margin: 0 0 1.5mm; font-weight: 600; }
    .ac-rules { margin: 0 0 3mm; padding-left: 4mm; font-size: 7.5pt; }
    .ac-sign { width: 100%; border-collapse: separate; border-spacing: 6mm 0; margin-top: 7mm; }
    .ac-sign td { width: 33%; text-align: center; border-top: 1px solid #222; padding-top: 1mm; font-size: 7.5pt; }
}

/* ===== Dialog buttons and marks entry on phones ===== */
@media screen and (max-width: 700px), screen and (max-height: 700px) {
    .admit-actions {
        position: sticky;
        bottom: -20px;
        margin: 14px -24px -20px;
        padding: 12px 24px;
        background: var(--surface, #fff);
        border-top: 1px solid var(--border, #e8ecf3);
        z-index: 2;
    }
}
/* Marks entry on phones: keep roll no. and student name fixed while you scroll sideways */
@media screen and (max-width: 700px) {
    .exam-table th:nth-child(1), .exam-table td:nth-child(1) { position: sticky; left: 0; z-index: 2; background: #fff; min-width: 38px; }
    .exam-table th:nth-child(2), .exam-table td:nth-child(2) {
        position: sticky; left: 38px; z-index: 2; background: #fff;
        box-shadow: 6px 0 8px -6px rgba(23, 35, 62, .25);
    }
    .exam-table thead th:nth-child(1), .exam-table thead th:nth-child(2) { background: #fafbfe; z-index: 3; }
    .exam-table td:nth-child(2) { max-width: 130px; overflow: hidden; text-overflow: ellipsis; }
}
