:root {
  --red: #A8231C; --red-dark: #7E1A15; --red-soft: #F6E4E1;
  --ink: #1F1A17; --muted: #6B625B; --line: #E8E1D9; --line-soft: #F0EAE3;
  --bg: #F7F4EF; --card: #FFFFFF;
  --blue: #1D4F8C; --blue-soft: #E3EDF8;
  --amber: #8A4508; --amber-soft: #FBEBDD;
  --gray: #5E5750; --gray-soft: #ECE8E3;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "PingFang SC", "Noto Sans SC", sans-serif; -webkit-text-size-adjust: 100%; }
button, input { font-family: inherit; }
a { color: var(--red); text-decoration: none; }
.center { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; text-align: center; }
.logo-lg { width: 88px; height: 88px; }
.muted { color: var(--muted); font-size: 14px; line-height: 1.6; }
.small { font-size: 12px; }
.page { min-height: 100vh; display: flex; flex-direction: column; padding-bottom: 76px; }
.page.no-tab { padding-bottom: 88px; }

/* 首页抬头 */
.hero { background: var(--red); color: #fff; padding: 16px 16px 52px; padding-top: max(16px, env(safe-area-inset-top)); }
.hero-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand img { width: 30px; height: 30px; filter: brightness(0) invert(1); }
.brand b { font-size: 14px; letter-spacing: 1px; display: block; }
.brand span { font-size: 11px; opacity: .85; }
.pill-w { font-size: 12px; background: rgba(255,255,255,.18); padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.hero h1 { font-size: 21px; margin: 12px 0 2px; }
.hero p { margin: 0; font-size: 12px; opacity: .9; }
.kpi { margin: -38px 16px 0; background: var(--card); border-radius: 16px; padding: 14px; box-shadow: 0 2px 10px rgba(31,26,23,.08);
  display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; gap: 6px; }
.kpi b { font-size: 21px; display: block; }
.kpi span { font-size: 12px; color: var(--muted); }

/* 顶栏 */
.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 6px; padding: 8px 10px; padding-top: max(8px, env(safe-area-inset-top));
  background: var(--card); border-bottom: 1px solid var(--line); }
.bar .back { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; color: var(--ink); }
.bar .title { font-size: 16px; font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.wrap { padding: 12px 16px; display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--card); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.card h3 { margin: 0; font-size: 15px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 16px 4px; }
.chip { flex-shrink: 0; min-height: 36px; padding: 0 14px; border-radius: 999px; font-size: 13px; border: 1px solid #E0D8CF; background: #fff; color: var(--ink); }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }

.store { display: flex; gap: 12px; align-items: center; background: var(--card); border-radius: 14px; padding: 14px; color: var(--ink); }
.store .no { width: 30px; height: 30px; border-radius: 15px; background: var(--red-soft); color: var(--red); font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.store .mid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.store .name { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.store .meta { font-size: 12px; color: var(--muted); }
.store .right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.flag { align-self: flex-start; font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--red-soft); color: var(--red); }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 999px; }
.tag.在动销 { background: var(--blue-soft); color: var(--blue); }
.tag.没动销 { background: var(--amber-soft); color: var(--amber); }
.tag.沉睡, .tag.已退货 { background: var(--gray-soft); color: var(--gray); }
.tag.新开 { background: #E8F3EC; color: #2C6B45; }
.owe { font-size: 12px; color: var(--red); }

.big-money { font-size: 22px; font-weight: 700; color: var(--red); }
.line-item { display: flex; justify-content: space-between; font-size: 13px; padding: 10px 12px; background: var(--bg); border-radius: 10px; gap: 8px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.cell { background: var(--bg); border-radius: 10px; padding: 10px 4px; }
.cell b { font-size: 18px; display: block; }
.cell span { font-size: 12px; color: var(--muted); }
.hist { display: flex; gap: 10px; font-size: 13px; }
.hist .d { color: var(--muted); width: 48px; flex-shrink: 0; }

.stepper { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line-soft); }
.stepper:first-of-type { border-top: 0; }
.stepper .lbl { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.stepper .lbl b { font-size: 15px; font-weight: 500; }
.stepper .lbl span { font-size: 12px; color: var(--muted); }
.rnd { width: 44px; height: 44px; border-radius: 22px; border: 1px solid #E0D8CF; background: #fff; font-size: 20px; color: var(--ink); }
.qty { width: 40px; text-align: center; font-size: 18px; font-weight: 700; }
.seg { display: grid; gap: 8px; }
.seg button { min-height: 44px; border-radius: 10px; font-size: 14px; border: 1px solid #E0D8CF; background: #fff; color: var(--ink); }
.seg button.on { background: var(--red); color: #fff; border-color: var(--red); }
input.txt { min-height: 44px; border: 1px solid #E0D8CF; border-radius: 10px; padding: 0 12px; font-size: 15px; width: 100%; }

.foot { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line);
  padding: 10px 16px; padding-bottom: max(10px, env(safe-area-inset-bottom)); display: flex; gap: 10px; align-items: center; }
.btn { min-height: 48px; border: 0; border-radius: 12px; background: var(--red); color: #fff; font-size: 16px; font-weight: 500; padding: 0 20px;
  display: inline-flex; align-items: center; justify-content: center; }
.btn.soft { background: var(--red-soft); color: var(--red); }
.btn.full { width: 100%; }
.btn:disabled { opacity: .5; }
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(3, 1fr); background: var(--card);
  border-top: 1px solid var(--line); padding: 4px 0; padding-bottom: max(6px, env(safe-area-inset-bottom)); }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); min-height: 44px; justify-content: center; }
.tabbar a.on { color: var(--red); }
.tabbar svg { width: 22px; height: 22px; }

.done { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 32px; text-align: center; }
.done .ok { width: 64px; height: 64px; border-radius: 32px; background: var(--blue-soft); color: var(--blue); display: flex; align-items: center; justify-content: center; font-size: 32px; }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: rgba(31,26,23,.9); color: #fff; padding: 10px 16px;
  border-radius: 10px; font-size: 14px; max-width: 86vw; z-index: 20; }
.empty { text-align: center; color: var(--muted); font-size: 14px; padding: 24px 0; }
.note-box { background: var(--amber-soft); color: var(--amber); border-radius: 12px; padding: 10px 12px; font-size: 13px; line-height: 1.6; }

.ph { position: relative; min-height: 88px; border-radius: 12px; border: 1px dashed #CFC5BA; background: var(--bg); color: var(--muted); font-size: 13px;
  display: flex; align-items: center; justify-content: center; overflow: hidden; aspect-ratio: 3 / 4; }
.ph.has { border: 1px solid var(--line); }
.ph img { width: 100%; height: 100%; object-fit: contain; display: block; background: #2a2522; }
.ph em { position: absolute; left: 0; right: 0; bottom: 0; font-style: normal; font-size: 10px; color: #fff; background: rgba(0,0,0,.45); padding: 2px 4px; }

.step { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line-soft); color: var(--ink); }
.step:first-child { border-top: 0; }
.step .sn { width: 28px; height: 28px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex-shrink: 0; }
.step .st { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.step .st b { font-size: 15px; }
.step .st span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step .ss { font-size: 12px; padding: 3px 10px; border-radius: 999px; flex-shrink: 0; }
.ok { background: var(--blue-soft); color: var(--blue); }
.wait { background: var(--amber-soft); color: var(--amber); }
.todo { background: var(--gray-soft); color: var(--gray); }
.bad { background: #FBEBEB; color: var(--red); }

.viewas { position: sticky; top: 0; z-index: 30; display: block; background: #1F1A17; color: #F3D9D6; font-size: 12px; text-align: center; padding: 8px 12px; }

.frow { display: flex; flex-direction: column; gap: 4px; }
.frow .chip { min-height: 32px; font-size: 12px; padding: 0 10px; }
