/* ============================================================
 * 五金商城 H5 · 全局样式
 * 移动端优先，桌面端居中显示 750px 内容列
 * ============================================================ */

:root {
  --brand: #1677ff;
  --brand-d: #0b5fd1;
  --brand-l: #e8f1ff;
  --ink: #1b2431;
  --ink2: #4b5563;
  --ink3: #8a94a6;
  --line: #e8ecf3;
  --bg: #eef1f6;
  --card: #ffffff;
  --soft: #f7f9fc;
  --price: #ff3b30;
  --ok: #16a34a;
  --warn: #f59e0b;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(24, 39, 75, 0.06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }
button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: inherit; }

/* 页面容器：手机端满宽，PC 端居中一列 */
.page {
  max-width: 750px;
  margin: 0 auto;
  background: var(--card);
  min-height: 100vh;
  box-shadow: 0 0 24px rgba(24, 39, 75, 0.07);
  padding-bottom: 76px;
  position: relative;
  overflow-x: hidden;
}

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.brand-logo {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), #4d9bff);
  color: #fff; font-weight: 700; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: .5px; }
.topbar-spacer { flex: 1; }
.topbar-link {
  font-size: 13px; color: var(--ink2);
  padding: 5px 10px; border-radius: 20px; background: var(--soft);
}
.topbar-link.primary { background: var(--brand-l); color: var(--brand-d); font-weight: 600; }

.back-btn {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--ink2); background: var(--soft);
  flex: 0 0 auto;
}
.topbar-title { font-size: 16px; font-weight: 600; }

