:root {
  --bg-primary: #f8f9fa;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --border-color: #e9ecef;
  --text-primary: #212529;
  --text-secondary: #6c757d;
  --primary-color: #6366f1;
  --primary-soft: #eef2ff;
  --success-color: #10b981;
  --danger-color: #ef4444;
  --warning-color: #f59e0b;
  --info-color: #3b82f6;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04), 0 1px 3px rgba(0,0,0,.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,.06);
  --radius: 12px;
}
[data-theme="dark"] {
  --bg-primary: #0f0f0f;
  --bg-card: #1e1e1e;
  --bg-sidebar: #161616;
  --border-color: #333333;
  --text-primary: #f1f3f5;
  --text-secondary: #adb5bd;
  --primary-color: #818cf8;
  --primary-soft: #2a2a4a;
  --success-color: #34d399;
  --danger-color: #f87171;
  --warning-color: #fbbf24;
  --info-color: #60a5fa;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,.4);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg-primary); color: var(--text-primary); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* 登录 */
#login-screen { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%); }
.login-card { width: 380px; max-width: 90vw; background: var(--bg-card); border-radius: 16px; padding: 40px 32px; box-shadow: var(--shadow-md); }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .ico { width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 14px; background: linear-gradient(135deg, #6366f1, #8b5cf6); display: flex; align-items: center; justify-content: center; font-size: 32px; }
.login-logo h1 { font-size: 20px; }
.login-logo p { color: var(--text-secondary); font-size: 13px; margin-top: 4px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.field input { width: 100%; height: 42px; padding: 0 14px; border: 1px solid var(--border-color); border-radius: 10px; background: var(--bg-primary); color: var(--text-primary); font-size: 14px; }
.field input:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 3px var(--primary-soft); }
.login-btn { width: 100%; height: 44px; border: none; border-radius: 10px; cursor: pointer; background: var(--primary-color); color: #fff; font-size: 15px; font-weight: 600; margin-top: 8px; }
.login-btn:hover { opacity: .92; }
.login-hint { text-align: center; color: var(--text-secondary); font-size: 12px; margin-top: 16px; }
.login-form { margin-top: 4px; }

/* 布局 */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 232px; flex-shrink: 0; background: var(--bg-sidebar); border-right: 1px solid var(--border-color); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side-logo { display: flex; align-items: center; gap: 10px; padding: 20px 20px 16px; border-bottom: 1px solid var(--border-color); }
.side-logo .ico { width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0; background: linear-gradient(135deg, #6366f1, #8b5cf6); display: flex; align-items: center; justify-content: center; font-size: 18px; }
.side-logo .txt b { font-size: 15px; display: block; }
.side-logo .txt span { font-size: 11px; color: var(--text-secondary); }
.nav { flex: 1; padding: 12px 12px; overflow-y: auto; }
.nav-group { font-size: 11px; color: var(--text-secondary); padding: 14px 12px 6px; letter-spacing: .5px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 9px; cursor: pointer; color: var(--text-secondary); font-size: 14px; margin-bottom: 2px; transition: .15s; }
.nav-item:hover { background: var(--bg-primary); color: var(--text-primary); }
.nav-item.active { background: var(--primary-soft); color: var(--primary-color); font-weight: 600; }
.nav-item .ni { font-size: 17px; width: 20px; text-align: center; }
.nav-back { font-size: 12px; color: var(--primary-color); padding: 4px 12px 10px; cursor: pointer; }
.nav-back:hover { text-decoration: underline; }
.side-foot { padding: 14px 16px; border-top: 1px solid var(--border-color); display: flex; align-items: center; gap: 10px; }
.side-foot .av { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-color); display: flex; align-items: center; justify-content: center; font-weight: 700; }
.side-foot .info b { font-size: 13px; display: block; }
.side-foot .info span { font-size: 11px; color: var(--text-secondary); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 60px; flex-shrink: 0; background: var(--bg-card); border-bottom: 1px solid var(--border-color); display: flex; align-items: center; padding: 0 24px; gap: 16px; position: sticky; top: 0; z-index: 10; }
.topbar h2 { font-size: 17px; font-weight: 700; }
.topbar .crumb { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.topbar .spacer { flex: 1; }
.icon-btn { width: 38px; height: 38px; border-radius: 9px; border: 1px solid var(--border-color); background: var(--bg-primary); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 16px; color: var(--text-secondary); }
.icon-btn:hover { color: var(--text-primary); }
.avatar-menu { position: relative; }
.av-btn { width: 38px; height: 38px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-color); font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.dropdown { position: absolute; right: 0; top: 46px; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 10px; box-shadow: var(--shadow-md); padding: 6px; min-width: 150px; z-index: 50; }
.dd-item { padding: 9px 12px; border-radius: 7px; cursor: pointer; font-size: 13px; }
.dd-item:hover { background: var(--bg-primary); }
.dd-item.danger { color: var(--danger-color); }

.content { padding: 24px; overflow-y: auto; flex: 1; }
.view { display: none; } .view.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* 卡片 / 统计 */
.card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.card-title { font-size: 14px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); }
.stat-card .lbl { font-size: 13px; color: var(--text-secondary); }
.stat-card .val { font-size: 26px; font-weight: 700; margin-top: 6px; }
.stat-card .sub { font-size: 12px; margin-top: 4px; }
.stat-card .sub.up { color: var(--success-color); }
.stat-card .sub.down { color: var(--danger-color); }
.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.bar-row .name { width: 72px; font-size: 13px; flex-shrink: 0; }
.bar-track { flex: 1; height: 8px; background: var(--bg-primary); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; background: var(--primary-color); }
.bar-row .pct { width: 38px; text-align: right; font-size: 12px; color: var(--text-secondary); }
svg.trend { width: 100%; height: 180px; }

/* 表格 */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border-color); }
th { color: var(--text-secondary); font-weight: 600; font-size: 12px; }
tbody tr:hover { background: var(--bg-primary); }
td .user-cell { display: flex; align-items: center; gap: 8px; }
td .uav { width: 28px; height: 28px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-color); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.link-btn { color: var(--primary-color); cursor: pointer; font-weight: 600; }
.link-btn:hover { text-decoration: underline; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.green { background: rgba(16,185,129,.12); color: var(--success-color); }
.badge.red { background: rgba(239,68,68,.12); color: var(--danger-color); }
.badge.gray { background: var(--bg-primary); color: var(--text-secondary); }
.badge.amber { background: rgba(245,158,11,.14); color: var(--warning-color); }
.tag-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.pill { font-size: 11px; padding: 1px 8px; border-radius: 6px; background: var(--bg-primary); color: var(--text-secondary); margin-left: 6px; }

/* 用户详情 */
.detail-head { display: flex; align-items: center; gap: 16px; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm); margin-bottom: 18px; }
.detail-head .big-av { width: 56px; height: 56px; border-radius: 16px; background: linear-gradient(135deg,#6366f1,#8b5cf6); color:#fff; display:flex; align-items:center; justify-content:center; font-size:24px; font-weight:700; }
.detail-head .meta b { font-size: 18px; }
.detail-head .meta .line { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.detail-head .spacer { flex: 1; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-color); margin-bottom: 18px; }
.tab { padding: 10px 16px; cursor: pointer; font-size: 14px; color: var(--text-secondary); border-bottom: 2px solid transparent; }
.tab.active { color: var(--primary-color); font-weight: 600; border-bottom-color: var(--primary-color); }
.tab-pane { display: none; } .tab-pane.active { display: block; }
.scope-note { background: var(--primary-soft); border: 1px solid var(--primary-color); border-radius: 10px; padding: 11px 14px; font-size: 13px; color: var(--primary-color); margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }

/* 用户详情 - 资料卡 */
.profile-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; margin-bottom: 16px; }
.profile-card .pc-cover { height: 72px; background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%); }
.profile-card .pc-body { display: flex; align-items: flex-end; gap: 18px; padding: 0 22px 20px; margin-top: -34px; flex-wrap: wrap; }
.profile-card .pc-avatar { width: 68px; height: 68px; border-radius: 20px; background: linear-gradient(135deg,#6366f1,#8b5cf6); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 30px; font-weight: 700; border: 3px solid var(--bg-card); flex-shrink: 0; box-shadow: var(--shadow-sm); }
.profile-card .pc-info { flex: 1; min-width: 200px; padding-top: 42px; }
.profile-card .pc-name { font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.profile-card .pc-sub { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.profile-card .pc-stats { display: flex; gap: 28px; margin-top: 16px; }
.profile-card .pc-stat { display: flex; flex-direction: column; }
.profile-card .pc-stat .v { font-size: 19px; font-weight: 700; }
.profile-card .pc-stat .l { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.profile-card .pc-actions { display: flex; gap: 10px; align-items: center; padding-top: 42px; }

/* 关联联系人标签 & 空值 */
.contact-tag { display: inline-block; padding: 2px 9px; border-radius: 20px; background: var(--primary-soft); color: var(--primary-color); font-size: 12px; margin: 1px 4px 1px 0; white-space: nowrap; }
.muted { color: var(--text-secondary); }

/* 分页 - 每页条数 */
.pgi-sel { height: 30px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-primary); font-size: 12px; padding: 0 6px; cursor: pointer; }
.pgi-size { font-size: 12px; color: var(--text-secondary); }

/* 分类列表（默认分类页） */
.cat-list { display: flex; flex-direction: column; gap: 8px; }
.cat-row { display: flex; align-items: center; gap: 12px; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 10px; padding: 10px 14px; }
.cat-row .ic { width: 34px; height: 34px; border-radius: 9px; background: var(--bg-primary); display: flex; align-items: center; justify-content: center; font-size: 18px; }
.cat-row .nm { font-weight: 600; }
.cat-row .pin { margin-left: auto; color: var(--text-secondary); font-size: 12px; }

.warn-banner { background: rgba(245,158,11,.1); border: 1px solid var(--warning-color); border-radius: 10px; padding: 14px 16px; font-size: 13px; color: var(--warning-color); margin-bottom: 18px; display: flex; gap: 10px; align-items: flex-start; line-height: 1.6; }
.warn-banner b { color: var(--warning-color); }

/* 工具栏 / 表单 */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.btn { height: 38px; padding: 0 16px; border-radius: 9px; border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-primary); cursor: pointer; font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { background: var(--bg-primary); }
.btn.primary { background: var(--primary-color); color: #fff; border-color: var(--primary-color); }
.btn.primary:hover { opacity: .92; }
.btn.danger { border-color: var(--danger-color); color: var(--danger-color); }
.btn.sm { height: 30px; padding: 0 12px; font-size: 12px; }
select.inp, input.inp { height: 38px; padding: 0 12px; border: 1px solid var(--border-color); border-radius: 9px; background: var(--bg-primary); color: var(--text-primary); font-size: 13px; }
input.inp { min-width: 160px; }

/* 开关 */
.switch-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 4px; border-bottom: 1px solid var(--border-color); }
.switch-row:last-child { border-bottom: none; }
.switch-row .label b { display: block; font-size: 14px; }
.switch-row .label span { font-size: 12px; color: var(--text-secondary); }
.toggle { width: 44px; height: 26px; border-radius: 13px; background: var(--border-color); position: relative; cursor: pointer; transition: .2s; flex-shrink: 0; }
.toggle.on { background: var(--success-color); }
.toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: .2s; }
.toggle.on::after { left: 21px; }

.empty-hint { text-align: center; color: var(--text-secondary); padding: 40px; font-size: 13px; }
.loading { text-align: center; color: var(--text-secondary); padding: 40px; font-size: 13px; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200; display: flex; align-items: center; justify-content: center; }
.modal { width: 420px; max-width: 92vw; background: var(--bg-card); border-radius: 14px; padding: 24px; box-shadow: var(--shadow-md); }
.modal h3 { font-size: 16px; margin-bottom: 18px; }
.modal .field { margin-bottom: 14px; }
.modal .field label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.modal .field input { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--border-color); border-radius: 9px; background: var(--bg-primary); color: var(--text-primary); font-size: 14px; }
.modal .field input:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 3px var(--primary-soft); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.modal-msg { font-size: 12px; margin-top: 10px; }
.modal-msg.err { color: var(--danger-color); }
.modal-msg.ok { color: var(--success-color); }

/* toast */
.toast { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); background: #212529; color: #fff; padding: 11px 20px; border-radius: 10px; font-size: 13px; z-index: 300; box-shadow: var(--shadow-md); }

/* 分页 */
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 14px 0 4px; }
.pgi-btn { height: 32px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-primary); cursor: pointer; font-size: 13px; font-weight: 600; transition: .15s; }
.pgi-btn:hover:not(.disabled) { background: var(--primary-soft); color: var(--primary-color); border-color: var(--primary-color); }
.pgi-btn.disabled { opacity: .45; cursor: default; }
.pgi-info { font-size: 12px; color: var(--text-secondary); }

@media (max-width: 860px) {
  .sidebar { width: 64px; }
  .side-logo .txt, .nav-group, .nav-item span:not(.ni), .side-foot .info, .nav-back { display: none; }
  .nav-item { justify-content: center; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
}
