:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --border: #d8dee6;
  --text: #172033;
  --muted: #667085;
  --blue: #20a0b0;
  --blue-dark: #168592;
  --soft: #eef2f6;
  --work-area-height: 560px;
  --review-empty-height: 380px;
  --review-loaded-height: max(620px, calc(100vh - 310px));
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Malgun Gothic", "Segoe UI", sans-serif;
  font-size: 14px;
}

body.login-mode {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #ffffff;
}

.shell {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 14px;
}

body.login-mode .shell {
  width: 360px;
  min-height: 360px;
  display: grid;
  place-items: center;
  padding: 0;
}

body.login-mode .topbar,
body.login-mode #statusBar {
  display: none;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 2px 8px;
  margin-bottom: 4px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar-logo {
  width: 36px;
  height: 44px;
  object-fit: contain;
  display: block;
  flex: 0 0 auto;
}

h1, h2, p { margin: 0; }
h1 { font-size: 22px; letter-spacing: 0; }
h2 { font-size: 17px; margin-bottom: 10px; }
p { color: var(--muted); margin-top: 4px; }

.account {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.panel { padding: 14px; margin-bottom: 10px; }

.login-panel {
  width: min(320px, calc(100vw - 32px));
  min-height: 320px;
  max-height: 360px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 14px;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.login-brand img {
  width: 118px;
  height: 142px;
  object-fit: contain;
  display: block;
}

.login-brand strong {
  font-size: 29px;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1;
  color: #162033;
}

.login-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.login-panel.loading .login-grid {
  display: none;
}

.init-loading {
  min-height: 112px;
  display: grid;
  place-items: center;
  gap: 8px;
  text-align: center;
}

.init-loading strong,
.app-loading-card strong {
  font-size: 15px;
  color: var(--text);
}

.init-loading p,
.app-loading-card p {
  max-width: 280px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.loader-bars {
  display: inline-flex;
  align-items: end;
  gap: 4px;
  height: 28px;
}

.loader-bars span {
  width: 5px;
  height: 10px;
  border-radius: 999px;
  background: var(--blue);
  animation: loader-rise 0.82s ease-in-out infinite;
}

.loader-bars span:nth-child(2) { animation-delay: 0.1s; }
.loader-bars span:nth-child(3) { animation-delay: 0.2s; }
.loader-bars span:nth-child(4) { animation-delay: 0.3s; }

@keyframes loader-rise {
  0%, 100% {
    height: 10px;
    opacity: 0.45;
  }
  50% {
    height: 28px;
    opacity: 1;
  }
}

.login-grid input,
.login-grid button {
  width: 100%;
  height: 38px;
}

.omr-upload-row,
.upload-panel,
.title-panel,
.section-head,
.actions,
.tab-actions,
.pdf-panel,
.pdf-controls,
.pdf-actions,
.cover-row,
.area-scope-control,
.settings-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.omr-upload-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
  gap: 8px;
  margin-bottom: 10px;
}

.tab-panel > .omr-upload-row {
  margin-bottom: 10px;
}

.omr-upload-row > .saved-load-panel {
  margin-bottom: 0;
}

.omr-results-panel {
  transition: outline-color 0.15s ease, background 0.15s ease;
}

.saved-load-panel {
  width: 100%;
  min-width: 0;
  min-height: 56px;
  display: grid;
  grid-template-rows: auto auto;
  align-items: stretch;
  gap: 5px;
}

.saved-load-panel h2 {
  margin-bottom: 0;
  white-space: nowrap;
}

.saved-load-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.saved-load-controls .saved-search-keywords {
  flex: 1 1 260px;
  min-width: 0;
}

.saved-load-controls > button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  height: 36px;
  padding: 8px 11px;
  margin-left: auto;
  line-height: 1;
}

.saved-date-filter {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  min-width: 0;
}

.saved-date-filter input[type="date"] {
  flex: 0 0 124px;
  width: 124px;
  min-width: 0;
  height: 36px;
  padding: 6px 7px;
}

.date-separator {
  color: var(--muted);
  font-size: 12px;
}

.upload-panel {
  justify-content: flex-start;
  border-style: dashed;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  min-height: 56px;
}
.upload-panel.drag-over {
  background: #e7f7f9;
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px rgba(32, 160, 176, 0.22);
}
.upload-copy {
  min-width: 0;
  flex: 1;
}
.upload-copy p {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-button-tall {
  width: 54px;
  min-height: 42px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
  padding: 6px 8px;
}

.pdf-panel {
  justify-content: space-between;
  gap: 12px;
}
.pdf-panel h2 {
  flex: 0 0 auto;
  margin-bottom: 0;
}
.pdf-controls {
  justify-content: flex-end;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
}
.cover-row {
  justify-content: flex-end;
  font-weight: 700;
}
.cover-row span { white-space: nowrap; }
.cover-row select { min-width: 220px; }
.pdf-actions { flex-wrap: nowrap; justify-content: flex-end; }
.title-panel label { font-weight: 700; width: 46px; }
.title-panel input { flex: 1; }
.section-head {
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}
.section-head h2 { margin-bottom: 0; }
.actions { flex-wrap: wrap; justify-content: flex-end; }

.compact-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 0;
  height: 36px;
  padding: 8px 11px;
  line-height: 1;
  white-space: nowrap;
}

.bulk-sheet-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
}

