:root {
  --page: #f1f3f1;
  --surface: #ffffff;
  --surface-muted: #f7f8f7;
  --ink: #1d211f;
  --muted: #66706b;
  --line: #d9dfdb;
  --line-strong: #bcc6c0;
  --accent: #176b4d;
  --accent-dark: #10523b;
  --accent-soft: #e8f3ee;
  --danger: #ae3b3b;
  --danger-soft: #faeded;
  --warning: #946200;
  --warning-soft: #fff4d9;
  --info: #376ba5;
  --info-soft: #eaf1f9;
  --shadow: 0 14px 38px rgba(28, 38, 33, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--page);
  font-synthesis: none;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--page);
}

button,
input,
textarea {
  font: inherit;
}

button,
a,
input,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(55, 107, 165, 0.25);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-width: 190px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 38px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  background: var(--ink);
  color: white;
  font-size: 12px;
  font-weight: 800;
}

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

.brand strong {
  font-size: 15px;
  line-height: 1.2;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.key-form {
  display: grid;
  grid-template-columns: auto minmax(190px, 280px) auto auto;
  align-items: center;
  gap: 8px;
}

.key-form label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.connection-state {
  min-width: 92px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.connection-state::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
}

.connection-state[data-state="ready"] {
  color: var(--accent);
}

.connection-state[data-state="error"] {
  color: var(--danger);
}

.app-shell {
  width: min(100%, 1500px);
  min-height: calc(100vh - 72px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 184px minmax(0, 1fr);
}

.section-nav {
  padding: 28px 18px;
  border-right: 1px solid var(--line);
}

.nav-item {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
  padding: 0 12px;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 0 5px 5px 0;
  background: transparent;
  color: var(--muted);
  text-align: left;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.65);
  color: var(--ink);
}

.nav-item.active {
  border-left-color: var(--accent);
  background: var(--surface);
  color: var(--ink);
}

.nav-count {
  min-width: 24px;
  height: 22px;
  display: grid;
  place-items: center;
  padding: 0 5px;
  border-radius: 4px;
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 11px;
}

.docs-link {
  margin-top: 22px;
  border-top: 1px solid var(--line);
  border-radius: 0;
}

.view {
  min-width: 0;
  padding: 36px clamp(24px, 4vw, 58px) 64px;
}

.view-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

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

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  margin-bottom: 0;
  font-size: 15px;
  line-height: 1.3;
}

.mode-switch {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface-muted);
}

.mode-button {
  min-width: 76px;
  height: 34px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.mode-button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(28, 38, 33, 0.12);
}

.validation-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.validation-form {
  min-width: 0;
  padding: 28px;
}

.preview-panel {
  min-width: 0;
  padding: 24px;
  border-left: 1px solid var(--line);
  background: #f8faf9;
}

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

.panel-heading > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.batch-row {
  align-items: start;
}

.field {
  min-width: 0;
  margin-bottom: 18px;
}

.field label {
  display: block;
  margin-bottom: 7px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 750;
}

.field label span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink);
}

input {
  height: 42px;
  padding: 0 11px;
}

textarea {
  min-height: 130px;
  padding: 10px 11px;
  resize: vertical;
  line-height: 1.5;
}

input::placeholder,
textarea::placeholder {
  color: #959d99;
}

input:hover,
textarea:hover {
  border-color: #95a39b;
}

input:focus,
textarea:focus {
  border-color: var(--info);
  outline: 0;
}

.upload-control {
  position: relative;
  min-height: 88px;
  display: grid !important;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin-bottom: 0 !important;
  padding: 15px;
  border: 1px dashed #aebbb4;
  border-radius: 7px;
  background: #fbfcfb;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.upload-control:hover,
.upload-control:focus-within {
  border-color: var(--info);
  background: #f6faf8;
  box-shadow: 0 0 0 4px rgba(55, 107, 165, 0.08);
}

.upload-control input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.upload-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 1px solid #d5e1db;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px !important;
  font-weight: 850 !important;
}

