:root {
  color-scheme: light;
  --ink: #101828;
  --muted: #667085;
  --soft: #f3f6fb;
  --paper: #eef2f6;
  --panel: #ffffff;
  --line: #d8dee8;
  --line-strong: #c7d0dd;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --brand-soft: #e6f4f1;
  --accent: #315f9b;
  --danger: #b42318;
  --warn: #9a6700;
  --ok: #067647;
  --shadow: 0 18px 42px rgba(16, 24, 40, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background:
    linear-gradient(180deg, #f8fafc 0%, var(--paper) 42%, #e9eef5 100%);
  color: var(--ink);
}

.shell {
  width: min(1240px, calc(100vw - 32px));
  margin: 22px auto;
}

.appHeader {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.headerPill,
.stepPill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  color: #344054;
  background: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  font-weight: 750;
}

.stepPill {
  width: 30px;
  padding: 0;
  color: #fff;
  border-color: var(--brand);
  background: var(--brand);
}

.workspace {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.panel {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.controls {
  padding: 18px;
  display: grid;
  gap: 16px;
  position: sticky;
  top: 18px;
}

.results {
  min-height: calc(100vh - 112px);
  padding: 18px;
  display: grid;
  gap: 14px;
}

.panelTitle,
.statusbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.eyebrow {
  margin: 0 0 5px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--brand-dark);
  font-weight: 800;
}

h1,
h2 {
  margin: 0;
  line-height: 1.12;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 21px;
}

.controlGroup {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid #e3e8f0;
  border-radius: 8px;
  background: #fbfcfe;
}

.groupLabel,
.field {
  font-size: 13px;
  color: #344054;
  font-weight: 700;
}

.field {
  display: grid;
  gap: 7px;
}

select,
input[type='text'] {
  width: 100%;
  min-height: 42px;
  border: 1px solid #c8ced9;
  border-radius: 6px;
  padding: 9px 11px;
  font: inherit;
  color: var(--ink);
  background: #fff;
  outline: none;
}

select:focus,
input[type='text']:focus,
.reviewInput:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.uploadBox {
  position: relative;
  display: grid;
  gap: 6px;
  justify-items: center;
  padding: 18px 12px;
  border: 1px dashed #9fb0c5;
  border-radius: 8px;
  background: #ffffff;
  color: #344054;
  cursor: pointer;
  text-align: center;
}

.uploadBox:hover {
  border-color: var(--brand);
  background: #f7fbfa;
}

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

.uploadIcon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 34px;
  border: 1px solid #b9c7d8;
  border-radius: 6px;
  color: var(--accent);
  background: #eef5ff;
  font-size: 12px;
  font-weight: 850;
}

.uploadBox strong {
  font-size: 14px;
}

.uploadBox small {
  width: 100%;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.switch {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 10px;
  align-items: center;
  min-height: 38px;
  font-size: 14px;
  color: #344054;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch span {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: #d0d5dd;
  transition: background 160ms ease;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(16, 24, 40, 0.25);
  transition: transform 160ms ease;
}

.switch input:checked + span {
  background: var(--brand);
}

.switch input:checked + span::after {
  transform: translateX(20px);
}

.switch b {
  font-size: 14px;
}

button {
  border: 0;
  border-radius: 6px;
  min-height: 42px;
  padding: 0 16px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

.primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 10px 20px rgba(15, 118, 110, 0.18);
}

.primary:hover:not(:disabled) {
  background: var(--brand-dark);
}

.secondary {
  color: var(--brand-dark);
  background: var(--brand-soft);
  border: 1px solid #b7dcda;
}

.secondary:hover:not(:disabled) {
  background: #d9eeeb;
}

.dangerBtn {
  color: #fff;
  background: var(--danger);
  min-width: 94px;
}

.dangerBtn:hover:not(:disabled) {
  background: #912018;
}

.hint {
  color: var(--muted);
  line-height: 1.45;
  font-size: 12px;
}

code {
  font-family: Consolas, Monaco, monospace;
  color: #344054;
}

.actionRow {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

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

.stat {
  min-height: 78px;
  padding: 12px;
  border: 1px solid #e0e6ef;
  border-radius: 8px;
  background: #fbfcff;
  display: grid;
  align-content: space-between;
}

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

.stat strong {
  font-size: 26px;
  line-height: 1;
}

.scanWarning {
  border: 1px solid #f5d68c;
  background: #fff8e5;
  color: #7a5300;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.35;
}

.progressShell {
  display: flex;
  justify-content: space-between;
  color: #475467;
  font-size: 12px;
  font-weight: 800;
}

.progress {
  height: 10px;
  background: #edf0f5;
  border-radius: 999px;
  overflow: hidden;
}

#progressFill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  transition: width 160ms ease;
}

.tableWrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
  vertical-align: top;
}

.pageSub {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f2f5f9;
  color: #344054;
  font-size: 11px;
  text-transform: uppercase;
}

tbody tr:hover {
  background: #fafcff;
}

tr:last-child td {
  border-bottom: 0;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 34px 12px;
}

.resultPreview {
  width: min(178px, 22vw);
  min-width: 132px;
  height: 64px;
  object-fit: contain;
  border: 1px solid #d8e1ee;
  border-radius: 6px;
  background: #fff;
  cursor: zoom-in;
  display: block;
  margin: 0 auto;
  padding: 4px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.previewMissing {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  color: var(--muted);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 800;
}

.ok {
  color: var(--ok);
  background: #ecfdf3;
}

.warn {
  color: var(--warn);
  background: #fffaeb;
}

.bad {
  color: var(--danger);
  background: #fef3f2;
}

#logBox {
  margin: 0;
  min-height: 118px;
  max-height: 220px;
  overflow: auto;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #202b3c;
  background: #101828;
  color: #d1fae5;
  font-size: 12px;
  line-height: 1.55;
}

.reviewPanel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 10px;
  background: #fafcff;
}

.reviewPanel h3 {
  margin: 0;
  font-size: 16px;
}

.reviewHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.reviewBulk,
.reviewControls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.reviewPanel p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.reviewList {
  display: grid;
  gap: 12px;
}

.reviewCard {
  border: 1px solid #d2d9e4;
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.reviewTop {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.reviewTop strong {
  font-size: 14px;
}

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

.reviewPreview {
  width: min(100%, 420px);
  max-height: 96px;
  object-fit: contain;
  border: 1px solid #dbe4f2;
  border-radius: 6px;
  background: #fff;
  cursor: zoom-in;
}

.reviewControls {
  align-items: center;
}

.reviewInput {
  min-width: 260px;
  flex: 1;
  min-height: 38px;
  border: 1px solid #c8ced9;
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
}

.tiny {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.sourceMeta {
  display: grid;
  gap: 3px;
  margin-top: 7px;
  font-size: 12px;
  color: #475467;
}

.previewModal {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.previewBackdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
}

.previewCard {
  position: relative;
  z-index: 1;
  width: min(92vw, 980px);
  margin: 28px auto;
  background: #fff;
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 56px);
}

#previewModalImage {
  width: 100%;
  min-height: 180px;
  max-height: calc(100vh - 130px);
  object-fit: contain;
  border: 1px solid #d0d8e5;
  border-radius: 6px;
  background: #fff;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

@media (max-width: 920px) {
  .workspace,
  .statGrid {
    grid-template-columns: 1fr;
  }

  .controls {
    position: static;
  }

  .statusbar,
  .appHeader {
    align-items: stretch;
    flex-direction: column;
  }

  .actionRow {
    justify-content: stretch;
  }

  .actionRow button {
    flex: 1;
  }
}

@media (max-width: 520px) {
  .shell {
    width: min(100vw - 20px, 1240px);
    margin: 10px auto;
  }

  h1 {
    font-size: 25px;
  }

  .controls,
  .results {
    padding: 12px;
  }

  .reviewInput {
    min-width: 100%;
  }
}
