:root {
  --primary: #ff5722;
  --primary-dark: #e64a19;
  --primary-soft: #fff3ee;
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #222;
  --sub: #888;
  --line: #ececec;
  --danger: #e53935;
  --ok: #43a047;
  --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}
img { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
/* 所有输入框 16px：避免手机端聚焦唤起输入法时页面被放大 */
input, textarea, select { font-family: inherit; font-size: 16px; }
/* 去掉数字输入框的上下箭头（桌面端悬浮出现的 spinner） */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }

.view-wrap { max-width: 520px; margin: 0 auto; min-height: 100vh; }

/* ---------- 底部备案号 ---------- */
.site-footer {
  max-width: 520px; margin: 0 auto; padding: 16px 12px 8px;
  text-align: center; font-size: 12px; color: #999;
}
.site-footer a { color: #999; text-decoration: none; }

/* ---------- 登录弹窗 ---------- */
.modal { position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center; }
.modal.hidden { display: none; }
.modal-mask { position: absolute; inset: 0; background: rgba(0,0,0,.5); }
.modal-box {
  position: relative; width: 82%; max-width: 320px; background: #fff;
  border-radius: 16px; padding: 24px 20px 20px;
}
.modal-close { position: absolute; top: 10px; right: 12px; font-size: 16px; color: #bbb; padding: 4px; }
.modal-title { font-size: 17px; font-weight: 700; text-align: center; }
.modal-sub { font-size: 12px; color: var(--sub); text-align: center; margin: 6px 0 16px; }
.modal-box input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; font-size: 16px; outline: none; text-align: center; background: #fafafa;
}
.modal-box input:focus { border-color: var(--primary); background: #fff; }
.modal-box .btn { margin-top: 14px; }

/* ---------- 价格隐藏与阶梯价 ---------- */
.login-hint { color: var(--sub); font-size: 12px; padding: 6px 0 2px; }
.tier-box { margin-top: 14px; background: var(--primary-soft); border-radius: 10px; padding: 10px 12px; }
.tier-title { font-size: 13px; font-weight: 700; margin-bottom: 6px; color: var(--primary); }
.tier-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; padding: 6px 0; color: #555; border-bottom: 1px dashed #f3d5c5;
}
.tier-row:last-child { border-bottom: none; }
.tier-row.active { color: var(--primary); font-weight: 700; }
.price-note { font-size: 12px; color: var(--sub); margin-top: 4px; }

/* ---------- 底部导航 ---------- */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  max-width: 520px; margin: 0 auto;
  display: flex; background: #fff;
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 6px; color: #999; font-size: 11px; position: relative;
}
.tab.active { color: var(--primary); }
.badge {
  position: absolute; top: 2px; left: calc(50% + 8px);
  min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; font-style: normal;
  line-height: 17px; text-align: center;
}
.badge.pop { animation: pop .25s ease; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }
.hidden { display: none !important; }

/* 详情页隐藏底部导航，避免与操作栏重叠 */
body[data-view="detail"] #tabbar { display: none; }

/* ---------- 通用 ---------- */
.section { padding: 12px; }
.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 22px; padding: 10px 22px; font-size: 15px; font-weight: 600;
}
.btn-primary { background: linear-gradient(135deg, #ff7043, var(--primary)); color: #fff; box-shadow: 0 4px 12px rgba(255,87,34,.28); }
.btn-primary:disabled { opacity: .5; box-shadow: none; cursor: not-allowed; }
.btn-ghost { background: var(--primary-soft); color: var(--primary); }
.btn-block { width: 100%; }
.btn-danger { background: #fdecea; color: var(--danger); }
.btn-sm { padding: 5px 12px; font-size: 13px; border-radius: 16px; }

.price { color: var(--danger); font-weight: 700; }
.price small { font-size: 12px; font-weight: 400; }

.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.78); color: #fff; font-size: 14px;
  padding: 10px 18px; border-radius: 20px; z-index: 99;
  max-width: 80%; text-align: center;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translate(-50%,-8px);} to { opacity: 1; transform: translate(-50%,0);} }

.empty { text-align: center; padding: 48px 16px; color: var(--sub); font-size: 14px; }
.empty .big { font-size: 44px; margin-bottom: 10px; }

