:root {
  --green: #43a91f;
  --green-dark: #1f7a17;
  --green-soft: #e8f6e4;
  --ink: #1f2a1f;
  --muted: #6b7669;
  --line: #dfe8dc;
  --paper: #fbfdf8;
  --warn: #fff4d9;
  --warn-line: #f0ca6a;
  --danger: #d9442e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f4f7f0;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 32px 42px 30px;
  background: linear-gradient(135deg, #228b15, #4bb027);
  color: white;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .04em;
  color: var(--green-dark);
}

.hero .eyebrow {
  color: rgba(255, 255, 255, .82);
}

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

h1 {
  font-size: clamp(30px, 4vw, 50px);
}

h2 {
  font-size: 22px;
}

.subtitle {
  margin: 12px 0 0;
  color: rgba(255, 255, 255, .9);
}

.heroStats {
  display: flex;
  align-items: center;
  gap: 16px;
}

.heroStats div {
  min-width: 96px;
  padding: 14px 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, .15);
  text-align: center;
  backdrop-filter: blur(8px);
}

.heroStats strong {
  display: block;
  font-size: 28px;
}

.heroStats span {
  font-size: 13px;
  color: rgba(255, 255, 255, .9);
}

.shell {
  width: min(1480px, calc(100vw - 44px));
  margin: 22px auto 54px;
}

.toolbar,
.notice,
.workspace,
.tableCard,
.addPanel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 12px 28px rgba(31, 67, 22, .08);
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr 190px 150px 150px;
  gap: 14px;
  padding: 16px;
  align-items: end;
}

label span {
  display: block;
  margin: 0 0 7px;
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
}

input,
select,
button,
textarea,
.openLink {
  border: 1px solid #cad8c5;
  border-radius: 12px;
  background: white;
  color: var(--ink);
  font: inherit;
}

input,
select,
button,
.openLink {
  width: 100%;
  height: 43px;
}

input,
select,
textarea {
  padding: 0 13px;
}

textarea {
  width: 100%;
  padding-top: 12px;
  line-height: 1.55;
  resize: vertical;
}

button,
.openLink {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  cursor: pointer;
  text-decoration: none;
  font-weight: 800;
}

button:hover,
.openLink:hover {
  border-color: var(--green);
  color: var(--green-dark);
}

.primaryButton {
  border-color: var(--green);
  background: var(--green);
  color: white;
}

.primaryButton:hover {
  background: var(--green-dark);
  color: white;
}

.ghostButton {
  width: auto;
  min-width: 96px;
}

.dangerButton {
  border-color: #ffd0c6;
  background: #fff2ef;
  color: var(--danger);
}

.notice {
  margin: 14px 0;
  padding: 13px 16px;
  background: var(--warn);
  border-color: var(--warn-line);
  color: #74501c;
}

.notice strong {
  margin-right: 10px;
}

.addPanel {
  margin-bottom: 14px;
  padding: 18px;
}

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

.addHeader {
  margin-bottom: 16px;
}

.addHeader .muted {
  margin: 8px 0 0;
}

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

.uploadBox,
.entryBox {
  min-width: 0;
}

.filePicker input {
  width: 100%;
}

