:root {
  --brand: #185FA5;
  --brand-weak: #E6F1FB;
  --brand-soft: #B5D4F4;
  --ok: #0F6E56;
  --ok-weak: #E1F5EE;
  --err: #A32D2D;
  --err-weak: #FCEBEB;
  --warn: #854F0B;
  --warn-weak: #FAEEDA;
  --text: #1c1c1a;
  --muted: #5F5E5A;
  --line: rgba(0, 0, 0, 0.10);
  --bg: #F4F4F1;
  --card: #ffffff;
  --radius: 16px;
  --radius-lg: 24px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.10);
  --font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

body { display: flex; flex-direction: column; }

button { font-family: inherit; touch-action: manipulation; }

/* ---------- 顶栏 ---------- */
.topbar {
  flex: 0 0 auto;
  height: 72px;
  padding: 0 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--brand); color: #fff;
  display: grid; place-items: center;
  font-size: 22px; font-weight: 600;
}
.store-name { font-size: 22px; font-weight: 600; letter-spacing: .5px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.scan-state {
  font-size: 14px; color: var(--muted);
  padding: 6px 14px; border-radius: 999px; background: var(--bg);
}
.scan-state.ok { background: var(--ok-weak); color: var(--ok); }
.scan-state.bad { background: var(--err-weak); color: var(--err); }

/* ---------- 布局 ---------- */
.layout {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 18px;
  padding: 18px;
}

.cart-panel, .side-panel {
  background: var(--card);
  border-radius: var(--radius-lg);
  display: flex; flex-direction: column;
  min-height: 0;
  box-shadow: 0 2px 10px rgba(0,0,0,.04);
}
.side-panel { padding: 18px; gap: 14px; }

.panel-head {
  flex: 0 0 auto;
  padding: 18px 22px 12px;
  display: flex; align-items: center; justify-content: space-between;
}
.panel-head h2 { margin: 0; font-size: 20px; font-weight: 600; }
.badge {
  background: var(--brand-weak); color: var(--brand);
  padding: 4px 12px; border-radius: 999px; font-size: 14px;
}

.cart-scroll { flex: 1 1 auto; overflow-y: auto; padding: 0 18px 18px; }

.empty-state {
  height: 100%; min-height: 260px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--muted); gap: 8px;
}
.empty-state p { margin: 0; font-size: 20px; color: var(--text); }
.empty-state small { font-size: 14px; }
.empty-icon {
  width: 84px; height: 84px; border-radius: 22px;
  background: var(--bg);
  position: relative; margin-bottom: 6px;
}
.empty-icon::before, .empty-icon::after {
  content: ""; position: absolute; background: #C9C7BF; border-radius: 2px;
}
.empty-icon::before { left: 18px; top: 40px; width: 48px; height: 4px; }
.empty-icon::after {
  left: 18px; top: 26px; width: 34px; height: 24px;
  border: 4px solid #C9C7BF; background: transparent; border-radius: 4px;
}

/* ---------- 购物车行 ---------- */
.cart-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.cart-item {
  display: grid;
  grid-template-columns: 84px 1fr auto;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  align-items: center;
}
.cart-item.flash { animation: flash .5s ease; }
@keyframes flash { from { background: var(--brand-weak); } to { background: var(--card); } }

.thumb {
  width: 84px; height: 84px; border-radius: 12px;
  background: var(--bg) center/cover no-repeat;
  display: grid; place-items: center;
  font-size: 26px; font-weight: 600; color: #8a8880;
  overflow: hidden;
}
.info-name { font-size: 18px; font-weight: 500; margin-bottom: 6px; line-height: 1.3; }
.info-meta { font-size: 14px; color: var(--muted); }
.price del { color: var(--muted); margin-left: 8px; font-size: 14px; }
.tag-off {
  display: inline-block; background: var(--err-weak); color: var(--err);
  font-size: 12px; padding: 2px 8px; border-radius: 6px; margin-left: 8px;
}
.qty-ctl { display: flex; align-items: center; gap: 10px; }
.qty-btn {
  width: 44px; height: 44px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card);
  font-size: 22px; color: var(--text); cursor: pointer;
  display: grid; place-items: center;
}
.qty-btn:active { background: var(--brand-weak); }
.qty-num { min-width: 44px; text-align: center; font-size: 20px; font-weight: 600; }
.line-total { font-size: 20px; font-weight: 600; min-width: 92px; text-align: right; }
.del-btn {
  margin-left: 10px; color: var(--muted); background: none; border: none;
  cursor: pointer; font-size: 18px; padding: 6px;
}