.upload-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.upload-copy strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-copy span {
  color: var(--muted) !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  line-height: 1.45;
}

.upload-action {
  min-width: 74px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--ink) !important;
  font-size: 12px !important;
  font-weight: 800 !important;
}

.tall-upload {
  min-height: 130px;
  align-content: center;
}

.selected-files {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 9px;
}

.selected-file {
  max-width: 100%;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  overflow: hidden;
  border: 1px solid #d5e1db;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

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

.button.primary {
  background: var(--accent);
  color: white;
}

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

.button.secondary {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}

.button.secondary:hover:not(:disabled) {
  border-color: #8b9891;
  background: var(--surface-muted);
}

.button.text-button {
  background: transparent;
  color: var(--muted);
}

.button.text-button:hover {
  color: var(--ink);
}

.button.danger {
  border-color: #e5bcbc;
  background: var(--danger-soft);
  color: var(--danger);
}

.spinner {
  width: 14px;
  height: 14px;
  display: none;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.button.loading .spinner {
  display: block;
}

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

.preview-grid {
  min-height: 360px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 12px;
}

.preview-item {
  position: relative;
  min-width: 0;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border: 1px solid #cfd8d3;
  border-radius: 7px;
  background: #e8ebe9;
  box-shadow: 0 12px 26px rgba(28, 38, 33, 0.08);
}

.preview-item::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.24);
}

.preview-item:only-child {
  grid-column: 1 / -1;
  width: min(100%, 330px);
  justify-self: center;
}

.preview-item img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.preview-index {
  position: absolute;
  left: 7px;
  bottom: 7px;
  min-width: 23px;
  height: 23px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: rgba(29, 33, 31, 0.85);
  color: white;
  font-size: 10px;
  font-weight: 800;
}

.empty-preview,
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  text-align: center;
}

.empty-preview {
  grid-column: 1 / -1;
  min-height: 360px;
  border: 1px dashed var(--line-strong);
  border-radius: 7px;
  background: #fbfcfb;
}

.empty-preview-mark {
  width: 52px;
  height: 42px;
  display: grid;
  place-items: center;
  margin-bottom: 11px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  color: #87918c;
  font-size: 10px;
  font-weight: 850;
}

.empty-preview p {
  margin-bottom: 0;
  font-size: 12px;
}

.results-section {
  margin-top: 28px;
  padding: 26px 28px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.batch-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0 0 22px;
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
}

.summary-item {
  padding: 13px 15px;
  border-right: 1px solid var(--line);
}

.summary-item:last-child {
  border-right: 0;
}

.summary-item strong,
.summary-item span {
  display: block;
}

.summary-item strong {
  font-size: 19px;
}

.summary-item span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.result-record + .result-record {
  margin-top: 28px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.result-overview {
  display: grid;
  grid-template-columns: minmax(130px, 0.38fr) minmax(220px, 0.72fr) minmax(0, 1.25fr);
  gap: 24px;
  margin-bottom: 22px;
}

.result-image {
  min-height: 132px;
  display: grid;
  grid-template-rows: minmax(118px, 1fr) auto;
  overflow: hidden;
  border: 1px solid #cfd8d3;
  border-radius: 7px;
  background: #eef2f0;
}

.result-image img {
  width: 100%;
  height: 100%;
  min-height: 118px;
  display: block;
  object-fit: cover;
}

.result-image-name,
.result-image-empty {
  min-width: 0;
  display: block;
  padding: 7px 9px;
  overflow: hidden;
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-image-empty {
  min-height: 132px;
  display: grid;
  place-items: center;
  border-top: 0;
  text-align: center;
  white-space: normal;
}

.result-status {
  min-height: 112px;
  padding: 18px;
  border-left: 5px solid var(--info);
  border-radius: 5px;
  background: var(--info-soft);
}

.result-status[data-status="approved"] {
  border-left-color: var(--accent);
  background: var(--accent-soft);
}

.result-status[data-status="rejected"],
.result-status[data-status="error"] {
  border-left-color: var(--danger);
  background: var(--danger-soft);
}


.status-label {
  display: block;
  margin-bottom: 7px;
  font-size: 18px;
  font-weight: 850;
  text-transform: capitalize;
}

.result-status p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.result-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--line);
}

