:root {
  --ink: #1c1612;
  --ink-soft: #5a4d42;
  --paper: #f3eadc;
  --card: #fff8ee;
  --line: #d4c4ad;
  --cinnabar: #c23a2b;
  --tea: #2f5d45;
  --tea-soft: #dce8df;
  --ok: #2f5d45;
  --warn: #b45309;
  --bad: #c23a2b;
  --shadow: 0 10px 24px rgba(48, 32, 16, 0.08);
  --radius: 16px;
  --serif: "Noto Serif SC", "Songti SC", serif;
  --sans: "Noto Sans SC", "PingFang SC", sans-serif;
  --display: "Fraunces", "Noto Serif SC", serif;
  --dock-h: calc(92px + env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    linear-gradient(180deg, rgba(243, 234, 220, 0.94), rgba(231, 216, 194, 0.9)),
    repeating-linear-gradient(0deg, transparent, transparent 27px, rgba(196, 170, 136, 0.12) 28px);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  touch-action: manipulation;
}

.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.16;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}

body > * { position: relative; z-index: 1; }
h1, h2, h3 { font-family: var(--serif); margin: 0; }
p { margin: 0; }
[hidden] { display: none !important; }

.eyebrow {
  margin: 0 0 2px;
  color: var(--cinnabar);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 8px;
  max-width: 760px;
  margin: 0 auto;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 34px; height: 34px; color: var(--cinnabar); flex: none; }
.brand h1 { font-size: 18px; }
.top-actions { display: flex; gap: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  font: 600 14px/1 var(--sans);
  cursor: pointer;
  color: inherit;
  background: none;
}

