:root {
  --primary: #ff5a36;
  --primary-dark: #e8431f;
  --accent: #ffb347;
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #222;
  --muted: #8a8f99;
  --line: #ececf0;
  --green: #2bb673;
  --blue: #2f80ed;
  --orange: #f2994a;
  --red: #eb5757;
  --shadow: 0 4px 18px rgba(0, 0, 0, 0.06);
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
button { font-family: inherit; cursor: pointer; }
a { color: inherit; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow);
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 700; }
.topbar .sub { font-size: 12px; opacity: .9; }
.topbar .right { display: flex; align-items: center; gap: 12px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #ffd2c2; display: inline-block; }
.status-dot.on { background: #b6ffce; }

/* ---------- category nav (顾客端：左侧竖排) ---------- */
.layout { display: flex; align-items: flex-start; }
.catnav {
  position: sticky; top: 56px; z-index: 40;
  flex: 0 0 88px; align-self: flex-start;
  display: flex; flex-direction: column; gap: 8px;
  height: calc(100vh - 56px); overflow-y: auto;
  padding: 12px 8px; background: var(--card);
  border-right: 1px solid var(--line);
  scrollbar-width: none;
}
.catnav::-webkit-scrollbar { display: none; }
.catnav button {
  border: none; background: var(--bg); color: var(--muted);
  padding: 10px 4px; border-radius: 12px; font-size: 13px; line-height: 1.35;
  text-align: center; white-space: normal; word-break: break-word;
  transition: .15s;
}
.catnav button.active { background: var(--primary); color: #fff; font-weight: 600; }

/* ---------- dish list ---------- */
.section-title { padding: 16px 16px 8px; font-weight: 700; font-size: 15px; color: var(--text); }
.dish {
  display: flex; gap: 12px; padding: 14px 16px; background: var(--card);
  border-bottom: 1px solid var(--line); align-items: center;
}
.dish .thumb {
  width: 60px; height: 60px; border-radius: 12px; flex: 0 0 60px;
  background: linear-gradient(135deg, #ffd9c9, #ffe9b0);
  display: flex; align-items: center; justify-content: center; font-size: 26px; overflow: hidden;
}
.dish .thumb img { width: 100%; height: 100%; object-fit: cover; }
.dish .info { flex: 1; min-width: 0; }
.dish .name { font-weight: 600; font-size: 16px; }
.dish .desc { color: var(--muted); font-size: 12px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dish .price { color: var(--primary); font-weight: 700; margin-top: 4px; }
.dish .price small { color: var(--muted); font-weight: 400; }
.dish.unavailable { opacity: .5; }
.dish.unavailable .add { display: none; }

/* stepper */
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button {
  width: 30px; height: 30px; border-radius: 50%; border: none; font-size: 18px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.stepper .minus { background: var(--bg); color: var(--primary); border: 1px solid var(--line); }
.stepper .plus { background: var(--primary); color: #fff; }
.stepper .qty { min-width: 18px; text-align: center; font-weight: 600; }
.add {
  background: var(--primary); color: #fff; border: none; border-radius: 20px;
  padding: 8px 16px; font-size: 14px; font-weight: 600;
}

/* ---------- cart bar ---------- */
.cartbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: #2b2b33; color: #fff; display: flex; align-items: center;
  padding: 10px 16px; gap: 12px;
}
.cartbar .icon { position: relative; font-size: 26px; }
.cartbar .badge {
  position: absolute; top: -6px; right: -10px; background: var(--primary);
  color: #fff; font-size: 11px; min-width: 18px; height: 18px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center; padding: 0 5px;
}
.cartbar .total { flex: 1; }
.cartbar .total b { font-size: 20px; }
.cartbar .total small { display: block; color: #b9b9c2; font-size: 12px; }
.cartbar .checkout {
  background: var(--primary); color: #fff; border: none; border-radius: 24px;
  padding: 12px 26px; font-size: 15px; font-weight: 700;
}
.cartbar.hidden { display: none; }

/* ---------- modal ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 100;
  display: none; align-items: flex-end; justify-content: center;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; width: 100%; max-width: 520px; border-radius: 18px 18px 0 0;
  max-height: 86vh; overflow-y: auto; padding: 18px; animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform: translateY(40px); opacity:.6 } to { transform: translateY(0); opacity:1 } }
.modal h3 { margin: 0 0 14px; font-size: 17px; }
.modal .row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.modal .row .nm { flex: 1; }
.modal .row .qt { color: var(--muted); margin: 0 12px; }
.modal .row .pr { font-weight: 600; }
.modal .field { margin: 14px 0; }
.modal label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.modal input, .modal select, .modal textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 15px; font-family: inherit;
}
.modal .actions { display: flex; gap: 10px; margin-top: 16px; }
.btn { flex: 1; padding: 13px; border-radius: 12px; border: none; font-size: 15px; font-weight: 700; }
.btn-ghost { background: var(--bg); color: var(--text); }
.btn-primary { background: var(--primary); color: #fff; }
.modal .grand { display: flex; justify-content: space-between; font-size: 17px; font-weight: 700; margin-top: 12px; }
.modal .grand b { color: var(--primary); }

.success { text-align: center; padding: 20px 0; }
.success .ok { font-size: 54px; }
.success h3 { margin: 10px 0 4px; }
.success p { color: var(--muted); }

/* ---------- merchant layout ---------- */
.tabs { display: flex; background: var(--card); position: sticky; top: 56px; z-index: 40; border-bottom: 1px solid var(--line); }
.tabs button {
  flex: 1; border: none; background: none; padding: 13px 4px; font-size: 14px; color: var(--muted);
  border-bottom: 3px solid transparent; font-weight: 600;
}
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.page { display: none; padding: 14px; max-width: 920px; margin: 0 auto; }
.page.active { display: block; }

/* order cards */
.order {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; margin-bottom: 12px; border-left: 5px solid var(--muted);
}
.order.pending { border-left-color: var(--orange); }
.order.preparing { border-left-color: var(--blue); }
.order.completed { border-left-color: var(--green); }
.order.cancelled { border-left-color: var(--red); opacity: .65; }
.order .head { display: flex; justify-content: space-between; align-items: center; }
.order .table { font-weight: 700; font-size: 16px; }
.order .time { color: var(--muted); font-size: 12px; }
.order .items { margin: 8px 0; }
.order .items div { display: flex; justify-content: space-between; font-size: 14px; padding: 2px 0; }
.order .items .oitem { justify-content: flex-start; align-items: center; gap: 8px; }
.order .items .oitem .nm { flex: 1; min-width: 0; }
.order .items .oitem .qt { color: var(--muted); margin: 0 2px; }
.order .items .oitem .pr { font-weight: 600; margin-right: 4px; }
.order .items .oitem .nm .rt { font-style: normal; font-size: 11px; color: var(--red); background: #ffeaea; border-radius: 6px; padding: 0 5px; margin-left: 4px; white-space: nowrap; }
.item-refund { border: 1px solid var(--red); background: #fff; color: var(--red); border-radius: 7px; padding: 3px 9px; font-size: 12px; font-weight: 600; }
.item-refund:hover { background: var(--red); color: #fff; }
.refunded-tag { font-size: 11px; color: var(--red); }
.order .foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.order .amt { font-size: 18px; font-weight: 700; color: var(--primary); }
.badge-status { font-size: 12px; padding: 3px 10px; border-radius: 12px; color: #fff; }
.badge-status.pending { background: var(--orange); }
.badge-status.preparing { background: var(--blue); }
.badge-status.completed { background: var(--green); }
.badge-status.cancelled { background: var(--red); }
.order .ops { display: flex; gap: 8px; margin-top: 10px; }
.order .ops button { flex: 1; padding: 9px; border-radius: 9px; border: none; font-weight: 600; font-size: 14px; }
.op-ok { background: var(--green); color: #fff; }
.op-prep { background: var(--blue); color: #fff; }
.op-cancel { background: var(--bg); color: var(--red); border: 1px solid var(--line); }
.flash { animation: flash 1s ease; }
@keyframes flash { 0% { background: #fff6e9; } 100% { background: var(--card); } }

/* menu manage */
.toolbar { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar input, .toolbar select { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; }
.toolbar .grow { flex: 1; min-width: 120px; }
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.cat-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.cat-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 5px 6px 5px 12px; font-size: 13px; box-shadow: var(--shadow); }
.cat-chip .ct { font-weight: 600; }
.cat-chip .cn { font-size: 11px; color: var(--muted); background: var(--bg); border-radius: 999px; padding: 1px 7px; }
.cat-chip .cat-del { border: none; background: transparent; color: var(--muted); font-size: 16px; line-height: 1; cursor: pointer; padding: 0 4px; border-radius: 999px; }
.cat-chip .cat-del:hover { color: #fff; background: var(--red); }
.mcard { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.mcard.pinned { border-left: 4px solid var(--accent); }
.mcard .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.pin-tag { display: inline-block; background: var(--accent); color: #5a3b00; font-size: 11px; font-weight: 700; border-radius: 6px; padding: 1px 6px; margin-left: 4px; vertical-align: middle; }
.mcard .mini.pin-on { background: var(--accent); color: #5a3b00; border-color: var(--accent); }
.cat-move { border: none; background: var(--bg); color: var(--muted); font-size: 11px; line-height: 1; cursor: pointer; padding: 3px 5px; border-radius: 6px; }
.cat-move:hover:not(:disabled) { color: var(--primary); background: #ffe9e1; }
.cat-move:disabled { opacity: .3; cursor: not-allowed; }
.mcard .nm { font-weight: 700; font-size: 16px; }
.mcard .cat { font-size: 12px; color: var(--muted); }
.mcard .desc { font-size: 12px; color: var(--muted); margin: 6px 0; min-height: 16px; }
.mcard .price-edit { display: flex; align-items: center; gap: 6px; margin: 8px 0; }
.mcard .price-edit input { width: 90px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; }
.mcard .ops { display: flex; gap: 8px; align-items: center; }
.switch { position: relative; width: 42px; height: 24px; }
.switch input { display: none; }
.switch .slider { position: absolute; inset: 0; background: #ccc; border-radius: 24px; transition: .2s; }
.switch input:checked + .slider { background: var(--green); }
.switch .slider::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider::before { transform: translateX(18px); }
.mini { border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 6px 10px; font-size: 13px; }
.mini.danger { color: var(--red); }

/* analytics */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.kpi .v { font-size: 24px; font-weight: 800; color: var(--primary); }
.kpi .l { font-size: 13px; color: var(--muted); margin-top: 4px; }
.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.panel h4 { margin: 0 0 12px; font-size: 15px; }
.range-sel { display: flex; gap: 8px; margin-bottom: 12px; }
.range-sel button { border: 1px solid var(--line); background: var(--bg); border-radius: 20px; padding: 7px 18px; font-size: 14px; color: var(--muted); }
.range-sel button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.chart-box { position: relative; height: 260px; }
.tdlist { list-style: none; padding: 0; margin: 0; }
.tdlist li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.tdlist .bar { flex: 1; height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.tdlist .bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); }
.tdlist .nm { width: 90px; font-size: 14px; }
.tdlist .vl { width: 64px; text-align: right; font-size: 13px; color: var(--muted); }

/* 自动打印开关 */
.auto-print { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); white-space: nowrap; cursor: pointer; }

/* 小票（打印专用） */
.receipt { display: none; }
.receipt .r-shop { font-size: 18px; font-weight: 800; text-align: center; }
.receipt .r-sub { text-align: center; font-size: 13px; color: #555; margin-bottom: 6px; }
.receipt .r-meta { display: flex; justify-content: space-between; font-size: 13px; }
.receipt .r-time { font-size: 12px; color: #555; margin: 2px 0 6px; }
.receipt .r-line { border-top: 1px dashed #000; margin: 6px 0; }
.receipt .r-head, .receipt .r-row { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.receipt .r-head { font-weight: 700; border-bottom: 1px solid #000; padding-bottom: 3px; margin-bottom: 4px; }
.receipt .r-name { flex: 1; }
.receipt .r-q { width: 84px; text-align: right; }
.receipt .r-amt { width: 60px; text-align: right; }
.receipt .r-total { display: flex; justify-content: space-between; font-weight: 800; font-size: 15px; margin-top: 6px; }
.receipt .r-foot { text-align: center; font-size: 12px; color: #555; margin-top: 10px; }

@media print {
  body * { visibility: hidden !important; }
  #receipt, #receipt * { visibility: visible !important; }
  #receipt {
    display: block !important;
    position: absolute; left: 0; top: 0; width: 72mm;
    padding: 0; margin: 0; background: #fff; color: #000;
    font-family: "Courier New", "Microsoft YaHei", monospace;
  }
}

/* 编辑菜品弹窗（独立类，避免覆盖通用 .modal-mask 的默认 display:none） */
.edit-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; z-index: 60; padding: 16px;
}
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 360px;
  padding: 20px 22px; box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
.modal h3 { margin: 0 0 14px; font-size: 17px; }
.modal .fld { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.modal .fld input, .modal .fld select { padding: 9px 10px; border: 1px solid #ddd; border-radius: 8px; font-size: 14px; color: #222; background: #fff; }
.modal .fld.row { flex-direction: row; align-items: center; gap: 8px; color: #222; }
.modal .fld.row input { width: 16px; height: 16px; }
.modal-ops { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }

/* qr */
.qrbox { text-align: center; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px; }
.qrbox img { width: 280px; height: 280px; border: 1px solid var(--line); border-radius: 12px; }
.qrbox .url { margin-top: 14px; font-size: 14px; color: var(--muted); word-break: break-all; }
.qrbox .tip { margin-top: 6px; font-size: 12px; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.container { flex: 1; min-width: 0; max-width: 720px; margin: 0 auto; padding-bottom: 90px; }
.mtop { padding-top: 8px; }

/* ---------- 菜品图片上传 ---------- */
.file-btn { display: inline-flex; align-items: center; gap: 4px; padding: 8px 12px; border: 1px solid var(--bd); border-radius: 8px; font-size: 13px; color: var(--muted); cursor: pointer; flex: 0 0 auto; }
.file-btn input[type=file] { display: none; }
.img-prev { margin: 6px 0; display: inline-flex; align-items: center; gap: 8px; }
.img-prev img { width: 80px; height: 80px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.img-x { border: none; background: var(--red); color: #fff; width: 22px; height: 22px; border-radius: 50%; font-size: 14px; line-height: 1; cursor: pointer; }
