:root {
  --ink: #17314f;
  --ink-strong: #10243a;
  --ink-muted: #536579;
  --paper: #ffffff;
  --canvas: #edf0f2;
  --line: #cbd2d9;
  --line-dark: #9ca8b3;
  --soft: #f5f7f8;
  --red: #b13b38;
  --red-soft: #f7eceb;
  --green: #2f6a4f;
  --amber: #8a621d;
  --radius: 3px;
  --header-height: 62px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--ink-strong);
  background: var(--canvas);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--canvas);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink-strong);
  background: var(--canvas);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select,
input[type="radio"],
input[type="checkbox"] {
  cursor: pointer;
}

button:disabled,
select:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
dialog:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid rgba(23, 49, 79, 0.2);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 8px;
  left: 8px;
  padding: 8px 12px;
  color: #fff;
  background: var(--ink);
  transform: translateY(-140%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-strong);
  text-decoration: none;
}

.brand-lockup strong,
.brand-lockup small {
  display: block;
}

.brand-lockup strong {
  display: flex;
  align-items: baseline;
  gap: 7px;
  font-family: "STSong", "Songti SC", "SimSun", serif;
  font-size: 19px;
  letter-spacing: 0.12em;
  line-height: 1;
}

.brand-lockup strong em {
  color: var(--ink-muted);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 9px;
  font-style: normal;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.brand-lockup small {
  margin-top: 1px;
  color: var(--ink-muted);
  font-size: 11px;
  letter-spacing: 0.08em;
}

.brand-mark {
  display: block;
  width: 38px;
  height: 38px;
  flex: none;
}

.header-actions,
.admin-top-actions,
.preview-actions,
.dialog-actions,
.filter-row,
.date-range-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.entitlement-stamp {
  padding: 3px 7px;
  border: 1px solid var(--red);
  color: var(--red);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.text-button,
.link-button,
.password-toggle,
.icon-close {
  border: 0;
  color: var(--ink);
  background: transparent;
}

.text-button {
  padding: 7px 4px;
  font-size: 13px;
}

.text-button:hover,
.link-button:hover {
  color: var(--red);
}

.global-notice {
  position: fixed;
  z-index: 90;
  top: 72px;
  left: 50%;
  max-width: min(520px, calc(100% - 32px));
  padding: 10px 15px;
  border: 1px solid var(--ink);
  color: var(--ink-strong);
  background: #fff;
  box-shadow: 3px 3px 0 rgba(23, 49, 79, 0.14);
  font-size: 13px;
  transform: translateX(-50%);
}

.global-notice.is-error {
  border-color: var(--red);
  color: #7c2927;
  background: #fffafa;
}

.auth-shell {
  display: grid;
  grid-template-columns: minmax(0, 540px) 270px;
  gap: 32px;
  width: min(920px, calc(100% - 40px));
  margin: 52px auto;
  align-items: start;
}

.auth-sheet,
.admin-login-sheet {
  border: 1px solid var(--line-dark);
  background: var(--paper);
}

.auth-sheet {
  min-height: 520px;
}

.auth-sheet-heading {
  padding: 30px 34px 24px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--red);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.auth-sheet-heading h1,
.admin-login-heading h1,
.admin-section-heading h1 {
  margin: 0;
  font-family: "STSong", "Songti SC", "SimSun", serif;
  color: var(--ink-strong);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.auth-sheet-heading h1 {
  font-size: 28px;
}

.auth-sheet-heading p:last-child,
.admin-login-heading p:last-child {
  margin: 10px 0 0;
  color: var(--ink-muted);
  font-size: 13px;
  line-height: 1.7;
}

.tab-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--line);
}

.tab-button {
  height: 45px;
  border: 0;
  border-right: 1px solid var(--line);
  color: var(--ink-muted);
  background: var(--soft);
  font-size: 14px;
  font-weight: 700;
}

.tab-button:last-child {
  border-right: 0;
}

.tab-button.is-active {
  color: var(--ink);
  background: #fff;
  box-shadow: inset 0 -3px 0 var(--ink);
}

.auth-panel {
  padding: 26px 34px 34px;
}

.field-label,
.field-row > label,
.control-label {
  display: block;
  margin: 0 0 7px;
  color: var(--ink-strong);
  font-size: 12px;
  font-weight: 700;
}

.field-input,
.search-input,
select,
input[type="date"] {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line-dark);
  border-radius: var(--radius);
  color: var(--ink-strong);
  background: #fff;
  padding: 0 10px;
  appearance: none;
}

select {
  padding-right: 8px;
  appearance: auto;
}

.field-input:focus,
.search-input:focus,
select:focus,
input[type="date"]:focus {
  border-color: var(--ink);
  outline: 2px solid rgba(23, 49, 79, 0.11);
  outline-offset: 0;
}

.field-input::placeholder,
.search-input::placeholder {
  color: #8b969f;
}

.auth-panel .field-input,
.plain-dialog .field-input,
.admin-login-sheet .field-input {
  margin-bottom: 18px;
}

.password-field {
  position: relative;
}

.password-field .field-input {
  padding-right: 54px;
}

.password-toggle {
  position: absolute;
  top: 1px;
  right: 1px;
  height: 36px;
  padding: 0 11px;
  color: var(--ink-muted);
  font-size: 12px;
}

.code-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.field-pair,
.field-row-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field-help,
.inline-help,
.dialog-note,
.auth-note-line {
  color: var(--ink-muted);
  font-size: 12px;
  line-height: 1.65;
}

.field-help {
  margin: -2px 0 20px;
  padding: 9px 11px;
  border-left: 3px solid var(--line-dark);
  background: var(--soft);
}

.form-error {
  margin: 0 0 14px;
  padding: 9px 11px;
  border-left: 3px solid var(--red);
  color: #7b2c29;
  background: var(--red-soft);
  font-size: 12px;
  line-height: 1.55;
}

