.smart-capture-page {
  --smart-ink: #073f31;
  --smart-green: #087657;
  --smart-mint: #dff5ec;
  --smart-paper: #fffefa;
  --smart-line: #d2e1da;
  width: min(1600px, calc(100% - 32px));
  margin: 24px auto 56px;
  color: #163e33;
}

.smart-hero {
  border: 1px solid #1b5d49;
  border-radius: 24px;
  padding: clamp(20px, 4vw, 34px);
  background: var(--smart-ink);
  color: white;
  box-shadow: 0 18px 40px rgb(7 63 49 / 16%);
}

.smart-hero p,
.smart-samples > div:first-child p {
  margin: 0;
  color: #8fe0bf;
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.1em;
}

.smart-hero h1 {
  margin: 6px 0 4px;
  color: white;
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 950;
  letter-spacing: -0.035em;
}

.smart-hero > span {
  display: block;
  max-width: 760px;
  color: rgb(255 255 255 / 76%);
  font-size: 0.92rem;
  line-height: 1.55;
}

.smart-shell,
.smart-samples {
  margin-top: 24px;
  border: 1px solid var(--smart-line);
  border-radius: 22px;
  background: var(--smart-paper);
  box-shadow: 0 14px 34px rgb(7 63 49 / 9%);
}

.smart-shell {
  overflow: hidden;
  scroll-margin-top: 84px;
}

.smart-shell.capture-active {
  box-shadow: 0 20px 54px rgb(7 63 49 / 13%);
}

.smart-toolbar,
.smart-result-heading,
.smart-review-actions,
.smart-timings,
.smart-capture-metrics,
.smart-result-checks {
  display: flex;
  align-items: center;
  gap: 12px;
}

.smart-toolbar {
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--smart-line);
  background: #f7fbf9;
}

.smart-ready {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--smart-line);
  border-radius: 999px;
  background: white;
  font-size: 0.78rem;
}

.smart-ready i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22b877;
  box-shadow: 0 0 0 4px rgb(34 184 119 / 13%);
}

.smart-ready[data-state="busy"] i {
  background: #d39719;
}

.smart-ready[data-state="error"] i {
  background: #c44444;
}

.smart-actions {
  display: flex;
  gap: 8px;
}

.smart-actions[hidden],
.smart-samples[hidden] {
  display: none;
}

.smart-stage-actions {
  display: flex;
  gap: 8px;
}

.smart-stage-actions[hidden] {
  display: none;
}

.smart-review-actions[hidden],
.smart-error-actions[hidden] {
  display: none;
}

.smart-stage-actions button,
.smart-actions button,
.smart-error-actions button,
.smart-review-actions button {
  min-height: 40px;
  border: 1px solid #aacabe;
  border-radius: 12px;
  padding: 0 14px;
  background: white;
  color: var(--smart-ink);
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
}

.smart-stage-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  gap: 7px;
}

.smart-review-actions,
.smart-error-actions {
  gap: 8px;
}

.smart-review-actions button,
.smart-error-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.smart-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.smart-stage-actions button.primary,
.smart-actions button.primary,
.smart-review-actions button.accept {
  border-color: var(--smart-green);
  background: var(--smart-green);
  color: white;
}

.smart-shell.capture-error .smart-toolbar {
  border-bottom-color: #e46659;
  background: #fff0ed;
}

.smart-shell.capture-error .smart-error-actions button {
  border-color: #c8574c;
  color: #7d291f;
}

.smart-shell.capture-error .smart-error-actions button:first-child {
  background: #a63b31;
  color: white;
}

.smart-toolbar-error {
  margin-left: auto;
  color: #8e2f25;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.smart-stage-actions button:disabled,
.smart-actions button:disabled,
.smart-sample-grid button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.smart-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
}

.smart-spinner {
  display: none;
  margin-left: auto;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  border: 3px solid #dbe9e3;
  border-top-color: var(--smart-green);
  border-radius: 50%;
  animation: smart-spin 0.75s linear infinite;
}

.smart-spinner.active {
  display: block;
}

@keyframes smart-spin {
  to { transform: rotate(360deg); }
}

.smart-progress {
  height: 3px;
  overflow: hidden;
  background: #e5f0eb;
}

