:root {
  --bg: #f4f6f5;
  --panel: #ffffff;
  --ink: #171918;
  --muted: #68706c;
  --line: #dfe5e1;
  --brand: #176b5b;
  --brand-soft: #e3f4ef;
  --warn: #b84d2e;
  --warn-soft: #fff0e7;
  --ok: #246b43;
  --ok-soft: #e6f3ea;
  --blue: #2f5f9f;
  --blue-soft: #edf3ff;
  --shadow: 0 14px 34px rgba(31, 39, 35, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1320px, 100%);
  margin: 0 auto;
  padding: 22px 16px 48px;
}

.topbar,
.top-actions,
.panel-head,
.ocr-actions,
.review-actions,
.row-actions,
.inbound-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar,
.panel-head {
  justify-content: space-between;
  align-items: flex-start;
}

.topbar {
  margin-bottom: 12px;
}

.eyebrow,
.panel-head p {
  color: var(--muted);
  font-size: 13px;
}

.eyebrow,
h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.12;
}

h2 {
  font-size: 18px;
}

.primary-btn,
.ghost-btn,
.danger-btn {
  min-height: 38px;
  border-radius: 8px;
  padding: 8px 12px;
  white-space: nowrap;
}

.primary-btn {
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  font-weight: 700;
}

.ghost-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.danger-btn {
  border: 1px solid #efc3b3;
  background: #fff7f3;
  color: var(--warn);
}

.notice {
  border: 1px solid #d9e6df;
  border-radius: 8px;
  background: #fbfdfb;
  color: var(--muted);
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 13px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 13px;
}

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

.metric strong {
  font-size: 28px;
}

.layout {
  display: grid;
  grid-template-columns: 440px minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 14px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0 12px;
}

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

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

.field input,
.field select,
.field textarea,
.review-actions input,
.review-actions select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
}

.text-field {
  margin-top: 12px;
}

textarea {
  min-height: 168px;
  resize: vertical;
}

.drop-zone {
  position: relative;
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 132px;
  border: 1px dashed #aab7b0;
  border-radius: 8px;
  background: #f9fbfa;
  text-align: center;
  padding: 18px;
}

.drop-zone.is-dragging {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.drop-zone span,
.status-line {
  color: var(--muted);
  font-size: 13px;
}

.drop-zone input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.ocr-actions {
  flex-wrap: wrap;
  margin-top: 12px;
}

.status-line {
  margin-top: 10px;
}

.thumb-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.thumb-wrap {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #f7f8f6;
}

.thumb {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
}

.thumb-wrap.is-active {
  border-color: var(--brand);
  outline: 2px solid var(--brand-soft);
}

.thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

.thumb-delete {
  position: absolute;
  right: 5px;
  bottom: 5px;
  border: 1px solid #efc3b3;
  border-radius: 999px;
  background: rgba(255, 247, 243, 0.94);
  color: var(--warn);
  padding: 4px 7px;
  font-size: 11px;
}

.image-preview {
  display: grid;
  place-items: center;
  min-height: 474px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f9f7;
  color: var(--muted);
  overflow: hidden;
}

.image-preview img {
  display: block;
  max-width: 100%;
  max-height: 680px;
  object-fit: contain;
}

.review-panel,
.inbound-panel {
  margin-top: 14px;
}

.review-head {
  gap: 16px;
}

.review-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.review-actions select {
  width: 130px;
}

.review-actions input {
  width: 220px;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 12px;
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7f9f7;
  color: var(--muted);
}

td input,
td select {
  width: 100%;
  min-width: 84px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: #f8faf8;
  padding: 7px;
}

td input:focus,
td select:focus {
  border-color: var(--brand);
  background: #fff;
  outline: 0;
}

.risk-row td {
  background: var(--warn-soft);
}

.duplicate-row td {
  background: #fff8dc;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-pending {
  background: #fff2d6;
  color: #855b00;
}

.badge-approved {
  background: var(--blue-soft);
  color: var(--blue);
}

.badge-inbounded {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge-exception {
  background: var(--warn-soft);
  color: var(--warn);
}

.mini-btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 6px 8px;
  font-size: 12px;
}

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

.inbound-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 12px;
}

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

.selectable-card:has(.inbound-check:checked) {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.inbound-check {
  width: 18px;
  height: 18px;
  margin-top: 2px;
}

.reviewed-card {
  background: var(--ok-soft);
}

.inbound-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.inbound-actions span {
  color: var(--muted);
  font-size: 13px;
}

.inbound-card strong {
  display: block;
  margin-bottom: 8px;
}

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

@media (max-width: 1000px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .layout,
  .inbound-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar,
  .top-actions,
  .panel-head,
  .review-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .metric-grid,
  .field-grid {
    grid-template-columns: 1fr;
  }

  .primary-btn,
  .ghost-btn,
  .danger-btn,
  .review-actions input,
  .review-actions select {
    width: 100%;
  }
}