.primary-button,
.secondary-button,
.small-button {
  min-height: 38px;
  border-radius: var(--radius);
  padding: 0 16px;
  font-weight: 700;
}

.primary-button {
  border: 1px solid var(--ink);
  color: #fff;
  background: var(--ink);
}

.primary-button:hover:not(:disabled) {
  border-color: var(--ink-strong);
  background: var(--ink-strong);
}

.secondary-button {
  border: 1px solid var(--line-dark);
  color: var(--ink);
  background: #fff;
}

.secondary-button:hover:not(:disabled),
.small-button:hover:not(:disabled) {
  border-color: var(--ink);
  background: var(--soft);
}

.small-button {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
  font-size: 12px;
}

.compact {
  min-height: 32px;
  padding: 0 12px;
  font-size: 12px;
}

.full-width {
  width: 100%;
}

.link-button {
  padding: 9px 0;
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.auth-panel .link-button {
  display: block;
  margin: 5px auto -5px;
}

.auth-notes {
  padding: 24px 0;
}

.auth-notes h2 {
  margin: 0 0 16px;
  font-family: "STSong", "Songti SC", serif;
  font-size: 18px;
}

.plain-steps {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line-dark);
}

.plain-steps li {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink-muted);
  font-size: 12px;
  line-height: 1.55;
}

.plain-steps li span {
  color: var(--red);
  font-family: Georgia, serif;
  font-size: 18px;
}

.auth-note-line {
  margin-top: 18px;
  padding-left: 11px;
  border-left: 3px solid var(--red);
}

/* User workbench */
.workbench {
  display: grid;
  grid-template-columns: 340px minmax(640px, 1fr);
  height: calc(100vh - var(--header-height));
  overflow: hidden;
}

.control-panel {
  position: relative;
  z-index: 4;
  overflow-y: auto;
  border-right: 1px solid var(--line-dark);
  background: #fff;
}

.workspace-tabs {
  position: sticky;
  z-index: 4;
  top: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--line);
  background: var(--soft);
}

.workspace-tab {
  height: 44px;
  border: 0;
  border-right: 1px solid var(--line);
  color: var(--ink-muted);
  background: transparent;
  font-size: 13px;
  font-weight: 700;
}

.workspace-tab:last-child {
  border-right: 0;
}

.workspace-tab.is-active {
  color: var(--ink);
  background: #fff;
  box-shadow: inset 0 -3px 0 var(--red);
}

.settings-panel,
.history-panel {
  padding: 0 20px 24px;
}

.setting-group {
  margin: 0;
  padding: 18px 0 20px;
  border: 0;
  border-bottom: 1px solid var(--line);
}

.setting-group legend {
  width: 100%;
  margin: 0 0 14px;
  padding: 0;
  color: var(--ink-strong);
  font-family: "STSong", "Songti SC", serif;
  font-size: 15px;
  font-weight: 700;
}

.setting-group legend span {
  margin-right: 6px;
  color: var(--red);
  font-family: Georgia, serif;
  font-size: 12px;
}

.field-row + .field-row {
  margin-top: 13px;
}

.field-row-split > div > label {
  display: block;
  margin: 0 0 7px;
  font-size: 12px;
  font-weight: 700;
}

.inline-help {
  margin: 6px 0 0;
  font-size: 11px;
}

.choice-list {
  border: 1px solid var(--line-dark);
}

.choice-row {
  position: relative;
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 10px;
  min-height: 54px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.choice-row:last-child {
  border-bottom: 0;
}

.choice-row:has(input:checked) {
  background: #f2f5f7;
  box-shadow: inset 3px 0 0 var(--ink);
}

.choice-row input {
  position: absolute;
  opacity: 0;
}

.choice-glyph {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  align-self: center;
  border: 1px solid var(--line-dark);
  color: var(--ink);
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 16px;
  font-weight: 700;
  background: #fff;
}

.choice-row:has(input:checked) .choice-glyph {
  border-color: var(--ink);
}

.choice-row strong,
.choice-row small {
  display: block;
}

.choice-row strong {
  font-size: 13px;
}

.choice-row small {
  margin-top: 3px;
  color: var(--ink-muted);
  font-size: 10px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line-dark);
}

.segmented-two {
  grid-template-columns: repeat(2, 1fr);
}

.segmented label {
  position: relative;
  border-right: 1px solid var(--line);
}

.segmented label:last-child {
  border-right: 0;
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented span {
  display: grid;
  height: 34px;
  place-items: center;
  color: var(--ink-muted);
  background: #fff;
  font-size: 12px;
  cursor: pointer;
}

.segmented input:checked + span {
  color: #fff;
  background: var(--ink);
  font-weight: 700;
}

.generate-button {
  width: 100%;
  height: 42px;
  margin-top: 18px;
}

.quantity-fields {
  padding-left: 10px;
  border-left: 3px solid #d8dde2;
}

.page-count-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: center;
  border: 1px solid var(--line-dark);
  border-radius: var(--radius);
  background: #fff;
}

.page-count-control .field-input {
  height: 36px;
  border: 0;
  background: transparent;
}

.page-count-control > span {
  display: grid;
  height: 22px;
  place-items: center;
  border-left: 1px solid var(--line);
  color: var(--ink-muted);
  font-size: 12px;
}

.history-panel {
  padding-top: 18px;
}

.panel-heading-row,
.section-line-heading,
.table-toolbar,
.admin-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.panel-heading-row h2,
.section-line-heading h2,
.batch-strip h2,
.integration-ledger h2 {
  margin: 0;
  font-family: "STSong", "Songti SC", serif;
  font-size: 16px;
}

.panel-heading-row p,
.batch-strip p,
.integration-status-line p,
.interface-note p {
  margin: 4px 0 0;
  color: var(--ink-muted);
  font-size: 11px;
  line-height: 1.5;
}

.history-list {
  margin-top: 15px;
  border-top: 1px solid var(--line-dark);
}

