:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --ink: #20242b;
  --muted: #6b7280;
  --line: #e7e1d8;
  --accent: #b5563f;
  --accent-d: #97442f;
  --ok: #2f8f5b;
  --warn: #c98a1b;
  --danger: #c0392b;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(40, 30, 20, .08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* 导航 */
.nav {
  display: flex; align-items: center; gap: 18px;
  padding: 14px 26px; background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.nav .brand { font-weight: 700; font-size: 19px; letter-spacing: .5px; color: var(--ink); }
.nav .spacer { flex: 1; }
.nav a.link { color: var(--muted); font-size: 14px; }
.nav a.link:hover { color: var(--accent); }
.nav .pill {
  background: var(--ink); color: #fff; padding: 6px 14px; border-radius: 999px; font-size: 13px;
}

/* 布局 */
.container { max-width: 980px; margin: 0 auto; padding: 28px 20px 60px; }
.wrap { max-width: 620px; margin: 40px auto; padding: 0 20px; }

/* 卡片 */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px;
}
.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 720px){ .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; } }

/* 标题 */
h1 { font-size: 30px; margin: 0 0 6px; letter-spacing: .3px; }
h2 { font-size: 21px; margin: 0 0 12px; }
.sub { color: var(--muted); margin: 0 0 22px; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: #fff; border: none; cursor: pointer;
  padding: 11px 18px; border-radius: 10px; font-size: 15px; font-weight: 600;
  transition: background .15s ease, transform .05s ease;
}
.btn:hover { background: var(--accent-d); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { background: #f3eee6; }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* 表单 */
label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
input[type=text], input[type=password], input[type=email], input[type=number], select, textarea {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 15px; background: #fff; color: var(--ink); font-family: inherit;
}
input:focus, textarea:focus, select:focus { outline: 2px solid rgba(181,86,63,.25); border-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; }

/* 徽标 */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.unused { background: #eef6f0; color: var(--ok); }
.badge.assigned { background: #fdf3e2; color: var(--warn); }
.badge.redeemed { background: #f1e9e7; color: var(--muted); }
.badge.disabled { background: #fae8e6; color: var(--danger); }
.badge.on { background: #eef6f0; color: var(--ok); }
.badge.off { background: #f1e9e7; color: var(--muted); }
.badge.paid { background: #eef6f0; color: var(--ok); }
.badge.pending { background: #fdf3e2; color: var(--warn); }
.badge.failed { background: #fae8e6; color: var(--danger); }

/* 提示 */
.alert { padding: 11px 14px; border-radius: 10px; margin: 12px 0; font-size: 14px; }
.alert.error { background: #fae8e6; color: var(--danger); }
.alert.ok { background: #eef6f0; color: var(--ok); }
.alert.info { background: #eef3f8; color: #2b6cb0; }

/* 表 */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
tr:hover td { background: #fcfaf6; }
.mono { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; letter-spacing: 1px; }

/* 价格标签 */
.price { font-size: 13px; color: var(--muted); }

/* 统计 */
.stat { text-align: center; }
.stat .n { font-size: 28px; font-weight: 700; }
.stat .l { font-size: 13px; color: var(--muted); }

/* 测试页 */
.test-hero { text-align: center; padding: 30px 0 10px; }
.test-hero h1 { font-size: 34px; }
.gate {
  max-width: 420px; margin: 24px auto; text-align: center;
}
.gate input { text-align: center; font-size: 20px; letter-spacing: 3px; }
.kbd-hint { color: var(--muted); font-size: 13px; margin-top: 10px; }
.result-box { background: #fcfaf6; border: 1px dashed var(--line); border-radius: 12px; padding: 20px; margin-top: 18px; }
.hidden { display: none; }
.q { margin: 18px 0; }
.q p { font-weight: 600; margin: 0 0 8px; }
.opt { display: block; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; margin: 6px 0; cursor: pointer; }
.opt:hover { border-color: var(--accent); }
.opt.sel { background: var(--accent); color: #fff; border-color: var(--accent); }

/* 二维码区 */
.qr-box { text-align: center; padding: 10px; }
.qr-box img { max-width: 240px; }
.step { display: flex; gap: 12px; align-items: flex-start; margin: 10px 0; }
.step .num { width: 26px; height: 26px; border-radius: 50%; background: var(--ink); color:#fff; display:flex; align-items:center; justify-content:center; font-size:13px; flex: 0 0 auto; }
.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 30px 0; }

/* 管理后台布局 */
.admin-shell { display: flex; min-height: 100vh; }
.admin-side {
  width: 230px; flex: 0 0 230px; align-self: flex-start;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--line);
  padding: 22px 16px; display: flex; flex-direction: column;
}
.admin-brand { font-weight: 700; font-size: 18px; color: var(--ink); margin: 2px 6px 18px; }
.admin-nav-item {
  display: block; padding: 10px 12px; border-radius: 10px;
  color: var(--muted); font-size: 14px; margin-bottom: 4px;
}
.admin-nav-item:hover { background: #f3eee6; color: var(--accent); text-decoration: none; }
.admin-nav-item.active { background: var(--accent); color: #fff; }
.admin-side-foot { margin-top: auto; padding: 12px 6px 0; border-top: 1px solid var(--line); font-size: 13px; }
.admin-main { flex: 1; padding: 28px 32px 60px; }
.admin-main .container { max-width: 1180px; }
@media (max-width: 760px){
  .admin-shell { flex-direction: column; }
  .admin-side { width: 100%; flex: none; height: auto; position: static; flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .admin-brand { width: 100%; margin-bottom: 8px; }
  .admin-side-foot { width: 100%; margin-top: 8px; }
  .admin-main { padding: 20px 16px 40px; }
}

/* 分页 */
.pager { display: flex; align-items: center; gap: 14px; margin: 20px 0 4px; flex-wrap: wrap; }
.pager-info { color: var(--muted); font-size: 14px; }

/* 两列网格（表单用） */
.grid.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* 弹窗 modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20, 18, 14, .5);
  display: none; align-items: flex-start; justify-content: center;
  padding: 56px 16px; z-index: 1000; overflow: auto;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--surface); width: 100%; max-width: 580px;
  border-radius: 14px; box-shadow: 0 22px 60px rgba(0,0,0,.28);
  animation: modalIn .16s ease;
}
@keyframes modalIn { from { transform: translateY(-10px); opacity: 0 } to { transform: none; opacity: 1 } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; color: var(--ink); }
.modal-head .x { border: none; background: transparent; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }
.modal-body textarea { min-height: 76px; }
.modal-body .grid.cols-2 { gap: 12px; }
@media (max-width: 560px) { .modal .grid.cols-2 { grid-template-columns: 1fr; } }
