:root {
  --bg: #f3f4fb;
  --card: #ffffff;
  --ink: #24283a;
  --muted: #8a8fa8;
  --line: #e7e9f2;
  --primary: #5f7fd7;
  --lav: #9b91d0;
  --pink: #e6a6bd;
  --peach: #f0b28f;
  --danger: #e05a6b;
  --success: #4caf7d;
  --warn: #e0a23a;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(95, 127, 215, 0.10);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif; background: var(--bg); color: var(--ink); font-size: 14px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.w-full { width: 100%; }

/* ---------- 布局 ---------- */
.app { display: flex; height: 100vh; }
.sidebar { width: 228px; background: linear-gradient(180deg, #5f7fd7, #9b91d0); color: #fff; display: flex; flex-direction: column; padding: 20px 14px; flex-shrink: 0; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 18px; }
.brand.center { justify-content: center; }
.logo { width: 40px; height: 40px; border-radius: 12px; background: rgba(255,255,255,.22); display: grid; place-items: center; font-size: 22px; font-weight: 700; border: 1px solid rgba(255,255,255,.35); }
.brand-title { font-size: 16px; font-weight: 700; letter-spacing: .5px; }
.brand-sub { font-size: 10px; opacity: .8; letter-spacing: 1.5px; margin-top: 2px; }
nav { flex: 1; display: flex; flex-direction: column; gap: 4px; margin-top: 8px; overflow: auto; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: rgba(255,255,255,.88); cursor: pointer; font-size: 14px; transition: background .15s; }
.nav-item:hover { background: rgba(255,255,255,.12); }
.nav-item.active { background: rgba(255,255,255,.22); font-weight: 600; }
.side-bottom { padding-top: 12px; border-top: 1px solid rgba(255,255,255,.2); }

.main { flex: 1; overflow: auto; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 18px 28px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar h1 { margin: 0; font-size: 18px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.env-tag { background: var(--bg); color: var(--muted); padding: 2px 8px; border-radius: 20px; font-size: 12px; }
.view { padding: 24px 28px; }

/* ---------- 卡片 / 统计 ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .num { font-size: 26px; font-weight: 700; margin-top: 6px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat.grad { background: linear-gradient(135deg, #5f7fd7, #9b91d0); color: #fff; border: none; }
.stat.grad .label { color: rgba(255,255,255,.85); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-head h3 { margin: 0; font-size: 15px; }

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.table th { color: var(--muted); font-weight: 600; background: #fafbff; }
.table tr:hover td { background: #f7f8ff; }
.table .actions { display: flex; gap: 6px; }
.avatar { width: 30px; height: 30px; border-radius: 8px; object-fit: cover; background: var(--lav); color: #fff; display: inline-grid; place-items: center; font-size: 14px; }

/* ---------- 徽章 ---------- */
.badge { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.badge.green { background: rgba(76,175,125,.14); color: #2e7d51; }
.badge.blue { background: rgba(95,127,215,.14); color: #3d5fc4; }
.badge.orange { background: rgba(224,162,58,.16); color: #b97f1d; }
.badge.pink { background: rgba(230,166,189,.18); color: #c0597f; }
.badge.gray { background: #eef0f6; color: var(--muted); }
.badge.red { background: rgba(224,90,107,.14); color: #c33b4e; }

/* ---------- 按钮 ---------- */
.btn { border: 1px solid transparent; border-radius: 9px; padding: 7px 14px; cursor: pointer; font-size: 13px; transition: all .15s; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { background: #f2f4ff; }
.btn.danger { background: #fff; border-color: #f1c4cc; color: var(--danger); }
.btn.danger:hover { background: #fdf0f2; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.icon { width: 32px; height: 32px; padding: 0; font-size: 20px; line-height: 1; }

/* ---------- 表单 / 弹窗 ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field span { font-size: 13px; color: var(--ink); }
.field input, .field select, .field textarea { border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; font-size: 14px; outline: none; transition: border .15s; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); }
.field.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.modal { position: fixed; inset: 0; background: rgba(20,24,40,.4); display: grid; place-items: center; z-index: 20; padding: 20px; }
.modal-card { background: var(--card); border-radius: 16px; width: 100%; max-width: 520px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.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; }
.modal-body { padding: 20px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .search { border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px; width: 240px; font-size: 13px; outline: none; }
.toolbar .search:focus { border-color: var(--primary); }

.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* ---------- 登录 ---------- */
.login { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #5f7fd7 0%, #9b91d0 45%, #e6a6bd 100%); padding: 20px; }
.login-card { background: var(--card); border-radius: 20px; padding: 34px 34px 28px; width: 100%; max-width: 380px; box-shadow: 0 24px 70px rgba(0,0,0,.25); }
.tip { font-size: 12px; color: var(--muted); margin-top: 12px; text-align: center; }
.err { color: var(--danger); font-size: 13px; }
.login .brand { justify-content: center; margin-bottom: 8px; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 22px; border-radius: 24px; font-size: 13px; z-index: 40; box-shadow: 0 10px 30px rgba(0,0,0,.25); }

@media (max-width: 820px) {
  .sidebar { width: 70px; padding: 14px 8px; }
  .brand-title, .brand-sub, .nav-item span, .side-bottom .btn { display: none; }
  .nav-item { justify-content: center; padding: 12px; }
  .view { padding: 16px; }
  .topbar { padding: 14px 16px; }
}