:root {
  --primary: #07c160;
  --primary-dark: #06ad56;
  --primary-light: #e8f8ef;
  --danger: #fa5151;
  --warning: #ff976a;
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1a1a1a;
  --text-2: #6b7280;
  --text-3: #9ca3af;
  --line: #ececec;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; border: none; outline: none; }
input, textarea { font-family: inherit; outline: none; }

/* ---------- 手机外壳 ---------- */
.phone {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- 顶部栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  padding: 14px 16px 12px;
}
.topbar .shop-name { font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.topbar .shop-sub { font-size: 12px; opacity: .9; margin-top: 3px; display: flex; gap: 12px; align-items: center; }
.topbar .badge {
  background: rgba(255,255,255,.22);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 12px;
}

/* ---------- 视图切换 ---------- */
.view { display: none; flex: 1; flex-direction: column; min-height: 0; }
.view.active { display: flex; }

/* ---------- 菜单布局 ---------- */
.menu-body { display: flex; flex: 1; min-height: 0; }
.cat-side {
  width: 92px;
  background: #f0f1f3;
  overflow-y: auto;
  flex-shrink: 0;
  padding-bottom: 80px;
}
.cat-item {
  padding: 16px 8px;
  text-align: center;
  font-size: 13px;
  color: var(--text-2);
  position: relative;
  transition: .2s;
}
.cat-item.active {
  background: var(--card);
  color: var(--text);
  font-weight: 600;
}
.cat-item.active::before {
  content: "";
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 18px;
  background: var(--primary);
  border-radius: 2px;
}
.cat-item .dot {
  position: absolute;
  right: 10px; top: 10px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  min-width: 15px; height: 15px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
}

.dish-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 12px 90px;
  background: var(--card);
}
.cat-title { font-size: 13px; color: var(--text-3); padding: 14px 4px 6px; font-weight: 600; }
.dish {
  display: flex;
  gap: 10px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
}
.dish:last-child { border-bottom: none; }
.dish .pic {
  width: 64px; height: 64px;
  border-radius: 10px;
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
  flex-shrink: 0;
}
.dish .info { flex: 1; min-width: 0; }
.dish .name { font-weight: 600; font-size: 15px; }
.dish .desc { font-size: 12px; color: var(--text-3); margin: 3px 0; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dish .meta { font-size: 11px; color: var(--text-3); }
.dish .price { color: var(--danger); font-weight: 700; font-size: 15px; margin-top: 4px; }
.dish .price small { font-size: 11px; font-weight: 400; }

/* 步进器 */
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button {
  width: 26px; height: 26px;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.stepper .minus { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.stepper .plus { background: var(--primary); color: #fff; }
.stepper .num { min-width: 18px; text-align: center; font-weight: 600; }
.stepper .minus[hidden], .stepper .num[hidden] { display: none; }

/* ---------- 底部购物车栏 ---------- */
.cartbar {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%; max-width: 480px;
  background: #2b2b2b;
  color: #fff;
  display: flex;
  align-items: center;
  padding: 8px 12px;
  z-index: 30;
  height: 56px;
}
.cartbar .cart-icon {
  width: 50px; height: 50px;
  background: var(--primary);
  border-radius: 50%;
  margin-top: -22px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  position: relative;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.cartbar .cart-icon .count {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  min-width: 18px; height: 18px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}
.cartbar .total { flex: 1; padding-left: 14px; }
.cartbar .total .big { font-size: 18px; font-weight: 700; }
.cartbar .total .small { font-size: 11px; color: #bbb; }
.cartbar .go {
  background: var(--primary);
  color: #fff;
  padding: 0 22px;
  height: 40px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 15px;
}
.cartbar .go.disabled { background: #555; color: #999; }

/* 购物车明细弹层 */
.cart-pop {
  position: fixed;
  bottom: 56px; left: 50%;
  transform: translateX(-50%);
  width: 100%; max-width: 480px;
  background: #fff;
  border-radius: 14px 14px 0 0;
  z-index: 29;
  max-height: 60vh;
  overflow-y: auto;
  display: none;
  box-shadow: 0 -4px 16px rgba(0,0,0,.12);
}
.cart-pop.show { display: block; }
.cart-pop .head { display: flex; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 600; }
.cart-pop .clear { color: var(--text-3); font-size: 13px; }
.cart-pop .row { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.cart-pop .row .r-name { flex: 1; }
.cart-pop .row .r-price { color: var(--danger); font-weight: 600; margin-right: 10px; }
.mask {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 28;
  display: none;
}
.mask.show { display: block; }

/* ---------- 通用卡片/区块 ---------- */
.section { background: var(--card); margin: 10px 12px; border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.section .label { font-size: 13px; color: var(--text-2); margin-bottom: 10px; font-weight: 600; }

/* 分段控件 */
.seg { display: flex; background: #f0f1f3; border-radius: 10px; padding: 4px; gap: 4px; }
.seg button { flex: 1; padding: 9px; border-radius: 8px; background: transparent; color: var(--text-2); font-weight: 600; font-size: 14px; transition: .2s; }
.seg button.on { background: #fff; color: var(--primary); box-shadow: 0 1px 4px rgba(0,0,0,.08); }

/* 表单 */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.field input, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 14px;
  background: #fafafa;
  color: var(--text);
}
.field textarea { resize: none; height: 64px; }
.field input:focus, .field textarea:focus { border-color: var(--primary); background: #fff; }

/* 选项卡片(支付模式) */
.opt {
  display: flex; align-items: center; gap: 12px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  transition: .15s;
}
.opt.on { border-color: var(--primary); background: var(--primary-light); }
.opt .o-ico { font-size: 24px; }
.opt .o-main { flex: 1; }
.opt .o-title { font-weight: 600; }
.opt .o-desc { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.opt .o-check { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); flex-shrink: 0; }
.opt.on .o-check { border-color: var(--primary); background: var(--primary); position: relative; }
.opt.on .o-check::after { content: "✓"; color: #fff; font-size: 12px; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }

/* 明细行 */
.bill-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.bill-row:last-child { border-bottom: none; }
.bill-row .q { color: var(--text-3); font-size: 12px; }

/* 按钮 */
.btn {
  display: block; width: 100%;
  background: var(--primary);
  color: #fff;
  padding: 14px;
  border-radius: 24px;
  font-size: 16px; font-weight: 600;
  text-align: center;
  margin-top: 14px;
}
.btn.ghost { background: #fff; color: var(--primary); border: 1.5px solid var(--primary); }
.btn.warn { background: var(--warning); }
.btn.danger { background: var(--danger); }
.btn:disabled { background: #ccc; }

.scroll-area { flex: 1; overflow-y: auto; padding-bottom: 20px; }

/* ---------- 订单状态页 ---------- */
.order-hero { text-align: center; padding: 24px 16px 8px; }
.order-hero .ok-ico { font-size: 52px; }
.order-hero .title { font-size: 18px; font-weight: 700; margin-top: 8px; }
.order-hero .sub { color: var(--text-2); font-size: 13px; margin-top: 4px; }

.timeline { padding: 4px 0; }
.tl-item { display: flex; gap: 12px; padding: 8px 0; position: relative; }
.tl-item .tl-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--line); margin-top: 3px; flex-shrink: 0; }
.tl-item.done .tl-dot { background: var(--primary); }
.tl-item .tl-txt .t { font-size: 14px; font-weight: 600; }
.tl-item .tl-txt .s { font-size: 12px; color: var(--text-3); }
.tl-item:not(:last-child)::after { content: ""; position: absolute; left: 6px; top: 22px; bottom: -6px; width: 2px; background: var(--line); }
.tl-item.done:not(:last-child)::after { background: var(--primary); }

.pay-flag { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 12px; font-weight: 600; }
.pay-flag.later { background: #fff4e5; color: var(--warning); }
.pay-flag.paid { background: var(--primary-light); color: var(--primary-dark); }

/* ---------- 商家后台 ---------- */
.admin-stats { display: flex; gap: 8px; padding: 12px; }
.admin-stats .st { flex: 1; background: var(--card); border-radius: 10px; padding: 12px; text-align: center; box-shadow: var(--shadow); }
.admin-stats .st .n { font-size: 20px; font-weight: 700; color: var(--primary); }
.admin-stats .st .l { font-size: 12px; color: var(--text-2); margin-top: 2px; }

.order-card { background: var(--card); margin: 10px 12px; border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.order-card .oc-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.order-card .oc-no { font-weight: 700; font-size: 14px; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 8px; font-weight: 600; }
.tag.dine { background: var(--primary-light); color: var(--primary-dark); }
.tag.take { background: #e6f0ff; color: #2b6cff; }
.tag.p-later { background: #fff4e5; color: var(--warning); }
.tag.p-paid { background: #f0f9ff; color: #0a8bd6; }
.tag.s-wait { background: #fde8e8; color: var(--danger); }
.tag.s-cook { background: #fff4e5; color: var(--warning); }
.tag.s-done { background: #e8f8ef; color: var(--primary-dark); }

.order-card .oc-addr { font-size: 12px; color: var(--text-2); margin: 4px 0; }
.order-card .oc-items { font-size: 12px; color: var(--text-2); border-top: 1px dashed var(--line); border-bottom: 1px dashed var(--line); padding: 8px 0; margin: 8px 0; }
.order-card .oc-foot { display: flex; justify-content: space-between; align-items: center; }
.order-card .oc-total { color: var(--danger); font-weight: 700; font-size: 16px; }
.order-card .oc-actions { display: flex; gap: 8px; }
.order-card .oc-actions button { padding: 7px 14px; border-radius: 16px; font-size: 13px; font-weight: 600; }
.oc-actions .a-accept { background: var(--primary); color: #fff; }
.oc-actions .a-done { background: var(--primary-dark); color: #fff; }
.oc-actions .a-pay { background: var(--warning); color: #fff; }

.empty { text-align: center; color: var(--text-3); padding: 60px 20px; }
.empty .ico { font-size: 48px; }

.toast {
  position: fixed;
  bottom: 80px; left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,.82);
  color: #fff;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 13px;
  z-index: 100;
  opacity: 0;
  transition: opacity .25s;
  pointer-events: none;
}
.toast.show { opacity: 1; }

.pay-sheet { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 50; display: none; align-items: flex-end; }
.pay-sheet.show { display: flex; }
.pay-sheet .sheet { background: #fff; width: 100%; max-width: 480px; margin: 0 auto; border-radius: 16px 16px 0 0; padding: 20px 18px 28px; }
.pay-sheet .sheet .amt { font-size: 30px; font-weight: 700; text-align: center; color: var(--danger); margin: 6px 0 4px; }
.pay-sheet .sheet .amt small { font-size: 15px; }
.pay-sheet .methods .m { display: flex; align-items: center; gap: 10px; padding: 14px 4px; border-bottom: 1px solid var(--line); }
.pay-sheet .methods .m .mi { font-size: 22px; }
.pay-sheet .methods .m .mt { flex: 1; font-weight: 600; }
.pay-sheet .methods .m .mc { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); }
.pay-sheet .methods .m.on .mc { border-color: var(--primary); background: var(--primary); }

/* 扫码模拟入口 */
.scan-entry { text-align: center; padding: 40px 20px; }
.scan-entry .qr { font-size: 90px; }
.scan-entry .t { font-size: 16px; font-weight: 600; margin: 14px 0 6px; }
.scan-entry .d { color: var(--text-2); font-size: 13px; margin-bottom: 20px; }
.table-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.table-grid button { background: #fff; border: 1.5px solid var(--line); border-radius: 10px; padding: 12px 0; font-weight: 600; }
.table-grid button.on { border-color: var(--primary); background: var(--primary-light); color: var(--primary-dark); }