.bulk-sheet-control span,
.bulk-variant-control span {
  color: #475467;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.bulk-variant-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
}

.bulk-sheet-input {
  width: clamp(180px, 24vw, 320px);
  height: 36px;
  padding: 0 8px;
  font-size: 12px;
}

.bulk-variant-control select,
.result-variant-select {
  height: 30px;
  min-width: 74px;
  padding: 0 7px;
  font-size: 12px;
}

.bulk-variant-control select {
  height: 36px;
}

.result-variant-select {
  width: 62px;
  min-width: 0;
  padding: 0 3px;
}

.tab-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.variant-toolbar {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.variant-toolbar .variant-label {
  color: #475467;
  font-size: 13px;
  font-weight: 800;
}

.variant-toolbar select {
  height: 34px;
  min-width: 110px;
  padding: 5px 8px;
}

.variant-select-hidden {
  display: none;
}

.variant-badges {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  min-height: 34px;
  max-width: min(520px, 100%);
}

.variant-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 160px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid #cbd5df;
  border-radius: 999px;
  background: #ffffff;
  color: #344054;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.variant-badge:hover {
  border-color: #8ad7df;
  background: #f4fbfc;
}

.variant-badge.active {
  border-color: #1ea6b7;
  background: #e3f8fb;
  color: #075d68;
  box-shadow: inset 0 0 0 1px rgba(30, 166, 183, 0.12);
}

.variant-toolbar button {
  height: 34px;
  padding: 7px 10px;
}

button.danger-text {
  border-color: #f3b4b4;
  color: #b42318;
}

button.danger-text:hover {
  background: #fff1f1;
}

.area-scope-control {
  height: 36px;
  font-weight: 700;
}

.area-scope-control span {
  white-space: nowrap;
}

.area-scope-control select {
  height: 36px;
  min-width: 250px;
  padding: 6px 8px;
}

input, select, textarea, button {
  font-family: inherit;
  font-size: 14px;
}

input, select, textarea {
  border: 1px solid #cbd5df;
  border-radius: 6px;
  background: white;
  padding: 8px 9px;
  color: var(--text);
}

button,
.file-button {
  border: 1px solid var(--blue);
  background: var(--blue);
  color: white;
  border-radius: 6px;
  padding: 8px 11px;
  cursor: pointer;
  white-space: nowrap;
}

button:hover,
.file-button:hover { background: var(--blue-dark); }

button.secondary {
  background: var(--soft);
  border-color: #cbd5df;
  color: var(--text);
}

button.ghost {
  background: transparent;
  border-color: #cbd5df;
  color: var(--text);
}

button.swift-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 33px;
  padding: 5px 8px 5px 10px;
  background: #ffffff;
  border-color: #cbd5df;
  color: var(--text);
}

button.swift-toggle:hover {
  background: #f5f9ff;
}

.swift-toggle-label {
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.swift-toggle-track {
  position: relative;
  width: 36px;
  height: 19px;
  border-radius: 999px;
  background: #cbd5df;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.18);
  transition: background 0.18s ease;
}

.swift-toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 13px;
  height: 13px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.28);
  transition: transform 0.18s ease;
}

button.swift-toggle.active {
  border-color: #1aa7b5;
  color: #087987;
}

button.swift-toggle.active .swift-toggle-track {
  background: #1aa7b5;
}

button.swift-toggle.active .swift-toggle-thumb {
  transform: translateX(17px);
}

button.danger {
  background: #dc2626;
  border-color: #b91c1c;
  color: #ffffff;
}

button.danger:hover {
  background: #b91c1c;
}

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

.app-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  cursor: progress;
  background: rgba(255, 255, 255, 0.76);
  backdrop-filter: blur(4px);
}

.app-loading-card {
  width: min(320px, calc(100vw - 32px));
  min-height: 260px;
  display: grid;
  place-items: center;
  gap: 10px;
  padding: 26px;
  text-align: center;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 18px 44px rgba(23, 32, 51, 0.16);
}

.app-loading-card img {
  width: 104px;
  height: 126px;
  object-fit: contain;
}

.swift-notice-overlay {
  z-index: 55;
}

.swift-notice-card {
  min-height: 230px;
  gap: 12px;
}

.swift-notice-icon {
  font-size: 76px;
  line-height: 1;
  filter: drop-shadow(0 6px 12px rgba(245, 158, 11, 0.28));
}

.swift-notice-card strong {
  font-size: 18px;
  color: var(--text);
}

.swift-notice-card p {
  max-width: 250px;
  margin-top: 0;
  line-height: 1.45;
}

.file-button input { display: none; }

.tabs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0;
  margin: 10px 0 0;
  padding: 0;
  background: transparent;
  border-bottom: 1px solid var(--border);
  overflow: visible;
}

.tab {
  background: transparent;
  border-color: transparent;
  color: #475467;
  border-radius: 7px 7px 0 0;
  padding: 10px 20px;
  font-weight: 700;
  position: relative;
  margin-bottom: -1px;
}