.smart-progress span {
  display: block;
  width: 35%;
  height: 100%;
  background: linear-gradient(90deg, transparent, #21a97a, transparent);
  animation: smart-progress 1.25s ease-in-out infinite;
}

@keyframes smart-progress {
  from { transform: translateX(-120%); }
  to { transform: translateX(400%); }
}

.smart-error-actions button {
  min-height: 40px;
  border-color: #c8574c;
  border-radius: 8px;
  padding: 0 13px;
  color: #7d291f;
  font-size: 0.76rem;
  font-weight: 850;
}

.smart-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 5px;
  margin: 16px 16px 0;
  border: 1px solid var(--smart-line);
  border-radius: 13px;
  padding: 4px;
  background: #edf5f1;
}

.smart-tabs button {
  min-height: 38px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #536f65;
  font-size: 0.8rem;
  font-weight: 850;
  cursor: pointer;
}

.smart-tabs button.active {
  background: var(--smart-green);
  color: white;
  box-shadow: 0 4px 10px rgb(8 118 87 / 18%);
}

.smart-tabs button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.smart-panel {
  display: none;
  padding: 14px 16px 18px;
}

.smart-panel.active {
  display: block;
}

.smart-form-preview {
  width: min(100%, 680px);
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid var(--smart-line);
  border-radius: 15px;
  background: #eef3f1;
  transition: width 180ms ease;
}

.smart-form-preview.preview-expanded {
  width: 100%;
}

.smart-form-preview img {
  display: block;
  width: 100%;
  max-height: 880px;
  object-fit: contain;
  background: #dfe8e4;
}

.smart-form-preview.preview-expanded img {
  max-height: none;
  object-fit: initial;
}

.smart-scan-stage {
  position: relative;
  overflow: hidden;
}

.smart-preview-size-toggle {
  position: absolute;
  z-index: 4;
  top: 10px;
  right: 10px;
  width: 42px;
  height: 42px;
  border: 1px solid rgb(11 101 75 / 42%);
  border-radius: 10px;
  padding: 9px;
  background: rgb(255 255 255 / 72%);
  color: #0b654b;
  box-shadow: 0 3px 12px rgb(7 63 49 / 16%);
  cursor: pointer;
  backdrop-filter: blur(6px);
}

.smart-preview-size-toggle:hover {
  background: rgb(255 255 255 / 90%);
}

.smart-preview-size-toggle svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.smart-preview-size-toggle svg[hidden] {
  display: none;
}

.smart-preview-size-toggle:focus-visible {
  outline: 3px solid rgb(255 255 255 / 95%);
  outline-offset: 2px;
}

.smart-scan-overlay {
  position: absolute;
  inset: 0;
  display: none;
  overflow: hidden;
  pointer-events: none;
}

.smart-scan-overlay.active {
  display: block;
}

.smart-scan-grid {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgb(21 151 107 / 10%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(21 151 107 / 10%) 1px, transparent 1px);
  background-size: 28px 28px;
}

.smart-scan-beam {
  position: absolute;
  left: 0;
  right: 0;
  height: 5px;
  background: #41e4aa;
  box-shadow: 0 0 22px 8px rgb(65 228 170 / 46%);
  animation: smart-scan 1.55s ease-in-out infinite;
}

@keyframes smart-scan {
  0% { top: 1%; opacity: 0.4; }
  50% { top: 96%; opacity: 1; }
  100% { top: 1%; opacity: 0.4; }
}

.smart-form-preview figcaption {
  padding: 9px 12px;
  background: white;
  color: #5a746a;
  font-size: 0.72rem;
  text-align: center;
}

.smart-capture-metrics {
  flex-wrap: wrap;
  justify-content: center;
  padding: 0 0 10px;
}

.smart-capture-metrics span,
.smart-result-completeness > * {
  border: 1px solid var(--smart-line);
  border-radius: 999px;
  padding: 5px 10px;
  background: #f5faf8;
  color: #5a746a;
  font-size: 0.72rem;
}

.smart-capture-metrics span.pass,
.smart-result-completeness strong.pass {
  border-color: #9bd7c0;
  background: #eaf8f2;
  color: #087657;
}

.smart-report-sheet {
  border: 1px solid var(--smart-line);
  border-radius: 16px;
  padding: 14px;
  background: #fffefa;
  box-shadow: 0 4px 14px rgb(7 63 49 / 5%);
}

.smart-result-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--smart-line);
  padding: 0 0 12px;
}

.smart-result-heading label {
  grid-column: 2;
  display: flex;
  min-width: 280px;
  gap: 0;
}

