:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #1b2436;
  --muted: #6b7789;
  --line: #e5e9f2;
  --brand: #4b6bfb;
  --brand-dark: #3a55d9;
  --brand-soft: #eef1ff;
  --ok: #12a150;
  --ok-soft: #e8f8ee;
  --warn: #b7791f;
  --warn-soft: #fff6e5;
  --err: #d93025;
  --err-soft: #fdeceb;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(27, 36, 54, .06), 0 8px 24px rgba(27, 36, 54, .05);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); }

h1, h2, h3, h4 { margin: 0 0 .6em; line-height: 1.35; font-weight: 600; }
h1 { font-size: 26px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { margin: 0 0 1em; }

/* ---------- 布局 ---------- */
.wrap { width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 20px; }
.page { padding: 28px 0 64px; }
.row { display: flex; gap: 20px; flex-wrap: wrap; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.stack > * + * { margin-top: 16px; }
.mt { margin-top: 20px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }

/* ---------- 顶部导航 ---------- */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .wrap { display: flex; align-items: center; gap: 22px; height: 62px; }
.logo { font-size: 18px; font-weight: 700; letter-spacing: .3px; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.logo:hover { color: var(--brand); }
.logo-badge {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, #4b6bfb, #7a5cf7);
  color: #fff; display: grid; place-items: center; font-size: 15px; font-weight: 700;
}
.nav { display: flex; gap: 4px; margin-left: 8px; flex: 1; flex-wrap: wrap; }
.nav a {
  color: var(--muted); padding: 7px 12px; border-radius: 8px; font-weight: 500;
}
.nav a:hover { background: var(--brand-soft); color: var(--brand-dark); }
.nav a.active { background: var(--brand-soft); color: var(--brand-dark); }
.nav-user { display: flex; align-items: center; gap: 12px; }
.balance-pill {
  background: var(--brand-soft); color: var(--brand-dark);
  padding: 5px 12px; border-radius: 999px; font-weight: 600; font-size: 13px;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card.tight { padding: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-head h2, .card-head h3 { margin: 0; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-size: 14px; font-weight: 500;
  cursor: pointer; transition: .15s; white-space: nowrap; font-family: inherit;
}
.btn:hover { border-color: #c9d2e5; background: #fafbff; color: var(--ink); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-danger { background: #fff; border-color: #f3c3bf; color: var(--err); }
.btn-danger:hover { background: var(--err-soft); border-color: #eba9a3; color: var(--err); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { filter: brightness(.94); color: #fff; }
.btn-sm { padding: 5px 11px; font-size: 13px; border-radius: 7px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- 表单 ---------- */
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; font-weight: 500; color: #46536b; margin-bottom: 6px; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=search], textarea, select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; color: var(--ink); font-size: 14px; font-family: inherit;
  transition: .15s; outline: none;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(75, 107, 251, .12);
}
textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
.form-inline { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.form-inline label.field { margin-bottom: 0; }
.form-inline .grow { flex: 1; min-width: 140px; }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 5px; }
.check { display: flex; align-items: center; gap: 7px; font-size: 13.5px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; background: #fff; font-size: 13.5px; }
thead th {
  text-align: left; padding: 10px 14px; background: #f8fafd;
  color: #5b687e; font-weight: 600; font-size: 12.5px;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid #f0f3f9; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbff; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- 徽标 ---------- */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 1.7;
}
.badge-on { background: var(--ok-soft); color: var(--ok); }
.badge-off { background: #eef0f4; color: #6b7789; }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-err { background: var(--err-soft); color: var(--err); }
.badge-info { background: var(--brand-soft); color: var(--brand-dark); }

/* ---------- 提示 ---------- */
.flashes { margin: 18px 0 0; display: grid; gap: 10px; }
.flash {
  padding: 11px 15px; border-radius: 10px; font-size: 13.5px;
  border: 1px solid transparent; display: flex; gap: 9px; align-items: flex-start;
}
.flash::before { content: "●"; font-size: 10px; line-height: 1.9; }
.flash-success { background: var(--ok-soft); color: #0b7a3d; border-color: #c3ebd2; }
.flash-error { background: var(--err-soft); color: #a5251c; border-color: #f6cdc9; }
.flash-warning { background: var(--warn-soft); color: #8c5c12; border-color: #f6e0b6; }
.flash-info { background: var(--brand-soft); color: var(--brand-dark); border-color: #d6dcff; }

/* ---------- 商品 ---------- */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.product-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; transition: .18s;
  box-shadow: var(--shadow);
}
.product-card:hover { transform: translateY(-2px); border-color: #cfd8ee; box-shadow: 0 10px 26px rgba(27, 36, 54, .09); }
.product-card .body { padding: 16px 18px 18px; display: flex; flex-direction: column; flex: 1; }
.product-card h3 { font-size: 15.5px; margin-bottom: 6px; }
.product-card .desc { color: var(--muted); font-size: 13px; flex: 1; margin-bottom: 14px; min-height: 40px; }
.product-card .foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.price { color: #e0452c; font-weight: 700; font-size: 20px; font-variant-numeric: tabular-nums; }
.price small { font-size: 13px; font-weight: 600; }
.product-thumb {
  height: 96px; background: linear-gradient(135deg, #eef1ff, #f7f0ff);
  display: grid; place-items: center; font-size: 30px; color: #a9b3ff;
  border-bottom: 1px solid var(--line);
}

/* ---------- 统计块 ---------- */
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 12.5px; margin-bottom: 4px; }
.stat .value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .value.brand { color: var(--brand); }
.stat .value.ok { color: var(--ok); }

/* ---------- 空状态 ---------- */
.empty { text-align: center; color: var(--muted); padding: 44px 16px; }
.empty .icon { font-size: 34px; opacity: .5; margin-bottom: 10px; }

/* ---------- 分页 ---------- */
.pager { display: flex; gap: 8px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.pager a, .pager span {
  min-width: 36px; text-align: center; padding: 6px 11px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; font-size: 13px; color: var(--muted);
}
.pager a:hover { border-color: var(--brand); color: var(--brand); }
.pager .current { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

/* ---------- 卡密结果 ---------- */
.code-box {
  background: #111827; color: #d1fae5; border-radius: 10px; padding: 16px;
  font-family: Consolas, "Courier New", monospace; font-size: 13px;
  white-space: pre-wrap; word-break: break-all; line-height: 1.9;
  max-height: 420px; overflow: auto;
}
.secret {
  font-family: Consolas, "Courier New", monospace; background: #f6f8fc;
  border: 1px dashed #cdd6ea; border-radius: 7px; padding: 8px 10px;
  display: block; margin: 4px 0; word-break: break-all; color: #26324a;
}

/* ---------- 标签筛选 ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.chip {
  padding: 6px 14px; border-radius: 999px; background: #fff;
  border: 1px solid var(--line); font-size: 13px; color: var(--muted);
}
.chip:hover { border-color: #c9d2e5; color: var(--ink); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 500; }

/* ---------- 页脚 ---------- */
.footer {
  border-top: 1px solid var(--line); background: #fff; padding: 22px 0;
  color: var(--muted); font-size: 12.5px; text-align: center;
}

/* ---------- 认证页 ---------- */
.auth-shell { min-height: calc(100vh - 62px); display: grid; place-items: center; padding: 40px 20px; }
.auth-card { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 32px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 22px; text-align: center; margin-bottom: 4px; }
.auth-card .sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.auth-foot { text-align: center; font-size: 13px; color: var(--muted); margin-top: 18px; }

@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .topbar .wrap { height: auto; padding: 10px 16px; flex-wrap: wrap; gap: 10px; }
  .nav { order: 3; width: 100%; margin-left: 0; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; }
  .nav a { white-space: nowrap; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  h1 { font-size: 22px; }
  .page { padding: 20px 0 48px; }
}