.history-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  width: 100%;
  padding: 13px 2px;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink-strong);
  background: #fff;
  text-align: left;
}

.history-item:hover {
  background: var(--soft);
}

.history-item strong,
.history-item small {
  display: block;
}

.history-item strong {
  margin-bottom: 4px;
  font-size: 12px;
}

.history-item small,
.history-item time {
  color: var(--ink-muted);
  font-size: 10px;
}

.history-item time {
  white-space: nowrap;
}

.compact-empty,
.table-empty {
  color: var(--ink-muted);
  font-size: 12px;
  text-align: center;
}

.compact-empty {
  padding: 30px 10px;
}

.preview-pane {
  position: relative;
  overflow: hidden;
  background: var(--canvas);
}

.preview-toolbar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 50px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: #f8f9fa;
}

.preview-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-muted);
  font-size: 12px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border: 1px solid var(--line-dark);
  border-radius: 50%;
  background: #fff;
}

.preview-status.is-ready {
  color: var(--green);
}

.preview-status.is-ready .status-dot {
  border-color: var(--green);
  background: var(--green);
}

.paper-stage {
  height: calc(100vh - var(--header-height) - 50px);
  overflow: auto;
  padding: 28px 30px 80px;
}

.practice-paper {
  position: relative;
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto 28px;
  padding: 13mm 14mm 14mm;
  color: #161b20;
  background: #fff;
  box-shadow: 0 2px 12px rgba(21, 35, 50, 0.16);
  font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

.paper-heading {
  position: relative;
  padding-bottom: 4mm;
  border-bottom: 0.6mm solid var(--ink-strong);
  text-align: center;
}

.paper-heading h1 {
  margin: 0;
  font-family: "STSong", "Songti SC", "SimSun", serif;
  font-size: 7mm;
  letter-spacing: 0.15em;
}

.paper-subtitle {
  margin: 2mm 0 0;
  color: #4e5861;
  font-size: 3.1mm;
}

.paper-brand {
  position: absolute;
  top: 1mm;
  left: 0;
  padding: 1mm 1.7mm;
  border: 0.35mm solid var(--ink);
  color: var(--ink);
  font-family: "STSong", "Songti SC", serif;
  font-size: 2.8mm;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.paper-brand b {
  margin-left: 0.8mm;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 1.8mm;
  letter-spacing: 0.12em;
}

.paper-footer i,
.paper-footer b {
  font-style: normal;
  font-weight: 600;
}

.paper-footer b {
  margin-left: 0.7mm;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 2mm;
  letter-spacing: 0.1em;
}

.student-line {
  display: grid;
  grid-template-columns: 1.2fr 1.2fr 1fr 1fr;
  gap: 6mm;
  padding: 4mm 1mm 3.5mm;
  border-bottom: 0.25mm solid #b5bbc0;
  font-family: "STSong", "Songti SC", serif;
  font-size: 3.4mm;
}

.student-line span {
  display: flex;
  align-items: flex-end;
  white-space: nowrap;
}

.student-line i {
  display: inline-block;
  flex: 1;
  min-width: 12mm;
  height: 5mm;
  border-bottom: 0.25mm solid #59636c;
}

.paper-empty-state {
  display: grid;
  min-height: 184mm;
  place-items: center;
  align-content: center;
  color: #6d767e;
  text-align: center;
}

.paper-empty-state strong {
  margin-top: 8mm;
  color: #4e5962;
  font-family: "STSong", "Songti SC", serif;
  font-size: 5mm;
}

.paper-empty-state p {
  max-width: 105mm;
  margin: 3mm 0 0;
  font-size: 3.2mm;
  line-height: 1.7;
}

.empty-grid {
  position: relative;
  width: 34mm;
  height: 34mm;
  border: 0.4mm solid #a9b0b7;
}

.empty-grid::before,
.empty-grid::after {
  content: "";
  position: absolute;
  background: #d4d8dc;
}

.empty-grid::before {
  top: 0;
  bottom: 0;
  left: 50%;
  width: 0.25mm;
}

.empty-grid::after {
  right: 0;
  bottom: 50%;
  left: 0;
  height: 0.25mm;
}

.question-grid {
  --question-gap-x: 6mm;
  --question-gap-y: 4.5mm;
  display: grid;
  grid-template-columns: repeat(var(--columns, 4), minmax(0, 1fr));
  gap: var(--question-gap-y) var(--question-gap-x);
  margin: 0;
  padding: 7mm 0 11mm;
  list-style: none;
  counter-reset: question var(--question-offset, 0);
}

.question-item {
  position: relative;
  min-width: 0;
  break-inside: avoid;
  page-break-inside: avoid;
  counter-increment: question;
  font-family: "Times New Roman", "Noto Sans SC", serif;
  font-size: var(--question-font-size, 5mm);
  font-variant-numeric: tabular-nums lining-nums;
}

.question-item::before {
  content: counter(question) ".";
  position: static;
  flex: 0 0 9mm;
  width: 9mm;
  margin-right: 1.2mm;
  color: #46515a;
  font-family: Arial, sans-serif;
  font-size: 3.45mm;
  font-weight: 600;
  line-height: 1.2;
  text-align: right;
}

.question-grid.type-oral,
.question-grid.type-compare {
  --columns: 4;
  --question-gap-y: 5.4mm;
}

.question-grid.columns-3 {
  --columns: 3;
}

.question-grid.columns-4 {
  --columns: 4;
}

.question-grid.high-number-offset {
  --question-gap-x: 4mm;
}

.question-grid.high-number-offset .question-item::before {
  flex-basis: 7.6mm;
  width: 7.6mm;
  margin-right: 0.65mm;
  font-size: 3mm;
}

.question-grid.high-number-offset .oral-question:not(.very-compact-math) {
  --question-font-size: 3.7mm;
  --answer-slot-width: 9mm;
}

.question-grid.high-number-offset .oral-expression {
  gap: 0.7mm;
}

.question-grid.high-number-offset .compare-question:not(.compact-math) {
  --question-font-size: 4.4mm;
}

.question-grid.high-number-offset .compare-question:not(.compact-math) .comparison-circle {
  width: 6.4mm;
  height: 6.4mm;
  margin-inline: 1.5mm;
  font-size: 4.1mm;
}

.oral-question,
.compare-question {
  display: flex;
  min-height: 9mm;
  justify-content: flex-start;
  padding-left: 0;
  white-space: nowrap;
}

.oral-question {
  --answer-slot-width: 13mm;
  align-items: baseline;
}

.compare-question {
  align-items: center;
}

.oral-expression {
  display: inline-flex;
  align-items: baseline;
  gap: 1.4mm;
  line-height: 1.2;
}

.oral-expression.tokenized-expression,
body.answers-visible .oral-expression.tokenized-expression {
  gap: 0;
}

.tokenized-expression .math-operator,
.tokenized-expression .math-equals {
  margin-inline: 1.15mm;
}

.tokenized-expression .math-parenthesis.is-open {
  margin-right: 0.15mm;
}

.tokenized-expression .math-parenthesis.is-close {
  margin-left: 0.15mm;
}

.oral-question.compact-math {
  --question-font-size: 4mm;
  --answer-slot-width: 10mm;
}

.oral-question.uniform-expression-math {
  --question-font-size: 4mm;
  --answer-slot-width: 10mm;
}

.oral-question.compact-math .oral-expression {
  gap: 0.9mm;
}

.oral-question.very-compact-math {
  --question-font-size: 3.4mm;
  --answer-slot-width: 8mm;
}

.answer-blank {
  display: inline-block;
  width: 13mm;
  height: 6mm;
  border-bottom: 0.3mm solid #282e33;
  vertical-align: bottom;
}

.question-answer {
  display: none;
  margin-left: 1mm;
  color: var(--red);
  font-family: "STKaiti", "KaiTi", serif;
  font-weight: 700;
}

.oral-question .answer-slot {
  position: relative;
  display: inline-flex;
  flex: 0 0 var(--answer-slot-width);
  width: var(--answer-slot-width);
  height: 6mm;
  align-self: baseline;
  vertical-align: bottom;
}

.oral-question .answer-slot .answer-blank,
.oral-question .answer-slot .question-answer {
  position: absolute;
  inset: 0;
  width: 100%;
}

.oral-question .answer-slot .question-answer {
  align-items: flex-end;
  justify-content: flex-start;
  margin-left: 0;
  line-height: 1.15;
}

body.answers-visible .question-answer {
  display: inline-flex;
  margin-left: 0;
}

body.answers-visible .answer-blank {
  display: none;
}

body.answers-visible .oral-question.answer-compact-math .question-answer {
  font-size: 3.4mm;
}

body.answers-visible .oral-question.answer-very-compact-math .question-answer {
  font-size: 3mm;
}

.comparison-circle {
  display: inline-grid;
  width: 7.2mm;
  height: 7.2mm;
  margin: 0 2.4mm;
  place-items: center;
  border: 0.35mm solid #22282d;
  border-radius: 50%;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 4.8mm;
  line-height: 1;
  vertical-align: middle;
}

body.answers-visible .comparison-circle {
  border-color: var(--red);
  color: var(--red);
}

.compare-question.compact-math {
  --question-font-size: 3.5mm;
}

.compare-question.compact-math .comparison-circle {
  width: 6mm;
  height: 6mm;
  margin: 0 1.2mm;
  font-size: 4mm;
}

.compare-question.very-compact-math {
  --question-font-size: 3mm;
}

.compare-question.very-compact-math .comparison-circle {
  width: 5.4mm;
  height: 5.4mm;
  margin: 0 0.8mm;
  font-size: 3.5mm;
}

.comparison-answer {
  display: none;
  color: var(--red);
}

body.answers-visible .comparison-answer {
  display: inline;
}

.math-fraction {
  display: inline-grid;
  min-width: 6mm;
  margin: 0 0.7mm;
  grid-template-rows: 1fr 1fr;
  align-items: center;
  text-align: center;
  vertical-align: middle;
  line-height: 1.05;
}

.math-fraction > span:first-child {
  padding: 0 0.8mm 0.45mm;
  border-bottom: 0.3mm solid currentColor;
}

.math-fraction > span:last-child {
  padding-top: 0.45mm;
}

.mixed-number {
  display: inline-flex;
  align-items: center;
  gap: 0.3mm;
}

.question-grid.type-vertical {
  --columns: 3;
  --question-gap-x: 11mm;
  --question-gap-y: 2.5mm;
  padding-top: 6mm;
}

.question-grid.type-vertical.columns-2 {
  --columns: 2;
  --question-gap-x: 20mm;
}

.vertical-question {
  display: flex;
  min-height: 39mm;
  align-items: flex-start;
  justify-content: flex-start;
  padding-left: 0;
}

.vertical-question::before {
  margin-top: 1mm;
}

.vertical-question-body {
  display: grid;
  flex: 1;
  min-width: 0;
  justify-items: start;
  align-content: start;
}

.vertical-expression {
  display: flex;
  width: auto;
  min-height: 6mm;
  align-items: baseline;
  justify-content: flex-start;
  gap: 0.8mm;
  white-space: nowrap;
}

.vertical-expression .answer-blank {
  width: 12mm;
  height: 5mm;
}

.vertical-expression .question-answer {
  color: var(--red);
}

.vertical-stack {
  display: grid;
  min-width: 22mm;
  align-content: start;
  justify-content: end;
  padding: 1.5mm 1mm 0 3mm;
}

.vertical-number-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(2ch, auto) 0.55ch minmax(0, var(--decimal-width, 0ch));
  justify-content: end;
  align-items: baseline;
  min-height: 6.2mm;
  text-align: right;
  line-height: 1.15;
}

.vertical-number-row .operator {
  position: absolute;
  right: calc(100% + 2.5mm);
  bottom: 0;
}

.vertical-integer {
  text-align: right;
}

.vertical-dot {
  text-align: center;
}

.vertical-decimal {
  text-align: left;
}

.vertical-line {
  width: calc(100% + 6mm);
  height: 0;
  margin: 1mm 0 1.7mm -6mm;
  border-top: 0.45mm solid #171b1f;
}

.vertical-result {
  min-height: 7mm;
  color: var(--red);
}

.vertical-result .answer-only {
  visibility: hidden;
}

body.answers-visible .vertical-result .answer-only {
  visibility: visible;
}

.long-division-stack {
  display: grid;
  min-width: 32mm;
  grid-template-columns: minmax(7mm, auto) minmax(18mm, auto);
  grid-template-rows: 7.5mm 7.5mm 12mm;
  align-items: start;
  justify-content: start;
  padding-top: 1mm;
  font-variant-numeric: tabular-nums;
}

.long-division-quotient {
  display: flex;
  grid-column: 2;
  grid-row: 1;
  min-height: 7mm;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 0 1.5mm 0.8mm;
  color: var(--red);
  line-height: 1;
}

.long-division-quotient .question-answer {
  justify-content: flex-end;
}

.long-division-divisor {
  grid-column: 1;
  grid-row: 2;
  padding: 1.2mm 1.7mm 0 0;
  text-align: right;
  line-height: 1.15;
}

.long-division-dividend {
  grid-column: 2;
  grid-row: 2;
  min-height: 7mm;
  padding: 1.1mm 1.5mm 0;
  border-top: 0.45mm solid #171b1f;
  border-left: 0.45mm solid #171b1f;
  border-top-left-radius: 3mm 1.6mm;
  text-align: right;
  line-height: 1.15;
}

.long-division-working-space {
  grid-column: 2;
  grid-row: 3;
  min-height: 12mm;
}

.answer-sheet {
  display: none;
  padding-top: 8mm;
}

.answer-paper {
  display: none;
}

.answer-sheet h2 {
  margin: 0 0 5mm;
  padding-bottom: 3mm;
  border-bottom: 0.5mm solid var(--ink);
  font-family: "STSong", "Songti SC", serif;
  font-size: 6mm;
  text-align: center;
  letter-spacing: 0.15em;
}

.answer-key-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4mm 6mm;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: answer var(--answer-offset, 0);
  font-family: "Times New Roman", "Noto Sans SC", serif;
  font-size: 4mm;
}