.tab.active {
  background: var(--panel);
  border-color: var(--border);
  border-bottom-color: var(--panel);
  color: var(--blue);
  box-shadow: none;
  transform: none;
}

.tab:hover {
  background: #f7f9fc;
  color: var(--text);
}

.tab.active:hover {
  background: var(--panel);
  color: var(--blue);
}

.tab-status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 4px;
  margin-left: auto;
  max-width: min(720px, 58vw);
  padding: 0 2px 7px 12px;
  color: #475467;
  font-size: 12px;
  line-height: 1.25;
  text-align: right;
}

.status-item {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-item.task {
  padding: 2px 7px;
  border: 1px solid #b8e4e8;
  border-radius: 999px;
  background: #e9f8fa;
  color: #137887;
  font-weight: 700;
}

.status-item.base {
  color: #667085;
}

.tab-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  padding: 10px;
  margin-bottom: 10px;
}

.tab-panel > .panel:last-child,
.tab-panel > .grid:last-child,
.tab-panel > .review-grid:last-child {
  margin-bottom: 0;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 10px;
}

.review-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 10px;
}

.table-wrap {
  overflow: auto;
  max-height: var(--work-area-height);
  border: 1px solid var(--border);
  border-radius: 6px;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 760px;
  background: white;
}

th, td {
  border-bottom: 1px solid #e1e7ef;
  border-right: 1px solid #e1e7ef;
  padding: 7px;
  text-align: left;
}

th {
  background: #eef2f6;
  font-weight: 700;
  position: sticky;
  top: 0;
}

td[contenteditable="true"] { background: #fff; }
td:focus { outline: 2px solid #8ad7df; outline-offset: -2px; }
tr.selected-row td { background: #e7f7f9; }

#blueprintTable {
  table-layout: fixed;
  min-width: 640px;
  font-size: 10pt;
}

#blueprintTable th,
#blueprintTable td,
#blueprintTable select {
  font-size: 10pt;
  line-height: 1.2;
}

#blueprintTable th,
#blueprintTable td {
  padding: 4px 5px;
}

#blueprintTable th {
  text-align: center;
}

#blueprintTable .two-line-header {
  line-height: 1.1;
}

#blueprintTable th:nth-child(1) { width: 58px; }
#blueprintTable th:nth-child(2) { width: 64px; }
#blueprintTable th:nth-child(3) { width: 78px; }
#blueprintTable th:nth-child(5) { width: 118px; }
#blueprintTable th:nth-child(6) { width: 82px; }

#scoreTotal {
  font-weight: 600;
  white-space: nowrap;
}

#blueprintTable .cell-select {
  min-width: 0;
  height: 26px;
  padding: 2px 4px;
}

.select-cell {
  padding: 4px;
}

.cell-select {
  width: 100%;
  min-width: 112px;
  height: 32px;
  padding: 4px 6px;
  border-radius: 4px;
}

.sheet-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.review-result-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.review-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: var(--review-empty-height);
  min-height: var(--review-empty-height);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  background: #fbfcfe;
}

.review-results.empty {
  justify-content: center;
  align-items: center;
  color: var(--muted);
  text-align: center;
}

.review-item {
  width: 100%;
  display: grid;
  gap: 5px;
  text-align: left;
  white-space: normal;
  color: var(--text);
  background: #ffffff;
  border-color: var(--border);
  padding: 10px;
}

.review-item:hover {
  background: #f4fbfc;
  border-color: #8ad7df;
}

.review-item.active {
  background: #e7f7f9;
  border-color: var(--blue);
  box-shadow: inset 3px 0 0 var(--blue);
}

.review-item .review-meta {
  color: var(--blue);
  font-weight: 700;
  font-size: 12px;
}

.review-item .review-severity {
  color: inherit;
}

.review-item .review-severity.severity-medium {
  color: #d97706;
}

.review-item .review-severity.severity-high {
  color: #dc2626;
}

.review-item strong {
  font-size: 13px;
  line-height: 1.45;
}

.review-item small {
  color: var(--muted);
  line-height: 1.4;
}

#reviewText {
  width: 100%;
  height: var(--review-empty-height);
  min-height: var(--review-empty-height);
  resize: vertical;
  line-height: 1.55;
}

#reviewTab.review-loaded #reviewText,
#reviewTab.review-loaded .review-results {
  height: var(--review-loaded-height);
  min-height: var(--review-loaded-height);
}

.settings-row { margin-bottom: 10px; }
.settings-row input[type="password"] { min-width: 360px; }

.message { min-height: 20px; color: var(--muted); }
.hidden { display: none !important; }

.omr-shell {
  width: min(1180px, 100%);
}