.smart-result-heading label > span {
  display: inline-flex;
  align-items: center;
  border: 1px solid #bfd4cb;
  border-right: 0;
  border-radius: 9px 0 0 9px;
  padding: 0 12px;
  background: #f3f8f6;
  color: #365b4f;
  font-size: 0.72rem;
  font-weight: 850;
  white-space: nowrap;
}

.smart-result-heading input {
  width: 210px;
  border-radius: 0 9px 9px 0;
  text-align: center;
  letter-spacing: 0.045em;
}

.smart-result-completeness {
  grid-column: 3;
  display: flex;
  justify-self: end;
  gap: 7px;
}

.smart-result-completeness strong {
  color: var(--smart-green);
}

.smart-result-heading strong {
  color: var(--smart-ink);
}

.smart-result-heading input,
.smart-field-row input,
.smart-calculated-row output {
  min-height: 38px;
  border: 1px solid #bfd4cb;
  border-radius: 9px;
  padding: 0 10px;
  background: white;
  color: #143e32;
  font-size: 0.9rem;
  font-weight: 850;
  text-align: right;
}

.smart-result-heading input {
  border-radius: 0 9px 9px 0;
  text-align: center;
}

.smart-result-heading input:focus,
.smart-field-row input:focus {
  outline: 3px solid rgb(33 169 122 / 18%);
  border-color: var(--smart-green);
}

.smart-results-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 18px;
  padding-top: 14px;
}

.smart-result-checks {
  flex-wrap: wrap;
  padding-top: 12px;
}

.smart-result-checks span {
  border: 1px solid #b7d9cb;
  border-radius: 999px;
  padding: 5px 10px;
  background: #effaf6;
  color: #087657;
  font-size: 0.7rem;
  font-weight: 800;
}

.smart-result-checks span[data-status="warn"] {
  border-color: #e2c878;
  background: #fff7d9;
  color: #785b0b;
}

.smart-field-table {
  overflow: hidden;
  border: 1px solid var(--smart-line);
  border-radius: 12px;
  background: white;
}

.smart-field-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 10px;
  padding: 9px 9px 9px 11px;
  background: #f1f2f1;
  color: #52675f;
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.smart-field-header span:last-child {
  text-align: right;
}

.smart-field-list {
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: white;
}

.smart-field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  align-items: center;
  gap: 10px;
  min-height: 49px;
  padding: 5px 8px 5px 11px;
  border-bottom: 1px solid #e5eee9;
}

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

