:root {
  --ink: #18212f;
  --muted: #687386;
  --line: #dce3ec;
  --paper: #f6f2ea;
  --panel: #ffffff;
  --blue: #174f78;
  --blue2: #0d6c8b;
  --green: #14765b;
  --amber: #b7791f;
  --red: #b42318;
  --shadow: 0 18px 48px rgba(24, 33, 47, .12);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(23, 79, 120, .16), transparent 34rem),
    linear-gradient(135deg, #faf7ef 0%, #edf4f6 100%);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}
button, input { font: inherit; }
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 24px 32px;
  background: rgba(255,255,255,.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
h1 { margin: 0 0 6px; font-size: 28px; letter-spacing: -.5px; }
p { margin: 0; color: var(--muted); }
.actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
button, .linkButton {
  border: 0;
  border-radius: 14px;
  padding: 11px 16px;
  cursor: pointer;
  transition: transform .14s ease, box-shadow .14s ease, background .14s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}
button:hover, .linkButton:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(24,33,47,.12); }
.primary { background: linear-gradient(135deg, var(--blue), var(--blue2)); color: white; font-weight: 700; }
.ghost { background: white; color: var(--blue); border: 1px solid #c9d7e3; font-weight: 700; }
.tiny { padding: 7px 10px; border-radius: 10px; background: #eef5f8; color: var(--blue); }
.summary { display: grid; grid-template-columns: repeat(4, minmax(110px, 1fr)) minmax(180px, 2fr); gap: 12px; padding: 18px 32px 8px; }
.card, .status {
  background: rgba(255,255,255,.86);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
  box-shadow: 0 10px 30px rgba(24,33,47,.06);
}
.card strong { display: block; font-size: 26px; line-height: 1; }
.card span, .status { color: var(--muted); }
.card.ok strong { color: var(--green); }
.card.warn strong { color: var(--amber); }
.card.edit strong { color: var(--red); }
.status { display: flex; align-items: center; }
.tabs { display: flex; gap: 10px; padding: 12px 32px 18px; overflow-x: auto; }
.tab {
  background: rgba(255,255,255,.78);
  border: 1px solid var(--line);
  color: var(--ink);
  min-width: 120px;
}
.tab.active { background: var(--blue); color: white; border-color: var(--blue); }
.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 42vw) 1fr;
  gap: 22px;
  padding: 0 32px 32px;
  align-items: start;
}
.imagePane, .tablePane {
  background: rgba(255,255,255,.9);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.imagePane { position: sticky; top: 132px; max-height: calc(100vh - 154px); display: flex; flex-direction: column; }
.imageHead, .tableHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfdff;
}
.imageWrap { overflow: auto; padding: 16px; background: #ede9df; }
.imageWrap img { display: block; max-width: none; width: 100%; border-radius: 14px; box-shadow: 0 8px 24px rgba(24,33,47,.16); background: white; }
.tableHead h2 { margin: 0 0 4px; font-size: 22px; }
.rows { padding: 10px; display: grid; gap: 10px; }
.row {
  display: grid;
  grid-template-columns: 56px minmax(130px, 1.2fr) 86px minmax(130px, 1.1fr) 84px minmax(110px, .9fr) minmax(140px, 1fr);
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
}
.row.pending { border-left: 6px solid var(--amber); }
.row.confirmed { border-left: 6px solid var(--green); background: #f6fffb; }
.row.edited { border-left: 6px solid var(--red); background: #fff8f6; }
.seq { font-size: 18px; font-weight: 800; color: var(--blue); text-align: center; }
.model { font-size: 18px; font-weight: 800; letter-spacing: .2px; }
.qty { font-weight: 800; }
.field label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.field input {
  width: 100%;
  border: 1px solid #cad5df;
  border-radius: 11px;
  padding: 9px 10px;
  background: #fbfdff;
}
.note { color: var(--muted); font-size: 13px; line-height: 1.35; }
.rowActions { display: flex; gap: 8px; flex-wrap: wrap; }
.rowActions button { padding: 8px 10px; border-radius: 11px; font-size: 14px; }
.confirm { background: #e8f7f0; color: var(--green); font-weight: 800; }
.edit { background: #fff1e0; color: var(--amber); font-weight: 800; }
.reset { background: #eef1f5; color: #526071; }
.badge { display: inline-flex; padding: 4px 8px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.badge.match { color: var(--green); background: #e8f7f0; }
.badge.warn { color: var(--amber); background: #fff5d8; }
dialog { border: 0; border-radius: 20px; padding: 24px; box-shadow: var(--shadow); max-width: 420px; }
dialog::backdrop { background: rgba(24,33,47,.42); }
dialog h3 { margin-top: 0; }
@media (max-width: 1100px) {
  .workspace { grid-template-columns: 1fr; }
  .imagePane { position: static; max-height: none; }
  .summary { grid-template-columns: repeat(2, 1fr); }
  .row { grid-template-columns: 46px 1fr 70px; }
  .field, .rowActions, .note { grid-column: 1 / -1; }
}
.adopt { background: #e9f3ff; color: #174f78; font-weight: 800; }
.moveTools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #f7fbfd;
}
.imageViewport {
  position: relative;
  height: 720px;
  min-width: 360px;
  overflow: hidden;
  border-radius: 14px;
  background: #ded8cc;
  box-shadow: inset 0 0 0 1px rgba(24,33,47,.08);
}
.imageViewport img {
  position: absolute;
  left: 0;
  top: 0;
  width: 1280px;
  max-width: none;
  border-radius: 0;
  box-shadow: none;
  transform-origin: top left;
  user-select: none;
  -webkit-user-drag: none;
}
.imageViewport.full {
  height: 760px;
}
@media (max-width: 1100px) {
  .imageViewport { height: 620px; }
}
.imageViewport { cursor: grab; touch-action: none; }
.imageViewport.dragging { cursor: grabbing; }
/* Compact desktop layout: fit more content at 100% browser zoom. */
@media (min-width: 1101px) {
  .topbar { padding: 14px 24px; }
  h1 { font-size: 24px; margin-bottom: 2px; }
  .topbar p { font-size: 14px; }
  button, .linkButton { padding: 9px 13px; border-radius: 12px; }
  .summary { display: none; }
  .tabs { padding: 10px 24px 12px; }
  .tab { min-width: 106px; padding: 9px 12px; }
  .workspace {
    grid-template-columns: minmax(360px, 43vw) 1fr;
    gap: 16px;
    padding: 0 24px 18px;
    height: calc(100vh - 132px);
    min-height: 620px;
  }
  .imagePane, .tablePane {
    height: 100%;
    max-height: 100%;
  }
  .imagePane {
    position: static;
    display: flex;
    flex-direction: column;
  }
  .imageHead, .tableHead { padding: 12px 14px; }
  .tableHead h2 { font-size: 20px; margin-bottom: 2px; }
  .tableHead p { font-size: 13px; }
  .moveTools { padding: 9px 12px; gap: 6px; }
  .tiny { padding: 6px 9px; border-radius: 9px; }
  .imageWrap { flex: 1; min-height: 0; padding: 10px; }
  .imageViewport { height: 100%; min-height: 0; }
  .imageViewport.full { height: 100%; }
  .tablePane { display: flex; flex-direction: column; min-width: 0; }
  .rows {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 8px;
    gap: 8px;
    scroll-behavior: smooth;
  }
  .row {
    grid-template-columns: 42px minmax(112px, 1fr) 74px minmax(116px, .85fr) 78px 92px minmax(105px, .8fr);
    gap: 8px;
    padding: 8px 10px;
    border-radius: 13px;
    min-height: 92px;
  }
  .seq { font-size: 16px; }
  .model { font-size: 16px; }
  .qty { font-size: 14px; }
  .field label { font-size: 11px; }
  .field input { padding: 7px 9px; border-radius: 10px; }
  .rowActions { gap: 6px; }
  .rowActions button { padding: 6px 9px; border-radius: 9px; font-size: 13px; }
  .note { font-size: 12px; }
  .badge { font-size: 11px; padding: 3px 7px; }
}
/* Fix compact row overflow: keep rows compact without overlapping controls/text. */
@media (min-width: 1101px) {
  .row {
    align-items: center;
    min-height: 112px;
    height: auto;
    overflow: hidden;
  }
  .rowActions {
    display: grid;
    grid-template-columns: 1fr;
    align-content: center;
    gap: 5px;
  }
  .rowActions button {
    width: 100%;
    min-width: 0;
    height: 26px;
    padding: 3px 7px;
    line-height: 1;
  }
  .note {
    max-height: 78px;
    overflow: auto;
    line-height: 1.25;
    padding-right: 4px;
  }
  .field input {
    font-size: 15px;
  }
  .rows {
    align-content: start;
  }
}
.uploadPanel {
  margin: 14px 32px 0;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: minmax(240px, 1.4fr) repeat(2, minmax(180px, 1fr)) auto;
  gap: 10px;
  align-items: center;
  background: rgba(255,255,255,.88);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(24,33,47,.06);
}
.uploadPanel strong { display: block; }
.uploadPanel span { color: var(--muted); font-size: 12px; }
.uploadPanel label { color: var(--muted); font-size: 12px; }
.uploadPanel input { display: block; max-width: 100%; margin-top: 4px; }
.tableActions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
@media (min-width: 1101px) {
  .uploadPanel { margin: 8px 24px 0; grid-template-columns: minmax(220px, 1.2fr) repeat(2, minmax(160px, .8fr)) auto; padding: 8px 12px; }
  .uploadPanel input { font-size: 12px; }
  .workspace { height: calc(100vh - 188px); }
}
@media (max-width: 1100px) {
  .uploadPanel { grid-template-columns: 1fr; margin: 12px 16px 0; }
}
.emptyState {
  padding: 28px;
  border: 1px dashed #b7c6d6;
  border-radius: 16px;
  color: var(--muted);
  background: #fbfdff;
}

.wideDialog { max-width: 860px; width: min(860px, calc(100vw - 40px)); }
.diffList { margin: 16px 0; max-height: 60vh; overflow: auto; display: grid; gap: 8px; }
.diffItem { display: grid; grid-template-columns: 80px 1fr 100px 100px 100px; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-left: 6px solid var(--amber); border-radius: 12px; background: #fffaf0; }
.diffItem strong { font-size: 16px; }
.diffItem span { color: var(--muted); }
.dialogActions { display: flex; justify-content: flex-end; gap: 10px; }
.row.qtyDiff { box-shadow: inset 0 0 0 2px rgba(183, 121, 31, .22); }
@media (max-width: 760px) { .diffItem { grid-template-columns: 1fr 1fr; } }
.dropZone {
  min-height: 62px;
  border: 1.5px dashed #b8c8d8;
  border-radius: 14px;
  padding: 10px 12px;
  background: #fbfdff;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.dropZone:hover, .dropZone.dragOver {
  border-color: var(--blue);
  background: #eef7ff;
  transform: translateY(-1px);
}
.dropZone input { display: none; }
.dropZone span { display: block; margin-top: 5px; color: var(--ink); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dangerGhost { color: var(--red); border-color: rgba(180,35,24,.35); }
.dangerGhost:hover { background: #fff1f0; }
@media (min-width: 1101px) {
  .uploadPanel { grid-template-columns: minmax(220px, 1.2fr) repeat(2, minmax(190px, .9fr)) auto auto; }
}

.tablePreview {
  position: absolute;
  inset: 0;
  overflow: auto;
  padding: 14px;
  background: #f8fbfd;
}
.previewCard {
  background: white;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 10px 28px rgba(24,33,47,.08);
}
.previewTitle {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  color: var(--blue);
  font-weight: 800;
  background: #eef7ff;
  border-bottom: 1px solid var(--line);
}
.previewTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.previewTable th,
.previewTable td {
  padding: 10px 12px;
  border-bottom: 1px solid #e7edf4;
  text-align: left;
}
.previewTable th {
  color: var(--muted);
  background: #fbfdff;
  font-weight: 800;
}
.previewTable td:nth-child(1), .previewTable td:nth-child(3), .previewTable th:nth-child(1), .previewTable th:nth-child(3) { text-align: center; }
.previewHint {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.imageViewport.previewMode { cursor: default; touch-action: auto; }
.imageViewport.previewMode img { display: none; }
.imageViewport.previewMode .tablePreview { display: block; }
