:root {
  --primary: #4f6ef7;
  --primary-dark: #3a55d9;
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #23272e;
  --muted: #8a93a3;
  --border: #e6eaf2;
  --danger: #e5484d;
  --ok: #18a058;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(30, 40, 80, .08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px;
}
a { color: var(--primary); text-decoration: none; }
.container { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* ===== 顶部导航 ===== */
.topbar { background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
.topbar-inner { display: flex; align-items: center; height: 58px; gap: 18px; }
.logo { font-size: 20px; font-weight: 700; color: var(--primary); white-space: nowrap; }
.nav { display: flex; gap: 6px; flex: 1; }
.nav a { padding: 6px 12px; border-radius: 8px; color: var(--text); font-size: 14px; }
.nav a:hover, .nav a.active { background: var(--bg); color: var(--primary); font-weight: 600; }
.user-area { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.menu-btn { display: none; background: none; border: none; font-size: 22px; cursor: pointer; }

/* ===== 按钮 / 表单 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: 10px; border: 1px solid transparent;
  font-size: 14px; cursor: pointer; transition: .15s; background: var(--primary); color: #fff;
}
.btn:hover { background: var(--primary-dark); }
.btn.ghost { background: #fff; color: var(--primary); border-color: var(--primary); }
.btn.ghost:hover { background: #f0f3ff; }
.btn.warn { background: #ff9800; }
.btn.danger { background: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn.block { width: 100%; padding: 12px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 14px; outline: none; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
label.field { display: block; margin-bottom: 12px; }
label.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }

/* ===== 卡片 / 布局 ===== */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.grid { display: grid; gap: 16px; }
.grid.products { grid-template-columns: repeat(4, 1fr); }
.grid.cols2 { grid-template-columns: 1fr 1fr; }
.grid.cols3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols4 { grid-template-columns: repeat(4, 1fr); }
.page-title { font-size: 22px; font-weight: 700; margin: 24px 0 16px; }
.muted { color: var(--muted); font-size: 13px; }
.price { color: var(--danger); font-weight: 700; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; background: #eef1fe; color: var(--primary); }
.tag.gray { background: #f0f2f5; color: var(--muted); }
.tag.ok { background: #e7f7ee; color: var(--ok); }
.tag.red { background: #fdeaea; color: var(--danger); }

/* ===== 轮播 ===== */
.banner { position: relative; border-radius: var(--radius); overflow: hidden; margin-top: 16px; height: 220px; background: linear-gradient(120deg, #4f6ef7, #7f8ff8); }
.banner .slides { display: flex; height: 100%; transition: transform .4s; }
.banner .slide { min-width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 26px; font-weight: 700; cursor: pointer; }
.notice-bar { margin-top: 12px; background: #fff8e6; color: #9a6b00; border-radius: 10px; padding: 10px 16px; font-size: 13px; }

/* ===== 商品卡 ===== */
.p-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; cursor: pointer; transition: .15s; display: flex; flex-direction: column; }
.p-card:hover { transform: translateY(-3px); }
.p-thumb { height: 110px; display: flex; align-items: center; justify-content: center; font-size: 38px; color: #fff; }
.p-body { padding: 14px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.p-name { font-weight: 600; font-size: 15px; }
.p-foot { display: flex; justify-content: space-between; align-items: center; }

/* ===== 表格 ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; background: #fafbfd; }
code.code { background: #f0f3ff; color: var(--primary); padding: 2px 8px; border-radius: 6px; font-size: 12px; user-select: all; }

/* ===== 模态框 ===== */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: none; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal-mask.show { display: flex; }
.modal { background: #fff; border-radius: 14px; padding: 22px; width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; position: relative; }
.modal h3 { margin-bottom: 16px; }
.modal-close { position: absolute; top: 10px; right: 12px; width: 30px; height: 30px; border: none; background: transparent; font-size: 20px; line-height: 1; color: #9aa0ab; cursor: pointer; border-radius: 8px; padding: 0; }
.modal-close:hover { color: #333; background: #f2f3f7; }

/* ===== Toast ===== */
#toast { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); background: rgba(30,30,40,.9); color: #fff; padding: 10px 20px; border-radius: 10px; font-size: 14px; display: none; z-index: 200; max-width: 90vw; }

/* ===== 侧边栏布局（后台 / 会员中心） ===== */
.layout { display: flex; gap: 20px; padding: 20px 0 40px; }
.side { width: 210px; flex-shrink: 0; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; align-self: flex-start; position: sticky; top: 78px; }
.side a { display: block; padding: 10px 14px; border-radius: 8px; color: var(--text); margin-bottom: 4px; font-size: 14px; }
.side a.active, .side a:hover { background: #eef1fe; color: var(--primary); font-weight: 600; }
.main { flex: 1; min-width: 0; }
.stat-num { font-size: 26px; font-weight: 700; }
.stat-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.stat-card .muted { margin-top: 6px; }

/* ===== 手机适配 ===== */
@media (max-width: 860px) {
  .grid.products, .grid.cols4 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .menu-btn { display: block; }
  .nav { display: none; position: absolute; top: 58px; left: 0; right: 0; background: #fff; flex-direction: column; padding: 10px 16px 16px; border-bottom: 1px solid var(--border); box-shadow: var(--shadow); }
  .nav.open { display: flex; }
  .nav a { padding: 12px; }
  .grid.products, .grid.cols2, .grid.cols3, .grid.cols4 { grid-template-columns: 1fr 1fr; }
  .layout { flex-direction: column; }
  .side { width: 100%; position: static; display: flex; flex-wrap: wrap; }
  .side a { padding: 8px 12px; }
  .banner { height: 150px; }
  .banner .slide { font-size: 18px; padding: 0 20px; text-align: center; }
  .page-title { font-size: 18px; }
  .topbar-inner { gap: 10px; }
  .user-area .btn { padding: 7px 10px; font-size: 12px; }
  table { font-size: 12px; }
  th, td { padding: 8px 8px; }
}
@media (max-width: 380px) {
  .grid.products, .grid.cols2, .grid.cols3, .grid.cols4 { grid-template-columns: 1fr; }
}
