:root {
  --bg: #f4f3f2;
  --surface: #ffffff;
  --surface-2: #f8f7f6;
  --ink: #1d1a1a;
  --muted: #706b6b;
  --line: #ded9d7;
  --brand: #7a1f2b;
  --brand-dark: #4c1119;
  --brand-soft: #f5e9eb;
  --gold: #d9aa42;
  --green: #27745b;
  --amber: #9a6508;
  --red: #a12b36;
  --blue: #2f608f;
  --shadow: 0 14px 36px rgba(54, 31, 34, 0.09);
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  letter-spacing: 0;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 64px;
  color: #fff;
  background: var(--brand-dark);
  border-bottom: 3px solid var(--gold);
}

.topbar-inner {
  width: min(1280px, calc(100% - 40px));
  height: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 26px;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 292px;
  gap: 9px;
  font-weight: 800;
}

.brand-logo { flex: 0 0 43px; width: 43px; height: 43px; object-fit: contain; }

.brand-copy { display: grid; line-height: 1.1; }
.brand-copy small { margin-top: 4px; color: rgba(255,255,255,.66); font-size: 10px; font-weight: 650; }

.nav { display: flex; align-self: stretch; gap: 3px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 15px;
  color: rgba(255,255,255,.72);
  font-weight: 650;
  border-bottom: 3px solid transparent;
}
.nav a:hover, .nav a.active { color: #fff; background: rgba(255,255,255,.06); border-bottom-color: var(--gold); }

.user-menu { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-name { color: rgba(255,255,255,.72); font-size: 12px; }

.app-shell { width: min(1280px, calc(100% - 40px)); margin: 0 auto; padding: 26px 0 60px; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 20px;
}
.page-head h1 { margin: 0; font-size: 25px; line-height: 1.25; }
.page-head p { margin: 6px 0 0; color: var(--muted); }
.page-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.student-page-actions { align-items: center; flex-wrap: nowrap; }
.student-search-form { display: flex; align-items: center; gap: 8px; }
.student-search-form .input { width: 310px; }
.student-name-link { display: inline-flex; align-items: center; gap: 4px; color: var(--ink); }
.student-name-link:hover { color: var(--brand); }
.student-name-link svg { width: 16px; height: 16px; color: var(--brand); }
.student-average-score { color: var(--brand); font-weight: 800; }
.score-overview-table { min-width: 1040px; table-layout: fixed; }
.score-overview-table th, .score-overview-table td { padding: 8px 7px; border: 1px solid #d7d3d1; text-align: center; }
.score-overview-table thead th { color: #fff; font-size: 11px; }
.score-overview-table .overview-student-head, .score-overview-table .overview-total-head { width: 114px; background: #88898c; }
.score-overview-table .overview-listening { background: #1687a8; }
.score-overview-table .overview-reading { background: #27865d; }
.score-overview-table .overview-cloze { background: #356f9d; }
.score-overview-table .overview-grammar { background: #b85c63; }
.score-overview-table .overview-essay { background: #397858; }
.score-overview-table tbody td:first-child { text-align: left; }
.score-overview-table tbody td:first-child a { display: grid; gap: 1px; }
.score-overview-table tbody td:first-child small { color: var(--muted); font-size: 10px; font-weight: 500; }
.score-overview-table .overview-total { background: #f2f1f0; font-size: 15px; }
.score-overview-table .overview-total a { display: grid; gap: 1px; }
.score-overview-table .overview-total small { color: var(--amber); font-size: 9px; }
.score-overview-table .overview-absence { color: #8b2530; background: #faf1f2; font-weight: 800; letter-spacing: 0; }
.score-overview-table .is-absent td:first-child { color: var(--muted); }
.score-overview-table tfoot th, .score-overview-table tfoot td { color: #b52218; background: #fffafa; font-weight: 850; }
.exam-page-head { align-items: center; }
.exam-heading-summary { display: flex; flex: 1 1 auto; align-items: center; min-width: 0; gap: 22px; }
.exam-heading-copy { flex: 0 1 auto; min-width: 250px; }
.exam-score-statistics { display: grid; grid-template-columns: repeat(4, minmax(62px, 1fr)); min-width: 300px; margin: 0; padding-left: 18px; border-left: 1px solid var(--line); }
.exam-score-statistics > div { display: grid; gap: 1px; min-width: 0; padding: 0 11px; border-right: 1px solid #e7e2df; }
.exam-score-statistics > div:last-child { border-right: 0; }
.exam-score-statistics dt { color: var(--muted); font-size: 10px; font-weight: 700; white-space: nowrap; }
.exam-score-statistics dd { margin: 0; color: var(--brand); font-size: 19px; font-weight: 820; line-height: 1.25; font-variant-numeric: tabular-nums; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: 0 5px 18px rgba(42, 26, 28, .035);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2, .panel-head h3 { margin: 0; font-size: 15px; }
.panel-body { padding: 16px; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric { padding: 15px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; }
.metric-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin-top: 5px; font-size: 27px; line-height: 1.15; }
.metric-icon { color: var(--brand); }

.two-col { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(290px, 1fr); gap: 16px; }
.stack { display: grid; gap: 16px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 13px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cfc9c7;
  border-radius: 6px;
  font-weight: 700;
}
.btn:hover { background: var(--surface-2); border-color: #b7aeac; }
.btn-primary { color: #fff; background: var(--brand); border-color: var(--brand); }
.btn-primary:hover { background: #681823; border-color: #681823; }
.btn-danger { color: var(--red); background: #fff; border-color: #dcbac0; }
.btn-quiet { color: rgba(255,255,255,.76); background: transparent; border-color: rgba(255,255,255,.25); min-height: 33px; padding: 6px 9px; }
.btn-sm { min-height: 31px; padding: 5px 9px; font-size: 12px; }
.btn-icon { width: 34px; min-width: 34px; padding: 0; }
.btn svg { width: 16px; height: 16px; }

.field { display: grid; gap: 6px; }
.field label { font-size: 12px; font-weight: 750; color: #474141; }
.status-fieldset { min-width: 0; margin-right: 0; margin-left: 0; padding: 0; border: 0; }
.status-fieldset legend { margin-bottom: 7px; color: #474141; font-size: 12px; font-weight: 750; }
.status-picker { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; max-width: 520px; }
.status-picker input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.status-picker label { display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 0; height: 42px; color: #514b49; background: #fff; border: 1px solid #d1cbc8; border-radius: 6px; font-size: 13px; font-weight: 750; cursor: pointer; transition: color .16s ease, background .16s ease, border-color .16s ease, box-shadow .16s ease; }
.status-picker label:hover { color: var(--brand); border-color: #a7797e; background: #fdf9f9; }
.status-picker label svg { flex: 0 0 auto; width: 17px; height: 17px; }
.status-picker input:checked + label { color: #fff; background: var(--brand); border-color: var(--brand); box-shadow: 0 2px 7px rgba(97,24,34,.18); }
.status-picker input:focus-visible + label { outline: 2px solid rgba(122,31,43,.35); outline-offset: 2px; }
.class-fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.class-fieldset legend { margin-bottom: 8px; color: #3e3937; font-size: 13px; font-weight: 750; }
.class-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.class-picker input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.class-picker label { display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 0 14px; color: #514b49; background: #fff; border: 1px solid #d1cbc8; border-radius: 6px; font-size: 13px; font-weight: 750; cursor: pointer; transition: color .16s ease, background .16s ease, border-color .16s ease, box-shadow .16s ease; }
.class-picker label:hover { color: var(--brand); border-color: #a7797e; background: #fdf9f9; }
.class-picker label svg { width: 16px; height: 16px; }
.class-picker input:checked + label { color: #fff; background: var(--brand); border-color: var(--brand); box-shadow: 0 2px 7px rgba(97,24,34,.18); }
.class-picker input:focus-visible + label { outline: 2px solid rgba(122,31,43,.35); outline-offset: 2px; }
.field-note { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.class-picker-empty { padding: 12px 14px; color: var(--muted); background: #f8f6f5; border: 1px solid #e2dcda; border-radius: 6px; font-size: 13px; }
.input, select, textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #c9c3c1;
  border-radius: 5px;
  outline: none;
}
textarea { resize: vertical; }
.input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(122,31,43,.13); }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.help { color: var(--muted); font-size: 12px; }
.live-search-empty { padding: 22px 12px; color: var(--muted); text-align: center; font-size: 12px; }
.account-panel { width: min(520px, 100%); }
.account-panel form { display: grid; gap: 14px; }

.flash-wrap { display: grid; gap: 8px; margin-bottom: 16px; }
.flash { padding: 10px 13px; border: 1px solid; border-radius: 6px; font-weight: 650; }
.flash.success { color: #175b45; background: #e9f4ef; border-color: #b7d7ca; }
.flash.error { color: #81202a; background: #f8e9eb; border-color: #e2b9bf; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #ece8e6; vertical-align: middle; }
th { color: var(--muted); background: #faf9f8; font-size: 11px; font-weight: 800; white-space: nowrap; }
tbody tr:hover { background: #fcfbfa; }
.submission-clickable-row, .clickable-table-row { cursor: pointer; }
.submission-clickable-row:hover, .clickable-table-row:hover { background: #f8f2f3; }
.submission-clickable-row:focus-visible, .clickable-table-row:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; background: #f8f2f3; }
.submission-clickable-row [data-row-actions], .clickable-table-row [data-row-actions] { cursor: default; }
td.num { font-variant-numeric: tabular-nums; font-weight: 750; }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }

.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 4px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.badge-queued, .badge-processing { color: #2c547a; background: #e6eef6; }
.badge-ready { color: #6d4c05; background: #f7eed9; }
.badge-review, .badge-error { color: #8b2530; background: #f7e6e8; }
.badge-graded { color: #23664f; background: #e4f2ec; }
.badge-draft { color: #6b6562; background: #eeeae8; }
.badge-active { color: #23664f; background: #e4f2ec; }
.badge-closed { color: #514d4b; background: #e7e4e2; }
.badge-scan-assigned { color: #23664f; background: #e4f2ec; }
.badge-scan-received, .badge-scan-awaiting_pair { color: #6d4c05; background: #f7eed9; }
.badge-scan-needs_assignment, .badge-scan-duplicate, .badge-scan-error { color: #8b2530; background: #f7e6e8; }
.badge-phase-completed { color: #23664f; background: #e4f2ec; }
.badge-phase-pending, .badge-phase-waiting { color: #6d4c05; background: #f7eed9; }
.badge-phase-processing { color: #2c547a; background: #e6eef6; }
.badge-phase-review, .badge-phase-error { color: #8b2530; background: #f7e6e8; }

.empty { padding: 34px 18px; text-align: center; color: var(--muted); }
.empty svg { width: 30px; height: 30px; margin-bottom: 8px; color: #a69e9b; }

.tabs {
  display: flex;
  gap: 6px;
  margin: 0;
  padding: 0 16px;
  overflow-x: auto;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.tab {
  appearance: none;
  flex: 0 0 auto;
  min-height: 50px;
  padding: 0 14px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}
.tab:hover { color: var(--ink); background: #faf8f8; }
.tab:focus-visible { outline: 2px solid var(--brand); outline-offset: -4px; }
.tab.active { color: var(--brand); background: transparent; border-bottom-color: var(--brand); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.answer-score-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 10px; background: var(--line); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; gap: 1px; }
.answer-score-summary > div { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 38px; padding: 7px 10px; background: #f8f6f5; }
.answer-score-summary span { color: var(--muted); font-size: 10px; }
.answer-score-summary strong { color: var(--brand); font-size: 11px; white-space: nowrap; }
.answer-entry-toolbar { display: flex; justify-content: flex-end; margin-bottom: 10px; }
.quick-answer-panel[hidden] { display: none; }
.quick-answer-panel { display: grid; gap: 10px; margin-bottom: 12px; padding: 12px; background: #faf9f8; border: 1px solid #d8d1cf; border-radius: 6px; }
.quick-answer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.quick-answer-head > div { display: flex; align-items: baseline; gap: 10px; }
.quick-answer-head strong { font-size: 14px; }
.quick-answer-head span { color: var(--brand); font-size: 11px; font-weight: 750; }
.quick-answer-editor { display: grid; grid-template-columns: 52px minmax(0, 1fr); height: 420px; overflow: hidden; background: #fff; border: 1px solid #c9c3c1; border-radius: 5px; }
.quick-answer-editor:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(122,31,43,.13); }
.quick-answer-lines { height: 100%; overflow: hidden; color: #7a7371; background: #f3f0ef; border-right: 1px solid #ddd7d4; text-align: center; font-size: 12px; font-variant-numeric: tabular-nums; user-select: none; }
.quick-answer-lines > div { padding: 9px 0; will-change: transform; }
.quick-answer-lines span { display: block; height: 28px; line-height: 28px; }
.quick-answer-editor textarea { height: 100%; min-height: 0; padding: 9px 12px; overflow-x: hidden; overflow-y: auto; border: 0; border-radius: 0; box-shadow: none; resize: none; font-family: "IBM Plex Sans SC", ui-monospace, monospace; font-size: 14px; font-weight: 750; line-height: 28px; letter-spacing: 0; text-transform: uppercase; white-space: pre; }
.quick-answer-editor textarea:focus { border: 0; box-shadow: none; }
.quick-answer-feedback { min-height: 18px; color: var(--muted); font-size: 11px; }
.quick-answer-feedback.is-error { color: var(--red); font-weight: 700; }
.answer-grid { display: grid; grid-template-rows: repeat(10, 96px); grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 7px; }
.answer-item { min-width: 0; padding: 8px; background: #faf9f8; border: 1px solid #e5e0de; border-radius: 6px; }
.answer-item:hover { background: #fff; border-color: #cfc5c3; }
.answer-item-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 7px; }
.answer-number { font-weight: 850; }
.answer-card-title { display: flex; align-items: baseline; min-width: 0; gap: 6px; }
.answer-card-title small { overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.answer-card-score { display: flex; align-items: center; flex: 0 0 auto; gap: 4px; }
.answer-card-score span { color: var(--muted); font-size: 9px; }
.answer-score { width: 47px; min-height: 27px; padding: 3px 4px; text-align: center; font-size: 11px; font-variant-numeric: tabular-nums; }
.answer-alternative-input { min-height: 34px; padding: 5px 7px; font-size: 11px; }
.choice-set { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; }
.choice-set input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.choice-set label { display: grid; place-items: center; height: 30px; color: #514b49; background: #fff; border: 1px solid #d4cecb; border-radius: 4px; font-weight: 800; cursor: pointer; }
.choice-set input:checked + label { color: #fff; background: var(--brand); border-color: var(--brand); }
.choice-set input:focus-visible + label { outline: 2px solid rgba(122,31,43,.35); outline-offset: 2px; }
.answer-key-choices { width: 100%; }
.answer-key-choices label { height: 34px; font-size: 11px; }
.answer-save-bar { position: sticky; bottom: 10px; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 18px; padding: 10px 12px; background: rgba(255,255,255,.96); border: 1px solid #d7d1ce; border-radius: 6px; box-shadow: 0 8px 24px rgba(50,31,33,.12); backdrop-filter: blur(8px); }
.answer-save-bar > div { display: flex; align-items: baseline; gap: 9px; }
.answer-save-bar strong { color: var(--brand); }
.answer-save-bar span { color: var(--muted); font-size: 11px; }
[data-answer-key-form].quick-entry-open .answer-save-bar { position: static; }

.upload-zone { padding: 38px 20px; text-align: center; background: #fbfaf9; border: 1px dashed #bdb5b2; border-radius: 6px; }
.upload-zone input { max-width: 520px; }
.upload-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0; }
.upload-step { display: flex; gap: 10px; padding: 12px; background: var(--surface-2); border-radius: 6px; }
.step-number { display: grid; place-items: center; flex: 0 0 25px; height: 25px; color: #fff; background: var(--brand); border-radius: 50%; font-weight: 800; }

.review-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(430px, .75fr); gap: 16px; align-items: start; }
.scan-viewer { position: sticky; top: 86px; overflow: hidden; background: #292525; border-radius: 7px; }
.scan-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 9px 11px; color: #fff; background: #3b3334; }
.scan-tabs { display: flex; gap: 5px; }
.scan-tabs button { padding: 5px 9px; color: rgba(255,255,255,.7); background: transparent; border: 1px solid rgba(255,255,255,.2); border-radius: 4px; }
.scan-tabs button.active { color: #251d1e; background: var(--gold); border-color: var(--gold); }
.scan-image-wrap { max-height: calc(100vh - 150px); overflow: auto; text-align: center; }
.scan-image { display: block; max-width: 100%; margin: 0 auto; }
.issue-list { display: grid; gap: 7px; margin-bottom: 12px; }
.issue { display: flex; gap: 8px; padding: 9px 10px; color: #7a242d; background: #f8e9eb; border-left: 3px solid var(--red); }
.issue.warning { color: #72510b; background: #fbf2df; border-left-color: var(--amber); }
.review-answer-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.review-answer { padding: 7px; background: #faf9f8; border: 1px solid #e6e1de; border-radius: 5px; }
.review-answer .choice-set label { height: 27px; font-size: 11px; }
.review-answer .choice-set input:checked + label { color: #fff; background: #b55a14; border-color: #b55a14; }
.review-answer .choice-set input[data-correct="true"]:checked + label { color: #fff; background: #23664f; border-color: #23664f; }
.answer-color-legend { display: flex; align-items: center; gap: 13px; color: var(--muted); font-size: 11px; font-weight: 700; }
.answer-color-legend span { display: flex; align-items: center; gap: 5px; }
.answer-color-legend i { width: 10px; height: 10px; background: #b55a14; border-radius: 2px; }
.answer-color-legend i.is-correct { background: #23664f; }
.recognized-note { margin-top: 4px; color: var(--muted); font-size: 10px; }
.score-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }

.paper-page-head { align-items: center; margin-bottom: 12px; }
.paper-record-navigation { display: grid; grid-template-columns: 34px auto 34px; align-items: center; overflow: hidden; min-height: 38px; background: #fff; border: 1px solid #d4cecb; border-radius: 5px; }
.paper-record-navigation a, .paper-record-navigation > span { display: grid; place-items: center; width: 34px; height: 36px; color: var(--brand); }
.paper-record-navigation a:hover { background: var(--brand-soft); }
.paper-record-navigation > span.disabled { color: #c7c1be; }
.paper-record-navigation strong { padding: 0 9px; font-size: 11px; font-variant-numeric: tabular-nums; }
.paper-record-navigation svg { width: 18px; height: 18px; }
.paper-menu { position: relative; }
.paper-menu summary { list-style: none; }
.paper-menu summary::-webkit-details-marker { display: none; }
.paper-menu[open] summary { color: #fff; background: var(--brand); border-color: var(--brand); }
.paper-menu-popover { position: absolute; top: calc(100% + 7px); right: 0; z-index: 15; display: grid; width: 220px; padding: 6px; background: #fff; border: 1px solid #cfc8c5; border-radius: 6px; box-shadow: 0 16px 38px rgba(43, 25, 28, .18); }
.paper-menu-popover a { display: flex; align-items: center; gap: 9px; min-height: 40px; padding: 8px 10px; border-radius: 4px; font-weight: 700; }
.paper-menu-popover a:hover { color: var(--brand); background: var(--brand-soft); }
.paper-menu-popover svg { width: 16px; height: 16px; color: var(--brand); }
.paper-score-band { display: grid; grid-template-columns: minmax(230px, auto) 1fr auto; align-items: center; gap: 28px; margin-bottom: 12px; padding: 12px 18px; background: #fff; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.paper-score-value { display: flex; align-items: baseline; gap: 7px; font-variant-numeric: tabular-nums; }
.paper-score-value strong { font-size: 30px; line-height: 1; }
.paper-score-value span { color: var(--muted); font-size: 15px; font-weight: 750; }
.paper-score-value b { margin-left: 8px; color: var(--brand); font-size: 17px; }
.paper-student-identity { display: grid; }
.paper-student-identity strong { font-size: 17px; }
.paper-student-identity span { color: var(--muted); font-size: 12px; }
body:has(.paper-review-shell) .app-shell { padding-bottom: 10px; }
.paper-review-shell { padding-bottom: 6px; }
.paper-review-workspace { display: grid; grid-template-columns: minmax(400px, .82fr) minmax(650px, 1.28fr); gap: 14px; height: clamp(460px, calc(100vh - 263px), 940px); min-height: 0; }
.paper-scan-column, .paper-analysis-column { display: grid; grid-template-rows: auto minmax(0, 1fr); min-width: 0; min-height: 0; }
.paper-analysis-column { overflow: hidden; background: #fff; border: 1px solid var(--line); border-radius: 7px; }
.paper-workspace-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 46px; padding: 0 2px 9px; }
.paper-analysis-column > .paper-workspace-heading { min-height: 51px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.paper-workspace-heading h2 { margin: 0; font-size: 15px; }
.paper-workspace-heading > div:first-child { display: grid; min-width: 0; }
.paper-workspace-heading > div:first-child > span { color: var(--muted); font-size: 10px; }
.paper-analysis-legend { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 9px; font-weight: 700; white-space: nowrap; }
.paper-analysis-legend span { display: flex; align-items: center; gap: 4px; }
.paper-analysis-legend i { width: 8px; height: 8px; background: #aaa4a1; border-radius: 2px; }
.paper-analysis-legend .is-correct { background: var(--green); }
.paper-analysis-legend .is-partial { background: var(--amber); }
.paper-analysis-legend .is-incorrect { background: var(--red); }
.paper-image-viewer { display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; overflow: hidden; background: #302c2d; border: 1px solid #484143; border-radius: 7px; }
.paper-image-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 9px; min-height: 46px; padding: 6px 8px; color: #fff; background: #3b3435; border-bottom: 1px solid #504849; }
.paper-page-options { display: flex; min-width: 0; gap: 5px; overflow-x: auto; }
.paper-page-options button { flex: 0 0 auto; min-height: 32px; padding: 5px 8px; color: rgba(255,255,255,.7); background: transparent; border: 1px solid rgba(255,255,255,.2); border-radius: 4px; font-size: 11px; font-weight: 700; }
.paper-page-options button:hover { color: #fff; border-color: rgba(255,255,255,.42); }
.paper-page-options button.active { color: #302728; background: var(--gold); border-color: var(--gold); }
.paper-image-tools { display: flex; flex: 0 0 auto; align-items: center; gap: 5px; }
.paper-image-stage { display: grid; place-items: start center; min-height: 0; padding: 8px; overflow: auto; background: #242122; }
.paper-image-stage img { display: block; width: auto; height: auto; max-width: none; max-height: none; margin: 0 auto; object-fit: contain; background: #fff; transform-origin: top center; }
.paper-analysis-scroll { min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.paper-section-panel { padding: 10px 12px 12px; border-bottom: 1px solid var(--line); }
.paper-subsection-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 28px; margin-bottom: 6px; }
.paper-subsection-head h3 { margin: 0; font-size: 13px; }
.paper-subsection-head > span { color: var(--muted); font-size: 9px; font-weight: 650; }
.paper-section-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); overflow: hidden; background: var(--line); border: 1px solid var(--line); border-radius: 5px; gap: 1px; }
.paper-section-summary-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 5px 8px; min-width: 0; min-height: 57px; padding: 7px 9px; background: #fff; }
.paper-section-summary-item > div:first-child { display: flex; grid-column: 1 / -1; align-items: center; justify-content: space-between; gap: 7px; min-width: 0; }
.paper-section-summary-item strong { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.paper-section-summary-item b { color: var(--brand); font-size: 12px; font-variant-numeric: tabular-nums; }
.paper-section-summary-item > span { color: var(--muted); font-size: 9px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.paper-section-summary-item .bar { height: 5px; }
.paper-question-panel { padding: 8px 12px 12px; }
.paper-question-groups { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); overflow: hidden; border: 1px solid var(--line); border-radius: 5px; }
.paper-question-group { min-width: 0; border-right: 1px solid var(--line); }
.paper-question-group:last-child { border-right: 0; }
.paper-question-group-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-height: 29px; padding: 5px 7px; color: #4f4846; background: #f2efed; border-bottom: 1px solid var(--line); }
.paper-question-group-head strong { font-size: 10px; }
.paper-question-group-head span { color: var(--muted); font-size: 8px; }
.paper-question-item { display: grid; grid-template-columns: 24px minmax(0, 1fr) 44px 20px; align-items: center; gap: 5px; min-height: 29px; padding: 3px 6px; border-bottom: 1px solid #eeeae8; font-size: 10px; font-variant-numeric: tabular-nums; }
.paper-question-item:last-child { border-bottom: 0; }
.paper-question-item:hover { background: #faf8f7; }
.paper-question-number { color: #4b4543; font-size: 11px; }
.paper-answer-comparison { display: flex; align-items: center; min-width: 0; gap: 3px; }
.paper-answer-comparison > span, .paper-answer-comparison > strong { max-width: 44%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.paper-answer-comparison > span { color: var(--muted); }
.paper-answer-comparison > svg { flex: 0 0 auto; width: 10px; height: 10px; color: #aaa29f; }
.paper-answer-comparison > em { flex: 0 0 auto; padding: 0 2px; color: #6d4c05; background: #f7eed9; border-radius: 2px; font-size: 7px; font-style: normal; font-weight: 800; }
.paper-question-score { color: var(--muted); text-align: right; white-space: nowrap; }
.paper-result { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; }
.paper-result svg { width: 14px; height: 14px; }
.result-correct { color: var(--green); background: #e5f2ed; }
.result-incorrect { color: var(--red); background: #f8e7e9; }
.result-partial { color: var(--amber); background: #f8eedb; }
.result-unscored { color: #7d7674; background: #ece9e7; }

.bar { height: 8px; overflow: hidden; background: #ece7e5; border-radius: 4px; }
.bar > span { display: block; height: 100%; background: var(--brand); }
.accuracy-grid { display: grid; grid-template-columns: repeat(5, minmax(110px, 1fr)); gap: 8px; }
.accuracy-item { padding: 10px; border: 1px solid #e4dfdc; border-radius: 6px; }
.accuracy-item-top { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; font-size: 12px; }

.analysis-filter-panel { width: min(520px, 100%); margin: 0 0 16px auto; }
.analysis-filter-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; }
.analysis-filter-form .field { width: 218px; }
.analysis-filter-form select { min-height: 36px; padding: 6px 9px; font-size: 12px; }
.analysis-filter-form .btn { min-height: 36px; }
.section-accuracy-panel { margin-bottom: 16px; overflow: hidden; }
.section-accuracy-table-wrap { overflow-x: auto; }
.section-accuracy-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.section-accuracy-table.is-listening { min-width: 1034px; }
.section-accuracy-table.is-reading { min-width: 520px; }
.section-accuracy-table th, .section-accuracy-table td { min-width: 94px; padding: 10px 8px; border-right: 1px solid #e5dfdc; text-align: center; }
.section-accuracy-table th:last-child, .section-accuracy-table td:last-child { border-right: 0; }
.section-accuracy-table th { color: #4e4745; background: #faf9f8; border-bottom: 1px solid #e5dfdc; font-size: 11px; }
.section-accuracy-table th strong, .section-accuracy-table th small, .section-accuracy-table td strong, .section-accuracy-table td small { display: block; }
.section-accuracy-table th strong { font-size: 11px; }
.section-accuracy-table th small { margin-top: 2px; color: var(--muted); font-size: 9px; font-weight: 600; }
.section-accuracy-table td strong { color: var(--brand); font-size: 18px; font-variant-numeric: tabular-nums; }
.section-accuracy-table td small { margin-top: 2px; color: var(--muted); font-size: 9px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.item-analysis-panel { overflow: hidden; }
.item-analysis-header, .item-analysis-row { display: grid; grid-template-columns: 90px 130px minmax(360px, 1fr) 110px 64px; align-items: center; gap: 16px; }
.item-analysis-header { min-height: 44px; padding: 8px 16px; color: var(--muted); background: #faf9f8; border-bottom: 1px solid var(--line); font-size: 11px; font-weight: 800; }
.item-analysis-header > :last-child { text-align: center; }
.analysis-sort-link { display: inline-flex; align-items: center; justify-content: flex-start; gap: 5px; width: fit-content; min-height: 30px; padding: 4px 6px; margin-left: -6px; color: inherit; border-radius: 5px; }
.analysis-sort-link:hover { color: var(--brand); background: #f2ecec; }
.analysis-sort-link.is-active { color: var(--brand); }
.analysis-sort-link.is-centered { justify-self: center; justify-content: center; margin-left: 0; }
.analysis-sort-link svg { width: 14px; height: 14px; }
.analysis-sort-link:focus-visible { outline: 2px solid rgba(122,31,43,.35); outline-offset: 1px; }
.item-analysis-list { display: grid; }
.item-analysis-row { min-height: 116px; padding: 13px 16px; border-bottom: 1px solid #ece8e6; }
.item-analysis-row:last-child { border-bottom: 0; }
.item-analysis-row:hover { background: #fcfbfa; }
.analysis-question { display: grid; align-content: center; }
.analysis-question strong { font-size: 24px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.analysis-question span { margin-top: 4px; color: var(--muted); font-size: 11px; }
.analysis-question small { margin-top: 1px; color: var(--brand); font-size: 10px; font-weight: 750; }
.analysis-accuracy { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 5px 8px; }
.analysis-accuracy strong { color: var(--brand); font-size: 20px; font-variant-numeric: tabular-nums; }
.analysis-accuracy > span { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.analysis-accuracy .bar { grid-column: 1 / -1; }
.response-frequency { display: flex; align-items: flex-end; min-width: 0; gap: 12px; }
.response-option { appearance: none; display: grid; grid-template-columns: 44px; justify-items: center; gap: 1px; flex: 0 0 44px; min-width: 0; padding: 0; color: inherit; background: transparent; border: 0; border-radius: 4px; font: inherit; cursor: pointer; }
.response-option:hover, .response-option.is-active { background: #f3efed; }
.response-option:focus-visible { outline: 2px solid rgba(122,31,43,.38); outline-offset: 2px; }
.response-track { display: flex; align-items: flex-end; justify-content: center; width: 38px; height: 45px; }
.response-track span { display: block; width: 28px; min-height: 2px; max-height: 100%; background: var(--red); border-radius: 2px 2px 0 0; }
.response-option.is-correct .response-track span { background: var(--green); }
.response-option.is-blank .response-track span { background: #9a9391; }
.response-option.is-invalid .response-track span { background: var(--amber); }
.response-option strong { font-size: 13px; line-height: 1.2; }
.response-option.is-correct strong { color: var(--green); }
.response-option small { color: var(--muted); font-size: 9px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.response-frequency.is-fill { overflow-x: auto; padding: 3px 1px; }
.response-option.is-text { grid-template-columns: minmax(70px, auto); flex-basis: auto; min-width: 70px; }
.response-option.is-text .response-track { width: 100%; min-width: 58px; }
.response-option.is-text .response-track span { width: 50px; }
.response-option.is-text strong { max-width: 120px; overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.analysis-discrimination { display: grid; justify-items: center; gap: 5px; text-align: center; }
.analysis-discrimination > strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.df-badge { display: inline-flex; justify-content: center; min-width: 48px; padding: 2px 6px; border-radius: 4px; font-size: 9px; font-weight: 800; }
.df-neutral { color: #68615f; background: #ece9e7; }
.df-danger { color: #892530; background: #f7e5e8; }
.df-low { color: #805509; background: #f8edd7; }
.df-medium { color: #3f5f79; background: #e7eef4; }
.df-good, .df-excellent { color: #21634d; background: #e3f1eb; }
.analysis-points { display: grid; justify-items: center; text-align: center; }
.analysis-points strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.analysis-points span { color: var(--muted); font-size: 10px; }
.item-response-detail { grid-column: 1 / -1; width: 100%; margin-top: 2px; overflow: hidden; background: #fff; border: 1px solid #ded8d5; border-radius: 6px; }
.item-response-detail[hidden] { display: none; }
.item-response-detail-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 42px; padding: 7px 9px 7px 12px; background: #f7f5f4; border-bottom: 1px solid #e5dfdc; }
.item-response-detail-head > div { display: flex; align-items: baseline; gap: 9px; }
.item-response-detail-head strong { color: var(--brand); font-size: 13px; }
.item-response-detail-head span { color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.response-student-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.response-student-row { display: grid; grid-template-columns: minmax(80px, 1fr) minmax(60px, .7fr); gap: 2px 10px; min-width: 0; padding: 10px 12px; border-right: 1px solid #ece7e4; border-bottom: 1px solid #ece7e4; }
.response-student-row:nth-child(3n) { border-right: 0; }
.response-student-row:hover { color: var(--brand); background: var(--brand-soft); }
.response-student-row strong, .response-student-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.response-student-row strong { font-size: 12px; }
.response-student-row span { color: var(--muted); font-size: 10px; text-align: right; }
.response-student-row small { grid-column: 1 / -1; color: var(--muted); font-size: 9px; font-variant-numeric: tabular-nums; }
.response-student-empty { grid-column: 1 / -1; padding: 18px; color: var(--muted); text-align: center; font-size: 11px; }

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 30px; background: #f0f1ef; }
.login-shell { width: min(940px, 100%); min-height: 520px; display: grid; grid-template-columns: 1.65fr 1fr; overflow: hidden; background: #fff; border: 1px solid #d8d5d2; border-radius: 7px; box-shadow: var(--shadow); }
.login-brand { position: relative; display: flex; align-items: flex-end; padding: 54px; color: #fff; background: var(--brand-dark); border-right: 7px solid var(--gold); }
.login-brand::before { content: ""; position: absolute; top: 44px; left: 54px; width: 42px; height: 5px; background: var(--gold); }
.login-brand small { color: #efc76c; font-weight: 800; letter-spacing: .08em; }
.login-brand h1 { max-width: 480px; margin: 10px 0 12px; font-size: 39px; line-height: 1.18; }
.login-brand p { margin: 0; color: rgba(255,255,255,.68); font-size: 15px; }
.login-form { display: grid; align-content: center; padding: 38px; }
.login-form h2 { margin: 0 0 22px; font-size: 22px; }
.login-form form { display: grid; gap: 14px; }
.login-form .btn { width: 100%; min-height: 45px; margin-top: 3px; }

.student-filter-panel { margin-bottom: 0; }
.sheet-filter-form { display: grid; grid-template-columns: 220px minmax(260px, 1fr) auto auto; align-items: end; gap: 10px; padding: 14px 16px; }
.sheet-filter-control { min-height: 44px; padding: 9px 12px; background: #fff; border: 1px solid #c9c2bf; border-radius: 7px; box-shadow: 0 1px 2px rgba(54,31,34,.04); font-size: 14px; transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease; }
.sheet-filter-control:hover { background: #fdfbfb; border-color: #a89194; }
.sheet-filter-control:focus { background: #fff; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(122,31,43,.12); }
.sheet-select-shell { position: relative; display: block; min-width: 0; }
.sheet-select-shell .sheet-filter-control { appearance: none; -webkit-appearance: none; width: 100%; padding-right: 40px; font-weight: 700; cursor: pointer; }
.sheet-select-shell > svg { position: absolute; top: 50%; right: 12px; width: 18px; height: 18px; color: #6f6866; pointer-events: none; transform: translateY(-50%); transition: color .16s ease, transform .16s ease; }
.sheet-select-shell:focus-within > svg { color: var(--brand); transform: translateY(-50%) rotate(180deg); }
.sheet-filter-form .btn { min-height: 40px; }
.roster-preview .panel-head > div { display: grid; gap: 2px; }

.roster-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin: 16px 0; overflow: hidden; background: var(--line); border: 1px solid var(--line); border-radius: 7px; }
.roster-summary > div { display: grid; gap: 4px; min-height: 82px; padding: 14px 16px; background: #fff; }
.roster-summary span { color: var(--muted); font-size: 11px; font-weight: 700; }
.roster-summary strong { font-size: 22px; line-height: 1.2; }
.roster-summary .summary-status { background: #f1f7f4; }
.summary-status strong { display: flex; align-items: center; gap: 7px; color: var(--green); font-size: 15px; }
.summary-status svg { width: 18px; height: 18px; }

.sheet-workspace { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.roster-table-wrap { max-height: 590px; overflow: auto; }
.roster-table-wrap thead { position: sticky; top: 0; z-index: 1; }
.selection-cell { width: 48px; text-align: center; }
.selection-checkbox { width: 18px; height: 18px; margin: 0; accent-color: var(--brand); vertical-align: middle; cursor: pointer; }
[data-student-row]:has(.selection-checkbox:checked) { background: #fcf8f8; }
[data-student-row]:has(.selection-checkbox:not(:checked)) { color: #9a9391; }
.student-sheet-link { display: inline-flex; align-items: center; gap: 7px; padding: 2px 0; color: var(--ink); background: transparent; border: 0; }
.student-sheet-link strong { font-size: 14px; }
.student-sheet-link svg { width: 15px; height: 15px; color: var(--brand); opacity: 0; transform: translateX(-3px); transition: opacity .15s ease, transform .15s ease; }
.student-sheet-link:hover, .student-sheet-link:focus-visible { color: var(--brand); }
.student-sheet-link:hover svg, .student-sheet-link:focus-visible svg { opacity: 1; transform: translateX(0); }
.student-sheet-link:focus-visible { outline: 2px solid rgba(122,31,43,.28); outline-offset: 3px; }
.generate-panel { position: static; }
.generate-form { display: grid; gap: 16px; }
.generate-selection { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 2px 10px; padding: 12px; background: #f7f5f4; border-left: 3px solid var(--brand); }
.generate-selection > span { color: var(--muted); font-size: 11px; }
.generate-selection > strong { color: var(--brand); font-size: 16px; }
.generate-selection > small { grid-column: 1 / -1; color: var(--muted); }
.generate-selection b { font-variant-numeric: tabular-nums; }
.option-fieldset { display: grid; gap: 8px; min-width: 0; margin: 0; padding: 0; border: 0; }
.option-fieldset legend { margin-bottom: 7px; color: #474141; font-size: 12px; font-weight: 750; }
.output-option { position: relative; display: grid; grid-template-columns: 38px 1fr 18px; align-items: center; gap: 10px; min-height: 64px; padding: 10px; background: #fff; border: 1px solid #d5cfcc; border-radius: 6px; cursor: pointer; }
.output-option:hover { background: #fbf8f8; border-color: #bcaeb0; }
.output-option:has(input:checked) { background: var(--brand-soft); border-color: var(--brand); box-shadow: inset 3px 0 0 var(--brand); }
.output-option input { position: absolute; opacity: 0; }
.option-icon { display: grid; place-items: center; width: 38px; height: 38px; color: var(--brand); background: #f3eeee; border-radius: 5px; }
.option-icon svg { width: 18px; height: 18px; }
.output-option > span:nth-of-type(2) { display: grid; }
.output-option small { color: var(--muted); }
.option-check { width: 18px; height: 18px; color: var(--brand); opacity: 0; }
.output-option:has(input:checked) .option-check { opacity: 1; }
.print-note { display: flex; align-items: flex-start; gap: 9px; padding: 10px; color: #5f5755; background: #f7f5f4; border-left: 3px solid #b8aeab; font-size: 12px; }
.print-note svg { flex: 0 0 16px; width: 16px; height: 16px; margin-top: 1px; color: var(--brand); }
.generate-button { width: 100%; min-height: 44px; }
.generate-button:disabled { color: #817a78; background: #d8d3d1; border-color: #d8d3d1; cursor: not-allowed; }
.empty .btn { margin-top: 14px; }

.scan-record-metrics { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.scan-record-metrics .metric { color: inherit; }
.scan-record-metrics .metric:hover { border-color: #baaeb0; background: #fff; }
.scan-record-metrics .metric.is-selected { border-color: var(--brand); box-shadow: inset 0 3px 0 var(--brand); }
.scan-filter-select { width: min(290px, 36vw); }
.scan-select-shell { position: relative; display: block; min-width: 0; }
.scan-select-shell > svg { position: absolute; top: 50%; right: 12px; width: 18px; height: 18px; color: #6f6866; pointer-events: none; transform: translateY(-50%); transition: color .16s ease, transform .16s ease; }
.scan-select { appearance: none; -webkit-appearance: none; width: 100%; min-height: 44px; padding: 9px 40px 9px 13px; color: #2d2928; background: #fff; border: 1px solid #c9c2bf; border-radius: 7px; box-shadow: 0 1px 2px rgba(54,31,34,.04); font-size: 13px; font-weight: 700; line-height: 1.25; cursor: pointer; transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease; }
.scan-select-shell:hover .scan-select { background: #fdfbfb; border-color: #a89194; }
.scan-select-shell:focus-within .scan-select { background: #fff; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(122,31,43,.12); }
.scan-select-shell:focus-within > svg { color: var(--brand); transform: translateY(-50%) rotate(180deg); }
.scan-file-link { display: flex; align-items: center; min-width: 180px; gap: 9px; }
.scan-file-link > svg { flex: 0 0 18px; width: 18px; color: var(--brand); }
.scan-file-link > span { display: grid; }
.scan-file-link small { color: var(--muted); font-size: 10px; }
.scan-assignment { display: grid; grid-template-columns: minmax(170px, .9fr) minmax(250px, 1.35fr) 104px 44px; align-items: center; gap: 8px; }
.scan-assignment .btn-icon { width: 44px; height: 44px; min-height: 44px; }
.scan-issue { margin-top: 5px; color: var(--red); font-size: 11px; }
.scan-record-table td:nth-child(3) { min-width: 650px; }
.scan-record-table tbody td { padding-top: 14px; padding-bottom: 14px; }
.workflow-metrics { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.workflow-metrics .metric:hover { border-color: #baaeb0; background: #fff; }
.workflow-metrics .metric.is-selected { border-color: var(--brand); box-shadow: inset 0 3px 0 var(--brand); }
.submission-score-cell { color: #4c4543; font-size: 15px; font-weight: 750; font-variant-numeric: tabular-nums; }
.submission-total-score { color: var(--brand); font-size: 17px; }
.grammar-review-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grammar-review-item { display: grid; gap: 10px; min-width: 0; padding: 16px; border-right: 1px solid #ece8e6; border-bottom: 1px solid #ece8e6; }
.grammar-review-item:nth-child(2n) { border-right: 0; }
.grammar-review-item.needs-review { box-shadow: inset 3px 0 0 var(--brand); }
.grammar-review-head, .grammar-ocr-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grammar-review-head strong { font-size: 19px; }
.grammar-review-head span, .grammar-ocr-meta { color: var(--muted); font-size: 11px; }
.grammar-crop { display: grid; place-items: center; min-height: 100px; overflow: hidden; background: #f5f3f2; border: 1px solid #ddd7d4; }
.grammar-crop img { display: block; max-width: 100%; max-height: 130px; }
.grammar-answer-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; }
.grammar-answer-row .field { min-width: 0; }
.grammar-decision { position: relative; display: grid; grid-template-columns: repeat(2, 42px); gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }
.grammar-decision legend { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.grammar-decision input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.grammar-decision label { display: grid; place-items: center; width: 42px; height: 40px; background: #fff; border: 1px solid currentColor; border-radius: 5px; font-size: 22px; font-weight: 850; line-height: 1; cursor: pointer; transition: background-color .14s ease, color .14s ease, box-shadow .14s ease; }
.grammar-decision label.is-correct { color: #23664f; }
.grammar-decision label.is-incorrect { color: #b55a14; }
.grammar-decision label:hover { box-shadow: 0 0 0 3px rgba(54, 45, 43, .08); }
.grammar-decision input:checked + label { color: #fff; }
.grammar-decision input:checked + label.is-correct { background: #23664f; border-color: #23664f; }
.grammar-decision input:checked + label.is-incorrect { background: #b55a14; border-color: #b55a14; }
.reference-answer { min-height: 40px; padding: 9px 10px; color: var(--brand); background: var(--brand-soft); border-radius: 5px; font-weight: 750; }
.essay-review-heading { align-items: center; }
.essay-review-editor { display: grid; grid-template-columns: 150px minmax(620px, 1fr) 260px; gap: 12px; align-items: start; }
.essay-tools, .essay-finalize { position: sticky; top: 86px; padding: 12px; }
.essay-tools { display: grid; gap: 14px; }
.essay-tool-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.essay-tool { display: grid; place-items: center; gap: 4px; min-height: 55px; padding: 7px; color: #595251; background: #faf9f8; border: 1px solid #d7d1cf; border-radius: 5px; font-size: 10px; font-weight: 750; }
.essay-tool svg { width: 18px; height: 18px; }
.essay-tool:hover, .essay-tool.active { color: #fff; background: var(--brand); border-color: var(--brand); }
.essay-color-row, .essay-history { display: flex; align-items: center; justify-content: center; gap: 8px; }
.essay-swatch { width: 30px; height: 30px; padding: 0; background: var(--swatch); border: 3px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px #bcb5b2; }
.essay-swatch.active { box-shadow: 0 0 0 2px var(--brand); }
.essay-stroke { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; }
.essay-stroke input { min-width: 0; }
.essay-canvas-stage { min-height: 72vh; overflow: auto; padding: 18px; background: #2a2727; border: 1px solid #484141; border-radius: 7px; }
.essay-canvas-loading { padding: 30px; color: rgba(255,255,255,.72); text-align: center; }
.essay-canvas-wrap { width: max-content; margin: 0 auto; background: #fff; box-shadow: 0 8px 28px rgba(0,0,0,.28); }
.essay-finalize { display: grid; gap: 16px; }
.essay-finalize h2 { margin: 3px 0 0; font-size: 19px; }
.essay-score-field { display: grid; gap: 7px; color: #474141; font-size: 12px; font-weight: 750; }
.essay-score-field > span { display: grid; grid-template-columns: 1fr auto; align-items: baseline; overflow: hidden; border: 1px solid #c9c3c1; border-radius: 6px; }
.essay-score-field input { width: 100%; min-width: 0; padding: 10px; border: 0; outline: 0; font-size: 26px; font-weight: 800; }
.essay-score-field b { padding-right: 10px; color: var(--muted); font-size: 13px; }
.essay-score-field.is-keyboard-active > span { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(122,31,43,.13); }

.sheet-preview-dialog { width: min(1180px, calc(100vw - 36px)); height: calc(100vh - 32px); max-width: none; max-height: none; padding: 0; overflow: hidden; background: #fff; border: 1px solid #bfb8b5; border-radius: 7px; box-shadow: 0 24px 70px rgba(32, 19, 21, .28); }
.sheet-preview-dialog::backdrop { background: rgba(29, 21, 22, .62); }
.sheet-preview-shell { display: grid; grid-template-rows: auto minmax(0, 1fr); height: 100%; }
.sheet-preview-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 70px; padding: 11px 14px 11px 18px; border-bottom: 1px solid var(--line); }
.sheet-preview-head > div:first-child { display: grid; grid-template-columns: auto auto; align-items: baseline; gap: 1px 10px; }
.sheet-preview-head span { grid-column: 1 / -1; color: var(--brand); font-size: 10px; font-weight: 800; }
.sheet-preview-head h2 { margin: 0; font-size: 17px; }
.sheet-preview-head small { color: var(--muted); font-variant-numeric: tabular-nums; }
.sheet-preview-actions { display: flex; align-items: center; gap: 8px; }
.sheet-preview-body { min-height: 0; background: #3d3938; }
.sheet-preview-body iframe { display: block; width: 100%; height: 100%; background: #fff; border: 0; }

@media (max-width: 980px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .two-col, .review-layout { grid-template-columns: 1fr; }
  .scan-viewer { position: static; }
  .accuracy-grid { grid-template-columns: repeat(3, minmax(130px, 1fr)); }
  .answer-grid { grid-template-rows: repeat(20, 96px); }
  .answer-score-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .item-analysis-header, .item-analysis-row { grid-template-columns: 70px 110px minmax(310px, 1fr) 90px 54px; gap: 10px; }
  .response-frequency { gap: 7px; }
  .response-option { grid-template-columns: 40px; flex-basis: 40px; }
  .sheet-filter-form { grid-template-columns: 1fr 1fr auto auto; }
  .sheet-workspace { grid-template-columns: 1fr; }
  .brand { min-width: auto; }
  .brand-copy small, .user-name { display: none; }
  .scan-record-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .workflow-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .essay-review-editor { grid-template-columns: 130px minmax(560px, 1fr); }
  .essay-finalize { position: static; grid-column: 1 / -1; grid-template-columns: 1fr 1fr; }
  .exam-page-head { align-items: flex-start; flex-direction: column; }
  .exam-heading-summary { width: 100%; }
  .exam-page-head .page-actions { justify-content: flex-start; }
  .paper-review-workspace { grid-template-columns: 1fr; height: auto; }
  .paper-scan-column, .paper-analysis-column { display: grid; }
  .paper-image-viewer { height: min(72vh, 760px); }
  .paper-analysis-column { margin-top: 14px; }
  .paper-analysis-scroll { overflow: visible; }
}

@media (max-width: 720px) {
  .topbar { height: auto; position: static; }
  .topbar-inner { width: 100%; padding: 10px 14px; flex-wrap: wrap; gap: 8px 14px; }
  .brand { flex: 1; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
  .nav a { min-height: 42px; padding: 0 10px; }
  .app-shell { width: calc(100% - 24px); padding-top: 18px; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .page-actions { justify-content: flex-start; }
  .student-page-actions { width: 100%; flex-wrap: wrap; }
  .student-search-form { width: 100%; }
  .student-search-form .input { flex: 1 1 auto; width: auto; min-width: 0; }
  .exam-heading-summary { align-items: flex-start; flex-direction: column; gap: 12px; }
  .exam-heading-copy { min-width: 0; }
  .exam-score-statistics { grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; min-width: 0; padding: 10px 0 0; border-top: 1px solid var(--line); border-left: 0; }
  .exam-score-statistics > div { padding: 0 8px; }
  .exam-score-statistics > div:first-child { padding-left: 0; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .form-row, .score-grid { grid-template-columns: 1fr; }
  .accuracy-grid, .review-answer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .answer-grid { grid-template-rows: repeat(30, 96px); }
  .answer-save-bar { bottom: 6px; }
  .quick-answer-editor { grid-template-columns: 44px minmax(0, 1fr); height: 360px; }
  .quick-answer-head > div { align-items: flex-start; flex-direction: column; gap: 2px; }
  .analysis-filter-panel { width: 100%; }
  .analysis-filter-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
  .analysis-filter-form .field { width: auto; }
  .item-analysis-header { display: none; }
  .item-analysis-row { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "question accuracy points" "responses responses responses" "df df df" "detail detail detail"; gap: 12px; min-height: 0; padding: 15px 14px; }
  .analysis-question { grid-area: question; }
  .analysis-accuracy { grid-area: accuracy; min-width: 88px; }
  .analysis-points { grid-area: points; min-width: 42px; }
  .response-frequency { grid-area: responses; gap: 8px; overflow-x: auto; padding: 4px 0; }
  .response-option { grid-template-columns: 54px; flex-basis: 54px; }
  .analysis-discrimination { grid-area: df; display: flex; align-items: center; justify-content: flex-end; }
  .item-response-detail { grid-area: detail; }
  .response-student-list { grid-template-columns: 1fr 1fr; }
  .response-student-row:nth-child(3n) { border-right: 1px solid #ece7e4; }
  .response-student-row:nth-child(2n) { border-right: 0; }
  .paper-page-head { flex-direction: row; align-items: center; }
  .paper-page-head > div:first-child { min-width: 0; }
  .paper-page-head h1 { font-size: 21px; }
  .paper-page-head p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .paper-page-head .page-actions > .btn { width: 38px; padding: 0; font-size: 0; }
  .paper-record-navigation { order: -1; }
  .paper-score-band { grid-template-columns: 1fr auto; gap: 8px 14px; padding: 14px 12px; }
  .paper-score-value { grid-column: 1 / -1; justify-content: center; }
  .paper-score-value strong { font-size: 30px; }
  .paper-score-value span { font-size: 15px; }
  .paper-score-value b { font-size: 16px; }
  .paper-student-identity strong { font-size: 15px; }
  .paper-image-toolbar { align-items: stretch; flex-direction: column; }
  .paper-page-options { width: 100%; }
  .paper-page-options button { flex: 1 0 auto; }
  .paper-image-tools { justify-content: flex-end; }
  .paper-image-viewer { height: 64vh; min-height: 460px; }
  .paper-section-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .paper-question-groups { grid-template-columns: 1fr; }
  .paper-question-group { border-right: 0; border-bottom: 1px solid var(--line); }
  .paper-question-group:last-child { border-bottom: 0; }
  .paper-question-item { grid-template-columns: 30px minmax(0, 1fr) 54px 24px; min-height: 34px; padding: 4px 9px; font-size: 11px; }
  .paper-result { width: 22px; height: 22px; }
  .paper-result svg { width: 16px; height: 16px; }
  .upload-steps { grid-template-columns: 1fr; }
  .sheet-filter-form { grid-template-columns: 1fr; }
  .sheet-filter-form .btn { width: 100%; }
  .roster-summary { grid-template-columns: 1fr 1fr; }
  .login-shell { min-height: 0; grid-template-columns: 1fr; }
  .login-brand { min-height: 250px; padding: 34px; border-right: 0; border-bottom: 6px solid var(--gold); }
  .login-brand h1 { font-size: 30px; }
  .login-form { padding: 32px; }
  .sheet-preview-dialog { width: 100vw; height: 100vh; border: 0; border-radius: 0; }
  .sheet-preview-head { align-items: flex-start; }
  .sheet-preview-head > div:first-child { grid-template-columns: 1fr; }
  .sheet-preview-head span { grid-column: auto; }
  .scan-record-metrics { grid-template-columns: 1fr 1fr; }
  .workflow-metrics { grid-template-columns: 1fr 1fr; }
  .grammar-review-grid { grid-template-columns: 1fr; }
  .grammar-review-item { border-right: 0; }
  .essay-review-editor { grid-template-columns: 1fr; }
  .essay-tools, .essay-finalize { position: static; }
  .essay-tool-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .essay-canvas-stage { min-height: 60vh; padding: 10px; }
  .essay-finalize { grid-column: auto; grid-template-columns: 1fr; }
  .sheet-preview-actions .btn-primary { min-width: 40px; padding: 8px; font-size: 0; }
}

@media (max-width: 430px) {
  .answer-grid { grid-template-rows: repeat(60, 96px); }
  .response-student-list { grid-template-columns: 1fr; }
  .response-student-row, .response-student-row:nth-child(3n) { border-right: 0; }
}

@media print {
  body:has(.exam-overview-page) { background: #fff; font-size: 10px; }
  body:has(.exam-overview-page) .topbar,
  body:has(.exam-overview-page) .flash-wrap,
  body:has(.exam-overview-page) .exam-overview-page-head .page-actions { display: none; }
  body:has(.exam-overview-page) .app-shell { width: 100%; padding: 0; }
  body:has(.exam-overview-page) .exam-overview-page-head { margin: 0 0 8px; }
  body:has(.exam-overview-page) .exam-overview-page-head h1 { font-size: 19px; }
  body:has(.exam-overview-page) .exam-overview-page { border: 0; box-shadow: none; }
  body:has(.exam-overview-page) .exam-overview-page .panel-head { min-height: 0; padding: 5px 0; border: 0; }
  body:has(.exam-overview-page) .score-overview-table { min-width: 0; }
  body:has(.exam-overview-page) .score-overview-table th,
  body:has(.exam-overview-page) .score-overview-table td { padding: 4px 3px; }
}
