/* ==========================================================================
   产品中心（products.html）与产品详情（product.html）
   ========================================================================== */

/* ---------- 工具栏：类型切换、搜索、视图切换 ---------- */
.toolbar {
  position: sticky;
  top: var(--hdr);
  z-index: 30;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.toolbar .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 28px;
  min-height: 68px;
  padding-block: 10px;
}

.seg {
  display: flex;
  gap: 26px;
  max-width: 100%;
  overflow-x: auto;
}

.seg button {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 20px 0;
  border: 0;
  background: none;
  font-family: var(--label);
  font-size: 15px;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
}

.seg button .n {
  font: 300 12px var(--num);
  color: var(--faint);
}

.seg button[aria-pressed='true'] {
  color: var(--ink);
}

.seg button[aria-pressed='true']::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  height: 1px;
  background: var(--brand);
}

.tsearch {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
  height: 44px;
  border-bottom: 1px solid var(--line);
}

.tsearch:focus-within {
  border-color: var(--ink);
}

.tsearch svg {
  width: 18px;
  height: 18px;
  color: var(--muted);
}

.tsearch input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: none;
  font-size: 15px;
}

.view-toggle {
  display: flex;
  gap: 20px;
}

.view-toggle button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border: 0;
  background: none;
  font-family: var(--label);
  font-size: 14px;
  color: var(--muted);
}

.view-toggle button svg {
  width: 16px;
  height: 16px;
}

.view-toggle button[aria-pressed='true'] {
  color: var(--ink);
}

/* ---------- 目录：左侧筛选 + 右侧结果 ---------- */
.catalog {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  align-items: start;
  gap: 56px;
  padding-block: 40px 120px;
}

.catalog > * {
  min-width: 0;
}

.filters {
  position: sticky;
  top: calc(var(--hdr) + 92px);
  display: grid;
  max-height: calc(100vh - var(--hdr) - 110px);
  overflow: auto;
  border-top: 1px solid var(--ink);
}

/* 手机筛选面板的标题栏 */
.sheet-head {
  display: none;
}

.fgroup {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.fgroup summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0 10px;
  font-family: var(--label);
  font-size: 14px;
  letter-spacing: 0.04em;
  color: var(--ink);
  list-style: none;
  cursor: pointer;
}

.fgroup summary::-webkit-details-marker {
  display: none;
}

.fgroup summary::after {
  content: '+';
  font: 300 18px var(--num);
  color: var(--muted);
}

.fgroup[open] summary::after {
  content: '−';
}

.fopt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  font-family: var(--label);
  font-size: 14px;
  color: var(--ink-2);
  cursor: pointer;
}

.fopt:hover {
  color: var(--ink);
}

.fopt input {
  appearance: none;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  margin: 0;
  border: 1px solid #b9bec6;
}

.fopt input:checked {
  background: var(--ink);
  border-color: var(--ink);
}

.fopt input:checked::after {
  content: '';
  width: 7px;
  height: 4px;
  border-left: 1.5px solid #fff;
  border-bottom: 1.5px solid #fff;
  transform: rotate(-45deg) translate(1px, -1px);
}

.fopt .c {
  margin-left: auto;
  font: 300 12px var(--num);
  color: var(--faint);
}

.filters-toggle {
  display: none;
}

/* 结果栏：数量、已选条件 */
.result-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.result-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.result-bar .count {
  font-size: 14px;
  color: var(--muted);
}

.result-bar .count b {
  margin-right: 4px;
  font: 300 22px var(--num);
  color: var(--ink);
}

