:root {
  --bg: #faf6f1;
  --card: #ffffff;
  --ink: #3a2e28;
  --muted: #8b7d74;
  --brand: #c98b5e;
  --brand-dark: #a86b41;
  --brand-soft: #f3e3d3;
  --line: #ece3d9;
  --ok: #4caf7d;
  --warn: #e0a03c;
  --err: #d9604a;
  --dock-h: 68px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background: #efe7dd;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

/* ================= 小程序外壳（PC 居中限宽） ================= */
.app-shell {
  max-width: 720px;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 0 46px rgba(120, 85, 55, .16);
}

/* ================= 顶部 ================= */
.topbar {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 12px;
  background: linear-gradient(135deg, #fdf7f0, #f7ead9);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 12;
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  font-size: 34px;
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 4px 12px rgba(180, 130, 85, .18);
}
.brand h1 { margin: 0; font-size: 20px; letter-spacing: 1px; color: var(--brand-dark); }
.sub { margin: 3px 0 0; font-size: 12px; color: var(--muted); }

/* 店员面板默认折叠，不干扰点单主流程 */
.staff-panel { max-width: 46%; }
.staff-panel > summary {
  list-style: none;
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 7px 12px;
  white-space: nowrap;
  user-select: none;
}
.staff-panel > summary::-webkit-details-marker { display: none; }
.staff-panel[open] > summary { color: var(--brand-dark); border-color: var(--brand); }
.staff-panel[open] {
  max-width: none;
  position: absolute;
  top: 60px; right: 12px;
  z-index: 20;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  box-shadow: 0 14px 40px rgba(60, 40, 20, .22);
}
.staff-panel[open] > summary { margin-bottom: 10px; }

.status-bar { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
.status-card {
  display: flex; align-items: center; gap: 9px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 10px;
  min-width: 200px;
}
.staff-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.status-body { display: flex; flex-direction: column; line-height: 1.3; }
.status-label { font-size: 10px; color: var(--muted); letter-spacing: .5px; }
#printer-text, #label-text, #battery-text { font-size: 12px; color: var(--ink); }
.label-icon { font-size: 18px; }
#label-card.low #label-text { color: var(--err); font-weight: 700; }
#label-card.ok #label-text { color: var(--ok); }
#battery-card.low #battery-text { color: var(--err); font-weight: 700; }
#battery-card.ok #battery-text { color: var(--ok); }
#battery-card.charging #battery-text { color: #2e9bd6; }
.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 3px rgba(0,0,0,.04);
  flex-shrink: 0;
}
.dot.ok { background: var(--ok); }
.dot.busy { background: var(--warn); animation: pulse 1s infinite; }
.dot.err { background: var(--err); }
@keyframes pulse { 50% { opacity: .35; } }

/* ================= 左右分割主体 ================= */
.layout {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

/* 左侧：竖排分类栏 */
.category-bar {
  width: 92px;
  flex-shrink: 0;
  background: #f1e8dd;
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 8px 6px calc(var(--dock-h) + 90px);
  scrollbar-width: none;
}
.category-bar::-webkit-scrollbar { display: none; }
.cat-btn {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  line-height: 1.45;
  text-align: center;
  padding: 13px 4px;
  margin-bottom: 4px;
  border-radius: 10px;
  cursor: pointer;
  position: relative;
  transition: background .15s, color .15s;
  word-break: break-all;
}
.cat-btn.active {
  background: var(--card);
  color: var(--brand-dark);
  font-weight: 700;
  box-shadow: 0 3px 10px rgba(160, 120, 80, .1);
}
.cat-btn.active::before {
  content: "";
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 20px;
  border-radius: 0 3px 3px 0;
  background: var(--brand);
}

/* 右侧：商品列表 */
.menu {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 14px 12px calc(var(--dock-h) + 96px);
  scroll-behavior: smooth;
}
.group { margin-bottom: 18px; }
.group-title {
  font-size: 13px;
  color: var(--brand-dark);
  font-weight: 700;
  margin: 4px 2px 10px;
  padding-left: 8px;
  border-left: 4px solid var(--brand);
  scroll-margin-top: 8px;
}
.empty { color: var(--muted); font-size: 13px; text-align: center; padding: 40px 10px; }

.product {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 12px;
  margin-bottom: 11px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s;
  user-select: none;
}
.product:active { transform: scale(.985); }
.product:hover { border-color: var(--brand); box-shadow: 0 6px 16px rgba(160, 120, 80, .1); }
.p-info { flex: 1; min-width: 0; }
.product .name { font-size: 16px; font-weight: 700; margin-bottom: 5px; line-height: 1.3; }
.product .price { color: var(--brand-dark); font-weight: 700; font-size: 15px; }
.product .cat {
  display: inline-block;
  font-size: 10px;
  color: var(--muted);
  background: var(--bg);
  border-radius: 6px;
  padding: 2px 7px;
  margin-left: 6px;
  vertical-align: 1px;
}
.add-btn {
  width: 34px; height: 34px;
  flex-shrink: 0;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  font-size: 24px;
  line-height: 30px;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(168, 107, 65, .35);
  padding: 0;
}
.add-btn:active { transform: scale(.9); }

/* ================= 吸底购物车栏 ================= */
.cart-dock {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 720px;
  height: calc(var(--dock-h) + env(safe-area-inset-bottom, 0px));
  padding: 0 14px env(safe-area-inset-bottom, 0px);
  background: #fff;
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 20px rgba(90, 60, 35, .1);
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 30;
}
.cart-toggle {
  position: relative;
  width: 52px; height: 52px;
  margin-top: -16px;
  border: 4px solid #fff;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  box-shadow: 0 5px 14px rgba(168, 107, 65, .4);
  cursor: pointer;
  flex-shrink: 0;
}
.cart-emoji { font-size: 24px; line-height: 1; }
.cart-badge {
  position: absolute;
  top: -4px; right: -4px;
  min-width: 20px; height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--err);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  border: 2px solid #fff;
}
.cart-badge.zero { display: none; }
.cart-summary { flex: 1; display: flex; flex-direction: column; line-height: 1.25; }
.cart-summary span { font-size: 11px; color: var(--muted); }
.cart-summary strong { font-size: 21px; color: var(--brand-dark); }
.checkout {
  border: 0;
  border-radius: 24px;
  padding: 13px 26px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  cursor: pointer;
  transition: filter .15s;
}
.checkout:hover { filter: brightness(1.05); }
.checkout:disabled { opacity: .5; cursor: not-allowed; }

/* ================= 购物车抽屉 ================= */
.cart-mask {
  position: fixed; inset: 0;
  background: rgba(40, 28, 20, .4);
  z-index: 38;
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s;
}
.cart-mask.show { opacity: 1; visibility: visible; }
.cart-panel {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translate(-50%, 100%);
  width: 100%;
  max-width: 720px;
  max-height: 78dvh;
  background: var(--card);
  border-radius: 20px 20px 0 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -10px 40px rgba(60, 40, 20, .25);
  transition: transform .25s ease;
}
.cart-panel.show { transform: translate(-50%, 0); }
.cart-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.cart-panel-head strong { font-size: 15px; }
.cart-scroll { overflow-y: auto; padding: 14px 16px 24px; }

.cart-items { display: flex; flex-direction: column; gap: 10px; }
.cart-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: 10px;
}
.cart-item .t { font-weight: 700; font-size: 14px; }
.cart-item .s { font-size: 12px; color: var(--muted); grid-column: 1; }
.qty { display: flex; align-items: center; gap: 6px; }
.qty button {
  width: 24px; height: 24px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
.qty span { min-width: 16px; text-align: center; font-size: 13px; }

.note-label { display: block; margin: 14px 0 6px; font-size: 12px; color: var(--muted); }
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
  background: #fff;
  color: var(--ink);
}

.recent { margin-top: 18px; border-top: 1px dashed var(--line); padding-top: 12px; }
.recent h3 { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.recent-item { display: flex; justify-content: space-between; align-items: center; font-size: 12px; padding: 6px 0; border-bottom: 1px solid var(--bg); }
.recent-item .no { font-weight: 700; }
.recent-item .st { color: var(--muted); }
.recent-item .st.failed { color: var(--err); }
.recent-item a { color: var(--brand-dark); text-decoration: none; font-size: 11px; margin-left: 6px; }
.recent-item a.reprint { color: var(--brand); font-weight: 700; }
.recent-order { border-bottom: 1px solid var(--bg); padding: 8px 0; }
.ro-head { display: flex; justify-content: space-between; align-items: center; }
.ro-head .no { font-weight: 700; font-size: 14px; color: var(--brand-dark); }
.ro-head .st { font-size: 11px; color: var(--muted); }
.ro-head .st.failed { color: var(--err); }
.ro-head .st.pending { color: var(--warn); font-weight: 700; }
.ro-drinks { font-size: 12px; color: var(--ink); margin: 4px 0; line-height: 1.5; }
.ro-drinks b { color: var(--brand); margin-right: 2px; }
.ro-drinks .spec { color: var(--muted); font-size: 11px; margin-left: 6px; }
.ro-ops a { color: var(--brand-dark); text-decoration: none; font-size: 11px; margin-right: 10px; }
.ro-ops a.call-btn { display: inline-block; background: var(--brand); color: #fff; padding: 4px 10px; border-radius: 8px; font-weight: 700; }
.ro-ops a.call-btn:hover { background: var(--brand-dark); }
.ro-ops a.call-btn.calling { background: var(--ok); }
.ro-ops a.mark-printed { color: #fff; background: var(--ok); padding: 4px 10px; border-radius: 8px; font-weight: 700; }

/* ================= 通用按钮 ================= */
button.ghost {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}
button.ghost:hover { border-color: var(--brand); color: var(--brand-dark); }

button.primary {
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 14px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  cursor: pointer;
  transition: filter .15s;
}
button.primary:hover { filter: brightness(1.05); }
button.primary:disabled { opacity: .55; cursor: not-allowed; }

/* 通用提示文字（管理面板里的 #manage-hint 等沿用） */
.hint { font-size: 12px; color: var(--muted); min-height: 18px; margin: 10px 0 0; }
.hint.err { color: var(--err); }
.hint.ok { color: var(--ok); }

/* 吸底轻提示浮层（只作用于全局 #hint） */
#hint {
  position: fixed;
  left: 50%;
  bottom: calc(var(--dock-h) + 20px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 12px);
  max-width: 88vw;
  width: max-content;
  background: rgba(58, 46, 40, .92);
  color: #fff;
  font-size: 12px;
  padding: 9px 16px;
  margin: 0;
  border-radius: 20px;
  z-index: 55;
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s, transform .2s;
  text-align: center;
  box-shadow: 0 6px 20px rgba(40, 28, 20, .3);
}
#hint.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
#hint.err { background: var(--err); color: #fff; }
#hint.ok { background: var(--ok); color: #fff; }

/* ================= 弹窗 ================= */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(40, 28, 20, .45);
  display: flex; align-items: center; justify-content: center;
  z-index: 60;
  backdrop-filter: blur(2px);
}
.modal-mask[hidden] { display: none; }
.modal {
  width: min(420px, 92vw);
  background: var(--card);
  border-radius: 18px;
  padding: 22px;
  box-shadow: 0 20px 60px rgba(60, 40, 20, .25);
  max-height: 90vh;
  overflow-y: auto;
}
.modal h3 { margin: 0 0 18px; font-size: 18px; }
.opt-group { margin-bottom: 16px; border: 0; padding: 0; min-width: 0; }
.opt-group > label, .opt-group legend { display: block; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 20px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  transition: all .12s;
}
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .ghost { flex: 1; padding: 12px; font-size: 14px; }
.modal-actions .primary { flex: 2; }
.group-checks { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 0; }
.group-checks label { display: flex; flex-direction: row; align-items: center; gap: 5px; padding: 5px 7px; border: 1px solid var(--line); border-radius: 6px; }
.group-checks input[type=checkbox], .manage-table tr.editing input[type=checkbox] { width: auto; min-width: 0; }

/* ================= 商品管理面板 ================= */
.modal-wide { width: min(860px, 95vw); max-height: 90vh; overflow: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h3 { margin: 0; }
.quick-add { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--bg); }
.quick-title { font-weight: 700; font-size: 14px; color: var(--brand-dark); margin-bottom: 4px; }
.quick-title small { font-weight: 400; color: var(--muted); margin-left: 8px; }
.quick-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 10px; }
.quick-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.quick-grid input, .quick-grid select { border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; font-family: inherit; font-size: 13px; background: #fff; color: var(--ink); }
.inline-options-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 14px 0 6px; }
.inline-options-head strong { font-size: 13px; color: var(--brand-dark); }
.inline-options-head small { flex: 1; min-width: 200px; font-size: 11px; color: var(--muted); }
#opt-list { display: flex; flex-direction: column; gap: 8px; }
.opt-row { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; }
.opt-row-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.opt-row-head .opt-name { flex: 1; border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; font-family: inherit; font-size: 13px; min-width: 0; }
.opt-multi { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.opt-labels { width: 100%; box-sizing: border-box; border: 1px dashed var(--line); border-radius: 6px; padding: 7px 9px; font-family: inherit; font-size: 12px; color: var(--ink); }
.opt-del { color: var(--err); }
.advanced-box { border: 1px dashed var(--line); border-radius: 10px; margin-top: 12px; padding: 8px 12px; }
.advanced-box > summary { cursor: pointer; font-size: 12px; color: var(--muted); }
.advanced-box > summary small { color: #b0a49a; }
.advanced-body { padding-top: 10px; }
.add-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 12px; }
.add-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.add-grid label.full { grid-column: 1 / -1; }
.add-grid input { border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; font-family: inherit; font-size: 13px; background: #fff; color: var(--ink); }
.add-actions { display: flex; gap: 10px; margin-top: 12px; }
.add-actions .primary { flex: 1; }
.add-actions .ghost { padding: 10px 18px; }
.manage-table-wrap { overflow-x: auto; margin-top: 8px; }
.manage-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.manage-table th { text-align: left; padding: 8px 10px; color: var(--muted); font-size: 11px; font-weight: 600; border-bottom: 2px solid var(--line); white-space: nowrap; }
.manage-table td { padding: 9px 10px; border-bottom: 1px solid var(--bg); vertical-align: middle; }
.manage-table tr.off td { opacity: .5; }
.c-name { font-weight: 700; }
.c-price { color: var(--brand-dark); font-weight: 700; white-space: nowrap; }
.c-cat { color: var(--muted); }
.c-opts { font-size: 11px; line-height: 1.6; }
.opt-line .k { display: inline-block; min-width: 28px; color: var(--muted); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 11px; white-space: nowrap; }
.pill.on { background: #e6f4ec; color: var(--ok); }
.pill.off { background: #f0ece8; color: var(--muted); }
.c-ops { white-space: nowrap; }
button.mini { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 4px 9px; font-size: 12px; color: var(--ink); cursor: pointer; margin-right: 4px; }
button.mini:hover { border-color: var(--brand); color: var(--brand-dark); }
button.mini.danger:hover { border-color: var(--err); color: var(--err); }
button.mini.primary-mini { background: var(--brand); color: #fff; border-color: var(--brand); }
.manage-table tr.editing { background: #fffaf5; }
.manage-table tr.editing input { width: 100%; min-width: 60px; border: 1px solid var(--brand); border-radius: 6px; padding: 5px 7px; font-family: inherit; font-size: 12px; background: #fff; color: var(--ink); }
.manage-table tr.editing td:nth-child(4) input { margin-bottom: 4px; }
.group-library-head { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; }
.library-row { display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--line); padding: 9px 0; }
.library-row span { flex: 1; font-size: 12px; overflow-wrap: anywhere; }
.add-grid select, .pack-price input, .cart-pack select { border: 1px solid var(--line); padding: 8px; border-radius: 7px; font-family: inherit; color: var(--ink); background: white; min-width: 0; }
.pack-price { display: flex; align-items: center; gap: 8px; font-size: 12px; margin-top: 12px; }
.pack-price input { width: 75px; }
.cart-pack { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.cart-pack select { flex: 1; }
button:disabled { cursor: wait; opacity: .55; }

@media (max-width: 600px) {
  .add-grid, .quick-grid { grid-template-columns: 1fr; }
  .modal-wide { padding: 14px; }
  .library-row { flex-wrap: wrap; }
  .manage-table { min-width: 620px; }
  .staff-panel > summary { font-size: 11px; padding: 6px 9px; }
  .staff-panel[open] { left: 12px; right: 12px; }
}
