:root {
  --primary: #6c5ce7;
  --primary-dark: #5b46c9;
  --primary-light: #eeebfc;
  --bg: #f5f6fa;
  --card: #ffffff;
  --border: #e6e8f0;
  --text: #1f2430;
  --text-2: #6b7280;
  --text-3: #9aa1af;
  --danger: #e5484d;
  --danger-light: #fdecec;
  --success: #1f9d68;
  --success-light: #e6f6ee;
  --warn: #b8860b;
  --warn-light: #fbf3dd;
  --shadow: 0 1px 3px rgba(20, 23, 40, 0.06), 0 6px 24px rgba(20, 23, 40, 0.05);
  --radius: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; border: none; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #efeafc 0%, #f7f6fd 50%, #eef1fb 100%);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 36px 32px;
}
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.logo-badge {
  width: 52px; height: 52px; border-radius: 14px;
  background: linear-gradient(135deg, #7c6ef0, var(--primary-dark));
  color: #fff; font-weight: 800; font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(108, 92, 231, 0.35);
}
.logo-badge.sm { width: 40px; height: 40px; font-size: 16px; border-radius: 11px; }
.login-logo h1 { font-size: 20px; font-weight: 700; }
.login-logo p { color: var(--text-2); font-size: 13px; }
.field { display: block; margin-bottom: 18px; }
.field span { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 7px; font-weight: 500; }
.field input, .field select {
  width: 100%; padding: 11px 13px; border: 1px solid var(--border);
  border-radius: 10px; background: #fafbff; outline: none; transition: border .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); background: #fff; }
.login-error {
  background: var(--danger-light); color: var(--danger);
  padding: 9px 12px; border-radius: 9px; font-size: 13px; margin-bottom: 16px;
}
.login-hint { text-align: center; color: var(--text-3); font-size: 12px; margin-top: 18px; }

/* ---------- 按钮 ---------- */
.btn-primary {
  background: linear-gradient(135deg, #7c6ef0, var(--primary-dark));
  color: #fff; font-weight: 600; padding: 11px 18px; border-radius: 10px;
  box-shadow: 0 4px 12px rgba(108, 92, 231, 0.25); transition: transform .12s, box-shadow .12s;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(108, 92, 231, 0.32); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.btn-block { width: 100%; }
.btn-ghost {
  background: transparent; color: var(--text-2); border: 1px solid var(--border);
  padding: 9px 14px; border-radius: 9px; font-weight: 500; transition: all .15s;
}
.btn-ghost:hover { background: #f1f2f7; color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; padding: 8px 14px; border-radius: 9px; font-weight: 500; }
.btn-danger:hover { background: #d33; }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn-outline {
  background: #fff; border: 1px solid var(--border); color: var(--text);
  padding: 6px 12px; border-radius: 8px; font-size: 13px;
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

/* ---------- 主框架 ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex-shrink: 0; background: #fff; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 22px 16px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 6px 22px; border-bottom: 1px solid var(--border); }
.brand-text strong { display: block; font-size: 16px; }
.brand-text span { font-size: 12px; color: var(--text-3); }
.nav { flex: 1; padding: 16px 0; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 10px 13px; border-radius: 10px; background: transparent; color: var(--text-2);
  font-size: 14px; font-weight: 500; text-align: left; transition: all .15s;
}
.nav-item:hover { background: #f3f4f9; color: var(--text); }
.nav-item.active { background: var(--primary-light); color: var(--primary-dark); font-weight: 600; }
.nav-item .ico { width: 18px; text-align: center; }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 14px; }
.admin-identity { font-size: 13px; margin-bottom: 10px; padding: 0 4px; }
.admin-identity .nm { font-weight: 600; }
.admin-identity .role { display: inline-block; margin-top: 3px; font-size: 11px; padding: 2px 8px; border-radius: 20px; }
.role.super { background: var(--primary-light); color: var(--primary-dark); }
.role.sub { background: var(--warn-light); color: var(--warn); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 64px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; position: sticky; top: 0; z-index: 5;
}
.topbar h2 { font-size: 18px; font-weight: 700; }
.chip {
  font-size: 12px; color: var(--text-2); background: var(--bg);
  padding: 6px 12px; border-radius: 20px; border: 1px solid var(--border);
}
.content { padding: 26px 28px; max-width: 1280px; width: 100%; }

/* ---------- 卡片/统计 ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.stat-card .label { color: var(--text-2); font-size: 13px; margin-bottom: 8px; }
.stat-card .value { font-size: 28px; font-weight: 700; line-height: 1.1; }
.stat-card .value.danger { color: var(--danger); }
.stat-card .sub { color: var(--text-3); font-size: 12px; margin-top: 6px; }

.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 22px; }
.panel-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.panel-head h3 { font-size: 15px; font-weight: 700; }
.panel-body { padding: 18px 20px; }

/* ---------- 工具栏/表格 ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar input[type="search"], .toolbar input[type="text"] {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 9px; outline: none; min-width: 220px; background: #fafbff;
}
.toolbar input:focus { border-color: var(--primary); }
table { width: 100%; border-collapse: collapse; }
.table-wrap { overflow-x: auto; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px; vertical-align: middle; }
th { color: var(--text-2); font-weight: 600; font-size: 12.5px; background: #fafbff; white-space: nowrap; }
tbody tr:hover { background: #fafbff; }
td .email { font-weight: 500; }
td .meta { color: var(--text-3); font-size: 12px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--primary-light);
  color: var(--primary-dark); display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.user-cell { display: flex; align-items: center; gap: 11px; }
.badge { display: inline-block; font-size: 11.5px; padding: 2px 9px; border-radius: 20px; font-weight: 500; white-space: nowrap; }
.badge.active { background: var(--success-light); color: var(--success); }
.badge.banned, .badge.disabled { background: var(--danger-light); color: var(--danger); }
.badge.super { background: var(--primary-light); color: var(--primary-dark); }
.badge.sub { background: var(--warn-light); color: var(--warn); }
.count-pill { display: inline-block; min-width: 22px; text-align: center; background: var(--bg); border: 1px solid var(--border); border-radius: 20px; padding: 1px 8px; font-size: 12px; color: var(--text-2); margin-right: 4px; }
.row-actions { display: flex; gap: 7px; justify-content: flex-end; }

.empty { text-align: center; color: var(--text-3); padding: 40px 0; }
.pagination { display: flex; gap: 10px; align-items: center; justify-content: flex-end; padding: 14px 20px; }
.loading { color: var(--text-3); padding: 40px; text-align: center; }

/* ---------- 模态 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(22, 25, 38, 0.45);
  display: flex; align-items: flex-start; justify-content: center; padding: 48px 20px; z-index: 50; overflow-y: auto;
}
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 560px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25); animation: pop .18s ease;
}
.modal.wide { max-width: 760px; }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { font-size: 16px; }
.modal-close { background: none; font-size: 22px; color: var(--text-3); line-height: 1; }
.modal-body { padding: 22px; max-height: 68vh; overflow-y: auto; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

.detail-section { margin-bottom: 20px; }
.detail-section h4 { font-size: 13px; color: var(--text-2); margin-bottom: 10px; font-weight: 600; }
.kv { display: grid; grid-template-columns: 90px 1fr; gap: 8px 14px; font-size: 13.5px; }
.kv .k { color: var(--text-3); }
.content-item { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; }
.content-item .ci-head { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 12px; color: var(--text-3); }
.content-item .ci-body { font-size: 13.5px; white-space: pre-wrap; word-break: break-word; max-height: 120px; overflow: hidden; }
.tag { display: inline-block; background: var(--primary-light); color: var(--primary-dark); font-size: 11px; padding: 2px 8px; border-radius: 12px; margin-right: 5px; }

.perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.perm-opt { display: flex; align-items: center; gap: 9px; border: 1px solid var(--border); border-radius: 10px; padding: 11px 13px; cursor: pointer; }
.perm-opt:hover { border-color: var(--primary); }
.perm-opt input { width: 16px; height: 16px; accent-color: var(--primary); }
.perm-opt .pd { font-size: 13px; }
.perm-opt .pd small { display: block; color: var(--text-3); font-size: 11.5px; }

.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: #1f2430; color: #fff; padding: 11px 22px; border-radius: 10px;
  font-size: 14px; z-index: 100; box-shadow: 0 8px 30px rgba(0,0,0,.3); animation: pop .2s ease;
}
.toast.err { background: var(--danger); }

@media (max-width: 760px) {
  .sidebar { width: 64px; padding: 16px 8px; }
  .brand-text, .nav-item .label, .admin-identity, .sidebar-foot .btn-block { display: none; }
  .nav-item { justify-content: center; }
  .content { padding: 18px 14px; }
}
