:root {
  --ink: #1c1916;
  --muted: #8a8178;
  --line: #e7e0d6;
  --bg: #f6f1ea;
  --card: #fffdf9;
  --accent: #c45c26;
  --accent-soft: #f4e0d2;
  --ok: #2f6d4f;
  --danger: #9b3d32;
  --radius: 16px;
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
input, select { width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 12px; }
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[readonly] { background: #f6f1ea; color: var(--ink); }
a { color: var(--accent); }
#app {
  max-width: 980px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(12px + env(safe-area-inset-top)) 14px calc(24px + env(safe-area-inset-bottom));
}
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.top-actions { display: flex; align-items: center; gap: 10px; flex: none; }
.store-name { font-size: 20px; font-weight: 750; }
.sync-line { font-size: 12px; color: var(--muted); margin-top: 2px; }
.pill { background: var(--ink); color: #fff; border-radius: 999px; padding: 8px 14px; font-size: 13px; }
.text-btn { color: var(--muted); font-size: 13px; }
.text-btn.accent { color: var(--accent); font-weight: 650; }
.view { display: none; }
.view.active { display: block; }
.catalog-flow { font-size: 13px; color: var(--muted); margin: 0 0 10px; line-height: 1.45; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 42px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line);
  background: #fff; font-weight: 650;
}
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.danger { background: #f8e7e4; color: var(--danger); border-color: #efd2cc; }
.btn.wide { width: 100%; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.field { display: block; margin: 0 0 12px; font-size: 12px; color: var(--muted); }
.field input, .field select { margin-top: 6px; }
.note { color: var(--muted); font-size: 13px; line-height: 1.55; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.auth-error { color: var(--danger); font-size: 13px; line-height: 1.45; margin: 0 0 12px; }
.overlay {
  position: fixed; inset: 0; background: rgba(20,16,12,.45); z-index: 20;
  display: flex; align-items: flex-end; justify-content: center;
}
.overlay.login-gate { align-items: center; background: var(--bg); z-index: 40; }
[hidden] { display: none !important; }
.sheet {
  width: min(560px, 100%); background: var(--bg); border-radius: 20px 20px 0 0;
  padding: 14px 16px calc(18px + env(safe-area-inset-bottom));
  max-height: 92dvh; overflow: auto;
}
.login-gate .sheet {
  border-radius: 20px;
  margin: 16px;
  width: min(420px, calc(100% - 32px));
  box-shadow: 0 12px 40px rgba(28,25,22,.12);
  padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
}
.sheet.tall { max-height: 96dvh; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.sheet-head.sticky {
  position: sticky; top: -14px; z-index: 3;
  background: var(--bg);
  padding-top: 14px; margin-top: -14px;
}
.photos { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.photos img { width: 72px; height: 72px; border-radius: 12px; object-fit: cover; background: #efe8de; }
.photos .x { position: relative; }
.photos .x button {
  position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--ink); color: #fff; font-size: 12px;
}
.photo-head { font-size: 12px; color: var(--muted); margin-top: 4px; }
.sr-file {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); border: 0;
}
.kpi { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.kpi.kpi-4 { grid-template-columns: 1fr 1fr; }
@media (min-width: 720px) {
  .kpi.kpi-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
}
.kpi div { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.kpi small { color: var(--muted); font-size: 11px; }
.kpi strong { display: block; margin-top: 4px; font-size: 16px; }
.seg {
  display: flex; gap: 4px; background: #efe8de; padding: 4px;
  border-radius: 999px; margin: 0 0 12px;
}
.seg button { flex: 1; min-height: 34px; border-radius: 999px; font-size: 13px; color: var(--muted); }
.seg button.active { background: #fff; color: var(--ink); font-weight: 700; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(12px);
  background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 12px; opacity: 0;
  pointer-events: none; z-index: 80; max-width: 86%; text-align: center; font-size: 13px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); transition: .2s ease; }
.search-wrap { margin-bottom: 8px; }
.thumb {
  width: 54px; height: 54px; border-radius: 12px; object-fit: cover; background: #efe8de; flex: none;
}
.thumb.ph { display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.grow { min-width: 0; flex: 1; }
.name { font-weight: 650; }
.sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.arrive-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  margin: 0 0 12px;
}
.arrive-bar .arrive-month {
  flex: 1 1 140px;
  margin: 0;
}
.arrive-bar .arrive-day { flex: 1 1 96px; }
.arrive-bar .arrive-month select {
  margin-top: 6px;
}
.arrive-bar .seg {
  flex: 1 1 220px;
  margin: 0;
}
.purchase-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 14px;
}
.purchase-actions .btn { flex: 1; min-width: 96px; }
.batch-list, .stock-list { display: flex; flex-direction: column; gap: 10px; }
.batch-card, .stock-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
  text-align: left;
  cursor: pointer;
}
.batch-card .money, .stock-card .money {
  font-weight: 750;
  white-space: nowrap;
  text-align: right;
  line-height: 1.35;
}
.container-store .batch-card .money {
  white-space: normal;
  max-width: 46%;
}
.batch-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.batch-status {
  font-size: 12px;
  color: var(--muted);
  background: #efe8de;
  border-radius: 999px;
  padding: 4px 10px;
}
.batch-status.received { color: var(--ok); background: #e4f0e8; }
.batch-status.partial { color: var(--accent); background: var(--accent-soft); }
.batch-meta .field { margin-bottom: 8px; }
.batch-meta .field.check { display: flex; align-items: center; }
.batch-meta .field.check span { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.ymd-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}
.field .ymd-row input,
.field .ymd-row select {
  margin-top: 0;
  width: auto;
  text-align: center;
  padding: 12px 8px;
}
.ymd-row select {
  appearance: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  font: inherit;
  color: inherit;
}
.ymd-row select[id$="Year"] { width: 5.4em; flex: 0 0 5.4em; }
.ymd-row select[id$="Month"],
.ymd-row select[id$="Day"] { width: 4.2em; flex: 0 0 4.2em; }
.ymd-row span { flex: none; color: var(--ink); font-size: 13px; }
.ymd-cal {
  position: relative;
  width: 42px;
  height: 42px;
  flex: none;
  margin: 0 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.ymd-cal::after {
  content: "日历";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--accent);
  pointer-events: none;
}
.ymd-cal input[type="date"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  cursor: pointer;
}
.batch-docs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 0 0 12px;
}
.batch-docs img {
  width: 92px;
  height: 92px;
  object-fit: cover;
  border-radius: 12px;
  background: #efe8de;
  flex: none;
}
.item-view-bar {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 10px;
}
.item-view-bar .seg {
  flex: none;
  width: auto;
  margin: 0;
}
.item-view-bar .seg button {
  flex: none;
  padding: 0 14px;
}
.item-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.item-grid.item-grid-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
@media (min-width: 720px) {
  .item-grid:not(.item-grid-list) { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 980px) {
  .item-grid:not(.item-grid-list) { grid-template-columns: 1fr 1fr 1fr; }
}
.po-head,
.po-row {
  display: grid;
  grid-template-columns: 64px minmax(150px, 2fr) minmax(64px, .55fr) 80px 86px 72px 96px;
  gap: 8px 12px;
  align-items: center;
  width: 100%;
  text-align: left;
}
.po-head {
  padding: 0 12px 6px;
  font-size: 12px;
  color: var(--muted);
}
.po-head span:nth-child(n+4) { text-align: right; }
.po-row {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  cursor: pointer;
}
.po-row .thumb {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  object-fit: cover;
  background: #efe8de;
  flex: none;
}
.po-row .thumb.ph { display: grid; place-items: center; color: var(--muted); font-size: 11px; }
.po-name { min-width: 0; }
.po-name .name { font-weight: 650; }
.po-name .extra { color: var(--muted); font-size: 12px; margin-top: 2px; }
.po-name .extra:empty { display: none; }
.mix-chips,
.color-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}
.mix-chips:empty,
.mix-chips[hidden],
.color-chips:empty { display: none; }
.color-chip,
.size-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
}
.color-chip {
  background: #efe8de;
  font-weight: 650;
}
.size-chip {
  background: #fff;
  border: 1px solid #e4d9cc;
}
.color-chip b,
.size-chip b {
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}
.po-sku { color: var(--muted); font-size: 13px; word-break: break-all; }
.po-nums { display: contents; }
.po-num { text-align: right; }
.po-row .qty .n { font-size: 14px; font-weight: 700; }
.po-row .qty .pack,
.po-row .cbm .each { font-size: 11px; color: var(--muted); margin-top: 2px; }
.po-row .qty .pack:empty,
.po-row .cbm .each:empty { display: none; }
.cbm-input { max-width: 6.4em; font-weight: 650; }
.po-row .unit { font-size: 13px; color: var(--muted); white-space: nowrap; }
.po-row .money { font-weight: 750; }
.sell-input {
  width: 100%;
  max-width: 7.2em;
  margin: 0 0 0 auto;
  padding: 8px 6px;
  text-align: right;
  font-weight: 750;
  border-radius: 10px;
}
.po-row.noprice .sell-input { border-color: var(--accent); }
.po-card { cursor: pointer; }
.po-card.noprice .row span:last-child { color: var(--accent); }
.po-row.partial { outline: 2px solid var(--accent-soft); }
.po-row.done .qty { color: var(--ok); }
@media (max-width: 719px) {
  .po-head { display: none; }
  .po-row {
    grid-template-columns: 56px minmax(0, 1fr);
  }
  .po-sku {
    grid-column: 2;
  }
  .po-nums {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 10px;
    grid-column: 2 / -1;
  }
  .po-row .qty { text-align: left; }
}
.po-card .mix-chips,
.po-card .color-chips { margin-top: 8px; }
.po-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  width: 100%;
  text-align: left;
  padding: 0;
  cursor: pointer;
}
.po-card img, .po-card .ph {
  width: 100%;
  height: 160px;
  object-fit: cover;
  background: #efe8de;
  display: block;
}
.po-card .ph { display: grid; place-items: center; color: var(--muted); }
.po-card .body { padding: 10px 12px 12px; }
.po-card .name { font-size: 15px; }
.po-card .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.po-card .row {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-weight: 700;
}
.review-list { display: flex; flex-direction: column; gap: 10px; }
.review-batch { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.review-batch h3 { margin: 0 0 8px; font-size: 15px; }
.review-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; padding: 6px 0; border-top: 1px solid var(--line); }
.review-item:first-of-type { border-top: 0; }
.review-item .thumb { width: 42px; height: 42px; }
.ocr-box {
  white-space: pre-wrap;
  background: #efe8de;
  border-radius: 12px;
  padding: 10px;
  font-size: 12px;
  max-height: 160px;
  overflow: auto;
  margin: 8px 0 0;
}
.mini-filters { margin-bottom: 4px; }
#stockFilter { flex-wrap: wrap; border-radius: 18px; }
#stockFilter button { flex: 1 1 28%; }
.stock-card .qty-line { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stock-card .qty-line b { color: var(--ink); }
.stock-card.zero .money { color: var(--muted); }
.stock-card.noprice .money { color: var(--accent); }
.move-list { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 16px; }
.move-row {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}
.move-row .muted { color: var(--muted); font-size: 12px; }
.adjust-box {
  background: #efe8de;
  border-radius: 14px;
  padding: 10px 12px 2px;
  margin: 8px 0 14px;
}
.po-card.partial { outline: 2px solid var(--accent-soft); }
.po-card.done .row span:first-child { color: var(--ok); }
.filter-totals {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  margin: 0 0 12px;
  font-weight: 750;
  font-size: 15px;
  line-height: 1.45;
}
.print-root { display: none; }
body.printing #app,
body.printing .overlay,
body.printing .toast { display: none !important; }
body.printing .print-root { display: block; }
.print-sheet { padding: 8px 4px; color: #111; }
.print-sheet h1 { margin: 0 0 8px; font-size: 22px; }
.print-sheet .print-meta { margin: 0 0 12px; font-size: 14px; }
.print-sheet table { width: 100%; border-collapse: collapse; font-size: 14px; }
.print-sheet th, .print-sheet td {
  border: 1px solid #222;
  padding: 8px 6px;
  text-align: center;
  vertical-align: middle;
}
.print-sheet th { background: #f3f3f3; font-weight: 700; }
.print-sheet .p-name { text-align: left; font-weight: 650; }
.print-sheet .p-name small { display: block; color: #555; font-weight: 400; font-size: 12px; margin-top: 2px; }
.print-sheet .p-blank { min-width: 64px; height: 28px; }
.print-sheet .p-tick { width: 36px; }
.print-sheet tfoot td { font-weight: 750; }
.print-sheet .p-group td { text-align: left; background: #ececec; font-weight: 700; }
.arrive-head,
.arrive-line {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) 64px 64px 78px;
  gap: 8px;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
}
.arrive-head {
  font-size: 12px;
  color: var(--muted);
  padding-bottom: 4px;
}
.arrive-head span:nth-child(n+2),
.arrive-line span:nth-child(n+2) { text-align: right; }
.arrive-group {
  margin-top: 8px;
  background: #efe8de;
  border-radius: 12px;
  padding: 8px 12px;
  font-weight: 750;
  text-align: left;
  width: 100%;
}
.arrive-line {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-top: 6px;
  cursor: pointer;
}
.arrive-line .name { font-weight: 650; }
.arrive-line.empty-line { color: var(--muted); font-weight: 400; }
.tag-skip {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  background: #efe8de;
  border-radius: 999px;
  padding: 2px 8px;
  margin-left: 6px;
}
.container-line {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
  text-align: left;
}
.container-line .qty {
  font-weight: 750;
  white-space: nowrap;
  text-align: right;
}
.container-line.skip { background: #f7f3ee; }
.print-sheet .p-skip td { background: #f6f1ea; }
.print-sheet .print-sign { margin: 22px 0 8px; font-size: 14px; }
.print-sheet .print-note { margin: 0; color: #555; font-size: 12px; }
.staff-catalog h1 { margin-bottom: 4px; }
.staff-section { margin: 12px 0 8px; }
.staff-section h2 { margin: 0 0 8px; font-size: 16px; break-after: avoid; }
.staff-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px 12px;
}
.staff-card {
  border: 1px solid #222;
  border-radius: 10px;
  overflow: hidden;
  break-inside: avoid;
  page-break-inside: avoid;
  background: #fff;
}
.staff-card img,
.staff-ph {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  object-position: center;
  background: #f3eee8;
  display: block;
}
.staff-ph { display: grid; place-items: center; color: #888; font-size: 13px; }
.staff-body { padding: 7px 9px 9px; }
.staff-name { font-weight: 750; font-size: 13px; line-height: 1.3; }
.staff-sub, .staff-meta { color: #555; font-size: 11px; margin-top: 2px; }
.staff-price { margin-top: 4px; font-size: 18px; font-weight: 800; }
@media print {
  html, body { background: #fff !important; }
  body.printing .print-root { display: block !important; }
  .print-sheet { padding: 0; }
  .staff-grid { grid-template-columns: repeat(2, 1fr); gap: 8px 10px; }
  .staff-card img,
  .staff-ph {
    aspect-ratio: 4 / 3;
    height: auto;
    object-fit: contain;
    image-rendering: auto;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  @page { margin: 10mm; }
}