/* ---------- 侧栏 ---------- */
.scan-box { position: relative; }
#scanInput {
  width: 100%; height: 62px;
  border: 2px dashed var(--brand-soft); border-radius: 14px;
  background: var(--brand-weak);
  font-size: 18px; padding: 0 16px; color: var(--text);
  outline: none; text-align: center;
}
#scanInput::placeholder { color: #7b8fa6; }
.scan-tip { text-align: center; font-size: 13px; color: var(--muted); margin-top: 8px; }

.totals { border-top: 1px solid var(--line); padding-top: 14px; }
.totals .row { display: flex; justify-content: space-between; align-items: baseline; padding: 6px 2px; font-size: 15px; color: var(--muted); }
.totals .row b { font-size: 18px; color: var(--text); font-weight: 600; }
.totals .discount b { color: var(--err); }
.totals .grand { margin-top: 6px; padding-top: 12px; border-top: 1px dashed var(--line); }
.totals .grand span { font-size: 16px; }
.totals .grand b { font-size: 40px; color: var(--brand); font-weight: 600; }

.quick-head { font-size: 14px; color: var(--muted); }
.quick-grid {
  flex: 1 1 auto; overflow-y: auto;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  align-content: start;
}
.quick-btn {
  border: 1px solid var(--line); background: var(--card);
  border-radius: 12px; padding: 10px 6px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  min-height: 88px;
}
.quick-btn img { width: 46px; height: 46px; border-radius: 8px; object-fit: cover; background: var(--bg); }
.quick-btn span { font-size: 12px; color: var(--text); text-align: center; line-height: 1.25; }
.quick-btn b { font-size: 13px; color: var(--brand); }
.quick-btn:active { background: var(--brand-weak); }

/* ---------- 按钮 ---------- */
.btn {
  border: none; border-radius: 14px; cursor: pointer;
  font-size: 16px; font-weight: 500;
  padding: 12px 18px; min-height: 48px;
  user-select: none; -webkit-user-select: none;
  transition: transform .05s ease, background .15s ease, opacity .15s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: #14497f; }
.btn.ghost { background: var(--bg); color: var(--text); border: 1px solid var(--line); }
.btn.huge { height: 76px; font-size: 26px; font-weight: 600; border-radius: 18px; margin-top: 4px; }
.btn.icon-btn { width: 46px; height: 46px; min-height: 46px; padding: 0; font-size: 20px; background: var(--bg); }

/* ---------- 弹窗 ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; }
.modal[hidden] { display: none; }
.modal-mask { position: absolute; inset: 0; background: rgba(20, 20, 18, .45); }

.modal-card {
  position: relative; z-index: 1;
  background: var(--card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  width: min(560px, 92vw);
  padding: 26px;
}
.pay-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.pay-amount { font-size: 44px; font-weight: 600; color: var(--brand); line-height: 1.1; }
.pay-sub { font-size: 15px; color: var(--muted); margin-top: 4px; }

/* 收款方式：顾客扫屏幕上的码 / 扫码枪扫顾客的付款码 */
.pay-mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.mode-btn {
  height: 52px; border-radius: 12px; cursor: pointer; font-size: 17px; font-weight: 500;
  border: 2px solid var(--line); background: var(--card); color: var(--muted);
}
.mode-btn.active { border-color: var(--brand); background: var(--brand-weak); color: var(--brand); }
.ch-auto { grid-column: 1 / -1; margin-top: -6px; font-size: 14px; color: var(--brand); text-align: center; }

.channel-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.ch-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  height: 60px; border-radius: 14px; cursor: pointer; font-size: 18px; font-weight: 500;
  border: 2px solid var(--line); background: var(--card); color: var(--text);
}
.ch-btn.active { border-color: var(--brand); background: var(--brand-weak); color: var(--brand); }
.ch-logo { width: 26px; height: 26px; border-radius: 7px; display: inline-block; }
.ch-logo.wechat { background: #07C160; }
.ch-logo.alipay { background: #1677FF; }

.qr-frame { border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; text-align: center; }
.qr-inner {
  width: 300px; height: 300px; margin: 0 auto;
  display: grid; place-items: center; background: #fff;
}
.qr-inner svg { width: 300px; height: 300px; }
.qr-loading { color: var(--muted); font-size: 15px; }
.qr-hint { font-size: 18px; margin-top: 14px; color: var(--text); }
.countdown { margin-top: 8px; font-size: 14px; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 8px; }
.countdown .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); animation: pulse 1.4s infinite; }
@keyframes pulse { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }

