/* ============================================================
   自动发卡平台 · 移动端优先设计系统
   统一 design tokens + 组件样式，前台页全部复用，不留内联。
   ============================================================ */
:root {
  /* 品牌 / 语义色 */
  --brand: #07c160;
  --brand-dark: #06a050;
  --brand-soft: #e8f8ef;
  --price: #fa5151;
  --blue: #1677ff;
  --blue-dark: #0e63e6;

  /* 中性色 */
  --bg: #f2f3f5;
  --card: #ffffff;
  --text: #1f1f1f;
  --text-sub: #8a8f99;
  --text-mute: #aab0ba;
  --line: #eef0f3;

  /* 形状与阴影 */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .06);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, .08);
  --shadow-bar: 0 -2px 12px rgba(0, 0, 0, .06);

  /* 8pt 间距系统 */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-8: 32px;

  /* 移动端安全区（iPhone 刘海/底部条） */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* 大屏：内容居中，模拟原生 App 宽度 */
.topbar, .sellpoint, .cat-nav, .list, .list-wrap, .cat-grid, .wrap, .buy-box, .order-box {
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
}

/* ===== 顶栏 ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 48px;
  line-height: 48px;
  text-align: center;
  background: var(--brand);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  padding-top: var(--safe-top);
  height: calc(48px + var(--safe-top));
  line-height: 48px;
}

/* ===== 微信提示条 ===== */
.wechat-tip {
  background: #fff7e6;
  color: #ad6800;
  font-size: 13px;
  padding: 10px 14px;
  line-height: 1.5;
  border-bottom: 1px solid #ffe7ba;
}

/* ===== 卖点高亮条 ===== */
.sellpoint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .3px;
  background: linear-gradient(90deg, #fff1e6, #ffe8ec 55%, #ffeef3);
  color: #e23b3b;
  border-bottom: 1px solid #ffd9c9;
}
.sellpoint .sp-icon { font-size: 14px; line-height: 1; }

