:root {
  --brand: #e1251b;
  --brand-dark: #b81c14;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f7f8fa;
  --card: #ffffff;
  --ok: #0f9d58;
  --radius: 14px;
  --shadow: 0 4px 20px rgba(17, 24, 39, .07);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.6; -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { display: block; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* 顶栏 */
.topbar { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar .wrap { height: 64px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 700; letter-spacing: .3px; }
.brand-logo {
  width: 32px; height: 32px; border-radius: 9px; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-size: 17px; font-weight: 800;
}
.cart-btn {
  position: relative; border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 8px 16px 8px 12px; display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink);
  transition: .2s;
}
.cart-btn:hover { border-color: var(--brand); color: var(--brand); }
.cart-icon { font-size: 17px; line-height: 1; }
.cart-badge {
  min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px; background: var(--brand); color: #fff;
  font-size: 12px; font-weight: 700; display: grid; place-items: center;
}

/* 页头 */
.hero { padding: 40px 0 26px; }
.hero h1 { margin: 0 0 8px; font-size: 28px; letter-spacing: -.5px; }
.hero p { margin: 0; color: var(--muted); font-size: 14px; }

/* 商品网格 */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; padding-bottom: 60px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column;
  transition: transform .18s, box-shadow .18s;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 10px 28px rgba(17, 24, 39, .12); }
.card-img {
  aspect-ratio: 4 / 3; background: linear-gradient(135deg, #f3f4f6, #e9ebef);
  object-fit: cover; width: 100%;
}
.card-img.placeholder {
  display: grid; place-items: center; color: #9ca3af; font-size: 34px; font-weight: 800;
}
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; flex: 1; }
.card-name { font-size: 15px; font-weight: 600; margin: 0 0 6px; line-height: 1.45; }
.card-desc { font-size: 12.5px; color: var(--muted); margin: 0 0 14px; flex: 1;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.price { color: var(--brand); font-size: 20px; font-weight: 700; }
.price small { font-size: 12px; margin-right: 1px; }
.btn {
  border: 0; border-radius: 9px; padding: 9px 16px; font-size: 14px; font-weight: 600;
  background: var(--brand); color: #fff; transition: .18s;
}
.btn:hover { background: var(--brand-dark); }
.btn.sm { padding: 7px 13px; font-size: 13px; }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; }
.empty { grid-column: 1 / -1; text-align: center; padding: 70px 20px; color: var(--muted); }

/* 购物车抽屉 */
.overlay { position: fixed; inset: 0; background: rgba(17, 24, 39, .4); z-index: 40; opacity: 0; pointer-events: none; transition: .22s; }
.overlay.show { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(400px, 100%); background: #fff; z-index: 41;
  transform: translateX(100%); transition: transform .25s ease; display: flex; flex-direction: column;
}
.drawer.show { transform: translateX(0); }
.drawer-head { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.drawer-head h2 { margin: 0; font-size: 17px; }
.icon-btn { border: 0; background: transparent; font-size: 22px; color: var(--muted); line-height: 1; padding: 4px 8px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 10px 20px; }
.cart-item { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.cart-item img, .cart-item .thumb { width: 62px; height: 62px; border-radius: 9px; object-fit: cover; flex-shrink: 0;
  background: #f3f4f6; display: grid; place-items: center; color: #9ca3af; }
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-item-price { color: var(--brand); font-size: 13px; margin-top: 2px; }
.qty-ctrl { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.qty-ctrl button { width: 24px; height: 24px; border: 1px solid var(--line); background: #fff; border-radius: 6px; line-height: 1; }
.qty-ctrl span { font-size: 13px; min-width: 18px; text-align: center; }
.cart-del { border: 0; background: none; color: var(--muted); font-size: 12px; }
.drawer-foot { padding: 18px 20px 24px; border-top: 1px solid var(--line); }
.total-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; font-size: 14px; }
.total-row b { color: var(--brand); font-size: 24px; }

/* 支付页 / 结果页 */
.center-page { min-height: calc(100vh - 64px); display: grid; place-items: center; padding: 36px 20px; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); width: min(480px, 100%); padding: 30px; text-align: center; }
.panel h1 { font-size: 21px; margin: 0 0 6px; }
.panel .sub { color: var(--muted); font-size: 13px; margin: 0 0 22px; }
.pay-amount { font-size: 34px; font-weight: 800; color: var(--brand); margin: 4px 0 18px; }
.qr-box { width: 236px; height: 236px; margin: 0 auto 16px; border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: #fff; display: grid; place-items: center; }
.qr-box img { width: 100%; height: 100%; }
.qr-tip { font-size: 13px; color: var(--muted); }
.status-line { margin-top: 16px; font-size: 13.5px; color: var(--muted); }
.status-line .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #f59e0b; margin-right: 7px; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.mock-box { margin-top: 18px; padding: 14px; background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px; font-size: 12.5px; color: #92400e; text-align: left; }
.mock-box button { margin-top: 10px; }
.kv { text-align: left; margin: 18px 0; border-top: 1px solid var(--line); }
.kv div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.kv span { color: var(--muted); }
.result-icon { width: 64px; height: 64px; border-radius: 50%; background: #e8f5ee; color: var(--ok); font-size: 34px; display: grid; place-items: center; margin: 0 auto 14px; }
.links { margin-top: 18px; font-size: 13px; color: var(--muted); }
.links a { color: var(--brand); }

/* Toast */
#toast { position: fixed; left: 50%; bottom: 40px; transform: translate(-50%, 12px); z-index: 90;
  background: rgba(31, 41, 55, .94); color: #fff; padding: 11px 20px; border-radius: 10px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .22s; max-width: 90vw; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

footer { text-align: center; color: #9ca3af; font-size: 12px; padding: 26px 20px 34px; }

@media (max-width: 560px) {
  .hero { padding: 26px 0 18px; }
  .hero h1 { font-size: 22px; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .card-body { padding: 11px 12px 13px; }
  .price { font-size: 17px; }
  .btn.sm { padding: 6px 10px; font-size: 12px; }
  .panel { padding: 22px 18px; }
}
