.number-pad {
  width: min(100%, 560px);
  margin: 14px auto 0;
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 8px;
}

.number-pad button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--ink);
  font-weight: 800;
}

.number-pad button:last-child {
  font-size: 0.82rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.primary-actions {
  justify-content: center;
}

.solve-options {
  max-width: 520px;
  margin: 14px auto 0;
}

.loader-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: stretch;
  margin-bottom: 14px;
}

.checkbox-option {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  background: var(--surface-soft);
  color: var(--ink);
  cursor: pointer;
}

.checkbox-option input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--accent);
}

.checkbox-option span,
.checkbox-option small {
  display: block;
}

.checkbox-option strong {
  display: block;
  font-size: 0.95rem;
}

.checkbox-option small {
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.35;
}

.checkbox-option.compact-option {
  max-width: 420px;
  padding: 10px 12px;
}

.checkbox-option.compact-option strong {
  font-size: 0.9rem;
}

.button {
  border: 1px solid var(--line);
  border-radius: 14px;
  min-height: 44px;
  padding: 11px 14px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.button:hover:not(:disabled),
.number-pad button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.button:disabled,
.number-pad button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.library-choice-card:disabled,
.library-choice-card.is-disabled {
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
  box-shadow: none;
}

.library-choice-card:disabled:hover,
.library-choice-card.is-disabled:hover,
.library-choice-card:disabled:focus-visible,
.library-choice-card.is-disabled:focus-visible {
  transform: none;
  border-color: var(--line);
  box-shadow: none;
}

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

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

.button.ghost {
  background: transparent;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  min-height: 44px;
  padding: 12px;
  background: var(--surface);
  color: var(--ink);
}


.scan-file-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.scan-file-button {
  cursor: pointer;
}

.scan-file-name {
  min-width: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scan-source-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
}

.scan-edit-button[hidden] {
  display: none;
}

.scan-import-layout {
  display: grid;
  grid-template-columns: minmax(240px, 0.78fr) minmax(320px, 1.22fr);
  gap: 16px;
  align-items: start;
}

.scan-import-source,
.scan-import-review {
  min-width: 0;
}

.scan-preview {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-soft);
}

.scan-preview[hidden] {
  display: none;
}


.scan-prep-actions {
  margin-top: 12px;
}

.scan-prep-panel {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px;
  background: var(--surface-soft);
}

.scan-prep-panel[hidden] {
  display: none;
}

.scan-prep-heading h3 {
  margin: 0 0 4px;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
}

.scan-detected-canvas,
.scan-prepared-canvas {
  display: block;
  width: min(100%, 420px);
  aspect-ratio: 1;
  border: 2px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface);
  margin: 12px 0;
}

.scan-detected-canvas {
  aspect-ratio: auto;
  max-height: 360px;
  object-fit: contain;
}


.scan-review-heading {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  margin-bottom: 10px;
}

.scan-review-heading h3 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.scan-review-count {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 7px 10px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  line-height: 1;
}

.scan-review-grid {
  width: min(100%, 430px);
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  border: 3px solid var(--line-strong);
  border-radius: 14px;
  overflow: hidden;
  background: var(--line-strong);
  margin-bottom: 14px;
}

.scan-cell {
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  text-align: center;
  font-size: clamp(1rem, 3vw, 1.65rem);
  font-weight: 800;
  outline: none;
  transition: background 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
  touch-action: manipulation;
  -moz-appearance: textfield;
}

.scan-cell::-webkit-outer-spin-button,
.scan-cell::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.scan-cell:nth-child(3n) {
  border-right: 3px solid var(--line-strong);
}

.scan-cell:nth-child(9n) {
  border-right: 0;
}

.scan-cell:nth-child(n + 19):nth-child(-n + 27),
.scan-cell:nth-child(n + 46):nth-child(-n + 54) {
  border-bottom: 3px solid var(--line-strong);
}

.scan-cell:nth-child(n + 73) {
  border-bottom: 0;
}

.scan-cell.is-filled {
  background: var(--given-bg);
  color: var(--given-ink);
}

.scan-cell.is-conflict {
  background: var(--bad);
  color: var(--bad-ink);
}

.scan-cell.is-ocr-recognized {
  box-shadow: inset 0 0 0 2px rgba(124, 58, 237, 0.35);
}

.scan-cell.is-ocr-low-confidence:not(.is-conflict) {
  background: var(--surface);
  color: var(--given-ink);
  box-shadow: inset 0 0 0 3px rgba(245, 158, 11, 0.55);
}

.scan-cell.is-ocr-rule-resolved:not(.is-conflict) {
  box-shadow: inset 0 0 0 2px rgba(22, 163, 74, 0.48);
}

.scan-cell.is-ocr-auto-corrected:not(.is-conflict) {
  background: var(--good);
  color: var(--good-ink);
}

.scan-cell::selection {
  background: rgba(245, 158, 11, 0.22);
  color: var(--given-ink);
}

.scan-cell.is-active {
  box-shadow: inset 0 0 0 4px var(--accent);
  z-index: 2;
}

.scan-actions {
  margin-bottom: 12px;
}

.scan-import-status {
  margin-top: 12px;
}

.status-box {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: var(--surface-soft);
  color: var(--muted);
  line-height: 1.55;
}

.status-box.is-ok {
  background: var(--good);
  border-color: #86efac;
  color: var(--good-ink);
}

.status-box.is-warn {
  background: var(--warn);
  border-color: #fde68a;
  color: var(--warn-ink);
}

.status-box.is-bad {
  background: var(--bad);
  border-color: #fecaca;
  color: var(--bad-ink);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0 0;
}

.stats-grid div {
  border: 1px solid var(--line);
  border-radius: 14px;
  min-height: 44px;
  padding: 12px;
  background: var(--surface-soft);
}

.stats-grid dt {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stats-grid dd {
  margin: 4px 0 0;
  font-size: 1.18rem;
  font-weight: 900;
}

.button.small {
  padding: 8px 12px;
  font-size: 0.82rem;
}

