/* ============================================
   极简卡网· 白色系
   ============================================ */

:root {
  --bg: #ffffff;
  --bg-soft: #fafafa;
  --bg-hover: #f5f5f5;
  --line: #ebebeb;
  --line-strong: #dcdcdc;
  --text: #1a1a1a;
  --text-2: #6b6b6b;
  --text-3: #a0a0a0;
  --accent: #1a1a1a;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .03), 0 4px 16px rgba(0, 0, 0, .04);
  --shadow-hover: 0 2px 4px rgba(0, 0, 0, .04), 0 8px 28px rgba(0, 0, 0, .07);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.7 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ---------- 布局 ---------- */
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.wrap-narrow { max-width: 760px; margin: 0 auto; padding: 0 20px; }

/* ---------- 顶部导航 ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.nav-in {
  max-width: 1080px; margin: 0 auto; padding: 0 20px;
  height: 60px; display: flex; align-items: center; gap: 28px;
}
.nav-logo { font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.nav-logo span { color: var(--text-3); font-weight: 400; margin-left: 8px; font-size: 13px; }
.nav-links { margin-left: auto; display: flex; gap: 24px; font-size: 14px; }
.nav-links a { color: var(--text-2); transition: color .15s; }
.nav-links a:hover, .nav-links a.on { color: var(--text); }

/* ---------- 页脚 ---------- */
.foot {
  margin-top: 80px; padding: 28px 0 40px;
  border-top: 1px solid var(--line);
  color: var(--text-3); font-size: 13px; text-align: center;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--bg); color: var(--text);
  font-size: 14px; font-family: inherit; font-weight: 500;
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); border-color: #cfcfcf; }
.btn:active { transform: translateY(.5px); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: #333; border-color: #333; }
.btn-lg { padding: 13px 28px; font-size: 15px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { display: flex; width: 100%; }
.btn:disabled, .btn.disabled {
  opacity: .45; cursor: not-allowed; pointer-events: none;
}
.btn-danger { color: var(--err); border-color: #f0c8c8; }
.btn-danger:hover { background: #fdf5f5; border-color: #e8b4b4; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 24px;
}
.card-pad-sm { padding: 18px; }

/* ---------- 首页头部 ---------- */
.hero { padding: 64px 0 44px; text-align: center; }
.hero h1 { font-size: 34px; margin: 0 0 12px; letter-spacing: -.02em; font-weight: 700; }
.hero p { color: var(--text-2); margin: 0; font-size: 16px; }
.hero-tags { margin-top: 22px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.tag {
  display: inline-block; padding: 5px 13px; border: 1px solid var(--line);
  border-radius: 999px; font-size: 13px; color: var(--text-2); background: var(--bg-soft);
}

/* ---------- 商品网格 ---------- */
.grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
}
.pcard {
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 22px; background: var(--bg);
  transition: all .18s; display: flex; flex-direction: column;
}
.pcard:hover { border-color: var(--line-strong); box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.pcard-ico {
  width: 42px; height: 42px; border-radius: 11px;
  background: var(--bg-soft); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; margin-bottom: 15px;
}
.pcard h3 { margin: 0 0 7px; font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.pcard-desc {
  color: var(--text-2); font-size: 13.5px; margin: 0 0 16px; flex: 1;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden; min-height: 38px;
}
.pcard-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.price { font-size: 25px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.price small { font-size: 15px; font-weight: 500; margin-right: 1px; }
.price-unit { font-size: 12px; color: var(--text-3); font-weight: 400; margin-left: 5px; }

/* ---------- 库存徽标 ---------- */
.stock { font-size: 12.5px; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.stock-in { color: var(--ok); background: #f0faf3; border: 1px solid #cdeed8; }
.stock-low { color: var(--warn); background: #fffbf0; border: 1px solid #f7e4c0; }
.stock-out { color: var(--text-3); background: var(--bg-soft); border: 1px solid var(--line); }

/* ---------- 表单 ---------- */
.field { margin-bottom: 18px; }
.label { display: block; font-size: 13.5px; color: var(--text-2); margin-bottom: 7px; font-weight: 500; }
.input, .select, .textarea {
  width: 100%; padding: 10px 13px;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  font: 15px/1.5 inherit; color: var(--text); background: var(--bg);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, .05);
}
.textarea { min-height: 110px; resize: vertical; font-family: ui-monospace, Menlo, monospace; font-size: 13.5px; }
.hint { font-size: 12.5px; color: var(--text-3); margin-top: 6px; }
.hint code {
  background: var(--bg-soft); padding: 1px 5px; border-radius: 4px;
  font-family: ui-monospace, Menlo, monospace; font-size: 12px;
}

/* ---------- 支付方式选择 ---------- */
.pays { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
.pay {
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 15px 16px; cursor: pointer; display: flex; align-items: center; gap: 12px;
  transition: all .15s; position: relative; background: var(--bg);
}
.pay:hover { border-color: #c4c4c4; background: var(--bg-soft); }
.pay input { position: absolute; opacity: 0; pointer-events: none; }
.pay-ico {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 16px;
  background: var(--bg-soft); border: 1px solid var(--line);
}
.pay-ico.alipay { background: #f0f6ff; border-color: #d6e6ff; }
.pay-ico.wechat { background: #f0faf3; border-color: #d5f0de; }
.pay-body { flex: 1; min-width: 0; }
.pay-name { font-size: 14.5px; font-weight: 500; }
.pay-desc { font-size: 12.5px; color: var(--text-3); margin-top: 1px; }
.pay-check {
  width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--line-strong);
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
}
.pay input:checked ~ .pay-check { background: var(--accent); border-color: var(--accent); }
.pay input:checked ~ .pay-check::after {
  content: ''; width: 5px; height: 9px; border: solid #fff;
  border-width: 0 2px 2px 0; transform: rotate(45deg) translateY(-1px);
}
.pay.on { border-color: var(--accent); background: var(--bg); box-shadow: 0 0 0 3px rgba(0,0,0,.04); }

/* ---------- 提示条 ---------- */
.alert {
  padding: 12px 15px; border-radius: var(--radius); font-size: 14px;
  border: 1px solid; margin-bottom: 18px;
}
.alert-err { background: #fdf5f5; border-color: #f5d5d5; color: #b91c1c; }
.alert-ok { background: #f0faf3; border-color: #cdeed8; color: #15803d; }
.alert-warn { background: #fffbf0; border-color: #f7e4c0; color: #b45309; }

/* ---------- 订单/卡密展示 ---------- */
.box {
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 16px;
}
.box-title { font-size: 13px; color: var(--text-2); margin: 0 0 10px; font-weight: 500; }

.cardcode {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 16px; font-weight: 600; letter-spacing: .02em;
  background: var(--bg); border: 1px dashed var(--line-strong);
  border-radius: var(--radius); padding: 16px; text-align: center;
  word-break: break-all; user-select: all; line-height: 1.6;
}
.copyrow { display: flex; gap: 10px; margin-top: 12px; }
.copyrow .cardcode { flex: 1; text-align: left; }

/* ---------- 状态标记 ---------- */
.pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12.5px; border: 1px solid; white-space: nowrap;
}
.pill-pending { color: var(--warn); background: #fffbf0; border-color: #f7e4c0; }
.pill-paid { color: var(--ok); background: #f0faf3; border-color: #cdeed8; }
.pill-closed { color: var(--text-3); background: var(--bg-soft); border-color: var(--line); }

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; padding: 10px 12px; font-size: 12.5px; color: var(--text-2);
  font-weight: 500; border-bottom: 1px solid var(--line); white-space: nowrap;
  background: var(--bg-soft);
}
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg-soft); }
.td-mono { font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.td-nowrap { white-space: nowrap; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---------- 空状态 ---------- */
.empty { text-align: center; padding: 64px 20px; color: var(--text-3); }
.empty-ico { font-size: 40px; margin-bottom: 14px; opacity: .5; }
.empty h3 { margin: 0 0 6px; font-size: 16px; color: var(--text-2); font-weight: 500; }
.empty p { margin: 0; font-size: 14px; }

/* ---------- 统计卡 ---------- */
.stats { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); }
.stat {
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 18px 20px; background: var(--bg);
}
.stat-label { font-size: 13px; color: var(--text-2); margin-bottom: 7px; }
.stat-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.stat-value small { font-size: 15px; font-weight: 500; color: var(--text-3); margin-right: 2px; }
.stat-sub { font-size: 12.5px; color: var(--text-3); margin-top: 5px; }

/* ---------- 图表（纯 CSS 柱状） ---------- */
.chart { display: flex; align-items: flex-end; gap: 5px; height: 168px; padding-top: 20px; }
.chart-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; position: relative; }
.chart-bar {
  background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px;
  transition: opacity .15s; position: relative;
}
.chart-col:hover .chart-bar { opacity: .78; }
.chart-val {
  position: absolute; top: -18px; left: 50%; transform: translateX(-50%);
  font-size: 11px; color: var(--text-2); white-space: nowrap;
}
.chart-labels { display: flex; gap: 5px; margin-top: 8px; }
.chart-labels span {
  flex: 1; text-align: center; font-size: 10.5px; color: var(--text-3);
  overflow: hidden; white-space: nowrap;
}

/* ---------- 管理后台 ---------- */
.admin-body { background: var(--bg-soft); }
.admin-top {
  background: var(--bg); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.admin-top-in {
  max-width: 1240px; margin: 0 auto; padding: 0 20px;
  height: 58px; display: flex; align-items: center; gap: 26px;
}
.admin-brand { font-weight: 700; font-size: 15px; }
.admin-brand span { color: var(--text-3); font-weight: 400; font-size: 13px; margin-left: 7px; }
.admin-menu { display: flex; gap: 4px; margin-left: 12px; }
.admin-menu a {
  padding: 7px 14px; border-radius: var(--radius); font-size: 14px; color: var(--text-2);
  transition: all .15s;
}
.admin-menu a:hover { background: var(--bg-hover); color: var(--text); }
.admin-menu a.on { background: var(--accent); color: #fff; }
.admin-user { margin-left: auto; font-size: 13px; color: var(--text-3); display: flex; align-items: center; gap: 12px; }
.admin-main { max-width: 1240px; margin: 0 auto; padding: 26px 20px 60px; }
.admin-h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }
.admin-sub { color: var(--text-2); font-size: 14px; margin: 0 0 24px; }

/* 开关 */
.switch { position: relative; display: inline-block; width: 44px; height: 25px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-t {
  position: absolute; inset: 0; background: var(--line-strong);
  border-radius: 999px; transition: .2s; cursor: pointer;
}
.switch-t::before {
  content: ''; position: absolute; height: 19px; width: 19px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .18);
}
.switch input:checked + .switch-t { background: var(--accent); }
.switch input:checked + .switch-t::before { transform: translateX(19px); }

/* 支付方式行 */
.payrow {
  display: flex; align-items: center; gap: 16px; padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
.payrow:last-child { border-bottom: none; }
.payrow-body { flex: 1; min-width: 0; }
.payrow-name { font-size: 15px; font-weight: 500; display: flex; align-items: center; gap: 9px; }
.payrow-desc { font-size: 13px; color: var(--text-3); margin-top: 2px; }
.payrow-state { font-size: 13px; font-weight: 500; min-width: 42px; text-align: right; }
.payrow-state.on { color: var(--ok); }
.payrow-state.off { color: var(--text-3); }

/* 商品管理表内的输入 */
.mini-input {
  width: 100%; padding: 7px 10px; border: 1px solid var(--line-strong);
  border-radius: 8px; font: 14px/1.4 inherit; background: var(--bg);
}
.mini-input:focus { outline: none; border-color: var(--accent); }
textarea.mini-input { font-family: ui-monospace, Menlo, monospace; font-size: 13px; }

/* 筛选栏 */
.filters {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end;
  margin-bottom: 18px; padding: 16px; border: 1px solid var(--line);
  border-radius: var(--radius-lg); background: var(--bg);
}
.filters .field { margin: 0; }
.filters .field.w-sm { width: 118px; }
.filters .field.w-md { width: 168px; }
.filters .field.w-lg { flex: 1; min-width: 190px; }
.filters .label { font-size: 12.5px; margin-bottom: 4px; }
.filters .input, .filters .select { padding: 7px 11px; font-size: 14px; }

/* 分页 */
.pager { display: flex; gap: 8px; justify-content: center; margin-top: 26px; font-size: 14px; }
.pager a, .pager span {
  padding: 7px 13px; border: 1px solid var(--line); border-radius: 8px; color: var(--text-2);
}
.pager a:hover { background: var(--bg-hover); }
.pager .on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* 登录页 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 366px; }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo h1 { font-size: 21px; margin: 0 0 6px; letter-spacing: -.01em; }
.login-logo p { color: var(--text-3); font-size: 13.5px; margin: 0; }

/* 加载 */
.loading { opacity: .55; pointer-events: none; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%) translateY(14px);
  background: var(--accent); color: #fff; padding: 11px 20px; border-radius: var(--radius);
  font-size: 14px; opacity: 0; pointer-events: none; transition: all .22s; z-index: 200;
  box-shadow: var(--shadow-hover); max-width: 88vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .wrap, .wrap-narrow { padding: 0 16px; }
  .hero { padding: 44px 0 32px; }
  .hero h1 { font-size: 26px; }
  .hero p { font-size: 15px; }
  .nav-in { gap: 16px; height: 56px; }
  .nav-logo span { display: none; }
  .nav-links { gap: 16px; font-size: 13.5px; }
  .grid { grid-template-columns: 1fr; gap: 14px; }
  .pays { grid-template-columns: 1fr; }
  .card { padding: 20px; }
  .admin-menu { gap: 0; margin-left: 0; overflow-x: auto; max-width: 100%; }
  .admin-menu a { padding: 6px 11px; font-size: 13px; white-space: nowrap; }
  .admin-top-in { gap: 14px; height: auto; padding-top: 12px; padding-bottom: 12px; flex-wrap: wrap; }
  .admin-user { font-size: 12.5px; }
  .filters .field, .filters .field.w-sm, .filters .field.w-md, .filters .field.w-lg {
    width: 100%; flex: 1 1 140px;
  }
  .stat-value { font-size: 22px; }
  .chart { height: 132px; }
  .chart-labels span { font-size: 9px; }
}