.smart-field-row label {
  overflow: hidden;
  color: #3a5d51;
  font-size: 0.76rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.smart-field-row input[data-state="BLANK"],
.smart-field-row input[data-state="SKIP"] {
  background: #f8fbfa;
  color: #7d928a;
}

.smart-field-row input {
  background: #fbfcfb;
}

.smart-field-row[data-state="SKIP"],
.smart-field-row[data-state="CHECK"],
.smart-field-row[data-state="ABSTAIN"] {
  background: #fffaf0;
}

.smart-total-row {
  border-top: 2px solid #dfe2e4;
  background: #f7f7f7;
}

.smart-calculated-row {
  border-top: 2px solid #dfe2e4;
  background: #f4f7f5;
}

.smart-total-row label,
.smart-calculated-row strong {
  overflow: hidden;
  color: #111;
  font-size: 0.75rem;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.smart-calculated-row output {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.smart-total-row.total-match,
.smart-calculated-row.total-match {
  background: rgb(31 170 112 / 14%);
}

.smart-total-row.total-match input,
.smart-calculated-row.total-match output {
  border-color: #54b58e;
  background: rgb(238 252 246 / 92%);
  color: #075c41;
}

.smart-total-row.total-mismatch,
.smart-calculated-row.total-mismatch {
  background: #fff7d9;
}

.smart-review-actions button.reject {
  border-color: #d9a097;
  color: #8d3b33;
}

.smart-review-message {
  margin: 12px 0 0;
  color: #6d8179;
  font-size: 0.7rem;
}

.smart-timings {
  flex-wrap: wrap;
  padding: 0 0 14px;
}

.smart-timings span {
  border: 1px solid var(--smart-line);
  border-radius: 999px;
  padding: 5px 9px;
  background: #f6faf8;
  color: #5b766c;
  font-size: 0.68rem;
}

.smart-timings b {
  color: var(--smart-ink);
}

.smart-enhanced-preview {
  margin-top: 16px;
}

.smart-enhanced-stage {
  position: relative;
  overflow: hidden;
}

.smart-samples {
  padding: 18px;
}

.smart-samples > div:first-child h2 {
  margin: 4px 0 2px;
  color: var(--smart-ink);
  font-size: 1rem;
  font-weight: 800;
}

.smart-samples > div:first-child p {
  color: var(--smart-green);
}

.smart-samples > div:first-child span {
  color: #607b71;
  font-size: 0.78rem;
}

.smart-sample-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.smart-sample-grid button {
  overflow: hidden;
  border: 1px solid #b8d2c7;
  border-radius: 16px;
  padding: 0;
  background: white;
  color: var(--smart-ink);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 1px 3px rgb(7 63 49 / 10%);
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.smart-sample-grid button:hover {
  transform: translateY(-2px);
  border-color: var(--smart-green);
  box-shadow: 0 8px 18px rgb(7 63 49 / 14%);
}

.smart-sample-grid button:focus-visible {
  outline: 4px solid rgb(143 224 191 / 50%);
  outline-offset: 2px;
}

.smart-sample-grid button[aria-pressed="true"] {
  border-color: var(--smart-green);
  box-shadow: 0 0 0 3px rgb(143 224 191 / 45%);
}

.smart-sample-image {
  display: block;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #e9f1ed;
}

.smart-sample-grid img {
  display: block;
  height: 100%;
  width: 100%;
  object-fit: cover;
  object-position: top;
  transition: transform 200ms ease;
}

.smart-sample-grid button:hover img {
  transform: scale(1.03);
}

.smart-sample-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
}

.smart-sample-label strong {
  color: var(--smart-ink);
  font-size: 0.875rem;
  font-weight: 900;
}

.smart-sample-label > span {
  color: var(--smart-green);
}

@media (max-width: 760px) {
  .smart-capture-page {
    width: min(100% - 16px, 620px);
    margin-top: 12px;
  }

  .smart-shell,
  .smart-samples {
    margin-top: 14px;
    border-radius: 17px;
  }

  .smart-toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 9px;
    padding: 10px;
  }

  .smart-shell.capture-active .smart-toolbar {
    align-items: center;
    flex-direction: row;
  }

  .smart-shell.capture-active .smart-stage-actions {
    flex: 1 1 auto;
    width: auto;
  }

  .smart-shell.capture-active .smart-review-actions,
  .smart-shell.capture-active .smart-error-actions {
    flex: 1 1 auto;
    width: auto;
  }

  .smart-ready {
    align-self: flex-start;
  }

  .smart-actions {
    display: grid;
    grid-template-columns: 1fr 1.35fr;
  }

  .smart-stage-actions {
    display: grid;
    grid-template-columns: 1.35fr 1fr;
    width: 100%;
  }

  .smart-actions button,
  .smart-error-actions button,
  .smart-review-actions button {
    min-height: 44px;
  }

  .smart-toolbar-error {
    margin-left: 0;
    font-size: 0.72rem;
  }

  .smart-panel {
    padding: 12px 10px 14px;
  }

  .smart-tabs {
    margin: 10px 10px 0;
  }

  .smart-result-heading {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .smart-result-heading label {
    grid-column: 1;
    min-width: 0;
  }

  .smart-result-heading input {
    width: 100%;
    min-width: 0;
  }

  .smart-result-completeness {
    grid-column: 1;
    justify-self: center;
  }

  .smart-capture-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .smart-capture-metrics span {
    text-align: center;
  }

  .smart-results-grid {
    grid-template-columns: 1fr;
  }

  .smart-review-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .smart-error-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .smart-samples {
    padding: 14px;
  }

  .smart-sample-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
}

@media (max-width: 390px) {
  .smart-tabs {
    margin: 10px 12px 0;
  }

  .smart-panel {
    margin: 0;
    padding: 12px 12px 14px;
  }

  .smart-field-row {
    grid-template-columns: minmax(0, 1fr) 96px;
  }

  .smart-field-header {
    grid-template-columns: minmax(0, 1fr) 96px;
  }

  .smart-actions {
    grid-template-columns: 1fr 1fr;
  }

  .smart-actions button {
    padding: 0 8px;
    font-size: 0.76rem;
  }

  .smart-timings {
    gap: 6px;
  }

  .smart-timings span {
    padding: 4px 7px;
    font-size: 0.64rem;
  }

}
