* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #14121a;
  --card: #1f1c29;
  --card2: #2a2636;
  --accent: #e8b04b;
  --accent2: #c9892f;
  --text: #f3f0ea;
  --muted: #9b95a8;
  --green: #4caf72;
  --red: #d9534f;
  --line: #322d3f;
}
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
button { font-family: inherit; cursor: pointer; border: none; }

/* ============ 顾客页 ============ */
.customer { padding-bottom: 90px; max-width: 640px; margin: 0 auto; }
.c-header {
  text-align: center; padding: 22px 16px 16px;
  background: linear-gradient(135deg, #2a2233, #14121a);
}
.c-header h1 { font-size: 28px; color: var(--accent); }
.c-header p { color: var(--muted); margin-top: 4px; font-size: 14px; }

.seat-bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--line);
}
.seat-bar label { font-size: 14px; white-space: nowrap; color: var(--muted); }
.seat-bar input {
  flex: 1; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card2); color: var(--text);
  font-size: 16px;
}
.seat-bar input:focus { outline: none; border-color: var(--accent); }
.seat-bar.locked input { background: #241f15; border-color: var(--accent); color: var(--accent); font-weight: 700; }

.menu { padding: 8px 16px; }
.cat-title {
  font-size: 16px; color: var(--accent); margin: 18px 0 8px;
  padding-bottom: 6px; border-bottom: 1px solid var(--line);
}
.item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.item-name { font-size: 16px; font-weight: 600; }
.item-desc { font-size: 13px; color: var(--muted); margin-top: 3px; }
.item-price { font-size: 15px; color: var(--accent); margin-top: 4px; }

.qty-ctrl { display: flex; align-items: center; gap: 12px; }
.qty-ctrl.small { gap: 8px; }
.qty-btn {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--card2); color: var(--text); font-size: 20px; line-height: 1;
  border: 1px solid var(--line);
}
.qty-btn.plus { background: var(--accent); color: #1a1620; border-color: var(--accent); }
.qty-num { min-width: 18px; text-align: center; font-size: 16px; }

.cart-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  max-width: 640px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--card); border-top: 1px solid var(--line);
}
.cart-summary { font-size: 16px; }
.cart-summary #cartTotal, .cart-summary #cartCount { color: var(--accent); font-weight: 700; }

.btn-primary {
  background: var(--accent); color: #1a1620; font-weight: 700;
  padding: 11px 20px; border-radius: 10px; font-size: 15px;
}
.btn-primary:active { background: var(--accent2); }
.btn-primary.big { width: 100%; padding: 14px; font-size: 16px; }
.btn-primary:disabled { opacity: 0.6; }

/* 弹层 */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-content {
  background: var(--card); width: 100%; max-width: 640px;
  border-radius: 18px 18px 0 0; padding: 18px 18px 24px;
  max-height: 85vh; overflow-y: auto;
}
.modal-content.center { text-align: center; border-radius: 18px; margin: auto 16px; align-self: center; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head h2 { font-size: 18px; }
.icon-btn { background: none; color: var(--muted); font-size: 20px; }

.cart-items { margin-bottom: 12px; }
.cart-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
#note {
  width: 100%; min-height: 60px; padding: 10px; border-radius: 10px;
  background: var(--card2); border: 1px solid var(--line); color: var(--text);
  font-size: 14px; font-family: inherit; resize: vertical; margin-bottom: 14px;
}
#note:focus { outline: none; border-color: var(--accent); }
.modal-foot .total-line { font-size: 16px; margin-bottom: 12px; text-align: right; }
.modal-foot .total-line strong { color: var(--accent); font-size: 20px; }

.success-icon {
  width: 64px; height: 64px; border-radius: 50%; background: var(--green);
  color: #fff; font-size: 36px; line-height: 64px; margin: 8px auto 14px;
}
.order-no { color: var(--accent); font-weight: 700; margin: 8px 0; }
.success-modal-content p { margin: 6px 0; }
#successModal .btn-primary { margin-top: 18px; }

/* ============ 商家后台 ============ */
.admin { max-width: 1100px; margin: 0 auto; padding: 0 0 40px; }
.a-header {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px;
  padding: 16px 20px; background: var(--card); border-bottom: 1px solid var(--line);
}
.a-header h1 { font-size: 22px; color: var(--accent); }
.a-controls { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.switch-label { font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 6px; cursor: pointer; }
.switch-label input { width: 16px; height: 16px; accent-color: var(--accent); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); display: inline-block; opacity: 0.5; transition: opacity .2s; }
.dot.blink { opacity: 1; box-shadow: 0 0 8px var(--green); }

.tabs { display: flex; gap: 8px; padding: 14px 20px 0; }
.tab {
  background: var(--card2); color: var(--muted); padding: 9px 16px;
  border-radius: 10px 10px 0 0; font-size: 14px;
}
.tab.active { background: var(--card); color: var(--accent); font-weight: 700; }
.badge {
  background: var(--red); color: #fff; border-radius: 10px;
  padding: 1px 7px; font-size: 12px; margin-left: 4px;
}

.orders {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px; padding: 16px 20px;
}
.empty { grid-column: 1/-1; text-align: center; color: var(--muted); padding: 60px 0; }

