/* ============ 基础与移动端优先 ============ */
:root {
  --brand: #0a66c2;
  --brand-dark: #084b8f;
  --ok: #1a7f37;
  --up: #c0392b;
  --down: #1a7f37;
  --warn: #b7791f;
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1a1a1a;
  --muted: #666;
  --border: #e0e2e6;
  --radius: 12px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

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

button, input, select, textarea {
  font-family: inherit;
  font-size: 17px;
}

button { cursor: pointer; }

img { max-width: 100%; }

/* ============ 访问码门槛 ============ */
.gate {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.gate-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 24px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: 0 6px 24px rgba(0,0,0,.08);
}
.gate-icon { font-size: 40px; }
.gate-card h2 { margin: 8px 0 6px; font-size: 21px; }
.gate-hint { color: var(--muted); font-size: 15px; margin: 0 0 18px; }
.gate-card input {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 18px;
  text-align: center;
  margin-bottom: 12px;
  outline: none;
}
.gate-card input:focus { border-color: var(--brand); }
.gate-err { color: var(--up); font-size: 15px; min-height: 22px; margin-top: 10px; }

/* ============ 店主端 ============ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--brand);
  color: #fff;
  padding: 12px 14px;
  box-shadow: 0 2px 6px rgba(0,0,0,.12);
}
.app-header h1 {
  margin: 0 0 10px;
  font-size: 19px;
  font-weight: 700;
}
.search-box {
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-radius: 10px;
  font-size: 17px;
  outline: none;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 12px 120px;
}

.category-block { margin-bottom: 18px; }
.category-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--brand-dark);
  padding: 8px 4px;
  border-bottom: 2px solid var(--brand);
  margin-bottom: 8px;
  position: sticky;
  top: 74px;
  background: var(--bg);
  z-index: 5;
}

/* 产品卡片 */
.product {
  display: flex;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
  align-items: center;
}
.product-img {
  width: 64px;
  height: 64px;
  flex: 0 0 64px;
  border-radius: 8px;
  object-fit: cover;
  background: #f0f0f0;
}
.product-img.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #bbb;
  font-size: 24px;
}
.product-info { flex: 1; min-width: 0; }
.product-name { font-weight: 600; font-size: 17px; }
.product-meta { color: var(--muted); font-size: 14px; margin-top: 2px; }
.product-price { color: var(--up); font-weight: 700; font-size: 18px; margin-top: 4px; }
.product-price small { color: var(--muted); font-weight: 400; font-size: 13px; }
.product-ref { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* 数量步进器 */
.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  flex: 0 0 auto;
}
.step-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--brand);
  background: #fff;
  color: var(--brand);
  font-size: 22px;
  font-weight: 700;
  border-radius: 8px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.step-btn:active { background: #eef4fb; }
.step-qty {
  width: 48px;
  height: 40px;
  text-align: center;
  border: 1px solid var(--border);
  margin: 0 6px;
  border-radius: 8px;
  -moz-appearance: textfield;
}
.step-qty::-webkit-outer-spin-button,
.step-qty::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* 吸底栏 */
.cart-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 10px rgba(0,0,0,.08);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 30;
}
.cart-summary { flex: 1; }
.cart-summary .count { font-size: 14px; color: var(--muted); }
.cart-summary .total { font-size: 20px; font-weight: 700; color: var(--up); }
.btn-primary {
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 14px 22px;
  font-size: 17px;
  font-weight: 700;
}
.btn-primary:active { background: var(--brand-dark); }
.btn-primary:disabled { background: #b7c3d0; }

.btn-ghost {
  background: #fff;
  color: var(--brand);
  border: 1px solid var(--brand);
  border-radius: 10px;
  padding: 12px 18px;
  font-weight: 600;
}
.btn-secondary {
  background: #eef1f5;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 18px;
  font-weight: 600;
}

.empty-hint { text-align: center; color: var(--muted); padding: 40px 20px; }

/* 弹层（选品清单 / 提交 / 成功） */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 40;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.overlay.show { display: flex; }
.sheet {
  background: var(--bg);
  width: 100%;
  max-width: 720px;
  max-height: 92vh;
  border-radius: 16px 16px 0 0;
  overflow-y: auto;
  padding: 16px 14px calc(16px + env(safe-area-inset-bottom));
}
.sheet-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.sheet-header h2 { margin: 0; font-size: 19px; }
.close-btn { background: none; border: none; font-size: 26px; color: var(--muted); line-height: 1; padding: 4px 8px; }

.cart-line {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border: 1px solid var(--border);
  border-radius: 10px; padding: 10px; margin-bottom: 8px;
}
.cart-line .info { flex: 1; min-width: 0; }
.cart-line .name { font-weight: 600; }
.cart-line .sub { color: var(--muted); font-size: 14px; }
.del-btn { background: none; border: none; color: var(--up); font-size: 15px; padding: 6px; }

.field { margin-bottom: 12px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; }
.field label .req { color: var(--up); }
.field input {
  width: 100%; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 10px;
  outline: none;
}
.field input:focus { border-color: var(--brand); }

/* 订单摘要 */
.summary-box {
  background: #fff; border: 1px solid var(--border);
  border-radius: 12px; padding: 14px; margin-bottom: 12px;
}
.summary-box .order-no { font-size: 15px; color: var(--muted); }
.summary-box .shop { font-size: 18px; font-weight: 700; margin: 4px 0 10px; }
.summary-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.summary-table th, .summary-table td {
  text-align: left; padding: 7px 4px; border-bottom: 1px solid var(--border);
}
.summary-table th { color: var(--muted); font-weight: 600; }
.summary-table td.num, .summary-table th.num { text-align: right; }
.summary-total { text-align: right; font-size: 19px; font-weight: 700; color: var(--up); margin-top: 10px; }
.screenshot-hint {
  text-align: center; color: var(--warn); font-size: 14px; margin: 8px 0 14px;
}
.stack-btns { display: flex; flex-direction: column; gap: 10px; }
.stack-btns button { width: 100%; }

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

@media (min-width: 560px) {
  .overlay { align-items: center; }
  .sheet { border-radius: 16px; max-height: 88vh; }
}