/* ---------- 选购页 ---------- */
.shop-card {
  background: linear-gradient(135deg, #ff7043, #f4511e);
  color: #fff; padding: 18px 16px 14px; display: flex; gap: 12px; position: relative;
  padding-right: 104px;
}
.share-shop-btn {
  position: absolute; top: 14px; right: 14px;
  background: rgba(255,255,255,.22); border: 1px solid rgba(255,255,255,.55);
  color: #fff; font-size: 12px; border-radius: 999px; padding: 6px 12px;
  display: inline-flex; align-items: center; gap: 4px; cursor: pointer; white-space: nowrap;
}
.share-shop-btn::before { content: '↗'; font-size: 13px; }
.share-shop-btn:active { background: rgba(255,255,255,.35); }
.shop-avatar {
  width: 62px; height: 62px; border-radius: 14px; object-fit: cover;
  background: rgba(255,255,255,.25); flex-shrink: 0;
}
.shop-meta { flex: 1; min-width: 0; }
.shop-name { font-size: 19px; font-weight: 800; }
.shop-intro { font-size: 12px; opacity: .92; margin-top: 4px; line-height: 1.5; word-break: break-all; }
.shop-tags { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 8px; font-size: 12px; opacity: .95; }
.shop-tags span { display: inline-flex; align-items: center; gap: 3px; }

.notice-bar {
  background: #fff7e6; color: #b26a00; font-size: 13px;
  padding: 8px 14px; display: flex; align-items: center; gap: 6px;
  border-bottom: 1px solid #f5e3c0;
}
.notice-bar b { flex-shrink: 0; color: #e8890c; }

.search-box { padding: 12px 12px 4px; }
.search-box input {
  width: 100%; border: none; background: #fff; border-radius: 20px;
  padding: 10px 16px; font-size: 16px; box-shadow: 0 1px 4px rgba(0,0,0,.05);
  outline: none;
}

#chips { padding: 10px 12px 0; }
.chips-row { display: flex; gap: 8px; overflow-x: auto; padding: 6px 0 4px; scrollbar-width: none; }
.chips-row::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; padding: 7px 16px; border-radius: 18px; background: #fff;
  font-size: 13px; color: #555; border: 1px solid var(--line); white-space: nowrap;
}
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.chip.sub { background: var(--primary-soft); color: #666; border-color: transparent; font-size: 12px; }
.chip.sub.active { background: var(--primary); color: #fff; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 4px 12px 12px; }
.p-card { background: #fff; border-radius: var(--radius); overflow: hidden; position: relative; }
.p-card .img { width: 100%; aspect-ratio: 1; object-fit: cover; background: #f2f2f2; }
.p-card .body { padding: 9px 10px 11px; }
.p-card .title {
  font-size: 13.5px; line-height: 1.4; height: 2.8em; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.p-card .price { margin-top: 6px; font-size: 16px; }
.p-card .unit { color: var(--sub); font-size: 12px; margin-left: 3px; }
.p-card .soldout {
  position: absolute; inset: 0; background: rgba(0,0,0,.45); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 700;
}
.p-card .minqty { position: absolute; top: 8px; left: 8px; background: rgba(0,0,0,.55); color: #fff; font-size: 11px; padding: 2px 8px; border-radius: 10px; }

.list-status { text-align: center; color: var(--sub); font-size: 13px; padding: 14px 0 24px; }

/* ---------- 详情页 ---------- */
.detail-top {
  position: sticky; top: 0; z-index: 20; background: #fff;
  display: flex; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line);
}
.back-btn { font-size: 20px; color: var(--text); padding: 4px 8px; }
.detail-top .t { flex: 1; text-align: center; font-size: 15px; font-weight: 600; margin-right: 36px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.detail-img { background: #fff; }
.detail-img .main { width: 100%; aspect-ratio: 1; object-fit: cover; }
.thumbs { display: flex; gap: 8px; padding: 10px 12px; overflow-x: auto; }
.thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 2px solid transparent; flex-shrink: 0; }
.thumbs img.active { border-color: var(--primary); }

.detail-info { background: #fff; border-radius: var(--radius); margin: 12px; padding: 14px; }
.detail-info .price { font-size: 24px; }
.detail-info .price small { font-size: 13px; }
.detail-meta { display: flex; gap: 16px; font-size: 12px; color: var(--sub); margin-top: 8px; }

.spec-block { margin-top: 14px; }
.spec-name { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.spec-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.spec-opt {
  padding: 7px 16px; border-radius: 8px; background: var(--bg); font-size: 13px;
  border: 1px solid transparent; color: #444;
}
.spec-opt.active { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); font-weight: 600; }
.spec-opt.disabled { opacity: .4; text-decoration: line-through; }

.qty-row { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; }
.qty-row .l { font-size: 14px; font-weight: 600; }
.stepper { display: flex; align-items: center; gap: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.stepper button { width: 34px; height: 34px; font-size: 18px; color: var(--text); background: #fafafa; }
.stepper button:disabled { color: #ccc; }
.stepper input {
  width: 46px; height: 34px; border: none; text-align: center; font-size: 16px;
  border-left: 1px solid var(--line); border-right: 1px solid var(--line); outline: none;
}

.detail-desc { background: #fff; border-radius: var(--radius); margin: 0 12px 12px; padding: 14px; }
.detail-desc h3 { font-size: 14px; margin-bottom: 8px; }
.detail-desc p { font-size: 13px; color: #555; line-height: 1.7; white-space: pre-wrap; word-break: break-all; }

.detail-actions {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  max-width: 520px; margin: 0 auto; display: flex; gap: 10px;
  background: #fff; border-top: 1px solid var(--line);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
}
.detail-actions .btn { flex: 1; }

/* ---------- 购物车 ---------- */
.cart-list { padding: 12px; }
.cart-item {
  display: flex; gap: 10px; background: #fff; border-radius: var(--radius);
  padding: 10px; margin-bottom: 10px; align-items: center;
}
.cart-item img { width: 72px; height: 72px; border-radius: 8px; object-fit: cover; background: #f2f2f2; flex-shrink: 0; }
.cart-item .info { flex: 1; min-width: 0; }
.cart-item .t { font-size: 13.5px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cart-item .sku { font-size: 12px; color: var(--sub); margin-top: 3px; }
.cart-item .row2 { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.cart-item .stepper button { width: 28px; height: 28px; font-size: 16px; }
.cart-item .stepper input { width: 38px; height: 28px; font-size: 16px; }
.cart-item .del { color: #bbb; font-size: 18px; padding: 4px; margin-left: 6px; }

.cart-bar {
  position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--line);
  padding: 10px 12px; display: flex; align-items: center; gap: 12px;
}
.cart-bar .total { flex: 1; font-size: 13px; color: var(--sub); }
.cart-bar .total .price { font-size: 18px; }

/* ---------- 采货单 ---------- */
.receipt {
  background: #fff; margin: 14px 12px; border-radius: var(--radius);
  overflow: hidden; border: 1px solid var(--line);
}
.receipt-head {
  background: linear-gradient(135deg, #ff7043, #f4511e); color: #fff;
  padding: 16px; display: flex; align-items: center; gap: 12px;
}
.receipt-head img { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: rgba(255,255,255,.25); }
.receipt-head .n { font-size: 16px; font-weight: 800; }
.receipt-head .s { font-size: 11px; opacity: .9; margin-top: 2px; }
.receipt-body { padding: 14px 16px; }
.receipt-no { font-size: 12px; color: var(--sub); display: flex; justify-content: space-between; margin-bottom: 10px; }
.receipt-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center;
  padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 13px;
}
.receipt-row .r { color: var(--sub); font-size: 12px; margin-top: 2px; }
.receipt-row .amt { text-align: right; min-width: 64px; }
/* 采货单明细带商品小图 */
.receipt-row.ri { grid-template-columns: 44px 1fr auto; align-items: start; }
.receipt-row.ri .ri-img { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; background: #f4f4f4; }
.receipt-row.ri .ri-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.receipt-total { display: flex; justify-content: space-between; padding: 12px 0 4px; font-size: 14px; }
.receipt-total .price { font-size: 19px; }
.receipt-fields { margin-top: 12px; }
.receipt-fields label { font-size: 13px; color: var(--sub); display: block; margin: 10px 0 5px; }
.receipt-fields input, .receipt-fields textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; outline: none; background: #fafafa;
}
.receipt-foot { border-top: 1px solid var(--line); padding: 12px 16px; font-size: 12px; color: var(--sub); line-height: 1.7; background: #fafafa; }
.receipt-footer-note { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line); color: #888; }
.receipt-actions { padding: 0 12px 20px; display: flex; flex-direction: column; gap: 10px; }

.success-box { text-align: center; padding: 40px 20px; }
.success-box .icon { width: 64px; height: 64px; border-radius: 50%; background: var(--ok); color: #fff; font-size: 34px; line-height: 64px; margin: 0 auto 16px; }
.success-box .no { color: var(--sub); font-size: 13px; margin: 8px 0 20px; }

/* ---------- 联系客服 ---------- */
.contact-card { background: #fff; border-radius: var(--radius); padding: 16px; margin: 12px; }
.contact-card h3 { font-size: 15px; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.qr-wrap { position: relative; width: 210px; margin: 4px auto 6px; }
.qr-wrap .qr { width: 100%; border-radius: 12px; border: 1px solid var(--line); }
.qr-wrap .wx-icon {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 46px; height: 46px; border-radius: 50%; background: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,.18);
}
.qr-wrap .wx-icon svg { width: 30px; height: 30px; display: block; }
.qr-tip { text-align: center; font-size: 12px; color: var(--sub); margin-bottom: 6px; }
.contact-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-top: 1px solid var(--line); font-size: 14px;
}
.contact-row .l { color: #555; }
.contact-row .v { font-weight: 600; }
.steps { display: flex; gap: 0; margin-top: 8px; }
.step { flex: 1; text-align: center; font-size: 12px; color: var(--sub); position: relative; }
.step i {
  display: block; width: 26px; height: 26px; border-radius: 50%; background: var(--primary);
  color: #fff; font-style: normal; font-size: 13px; line-height: 26px; margin: 0 auto 6px;
}
.step + .step::before { content: ""; position: absolute; top: 13px; left: -50%; width: 100%; border-top: 1px dashed #ccc; }

/* ---------- 分享商品 ---------- */
.share-box { width: 440px; max-width: 94vw; padding: 14px 14px 12px; }
.share-loading { text-align: center; color: var(--sub); font-size: 14px; padding: 40px 0; }
.share-img-final { display: block; width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line); background: #f7f7f7; }
.share-actions { display: flex; gap: 10px; margin-top: 10px; }
.share-actions .btn { flex: 1; }
.share-tip { font-size: 11px; color: var(--sub); text-align: center; margin-top: 8px; min-height: 14px; word-break: break-all; }
