:root {
  --bg: #f4f5f7;
  --surface: #fff;
  --surface-2: #f6f7f9;
  --border: #e3e5e9;
  --text: #1f2329;
  --text-2: #5c6470;
  --text-3: #9098a4;
  --brand: #2563eb;
  --brand-soft: #eef3fe;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --ok: #0f9960;
  --ok-soft: #e8f7ef;
  --warn: #b7791f;
  --warn-soft: #fdf6e7;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { opacity: .85; }
[hidden] { display: none !important; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 208px;
  flex: none;
  background: #fff;
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sb-brand {
  display: flex; align-items: center; gap: 9px;
  padding: 16px 16px 14px; border-bottom: 1px solid var(--border);
}
.sb-brand .mark {
  width: 28px; height: 28px; border-radius: 8px; background: var(--brand);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 600; flex: none;
}
.sb-brand b { font-size: 15px; }
.sb-brand span { font-size: 11.5px; color: var(--text-3); display: block; margin-top: -2px; }
.sb-group { padding: 12px 8px 4px; font-size: 11.5px; color: var(--text-3); padding-left: 18px; letter-spacing: .3px; }
.sb-nav { flex: 1; overflow: auto; padding: 4px 8px 12px; }
.sb-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 8px; color: var(--text-2);
  font-size: 13.5px; margin-bottom: 2px;
}
.sb-item .ic { width: 18px; text-align: center; opacity: .8; font-size: 13px; }
.sb-item:hover { background: var(--surface-2); color: var(--text); }
.sb-item.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.sb-foot { border-top: 1px solid var(--border); padding: 10px 14px; font-size: 12px; color: var(--text-3); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 56px; flex: none; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 22px;
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { margin: 0; font-size: 16px; font-weight: 600; }
.topbar .tb-right { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--text-2); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--brand-soft);
  color: var(--brand); display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex: none;
}
.link-btn { background: none; border: 0; color: var(--text-3); cursor: pointer; font: inherit; font-size: 12.5px; }
.link-btn:hover { color: var(--brand); }

.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 20px 22px 40px; display: flex; flex-direction: column; gap: 16px; }

/* ---------- 卡片 ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  font-weight: 700; font-size: 15px;
}
.card-h .hint { font-weight: 400; }
.card-b { padding: 18px; }
.hint { font-size: 12px; color: var(--text-3); line-height: 1.7; }
.section-title { font-size: 13px; font-weight: 700; color: var(--text-2); margin: 0 0 10px; }

/* ---------- 表单 ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 13px; }
.field > label { font-size: 12.5px; color: var(--text-2); }
.field .req { color: var(--danger); margin-left: 2px; }
input, select, textarea {
  font: inherit; border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 11px; outline: none; width: 100%; background: #fff; color: var(--text);
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
input:disabled { background: var(--surface-2); color: var(--text-3); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.checkbox { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.checkbox input { width: auto; }

/* ---------- 按钮 ---------- */
.btn {
  font: inherit; font-weight: 600; border-radius: 9px; padding: 7px 13px;
  border: 1px solid var(--border); background: #fff; color: var(--text-2);
  cursor: pointer; font-size: 13px; transition: all .14s; white-space: nowrap;
}
.btn:hover { color: var(--text); border-color: #cfd4dc; }
.btn.primary { background: var(--brand); border-color: transparent; color: #fff; }
.btn.primary:hover { filter: brightness(1.06); color: #fff; }
.btn.danger { color: var(--danger); border-color: #f0c9c4; background: var(--danger-soft); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--brand); }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { text-align: left; padding: 10px 9px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: 11.5px; color: var(--text-3); font-weight: 600; background: var(--surface-2); letter-spacing: .3px; }
.table th:first-child { border-radius: 8px 0 0 8px; }
.table th:last-child { border-radius: 0 8px 8px 0; }
.table tbody tr:hover td { background: #fafaff; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* ---------- 统计块 ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 820px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; background: var(--surface); }
.stat b { display: block; font-size: 24px; font-weight: 800; letter-spacing: -.5px; line-height: 1.3; }
.stat span { font-size: 12px; color: var(--text-3); }
.stat.brand b { color: var(--brand); }

/* ---------- 标签 ---------- */
.pill { display: inline-block; font-size: 11.5px; border-radius: 999px; padding: 1px 9px; border: 1px solid var(--border); color: var(--text-2); background: #fff; }
.pill.ok { color: var(--ok); border-color: #bfe6d4; background: var(--ok-soft); }
.pill.warn { color: var(--warn); border-color: #f0e0bb; background: var(--warn-soft); }
.pill.danger { color: var(--danger); border-color: #f0c9c4; background: var(--danger-soft); }
.pill.brand { color: var(--brand); border-color: #cddcfb; background: var(--brand-soft); }

/* ---------- 空态 ---------- */
.empty { text-align: center; color: var(--text-3); font-size: 13px; padding: 36px 10px; }

/* ---------- 提示 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 36px; transform: translateX(-50%) translateY(16px);
  background: rgba(16, 24, 40, .92); color: #fff; padding: 9px 18px; border-radius: 8px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 999; max-width: 80vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 移动端 ---------- */
.mobile-nav { display: none; }
@media (max-width: 880px) {
  .sidebar { display: none; }
  .wrap { padding: 14px 12px 84px; }
  .topbar { padding: 0 14px; height: 52px; }
  .mobile-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: #fff; border-top: 1px solid var(--border); padding: 6px 0 max(6px, env(safe-area-inset-bottom));
  }
  .mobile-nav a {
    flex: 1; text-align: center; font-size: 11px; color: var(--text-3);
    display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0;
  }
  .mobile-nav a .ic { font-size: 16px; }
  .mobile-nav a.on { color: var(--brand); font-weight: 600; }
}
