:root {
  --bg: #f6f2e8;
  --bg-deep: #efe3c5;
  --panel: rgba(255, 252, 245, 0.88);
  --panel-strong: #fffdf8;
  --ink: #1d2430;
  --muted: #6d727c;
  --accent: #1f6f78;
  --accent-strong: #15535a;
  --accent-soft: rgba(31, 111, 120, 0.12);
  --warn: #c96a32;
  --border: rgba(29, 36, 48, 0.12);
  --shadow: 0 24px 70px rgba(23, 29, 36, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(241, 194, 91, 0.28), transparent 28%),
    radial-gradient(circle at top right, rgba(31, 111, 120, 0.18), transparent 24%),
    linear-gradient(180deg, #faf7ef 0%, var(--bg) 52%, var(--bg-deep) 100%);
  font-family: "Avenir Next", "PingFang SC", "Noto Sans SC", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.7), transparent);
}

.page-shell {
  padding: 32px 18px 110px;
}

.page {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.page-review {
  width: min(1680px, 100%);
}

.hero-card,
.upload-card,
.table-card,
.summary-card,
.image-card {
  background: var(--panel);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.hero-card,
.upload-card,
.table-card {
  padding: 28px;
}

.compact-hero {
  margin-bottom: 22px;
}

.page-home {
  display: grid;
  gap: 24px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(31, 111, 120, 0.12);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

h1,
h2,
h3 {
  font-family: "Iowan Old Style", "Songti SC", "STSong", serif;
  margin: 0;
}

h1 {
  margin-top: 18px;
  font-size: clamp(2rem, 4vw, 3.3rem);
  line-height: 1.08;
}

h2 {
  font-size: 1.35rem;
  margin-bottom: 10px;
}

.lead {
  margin: 18px 0 0;
  max-width: 820px;
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--muted);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 22px;
}

.hero-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 28px;
}

.info-tile {
  padding: 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(29, 36, 48, 0.08);
}

.info-tile p {
  margin: 0;
  line-height: 1.65;
  color: var(--muted);
}

.picker-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.picker-button,
.primary-button,
.secondary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 22px;
  border-radius: 16px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  font-size: 15px;
  font-weight: 600;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.picker-button:hover,
.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.camera-button,
.primary-button {
  background: linear-gradient(135deg, var(--accent) 0%, #2e8b97 100%);
  color: #fff;
  box-shadow: 0 12px 28px rgba(31, 111, 120, 0.24);
}

.file-button,
.secondary-button {
  background: #fff;
  color: var(--ink);
  border-color: var(--border);
}

.ghost-button {
  background: transparent;
  color: var(--ink);
  border-color: var(--border);
}

.hidden-input {
  display: none;
}

.selection-panel {
  margin: 22px 0;
  padding: 20px;
  border-radius: 20px;
  border: 1px dashed rgba(31, 111, 120, 0.35);
  background: rgba(255, 255, 255, 0.52);
}

.selection-count {
  margin: 0 0 14px;
  font-weight: 700;
}

.selection-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.file-pill {
  display: inline-flex;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 14px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 24px;
}

.summary-card {
  min-width: 280px;
  padding: 18px 20px;
}

.summary-card div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.summary-card div:last-child {
  border-bottom: none;
}

.summary-card span {
  color: var(--muted);
}

.batch-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.field-group {
  display: grid;
  gap: 8px;
}

.field-group span {
  font-size: 14px;
  color: var(--muted);
}

.field-group input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid rgba(29, 36, 48, 0.12);
  background: #fff;
  font: inherit;
  font-size: 15px;
}

.field-group input:focus {
  outline: 2px solid rgba(31, 111, 120, 0.15);
  border-color: rgba(31, 111, 120, 0.42);
}

.field-hint {
  margin: 14px 0 0;
  color: var(--accent-strong);
  font-weight: 700;
}

.review-root {
  display: grid;
  gap: 22px;
}

.image-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  padding: 22px;
  opacity: 0;
  transform: translateY(10px);
  animation: card-in 420ms ease forwards;
}

.image-meta {
  display: grid;
  gap: 16px;
}

.image-fields-host {
  display: grid;
  gap: 12px;
}

.image-batch-fields {
  display: grid;
  gap: 14px;
  padding: 16px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(29, 36, 48, 0.08);
}

.image-file-note {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(29, 36, 48, 0.08);
  color: var(--muted);
  font-size: 14px;
}

.image-stage,
.console-image-stage {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: 0;
  padding: 14px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(29, 36, 48, 0.08);
  overflow: auto;
}

.image-preview {
  width: auto;
  max-width: 100%;
  border-radius: 22px;
  object-fit: contain;
  border: 1px solid rgba(29, 36, 48, 0.08);
  background: #fff;
}

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

.meta-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}

.meta-list span {
  color: var(--muted);
}

.table-card-inner {
  display: grid;
  gap: 14px;
}

.table-toolbar,
.section-title {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.section-title span,
.table-toolbar span {
  color: var(--muted);
}

.line-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 18px;
  background: var(--panel-strong);
}

.line-table th,
.line-table td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.line-table th {
  text-align: left;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: rgba(250, 248, 241, 0.96);
}

.line-table textarea {
  width: 100%;
  min-height: 84px;
  resize: vertical;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(29, 36, 48, 0.12);
  background: #fff;
  font: inherit;
  line-height: 1.6;
}

