/* ============================================================
   彦林优选 用户端 H5 统一样式
   移动端优先，375px 基准；主色中国红 #c0392b
   ============================================================ */
:root {
  --primary: #c0392b;
  --primary-dark: #a32e22;
  --primary-light: #fbeae8;
  --bg: #f4f4f4;
  --card: #ffffff;
  --text: #2b2b2b;
  --text-sub: #8a8a8a;
  --line: #ececec;
  --green: #2e7d32;
  --radius: 10px;
  --header-h: 46px;
  --tabbar-h: 56px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { font-family: inherit; border: none; outline: none; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 15px; outline: none; }

/* ---------- 页头 ---------- */
.header {
  position: fixed; top: 0; left: 0; right: 0; height: var(--header-h);
  background: var(--card); display: flex; align-items: center; justify-content: center;
  border-bottom: 1px solid var(--line); z-index: 100;
}
.header .back {
  position: absolute; left: 0; top: 0; height: 100%; width: 46px;
  display: flex; align-items: center; justify-content: center; font-size: 20px; color: var(--text);
  background: none;
}
.header .title { font-size: 17px; font-weight: 600; }
.header .right { position: absolute; right: 12px; font-size: 13px; color: var(--primary); background: none; }
.body { padding-top: var(--header-h); min-height: 100vh; }
.body.no-header { padding-top: 0; }
body.has-tabbar .body { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }

/* ---------- 底部 Tab ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line);
  display: flex; z-index: 100;
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--text-sub); font-size: 11px; }
.tabbar a .ico { font-size: 20px; line-height: 1; }
.tabbar a.active { color: var(--primary); }

/* ---------- 通用组件 ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 12px; margin: 10px; }
.muted { color: var(--text-sub); font-size: 12px; }
.row { display: flex; align-items: center; }
.between { justify-content: space-between; }
.price { color: var(--primary); font-weight: 700; }
.price .sym { font-size: 12px; }
.price .int { font-size: 18px; }
.old-price { color: var(--text-sub); text-decoration: line-through; font-size: 12px; margin-left: 4px; }
.unit { color: var(--text-sub); font-size: 12px; margin-left: 4px; }

.btn {
  display: block; width: 100%; padding: 12px; border-radius: 24px;
  background: var(--primary); color: #fff; font-size: 16px; text-align: center; font-weight: 600;
}
.btn:active { opacity: .85; }
.btn[disabled] { background: #ccc; }
.btn.ghost { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn.small { width: auto; padding: 6px 16px; font-size: 13px; border-radius: 16px; display: inline-block; }
.btn-row { display: flex; gap: 10px; padding: 12px; }
.btn-row .btn { flex: 1; }

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

/* 图片占位：底色 + 首字 */
.cover {
  background: linear-gradient(135deg, #f3d9d4, #e8c4bd);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 26px; font-weight: 700; border-radius: 6px; overflow: hidden; position: relative;
}
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover.wide { width: 100%; aspect-ratio: 1 / 1; }
.cover.sm { width: 64px; height: 64px; flex: none; font-size: 20px; }

/* ---------- 商品卡片 ---------- */
.goods-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 10px; }
.pcard { background: var(--card); border-radius: var(--radius); overflow: hidden; display: block; }
.pcard .pcover { width: 100%; aspect-ratio: 1/1; }
.pcard .pinfo { padding: 8px 10px 10px; }
.pcard .pname { font-size: 14px; line-height: 1.35; height: 2.8em; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pcard .psub { font-size: 11px; color: var(--text-sub); margin: 2px 0 6px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* ---------- 表单 ---------- */
.field { background: var(--card); margin: 10px; border-radius: var(--radius); padding: 0 12px; }
.field label { display: block; font-size: 12px; color: var(--text-sub); padding-top: 10px; }
.field input, .field textarea, .field select {
  width: 100%; border: none; padding: 8px 0 12px; background: transparent; font-size: 15px;
}
.field textarea { min-height: 60px; resize: none; }
.field-row { display: flex; align-items: center; }
.field-row input { flex: 1; }
.field-row .btn.small { flex: none; margin: 8px 0; white-space: nowrap; }

/* ---------- 列表行 ---------- */
.list-item { background: var(--card); padding: 12px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: none; }
.list-item .info { flex: 1; min-width: 0; }
.list-item .t { font-size: 14px; }
.list-item .s { font-size: 12px; color: var(--text-sub); margin-top: 2px; }

/* ---------- 状态 Tab 横滑 ---------- */
.st-tabs { display: flex; background: var(--card); border-bottom: 1px solid var(--line); overflow-x: auto; }
.st-tabs a { flex: none; padding: 11px 14px; font-size: 14px; color: var(--text-sub); position: relative; white-space: nowrap; }
.st-tabs a.active { color: var(--primary); font-weight: 600; }
.st-tabs a.active::after { content: ""; position: absolute; left: 50%; transform: translateX(-50%); bottom: 0; width: 22px; height: 3px; border-radius: 2px; background: var(--primary); }

/* ---------- 结算三 Tab ---------- */
.ful-tabs { display: flex; margin: 10px; background: var(--card); border-radius: var(--radius); padding: 4px; gap: 4px; }
.ful-tabs button { flex: 1; padding: 9px 0; border-radius: 8px; background: transparent; color: var(--text-sub); font-size: 14px; }
.ful-tabs button.active { background: var(--primary); color: #fff; font-weight: 600; }

/* ---------- 订单卡 ---------- */
.order-card { background: var(--card); border-radius: var(--radius); margin: 10px; overflow: hidden; }
.order-card .oc-head { display: flex; justify-content: space-between; padding: 10px 12px; border-bottom: 1px dashed var(--line); font-size: 12px; color: var(--text-sub); }
.order-card .oc-head .st { color: var(--primary); font-weight: 600; }
.order-card .oc-item { display: flex; gap: 10px; padding: 10px 12px; }
.order-card .oc-item .info { flex: 1; min-width: 0; }
.order-card .oc-item .name { font-size: 14px; }
.order-card .oc-item .spec { font-size: 12px; color: var(--text-sub); margin: 2px 0; }
.order-card .oc-foot { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }
.order-card .oc-foot .total { margin-right: auto; font-size: 13px; color: var(--text-sub); }
.order-card .oc-foot .total b { color: var(--primary); font-size: 16px; }

/* ---------- 礼品卡 ---------- */
.gift-card {
  background: linear-gradient(120deg, #b03a2e, #7b241c);
  color: #fff; border-radius: var(--radius); margin: 10px; padding: 14px; position: relative; overflow: hidden;
}
.gift-card::after { content: ""; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%; background: rgba(255,255,255,.08); }
.gift-card .gc-name { font-size: 15px; font-weight: 600; }
.gift-card .gc-row { display: flex; justify-content: space-between; margin-top: 8px; font-size: 12px; opacity: .92; }
.gift-card .gc-no { font-family: Menlo, Consolas, monospace; letter-spacing: 1px; margin-top: 10px; font-size: 15px; }
.gift-card .gc-status { position: absolute; right: 12px; top: 12px; font-size: 12px; background: rgba(255,255,255,.2); padding: 2px 8px; border-radius: 10px; }

/* ---------- 自提码 ---------- */
.pickup-box { text-align: center; padding: 20px 10px; }
.pickup-box .code { font-size: 34px; letter-spacing: 8px; font-weight: 700; color: var(--primary); font-family: Menlo, Consolas, monospace; margin: 8px 0; }
.pickup-box #qrcode { display: inline-block; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: 8px; margin-top: 10px; }

/* ---------- 时间线 ---------- */
.timeline { padding: 6px 0; }
.tl-item { display: flex; gap: 10px; padding: 8px 0; }
.tl-item .dot { width: 8px; height: 8px; border-radius: 50%; background: #ddd; margin-top: 6px; flex: none; }
.tl-item:first-child .dot { background: var(--primary); }
.tl-item:first-child .t { color: var(--text); font-weight: 600; }
.tl-item .t { font-size: 13px; color: var(--text-sub); }
.tl-item .time { font-size: 11px; color: #bbb; }

/* ---------- 数量步进 ---------- */
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.stepper button { width: 28px; height: 28px; background: #f7f7f7; font-size: 16px; color: var(--text); }
.stepper input { width: 40px; height: 28px; text-align: center; border: none; border-left: 1px solid var(--line); border-right: 1px solid var(--line); -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; top: 45%; transform: translate(-50%, -50%);
  background: rgba(0,0,0,.78); color: #fff; padding: 10px 18px; border-radius: 8px;
  font-size: 14px; z-index: 999; max-width: 80%; text-align: center; display: none;
}

/* ---------- 详情页 ---------- */
.gallery-main { width: 100%; aspect-ratio: 1/1; background: #fff; }
.gallery-main img { width: 100%; height: 100%; object-fit: contain; }
.gallery-thumbs { display: flex; gap: 8px; padding: 10px; overflow-x: auto; background: #fff; }
.gallery-thumbs .cover { width: 56px; height: 56px; flex: none; border: 2px solid transparent; }
.gallery-thumbs .cover.active { border-color: var(--primary); }
.spec-group { padding: 10px 12px; }
.spec-group .gname { font-size: 13px; color: var(--text-sub); margin-bottom: 8px; }
.spec-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.spec-opts button { padding: 6px 14px; border-radius: 16px; background: #f2f2f2; font-size: 13px; color: var(--text); }
.spec-opts button.active { background: var(--primary-light); color: var(--primary); border: 1px solid var(--primary); }
.bottom-bar {
  position: fixed; left: 0; right: 0; bottom: 0; background: #fff;
  border-top: 1px solid var(--line); display: flex; gap: 10px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  z-index: 90;
}
.bottom-bar .btn { flex: 1; padding: 11px 0; font-size: 15px; }
.bottom-bar .btn.cart-btn { background: #f0b429; }
.rich { padding: 12px; background: #fff; font-size: 14px; overflow-wrap: break-word; }
.rich img { max-width: 100%; height: auto; }

/* ---------- 公告条 ---------- */
.notice-bar {
  display: flex; align-items: center; gap: 6px; background: var(--primary-light); color: var(--primary-dark);
  padding: 8px 12px; font-size: 12px;
}
.notice-bar .txt { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* ---------- 分类入口 ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 10px; }
.cat-cell { background: #fff; border-radius: var(--radius); padding: 12px 4px; text-align: center; font-size: 12px; }
.cat-cell .icon { font-size: 26px; display: block; margin-bottom: 4px; }
.section-title { display: flex; justify-content: space-between; align-items: center; padding: 14px 12px 6px; font-size: 16px; font-weight: 700; }
.section-title .more { font-size: 12px; color: var(--text-sub); font-weight: 400; }

/* ---------- 个人中心 ---------- */
.me-head { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; padding: 26px 16px 20px; display: flex; align-items: center; gap: 12px; }
.me-head .avatar { width: 56px; height: 56px; border-radius: 50%; background: rgba(255,255,255,.25); display: flex; align-items: center; justify-content: center; font-size: 26px; overflow: hidden; }
.me-head .avatar img { width: 100%; height: 100%; object-fit: cover; }
.me-menu { background: var(--card); margin: 10px; border-radius: var(--radius); overflow: hidden; }
.me-menu .list-item { border-bottom: 1px solid var(--line); }
.me-menu .list-item:active { background: #fafafa; }
.me-menu .arrow { color: #ccc; }

/* ---------- 搜索栏 ---------- */
.search-bar { display: flex; align-items: center; background: #fff; margin: 10px; border-radius: 20px; padding: 8px 14px; gap: 8px; }
.search-bar input { flex: 1; border: none; background: transparent; }
.search-bar .go { color: var(--primary); font-size: 14px; background: none; }

/* ---------- 加载 ---------- */
.loading { text-align: center; color: var(--text-sub); padding: 16px; font-size: 13px; }
.mask-tip { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 200; }
.mask-tip .box { background: #fff; border-radius: 12px; padding: 22px 26px; text-align: center; max-width: 78%; }
.mask-tip .box .btns { display: flex; gap: 10px; margin-top: 16px; }
.mask-tip .box .btns button { flex: 1; padding: 9px 0; border-radius: 18px; background: #f2f2f2; font-size: 14px; }
.mask-tip .box .btns button.ok { background: var(--primary); color: #fff; }
