:root {
  --bg: #F7F5F2;
  --card: #FFFFFF;
  --line: #E7E2DB;
  --line-soft: #F0ECE6;
  --ink: #1E1B18;
  --muted: #57514A;
  --faint: #6B645C;
  --accent: #C2410C;
  --accent-soft: #FFF1E8;
  --accent-dark: #9A3412;
  --ok: #2F6B3A;
  --ok-soft: #EAF3EC;
  --bad: #B42318;
  --bad-soft: #FDECEA;
  --friend: #1D4ED8;
  --friend-soft: #E8EEFC;
  --radius: 14px;
  font-family: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body { font-size: 15px; line-height: 1.5; }
[hidden] { display: none !important; }
h1 { font-size: 22px; line-height: 1.3; margin: 0; font-weight: 700; }
h2 { font-size: 16px; margin: 0; font-weight: 700; }
p { margin: 0; }
ol, ul { margin: 0; padding: 0; list-style: none; }
dl, dd { margin: 0; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app { max-width: 480px; margin: 0 auto; height: 100dvh; display: flex; flex-direction: column; background: var(--bg); position: relative; overflow: hidden; }
@media (min-width: 520px) { .app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); } }

.bar { flex: none; display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 16px; background: var(--card); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); box-sizing: content-box; }
.logo { display: block; }
.brand { font-weight: 700; font-size: 17px; }
.bar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; min-width: 0; }
.who { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.link-btn { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 4px 12px; font-size: 13px; color: var(--muted); }

.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.pad { padding: 20px 16px; }
.fill { flex: 1; min-height: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-s { display: flex; flex-direction: column; gap: 8px; }
.stack-m { display: flex; flex-direction: column; gap: 14px; }
.wide-gap { gap: 20px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.gap { gap: 10px; }
.between { justify-content: space-between; }
.baseline { align-items: baseline; }
.grow { flex: 1; min-width: 0; }
.grow-top { margin-top: auto; }
.center { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.center-x { align-items: center; }
.full-width { width: 100%; align-self: stretch; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 600; }
.accent { color: var(--accent); }
.label { display: block; font-size: 12px; color: var(--faint); }
.big { font-size: 26px; font-weight: 700; line-height: 1.2; }
.big small { font-size: 14px; font-weight: 400; color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.pad-s { padding: 14px 16px; }
.pad-m { padding: 16px; }

.chip { font-size: 13px; padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; white-space: nowrap; }

.btn { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 48px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-weight: 600; font-size: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:active { background: var(--accent-dark); }
.btn.outline { border-color: var(--accent); color: var(--accent); }
.btn.soft { width: auto; flex: none; background: var(--accent-soft); border-color: var(--accent-soft); color: var(--accent-dark); padding: 0 18px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary:disabled { background: #D9C9BE; border-color: #D9C9BE; opacity: 1; }
.icon-btn { border: 0; background: transparent; padding: 6px; margin: -6px; color: var(--muted); display: flex; }

.error { color: var(--bad); font-size: 14px; background: var(--bad-soft); padding: 8px 12px; border-radius: 10px; }

.meter { height: 6px; border-radius: 999px; background: var(--line-soft); overflow: hidden; }
.meter.thick { height: 10px; }
.meter > div { height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .4s ease; }

/* 声明 */
.clauses { padding: 4px 16px; }
.clauses li { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line-soft); }
.clauses li:last-child { border-bottom: 0; }
.clauses p { color: var(--muted); font-size: 14px; margin-top: 2px; }
.num { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-dark); font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center; margin-top: 1px; }
.thanks { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius); background: var(--accent-soft); color: var(--accent-dark); }
.thanks svg { flex: none; margin-top: 2px; }
.thanks p { font-size: 14px; margin-top: 2px; }
.foot { flex: none; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--card); border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }

/* 登录 */
.seg { display: flex; padding: 4px; background: var(--line-soft); border-radius: 12px; gap: 4px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 9px; height: 38px; font-weight: 600; color: var(--muted); }
.seg button[aria-selected="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(30,27,24,.08); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
.field input { height: 48px; border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; background: var(--card); font-weight: 400; font-size: 16px; outline: none; }
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.badge { width: 72px; height: 72px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); }
.badge.gray { background: var(--line-soft); color: var(--muted); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge svg { stroke-width: 2.2; }

/* 二维码 */
.qr-box { position: relative; width: 252px; height: 252px; padding: 16px; background: #fff; border: 1px solid var(--line); border-radius: 18px; display: flex; align-items: center; justify-content: center; }
.qr-box img { width: 220px; height: 220px; display: block; image-rendering: pixelated; }
.qr-box img:not([src]) { visibility: hidden; }
.qr-box span { position: absolute; font-size: 14px; }
.qr-box.dim img { opacity: .12; }
.status { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; padding: 6px 14px; border-radius: 999px; background: var(--line-soft); color: var(--muted); }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status.active { background: var(--accent-soft); color: var(--accent-dark); }
.status.active .dot { animation: pulse 1.2s ease-in-out infinite; }
.status.bad { background: var(--bad-soft); color: var(--bad); }
@keyframes pulse { 50% { opacity: .3; } }
.tip { font-size: 13px; color: var(--accent-dark); font-weight: 600; text-align: center; }
.steps3 { display: flex; padding: 12px 8px; }
.steps3 li { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 13px; color: var(--faint); }
.steps3 li span { width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--line); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; background: var(--card); }
.steps3 li.on { color: var(--accent-dark); font-weight: 600; }
.steps3 li.on span { border-color: var(--accent); color: var(--accent); }
.steps3 li.done span { background: var(--accent); border-color: var(--accent); color: #fff; }

/* 扫描 */
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid3 strong, .grid3 dd { display: block; font-size: 15px; font-weight: 700; white-space: nowrap; }
.grid3 dt { font-size: 12px; color: var(--faint); }
.list { overflow-y: auto; }
.fill-list { flex: 1; min-height: 120px; }
.list li { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); }
.list li:last-child { border-bottom: 0; }
.list .name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .price { font-weight: 700; color: var(--accent); }
.list .empty { justify-content: center; color: var(--faint); font-size: 14px; padding: 28px 16px; }

/* 铺子 */
.top-card { flex: none; padding: 14px 16px; background: var(--card); border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; }
.sub { flex: none; padding: 10px 16px 6px; font-size: 12px; color: var(--faint); }
.rows { padding: 0 16px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; }
.stall { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.stall:active { background: var(--accent-soft); }
.stall .who-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.stall .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stall .meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--faint); }
.tag { font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 5px; background: var(--accent-soft); color: var(--accent-dark); }
.tag.friend { background: var(--friend-soft); color: var(--friend); }
.stall .pr { text-align: right; }
.stall .pr strong { display: block; font-size: 20px; color: var(--accent); line-height: 1.2; }
.stall .pr small { font-size: 12px; color: var(--faint); }
.stall .go { flex: none; height: 34px; padding: 0 14px; border-radius: 9px; background: var(--accent); color: #fff; font-weight: 600; font-size: 14px; display: flex; align-items: center; }
.rows .empty { text-align: center; color: var(--faint); padding: 40px 0; font-size: 14px; }
.rows .warn { text-align: center; color: var(--muted); font-size: 13px; padding: 4px 0; }

/* 卖出数量 */
.sheet-back { position: absolute; inset: 0; background: rgba(30,27,24,.42); display: flex; align-items: flex-end; z-index: 10; }
.sheet { width: 100%; background: var(--card); border-radius: 20px 20px 0 0; padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 16px; animation: rise .2s ease-out; }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
.grip { align-self: center; width: 40px; height: 4px; border-radius: 4px; background: var(--line); }
.tray { background: var(--bg); border-radius: 12px; padding: 12px; }
.tray dd + dd { font-weight: 400; }
.stepper { display: flex; height: 48px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.stepper button { width: 48px; border: 0; background: var(--line-soft); font-size: 20px; }
.stepper input { flex: 1; min-width: 0; border: 0; text-align: center; font-size: 18px; font-weight: 700; outline: none; }
.total strong { font-size: 22px; color: var(--accent); }

/* 卖出进度 */
.sell-steps { display: flex; flex-direction: column; }
.sell-steps li { display: flex; gap: 12px; padding: 10px 0; color: var(--faint); }
.sell-steps li div { display: flex; flex-direction: column; }
.sell-steps small { font-size: 13px; }
.mark { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); margin-top: 1px; }
.sell-steps li.on { color: var(--ink); }
.sell-steps li.on .mark { border-color: var(--accent); border-top-color: transparent; animation: spin .8s linear infinite; }
.sell-steps li.done { color: var(--ink); }
.sell-steps li.done .mark { border-color: var(--ok); background: var(--ok) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 12.5l4 4 8-9' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/14px no-repeat; }
.sell-steps li.bad .mark { border-color: var(--bad); background: var(--bad); }
@keyframes spin { to { transform: rotate(360deg); } }

/* 结果 */
.kv { padding: 4px 16px; }
.kv div { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.kv div:last-child { border-bottom: 0; }
.kv dt { color: var(--muted); }
.kv dd { font-weight: 600; text-align: right; }
.kv dd.hl { color: var(--accent); font-size: 18px; }
.summary { padding: 14px 8px; width: 100%; text-align: center; }
.meter > div.full { width: 100%; }
