/* Web 商城经营闭环：商品规格、购物车、会员订单、人工扫码付款。 */
.commerce-page {
  --commerce-success: #287a55;
  --commerce-success-bg: #edf8f2;
  --commerce-warning: #8b5a13;
  --commerce-warning-bg: #fff8e8;
  --commerce-danger-bg: #fff1ef;
  min-height: 58vh;
}

.commerce-page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.commerce-page-head h1,
.commerce-page-head p,
.commerce-panel h2,
.commerce-orders-head h2,
.commerce-orders-head p {
  margin: 0;
}

.commerce-page-head h1 {
  margin-top: 3px;
  font-size: clamp(28px, 3vw, 38px);
  line-height: 1.2;
  letter-spacing: -.02em;
}

.commerce-page-head > div > p:last-child,
.commerce-orders-head p,
.commerce-panel-head p {
  color: var(--muted);
  font-size: 14px;
}

.commerce-section-label {
  color: var(--primary);
  font-size: 14px;
  font-weight: 800;
}

.commerce-text-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 9px 0;
  color: var(--primary);
  font-weight: 800;
  white-space: nowrap;
}

.commerce-panel {
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
}

.commerce-panel-head,
.commerce-orders-head,
.commerce-member-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.commerce-panel-head {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.commerce-panel-head h2,
.commerce-orders-head h2 {
  font-size: 21px;
}

.commerce-message {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.commerce-message[data-type="success"] {
  border-color: #b9ddcb;
  background: var(--commerce-success-bg);
  color: #175f3f;
}

.commerce-message[data-type="error"] {
  border-color: #efc2bc;
  background: var(--commerce-danger-bg);
  color: var(--danger);
}

.commerce-message[data-type="warning"] {
  border-color: #ead19f;
  background: var(--commerce-warning-bg);
  color: var(--commerce-warning);
}

.commerce-loading,
.commerce-empty-state {
  display: flex;
  min-height: 170px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
  text-align: center;
}

.commerce-empty-state {
  flex-direction: column;
  padding: 30px 18px;
}

.commerce-empty-state i {
  color: var(--primary);
  font-size: 34px;
}

.commerce-empty-state h3,
.commerce-empty-state p {
  margin: 0;
}

.commerce-empty-state p {
  max-width: 480px;
  font-size: 14px;
}

.commerce-spinner {
  width: 22px;
  height: 22px;
  border: 2px solid #cfd9d5;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: commerce-spin .75s linear infinite;
}

@keyframes commerce-spin { to { transform: rotate(360deg); } }

.commerce-cart-layout,
.commerce-pay-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
  align-items: start;
  gap: 20px;
}

.commerce-checkout,
.commerce-payment-panel {
  position: sticky;
  top: 148px;
}

.commerce-cart-items {
  display: grid;
}

.commerce-source-group { min-width: 0; }
.commerce-source-group + .commerce-source-group { margin-top: 18px; }
.commerce-source-group > header { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:10px 12px; border:1px solid var(--commerce-line, #dfe4e7); border-bottom:0; background:#f5f7f6; overflow-wrap:anywhere; }
.commerce-source-group > header strong { min-width:0; overflow-wrap:anywhere; word-break:break-word; }
.commerce-source-group > header span { flex:0 0 auto; color:var(--commerce-muted, #68757d); font-size:12px; }
.commerce-source-warning { min-width:0; max-width:100%; margin-bottom:16px; padding:13px 14px; border:1px solid #d8bd8d; background:#fff8eb; color:#714f1f; overflow-wrap:anywhere; }
.commerce-source-warning p { margin:3px 0 0; }

.commerce-cart-item {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.commerce-cart-item:last-child { border-bottom: 0; }

.commerce-cart-item[data-unavailable="true"] {
  background: #fffaf5;
  color: var(--muted);
}

.commerce-product-thumb {
  width: 92px;
  height: 92px;
  overflow: hidden;
  border-radius: 10px;
  background: var(--soft);
}

.commerce-product-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.commerce-cart-copy { min-width: 0; }
.commerce-cart-copy h3 { margin: 0; font-size: 16px; line-height: 1.45; overflow-wrap: anywhere; }
.commerce-cart-copy p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.commerce-item-price { margin-top: 8px; color: var(--danger); font-size: 17px; font-weight: 900; }
.commerce-cart-controls { display: grid; justify-items: end; gap: 10px; }
.commerce-item-total { font-size: 16px; font-weight: 900; }

.commerce-quantity {
  display: inline-grid;
  grid-template-columns: 40px 50px 40px;
  height: 40px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.commerce-quantity button,
.commerce-quantity input {
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: center;
}

.commerce-quantity button { cursor: pointer; }
.commerce-quantity input { width: 50px; border-right: 1px solid var(--line); border-left: 1px solid var(--line); }

.commerce-button,
.commerce-link-button {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--primary);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.commerce-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 17px;
  border: 1px solid transparent;
}

.commerce-button-primary { background: var(--primary); color: #fff; }
.commerce-button-secondary { border-color: var(--line); background: #fff; color: var(--ink); }
.commerce-button-block { width: 100%; }
.commerce-link-button { min-height: 40px; padding: 7px 4px; }
.commerce-danger-link { color: var(--danger); }

.commerce-button:disabled,
.commerce-link-button:disabled,
.commerce-quantity button:disabled,
.commerce-quantity input:disabled {
  cursor: not-allowed;
  opacity: .52;
}

.commerce-button[data-loading="true"]::before {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: commerce-spin .75s linear infinite;
}

.commerce-form {
  display: grid;
  gap: 15px;
  margin-top: 18px;
}

.commerce-form label {
  display: grid;
  gap: 6px;
  font-size: 14px;
  font-weight: 800;
}

.commerce-form input,
.commerce-form textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid #cfd9d5;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}

.commerce-form textarea { min-height: 84px; resize: vertical; }
.commerce-optional,.commerce-field-help,.commerce-form-help { color: var(--muted); font-size: 12px; font-weight: 400; }
.commerce-form-help { margin: -4px 0 0; line-height: 1.55; }

.commerce-inline-note {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 11px;
  margin-top: 16px;
  padding: 12px;
  border: 1px solid #cdded6;
  border-radius: 10px;
  background: var(--soft);
  color: #29463e;
}

.commerce-inline-note > i { margin-top: 3px; color: var(--primary); }
.commerce-inline-note strong,.commerce-inline-note p { display: block; margin: 0; }
.commerce-inline-note p { margin-top: 2px; font-size: 13px; }
.commerce-inline-warning { border-color: #ead19f; background: var(--commerce-warning-bg); color: var(--commerce-warning); }
.commerce-inline-warning > i { color: var(--commerce-warning); }

.commerce-totals { display: grid; gap: 8px; margin: 4px 0 0; }
.commerce-totals > div { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; }
.commerce-totals dt,.commerce-totals dd { margin: 0; }
.commerce-totals dt { color: var(--muted); }
.commerce-totals dd { max-width: 65%; text-align: right; font-weight: 800; }
.commerce-total-final { padding-top: 11px; border-top: 1px solid var(--line); font-size: 17px; }
.commerce-total-final dd { color: var(--danger); font-size: 24px; }

.commerce-auth-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 430px);
  gap: 28px;
  align-items: center;
  min-height: 430px;
}

.commerce-auth-intro { padding: clamp(20px, 5vw, 54px); }
.commerce-auth-intro > i { color: var(--primary); font-size: 42px; }
.commerce-auth-intro h2 { margin: 16px 0 8px; font-size: clamp(26px, 3vw, 38px); }
.commerce-auth-intro p,.commerce-auth-intro li { color: var(--muted); }
.commerce-auth-intro ul { margin: 20px 0 0; padding-left: 20px; }
.commerce-auth-panel { padding: 26px; }

.commerce-auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  background: var(--soft);
}

.commerce-auth-tabs button {
  min-height: 42px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.commerce-auth-tabs button[aria-selected="true"] { background: #fff; color: var(--ink); }

.commerce-member-bar { margin-bottom: 24px; }
.commerce-member-identity { display: flex; align-items: center; gap: 14px; min-width: 0; }
.commerce-member-identity p,.commerce-member-identity h2,.commerce-member-identity span { display: block; margin: 0; }
.commerce-member-identity p,.commerce-member-identity span { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.commerce-member-identity h2 { font-size: 21px; }
.commerce-avatar { display: grid!important; width: 48px; height: 48px; place-items: center; flex: 0 0 auto; border-radius: 50%; background: var(--soft); color: var(--primary)!important; font-size: 20px!important; }
.commerce-orders-head { margin-bottom: 14px; }
.commerce-order-list { display: grid; gap: 14px; }
.commerce-order { padding: 0; overflow: hidden; }

.commerce-order-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfb;
}

.commerce-order-head p,.commerce-order-head strong { margin: 0; }
.commerce-order-head p { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.commerce-order-products { display: grid; gap: 12px; padding: 18px; }
.commerce-order-product { display: grid; grid-template-columns: 62px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.commerce-order-product img { width: 62px; height: 62px; border-radius: 8px; object-fit: cover; background: var(--soft); }
.commerce-order-product h3,.commerce-order-product p { margin: 0; }
.commerce-order-product h3 { font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; }
.commerce-order-product p { color: var(--muted); font-size: 12px; }
.commerce-order-product > strong { white-space: nowrap; }

.commerce-order-summary,
.commerce-order-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
}

.commerce-order-summary span { color: var(--muted); font-size: 13px; }
.commerce-order-summary strong { color: var(--danger); font-size: 20px; }
.commerce-order-progress,.commerce-tracking,.commerce-after-sale { margin: 0 18px 16px; padding: 12px; border-radius: 8px; background: var(--soft); font-size: 13px; }
.commerce-order-progress strong,.commerce-tracking strong { display: block; }
.commerce-status { display: inline-flex; align-items: center; min-height: 28px; padding: 3px 10px; border-radius: 999px; background: var(--soft); color: var(--primary); font-size: 12px; font-weight: 900; white-space: nowrap; }
.commerce-status[data-tone="warning"] { background: var(--commerce-warning-bg); color: var(--commerce-warning); }
.commerce-status[data-tone="success"] { background: var(--commerce-success-bg); color: var(--commerce-success); }
.commerce-status[data-tone="danger"] { background: var(--commerce-danger-bg); color: var(--danger); }
.commerce-after-sale summary { color: var(--primary); cursor: pointer; font-weight: 800; }
.commerce-after-sale .commerce-form { margin-top: 10px; }

.commerce-payment-methods { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.commerce-payment-method { min-height: 46px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--ink); font: inherit; font-weight: 800; cursor: pointer; }
.commerce-payment-method[aria-checked="true"] { border-color: var(--primary); background: var(--soft); color: var(--primary); }
.commerce-qr-wrap { display: grid; justify-items: center; gap: 9px; margin: 16px 0 0; }
.commerce-qr-wrap img { width: min(250px, 72vw); aspect-ratio: 1; object-fit: contain; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.commerce-qr-wrap figcaption { color: var(--muted); font-size: 13px; text-align: center; }
.commerce-payment-note { margin: 14px 0 0; padding: 11px 12px; border: 1px solid #ead19f; border-radius: 8px; background: #fffaf0; color: #684616; white-space: pre-wrap; overflow-wrap: anywhere; }
.commerce-proof-form { padding-top: 16px; border-top: 1px solid var(--line); }
.commerce-confirm-step { display: grid; grid-template-columns: auto 1fr; gap: 10px 12px; margin-top: 16px; padding: 14px; border: 1px solid #b9ddcb; border-radius: 10px; background: var(--commerce-success-bg); }
.commerce-confirm-step > i { margin-top: 3px; color: var(--commerce-success); }
.commerce-confirm-step strong,.commerce-confirm-step p { margin: 0; }
.commerce-confirm-step p { color: #3e6353; font-size: 13px; }
.commerce-confirm-step .commerce-button { grid-column: 1 / -1; }
.commerce-payment-panel > .commerce-danger-link { width: 100%; margin-top: 10px; }
.commerce-address-summary { margin: 0 18px 18px; padding: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }

.commerce-product-options { display: grid; gap: 14px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.commerce-option-row { display: grid; grid-template-columns: 72px minmax(0, 1fr); align-items: start; gap: 10px; }
.commerce-option-label { padding-top: 7px; color: var(--muted); font-size: 13px; font-weight: 800; }
.commerce-sku-list { display: flex; flex-wrap: wrap; gap: 8px; }
.commerce-sku-button { min-height: 40px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink); font: inherit; cursor: pointer; }
.commerce-sku-button[aria-pressed="true"] { border-color: var(--primary); background: var(--soft); color: var(--primary); font-weight: 800; }
.commerce-sku-button:disabled { cursor: not-allowed; opacity: .45; text-decoration: line-through; }
.commerce-product-purchase { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.commerce-product-purchase .commerce-quantity { height: 44px; }
.commerce-stock-note { color: var(--muted); font-size: 13px; }
.commerce-product-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.commerce-gallery { display: grid; gap: 10px; align-content: start; aspect-ratio: auto!important; overflow: visible!important; border-radius: 0!important; background: transparent!important; }
.commerce-gallery-main { overflow: hidden; border-radius: 16px; background: var(--soft); aspect-ratio: 1; }
.commerce-gallery-main img { width: 100%; height: 100%; object-fit: cover; }
.commerce-gallery-thumbs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.commerce-gallery-thumb { min-width: 0; padding: 0; overflow: hidden; aspect-ratio: 1; border: 2px solid transparent; border-radius: 7px; background: var(--soft); cursor: pointer; }
.commerce-gallery-thumb[aria-pressed="true"] { border-color: var(--primary); }
.commerce-gallery-thumb img { width: 100%; height: 100%; object-fit: cover; }

.commerce-button:hover:not(:disabled),
.commerce-link-button:hover:not(:disabled),
.commerce-text-link:hover { filter: brightness(.94); }

.commerce-button:focus-visible,
.commerce-link-button:focus-visible,
.commerce-text-link:focus-visible,
.commerce-form input:focus-visible,
.commerce-form textarea:focus-visible,
.commerce-quantity button:focus-visible,
.commerce-quantity input:focus-visible,
.commerce-auth-tabs button:focus-visible,
.commerce-payment-method:focus-visible,
.commerce-sku-button:focus-visible,
.commerce-gallery-thumb:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 34%, transparent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .commerce-spinner { animation-duration: 1.8s; }
}

@media (max-width: 900px) {
  .commerce-cart-layout,
  .commerce-pay-layout,
  .commerce-auth-layout { grid-template-columns: 1fr; }
  .commerce-checkout,
  .commerce-payment-panel { position: static; }
  .commerce-auth-layout { min-height: 0; }
  .commerce-auth-intro { padding: 20px 4px; }
}

@media (max-width: 560px) {
  .commerce-page { padding-top: 20px; }
  .commerce-page-head { align-items: flex-start; flex-direction: column; gap: 8px; }
  .commerce-page-head h1 { font-size: 29px; }
  .commerce-panel { padding: 16px; border-radius: 14px; }
  .commerce-panel-head,.commerce-orders-head,.commerce-member-bar { align-items: flex-start; }
  .commerce-cart-item { grid-template-columns: 74px minmax(0, 1fr); gap: 12px; }
  .commerce-product-thumb { width: 74px; height: 74px; }
  .commerce-cart-controls { grid-column: 1 / -1; width: 100%; grid-template-columns: 1fr auto auto; align-items: center; justify-items: start; }
  .commerce-item-total { justify-self: end; }
  .commerce-order-head { align-items: flex-start; }
  .commerce-order-product { grid-template-columns: 52px minmax(0, 1fr); }
  .commerce-order-product img { width: 52px; height: 52px; }
  .commerce-order-product > strong { grid-column: 2; }
  .commerce-order-summary,.commerce-order-actions { justify-content: flex-start; }
  .commerce-order-actions .commerce-button { flex: 1 1 135px; }
  .commerce-payment-methods { grid-template-columns: 1fr; }
  .commerce-option-row { grid-template-columns: 1fr; gap: 5px; }
  .commerce-option-label { padding-top: 0; }
  .commerce-product-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .commerce-product-actions .btn { width: 100%; min-width: 0; padding-inline: 10px; }
  .commerce-gallery-thumbs { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