.chips-active {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chips-active button {
  padding: 3px 10px;
  border: 1px solid var(--line);
  background: none;
  font-size: 12px;
  color: var(--ink-2);
}

.chips-active button:hover {
  border-color: var(--ink);
}

/* ---------- 产品表格（列表视图、详情页同项目产品） ---------- */
.ptable-wrap {
  overflow-x: auto;
  border-top: 1px solid var(--ink);
}

.ptable {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
  font-size: 14px;
}

.ptable th {
  padding: 16px 16px 16px 0;
  border-bottom: 1px solid var(--line);
  font-family: var(--label);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-align: left;
  color: var(--muted);
  white-space: nowrap;
}

.ptable td {
  padding: 18px 16px 18px 0;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.ptable tbody tr {
  transition: background 0.2s;
}

.ptable tbody tr:hover {
  background: var(--bg-2);
}

.ptable .sku {
  font: 400 13px var(--mono);
  color: var(--ink);
  white-space: nowrap;
}

.ptable .nm a {
  color: var(--ink);
}

.ptable .nm a:hover {
  color: var(--brand);
}

.ptable .nm small {
  display: block;
  margin-top: 2px;
  font: 12px var(--mono);
  color: var(--muted);
}

.ptable .pair {
  font: 12px var(--mono);
  color: var(--ok);
  white-space: nowrap;
}

.ptable-compact {
  min-width: 600px;
}

/* 表格中的“询价”按钮 */
.add {
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: #fff;
  font-family: var(--label);
  font-size: 13px;
  white-space: nowrap;
  transition:
    border-color 0.2s,
    background 0.2s,
    color 0.2s;
}

.add:hover {
  border-color: var(--ink);
}

.add.in {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.more {
  display: flex;
  justify-content: center;
  padding: 40px 0 0;
}

.empty {
  padding: 64px 0;
  text-align: center;
  color: var(--muted);
}

/* ---------- 按检测项目视图 ---------- */
.groups {
  display: grid;
  gap: 40px;
}

.group {
  border-top: 1px solid var(--ink);
}

.group-head {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px;
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}

.group-head img {
  width: 80px;
  height: 80px;
  object-fit: cover;
}

.group-head .code {
  font: 200 30px/1.1 var(--num);
  color: var(--ink);
}

.group-head .cn {
  margin-top: 4px;
  font-size: 14px;
  color: var(--ink-2);
}

.group-head .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.g-row,
.g-pair {
  display: grid;
  grid-template-columns: 110px 120px minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line-2);
  font-size: 14px;
}

.g-pair {
  grid-template-columns: 110px minmax(0, 1fr) auto;
}

.g-row .role,
.g-pair .role {
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.g-row .role.ag {
  color: var(--brand);
}

.g-pair .role-pair {
  font-weight: 600;
  color: var(--ok);
}

.g-row .sku {
  font: 400 13px var(--mono);
  color: var(--ink);
}

.g-row a.nm {
  color: var(--ink);
}

.g-row a.nm:hover {
  color: var(--brand);
}

.g-row a.nm small {
  margin-left: 10px;
  font: 12px var(--mono);
  color: var(--muted);
}

.g-pair .pp {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.g-pair .pp a {
  border-bottom: 1px solid var(--line);
  font: 400 13px var(--mono);
  color: var(--ink);
}

.g-pair .pp a:hover {
  color: var(--brand);
  border-color: var(--brand);
}

.g-pair .pp i {
  font-size: 12px;
  font-style: normal;
  color: var(--muted);
}

.g-more {
  padding: 14px 0 0;
}

.g-more button {
  padding: 0;
  border: 0;
  background: none;
  font-size: 13px;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* ---------- 产品详情 ---------- */
.pd {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  align-items: start;
  gap: 64px;
  padding-block: 16px 120px;
}

.pd > * {
  min-width: 0;
}

.pd-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: stretch;
  gap: 56px;
}

.pd-visual {
  position: relative;
  max-width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--dark);
}

.pd-visual img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pd-visual .sku-badge {
  position: absolute;
  left: 20px;
  bottom: 18px;
  font: 400 12px var(--mono);
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.75);
}

.pd-info {
  display: grid;
  align-content: end;
  gap: 18px;
}

.pd-info h1 {
  font-size: clamp(32px, 3.4vw, 48px);
  line-height: 1.25;
  letter-spacing: -0.03em;
}

.pd-info .abbr {
  font: 300 18px var(--mono);
  color: var(--muted);
}

.pd-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.kv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
  border-top: 1px solid var(--ink);
}

.kv-grid div {
  display: grid;
  gap: 2px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.kv-grid div:nth-child(odd) {
  padding-right: 16px;
}

.kv-grid span {
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.kv-grid b {
  font-size: 15px;
  font-weight: 400;
  color: var(--ink);
}

/* 右侧询价面板 */
.panel {
  position: sticky;
  top: calc(var(--hdr) + 24px);
  display: grid;
  gap: 18px;
  padding-top: 24px;
  border-top: 1px solid var(--ink);
}

.panel .row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.panel .row b {
  font-weight: 400;
  color: var(--ink);
}

/* 标签页 */
.tabs {
  display: flex;
  gap: 36px;
  margin-top: 72px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tabs button {
  margin-bottom: -1px;
  padding: 16px 0;
  border: 0;
  border-bottom: 1px solid transparent;
  background: none;
  font-size: 16px;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
}

.tabs button[aria-selected='true'] {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

.tab-panel {
  padding-top: 32px;
}

.spec {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.spec th,
.spec td {
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.spec th {
  width: 28%;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.spec td {
  color: var(--ink);
}

.spec-note {
  margin-top: 14px;
}

/* 同项目产品 */
.rel-title {
  margin-bottom: 12px;
}

.rel-more {
  margin: 28px 0 12px;
}

.rel-link {
  margin-top: 18px;
}

.pair-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 22px 0;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--line);
}

.pair-card .ab {
  display: grid;
  gap: 2px;
}

.pair-card .ab span {
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.pair-card .ab a {
  font: 400 17px var(--mono);
  color: var(--ink);
}

.pair-card .ab a:hover {
  color: var(--brand);
}

.pair-card .ab small {
  font-size: 12px;
  color: var(--muted);
}

.pair-card .j {
  display: grid;
  place-items: center;
  color: var(--faint);
}

.pair-card .j svg {
  width: 40px;
  height: 16px;
}

/* 手机底部操作栏（产品详情） */
.m-pbar {
  display: none;
}

/* ---------- 响应式 ---------- */
@media (max-width: 1100px) {
  .pd {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1024px) {
  .catalog {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .filters {
    position: static;
    display: none;
    max-height: none;
  }

  .filters.open {
    display: grid;
  }

  .filters-toggle {
    display: inline-flex;
  }
}

@media (max-width: 760px) {
  /* 工具栏：吸在页头下方，搜索与视图切换一行，类型切换为横向滑动的胶囊 */
  .toolbar {
    top: 66px;
  }

  .toolbar .wrap {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 10px 12px;
    min-height: 0;
    background: #fff;
  }

  .toolbar .tsearch {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
    height: 42px;
  }

  .toolbar .view-toggle {
    grid-column: 2 / 4;
    grid-row: 1;
    gap: 12px;
  }

  .toolbar .view-toggle button {
    gap: 0;
    padding: 8px;
    font-size: 0;
  }

  .toolbar .view-toggle button svg {
    width: 20px;
    height: 20px;
  }

  .toolbar .seg {
    grid-column: 1 / -1;
    grid-row: 2;
    gap: 8px;
    margin-inline: -20px;
    padding: 0 20px;
    scrollbar-width: none;
  }

  .toolbar .seg::-webkit-scrollbar {
    display: none;
  }

  .toolbar .seg button {
    padding: 7px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 13px;
  }

  .toolbar .seg button[aria-pressed='true'] {
    background: var(--ink);
    border-color: var(--ink);
    color: #fff;
  }

  .toolbar .seg button[aria-pressed='true']::after {
    display: none;
  }

  .toolbar .seg button[aria-pressed='true'] .n {
    color: rgba(255, 255, 255, 0.7);
  }

  .catalog {
    padding-block: 16px 60px;
  }

  /* 筛选：从底部弹出的面板 */
  .filters,
  .filters.open {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    z-index: 95;
    display: block;
    max-height: 78vh;
    padding: 0 20px calc(env(safe-area-inset-bottom, 0px) + 24px);
    overflow: auto;
    border: 0;
    border-radius: 20px 20px 0 0;
    background: #fff;
    box-shadow: 0 -20px 60px -20px rgba(var(--shade), 0.35);
    transform: translateY(105%);
    transition: transform 0.4s var(--ease);
  }

  .filters.open {
    transform: none;
  }

  .filters .sheet-head {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 0 14px;
    border-bottom: 1px solid var(--ink);
    background: #fff;
  }

  .filters .sheet-head b {
    font: 400 22px var(--head);
    color: var(--ink);
  }

  .sheet-scrim {
    position: fixed;
    inset: 0;
    z-index: 94;
    background: rgba(var(--shade), 0.4);
    opacity: 0;
    visibility: hidden;
    transition:
      opacity 0.3s,
      visibility 0.3s;
  }

  .sheet-scrim.open {
    opacity: 1;
    visibility: visible;
  }

  .result-bar {
    margin: 10px 0 8px;
    padding: 8px 0;
    background: #fff;
  }

  /* 产品表格改为两行卡片：货号 · 类型 · 用途 / 名称 · 缩写，右侧询价 */
  .ptable-wrap {
    overflow: visible;
    border-top: 0;
  }

  .ptable,
  .ptable tbody {
    display: block;
    min-width: 0;
  }

  .ptable-compact {
    min-width: 600px;
  }

  .ptable thead {
    display: none;
  }

  .ptable tr {
    display: grid;
    grid-template-columns: auto auto auto minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    align-items: center;
    gap: 6px;
    padding: 16px 0;
    border-bottom: 1px solid var(--line);
  }

  .ptable tbody tr:hover {
    background: none;
  }

  .ptable td {
    display: block;
    padding: 0;
    border: 0;
  }

  .ptable td.sku {
    grid-column: 1;
    grid-row: 1;
    margin-right: 4px;
    font-size: 12px;
    color: var(--muted);
  }

  .ptable td:nth-child(3) {
    grid-column: 2;
    grid-row: 1;
  }

  .ptable td:nth-child(4) {
    display: none;
  }

  .ptable td:nth-child(5) {
    grid-column: 3;
    grid-row: 1;
    display: flex;
    gap: 4px;
  }

  .ptable td.nm {
    grid-column: 1 / 5;
    grid-row: 2;
  }

  .ptable td.nm a {
    font-size: 16px;
    line-height: 1.4;
  }

  .ptable td.nm small {
    display: inline;
    margin: 0 0 0 8px;
    font-size: 12px;
  }

  .ptable td:nth-child(6) {
    grid-column: 1 / 5;
    grid-row: 3;
  }

  /* 没有用途 / 没有配对时整格隐藏 */
  .ptable td:nth-child(5):has(.small:only-child),
  .ptable td:nth-child(6):has(.small:only-child) {
    display: none;
  }

  .ptable td:last-child {
    grid-column: 5;
    grid-row: 1 / 3;
    align-self: center;
  }

  .ptable .tag {
    height: 20px;
    padding: 0 6px;
    font-size: 11px;
  }

  .ptable .add {
    height: 36px;
    padding: 0 16px;
    border-radius: 999px;
  }

  /* 按检测项目视图：与列表卡片统一 */
  .groups {
    gap: 28px;
  }

  .group-head {
    grid-template-columns: 56px minmax(0, 1fr);
    gap: 14px;
  }

  .group-head img {
    width: 56px;
    height: 56px;
  }

  .group-head .code {
    font-size: 24px;
  }

  .g-row {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    gap: 6px 10px;
    padding: 14px 0;
  }

  .g-row .role {
    grid-column: 1;
    grid-row: 1;
  }

  .g-row .sku {
    grid-column: 2;
    grid-row: 1;
  }

  .g-row a.nm {
    grid-column: 1 / 3;
    grid-row: 2;
    font-size: 15px;
    line-height: 1.4;
  }

  .g-row a.nm small {
    margin-left: 8px;
  }

  .g-row > :last-child {
    grid-column: 3;
    grid-row: 1 / 3;
    align-self: center;
    width: auto;
  }

  .g-pair {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    gap: 6px 10px;
    padding: 14px 0;
  }

  .g-pair .role {
    grid-column: 1;
    grid-row: 1;
  }

  .g-pair .pp {
    grid-column: 1;
    grid-row: 2;
  }

  .g-pair > :last-child {
    grid-column: 2;
    grid-row: 1 / 3;
    align-self: center;
    width: auto;
  }

  /* 产品详情：隐藏右侧面板，改用底部操作栏 */
  .pd {
    gap: 0;
    padding-block: 0 40px;
  }

  .pd-hero {
    grid-template-columns: 1fr;
    gap: 22px;
  }

  .pd-visual {
    aspect-ratio: 4 / 3;
  }

  .pd-info h1 {
    font-size: 32px;
  }

  .panel {
    display: none;
  }

  .tabs {
    margin-top: 40px;
  }

  body.has-pbar {
    padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  }

  body.has-pbar .m-bar {
    display: none;
  }

  .m-pbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 70;
    display: grid;
    grid-template-columns: 52px 1fr 1fr;
    gap: 10px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.98);
  }

  .m-pbar .btn {
    height: 50px;
    padding: 0 10px;
    font-size: 14px;
  }

  .m-pbar .ib {
    position: relative;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: var(--ink);
  }

  .m-pbar .ib svg {
    width: 22px;
    height: 22px;
  }

  .m-pbar .badge {
    top: -4px;
    right: -2px;
  }
}

@media (max-width: 700px) {
  .group-head .add-all {
    grid-column: 1 / -1;
    justify-self: start;
  }
}

@media (max-width: 640px) {
  .pair-card {
    grid-template-columns: 1fr;
  }

  .pair-card .j {
    display: none;
  }
}