.order-card {
  position: relative; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px; border-left: 4px solid var(--accent);
}
.order-card.done { border-left-color: var(--green); opacity: 0.7; }
.o-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.o-seat { font-size: 18px; font-weight: 800; color: var(--accent); }
.o-no { font-size: 12px; color: var(--muted); margin-left: 8px; }
.o-time { font-size: 12px; color: var(--muted); }
.o-items { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 8px 0; }
.o-item { display: flex; justify-content: space-between; font-size: 14px; padding: 3px 0; }
.o-note { font-size: 13px; color: var(--accent); margin-top: 8px; }
.o-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; flex-wrap: wrap; gap: 8px; }
.o-total { font-size: 16px; font-weight: 700; }
.o-actions { display: flex; gap: 6px; }
.btn-ghost { background: var(--card2); color: var(--text); padding: 7px 11px; border-radius: 8px; font-size: 13px; border: 1px solid var(--line); }
.btn-danger { background: transparent; color: var(--red); padding: 7px 11px; border-radius: 8px; font-size: 13px; border: 1px solid var(--red); }
.order-card .btn-primary { padding: 7px 12px; font-size: 13px; }
.printed-flag { position: absolute; top: 10px; right: 12px; font-size: 11px; color: var(--green); }

/* 主导航 */
.main-nav { display: flex; gap: 8px; padding: 14px 20px 0; flex-wrap: wrap; }
.nav-btn {
  background: var(--card2); color: var(--muted); padding: 10px 18px;
  border-radius: 10px; font-size: 15px; border: 1px solid var(--line);
}
.nav-btn.active { background: var(--accent); color: #1a1620; font-weight: 700; border-color: var(--accent); }
.nav-tip { padding: 0 20px; font-size: 13px; line-height: 1.6; }

/* 桌台二维码 */
.table-add { display: flex; gap: 10px; padding: 16px 20px 4px; flex-wrap: wrap; }
.table-add input {
  flex: 1; min-width: 180px; padding: 10px 12px; border-radius: 10px;
  background: var(--card2); border: 1px solid var(--line); color: var(--text); font-size: 15px;
}
.table-add input:focus { outline: none; border-color: var(--accent); }
.qr-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px; padding: 16px 20px;
}
.qr-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; text-align: center;
}
.qr-name { font-size: 18px; font-weight: 800; color: var(--accent); margin-bottom: 10px; }
.qr-img { width: 100%; max-width: 150px; background: #fff; border-radius: 8px; padding: 6px; }
.qr-actions { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }
.qr-actions .btn-ghost { text-decoration: none; }

/* 营业额统计 */
.stat-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px; padding: 18px 20px;
}
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.stat-label { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.stat-val { font-size: 26px; font-weight: 800; }
.stat-val.accent { color: var(--accent); }
.stat-h { padding: 6px 20px; font-size: 16px; color: var(--accent); margin-top: 8px; }

.chart7 {
  display: flex; align-items: flex-end; gap: 10px; height: 200px;
  padding: 16px 20px; margin: 0 4px;
}
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar-val { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.bar {
  width: 70%; max-width: 46px; background: linear-gradient(180deg, var(--accent), var(--accent2));
  border-radius: 6px 6px 0 0; min-height: 2px; transition: height .3s;
}
.bar-label { font-size: 11px; color: var(--muted); margin-top: 6px; }

.top-items { padding: 8px 20px 30px; }
.top-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.rank {
  width: 24px; height: 24px; line-height: 24px; text-align: center; border-radius: 50%;
  background: var(--card2); font-size: 13px; flex-shrink: 0;
}
.rank.top3 { background: var(--accent); color: #1a1620; font-weight: 700; }
.top-name { width: 150px; font-size: 14px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-bar-wrap { flex: 1; background: var(--card2); border-radius: 6px; height: 10px; overflow: hidden; }
.top-bar { height: 100%; background: var(--accent); border-radius: 6px; }
.top-qty { width: 44px; text-align: right; font-size: 13px; color: var(--muted); }
.top-rev { width: 70px; text-align: right; font-size: 14px; font-weight: 600; color: var(--accent); }

/* ============ 打印小票 ============ */
.print-area { display: none; }

@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { display: block; position: absolute; top: 0; left: 0; width: 100%; }
  .receipt {
    width: 280px; margin: 0 auto; color: #000; font-family: "Courier New", monospace;
    padding: 8px;
  }
  .receipt h2 { text-align: center; font-size: 18px; }
  .r-sub { text-align: center; font-size: 12px; margin-bottom: 6px; }
  .receipt hr { border: none; border-top: 1px dashed #000; margin: 6px 0; }
  .r-row { display: flex; justify-content: space-between; font-size: 13px; padding: 2px 0; }
  .r-row.big { font-size: 16px; }
  .r-row.big strong { font-size: 20px; }
  .r-row.total strong { font-size: 16px; }
  .r-table { width: 100%; border-collapse: collapse; font-size: 13px; }
  .r-table th, .r-table td { text-align: left; padding: 2px 0; }
  .r-table .c { text-align: center; }
  .r-table .r { text-align: right; }
  .r-note { font-size: 12px; margin-top: 6px; }
  .r-foot { text-align: center; font-size: 12px; margin-top: 10px; }

  /* 桌台二维码打印：每张一页桌卡，可裁剪摆台 */
  .qr-print { color: #000; }
  .qr-print-card {
    page-break-after: always; text-align: center;
    border: 2px dashed #999; border-radius: 12px;
    padding: 30px; margin: 20px auto; width: 320px;
  }
  .qr-print-card:last-child { page-break-after: auto; }
  .qr-print-name { font-size: 30px; font-weight: 800; margin-bottom: 14px; }
  .qr-print-card img { width: 240px; height: 240px; }
  .qr-print-tip { font-size: 16px; margin-top: 12px; }
}