.btn svg { width: 18px; height: 18px; }
.btn:focus-visible { outline: 3px solid #e8b089; outline-offset: 2px; }
.btn.solid { background: var(--cinnabar); color: #fff8ee; }
.btn.outline { border-color: var(--ink); }
.btn.ghost { background: rgba(255,248,238,0.8); border-color: var(--line); }
.btn.block { width: 100%; }
.btn.done { background: var(--tea); color: #f4faf6; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.wide { flex: 1; min-width: 0; }

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 4px 14px var(--dock-h);
}

.dropzone {
  position: relative;
  margin-top: 16px;
  padding: 36px 18px;
  border: 1.5px dashed #b89a74;
  border-radius: 22px;
  background: rgba(255, 248, 238, 0.78);
  text-align: center;
}

.dropzone.drag { background: #fff3df; border-color: var(--cinnabar); }
.dropzone h2 { font-size: 26px; margin-bottom: 10px; }
.dropzone p { color: var(--ink-soft); margin-bottom: 16px; }

.flow-preview {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
}

.flow-preview li {
  padding: 8px 4px;
  border-radius: 10px;
  background: #efe4d3;
  font-size: 12px;
  font-weight: 700;
}

.stamp {
  position: absolute;
  top: 14px;
  right: 14px;
  padding: 4px 8px;
  border: 2px solid var(--cinnabar);
  color: var(--cinnabar);
  font-family: var(--serif);
  font-weight: 700;
  letter-spacing: 0.16em;
  transform: rotate(8deg);
  font-size: 12px;
}

.batch-strip { padding: 6px 2px 12px; }
.batch-strip h2 { font-size: 24px; }
.batch-file {
  margin-top: 6px;
  color: var(--ink-soft);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.stepper {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 4px 0 12px;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 58px;
  padding: 8px 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,248,238,0.8);
  color: var(--ink-soft);
  cursor: pointer;
}

.step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #efe4d3;
  font-size: 12px;
  font-weight: 700;
}

.step-label { font-size: 12px; font-weight: 700; }
.step.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.step.active .step-num { background: var(--cinnabar); color: #fff8ee; }
.step.done { border-color: var(--tea); color: var(--tea); }
.step.done .step-num { background: var(--tea); color: #fff; }

.alert-bar {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fde8d8;
  color: #7c2d12;
  font-size: 14px;
}

.alert-bar.ok { background: var(--tea-soft); color: #163226; }
.step-lead { margin-bottom: 12px; color: var(--ink-soft); font-size: 14px; }
.panel { display: none; }
.panel.active { display: block; }

.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

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

.kpi .label { color: var(--ink-soft); font-size: 12px; }
.kpi .value { font-family: var(--display); font-size: 32px; line-height: 1.1; margin-top: 4px; }
.kpi .sub { margin-top: 4px; font-size: 12px; color: var(--ink-soft); }
.kpi.ok .value { color: var(--ok); }
.kpi.warn .value { color: var(--warn); }
.kpi.bad .value { color: var(--bad); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}

.card-head { margin-bottom: 12px; }
.card-head h3 { font-size: 18px; }
.card-head p { color: var(--ink-soft); font-size: 13px; }

.product-bars, .pick-board, .order-list, .issue-list { display: grid; gap: 8px; }

.pbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f8efe4;
  overflow: hidden;
}

.pbar.sealed {
  padding-right: 72px;
}

.pbar.mismatch { background: #f8dcd7; }
.pbar.ok { background: var(--tea-soft); }
.pbar .name { font-weight: 700; }
.pbar .nums { font-size: 13px; color: var(--ink-soft); }
.pbar .check { min-height: 44px; }

.check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  cursor: pointer;
  user-select: none;
}

input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  margin: 0;
  padding: 0;
  border: 2px solid #b08968;
  border-radius: 7px;
  background-color: #fffdf8;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 14px 14px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
  cursor: pointer;
  flex: none;
  vertical-align: middle;
  transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

input[type="checkbox"]:checked {
  background-color: var(--cinnabar);
  border-color: var(--cinnabar);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23fff8ee' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' d='M3.2 8.2l3.1 3.1 6.5-6.6'/%3E%3C/svg%3E");
}

input[type="checkbox"]:active {
  transform: scale(0.94);
}

input[type="checkbox"]:focus-visible {
  outline: 3px solid #e8b089;
  outline-offset: 2px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  background: #efe4d3;
  font-size: 12px;
  font-weight: 600;
}

.chip.晚安 { background: #e4dff2; }
.chip.无忧 { background: #dce8df; }
.chip.清润 { background: #d7e8ea; }
.chip.多宝 { background: #f3e2c4; }
.chip.降降 { background: #f3d6d1; }
.chip.黄精茶 { background: #ead8b8; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}
.chip-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff8ee;
  font: 600 13px/1 var(--sans);
  color: var(--ink-soft);
  cursor: pointer;
}
.chip-btn.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.meta-list { display: grid; gap: 10px; margin-bottom: 14px; }
.meta-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--line);
}
.meta-list dt { color: var(--ink-soft); }
.meta-list dd { margin: 0; font-weight: 600; text-align: right; }

.toolbar, .bulk-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.bulk-bar { display: grid; grid-template-columns: 1fr 1fr; }
.field { display: grid; gap: 6px; width: 100%; }
.field span { font-size: 12px; color: var(--ink-soft); font-weight: 600; }

input, select {
  min-height: 44px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffdf8;
  padding: 0 12px;
  font: 400 16px/1.4 var(--sans);
  color: var(--ink);
}

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%),
    linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 19px,
    calc(100% - 12px) 19px;
  background-size: 6px 6px;
  background-repeat: no-repeat;
}

input:focus, select:focus { outline: 3px solid #e8b089; outline-offset: 1px; }
.hint { color: var(--ink-soft); font-size: 13px; margin-bottom: 10px; }

.order-card, .pick-row, .pbar, .person-card {
  position: relative;
}

.order-card {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  column-gap: 12px;
  align-items: start;
  padding: 14px;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.order-card.no-check {
  grid-template-columns: minmax(0, 1fr);
}

.order-card.blocked { border-color: #e8b089; }

.card-check {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  min-height: 0;
  margin: 0;
  padding: 0;
  cursor: pointer;
}

.card-body {
  min-width: 0;
}

.order-card.sealed .card-body,
.person-card.sealed .person-head {
  padding-right: 72px;
}

.order-card h4 {
  margin: 0;
  font-size: 18px;
  line-height: 24px;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 20px;
}

.card-meta .phone {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--ink);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: #efe4d3;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}

.status-pill.warn { background: #f6e3c6; color: #7c2d12; }
.status-pill.ok { background: var(--tea-soft); color: #163226; }

.order-card .addr {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.45;
}

.card-body .chips {
  margin-top: 10px;
}

.order-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.order-actions .btn { width: 100%; }

.person-card {
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.person-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  column-gap: 12px;
  margin-bottom: 12px;
}

.person-head .check {
  min-height: 24px;
  padding-top: 2px;
}

.person-index {
  margin: 0 0 4px;
  color: var(--cinnabar);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.person-head h3 { font-size: 22px; }
.person-head .phone { font-weight: 600; font-variant-numeric: tabular-nums; }
.person-head .addr { margin-top: 6px; color: var(--ink-soft); font-size: 14px; }
.pick-items { display: grid; gap: 8px; }
.pick-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 12px;
  background: #f8efe4;
}

.seal {
  position: absolute;
  top: 12px;
  right: 12px;
  left: auto;
  bottom: auto;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 3;
}

.seal span {
  display: inline-block;
  padding: 5px 8px;
  border: 2px solid currentColor;
  box-shadow: 0 0 0 3px rgba(194, 58, 43, 0.08), inset 0 0 0 1px currentColor;
  border-radius: 4px;
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: 1;
  transform: rotate(-18deg);
  color: var(--cinnabar);
  background: rgba(255, 248, 238, 0.88);
  animation: stamp-in 320ms cubic-bezier(0.2, 1.2, 0.3, 1);
}

.seal-ship span { color: #c23a2b; }
.seal-pack span { color: #b45309; }
.seal-picked span { color: #2f5d45; box-shadow: 0 0 0 3px rgba(47, 93, 69, 0.08), inset 0 0 0 1px currentColor; }
.seal-ok span { color: #2f5d45; font-size: 14px; box-shadow: 0 0 0 3px rgba(47, 93, 69, 0.08), inset 0 0 0 1px currentColor; }

@keyframes stamp-in {
  0% { transform: rotate(-18deg) scale(1.55); opacity: 0; }
  65% { transform: rotate(-18deg) scale(0.96); opacity: 1; }
  100% { transform: rotate(-18deg) scale(1); opacity: 0.92; }
}

@media (prefers-reduced-motion: reduce) {
  .seal span { animation: none; }
}

.pick-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.pick-head {
  align-items: flex-start;
}
.pick-head h3 { font-size: 16px; }
.pick-sku, .pick-extra, .pick-action {
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 13px;
}
.card-body .pick-extra {
  margin-top: 8px;
}
.pick-action { color: var(--ink); font-size: 15px; }
.pick-rows { display: grid; gap: 8px; }
.pick-summary { display: grid; gap: 8px; }
.pick-sum-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px 8px;
  border-radius: 12px;
  background: #f8efe4;
}
.pick-sum-row .name { font-weight: 700; }
.pick-sum-row .sku { color: var(--ink-soft); font-size: 13px; margin-top: 2px; }
.pick-sum-row .qty { font-weight: 700; font-variant-numeric: tabular-nums; }

.history-tabs { margin: 8px 0 14px; }
.history-page { padding-bottom: 24px; }
.history-page .field { margin-bottom: 12px; }

.issue { padding: 10px 12px; border-radius: 12px; background: #f8efe4; font-size: 14px; }
.issue.ok { background: var(--tea-soft); }
.issue.bad { background: #f8dcd7; }
.issue.warn { background: #f6e3c6; }

.extra summary {
  cursor: pointer;
  font-weight: 700;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.compare-name { margin: 10px 0; font-size: 13px; color: var(--ink-soft); }

.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 248, 238, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.dock-status { font-size: 13px; color: var(--ink-soft); margin-bottom: 8px; }
.dock-actions { display: grid; grid-template-columns: 104px 1fr; gap: 8px; }

.dialog {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: end center;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
}

.dialog-scrim {
  position: absolute;
  inset: 0;
  background: rgba(28, 22, 18, 0.46);
}

.dialog-card {
  position: relative;
  width: min(420px, 100%);
  padding: 22px 20px 18px;
  border-radius: 22px 22px 18px 18px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 24px 48px rgba(48, 32, 16, 0.22);
  animation: dialog-in 220ms ease;
}

.dialog-card h3 {
  font-size: 22px;
  margin: 4px 0 8px;
}

.dialog-card p {
  color: var(--ink-soft);
  font-size: 15px;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 18px;
}

@keyframes dialog-in {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@media (min-width: 760px) {
  .dialog { place-items: center; }
  .dialog-card { border-radius: 22px; }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--dock-h) + 8px);
  transform: translateX(-50%) translateY(12px);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  opacity: 0;
  pointer-events: none;
  z-index: 20;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 760px) {
  .brand h1 { font-size: 22px; }
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .order-actions { grid-template-columns: repeat(4, 1fr); }
  .bulk-bar { display: flex; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
