:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --surface-2: #f4efe7;
  --ink: #2b2622;
  --ink-2: #6d6259;
  --ink-3: #9b8f84;
  --line: #e6ddd1;
  --brand: #c6472d;
  --brand-soft: #fbe9e3;
  --amber: #b8791b;
  --amber-soft: #fbf0dc;
  --green: #2f7d55;
  --green-soft: #e4f3e9;
  --blue: #1f6fa8;
  --blue-soft: #e4f0f9;
  --danger: #a32d2d;
  --radius: 12px;
  --radius-lg: 18px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }

.app { max-width: 520px; margin: 0 auto; min-height: 100vh; padding-bottom: 96px; }
.app.wide { max-width: 100%; padding: 0 16px 40px; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
  display: flex; align-items: center; gap: 10px;
}
.topbar .shop { font-size: 17px; font-weight: 600; letter-spacing: .5px; }
.topbar .spacer { flex: 1; }
.topbar .sub { font-size: 12px; color: var(--ink-2); }

.banner {
  padding: 10px 14px; font-size: 13px; line-height: 1.5;
  border-bottom: 1px solid var(--line);
}
.banner.offline { background: var(--amber-soft); color: #7a5210; }
.banner.danger { background: #fbe4e4; color: var(--danger); }
.banner.info { background: var(--blue-soft); color: #14527d; }

.section { padding: 14px 16px; }
.section-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600; color: var(--ink-2);
  margin: 4px 0 10px;
}
.section-title .hint { font-weight: 400; font-size: 12px; color: var(--ink-3); }

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

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); border-radius: 999px;
  padding: 8px 14px; font-size: 14px; min-height: 40px;
  transition: background .15s, border-color .15s;
}
.chip .price { color: var(--ink-3); font-size: 12px; margin-left: 4px; }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip.active .price { color: #ffe9e2; }
.chip.soldout { opacity: .42; text-decoration: line-through; pointer-events: none; }
.chip:disabled { opacity: .4; }

.btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 10px; padding: 10px 16px; min-height: 44px;
  font-size: 15px; font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-ghost { background: transparent; }
.btn-danger { background: #fff; border-color: #e5b7b7; color: var(--danger); }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 13px; }
.btn-lg { min-height: 56px; font-size: 17px; font-weight: 600; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; }

.bottom-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 12px;
}
.bottom-bar .total { flex: 1; }
.bottom-bar .total b { font-size: 22px; color: var(--brand); }
.bottom-bar .btn { min-width: 150px; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; background: var(--surface); color: var(--ink);
  min-height: 44px; outline: none;
}
.input:focus { border-color: var(--brand); }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.tab { border: 0; background: transparent; padding: 8px 14px; border-radius: 999px; color: var(--ink-2); white-space: nowrap; }
.tab.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; line-height: 1.7; }
.badge.gray { background: var(--surface-2); color: var(--ink-2); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }

.money { font-variant-numeric: tabular-nums; font-weight: 600; }
.muted { color: var(--ink-2); }
.small { font-size: 12px; }
.center { text-align: center; }
.empty { padding: 28px 12px; text-align: center; color: var(--ink-3); font-size: 14px; }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%);
  background: #2b2622; color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 14px; z-index: 100; opacity: 0; pointer-events: none;
  transition: opacity .2s; max-width: 88vw; text-align: center;
}
.toast.show { opacity: 1; }
.toast.err { background: var(--danger); }