.answer-key-grid li {
  counter-increment: answer;
  break-inside: avoid;
}

.answer-key-grid li::before {
  content: counter(answer) ". ";
  color: #4f5860;
  font-family: Arial, sans-serif;
  font-size: 3mm;
}

.paper-footer {
  position: absolute;
  right: 14mm;
  bottom: 7mm;
  left: 14mm;
  display: flex;
  justify-content: space-between;
  padding-top: 2mm;
  border-top: 0.25mm solid #bbc0c5;
  color: #727980;
  font-size: 2.5mm;
}

/* Dialogs */
.plain-dialog {
  width: min(430px, calc(100% - 28px));
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 26px 28px 28px;
  border: 1px solid var(--line-dark);
  border-radius: 0;
  color: var(--ink-strong);
  background: #fff;
  box-shadow: 5px 5px 0 rgba(23, 49, 79, 0.16);
}

.plain-dialog::backdrop {
  background: rgba(16, 31, 47, 0.45);
}

.plain-dialog h2 {
  margin: 0;
  font-family: "STSong", "Songti SC", serif;
  font-size: 23px;
}

.plain-dialog > p,
.plain-dialog form > p:not(.form-error) {
  margin: 10px 0 20px;
  color: var(--ink-muted);
  font-size: 12px;
  line-height: 1.65;
}