/* ===== 分类横向导航 ===== */
.cat-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 12px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.cat-nav::-webkit-scrollbar { display: none; }
.cat-link {
  flex: 0 0 auto;
  padding: 6px 14px;
  border-radius: 16px;
  background: #f2f3f5;
  color: #444;
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.cat-link.active { background: var(--brand); color: #fff; }

/* ===== 商品列表 ===== */
.list { padding: var(--s-3); }
.card {
  display: block;
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: var(--s-3);
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .12s ease;
}
.card:active { transform: scale(.985); box-shadow: var(--shadow-md); }
.card-name { font-size: 16px; font-weight: 600; color: var(--text); }
.card-desc {
  font-size: 13px;
  color: var(--text-sub);
  margin: 6px 0 12px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.price { color: var(--price); font-size: 18px; font-weight: 700; }
.card-meta {
  font-size: 12px;
  color: var(--text-sub);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.card-meta b { font-weight: 600; color: #5b6472; }
.card-meta .dot { color: #d0d4da; }
.card-meta .m-stock.out b { color: var(--price); }
.card-foot .buy {
  margin-left: auto;
  background: var(--brand);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: 16px;
}
.empty { text-align: center; color: #999; padding: 60px 0; font-size: 14px; }

/* ===== 首页分类分组（老八转码 / 闪点各自成块，绝不混排） ===== */
.list-wrap { padding: var(--s-3); }
.cat-block { margin-bottom: var(--s-5); }
.cat-block:last-child { margin-bottom: 0; }
.cat-block-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin: 4px 2px 10px;
  padding-left: 10px;
  border-left: 3px solid var(--brand);
  line-height: 1.2;
}
.cat-block .list { padding: 0; }

/* ===== 分类页当前分类提示条（只显示当前分类，不展示全部/其他分类入口） ===== */
.cat-current {
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-sub);
  background: #fff;
  border-bottom: 1px solid var(--line);
}

/* ===== 首页：仅展示商品分类入口（不列商品） ===== */
.home-hint {
  padding: 14px 16px 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-sub);
}
.cat-grid {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding: var(--s-3);
}
.cat-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 16px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .12s ease;
}
.cat-card:active { transform: scale(.985); box-shadow: var(--shadow-md); }
.cat-card .c-name { font-size: 17px; font-weight: 700; color: var(--text); }
.cat-card .c-sub { font-size: 12px; color: var(--text-sub); margin-top: 4px; }
.cat-card .c-arrow { color: var(--text-mute); font-size: 22px; line-height: 1; }

/* ===== 商品详情页 ===== */
.wrap { padding: var(--s-4); padding-bottom: calc(78px + var(--safe-bottom)); }
.detail-head {
  background: var(--card);
  border-radius: var(--radius);
  padding: var(--s-4);
  margin-bottom: var(--s-3);
  box-shadow: var(--shadow-sm);
}
.card-name { font-size: 19px; font-weight: 700; margin-bottom: 6px; }
.wrap .card-desc { margin-bottom: 14px; }
.meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-sub);
  margin-bottom: 4px;
}
.meta .price { font-size: 22px; font-weight: 700; color: var(--price); }
.meta .m b { color: #5b6472; font-weight: 600; }
.meta .m.out b { color: var(--price); }
.detail {
  background: var(--card);
  border-radius: var(--radius);
  padding: var(--s-4);
  font-size: 14px;
  line-height: 1.8;
  word-break: break-word;
  box-shadow: var(--shadow-sm);
}
.detail img { max-width: 100%; height: auto; border-radius: 8px; margin: 8px 0; display: block; }
.detail h1, .detail h2, .detail h3 { font-size: 16px; margin: 8px 0 4px; }
.detail p { margin: 6px 0; }
.detail ul, .detail ol { padding-left: 20px; margin: 6px 0; }
/* ===== 详情页底部固定购买条 ===== */
.bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  padding-bottom: calc(12px + var(--safe-bottom));
  background: #fff;
  box-shadow: var(--shadow-bar);
}
.bar-inner { max-width: 640px; margin: 0 auto; width: 100%; display: flex; align-items: center; gap: 12px; }
.bar .price { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.bar .price b { font-size: 20px; color: var(--price); }
.bar .price span { font-size: 12px; color: #999; }
.bar .buy {
  background: var(--brand);
  color: #fff;
  border: 0;
  padding: 12px 32px;
  border-radius: 24px;
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  transition: background .15s, transform .1s;
}
.bar .buy:active { transform: scale(.97); }
.bar .buy.disabled { background: #c8c9cc; }

/* ===== 下单 / 付款界面 ===== */
.buy-box, .order-box { padding: var(--s-4); }
.buy-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: var(--s-4);
  box-shadow: var(--shadow-sm);
}
.buy-name { font-size: 18px; font-weight: 700; }
.buy-desc { font-size: 13px; color: var(--text-sub); margin: 8px 0 16px; line-height: 1.5; }
.buy-price {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 14px;
  color: var(--text-sub);
  margin-bottom: var(--s-5);
}
.buy-price b { color: var(--price); font-size: 24px; font-weight: 700; }
.buy-price .unit { font-size: 14px; }

/* 表单字段 */
.field-label {
  display: block;
  font-size: 13px;
  color: #444;
  margin: 16px 0 6px;
  font-weight: 500;
}
.field-hint { font-size: 12px; color: var(--text-mute); margin-top: 6px; }
.field {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #d8dde6;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.field:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(7, 193, 96, .12);
}

/* 支付按钮 */
.pay-form { margin-top: 4px; }
.pay-btn {
  display: block;
  width: 100%;
  height: 50px;
  border: none;
  border-radius: 25px;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  transition: filter .15s, transform .1s;
}
.pay-btn:active { transform: scale(.985); }
.pay-btn:disabled { opacity: .5; }
.pay-btn.wx { background: var(--brand); }
.pay-btn.ali { background: var(--blue); }
.pay-btn.wx:active:not(:disabled) { background: var(--brand-dark); }
.pay-btn.ali:active:not(:disabled) { background: var(--blue-dark); }

.err-tip {
  margin: 12px 0;
  padding: 10px 12px;
  background: #fff2f0;
  border: 1px solid #ffccc7;
  border-radius: 8px;
  color: #cf1322;
  font-size: 13px;
}
.back, .back-link, .pay-again {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  margin-top: 16px;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background .15s, transform .1s;
}
.back, .back-link {
  background: #f2f3f5;
  color: #576b95;
}
.back::before, .back-link::before { content: "\2190"; font-size: 15px; line-height: 1; }
.back:active, .back-link:active { background: #e6e8eb; transform: scale(.99); }
.pay-again {
  background: var(--brand);
  color: #fff;
  height: 46px;
  line-height: 46px;
  border-radius: 23px;
  font-weight: 600;
}

/* ===== 订单详情 ===== */
.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.row span { color: var(--text-sub); }
.row b { font-weight: 600; color: var(--text); word-break: break-all; text-align: right; }
.order-box .tip { font-size: 12px; color: var(--text-mute); margin-top: 12px; line-height: 1.6; }
.order-box .tip a { color: #576b95; }
.pending {
  background: #fff7e6;
  color: #ad6800;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13px;
  margin: 14px 0;
  line-height: 1.6;
}
.card-result {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 18px;
  margin-top: 14px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--brand-soft);
}
.card-label { font-size: 13px; color: var(--text-sub); margin-bottom: 12px; }
.card-code {
  font-size: 18px;
  font-weight: 700;
  word-break: break-all;
  padding: 14px;
  background: #f6fff9;
  border: 1px dashed var(--brand);
  border-radius: 10px;
  color: var(--brand-dark);
  letter-spacing: .5px;
}
.copy-btn {
  margin-top: 14px;
  background: var(--brand);
  color: #fff;
  border: none;
  height: 44px;
  width: 70%;
  border-radius: 22px;
  font-size: 15px;
  font-weight: 600;
  transition: background .15s, transform .1s;
}
.copy-btn:active { transform: scale(.97); background: var(--brand-dark); }
.tip { font-size: 12px; color: #aaa; margin-top: 12px; }

/* ============================================================
   管理后台（左侧竖排菜单）—— 保持不变
   ============================================================ */
.admin-layout { display: flex; min-height: 100vh; background: #f2f3f5; }
.sidebar {
  width: 200px; flex: 0 0 200px; background: #1f2937; color: #cbd5e1;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
  font-size: 16px; font-weight: 700; color: #fff; padding: 18px 16px; border-bottom: 1px solid #374151;
}
.sidebar nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.sidebar nav a {
  display: block; padding: 12px 18px; color: #cbd5e1; text-decoration: none; font-size: 14px;
  border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: #374151; color: #fff; }
.sidebar nav a.active { background: #07c160; color: #fff; border-left-color: #fff; }
.sidebar .side-foot {
  padding: 12px 18px; border-top: 1px solid #374151; font-size: 13px;
  display: flex; justify-content: space-between; align-items: center;
}
.sidebar .side-foot a { color: #f87171; text-decoration: none; }

.admin-main { flex: 1; padding: 18px 22px 40px; max-width: 1000px; }
.pg-title { font-size: 18px; margin: 4px 0 16px; }
.box {
  background: #fff; border-radius: 10px; padding: 16px 18px; margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.box h3 { font-size: 15px; margin: 0 0 12px; }
.admin-main label { display: block; font-size: 13px; color: #444; margin: 10px 0 4px; }
.admin-main input[type=text], .admin-main input[type=number], .admin-main input:not([type=checkbox]):not([type=password]),
.admin-main select, .admin-main textarea {
  width: 100%; padding: 9px 10px; border: 1px solid #d8dde6; border-radius: 8px; font-size: 14px; font-family: inherit;
}
.admin-main textarea { height: 120px; resize: vertical; font-family: monospace; }
.admin-main .btn {
  background: #07c160; color: #fff; border: 0; padding: 9px 20px; border-radius: 8px;
  font-size: 14px; cursor: pointer; margin-top: 12px;
}
.admin-main .btn:hover { background: #069a4e; }
.admin-main .btn.ghost { background: #e5e7eb; color: #333; margin-left: 8px; }
.admin-main .ck { display: flex; align-items: center; gap: 8px; }
.admin-main .ck input { width: auto; }
.admin-main table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-main th, .admin-main td { text-align: left; padding: 9px 8px; border-bottom: 1px solid #eee; vertical-align: middle; }
.admin-main th { color: #666; font-weight: 600; }
.admin-main .ops a, .admin-main .ops .link {
  color: #576b95; font-size: 13px; text-decoration: none; background: none; border: 0; cursor: pointer;
  margin-right: 10px; padding: 0;
}
.admin-main .ops .link.danger { color: #e53e3e; }
.admin-main .mono { font-family: monospace; word-break: break-all; }
.admin-main .ok { background: #e8f5e9; color: #1b5e20; padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }
.admin-main .err { background: #fdecea; color: #b71c1c; padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }
.admin-main .muted { color: #999; font-size: 12px; line-height: 1.6; }
.admin-main .filter select { width: auto; min-width: 180px; }
.login { max-width: 360px; margin: 80px auto; background: #fff; padding: 28px; border-radius: 12px; box-shadow: 0 4px 18px rgba(0,0,0,.08); }
.login h3 { font-size: 17px; margin: 0 0 16px; }
.login label { display: block; font-size: 13px; margin: 10px 0 4px; }
.login input { width: 100%; padding: 9px 10px; border: 1px solid #d8dde6; border-radius: 8px; font-size: 14px; }
.login .btn { width: 100%; background: #07c160; color: #fff; border: 0; padding: 10px; border-radius: 8px; font-size: 15px; cursor: pointer; margin-top: 14px; }

/* 概览统计卡 */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat { background: #fff; border-radius: 10px; padding: 16px; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.stat b { display: block; font-size: 22px; color: #07c160; }
.stat span { font-size: 12px; color: #888; }
.switch-row { margin-top: 16px; display: flex; gap: 20px; font-size: 14px; }
.switch-row .on { color: #07c160; } .switch-row .off { color: #e53e3e; }

/* 窄屏：菜单变为顶部横向滚动 */
@media (max-width: 720px) {
  .admin-layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .sidebar nav { display: flex; overflow-x: auto; padding: 0; }
  .sidebar nav a { white-space: nowrap; border-left: 0; border-bottom: 3px solid transparent; }
  .sidebar nav a.active { border-left: 0; border-bottom-color: #fff; }
  .sidebar .side-foot { display: none; }
  .admin-main { padding: 14px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* 极小屏（320px）微调，保证不挤 */
@media (max-width: 360px) {
  .card-foot .buy { padding: 6px 12px; }
  .bar .buy { padding: 11px 22px; font-size: 15px; }
  .copy-btn { width: 86%; }
}
