:root {
  color-scheme: light;
  --ink: #17211d;
  --muted: #65716c;
  --line: #d7ded9;
  --paper: #f6f7f4;
  --panel: #ffffff;
  --accent: #096b5f;
  --accent-strong: #05493f;
  --warn: #a14c00;
  --bad: #b42318;
  --good: #0f7a45;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input {
  font: inherit;
}

.app {
  min-height: 100vh;
  padding: 22px;
}

.topbar {
  align-items: center;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin: 0 auto 16px;
  max-width: 1380px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.25;
}

.topbar p,
.panel-heading span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 5px;
}

.actions {
  display: flex;
  gap: 10px;
}

.file-button,
button {
  align-items: center;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font-weight: 700;
  min-height: 38px;
  padding: 0 14px;
}

.file-button input {
  display: none;
}

button:disabled {
  background: #b7c2bc;
  border-color: #b7c2bc;
  cursor: not-allowed;
}

button:not(:disabled):hover,
.file-button:hover {
  background: var(--accent-strong);
}

.summary {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0 auto 16px;
  max-width: 1380px;
}

.summary div,
.table-panel,
.preview-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.summary div {
  padding: 14px 16px;
}

.summary span {
  color: var(--muted);
  display: block;
  font-size: 13px;
}

.summary strong {
  display: block;
  font-size: 28px;
  margin-top: 5px;
}

.workspace {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(520px, 1fr) minmax(360px, 480px);
  margin: 0 auto;
  max-width: 1380px;
}

.panel-heading {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 52px;
  padding: 12px 14px;
}

h2 {
  font-size: 16px;
}

.check {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: 13px;
  gap: 7px;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 238px);
}

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

th,
td {
  border-bottom: 1px solid #edf0ec;
  font-size: 13px;
  line-height: 1.35;
  padding: 10px 11px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f2f5f1;
  color: #36413c;
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 1;
}

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

.tag {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 5px 8px;
}

.tag.good {
  background: #e5f5ec;
  color: var(--good);
}

.tag.bad {
  background: #fff0ed;
  color: var(--bad);
}

.mismatch {
  color: var(--warn);
  display: block;
  font-size: 12px;
  margin-top: 6px;
  max-width: 280px;
  word-break: break-all;
}

.preview-panel {
  min-width: 0;
}

.labels {
  display: grid;
  gap: 14px;
  justify-items: center;
  max-height: calc(100vh - 238px);
  overflow: auto;
  padding: 16px;
}

.label-page {
  background: #fff;
  border: 1px solid #cfd8d1;
  box-shadow: 0 12px 30px rgba(20, 30, 25, 0.1);
  height: 60mm;
  overflow: hidden;
  width: 60mm;
}

.label {
  background: #fff;
  color: #000;
  display: grid;
  grid-template-rows: 7mm 24mm 1fr;
  height: 60mm;
  padding: 3mm 3mm 2.5mm;
  width: 60mm;
}

.company {
  align-items: center;
  display: flex;
  font-family: "STSong", "Songti SC", "SimSun", serif;
  font-size: 9.2pt;
  font-weight: 700;
  justify-content: center;
  line-height: 1;
  overflow: hidden;
  text-align: center;
  white-space: nowrap;
}

.label-main {
  display: grid;
  gap: 2mm;
  grid-template-columns: 24mm 1fr;
  min-height: 0;
}

.qr-box {
  align-items: center;
  display: flex;
  height: 24mm;
  justify-content: center;
  width: 24mm;
}

.qr-box canvas {
  height: 24mm;
  image-rendering: pixelated;
  width: 24mm;
}

.compact-fields {
  display: grid;
  font-family: "STSong", "Songti SC", "SimSun", serif;
  font-size: 9.2pt;
  font-weight: 700;
  line-height: 1.3;
  padding-top: 4mm;
}

.field {
  align-items: baseline;
  display: flex;
  gap: 1mm;
  min-width: 0;
}

.field b,
.detail-row b {
  flex: 0 0 auto;
}

.field span,
.detail-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.details {
  align-content: start;
  display: grid;
  font-family: "STSong", "Songti SC", "SimSun", serif;
  font-size: 9.5pt;
  font-weight: 700;
  line-height: 1.35;
  padding-top: 1.5mm;
}

.detail-row {
  align-items: baseline;
  display: flex;
  gap: 1.5mm;
  min-width: 0;
}

.detail-row span.code-like {
  font-family: "Courier New", monospace;
  font-size: 9pt;
  letter-spacing: 0;
}

.spec-row {
  align-items: flex-start;
}

.spec-row span.code-like {
  line-height: 1.12;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

.print-root {
  display: none;
}

@media (max-width: 980px) {
  .topbar,
  .workspace {
    display: block;
  }

  .actions {
    margin-top: 12px;
  }

  .workspace {
    max-width: 100%;
  }

  .preview-panel {
    margin-top: 16px;
  }
}

@page {
  margin: 0;
  size: 60mm 60mm;
}

@media print {
  html,
  body {
    background: #fff;
    height: auto;
    margin: 0;
    padding: 0;
    width: 60mm;
  }

  .app {
    display: none !important;
  }

  .print-root {
    display: block;
    margin: 0;
    padding: 0;
    width: 60mm;
  }

  .print-root .label-page {
    display: block;
  }

  .label-page {
    border: 0;
    box-shadow: none;
    break-after: page;
    height: 60mm;
    page-break-after: always;
    width: 60mm;
  }

  .label-page:last-child {
    break-after: auto;
    page-break-after: auto;
  }
}