.dialog-rule {
  width: 42px;
  height: 4px;
  margin-bottom: 18px;
  background: var(--red);
}

.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}

.icon-close {
  width: 32px;
  height: 32px;
  padding: 0;
  color: var(--ink-muted);
  font-size: 24px;
  line-height: 1;
}

.recovery-code {
  margin: 18px 0 12px;
  padding: 15px 12px;
  border: 1px dashed var(--ink);
  color: var(--ink);
  background: var(--soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-align: center;
  overflow-wrap: anywhere;
}

.acknowledge-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 17px 0;
  color: var(--ink-muted);
  font-size: 12px;
  line-height: 1.5;
}

.acknowledge-row input {
  flex: 0 0 auto;
  margin-top: 2px;
}

.account-ledger {
  margin: 18px 0;
  border-top: 1px solid var(--line-dark);
}

.account-ledger > div {
  display: grid;
  grid-template-columns: 100px 1fr;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.account-ledger dt {
  color: var(--ink-muted);
}

.account-ledger dd {
  margin: 0;
  font-weight: 700;
}

.status-label,
.large-status {
  display: inline-block;
  border: 1px solid currentColor;
  line-height: 1;
  font-weight: 700;
}

.status-label {
  padding: 3px 6px;
  font-size: 11px;
}

.status-active,
.status-unused {
  color: var(--green);
}

.status-used {
  color: var(--ink-muted);
}

.status-disabled,
.status-failed {
  color: var(--red);
}

.status-pending {
  color: var(--amber);
}

/* Admin */
.admin-login-shell {
  display: grid;
  min-height: 100vh;
  padding: 32px 16px;
  place-items: center;
  background: var(--canvas);
}

.admin-login-sheet {
  width: min(400px, 100%);
  padding: 28px 32px 34px;
  box-shadow: 5px 5px 0 rgba(23, 49, 79, 0.14);
}

.admin-brand {
  margin-bottom: 34px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.admin-login-heading {
  margin-bottom: 23px;
}

.admin-login-heading h1 {
  font-size: 26px;
}

.admin-shell {
  display: grid;
  grid-template: 58px 1fr / 216px 1fr;
  min-height: 100vh;
  background: #f3f5f6;
}

.admin-topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px 0 16px;
  border-bottom: 1px solid var(--line-dark);
  background: #fff;
}

.compact-brand .brand-mark {
  width: 34px;
  height: 34px;
}

.compact-brand strong {
  font-size: 16px;
}

.compact-brand small {
  font-size: 10px;
}

.admin-top-actions {
  color: var(--ink-muted);
  font-size: 12px;
}

.admin-top-actions .text-button {
  min-height: 30px;
  padding: 0 4px;
  font-size: 11px;
}

.admin-sidebar {
  position: sticky;
  top: 58px;
  display: flex;
  height: calc(100vh - 58px);
  flex-direction: column;
  justify-content: space-between;
  border-right: 1px solid var(--line-dark);
  background: #f9fafb;
}

.admin-sidebar nav {
  padding: 14px 0;
}

.admin-nav-item {
  display: grid;
  width: 100%;
  height: 44px;
  grid-template-columns: 34px 1fr;
  align-items: center;
  border: 0;
  border-left: 3px solid transparent;
  color: var(--ink-muted);
  background: transparent;
  padding: 0 18px 0 14px;
  font-size: 13px;
  text-align: left;
}

.admin-nav-item span {
  color: #8a96a0;
  font-family: Georgia, serif;
  font-size: 11px;
}

.admin-nav-item:hover {
  color: var(--ink);
  background: #f0f3f5;
}

.admin-nav-item.is-active {
  border-left-color: var(--red);
  color: var(--ink-strong);
  background: #e9eef2;
  font-weight: 700;
}

.sidebar-footnote {
  padding: 16px 17px;
  border-top: 1px solid var(--line);
  color: #7b8792;
  font-size: 10px;
  line-height: 1.5;
}

.admin-main {
  min-width: 0;
  padding: 27px 30px 60px;
}

.admin-notice {
  top: 70px;
}

.admin-section {
  max-width: 1360px;
  margin: 0 auto;
}

.admin-section-heading {
  min-height: 54px;
  margin-bottom: 20px;
  padding-bottom: 13px;
  border-bottom: 2px solid var(--ink);
}

.admin-section-heading h1 {
  font-size: 25px;
}

.admin-section-heading .eyebrow {
  margin-bottom: 4px;
}

.date-note {
  margin: -10px 0 15px;
  color: var(--ink-muted);
  font-size: 11px;
  text-align: right;
}

.metric-ledger {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line-dark);
  background: #fff;
}