.gate {
  position: fixed; inset: 0; z-index: 90; background: rgba(43,38,34,.55);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.gate-card { background: var(--surface); border-radius: var(--radius-lg); padding: 22px; width: 100%; max-width: 340px; }
.gate-card h3 { font-size: 17px; margin-bottom: 6px; }

.pickup-hero {
  text-align: center; padding: 22px 14px; background: var(--brand-soft);
  border-radius: var(--radius-lg); margin-bottom: 14px;
}
.pickup-hero .no { font-size: 54px; font-weight: 700; color: var(--brand); letter-spacing: 3px; line-height: 1.1; }
.pickup-hero .label { font-size: 13px; color: var(--ink-2); }

.step-line { display: flex; align-items: center; gap: 6px; margin: 14px 0; }
.step { flex: 1; text-align: center; font-size: 12px; color: var(--ink-3); }
.step .dot { width: 22px; height: 22px; border-radius: 50%; background: var(--surface-2); margin: 0 auto 4px; display: flex; align-items: center; justify-content: center; font-size: 12px; }
.step.on .dot { background: var(--brand); color: #fff; }
.step.on { color: var(--brand); font-weight: 600; }

/* 收银台 */
.channel-bar { display: flex; gap: 8px; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.channel-bar .ch {
  flex: 1; min-height: 52px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); font-size: 14px; font-weight: 500; line-height: 1.25; padding: 6px;
}
.channel-bar .ch small { display: block; font-size: 11px; font-weight: 400; color: var(--ink-3); }
.channel-bar .ch.active { background: var(--amber-soft); border-color: var(--amber); color: #7a5210; }
.combo-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.combo {
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius);
  padding: 14px 10px; text-align: left; min-height: 76px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.combo:active { background: var(--brand-soft); }
.combo b { font-size: 15px; }
.combo .p { color: var(--brand); font-size: 13px; }

.line-item { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.line-item:last-child { border-bottom: 0; }
.line-item .name { flex: 1; min-width: 0; }
.line-item .name b { display: block; font-size: 14px; }
.line-item .name small { color: var(--ink-2); font-size: 12px; }
.qty-ctrl { display: flex; align-items: center; gap: 6px; }
.qty-ctrl button { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); font-size: 16px; }
.qty-ctrl span { min-width: 22px; text-align: center; font-weight: 600; }

/* 后厨大屏（横屏平板） */
.kitchen { min-height: 100vh; padding: 0 14px 20px; }
.kitchen-head { display: flex; align-items: center; gap: 12px; padding: 10px 2px; flex-wrap: wrap; }
.kitchen-head .shop { font-size: 20px; font-weight: 700; }
.kitchen-cols { display: grid; grid-template-columns: 1fr 1fr 320px; gap: 12px; align-items: start; }
.kcol { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 10px; min-height: 320px; }
.kcol > h3 { font-size: 15px; padding: 4px 6px 10px; display: flex; align-items: center; gap: 8px; }
.kcol > h3 .count { background: var(--surface); border-radius: 999px; padding: 0 8px; font-size: 12px; color: var(--ink-2); }
.kcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin-bottom: 10px; }
.kcard .kno { font-size: 30px; font-weight: 700; color: var(--brand); letter-spacing: 1px; line-height: 1.1; }
.kcard .dish { font-size: 17px; font-weight: 600; margin: 4px 0; }
.kcard .meta { font-size: 13px; color: var(--ink-2); }
.kcard .note { background: var(--amber-soft); color: #7a5210; padding: 5px 8px; border-radius: 6px; font-size: 13px; margin-top: 6px; }
.kcard .kfoot { display: flex; align-items: center; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.kcard .kfoot .btn { flex: 1; min-width: 96px; }
.longpress { position: relative; overflow: hidden; }
.longpress .fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: rgba(255,255,255,.28); pointer-events: none; }
.served-item { display: flex; align-items: center; gap: 10px; padding: 9px 8px; border-bottom: 1px solid var(--line); }
.served-item:last-child { border-bottom: 0; }
.served-item .no { font-size: 24px; font-weight: 700; color: var(--green); min-width: 74px; }

/* 店长页表格 */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: var(--surface-2); color: var(--ink-2); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat .k { font-size: 13px; color: var(--ink-2); }
.stat .v { font-size: 26px; font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; }
.stat .sub { font-size: 12px; color: var(--ink-2); }

/* V8：购物车与按份备注 */
.note-group { margin-bottom: 4px; }
.note-group .section-title { margin: 10px 0 8px; }
.note-tags { display: inline-flex; flex-wrap: wrap; gap: 4px; margin-left: 4px; vertical-align: middle; }
.note-tag { display: inline-block; background: var(--amber-soft); color: #7a5210; border-radius: 5px; padding: 1px 6px; font-size: 11px; line-height: 1.7; white-space: nowrap; }
.cart-badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--brand); color: #fff; font-size: 11px; line-height: 18px; text-align: center; margin-left: 4px; }
.cart-line { padding: 10px 0; border-bottom: 1px solid var(--line); }
.cart-line:last-child { border-bottom: 0; }
.cart-line .cl-head { display: flex; align-items: flex-start; gap: 8px; }
.cart-line .cl-name { flex: 1; min-width: 0; }
.cart-line .cl-name b { font-size: 14px; }
.cart-line .cl-sub { font-size: 12px; color: var(--ink-2); margin-top: 3px; line-height: 1.7; }
.cart-line .cl-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.cart-line .cl-foot .money { margin-left: auto; }
.cart-line .mini { min-height: 30px; padding: 4px 10px; font-size: 12px; border-radius: 8px; }
.note-panel .gate-card { max-width: 400px; max-height: 86vh; overflow-y: auto; }
.kcard .kline { display: flex; align-items: baseline; gap: 6px; font-size: 15px; padding: 3px 0; flex-wrap: wrap; }
.kcard .kline + .kline { border-top: 1px dashed var(--line); }
.kcard .kidx { display: inline-block; min-width: 36px; color: var(--brand); font-weight: 600; font-size: 13px; }
.kcard .kdish { font-weight: 600; }
.kcard .kextra { color: var(--ink-2); font-size: 12px; }
.kcard .kitem-note { color: #7a5210; font-size: 12px; }
.option-head, .option-row { display: grid; grid-template-columns: 1.3fr 1fr 1.2fr 58px 56px 64px; gap: 6px; align-items: center; }
.option-head { font-size: 12px; color: var(--ink-2); padding: 4px 2px; }
.option-row { margin-bottom: 6px; }
.option-row .input { min-height: 34px; padding: 6px 8px; font-size: 13px; }
.option-row .btn { min-height: 34px; padding: 4px 8px; font-size: 12px; }

/* V9：桌位标记、抽奖转盘、奖品券、桌贴二维码 */
.table-badge { display: inline-block; background: var(--blue-soft); color: #14527d; border-radius: 6px; padding: 1px 8px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.kcard .table-badge { font-size: 14px; padding: 2px 10px; }
.served-item .table-badge { font-size: 11px; }

.coupon-picker { display: flex; flex-direction: column; gap: 8px; }
.coupon-pick {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); text-align: left;
}
.coupon-pick.active { border-color: var(--brand); background: var(--brand-soft); }
.coupon-pick .cp-name { flex: 1; font-weight: 600; }
.coupon-pick .small { color: var(--ink-2); }
.price-split { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.price-split .origin { text-decoration: line-through; color: var(--ink-3); font-size: 12px; }
.price-split .cut { color: var(--green); font-size: 12px; }

.coupon {
  border: 1px solid var(--line); border-left: 5px solid var(--brand);
  border-radius: 10px; background: var(--surface); padding: 12px 14px; margin-bottom: 10px;
}
.coupon.used { border-left-color: var(--ink-3); opacity: .62; }
.coupon.free { border-left-color: var(--green); }
.coupon .cp-head { display: flex; align-items: center; gap: 8px; }
.coupon .cp-head b { font-size: 16px; flex: 1; }
.coupon .cp-code { font-family: var(--font-mono, monospace); font-size: 12px; color: var(--ink-2); word-break: break-all; }
.coupon .cp-foot { margin-top: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.coupon .cp-foot .btn { min-height: 32px; padding: 4px 10px; font-size: 12px; }

.wheel-wrap { position: relative; width: 300px; height: 300px; margin: 16px auto 22px; }
.wheel { width: 100%; height: 100%; transform: rotate(0deg); transition: transform 4.2s cubic-bezier(.12,.75,.2,1); }
.wheel svg { display: block; width: 100%; height: 100%; }
.wheel-pointer {
  position: absolute; left: 50%; top: -8px; transform: translateX(-50%); z-index: 3;
  width: 0; height: 0; border-left: 14px solid transparent; border-right: 14px solid transparent;
  border-top: 26px solid var(--brand);
}
.wheel-center {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 3;
  width: 64px; height: 64px; border-radius: 50%; background: var(--surface);
  border: 3px solid var(--brand); color: var(--brand); font-weight: 600; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}
.wheel-center.spinning { pointer-events: none; }
.lucky-hero { text-align: center; padding: 16px 12px 4px; }
.lucky-hero h2 { font-size: 20px; color: var(--brand); }
.win-card { text-align: center; }
.win-card .prize { font-size: 26px; font-weight: 700; color: var(--brand); margin: 8px 0; }
.share-note { background: var(--blue-soft); color: #14527d; border-radius: 10px; padding: 10px 12px; font-size: 13px; line-height: 1.6; }
.privacy-note { font-size: 12px; color: var(--ink-2); text-align: center; padding: 8px 12px 20px; line-height: 1.6; }

.prize-row, .prize-head { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1fr 1fr 70px; gap: 6px; align-items: center; }
.prize-head { font-size: 12px; color: var(--ink-2); padding: 4px 2px; }
.prize-row { margin-bottom: 6px; }
.prize-row .input { min-height: 34px; padding: 6px 8px; font-size: 13px; }
.prize-row .btn { min-height: 34px; padding: 4px 8px; font-size: 12px; }
.tier-row { display: grid; grid-template-columns: 1fr 1fr 70px; gap: 8px; align-items: center; margin-bottom: 6px; }
.qr-cell { display: flex; align-items: center; gap: 10px; }
.qr-cell img { width: 76px; height: 76px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.qr-placeholder { width: 76px; height: 76px; border: 1px dashed var(--line); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--ink-3); text-align: center; padding: 4px; }
.qr-link { font-size: 11px; color: var(--ink-2); word-break: break-all; max-width: 260px; }

@media (max-width: 560px) {
  .wheel-wrap { width: 260px; height: 260px; }
  .prize-row, .prize-head { grid-template-columns: 1.2fr 1fr 1fr 1fr; }
  .prize-row .hide-sm, .prize-head .hide-sm { display: none; }
}

@media (max-width: 900px) {
  .kitchen-cols { grid-template-columns: 1fr 1fr; }
  .kitchen-cols .kcol:last-child { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .kitchen-cols { grid-template-columns: 1fr; }
  .kitchen-cols .kcol:last-child { grid-column: auto; }
  .combo-grid { grid-template-columns: 1fr 1fr; }
  .bottom-bar .btn { min-width: 130px; }
}
