:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #1a1d29;
  --muted: #6b7280;
  --line: #e8eaf0;
  --brand: #4f46e5;
  --brand-2: #7c3aed;
  --green: #10b981;
  --red: #ef4444;
  --amber: #f59e0b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; }

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

.topbar {
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
}
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.logo-mark {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: grid; place-items: center; color: #fff; font-size: 16px;
}
.nav-links { display: flex; gap: 6px; }
.nav-links a {
  padding: 7px 14px; border-radius: 8px; font-size: 14px; color: var(--muted);
  transition: .18s;
}
.nav-links a:hover { background: #f0f1f7; color: var(--text); }

/* ---------- 公告 ---------- */
.notice {
  margin: 22px 0 0; padding: 12px 16px;
  background: #eef2ff; border: 1px solid #dbe1ff;
  border-radius: 10px; font-size: 14px; color: #4338ca;
  display: flex; gap: 10px; align-items: flex-start;
}
.notice.hidden { display: none; }

/* ---------- Hero ---------- */
.hero { padding: 46px 0 30px; text-align: center; }
.hero h1 {
  font-size: 34px; font-weight: 800; letter-spacing: -.5px;
  background: linear-gradient(135deg, #1a1d29 30%, #4f46e5);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.hero p { color: var(--muted); margin-top: 10px; font-size: 15px; }
.hero-badges { display: flex; gap: 10px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.badge {
  font-size: 13px; padding: 6px 14px; border-radius: 999px;
  background: #fff; border: 1px solid var(--line); color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }

/* ---------- 商品网格 ---------- */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 26px 0 16px;
}
.section-head h2 { font-size: 19px; font-weight: 700; }
.section-head .count { font-size: 13px; color: var(--muted); }

.grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  padding-bottom: 60px;
}

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow);
  transition: .2s; display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-2px); border-color: #d5d9e8; box-shadow: 0 4px 8px rgba(16,24,40,.05), 0 16px 40px rgba(16,24,40,.09); }

.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.card h3 { font-size: 16px; font-weight: 650; line-height: 1.4; }
.card .cat {
  font-size: 11px; padding: 3px 9px; border-radius: 6px;
  background: #f3f4f8; color: var(--muted); white-space: nowrap; flex-shrink: 0;
}
.card .desc {
  font-size: 13.5px; color: var(--muted); margin-top: 10px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 42px;
}
.card-foot {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--line);
}
.price { font-size: 25px; font-weight: 800; color: var(--red); letter-spacing: -.5px; }
.price small { font-size: 14px; font-weight: 600; margin-right: 1px; }
.stock { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.stock.low { color: var(--amber); }
.stock.out { color: var(--red); }

.btn {
  padding: 9px 20px; border-radius: 9px; font-size: 14px; font-weight: 600;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; transition: .18s; white-space: nowrap;
}
.btn:hover { opacity: .9; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { background: #cbd0dc; cursor: not-allowed; transform: none; opacity: 1; }
.btn-ghost {
  background: #fff; color: var(--text); border: 1px solid var(--line);
}
.btn-ghost:hover { background: #f8f9fc; }
.btn-sm { padding: 6px 14px; font-size: 13px; border-radius: 8px; }
.btn-danger { background: #fef2f2; color: var(--red); border: 1px solid #fecaca; }
.btn-danger:hover { background: #fee2e2; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(16,24,40,.45);
  backdrop-filter: blur(3px); display: none; place-items: center; z-index: 100; padding: 20px;
}
.modal-mask.show { display: grid; }
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 440px;
  padding: 26px; box-shadow: 0 24px 60px rgba(16,24,40,.2);
  animation: pop .2s ease;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal h3 { font-size: 18px; margin-bottom: 4px; }
.modal .sub { font-size: 13.5px; color: var(--muted); margin-bottom: 20px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 7px; color: #374151; }
.field input, .field textarea, .field select {
  width: 100%; padding: 10px 13px; border: 1px solid var(--line);
  border-radius: 9px; font-size: 14px; background: #fbfcfe; transition: .15s;
  outline: none; color: var(--text);
}
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--brand); background: #fff;
  box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}
.field .hint { font-size: 12px; color: var(--muted); margin-top: 5px; }

.qty-row { display: flex; align-items: center; gap: 10px; }
.qty-ctrl { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: #fbfcfe; }
.qty-ctrl button { width: 38px; height: 40px; font-size: 17px; color: var(--muted); }
.qty-ctrl button:hover { background: #eef0f7; color: var(--text); }
.qty-ctrl input {
  width: 52px; text-align: center; border: none; background: transparent;
  font-size: 15px; font-weight: 600; outline: none;
}

.total-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 0; border-top: 1px solid var(--line); margin-top: 4px;
}
.total-row .label { font-size: 14px; color: var(--muted); }
.total-row .val { font-size: 24px; font-weight: 800; color: var(--red); }

.modal-actions { display: flex; gap: 10px; margin-top: 8px; }
.modal-actions .btn { flex: 1; padding: 11px; text-align: center; }

/* ---------- 订单页 ---------- */
.order-wrap { max-width: 620px; margin: 0 auto; padding: 40px 20px 80px; }
.panel {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.panel-head { padding: 22px 26px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 18px; }
.panel-body { padding: 26px; }

.status-pill {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 600; padding: 5px 13px; border-radius: 999px;
}
.status-pending { background: #fffbeb; color: #b45309; }
.status-delivered { background: #ecfdf5; color: #047857; }
.status-expired { background: #f3f4f6; color: #6b7280; }
.status-failed { background: #fef2f2; color: #b91c1c; }

.kv { display: flex; justify-content: space-between; padding: 11px 0; font-size: 14px; border-bottom: 1px dashed #f0f1f5; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 600; text-align: right; word-break: break-all; }

.card-list { margin-top: 22px; }
.card-list h4 { font-size: 14px; margin-bottom: 12px; display: flex; align-items: center; gap: 7px; }
.secret-box {
  background: #f8fafc; border: 1px solid var(--line); border-radius: 10px;
  padding: 13px 15px; margin-bottom: 10px; display: flex;
  align-items: center; justify-content: space-between; gap: 12px;
}
.secret-box code {
  font-family: "SF Mono", Consolas, Monaco, monospace;
  font-size: 14px; letter-spacing: .4px; word-break: break-all; color: #0f172a;
}
.copy-btn {
  font-size: 12px; padding: 5px 11px; border-radius: 7px;
  background: #fff; border: 1px solid var(--line); color: var(--muted);
  white-space: nowrap; transition: .15s;
}
.copy-btn:hover { border-color: var(--brand); color: var(--brand); }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); font-size: 14px; }

/* ---------- 后台 ---------- */
.admin-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 216px; background: #fff; border-right: 1px solid var(--line);
  padding: 20px 14px; flex-shrink: 0; position: sticky; top: 0; height: 100vh;
}
.sidebar .logo { padding: 0 8px 20px; }
.side-nav { display: flex; flex-direction: column; gap: 3px; }
.side-nav button {
  text-align: left; padding: 10px 13px; border-radius: 9px;
  font-size: 14px; color: var(--muted); transition: .15s; width: 100%;
}
.side-nav button:hover { background: #f6f7fb; color: var(--text); }
.side-nav button.active {
  background: #eef2ff; color: var(--brand); font-weight: 600;
}
.admin-main { flex: 1; padding: 26px 30px 60px; min-width: 0; }

.stat-grid {
  display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  margin-bottom: 26px;
}
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 18px; box-shadow: var(--shadow);
}
.stat .lbl { font-size: 12.5px; color: var(--muted); }
.stat .num { font-size: 26px; font-weight: 800; margin-top: 5px; letter-spacing: -.5px; }
.stat .num.money { color: var(--red); }

.toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar input[type=text], .toolbar select {
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 13.5px; background: #fff; outline: none;
}
.toolbar input[type=text]:focus, .toolbar select:focus { border-color: var(--brand); }
.spacer { flex: 1; }

table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
thead th {
  background: #fafbfd; text-align: left; font-size: 12.5px; font-weight: 600;
  color: var(--muted); padding: 11px 14px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td { padding: 12px 14px; font-size: 13.5px; border-bottom: 1px solid #f4f5f9; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfd; }
.td-mono { font-family: "SF Mono", Consolas, monospace; font-size: 12.5px; }
.td-actions { display: flex; gap: 6px; }

.tag {
  font-size: 11.5px; padding: 3px 9px; border-radius: 6px; font-weight: 600;
  display: inline-block; white-space: nowrap;
}
.tag-unsold { background: #eff6ff; color: #1d4ed8; }
.tag-locked { background: #fffbeb; color: #b45309; }
.tag-sold { background: #ecfdf5; color: #047857; }
.tag-pending { background: #fffbeb; color: #b45309; }
.tag-delivered { background: #ecfdf5; color: #047857; }
.tag-expired { background: #f3f4f6; color: #6b7280; }
.tag-failed { background: #fef2f2; color: #b91c1c; }

.pager { display: flex; gap: 8px; justify-content: center; align-items: center; margin-top: 18px; font-size: 13.5px; color: var(--muted); }
.pager button { padding: 6px 13px; border: 1px solid var(--line); border-radius: 7px; background: #fff; font-size: 13px; }
.pager button:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.pager button:disabled { opacity: .45; cursor: not-allowed; }

.login-screen {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
}
.login-box {
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
  padding: 34px; width: 100%; max-width: 380px; box-shadow: 0 20px 50px rgba(16,24,40,.1);
}
.login-box h1 { font-size: 21px; margin-bottom: 6px; }
.login-box p { font-size: 13.5px; color: var(--muted); margin-bottom: 24px; }

.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #1a1d29; color: #fff; padding: 11px 22px; border-radius: 10px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 999;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: #b91c1c; }

.view { display: none; }
.view.active { display: block; }

@media (max-width: 720px) {
  .hero h1 { font-size: 26px; }
  .admin-layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .side-nav { flex-direction: row; overflow-x: auto; }
  .side-nav button { white-space: nowrap; }
  .admin-main { padding: 20px 16px 60px; }
  .grid { grid-template-columns: 1fr; }
}