.scan-layout {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.omr-drop-zone {
  min-height: 84px;
}

.omr-results-panel {
  min-width: 0;
}

.omr-table-wrap {
  position: relative;
  width: 100%;
  height: clamp(240px, 24vh, 420px);
  min-width: 0;
  max-width: 100%;
  min-height: 180px;
  max-height: 60vh;
  overflow: auto;
  transition: box-shadow 0.15s ease, background 0.15s ease;
}

.omr-table-wrap.drag-over {
  background: #f4fbfc;
  box-shadow: inset 0 0 0 2px rgba(32, 160, 176, 0.24);
}

.omr-table {
  table-layout: fixed;
  min-width: 1048px;
  width: 100%;
}

.omr-table th,
.omr-table td {
  padding: 4px 5px;
  font-size: 10pt;
  line-height: 1.2;
}

.omr-table th:nth-child(1) { width: 78px; }
.omr-table th:nth-child(2) { width: 56px; }
.omr-table th:nth-child(3) { width: 76px; }
.omr-table th:nth-child(4) { width: 400px; }
.omr-table th:nth-child(5) { width: 62px; }
.omr-table th:nth-child(6) { width: 196px; }
.omr-table th:nth-child(7) { width: 72px; }
.omr-table th:nth-child(8) { width: 132px; }

.omr-table th:nth-child(8),
.omr-table td:nth-child(8) {
  position: sticky;
  right: 0;
  z-index: 2;
}

.omr-table th:nth-child(8) {
  z-index: 3;
}

.omr-table td {
  overflow: hidden;
  text-overflow: ellipsis;
}

.omr-table tr.needs-review td { background: #fff8ed; }
.omr-table tr[data-status="wrong"] td { background: #fff4e8; }
.omr-table tr[data-status="missing"] td,
.omr-table tr[data-status="multi"] td,
.omr-table tr[data-status="student"] td,
.omr-table tr[data-status="sheet"] td,
.omr-table tr[data-status="scan"] td {
  background: #fff1f2;
}

.omr-table tbody tr {
  cursor: pointer;
  user-select: none;
}

.omr-table tr.selected-row td {
  background: #dff5f7 !important;
}

.analysis-panel {
  min-width: 0;
}

.analysis-table-wrap {
  width: 100%;
  height: clamp(360px, calc(100vh - 320px), 720px);
  min-height: 280px;
  max-height: calc(100vh - 250px);
  overflow: auto;
  resize: both;
}

.analysis-table {
  table-layout: fixed;
  min-width: 1020px;
  width: 100%;
}

.analysis-table th,
.analysis-table td {
  padding: 5px 6px;
  font-size: 10pt;
  line-height: 1.25;
}

.analysis-table th:nth-child(1) { width: 78px; }
.analysis-table th:nth-child(2) { width: 58px; }
.analysis-table th:nth-child(3) { width: 86px; }
.analysis-table th:nth-child(4) { width: 132px; }
.analysis-table th:nth-child(5) { width: 132px; }
.analysis-table th:nth-child(6) { width: 76px; }
.analysis-table th:nth-child(7) { width: 330px; }
.analysis-table th:nth-child(8) { width: 92px; }

.analysis-table td {
  overflow: hidden;
  text-overflow: ellipsis;
}

.analysis-table tbody tr {
  cursor: pointer;
  user-select: none;
}

.analysis-table tr.selected-row td {
  background: #dff5f7 !important;
}

.send-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.send-label {
  color: #475467;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.send-controls select {
  width: 132px;
  height: 32px;
  padding: 0 8px;
  font-size: 12px;
}

.analysis-status-cell {
  font-weight: 700;
  color: #475467;
}

.exam-analysis-filter-panel {
  margin-bottom: 10px;
}

.exam-analysis-controls {
  display: grid;
  grid-template-columns: minmax(280px, 1.8fr) 120px 148px 148px 170px;
  gap: 8px;
  align-items: end;
}

.exam-analysis-controls label {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.exam-analysis-controls span {
  color: #475467;
  font-size: 12px;
  font-weight: 700;
}

.exam-analysis-controls input,
.exam-analysis-controls select {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
}

.exam-analysis-output {
  display: grid;
  gap: 10px;
}

.exam-analysis-empty {
  min-height: 96px;
  display: grid;
  place-items: center;
  color: #667085;
  font-weight: 700;
}

.exam-report-panel {
  display: grid;
  gap: 12px;
}

.exam-report-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid #1f2937;
}

.exam-report-head p {
  margin: 0 0 4px;
  color: #168592;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
}

.exam-report-head h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
}

.exam-report-head span {
  display: block;
  margin-top: 5px;
  color: #667085;
  font-size: 12px;
}

.exam-summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.exam-summary-card {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfe;
}

.exam-summary-card span,
.exam-summary-card em {
  display: block;
  color: #667085;
  font-size: 11px;
  font-style: normal;
}

.exam-summary-card strong {
  display: block;
  margin: 4px 0 2px;
  color: var(--text);
  font-size: 20px;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.exam-analysis-grid {
  display: grid;
  grid-template-columns: minmax(360px, .9fr) minmax(420px, 1.1fr);
  gap: 10px;
}

.exam-distribution {
  height: 230px;
  display: grid;
  grid-template-columns: repeat(11, minmax(32px, 1fr));
  gap: 6px;
  align-items: end;
}

.exam-dist-bar {
  height: 100%;
  display: grid;
  grid-template-rows: 1fr auto auto;
  gap: 4px;
  min-width: 0;
  text-align: center;
}

.exam-dist-column {
  display: flex;
  align-items: end;
  justify-content: center;
  min-height: 0;
  border-radius: 6px;
  background: #eef4f6;
  overflow: hidden;
}

.exam-dist-column span {
  display: block;
  width: 100%;
  border-radius: 6px 6px 0 0;
  background: #20a0b0;
}

.exam-dist-bar strong {
  color: var(--text);
  font-size: 12px;
}

.exam-dist-bar em {
  color: #667085;
  font-size: 10px;
  font-style: normal;
  white-space: nowrap;
}

.exam-rank-table-wrap,
.exam-category-table-wrap,
.exam-item-table-wrap {
  width: 100%;
  overflow: auto;
}

.exam-special-panel .exam-rank-table-wrap {
  max-height: 230px;
}

.exam-analysis-grid .exam-category-table-wrap {
  max-height: 230px;
}

.exam-rank-panel .exam-rank-table-wrap {
  max-height: 360px;
}

.exam-item-table-wrap {
  max-height: 460px;
}

.exam-rank-table,
.exam-category-table,
.exam-item-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  min-width: 900px;
}

.exam-category-table {
  min-width: 520px;
}

.exam-item-table {
  min-width: 1360px;
}

.exam-rank-table th,
.exam-rank-table td,
.exam-category-table th,
.exam-category-table td,
.exam-item-table th,
.exam-item-table td {
  padding: 5px 6px;
  border: 1px solid var(--border);
  font-size: 10pt;
  line-height: 1.22;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
}

.exam-rank-table th,
.exam-category-table th,
.exam-item-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef4f8;
  color: var(--text);
}

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

.exam-rank-table td:nth-child(3),
.exam-rank-table td:nth-child(5),
.exam-rank-table td:nth-child(6),
.exam-item-table td:nth-child(2),
.exam-item-table td:nth-child(8),
.exam-category-table td:nth-child(1) {
  text-align: left;
}

.exam-item-table th:nth-child(1), .exam-item-table td:nth-child(1) { width: 42px; }
.exam-item-table th:nth-child(2), .exam-item-table td:nth-child(2) { width: 172px; }
.exam-item-table th:nth-child(3), .exam-item-table td:nth-child(3) { width: 48px; }
.exam-item-table th:nth-child(4), .exam-item-table td:nth-child(4) { width: 62px; }
.exam-item-table th:nth-child(5), .exam-item-table td:nth-child(5) { width: 62px; }
.exam-item-table th:nth-child(6), .exam-item-table td:nth-child(6) { width: 62px; }
.exam-item-table th:nth-child(7), .exam-item-table td:nth-child(7) { width: 62px; }
.exam-item-table th:nth-child(8), .exam-item-table td:nth-child(8) {
  width: 770px;
  white-space: nowrap;
}
.exam-item-table th:nth-child(9), .exam-item-table td:nth-child(9) { width: 84px; }

.exam-rank-table tr.managed td,
.exam-item-table tr.flagged td {
  background: #fff7ed;
}

.exam-management-pill,
.exam-item-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid #fed7aa;
  background: #ffedd5;
  color: #c2410c;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.exam-management-pill {
  border-color: #fecaca;
  background: #fff1f2;
  color: #be123c;
}