.meta-item {
  min-width: 0;
  padding: 12px;
  background: var(--surface);
}

.meta-item span,
.meta-item strong {
  display: block;
}

.meta-item span {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.meta-item strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flag-groups {
  display: grid;
  grid-template-columns: minmax(230px, 0.7fr) minmax(0, 1.3fr);
  gap: 24px;
}

.flag-group h3 {
  margin: 0 0 9px;
  font-size: 11px;
  text-transform: uppercase;
}

.flag-list {
  border-top: 1px solid var(--line);
}

.flag-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 45px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.flag-copy {
  min-width: 0;
}

.flag-copy strong,
.flag-copy span {
  display: block;
}

.flag-copy strong {
  font-size: 12px;
}

.flag-copy span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.flag-state {
  min-width: 68px;
  padding: 5px 7px;
  border-radius: 4px;
  background: var(--danger-soft);
  color: var(--danger);
  text-align: center;
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
}

.flag-state.pass {
  background: var(--accent-soft);
  color: var(--accent);
}

.flag-state.pending {
  background: var(--surface-muted);
  color: var(--muted);
}


.empty-state {
  min-height: 250px;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.45);
}

.empty-state strong {
  color: var(--ink);
  font-size: 14px;
}

.empty-state span {
  margin-top: 5px;
  font-size: 11px;
}


.toast-region {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  width: min(360px, calc(100vw - 36px));
  display: grid;
  gap: 8px;
}

.toast {
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--info);
  border-radius: 5px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.45;
  animation: toast-in 0.18s ease-out;
}

.toast.error {
  border-left-color: var(--danger);
}

.toast.success {
  border-left-color: var(--accent);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1100px) {
  .validation-workspace {
    grid-template-columns: minmax(0, 1fr) 330px;
  }

  .result-overview,
  .flag-groups {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    padding: 14px 20px;
  }

  .key-form {
    width: 100%;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .key-form label {
    grid-column: 1 / -1;
  }

  .connection-state {
    grid-column: 1 / -1;
  }

  .app-shell {
    min-height: auto;
    grid-template-columns: 1fr;
  }

  .section-nav {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    padding: 10px 20px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-item {
    margin: 0;
    border-left: 0;
    border-bottom: 3px solid transparent;
    border-radius: 5px 5px 0 0;
  }

  .nav-item.active {
    border-bottom-color: var(--accent);
  }

  .docs-link {
    margin-top: 0;
    border-top: 0;
  }

  .view {
    padding: 28px 20px 50px;
  }

  .validation-workspace {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .preview-grid {
    min-height: 280px;
  }

  .empty-preview {
    min-height: 280px;
  }
}

@media (max-width: 620px) {
  .view-heading {
    align-items: stretch;
    flex-direction: column;
    margin-bottom: 20px;
  }

  .mode-switch {
    width: 100%;
  }

  .field-row,
  .batch-summary,
  .result-meta {
    grid-template-columns: 1fr;
  }

  .batch-summary .summary-item {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .batch-summary .summary-item:last-child {
    border-bottom: 0;
  }

  .validation-form,
  .results-section {
    padding: 20px;
  }

  .upload-control {
    grid-template-columns: 44px minmax(0, 1fr);
    align-items: start;
  }

  .upload-icon {
    width: 44px;
    height: 44px;
  }

  .upload-action {
    grid-column: 1 / -1;
    width: 100%;
  }

  .docs-link {
    padding: 0 8px;
    font-size: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