.metric-cell {
  min-height: 122px;
  padding: 18px 20px;
  border-right: 1px solid var(--line);
}

.metric-cell:last-child {
  border-right: 0;
}

.metric-cell span,
.metric-cell strong,
.metric-cell small {
  display: block;
}

.metric-cell span {
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 700;
}

.metric-cell strong {
  margin: 7px 0 5px;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 32px;
  font-weight: 500;
}

.metric-cell small {
  color: #88939d;
  font-size: 10px;
}

.admin-two-column {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 20px;
  margin-top: 20px;
}

.ledger-section {
  min-width: 0;
  padding: 18px 20px 20px;
  border: 1px solid var(--line-dark);
  background: #fff;
}

.section-line-heading {
  padding-bottom: 11px;
  border-bottom: 1px solid var(--line);
}

.section-line-heading span {
  color: var(--ink-muted);
  font-size: 10px;
}

.simple-chart {
  display: grid;
  height: 210px;
  grid-template-columns: repeat(7, 1fr);
  gap: 12px;
  align-items: end;
  padding: 23px 8px 0;
  border-bottom: 1px solid var(--line-dark);
}

.chart-column {
  display: grid;
  height: 100%;
  grid-template-rows: 1fr 24px;
  align-items: end;
  text-align: center;
}

.chart-bar-wrap {
  position: relative;
  display: flex;
  height: 100%;
  align-items: flex-end;
  justify-content: center;
}

.chart-bar {
  width: min(28px, 65%);
  min-height: 2px;
  background: var(--ink);
}

.chart-value {
  position: absolute;
  right: 0;
  bottom: calc(var(--height, 0%) + 4px);
  left: 0;
  color: var(--ink-muted);
  font-family: Georgia, serif;
  font-size: 10px;
  text-align: center;
}

.chart-label {
  padding-top: 7px;
  color: var(--ink-muted);
  font-size: 10px;
}

.activity-list {
  min-height: 210px;
}

.activity-row {
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
}

.activity-row time {
  color: var(--ink-muted);
  white-space: nowrap;
}

.activity-row p {
  margin: 0;
  line-height: 1.5;
}

.batch-strip {
  display: grid;
  grid-template-columns: minmax(200px, 0.55fr) minmax(520px, 1.45fr);
  gap: 24px;
  align-items: end;
  margin-bottom: 18px;
  padding: 17px 19px;
  border: 1px solid var(--line-dark);
  background: #fff;
}

.batch-form {
  display: grid;
  grid-template-columns: 100px 1fr auto;
  gap: 10px;
  align-items: end;
}

.batch-form label {
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 700;
}

.batch-form .field-input {
  margin-top: 5px;
}

.input-short {
  max-width: 100px;
}

.table-toolbar {
  margin: 17px 0 10px;
}

.table-toolbar select {
  width: 130px;
  height: 34px;
  font-size: 12px;
}

.search-input {
  width: 270px;
  height: 34px;
  font-size: 12px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line-dark);
  background: #fff;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  white-space: nowrap;
}