.exam-mini-bar {
  display: inline-block;
  width: 78px;
  height: 8px;
  margin-right: 6px;
  border-radius: 999px;
  background: #e5e7eb;
  vertical-align: middle;
  overflow: hidden;
}

.exam-mini-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #20a0b0;
}

.sms-log-panel {
  min-width: 0;
}

.sms-log-table-wrap {
  width: 100%;
  height: clamp(360px, calc(100vh - 250px), 760px);
  min-height: 280px;
  overflow: auto;
  resize: vertical;
}

.sms-log-table {
  table-layout: fixed;
  min-width: 980px;
  width: 100%;
}

.sms-log-table th,
.sms-log-table td {
  padding: 5px 6px;
  font-size: 10pt;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sms-log-table th:nth-child(1) { width: 130px; }
.sms-log-table th:nth-child(2) { width: 64px; }
.sms-log-table th:nth-child(3) { width: 64px; }
.sms-log-table th:nth-child(4) { width: 120px; }
.sms-log-table th:nth-child(5) { width: 120px; }
.sms-log-table th:nth-child(6) { width: 82px; }
.sms-log-table th:nth-child(7) { width: 300px; }
.sms-log-table th:nth-child(8) { width: 100px; }

.sms-success-row td:nth-child(2) {
  color: #168592;
  font-weight: 700;
}

.sms-fail-row td:nth-child(2) {
  color: #b42318;
  font-weight: 700;
}

.sms-progress-row td:nth-child(2) {
  color: #c2410c;
  font-weight: 700;
}

.sms-shell {
  width: min(1240px, 100%);
}

.sms-admin-panel {
  padding: 10px;
}

.sms-filter-panel,
.sms-summary-panel,
.sms-admin-table-panel {
  margin-bottom: 10px;
}

.sms-admin-controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(118px, 150px)) minmax(260px, 1fr) repeat(2, minmax(112px, 132px));
  gap: 8px;
  align-items: end;
}