.line-table textarea:focus {
  outline: 2px solid rgba(31, 111, 120, 0.15);
  border-color: rgba(31, 111, 120, 0.42);
}

.line-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mini-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  color: var(--ink);
}

.mini-button.warn {
  color: var(--warn);
}

.confidence-badge {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.confidence-high {
  color: #0d6b3f;
  background: rgba(27, 142, 82, 0.14);
}

.confidence-mid {
  color: #956500;
  background: rgba(240, 184, 37, 0.18);
}

.confidence-low {
  color: #a73a22;
  background: rgba(201, 106, 50, 0.16);
}

.action-bar {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: min(920px, calc(100% - 24px));
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding: 14px;
  border-radius: 22px;
  background: rgba(255, 252, 245, 0.92);
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 44px rgba(23, 29, 36, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.65);
}

.toast {
  position: sticky;
  top: 12px;
  z-index: 20;
  display: none;
  margin-bottom: 18px;
  padding: 14px 18px;
  border-radius: 16px;
  background: rgba(21, 83, 90, 0.96);
  color: #fff;
  box-shadow: 0 12px 28px rgba(21, 83, 90, 0.24);
}

.toast.visible {
  display: block;
}

.preview-table-wrapper {
  overflow-x: auto;
}

.preview-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.preview-table th,
.preview-table td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
}

.result-card {
  margin-bottom: 22px;
}

.page-downloads {
  display: grid;
  gap: 24px;
}

.downloads-hero {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-end;
}

.result-filename {
  margin: 16px 0 0;
  color: var(--accent-strong);
  font-weight: 700;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 26px;
}

.result-preview-host {
  display: grid;
  gap: 18px;
}

.downloads-toolbar {
  display: flex;
  gap: 12px;
  margin: 18px 0 0;
}

.downloads-toolbar input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid rgba(29, 36, 48, 0.12);
  background: #fff;
  font: inherit;
  font-size: 15px;
}

.downloads-toolbar input:focus {
  outline: 2px solid rgba(31, 111, 120, 0.15);
  border-color: rgba(31, 111, 120, 0.42);
}

.downloads-list {
  margin-top: 18px;
}

.downloads-table-wrapper {
  overflow-x: auto;
}

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

.downloads-table th,
.downloads-table td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  white-space: pre-wrap;
  word-break: break-word;
}

.downloads-table th {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.04em;
  background: rgba(250, 248, 241, 0.96);
}

.downloads-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.result-preview-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent-strong);
}

.adaptive-preview-table th:nth-child(1),
.adaptive-preview-table td:nth-child(1) {
  width: 18%;
}

.adaptive-preview-table th:nth-child(2),
.adaptive-preview-table td:nth-child(2) {
  width: 10%;
}

.adaptive-preview-table th:nth-child(3),
.adaptive-preview-table td:nth-child(3) {
  width: 72%;
}

.console-status,
.console-preview-card,
.console-result-card {
  margin-top: 20px;
  padding: 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(29, 36, 48, 0.08);
}

.console-status.is-error {
  color: #9c2e1f;
  background: rgba(201, 106, 50, 0.12);
}

.console-status.is-success {
  color: var(--accent-strong);
}

.console-form {
  display: grid;
  gap: 18px;
}

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

.console-image {
  max-height: 560px;
  width: auto;
  max-width: 100%;
}

.console-pre {
  margin: 16px 0 0;
  min-height: 240px;
  padding: 16px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--border);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.65;
  font-family: Menlo, Monaco, monospace;
}

.console-table-host,
.review-content-host {
  display: grid;
  gap: 14px;
}

.ocr-table-card {
  display: grid;
  gap: 10px;
}

.ocr-table-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-strong);
}

.ocr-table-scroll {
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
}

.ocr-grid-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.ocr-grid-table td {
  min-width: 0;
  min-height: 52px;
  padding: 0;
  border: 1px solid rgba(29, 36, 48, 0.14);
  background: rgba(255, 255, 255, 0.92);
  vertical-align: top;
}

.grid-cell-text {
  min-height: 52px;
  padding: 10px 8px;
  line-height: 1.4;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.grid-cell-input {
  width: 100%;
  min-height: 64px;
  padding: 8px 8px;
  border: none;
  resize: vertical;
  background: transparent;
  font: inherit;
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.grid-cell-input:focus {
  outline: 2px solid rgba(31, 111, 120, 0.18);
  outline-offset: -2px;
}

.table-empty {
  padding: 18px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  border: 1px dashed rgba(29, 36, 48, 0.14);
}

@keyframes card-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .hero-grid,
  .image-card,
  .console-grid,
  .batch-meta-grid {
    grid-template-columns: 1fr;
  }

  .page-header {
    flex-direction: column;
  }

  .summary-card {
    width: 100%;
    min-width: auto;
  }

  .downloads-hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-review {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .page-shell {
    padding: 20px 14px 124px;
  }

  .hero-card,
  .upload-card,
  .table-card {
    padding: 22px 18px;
  }

  .action-bar {
    flex-direction: column;
  }

  .action-bar > * {
    width: 100%;
  }

  .line-table th:nth-child(2),
  .line-table td:nth-child(2) {
    display: none;
  }

  .ocr-grid-table td {
    min-height: 46px;
  }

  .grid-cell-text,
  .grid-cell-input {
    font-size: 12px;
    line-height: 1.3;
    padding: 6px;
  }
}
