:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #1f2330;
  --ink-soft: #6b7280;
  --line: #e6e8ec;
  --brand: #e1457b;
  --brand-2: #7c3aed;
  --accent: #ff7aa8;
  --ok: #16a34a;
  --warn: #d97706;
  --shadow: 0 6px 24px rgba(20, 23, 40, .08);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

/* 顶部 */
.topbar {
  background: linear-gradient(120deg, var(--brand), var(--brand-2));
  color: #fff;
  position: sticky; top: 0; z-index: 30;
  box-shadow: var(--shadow);
}
.topbar-inner {
  max-width: 1240px; margin: 0 auto; padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 42px; height: 42px; border-radius: 10px; object-fit: contain; background: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 20px;
}
.brand-name { font-weight: 800; font-size: 18px; }
.brand-sub { font-size: 12px; opacity: .85; }
.topbar-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.contact { font-size: 13px; opacity: .92; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  border: none; border-radius: 10px; padding: 9px 16px; font-size: 14px; font-weight: 600;
  text-decoration: none; transition: filter .15s ease;
}
.btn-primary { background: #fff; color: var(--brand); }
.btn-primary:hover { filter: brightness(.96); }
.btn-ghost { background: rgba(255,255,255,.16); color:#fff; }
.btn-line { background: var(--brand); color:#fff; }
.btn-line:hover { filter: brightness(1.05); }
.btn-soft { background: #fff; color: var(--brand); border: 1px solid var(--line); }

/* 工具栏 */
.toolbar { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 70px; z-index: 20; }
.toolbar-inner {
  max-width: 1240px; margin: 0 auto; padding: 12px 20px;
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
}
.search-box { flex: 1 1 260px; }
.search-box input {
  width: 100%; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; outline: none;
}
.search-box input:focus { border-color: var(--brand); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; }
.filters select {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; background: #fff; cursor: pointer;
}

/* 统计条 */
.stat-bar { max-width: 1240px; margin: 14px auto 0; padding: 0 20px; color: var(--ink-soft); font-size: 13px; }

/* 网格 */
.grid {
  max-width: 1240px; margin: 14px auto 40px; padding: 0 20px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px;
}
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  cursor: default; transition: transform .12s ease, box-shadow .15s ease; display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }

/* === R-13/R-18：卡片顶部 = 280×280 主图 + 缩略图条（手动点击切图，不轮播） === */
.card-img {
  position: relative; background: #eef0f3;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 8px 6px 4px;
}
.card-img-el { width: 100%; height: 280px; object-fit: cover; background: #eef0f3; display: block; }
.card-img-el.ph { display: flex; align-items: center; justify-content: center; color: #b7bdc7; font-weight: 700; font-size: 26px; }
.card-thumbs { display: flex; gap: 6px; padding-bottom: 6px; justify-content: center; flex-wrap: wrap; }
.card-thumbs img {
  width: 40px; height: 40px; object-fit: cover; border-radius: 6px;
  background: #eef0f3; cursor: pointer; border: 2px solid transparent;
}
.card-thumbs img.active { border-color: var(--brand); }
.card-thumbs img:hover { filter: brightness(.96); }

.card-body { padding: 12px 13px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-cat { font-size: 11px; color: var(--brand); font-weight: 700; letter-spacing: .3px; }
.card-name { font-size: 14px; font-weight: 700; line-height: 1.35; }
.card-drive { margin: 1px 0 0; }
.drive-badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; color: #fff; line-height: 1.5; }
.drv-电动 { background: #2f7be0; }
.drv-手动 { background: #f0821a; }
.drv-手动电动 { background: #8a3fd0; }
.drv-气动 { background: #16a085; }
.drv-智能 { background: #e0457b; }
.drv-其他 { background: #9aa0a6; }
.card-desc { font-size: 13px; color: var(--ink-soft); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 2px; }
.tag { font-size: 11px; background: #fbe9f1; color: var(--brand); padding: 2px 8px; border-radius: 999px; }
.card-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; padding-top: 8px; }
.price { color: #e11d48; font-weight: 800; font-size: 17px; }
.price small { font-size: 11px; color: var(--ink-soft); font-weight: 500; }
.stock { font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.stock.ok { background: #e7f6ec; color: var(--ok); }
.stock.soon { background: #fef3e2; color: var(--warn); }
.stock.custom { background: #eef2ff; color: var(--brand-2); }

.btn-detail {
  width: 100%; cursor: pointer; border: 1px solid var(--brand); background: #fff; color: var(--brand);
  border-radius: 9px; padding: 8px; font-size: 13px; font-weight: 700; transition: background .12s ease;
}
.btn-detail:hover { background: #fdeef4; }

.empty { text-align: center; color: var(--ink-soft); padding: 60px 20px; grid-column: 1 / -1; }

/* R-25：分页 */
.pagination {
  max-width: 1240px; margin: -20px auto 44px; padding: 0 20px;
  display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap;
}
.pg-btn {
  min-width: 36px; height: 36px; padding: 0 12px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 9px; font-size: 13px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.pg-btn:hover:not(:disabled):not(.active) { border-color: var(--brand); color: var(--brand); }
.pg-btn:disabled { opacity: .4; cursor: not-allowed; }
.pg-num.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.pg-gap { color: var(--ink-soft); padding: 0 2px; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,17,28,.55); z-index: 50;
  display: grid; place-items: center; padding: 20px;
}
.modal-mask[hidden] { display: none; }
.modal {
  background: #fff; border-radius: 18px; max-width: 920px; width: 100%; max-height: 90vh; overflow: auto;
  position: relative; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-close {
  position: absolute; top: 12px; right: 14px; width: 36px; height: 36px; border-radius: 50%; border: none;
  background: rgba(255,255,255,.9); font-size: 22px; cursor: pointer; z-index: 2; color: #333;
}
.modal-body { display: grid; grid-template-columns: 1.1fr 1fr; gap: 0; }
@media (max-width: 720px) { .modal-body { grid-template-columns: 1fr; } }

/* === R-17：左侧栏（gallery + 品牌信息/功能特征） === */
.left-col { display: flex; flex-direction: column; gap: 14px; padding: 16px 16px 20px; background: #fff; }
/* === R-18：左侧栏不对称内缩，左 24 / 右 16，让板块向右挪一点、避免靠边 === */
@media (max-width: 720px) {
  .left-col { padding: 16px 16px 20px 24px; }
}
.left-col .gallery { border-radius: 10px; overflow: hidden; }
/* 第一个 info-block 紧贴 gallery，去掉上方分隔线 */
.left-col .info-block:first-child { border-top: none; padding-top: 0; margin-top: 0; }

/* === R-8：gallery-main 改为 <img>，根治鼠标慢 === */
/* contain: paint 隔离重绘区域；max-width/max-height 用具体值避免持续栅格化 */
.gallery { background: #f2f3f6; contain: layout paint; }
.gallery-main {
  display: block; width: auto; height: auto; max-width: 480px; max-height: 480px;
  margin: 0 auto; object-fit: contain; background: #eef0f3; image-rendering: auto;
  -webkit-user-drag: none; user-select: none;
}
.gallery-main.ph { aspect-ratio: 1/1; max-width: 100%; }
.gallery-thumbs { display: flex; gap: 8px; padding: 10px; flex-wrap: wrap; }
.gallery-thumbs img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; cursor: pointer; border: 2px solid transparent; }
.gallery-thumbs img.active { border-color: var(--brand); }

.detail { padding: 22px 22px 24px; display: flex; flex-direction: column; gap: 12px; }
.detail h2 { margin: 0; font-size: 20px; }
.detail .d-cat { color: var(--brand); font-weight: 700; font-size: 12px; }
.detail .d-price { font-size: 26px; color: #e11d48; font-weight: 800; }
.detail .d-price small { font-size: 13px; color: var(--ink-soft); font-weight: 500; margin-left: 6px; }
.spec-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.spec-table td { padding: 7px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.spec-table td:first-child { color: var(--ink-soft); width: 92px; }
.d-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.d-desc { font-size: 13px; color: #374151; background: #fafafa; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.d-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.d-actions .btn { flex: 1 1 auto; justify-content: center; }

.footer { max-width: 1240px; margin: 0 auto; padding: 24px 20px 40px; color: var(--ink-soft); font-size: 12px; text-align: center; }
.footer-note { margin-top: 6px; opacity: .8; }

/* === R-3：卡片双段价格（无起订量） === */
.price-row { display: flex; flex-direction: column; gap: 2px; }
.pr { display: flex; align-items: baseline; gap: 6px; }
.pr-l { font-size: 11px; color: var(--ink-soft); flex: 0 0 auto; }
.pr-v { font-size: 16px; font-weight: 800; color: #e11d48; }
.pr-v.muted { color: #94a3b8; font-size: 14px; font-weight: 600; }
.pr.sub .pr-v { color: var(--warn); font-size: 14px; }

/* === R-4 / R-12：详情弹窗加购按钮（置顶橙底；R-12 后只展示一行"+ 加入采购单（X）"，无产品级 dec） === */
.card-foot { margin-top: auto; padding-top: 8px; }
.add-cart-wrap { display: flex; gap: 6px; width: 100%; }
.add-cart { flex: 1; cursor: pointer; border: 1px solid var(--brand); background: #fff; color: var(--brand); border-radius: 9px; padding: 9px 8px; font-size: 14px; font-weight: 700; transition: background .12s ease; }
.add-cart:hover { background: #fdeef4; }
.add-cart.in { background: var(--brand); color: #fff; }
.detail-add { padding: 10px 8px; font-size: 15px; }

/* === 采购单抽屉 === */
.cart-mask { position: fixed; inset: 0; background: rgba(15,17,28,.5); z-index: 60; display: grid; justify-items: end; }
.cart-mask[hidden] { display: none; }
.cart-drawer { width: min(440px, 92vw); height: 100%; background: #fff; display: flex; flex-direction: column; box-shadow: -10px 0 40px rgba(0,0,0,.25); }
.cart-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); font-weight: 800; font-size: 17px; }
.cart-close { width: 34px; height: 34px; border-radius: 50%; border: none; background: #f1f2f5; font-size: 20px; cursor: pointer; color: #333; }
.cart-list { flex: 1; overflow: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.cart-empty { text-align: center; color: var(--ink-soft); padding: 50px 10px; }
.cart-row { display: grid; grid-template-columns: 56px 1fr auto 34px; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.ci-thumb { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: #eef0f3; display: grid; place-items: center; color: #b7bdc7; font-size: 14px; }
.ci-info { min-width: 0; }
.ci-name { font-weight: 700; font-size: 14px; line-height: 1.3; }
.ci-model { font-size: 11px; color: #94a3b8; margin-top: 2px; }
.ci-price { font-size: 12px; color: var(--ink-soft); margin-top: 3px; }
.ci-qty { display: flex; align-items: center; gap: 4px; }
.qbtn { width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 15px; color: var(--ink); }
.qinput { width: 42px; height: 26px; border: 1px solid var(--line); border-radius: 7px; text-align: center; font-size: 13px; }
.ci-del { border: none; background: transparent; cursor: pointer; font-size: 16px; }
.cart-foot { border-top: 1px solid var(--line); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.cart-sum { font-size: 13px; color: var(--ink-soft); }
.cart-sum b { color: var(--ink); font-size: 15px; }
.cart-ops { display: flex; gap: 8px; flex-wrap: wrap; }
.cart-ops .btn { flex: 1 1 auto; justify-content: center; padding: 10px 8px; }

/* === R-7：地址抽屉 === */
.addr-mask { position: fixed; inset: 0; background: rgba(15,17,28,.5); z-index: 70; display: grid; justify-items: end; }
.addr-mask[hidden] { display: none; }
.addr-drawer { width: min(440px, 92vw); height: 100%; background: #fff; display: flex; flex-direction: column; box-shadow: -10px 0 40px rgba(0,0,0,.25); }
.addr-body { flex: 1; overflow: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.addr-body label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 700; color: var(--ink); }
.addr-body input, .addr-body textarea {
  border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; font-size: 14px; font-family: inherit; outline: none; font-weight: 400;
}
.addr-body input:focus, .addr-body textarea:focus { border-color: var(--brand); }
.addr-body select {
  border: 1px solid var(--line); border-radius: 9px; padding: 10px 10px; font-size: 14px; font-family: inherit; outline: none; font-weight: 400;
  background: #fff; color: var(--ink); cursor: pointer;
}
.addr-body select:focus { border-color: var(--brand); }
.addr-region { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.addr-smart { display: flex; flex-direction: column; gap: 6px; }
.addr-smart-label { font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.addr-smart-row { display: flex; gap: 8px; }
.addr-smart-row input { flex: 1; }
.addr-smart-row .btn { flex-shrink: 0; white-space: nowrap; }

/* === 详情弹窗价格/规格/参数 === */
.d-prices { display: flex; flex-direction: column; gap: 6px; }
.dp { display: flex; align-items: baseline; gap: 8px; background: #fff7fa; border: 1px solid #fde0ec; border-radius: 10px; padding: 8px 12px; }
.dp-l { font-size: 13px; color: var(--brand); font-weight: 700; }
.dp-v { font-size: 22px; font-weight: 800; color: #e11d48; }
.block-title { font-size: 12px; font-weight: 800; color: var(--ink-soft); letter-spacing: .5px; margin-bottom: 6px; }
.spec-block, .param-block { border-top: 1px solid var(--line); padding-top: 12px; }
.d-cfg-row { font-size: 13px; color: var(--ink-soft); border-top: 1px solid var(--line); padding-top: 12px; }
.dl-pack { width: 100%; justify-content: center; }

/* === R-6：规格 5 列表格（规格/条形码/价格/限价/数量） === */
.spec-grid { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
/* R-21：超长规格表（如 26 规格）加滚动容器，避免撑爆弹窗；表头吸顶 */
.spec-scroll { max-height: 340px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; }
.spec-grid thead th { position: sticky; top: 0; background: #fff; z-index: 1; }
.spec-grid th { text-align: left; color: var(--ink-soft); font-size: 12px; font-weight: 700; padding: 6px 6px; border-bottom: 2px solid var(--line); }
.spec-grid th:nth-child(1) { width: 24%; }  /* 规格 */
.spec-grid th:nth-child(2) { width: 16%; }  /* 条形码 */
.spec-grid th:nth-child(3) { width: 16%; }  /* 价格 */
.spec-grid th:nth-child(4) { width: 9%; }   /* 限价 */
.spec-grid th:nth-child(5) { width: 11%; }  /* 重量 */
.spec-grid th:nth-child(6) { width: 12%; }  /* 尺寸 */
.spec-grid th:nth-child(7) { width: 12%; }  /* 数量 */
.spec-grid td { padding: 7px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; word-break: break-all; }
.spec-grid td.sg { font-weight: 600; }
.spec-grid td.sb, .spec-grid td.sp, .spec-grid td.sw, .spec-grid td.sd { color: var(--ink-soft); }
.spec-grid td.sq { white-space: nowrap; }
.spec-grid .rq { width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 14px; color: var(--ink); }
.spec-grid .rqn {
  width: 48px; height: 28px; margin: 0 4px; border: 1px solid #d6dbe0; border-radius: 6px;
  text-align: center; font-weight: 700; font-size: 13px; color: var(--ink); background: #fff;
  padding: 4px 6px; outline: none;
}
.spec-grid .rqn:focus { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(225,29,72,.18); }
.spec-grid .rqn::-webkit-outer-spin-button,
.spec-grid .rqn::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.spec-grid .rqn { -moz-appearance: textfield; }
/* 实时随数量切换的价格 cell */
.spec-grid td.sp .spv { font-size: 14px; font-weight: 800; color: var(--ink); margin-right: 6px; }
.spec-grid td.sp .spv.ph { color: #b8bec6; font-weight: 500; }
.spec-grid td.sp .spt { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 700; vertical-align: middle; }
.spec-grid td.sp .spt[data-tier="wholesale"] { background: #fff1d6; color: #c2680a; border: 1px solid #fde0a8; }
.spec-grid td.sp .spt[data-tier="dropship"]  { background: #fdeef4; color: var(--brand); border: 1px solid #f9c4d6; }
.spec-grid td.sp .spt[data-tier="none"]      { background: transparent; color: transparent; border: none; }
/* 限价列：浅灰小字，标识「该规格零售价保底」 */
.spec-grid td.sr { color: #475569; }
.spec-grid td.sr .srv { font-size: 13px; font-weight: 700; }
.spec-grid td.sr .srv.ph { color: #b8bec6; font-weight: 500; }
.spec-hint { font-size: 12px; color: var(--ink-soft); margin-top: 6px; line-height: 1.5; }

/* === R-15 → R-19：信息块改为「分组 + 2 列紧凑网格」 === */
.info-block { border-top: 1px solid var(--line); padding-top: 12px; }
.info-block + .info-block { margin-top: 10px; }
.block-title { font-size: 12px; font-weight: 800; color: var(--ink-soft); letter-spacing: .5px; margin-bottom: 8px; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.info-grid-3 { grid-template-columns: repeat(3, 1fr); }
/* 单格：label 灰底小字 + value 主色大字号 */
.ig {
  background: #fafbfc;
  border: 1px solid #eef0f3;
  border-radius: 9px;
  padding: 7px 10px;
  min-width: 0;  /* 允许内部 word-break 撑开 */
}
.ig .il {
  font-size: 11px;
  color: var(--ink-soft);
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: 3px;
  letter-spacing: .2px;
}
.ig .iv {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.4;
  word-break: break-all;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* chip 行的 value 区不限制行数、不换行（chip 自由流动） */
.ig.ig-wide { grid-column: 1 / -1; }
.ig.ig-wide .iv {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  -webkit-line-clamp: unset;
  overflow: visible;
}
/* R-15：功能栏的 5 个 XX chip（后台 10 槽，本次测试仅显示前 5） */
.chip {
  display: inline-block;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #fdeef4;
  color: var(--brand);
  margin: 2px 4px 2px 0;
  font-weight: 600;
}
/* R-15：加入采购单按钮 R-12 后只剩一行"+ 加入采购单（X）"，无需产品级 dec */
.add-cart-wrap.full { width: 100%; }
.add-cart-wrap.full .add-cart { width: 100%; }