.rotateRow,
.saveRow {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.uploadPreviewFrame {
  position: relative;
  min-height: 260px;
  margin-top: 12px;
  overflow: auto;
  border: 1px dashed #b8cbb2;
  border-radius: 16px;
  background:
    linear-gradient(45deg, #f0f4ec 25%, transparent 25%),
    linear-gradient(-45deg, #f0f4ec 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f0f4ec 75%),
    linear-gradient(-45deg, transparent 75%, #f0f4ec 75%);
  background-size: 22px 22px;
  background-position: 0 0, 0 11px, 11px -11px, -11px 0;
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease;
}

.uploadPreviewFrame:hover,
.uploadPreviewFrame:focus-visible,
.uploadPreviewFrame.dragOver {
  border-color: var(--green);
  outline: none;
}

.uploadPreviewFrame.dragOver {
  background-color: var(--green-soft);
}

.uploadPreviewFrame img {
  display: none;
  width: 100%;
  height: auto;
  background: white;
  transform-origin: center center;
}

.uploadPreviewFrame.hasImage img {
  display: block;
}

#uploadEmptyHint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  pointer-events: none;
}

.uploadPreviewFrame.hasImage #uploadEmptyHint {
  display: none;
}

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

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

.wideLabel {
  display: block;
  margin-top: 12px;
}

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

.imagePanel,
.previewPanel,
.tableCard {
  min-width: 0;
}

.panelTitle,
.tableHeader {
  margin-bottom: 12px;
}

.imageList {
  max-height: 700px;
  overflow: auto;
  padding-right: 6px;
}

.imageItem {
  width: 100%;
  height: auto;
  display: block;
  margin: 0 0 9px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  text-align: left;
}

.imageListEntry {
  position: relative;
}

.imageListEntry .imageItem {
  padding-right: 46px;
}

.deleteUserImage {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  min-width: 28px;
  padding: 0;
  border-radius: 50%;
  border-color: #f4c9c4;
  background: #fff4f2;
  color: var(--danger);
  font-size: 18px;
  line-height: 1;
}

.deleteUserImage:hover {
  background: #ffe8e4;
}

.imageItem:hover,
.imageItem.active {
  border-color: var(--green);
  background: var(--green-soft);
}

.imageItem strong {
  display: block;
  margin-bottom: 5px;
  font-size: 14px;
  word-break: break-all;
}

.imageItem .meta {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 12px;
}

.pillRow {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #edf5ea;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
}

.pill.warn {
  background: #ffe8e1;
  color: var(--danger);
}

.pill.user {
  background: #e9f1ff;
  color: #2457a6;
}

.ocrDetails {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.ocrDetails summary {
  cursor: pointer;
  padding: 10px 12px;
  color: var(--muted);
}

.ocrDetails pre {
  max-height: 180px;
  margin: 0;
  padding: 0 12px 12px;
  overflow: auto;
  white-space: pre-wrap;
  font: inherit;
  color: var(--text);
}

.previewPanel {
  display: grid;
  gap: 12px;
  align-content: start;
}

.muted {
  color: var(--muted);
}

.openLink {
  max-width: 128px;
}

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

.miniCard {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
}

.miniCard span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.miniCard strong {
  font-size: 15px;
}

.imageFrame {
  min-height: 540px;
  max-height: 78vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    linear-gradient(45deg, #f0f4ec 25%, transparent 25%),
    linear-gradient(-45deg, #f0f4ec 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f0f4ec 75%),
    linear-gradient(-45deg, transparent 75%, #f0f4ec 75%);
  background-size: 22px 22px;
  background-position: 0 0, 0 11px, 11px -11px, -11px 0;
}

.imageFrame img {
  display: block;
  width: 100%;
  height: auto;
  background: white;
}

.tableCard {
  margin-top: 16px;
  padding: 16px;
}

.tableWrap {
  max-height: 720px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: white;
}

th,
td {
  padding: 10px 11px;
  border-bottom: 1px solid #edf2ea;
  vertical-align: top;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #176f18;
  color: white;
  text-align: left;
  white-space: nowrap;
}

td:nth-child(5),
td:nth-child(6),
td:nth-child(7) {
  text-align: right;
  white-space: nowrap;
}

tr:hover td,
tr.active td {
  background: #f2faef;
}

.productName {
  font-weight: 800;
}

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

.imageButton {
  width: auto;
  min-width: 78px;
  height: 32px;
  border-radius: 999px;
  font-size: 12px;
}

.statusStack {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

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

@media (max-width: 1080px) {
  .toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .addGrid,
  .workspace {
    display: block;
  }

  .uploadBox,
  .imagePanel {
    margin-bottom: 16px;
  }
}

@media (max-width: 720px) {
  .hero,
  .heroStats,
  .toolbar,
  .formGrid,
  .selectedItems,
  .rotateRow,
  .saveRow {
    display: block;
  }

  .shell {
    width: min(100vw - 22px, 1480px);
  }

  .heroStats {
    margin-top: 20px;
  }

  .heroStats div {
    display: inline-block;
    margin: 0 8px 8px 0;
  }

  .toolbar > *,
  .formGrid > *,
  .rotateRow > *,
  .saveRow > * {
    margin-bottom: 12px;
  }
}