/* ---------------- 搜索 ---------------- */
.searchwrap { padding: 10px 14px 4px; background: #fff; }
.searchbar {
  display: flex; align-items: center; gap: 8px;
  background: var(--soft); border: 1px solid var(--line);
  border-radius: 22px; padding: 8px 14px;
}
.searchbar input {
  flex: 1; border: 0; background: transparent; outline: none;
  font-size: 14px; color: var(--ink);
}
.searchbar input::placeholder { color: var(--ink3); }
.searchbar .ico { color: var(--ink3); font-size: 15px; }

/* ---------------- 首页 banner ---------------- */
.banner {
  margin: 12px 14px 0;
  border-radius: var(--radius);
  background: linear-gradient(120deg, #1677ff 0%, #3f8dff 55%, #6aa9ff 100%);
  color: #fff;
  padding: 18px 18px 20px;
  position: relative;
  overflow: hidden;
}
.banner::after {
  content: '';
  position: absolute; right: -40px; top: -50px;
  width: 180px; height: 180px; border-radius: 50%;
  background: rgba(255, 255, 255, .12);
}
.banner h2 { margin: 0 0 6px; font-size: 19px; font-weight: 700; position: relative; }
.banner p { margin: 0; font-size: 12.5px; opacity: .92; position: relative; }
.banner-tags { display: flex; gap: 8px; margin-top: 12px; position: relative; flex-wrap: wrap; }
.banner-tags span {
  font-size: 11.5px; padding: 3px 9px; border-radius: 20px;
  background: rgba(255, 255, 255, .2);
}

/* 保障条 */
.assure {
  display: flex; margin: 12px 14px; padding: 10px 4px;
  background: var(--soft); border-radius: var(--radius);
}
.assure div { flex: 1; text-align: center; font-size: 11.5px; color: var(--ink2); }
.assure b { display: block; font-size: 15px; margin-bottom: 2px; }

/* ---------------- 分类 ---------------- */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 14px 8px;
}
.section-head h3 { margin: 0; font-size: 15px; font-weight: 700; }
.section-head .more { font-size: 12.5px; color: var(--ink3); }

.cats {
  display: flex; gap: 8px; padding: 0 14px 8px;
  overflow-x: auto; scrollbar-width: none;
}
.cats::-webkit-scrollbar { display: none; }
.cat {
  flex: 0 0 auto; padding: 6px 14px; border-radius: 18px;
  background: var(--soft); color: var(--ink2); font-size: 13px;
  border: 1px solid var(--line); white-space: nowrap;
}
.cat.active { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 600; }

/* ---------------- 商品网格 ---------------- */
.grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  padding: 4px 14px 8px;
}
.pcard {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column;
}
.pcard:active { transform: scale(.985); }
.pcard .thumb { position: relative; }
.pcard .thumb svg { width: 100%; height: auto; }
.pcard .tag {
  position: absolute; left: 8px; top: 8px;
  background: var(--price); color: #fff; font-size: 10.5px;
  padding: 2px 7px; border-radius: 4px; font-weight: 600;
}
.pcard .tag.blue { background: var(--brand); }
.pcard .body { padding: 8px 10px 12px; display: flex; flex-direction: column; flex: 1; }
.pcard .name {
  font-size: 13px; line-height: 1.42; font-weight: 600;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 37px;
}
.pcard .sub {
  font-size: 11px; color: var(--ink3); margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pcard .foot { display: flex; align-items: baseline; justify-content: space-between; margin-top: 8px; }
.price { color: var(--price); font-weight: 700; }
.price .sym { font-size: 11px; }
.price .num { font-size: 17px; }
.price .unit { font-size: 11px; color: var(--ink3); font-weight: 400; }
.price-orig { font-size: 11px; color: var(--ink3); text-decoration: line-through; margin-left: 5px; }
.pcard .sold { font-size: 11px; color: var(--ink3); }

/* ---------------- 商品详情 ---------------- */
.detail-hero { background: var(--soft); padding: 18px; display: flex; justify-content: center; }
.detail-hero svg { width: 220px; height: 220px; }

.block { padding: 14px; border-bottom: 8px solid var(--soft); }
.block:last-child { border-bottom: 0; }
.block h4 { margin: 0 0 10px; font-size: 14px; font-weight: 700; }

.price-box {
  background: linear-gradient(120deg, #fff4f2, #ffece9);
  border-radius: var(--radius); padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between;
}
.price-box .big { font-size: 26px; }
.title-main { font-size: 16.5px; font-weight: 700; line-height: 1.5; margin: 12px 0 4px; }
.title-sub { font-size: 12.5px; color: var(--ink3); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.chips span {
  font-size: 11px; color: var(--brand-d); background: var(--brand-l);
  padding: 3px 9px; border-radius: 4px;
}

/* 规格表 */
.spec-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.spec-table tr { border-bottom: 1px solid var(--line); }
.spec-table tr:last-child { border-bottom: 0; }
.spec-table td { padding: 10px 0; vertical-align: top; }
.spec-table td:first-child { color: var(--ink3); width: 88px; }
.spec-table td:last-child { color: var(--ink); }

.hl-list { margin: 0; padding: 0; list-style: none; }
.hl-list li {
  position: relative; padding-left: 18px; margin-bottom: 7px;
  font-size: 13px; color: var(--ink2);
}
.hl-list li::before {
  content: ''; position: absolute; left: 2px; top: 8px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--brand);
}

.desc p { margin: 0 0 10px; font-size: 13.5px; color: var(--ink2); }

.notice {
  background: var(--soft); border-radius: var(--radius);
  padding: 12px 14px; font-size: 12.5px; color: var(--ink2); line-height: 1.75;
}
.notice b { color: var(--ink); }

/* 数量选择 */
.qty-row { display: flex; align-items: center; justify-content: space-between; padding: 4px 0; }
.qty { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.qty button {
  width: 34px; height: 32px; border: 0; background: var(--soft);
  color: var(--ink2); font-size: 17px; line-height: 1;
}
.qty button:disabled { color: #cbd3e0; }
.qty input {
  width: 48px; height: 32px; border: 0; text-align: center;
  outline: none; font-weight: 600; color: var(--ink);
}

/* ---------------- 底部操作条 ---------------- */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  max-width: 750px; margin: 0 auto;
  background: #fff; border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px calc(9px + env(safe-area-inset-bottom));
}
.actionbar .info { flex: 1; min-width: 0; }
.actionbar .info .lbl { font-size: 11px; color: var(--ink3); }
.actionbar .info .val { font-size: 17px; font-weight: 700; color: var(--price); }
.btn {
  border: 0; border-radius: 22px; padding: 11px 22px;
  font-size: 14.5px; font-weight: 600; color: #fff;
  background: linear-gradient(135deg, var(--brand), #3f8dff);
  white-space: nowrap;
}
.btn:active { opacity: .88; }
.btn.block { display: block; width: 100%; text-align: center; }
.btn.ghost { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.btn.gray { background: var(--soft); color: var(--ink2); }
.btn.warn { background: linear-gradient(135deg, #ff8a3d, #ff6a00); }
.btn.disabled, .btn:disabled { background: #c9d4e4; color: #fff; }
.btn.lg { padding: 13px 24px; font-size: 16px; }

/* 底部导航 */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
  max-width: 750px; margin: 0 auto;
  background: #fff; border-top: 1px solid var(--line);
  display: flex; padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
}
.tab {
  flex: 1; text-align: center; font-size: 11px; color: var(--ink3);
  position: relative; padding: 2px 0;
}
.tab b { display: block; font-size: 19px; line-height: 1.25; font-weight: 400; }
.tab.active { color: var(--brand); font-weight: 600; }
.tab .badge {
  position: absolute; top: -1px; left: 50%; margin-left: 6px;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--price); color: #fff; font-size: 10px;
  line-height: 16px; font-weight: 600;
}

/* ---------------- 购物车 ---------------- */
.cart-item {
  display: flex; gap: 10px; padding: 12px 14px;
  border-bottom: 1px solid var(--line); align-items: center;
}
.cart-item .thumb { flex: 0 0 74px; }
.cart-item .thumb svg { width: 74px; height: 74px; }
.cart-item .mid { flex: 1; min-width: 0; }
.cart-item .nm {
  font-size: 13px; font-weight: 600; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cart-item .sp { font-size: 11.5px; color: var(--ink3); margin-top: 3px; }
.cart-item .bt { display: flex; align-items: center; justify-content: space-between; margin-top: 7px; }
.checkbox {
  width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid #c8d1e0;
  flex: 0 0 auto; display: flex; align-items: center; justify-content: center;
  color: transparent; font-size: 12px;
}
.checkbox.on { background: var(--brand); border-color: var(--brand); color: #fff; }

.cart-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  max-width: 750px; margin: 0 auto;
  background: #fff; border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px calc(9px + env(safe-area-inset-bottom));
}
.cart-bar .sum { flex: 1; font-size: 12px; color: var(--ink3); }
.cart-bar .sum b { display: block; font-size: 18px; color: var(--price); }

/* ---------------- 订单确认 ---------------- */
.formrow {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.formrow:last-child { border-bottom: 0; }
.formrow label { flex: 0 0 74px; font-size: 13.5px; color: var(--ink2); }
.formrow input, .formrow textarea {
  flex: 1; border: 0; outline: none; background: transparent;
  font-size: 14px; color: var(--ink); width: 100%;
}
.formrow textarea { resize: none; height: 44px; line-height: 1.5; }
.formrow input::placeholder, .formrow textarea::placeholder { color: #b6bfcd; }

.order-line {
  display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--line);
}
.order-line:last-of-type { border-bottom: 0; }
.order-line .thumb svg { width: 58px; height: 58px; }
.order-line .mid { flex: 1; min-width: 0; }
.order-line .nm { font-size: 13px; font-weight: 600; line-height: 1.45; }
.order-line .sp { font-size: 11.5px; color: var(--ink3); margin-top: 3px; }
.order-line .rt { text-align: right; font-size: 12px; color: var(--ink3); }
.order-line .rt .p { color: var(--ink); font-weight: 700; font-size: 14px; }

.kv { display: flex; justify-content: space-between; padding: 8px 0; font-size: 13.5px; }
.kv.total { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 12px; }
.kv.total .v { font-size: 19px; font-weight: 700; color: var(--price); }
.kv .v.strong { font-weight: 700; }
.kv .k { color: var(--ink2); }

.pay-method {
  display: flex; align-items: center; gap: 10px;
  padding: 13px; border: 1px solid var(--brand); border-radius: var(--radius);
  background: var(--brand-l);
}
.pay-method .logo {
  width: 30px; height: 30px; border-radius: 7px; background: #1677ff; color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px;
}
.pay-method .t { flex: 1; font-size: 14px; font-weight: 600; }
.pay-method .t small { display: block; font-weight: 400; color: var(--ink3); font-size: 11.5px; }
.pay-method .tick { color: var(--brand); font-weight: 700; }

/* ---------------- 支付 / 结果 ---------------- */
.center-box { padding: 44px 28px 28px; text-align: center; }
.center-box .circle {
  width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 36px; color: #fff;
}
.circle.ok { background: linear-gradient(135deg, #22c55e, #16a34a); }
.circle.wait { background: linear-gradient(135deg, #3f8dff, #1677ff); }
.circle.fail { background: linear-gradient(135deg, #fb7185, #ef4444); }
.center-box h2 { margin: 0 0 6px; font-size: 19px; }
.center-box .amount { font-size: 30px; font-weight: 700; color: var(--ink); margin: 10px 0 4px; }
.center-box .tip { font-size: 13px; color: var(--ink3); line-height: 1.7; }

.receipt {
  background: var(--soft); border-radius: var(--radius);
  padding: 12px 14px; margin-top: 18px; text-align: left;
}
.receipt .kv { padding: 5px 0; font-size: 12.5px; }
.receipt .k { color: var(--ink3); }
.receipt .v { color: var(--ink); text-align: right; max-width: 62%; word-break: break-all; }

.spin {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid rgba(22, 119, 255, .18); border-top-color: var(--brand);
  animation: spin .8s linear infinite; margin: 0 auto 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- 富文本 / 关于我们 ---------------- */
.about-hero {
  background: linear-gradient(120deg, #1677ff, #4d9bff);
  color: #fff; padding: 26px 20px 24px;
}
.about-hero .logo {
  width: 52px; height: 52px; border-radius: 14px; background: rgba(255, 255, 255, .2);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700; margin-bottom: 12px;
}
.about-hero h2 { margin: 0 0 6px; font-size: 19px; }
.about-hero p { margin: 0; font-size: 12.5px; opacity: .92; }

.info-row {
  display: flex; gap: 10px; padding: 11px 0;
  border-bottom: 1px dashed var(--line); font-size: 13.5px;
}
.info-row:last-child { border-bottom: 0; }
.info-row .k { flex: 0 0 84px; color: var(--ink3); }
.info-row .v { flex: 1; color: var(--ink); word-break: break-all; }
.info-row .v a { color: var(--brand-d); }

.para { font-size: 13.5px; color: var(--ink2); line-height: 1.85; margin: 0 0 10px; }
.para:last-child { margin-bottom: 0; }
.para b { color: var(--ink); }

.num-list { margin: 0; padding-left: 20px; font-size: 13px; color: var(--ink2); line-height: 1.9; }

/* 页脚 */
.footer {
  padding: 22px 18px 26px; background: var(--soft);
  text-align: center; font-size: 11.5px; color: var(--ink3); line-height: 1.9;
}
.footer .fnav { display: flex; justify-content: center; gap: 14px; margin-bottom: 10px; flex-wrap: wrap; }
.footer .fnav a { color: var(--ink2); }
.footer .badge-line { margin-top: 8px; }

/* 空状态 */
.empty { padding: 70px 20px; text-align: center; color: var(--ink3); }
.empty .ico { font-size: 44px; margin-bottom: 10px; opacity: .5; }
.empty p { margin: 0 0 16px; font-size: 13.5px; }

/* 提示条 */
.bar-tip {
  display: flex; align-items: center; gap: 8px;
  background: #fff8ec; color: #a16207; font-size: 12px;
  padding: 9px 14px; border-bottom: 1px solid #fdf1d9;
}
.bar-tip.blue { background: var(--brand-l); color: var(--brand-d); border-bottom-color: #dce9ff; }

/* 弹层 */
.mask {
  position: fixed; inset: 0; background: rgba(17, 24, 39, .5);
  z-index: 90; display: flex; align-items: flex-end; justify-content: center;
}
.mask.hide { display: none; }
.sheet {
  width: 100%; max-width: 750px; background: #fff;
  border-radius: 16px 16px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  animation: up .22s ease;
}
@keyframes up { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet h3 { margin: 0 0 14px; font-size: 16px; text-align: center; }
.sheet .opt {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 4px; border-bottom: 1px solid var(--line); font-size: 14px;
}
.sheet .opt.sel { color: var(--brand); font-weight: 600; }

.toast {
  position: fixed; left: 50%; top: 45%; transform: translate(-50%, -50%);
  background: rgba(17, 24, 39, .86); color: #fff; font-size: 13.5px;
  padding: 10px 18px; border-radius: 8px; z-index: 200; opacity: 0;
  transition: opacity .2s; pointer-events: none; max-width: 78%; text-align: center;
}
.toast.show { opacity: 1; }

@media (max-width: 360px) {
  .grid { gap: 8px; padding-left: 10px; padding-right: 10px; }
  .pcard .name { font-size: 12.5px; }
}

/* ---------------- 页面级微调 ---------------- */

/* 关键修复：网格/弹性子项允许收缩到 0，
   防止「white-space:nowrap 的副标题」「长商品名」把卡片撑宽导致整页横向溢出 */
.grid > * { min-width: 0; }
.pcard, .pcard .body { min-width: 0; }
.cart-item .mid, .order-line .mid { min-width: 0; }

/* 购物车页：结算条悬浮在底部导航之上，两者不重叠 */
body[data-page='cart'] .cart-bar { bottom: 58px; }
body[data-page='cart'] .page { padding-bottom: 148px; }

/* 收银台 / 支付结果页没有底部操作条，去掉预留空白 */
body[data-page='pay'] .page,
body[data-page='result'] .page { padding-bottom: 24px; }