.sms-admin-controls label {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.sms-admin-controls span {
  color: #475467;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}

.sms-admin-controls input,
.sms-admin-controls select {
  width: 100%;
  height: 36px;
  min-width: 0;
}

.sms-keyword-field {
  min-width: 0;
}

.sms-summary-panel {
  min-height: 0;
  padding: 10px 14px;
}

.sms-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sms-summary-chip,
.sms-status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 23px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid #cbd5df;
  background: #f8fafc;
  color: #475467;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.sms-status-badge.success,
.sms-summary-chip.success {
  border-color: #a7e0ca;
  background: #e8f8f1;
  color: #087443;
}

.sms-status-badge.fail,
.sms-summary-chip.fail {
  border-color: #fecaca;
  background: #fff1f2;
  color: #be123c;
}

.sms-status-badge.running,
.sms-summary-chip.running,
.sms-status-badge.retry,
.sms-summary-chip.retry {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #c2410c;
}

.sms-admin-table-wrap {
  width: 100%;
  height: clamp(420px, calc(100vh - 260px), 760px);
  overflow: auto;
}

.sms-admin-table {
  table-layout: fixed;
  min-width: 1220px;
  width: 100%;
}

.sms-admin-table th,
.sms-admin-table td {
  padding: 5px 6px;
  font-size: 10pt;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sms-admin-table th:nth-child(1) { width: 136px; }
.sms-admin-table th:nth-child(2) { width: 60px; }
.sms-admin-table th:nth-child(3) { width: 82px; }
.sms-admin-table th:nth-child(4) { width: 64px; }
.sms-admin-table th:nth-child(5) { width: 118px; }
.sms-admin-table th:nth-child(6) { width: 118px; }
.sms-admin-table th:nth-child(7) { width: 82px; }
.sms-admin-table th:nth-child(8) { width: 230px; }
.sms-admin-table th:nth-child(9) { width: 54px; }
.sms-admin-table th:nth-child(10) { width: 120px; }
.sms-admin-table th:nth-child(11) { width: 256px; }

.sms-site-cell,
.sms-result-cell {
  color: #475467;
}

.sms-title-cell,
.sms-message-cell {
  color: var(--text);
}

.sms-empty-cell {
  height: 160px;
  color: var(--muted);
  text-align: center;
}

.sms-pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  color: #475467;
  font-size: 12px;
}

.hidden-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.settings-panel {
  min-height: 168px;
}

.report-logo-settings {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.report-logo-preview {
  width: 220px;
  min-height: 92px;
  display: grid;
  place-items: center;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfe;
  color: #98a2b3;
  font-weight: 800;
  letter-spacing: 0;
}

.report-logo-preview img {
  display: block;
  max-width: 100%;
  max-height: 96px;
  object-fit: contain;
}

.report-logo-preview.empty {
  border-style: dashed;
}

.report-logo-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.settings-form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: start;
}

.settings-field {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.settings-field span,
.placeholder-list {
  color: #475467;
  font-size: 12px;
  font-weight: 700;
}

.settings-field input,
.settings-field textarea {
  width: 100%;
}

.settings-field textarea {
  resize: vertical;
  min-height: 118px;
  line-height: 1.45;
}

.callback-settings,
.campus-callback-settings,
.sms-template-field {
  grid-column: 1 / -1;
}

.callback-add-row {
  display: flex;
  gap: 6px;
}

.callback-add-row input {
  flex: 1 1 auto;
}

.callback-list,
.placeholder-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.callback-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 9px;
  border: 1px solid #b8e4e8;
  border-radius: 999px;
  background: #e9f8fa;
  color: #137887;
  font-size: 12px;
  font-weight: 700;
}

.callback-chip button {
  height: 20px;
  min-width: 36px;
  padding: 0 6px;
  border-radius: 999px;
  background: #ffffff;
  color: #475467;
  font-size: 11px;
}

.callback-empty {
  color: var(--muted);
  font-size: 12px;
}

.settings-empty {
  padding: 9px 10px;
  border: 1px dashed var(--border);
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
  background: #fbfcfe;
}

.campus-map-list {
  display: grid;
  gap: 6px;
  max-height: 240px;
  overflow: auto;
  padding: 1px;
}

.campus-map-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 180px;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid #e4e9f0;
  border-radius: 6px;
  background: #ffffff;
}

.campus-map-row strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.campus-map-row select {
  width: 100%;
  height: 30px;
  font-size: 12px;
}

.account-group-settings-panel {
  min-height: 220px;
}

.account-group-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.account-group-toolbar input {
  flex: 1 1 240px;
  max-width: 360px;
}

.account-group-list {
  display: grid;
  gap: 10px;
}

.account-group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}

.account-group-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid #e4e9f0;
  border-radius: 7px;
  background: #ffffff;
}

.account-group-editor span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.account-user-table-wrap {
  max-height: 300px;
  overflow: auto;
  border: 1px solid #e4e9f0;
  border-radius: 7px;
  background: #ffffff;
}

.account-user-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.account-user-table th,
.account-user-table td {
  padding: 7px 8px;
  border-bottom: 1px solid #edf1f5;
  text-align: left;
}

.account-user-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f3f7fb;
  color: #344054;
}

.account-user-table tr.inactive {
  color: #98a2b3;
}

.account-user-table select {
  width: 100%;
  height: 30px;
  font-size: 12px;
}