/* 被扫：等扫码枪读顾客的付款码。
   刻意不显示付款码原文 —— 它是一次性凭证，被拍到就能用，
   屏幕上只回显读到了几位。 */
.scan-frame { border: 1px solid var(--line); border-radius: var(--radius); padding: 24px 20px; text-align: center; }
.scan-pictogram { position: relative; height: 132px; display: grid; place-items: center; }
.scan-phone {
  width: 74px; height: 118px; border-radius: 12px;
  border: 2px solid var(--line); background: var(--card);
  position: relative;
}
.scan-phone::after {
  content: ''; position: absolute; left: 14px; right: 14px; top: 30px; height: 8px;
  border-radius: 4px; background: var(--brand); opacity: .35;
}
.scan-beam {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 108px; height: 3px; border-radius: 2px; background: var(--brand);
  animation: scanSweep 1.8s ease-in-out infinite;
}
@keyframes scanSweep {
  0%, 100% { transform: translate(-50%, -34px); opacity: .35; }
  50% { transform: translate(-50%, 34px); opacity: 1; }
}
.scan-title { font-size: 19px; font-weight: 500; margin-top: 8px; color: var(--text); }
.scan-sub { font-size: 14px; color: var(--muted); margin-top: 6px; }
.scan-readout {
  margin-top: 16px; height: 44px; line-height: 44px; border-radius: 10px;
  background: var(--bg); color: var(--muted); font-size: 16px;
}
.scan-status { margin-top: 10px; font-size: 15px; color: var(--muted); min-height: 22px; }
.scan-status.busy { color: var(--brand); }
.scan-status.bad { color: var(--err); }

.pay-foot { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }

/* ---------- 结果 ---------- */
.result-card {
  position: relative; z-index: 1;
  background: var(--card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  width: min(460px, 90vw); padding: 40px 30px 28px;
  text-align: center;
}
.result-icon {
  width: 96px; height: 96px; border-radius: 50%;
  margin: 0 auto 20px; display: grid; place-items: center;
  background: var(--ok-weak); color: var(--ok); font-size: 52px;
}
.result-icon.fail { background: var(--err-weak); color: var(--err); }
.result-title { font-size: 30px; font-weight: 600; }
.result-desc { margin-top: 10px; font-size: 16px; color: var(--muted); line-height: 1.6; }
.result-actions { margin-top: 26px; display: flex; gap: 12px; justify-content: center; }
.result-actions .btn { min-width: 130px; height: 54px; font-size: 18px; }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; top: 86px; left: 0; right: 0; z-index: 90; display: flex; flex-direction: column; align-items: center; gap: 10px; pointer-events: none; }
.toast {
  background: rgba(28, 28, 26, .92); color: #fff;
  padding: 12px 22px; border-radius: 12px; font-size: 16px;
  animation: pop .25s ease;
}
.toast.bad { background: var(--err); }
.toast.good { background: var(--ok); }
@keyframes pop { from { transform: translateY(-10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 响应式 ---------- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr 340px; }
  .totals .grand b { font-size: 34px; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .side-panel { max-height: 46vh; }
  .qr-inner, .qr-inner svg { width: 240px; height: 240px; }
}

/* ---------- 多商户：收银台登录门与门店标识 ---------- */

.shop-tag {
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(24, 95, 165, 0.10);
  color: #185fa5;
  font-size: 12px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.login-gate {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 24, 33, 0.55);
  backdrop-filter: blur(2px);
}

.gate-card {
  width: min(380px, calc(100vw - 40px));
  padding: 28px 24px;
  border-radius: 14px;
  background: #fff;
  text-align: center;
}

.gate-card h2 { margin: 12px 0 8px; font-size: 17px; font-weight: 500; }
.gate-card p { font-size: 13px; line-height: 1.7; margin-bottom: 18px; }

.gate-logo {
  width: 52px;
  height: 52px;
  margin: 0 auto;
  border-radius: 14px;
  background: #185fa5;
  color: #fff;
  font-size: 24px;
  line-height: 52px;
}
