:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 14px rgba(15, 23, 42, .06);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ---------- 顶部导航 ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav-inner { max-width: 1080px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; gap: 16px; }
.logo { font-size: 19px; font-weight: 800; color: var(--text); display: flex; align-items: center; gap: 8px; }
.logo .dot { width: 28px; height: 28px; border-radius: 9px; background: linear-gradient(135deg, #2563eb, #7c3aed); display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: 15px; }
.nav-links { display: flex; gap: 4px; flex: 1; }
.nav-links a { padding: 7px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.nav-links a.active, .nav-links a:hover { color: var(--primary); background: #eff6ff; }
.nav-user { display: flex; align-items: center; gap: 10px; }

.badge-balance { background: #f0fdf4; border: 1px solid #bbf7d0; color: var(--success); font-weight: 700; padding: 6px 12px; border-radius: 999px; font-size: 13px; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: none; border-radius: 10px; padding: 9px 16px; font-size: 14px; font-weight: 600; transition: .15s; background: var(--primary); color: #fff; }
.btn:hover { background: var(--primary-dark); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); border-color: #cbd5e1; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn-success { background: var(--success); }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: var(--warning); }
.btn-warning:hover { background: #b45309; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--bg); }

/* ---------- 首页 Banner ---------- */
.hero-banner {
  position: relative;
  overflow: hidden;
  margin: 4px 0 18px;
  padding: 26px 28px;
  border-radius: 18px;
  color: #fff;
  background: linear-gradient(120deg, #1d4ed8 0%, #4f46e5 45%, #7c3aed 100%);
  box-shadow: 0 8px 24px rgba(79, 70, 229, .25);
}
.hero-deco {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, .1);
}
.hero-deco-1 { width: 200px; height: 200px; right: -60px; top: -80px; }
.hero-deco-2 { width: 120px; height: 120px; right: 90px; bottom: -60px; background: rgba(255, 255, 255, .07); }
.hero-badge {
  display: inline-block;
  margin-bottom: 10px;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(255, 255, 255, .18);
  border: 1px solid rgba(255, 255, 255, .3);
}
.hero-title {
  position: relative;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.7;
}
.hero-title b {
  font-weight: 800;
  color: #fde047;
}
.hero-sub {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  font-size: 13.5px;
  font-weight: 600;
  color: rgba(255, 255, 255, .95);
}
.hero-sep { color: rgba(255, 255, 255, .5); }
@media (max-width: 720px) {
  .hero-banner { padding: 20px 18px; }
  .hero-title { font-size: 15px; }
}

/* ---------- 公告 ---------- */
.notice-bar { max-width: 1080px; margin: 16px auto 0; background: #fffbeb; border: 1px solid #fde68a; color: #92400e; padding: 10px 16px; border-radius: var(--radius); font-size: 13px; }

/* ---------- 商品区 ---------- */
.main { max-width: 1080px; margin: 0 auto; padding: 20px; }
.section-title { font-size: 17px; font-weight: 700; margin: 18px 2px 14px; display: flex; align-items: center; gap: 8px; }
.section-title .bar { width: 4px; height: 18px; border-radius: 4px; background: var(--primary); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.card {
  background: var(--card); border-radius: var(--radius); border: 1px solid var(--border);
  overflow: hidden; box-shadow: var(--shadow); transition: .18s; display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(15,23,42,.12); }
.card-img { width: 100%; aspect-ratio: 16/10; object-fit: contain; background: #f8fafc; display: block; padding: 14px; }
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-name { font-weight: 700; font-size: 15px; }
.card-desc { color: var(--muted); font-size: 13px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 38px; }
.card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 8px; }
.price { color: var(--danger); font-weight: 800; font-size: 18px; }
.price small { font-size: 12px; font-weight: 600; }
.stock { color: var(--muted); font-size: 12px; }
.qty-wrap { display: flex; align-items: center; gap: 6px; }
.qty-btn { width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--border); background: #fff; font-size: 15px; font-weight: 700; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; }
.qty-btn:hover { border-color: var(--primary); color: var(--primary); }
.qty-num { width: 34px; text-align: center; font-weight: 700; }

/* ---------- 弹窗 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 100; display: none; align-items: center; justify-content: center; padding: 16px; backdrop-filter: blur(2px); }
.modal-mask.show { display: flex; }
.modal { background: #fff; border-radius: 18px; width: 100%; max-width: 420px; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.25); max-height: 90vh; overflow-y: auto; animation: pop .18s ease; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal h3 { font-size: 17px; margin-bottom: 16px; display: flex; justify-content: space-between; align-items: center; }
.modal .close { border: none; background: none; font-size: 20px; color: var(--muted); cursor: pointer; padding: 0 4px; }
.modal .close:hover { color: var(--text); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.input, .select, .textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 14px; font-family: inherit; outline: none; background: #fff; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.textarea { resize: vertical; min-height: 70px; }
.form-tip { font-size: 12px; color: var(--muted); margin-top: 4px; }

.amount-input { display: flex; gap: 8px; flex-wrap: wrap; }
.amount-input .chip { flex: 1; min-width: 80px; padding: 10px 0; text-align: center; border: 1px solid var(--border); border-radius: 10px; font-weight: 700; color: var(--muted); background: #fff; font-size: 14px; }
.amount-input .chip.active { border-color: var(--primary); color: var(--primary); background: #eff6ff; }

/* ---------- 列表/表格 ---------- */
.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; color: var(--muted); font-weight: 600; padding: 10px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 10px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #f8fafc; }

.tag { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.tag-pending { background: #fef3c7; color: #92400e; }
.tag-num_sent { background: #dbeafe; color: #1d4ed8; }
.tag-code_pending { background: #fef3c7; color: #92400e; }
.tag-code_sent { background: #dcfce7; color: #166534; }
.tag-shipped { background: #dbeafe; color: #1d4ed8; }
.tag-completed { background: #dcfce7; color: #166534; }
.tag-cancelled { background: #f1f5f9; color: #64748b; }
.tag-rejected { background: #fee2e2; color: #991b1b; }
.tag-confirmed { background: #dcfce7; color: #166534; }

/* ---------- 空状态 ---------- */
.empty { text-align: center; color: var(--muted); padding: 60px 0; }
.empty .icon { font-size: 40px; margin-bottom: 10px; }

/* ---------- 吐司提示 ---------- */
.toast-wrap { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 999; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #1e293b; color: #fff; padding: 10px 20px; border-radius: 10px; font-size: 14px; animation: slideDown .25s ease; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 90vw; }
.toast.ok { background: var(--success); }
.toast.err { background: var(--danger); }
@keyframes slideDown { from { transform: translateY(-12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---------- 后台 ---------- */
.admin-layout { display: flex; min-height: 100vh; }
.admin-side { width: 210px; background: #0f172a; color: #cbd5e1; flex-shrink: 0; padding: 20px 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.admin-side .logo { color: #fff; padding: 0 20px 24px; font-size: 17px; }
.admin-side .logo .dot { background: linear-gradient(135deg, #3b82f6, #8b5cf6); }
.admin-side nav a { display: flex; align-items: center; gap: 10px; padding: 11px 20px; color: #94a3b8; font-weight: 500; font-size: 14px; transition: .15s; border-left: 3px solid transparent; }
.admin-side nav a:hover { background: rgba(255,255,255,.05); color: #e2e8f0; }
.admin-side nav a.active { background: rgba(59,130,246,.15); color: #60a5fa; border-left-color: #3b82f6; }
.admin-main { flex: 1; padding: 24px 28px; min-width: 0; overflow-x: auto; }
.admin-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.admin-top h2 { font-size: 20px; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat-card .num { font-size: 24px; font-weight: 800; margin-top: 4px; }
.stat-card .lbl { color: var(--muted); font-size: 12px; font-weight: 600; }
.stat-card .num.blue { color: var(--primary); }
.stat-card .num.green { color: var(--success); }
.stat-card .num.orange { color: var(--warning); }
.stat-card .num.red { color: var(--danger); }

.tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs .tab { padding: 8px 16px; border-radius: 999px; border: 1px solid var(--border); background: #fff; font-size: 13px; font-weight: 600; color: var(--muted); }
.tabs .tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.toolbar .input { width: auto; }

.img-thumb { width: 56px; height: 42px; object-fit: contain; background: #f8fafc; border-radius: 7px; }

@media (max-width: 720px) {
  .admin-layout { flex-direction: column; }
  .admin-side { width: 100%; height: auto; position: static; padding: 12px 0; }
  .admin-side .logo { padding-bottom: 10px; }
  .admin-side nav { display: flex; flex-wrap: wrap; }
  .admin-side nav a { padding: 9px 14px; }
  .nav-inner { flex-wrap: wrap; }
  .two-col { grid-template-columns: 1fr !important; }
}