.data-table th,
.data-table td {
  height: 46px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.data-table th {
  height: 40px;
  color: var(--ink-muted);
  background: #f1f4f6;
  font-size: 11px;
  font-weight: 700;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover {
  background: #fafbfc;
}

.data-table .table-empty {
  height: 120px;
}

.activation-code-cell {
  color: var(--ink-strong);
  font-size: 11px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.activation-code-cell.is-historical {
  color: var(--ink-muted);
}

.align-right {
  text-align: right !important;
}

.table-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
}

.table-action-button {
  min-height: 27px;
  padding: 0 7px;
  border: 0;
  color: var(--ink);
  background: transparent;
  font-size: 11px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.table-action-button.danger {
  color: var(--red);
}

.pagination-row {
  display: flex;
  min-height: 40px;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  color: var(--ink-muted);
  font-size: 11px;
}

.page-button {
  min-width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
  font-size: 11px;
}

.page-button.is-active {
  border-color: var(--ink);
  color: #fff;
  background: var(--ink);
}

.statistics-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 20px;
  border: 1px solid var(--line-dark);
  background: #fff;
}

.statistics-summary > div {
  display: flex;
  min-height: 72px;
  align-items: baseline;
  justify-content: space-between;
  padding: 18px 20px;
  border-right: 1px solid var(--line);
}

.statistics-summary > div:last-child {
  border-right: 0;
}

.statistics-summary span {
  color: var(--ink-muted);
  font-size: 12px;
}

.statistics-summary strong {
  color: var(--ink);
  font-family: Georgia, serif;
  font-size: 25px;
  font-weight: 500;
}

.rank-list {
  padding-top: 12px;
}

.rank-row {
  display: grid;
  grid-template-columns: 90px 1fr 50px;
  gap: 10px;
  align-items: center;
  padding: 9px 0;
  font-size: 11px;
}

.rank-bar-track {
  height: 7px;
  background: #e4e8eb;
}

.rank-bar {
  height: 100%;
  background: var(--ink);
}

.rank-value {
  color: var(--ink-muted);
  font-family: Georgia, serif;
  text-align: right;
}

.date-range-controls label {
  color: var(--ink-muted);
  font-size: 11px;
}

.date-range-controls select {
  width: 130px;
  height: 33px;
  font-size: 11px;
}

.date-range-controls span {
  color: var(--ink-muted);
  font-size: 11px;
}

.integration-status-line {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 20px;
  align-items: center;
  padding: 23px 24px;
  border: 1px solid var(--line-dark);
  background: #fff;
}

.large-status {
  padding: 8px 10px;
  font-size: 14px;
  text-align: center;
}

.integration-status-line strong {
  font-size: 15px;
}

.integration-statistics {
  margin-top: 20px;
}

.integration-ledger {
  margin-top: 20px;
  padding: 20px 22px;
  border: 1px solid var(--line-dark);
  background: #fff;
}

.integration-ledger dl {
  margin: 15px 0 0;
  border-top: 1px solid var(--line-dark);
}

.integration-ledger dl > div {
  display: grid;
  grid-template-columns: 150px 1fr 70px;
  gap: 20px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.integration-ledger dt {
  font-weight: 700;
}

.integration-ledger dd {
  margin: 0;
  color: var(--ink-muted);
}

.integration-orders {
  margin-top: 20px;
}

.integration-orders .section-line-heading {
  padding-bottom: 10px;
}

.fulfillment-table {
  min-width: 980px;
}

.check-mark,
.waiting-mark {
  font-size: 11px;
  text-align: right;
}

.check-mark {
  color: var(--green);
}

.waiting-mark {
  color: var(--amber);
}

.interface-note {
  margin-top: 18px;
  padding: 14px 17px;
  border-left: 4px solid var(--ink);
  background: #e9eef2;
  font-size: 12px;
}

.admin-action-dialog {
  width: min(480px, calc(100% - 28px));
}

.admin-action-dialog .dialog-actions {
  justify-content: flex-end;
  margin-top: 22px;
}

.admin-action-dialog .dialog-actions button {
  min-width: 90px;
}

.confirmation-box {
  margin: 15px 0;
  padding: 11px 12px;
  border-left: 3px solid var(--red);
  color: #6f302d;
  background: var(--red-soft);
  font-size: 12px;
  line-height: 1.55;
}

@media (max-width: 1100px) {
  .workbench {
    grid-template-columns: 310px minmax(620px, 1fr);
  }

  .admin-shell {
    grid-template-columns: 184px 1fr;
  }

  .admin-nav-item {
    padding-right: 10px;
  }

  .metric-ledger {
    grid-template-columns: repeat(2, 1fr);
  }

  .metric-cell:nth-child(2) {
    border-right: 0;
  }

  .metric-cell:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .admin-two-column,
  .batch-strip {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  :root {
    --header-height: 56px;
  }

  .site-header {
    padding: 0 14px;
  }

  .brand-lockup small {
    display: none;
  }

  .brand-lockup strong {
    font-size: 16px;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
    font-size: 16px;
  }

  .auth-shell {
    display: block;
    width: calc(100% - 24px);
    margin: 18px auto 36px;
  }

  .auth-sheet {
    min-height: 0;
  }

  .auth-sheet-heading,
  .auth-panel {
    padding-right: 20px;
    padding-left: 20px;
  }

  .auth-sheet-heading {
    padding-top: 23px;
    padding-bottom: 18px;
  }

  .auth-sheet-heading h1 {
    font-size: 24px;
  }

  .field-pair {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .auth-notes {
    padding: 24px 8px 0;
  }

  .workbench {
    display: block;
    height: auto;
    overflow: visible;
  }

  .control-panel {
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line-dark);
  }

  .workspace-tabs {
    top: 0;
  }

  .settings-panel,
  .history-panel {
    padding-right: 16px;
    padding-left: 16px;
  }

  .choice-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .choice-row {
    display: flex;
    min-height: 72px;
    flex-direction: column;
    gap: 5px;
    align-items: center;
    justify-content: center;
    padding: 7px 4px;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    text-align: center;
  }

  .choice-row:last-child {
    border-right: 0;
  }

  .choice-row small {
    display: none;
  }

  .choice-row:has(input:checked) {
    box-shadow: inset 0 -3px 0 var(--ink);
  }

  .preview-pane {
    overflow: visible;
  }

  .preview-toolbar {
    position: sticky;
    top: 0;
    height: 48px;
    padding: 0 12px;
  }

  .preview-status {
    max-width: 42%;
  }

  #previewStatus {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .paper-stage {
    height: auto;
    min-height: 420px;
    padding: 14px 0 36px;
    overflow-x: auto;
  }

  .practice-paper {
    width: 210mm;
    min-height: 297mm;
    margin: 0 auto 14px;
    transform: none;
    zoom: 0.45;
  }

  .plain-dialog {
    padding: 22px 20px 24px;
  }

  .admin-shell {
    display: block;
  }

  .admin-topbar {
    position: sticky;
    height: 55px;
    padding-right: 12px;
  }

  .admin-top-actions {
    gap: 6px;
  }

  .admin-top-actions > span {
    display: none;
  }

  .admin-sidebar {
    position: sticky;
    z-index: 15;
    top: 55px;
    display: block;
    width: 100%;
    height: auto;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line-dark);
    background: #fff;
  }

  .admin-sidebar nav {
    display: flex;
    width: max-content;
    padding: 0;
  }

  .admin-nav-item {
    display: block;
    width: auto;
    height: 42px;
    padding: 0 14px;
    border-bottom: 3px solid transparent;
    border-left: 0;
    white-space: nowrap;
  }

  .admin-nav-item span,
  .sidebar-footnote {
    display: none;
  }

  .admin-nav-item.is-active {
    border-bottom-color: var(--red);
  }

  .admin-main {
    padding: 21px 14px 50px;
  }

  .admin-section-heading {
    align-items: flex-end;
  }

  .admin-section-heading h1 {
    font-size: 22px;
  }

  .metric-ledger,
  .statistics-summary {
    grid-template-columns: 1fr 1fr;
  }

  .metric-cell {
    min-height: 105px;
    padding: 15px;
  }

  .metric-cell strong {
    font-size: 26px;
  }

  .admin-two-column {
    grid-template-columns: 1fr;
  }

  .batch-form {
    grid-template-columns: 90px 1fr;
  }

  .batch-form .primary-button {
    grid-column: 1 / -1;
  }

  .table-toolbar {
    align-items: flex-end;
  }

  .filter-row {
    flex-wrap: wrap;
  }

  .search-input {
    width: min(230px, 62vw);
  }

  .statistics-summary > div {
    min-height: 66px;
    padding: 14px;
  }

  .statistics-summary > div:nth-child(2) {
    border-right: 0;
  }

  .statistics-summary > div:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .date-range-controls select {
    width: 120px;
  }

  .integration-status-line {
    grid-template-columns: 74px 1fr;
    padding: 18px 16px;
  }

  .integration-ledger dl > div {
    grid-template-columns: 90px 1fr;
    gap: 10px;
  }

  .integration-ledger dl span {
    grid-column: 2;
    text-align: left;
  }
}

@media (max-width: 420px) {
  .header-actions {
    gap: 5px;
  }

  .entitlement-stamp {
    display: none;
  }

  .practice-paper {
    zoom: 0.41;
  }

  .metric-ledger {
    grid-template-columns: 1fr;
  }

  .metric-cell,
  .metric-cell:nth-child(2) {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .metric-cell:last-child {
    border-bottom: 0;
  }
}

@page {
  size: A4 portrait;
  margin: 0;
}

@media print {
  :root,
  html,
  body {
    width: auto;
    min-width: 0;
    min-height: 0;
    color: #000;
    background: #fff !important;
  }

  .no-print,
  .skip-link,
  dialog,
  .control-panel,
  .preview-toolbar,
  .paper-empty-state {
    display: none !important;
  }

  .workbench,
  .preview-pane,
  .paper-stage {
    display: block !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    background: #fff !important;
  }

  .practice-paper {
    width: 210mm !important;
    min-height: 297mm !important;
    margin: 0 !important;
    padding: 0 12mm 13mm !important;
    box-shadow: none !important;
    transform: none !important;
    zoom: 1 !important;
    break-after: auto;
    page-break-after: auto;
  }

  .practice-paper + .practice-paper {
    break-before: page;
    page-break-before: always;
  }

  .practice-paper::before {
    display: block;
    height: 11mm;
    content: "";
  }

  .question-paper.last-question-page {
    break-after: auto;
    page-break-after: auto;
  }

  body.answers-visible .question-paper.last-question-page {
    break-after: page;
    page-break-after: always;
  }

  .paper-heading {
    padding-bottom: 3.2mm;
  }

  .student-line {
    padding-top: 3.2mm;
  }

  .question-grid {
    display: grid !important;
    padding: 6mm 0 0;
  }

  .question-item,
  .vertical-question,
  .oral-question,
  .compare-question {
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  .question-answer,
  body.answers-visible .question-answer,
  .comparison-answer,
  body.answers-visible .comparison-answer,
  .vertical-result .answer-only,
  body.answers-visible .vertical-result .answer-only {
    display: none !important;
  }

  body.answers-visible .answer-blank {
    display: inline-block !important;
    border-bottom-color: #282e33 !important;
  }

  body.answers-visible .comparison-circle {
    border-color: #22282d !important;
  }

  body.answers-visible .answer-paper {
    display: block !important;
    break-after: page;
    page-break-after: always;
  }

  body.answers-visible .answer-paper.last-answer-page {
    break-after: auto;
    page-break-after: auto;
  }

  body.answers-visible .question-paper.last-question-page,
  body.answers-visible .answer-paper {
    break-after: auto;
    page-break-after: auto;
  }

  body.answers-visible .answer-paper .answer-sheet {
    display: block !important;
  }

  .paper-footer {
    display: none;
  }
}