.placeholder-list code {
  padding: 3px 6px;
  border-radius: 5px;
  background: #eef2f6;
  color: #344054;
  font-family: "Malgun Gothic", "Segoe UI", sans-serif;
  font-size: 12px;
}

.storage-status {
  display: grid;
  gap: 10px;
}

.storage-disk-card,
.storage-cleanup-card,
.storage-dir-card {
  border: 1px solid #e4e9f0;
  border-radius: 7px;
  background: #ffffff;
}

.storage-disk-card,
.storage-cleanup-card {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.storage-disk-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #475467;
  font-size: 12px;
}

.storage-disk-line strong,
.storage-cleanup-card strong,
.storage-dir-card strong {
  color: var(--text);
  font-size: 13px;
}

.storage-meter {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #eef2f6;
}

.storage-meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #20a0b0;
}

.storage-dir-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.storage-dir-card {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 9px;
}

.storage-dir-card span,
.storage-cleanup-card span,
.storage-cleanup-card small {
  color: #667085;
  font-size: 12px;
  line-height: 1.4;
}

.storage-cleanup-card small {
  display: block;
}

.omr-table-upload-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.94);
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.omr-table-upload-overlay.drag-over,
.omr-table-wrap.drag-over .omr-table-upload-overlay {
  background: rgba(231, 247, 249, 0.96);
  box-shadow: inset 0 0 0 2px rgba(32, 160, 176, 0.24);
}

.table-upload-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 18px;
  text-align: center;
}

.table-upload-prompt h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.table-upload-prompt p {
  margin: 0;
  color: var(--muted);
  white-space: normal;
}

.table-upload-button {
  margin-top: 2px;
  min-width: 92px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 66px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid #cbd5df;
  background: #eef2f6;
  color: #344054;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-button {
  cursor: pointer;
}

.status-button:hover {
  filter: brightness(0.96);
}

.editable-cell {
  cursor: text;
}

.editable-cell:hover {
  background: #e7f7f9 !important;
}

.inline-edit-input {
  width: 100%;
  min-width: 54px;
  height: 28px;
  padding: 3px 6px;
  border-radius: 4px;
  border: 1px solid #8ad7df;
  font: inherit;
}

.status-pill.ok {
  border-color: #9fd3b0;
  background: #e8f8ee;
  color: #17633a;
}

.status-pill.wrong {
  border-color: #f3b27a;
  background: #ffe8d5;
  color: #8a3b0c;
}

.status-pill.student,
.status-pill.missing,
.status-pill.multi,
.status-pill.sheet,
.status-pill.scan {
  border-color: #f6a6b2;
  background: #ffe4e8;
  color: #9f1239;
}

