:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1d2129;
  --muted: #86909c;
  --line: #e5e6eb;
  --brand: #07c160;
  --brand-dark: #06ad56;
  --danger: #f53f3f;
  --warn: #ff7d00;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181a; --card: #232427; --text: #e8e9eb; --muted: #8a8f98;
    --line: #34363a; --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.topbar .wrap { display: flex; align-items: center; gap: 16px; height: 56px; }
.logo { font-weight: 700; font-size: 19px; letter-spacing: .5px; }
.logo span { color: var(--brand); }
.topbar nav { margin-left: auto; display: flex; gap: 18px; align-items: center; font-size: 14px; }
.cart-link { position: relative; }
.badge {
  position: absolute; top: -8px; right: -14px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; line-height: 18px; text-align: center;
}
.badge:empty, .badge[data-n="0"] { display: none; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 20px; padding-bottom: 48px; }
h1 { font-size: 22px; margin: 4px 0 16px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.price { color: var(--danger); font-weight: 600; }
.price::before { content: "¥"; font-size: .8em; margin-right: 1px; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }

/* 商品网格 */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
@media (max-width: 520px) { .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; } }
.goods { background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.goods .info { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.goods .name { font-weight: 500; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.goods .row { display: flex; justify-content: space-between; align-items: center; margin-top: auto; }
.thumb { aspect-ratio: 1 / 1; width: 100%; object-fit: cover; background: linear-gradient(135deg, #d9f7e8, #bfe9ff); }
.thumb.ph { display: flex; align-items: center; justify-content: center; font-size: 42px; font-weight: 700; color: rgba(0, 0, 0, .35); }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 999px; padding: 8px 18px; font-size: 14px; cursor: pointer; font-family: inherit;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); color: #fff; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.sm { padding: 4px 12px; font-size: 13px; }
.btn.block { width: 100%; padding: 12px; font-size: 16px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.icon-btn { width: 32px; height: 32px; padding: 0; border-radius: 50%; }

/* 详情 */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; }
@media (max-width: 720px) { .detail { grid-template-columns: 1fr; gap: 0; } }
.detail .thumb { border-radius: var(--radius); }
.detail .price { font-size: 26px; }
.qty { display: inline-flex; align-items: center; gap: 10px; }
.qty input { width: 56px; text-align: center; }
.actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

/* 表单 */
input, textarea, select {
  font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
input:focus, textarea:focus { outline: none; border-color: var(--brand); }
.form { display: grid; gap: 10px; }
.form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 520px) { .form-row { grid-template-columns: 1fr; } }

/* 购物车 / 订单行 */
.line { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.line:last-child { border-bottom: 0; }
.line .thumb { width: 64px; height: 64px; border-radius: 8px; flex: none; font-size: 22px; }
.line .grow { flex: 1; min-width: 0; }
.total-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.total-bar .price { font-size: 22px; }
.empty { text-align: center; padding: 48px 0; color: var(--muted); }

/* 状态 */
.tag { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 12px; background: var(--bg); color: var(--muted); }
.tag.NOTPAY { color: var(--warn); background: rgba(255, 125, 0, .1); }
.tag.PAID { color: var(--brand); background: rgba(7, 193, 96, .1); }
.tag.REFUNDING, .tag.REFUNDED { color: #3491fa; background: rgba(52, 145, 250, .1); }

/* 支付 */
.pay-box { max-width: 420px; margin: 0 auto; text-align: center; }
.qr { width: 240px; height: 240px; margin: 12px auto; padding: 8px; background: #fff; border-radius: 8px; }
.qr svg { width: 100%; height: 100%; }
.wx-tip { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-size: 14px; }
.wx-logo { width: 22px; height: 22px; border-radius: 50%; background: var(--brand); display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; font-weight: 700; }
.result-icon { width: 64px; height: 64px; border-radius: 50%; margin: 8px auto 12px; display: flex; align-items: center; justify-content: center; font-size: 34px; color: #fff; background: var(--brand); }
.result-icon.wait { background: var(--warn); }
.result-icon.fail { background: var(--muted); }
.paymethod { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1.5px solid var(--brand); border-radius: 10px; }
.paymethod .grow { flex: 1; }

/* 后台 */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; }
.table-wrap { overflow-x: auto; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); z-index: 99;
  background: rgba(0, 0, 0, .78); color: #fff; padding: 8px 18px; border-radius: 999px; font-size: 14px;
  opacity: 0; transition: opacity .2s; pointer-events: none;
}
.toast.show { opacity: 1; }
footer { text-align: center; color: var(--muted); font-size: 12px; padding: 24px 0 36px; }