.status-detail {
  display: inline-block;
  margin-left: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.answer-chip-wrap {
  display: grid;
  grid-template-columns: repeat(10, minmax(37px, 1fr));
  gap: 3px;
  max-height: 125px;
  overflow: auto;
}

.answer-chip {
  padding: 1px 3px;
  width: 100%;
  min-width: 0;
  height: 20px;
  border-radius: 4px;
  font-size: 10px;
  line-height: 1.1;
  background: #eef2f6;
  border-color: #cbd5df;
  color: var(--text);
}

.answer-chip:hover {
  background: #e7f7f9;
  border-color: #8ad7df;
}

.answer-chip.selected {
  background: #dff5f7;
  border-color: #20a0b0;
  color: #137887;
  box-shadow: inset 0 0 0 1px #20a0b0;
}

.answer-edit-input {
  width: 36px;
  min-width: 38px;
  height: 20px;
  padding: 1px 3px;
  border-radius: 4px;
  border: 1px solid #8ad7df;
  background: #fff;
  font-size: 10px;
  text-align: center;
}

.answer-chip.bad {
  background: #ffe8d5;
  border-color: #f3b27a;
  color: #8a3b0c;
}

.answer-chip.empty {
  border-style: dashed;
}

.sheet-select,
.sheet-picker-trigger {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet-picker-trigger {
  display: block;
  height: 28px;
  padding: 3px 7px;
  text-align: left;
  background: #ffffff;
  border: 1px solid #cbd5df;
  border-radius: 4px;
  color: var(--text);
  font-size: 10pt;
  font-weight: 500;
}

.sheet-picker-trigger:hover {
  border-color: #8ad7df;
  background: #f4fbfc;
}

.sheet-picker-popover {
  position: fixed;
  z-index: 100;
  display: grid;
  gap: 6px;
  padding: 8px;
  background: #ffffff;
  border: 1px solid #b9c5d4;
  border-radius: 6px;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.18);
}

.sheet-picker-input {
  width: 100%;
  height: 32px;
  padding: 5px 8px;
  border: 1px solid #8ad7df;
  border-radius: 4px;
  font-size: 13px;
}

.sheet-picker-list {
  display: grid;
  gap: 2px;
  max-height: 230px;
  overflow: auto;
}

.sheet-picker-option {
  width: 100%;
  min-height: 28px;
  padding: 5px 7px;
  text-align: left;
  background: #ffffff;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  white-space: normal;
}

.sheet-picker-option:hover,
.sheet-picker-option.selected {
  background: #e7f7f9;
  border-color: #8ad7df;
  color: #137887;
}

.sheet-picker-empty {
  padding: 8px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.omr-preview-panel {
  width: 100%;
  height: clamp(460px, calc((100vw - 80px) * 0.707 + 74px), 840px);
  min-width: 0;
  min-height: 360px;
  max-width: 100%;
  max-height: calc(100vh - 260px);
  display: flex;
  flex-direction: column;
  resize: both;
  overflow: auto;
}

.preview-canvas {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fbfcfe;
  width: 100%;
  height: auto;
  min-height: 320px;
  aspect-ratio: 297 / 210;
  overflow: auto;
  display: grid;
  place-items: start center;
  padding: 8px;
}

.preview-canvas.empty {
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.preview-stage {
  position: relative;
  width: 100%;
  min-width: 320px;
}

.preview-stage img {
  width: 100%;
  display: block;
}

.preview-marker {
  position: absolute;
  border: 3px solid #ef4444;
  background: rgba(239, 68, 68, 0.10);
  pointer-events: none;
}

.preview-meta {
  min-height: 34px;
  padding-top: 8px;
  color: var(--muted);
  line-height: 1.4;
}

.placeholder-box {
  min-height: 280px;
  border: 1px dashed var(--border);
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: #fbfcfe;
}

#statusBar {
  color: #475467;
}

@media (max-width: 900px) {
  .grid, .review-grid { grid-template-columns: 1fr; }
  .upload-panel, .section-head { align-items: stretch; flex-direction: column; }
  .pdf-panel, .pdf-controls { align-items: stretch; flex-direction: column; }
  .cover-row, .pdf-actions { justify-content: stretch; }
  .pdf-actions { flex-wrap: wrap; }
  .omr-upload-row { grid-template-columns: 1fr; align-items: stretch; }
  .saved-load-panel { align-items: stretch; }
  .saved-load-controls { align-items: stretch; flex-direction: column; }
  .saved-date-filter { width: 100%; }
  .saved-date-filter input[type="date"] { flex: 1 1 0; width: auto; }
  .saved-load-controls .saved-search-keywords { width: 100%; flex-basis: auto; }
  .report-logo-settings { grid-template-columns: 1fr; }
  .report-logo-preview { width: 100%; }
  .report-logo-actions { align-items: stretch; flex-direction: column; }
  .report-logo-actions button { width: 100%; }
  .settings-form-grid { grid-template-columns: 1fr; }
  .storage-dir-grid { grid-template-columns: 1fr; }
  .storage-disk-line { align-items: flex-start; flex-direction: column; }
  .campus-map-row { grid-template-columns: 1fr; }
  .exam-analysis-controls { grid-template-columns: 1fr; }
  .sms-admin-controls { grid-template-columns: 1fr; }
  .sms-admin-table { min-width: 980px; }
  .exam-analysis-grid { grid-template-columns: 1fr; }
  .exam-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .exam-distribution { min-width: 620px; }
  .exam-chart-panel { overflow-x: auto; }
  .send-controls { width: 100%; }
  .send-controls select,
  .send-controls button { flex: 1 1 0; width: auto; }
  .upload-panel .file-button-tall { width: 100%; flex-direction: row; gap: 4px; }
  .upload-copy p { white-space: normal; }
  .tab-status {
    flex-basis: 100%;
    max-width: 100%;
    margin-left: 0;
    padding: 6px 2px 8px;
    justify-content: flex-start;
    text-align: left;
  }
  .omr-preview-panel { height: min(82vw, 580px); min-height: 360px; }
  .preview-canvas { min-height: 300px; }
  .omr-table-wrap { height: 300px; min-height: 220px; }
}

@media print {
  body.omr-mode {
    background: #fff;
  }
  body.omr-mode .topbar,
  body.omr-mode .tabs,
  body.omr-mode .exam-analysis-filter-panel,
  body.omr-mode #scanTab,
  body.omr-mode #smsTab,
  body.omr-mode #smsLogTab,
  body.omr-mode #settingsTab,
  body.omr-mode .app-loading-overlay,
  body.omr-mode .swift-notice-overlay {
    display: none !important;
  }
  body.omr-mode #appPanel,
  body.omr-mode #examAnalysisTab {
    display: block !important;
  }
  body.omr-mode .shell,
  body.omr-mode .omr-shell {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
  }
  body.omr-mode .tab-panel {
    border: 0;
    padding: 0;
    margin: 0;
  }
  body.omr-mode .panel {
    border: 0;
    box-shadow: none;
    break-inside: avoid;
  }
  .exam-analysis-output {
    gap: 6mm;
  }
  .exam-summary-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
  .exam-analysis-grid {
    grid-template-columns: 1fr 1fr;
  }
  .exam-rank-panel,
  .exam-item-panel {
    break-before: page;
  }
  .exam-rank-table-wrap,
  .exam-category-table-wrap,
  .exam-item-table-wrap,
  .exam-special-panel .exam-rank-table-wrap,
  .exam-rank-panel .exam-rank-table-wrap {
    max-height: none;
    overflow: visible;
  }
  .exam-rank-table th,
  .exam-category-table th,
  .exam-item-table th {
    position: static;
  }
}
