:root {
  --brand: #1B3A8C;
  --brand-d: #23419e;
  --gold: #C9A227;
  --bg: #f4f6fb;
  --panel: #ffffff;
  --text: #1c2331;
  --muted: #8b93a7;
  --line: #e9edf4;
  --green: #19be6b;
  --orange: #ff9f1a;
  --red: #ee4d4d;
  --side: #1b2440;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text);
  display: flex; height: 100vh; overflow: hidden;
}
/* 关键修复：JS 把 .sidebar + .main 渲染进 #root，必须让 #root 成为 flex 容器，
   否则两个块会在 #root 内垂直堆叠变成上下结构 */
#root { display: flex; flex: 1; height: 100vh; overflow: hidden; }

/* 侧边栏 */
.sidebar {
  width: 230px; background: var(--side); color: #c7cee0;
  display: flex; flex-direction: column; flex-shrink: 0;
}
.sidebar .brand {
  padding: 18px 20px; color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08); display: flex; align-items: center; gap: 12px;
}
.sidebar .brand .logo { width: 40px; height: 40px; border-radius: 10px; background: linear-gradient(135deg, var(--brand), #2a4ba0); display: flex; align-items: center; justify-content: center; flex-shrink: 0; box-shadow: 0 4px 14px rgba(201,162,39,.25); overflow: hidden; }
.sidebar .brand .logo svg { display: block; }
.sidebar .brand .brand-t { font-size: 15px; font-weight: 700; line-height: 1.2; }
.sidebar .brand .brand-t i { display: block; font-size: 11px; font-weight: 400; color: #aeb7cf; font-style: normal; margin-top: 3px; letter-spacing: .5px; }
.sidebar .nav { padding: 14px 12px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.sidebar .nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; color: #aeb7cf; cursor: pointer; font-size: 14px;
  border-radius: 9px; border-left: 3px solid transparent;
}
.sidebar .nav a .ic { display: inline-flex; width: 20px; height: 20px; align-items: center; justify-content: center; color: #c7cee0; flex-shrink: 0; }
/* inline SVG icon (used in nav, table cells, etc.) */
.ico { display:inline-block; vertical-align:-.125em; width:1em; height:1em; }
.sidebar .nav a .ico { width: 18px; height: 18px; margin-right: 2px; color: #c7cee0; }
.sidebar .nav a:hover .ico { color: #fff; }
.sidebar .nav a.active .ico { color: var(--gold); }
.sidebar .nav a:hover .ic { color: #fff; }
.sidebar .nav a.active .ic { color: var(--gold); }
.sidebar .nav a:hover { background: rgba(255,255,255,.05); color: #fff; }
.sidebar .nav a.active { background: linear-gradient(90deg, rgba(201,162,39,.18), rgba(27,58,140,.10)); color: #fff; border-left-color: var(--gold); }
.sidebar .me { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; color: #8b93a7; }
.sidebar .me .me-name { color: #fff; font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.sidebar .me .me-name .dot { width: 8px; height: 8px; border-radius: 50%; background: #19be6b; box-shadow: 0 0 0 3px rgba(25,190,107,.18); display: inline-block; }
.sidebar .me .me-role { font-size: 12px; color: #aeb7cf; margin-top: 3px; }
.sidebar .me .logout { display: inline-block; margin-top: 10px; color: var(--gold); cursor: pointer; font-size: 12px; }

/* 主体 */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  height: 56px; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px;
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 600; }
.topbar .who { font-size: 13px; color: var(--muted); }
.topbar .who b { color: var(--text); }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.searchbox { position: relative; display: flex; align-items: center; gap: 8px; background: #f4f6fb; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; height: 36px; width: 320px; transition: border-color .15s, box-shadow .15s; }
.searchbox:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(27,58,140,.1); background: #fff; }
.searchbox .sc-ic { color: var(--muted); flex-shrink: 0; }
.searchbox input { border: none; background: transparent; outline: none; flex: 1; font-size: 13px; color: var(--text); }
.search-results { position: absolute; top: 42px; right: 0; width: 380px; max-height: 360px; overflow-y: auto; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(20,30,60,.16); z-index: 50; display: none; padding: 6px; }
.search-results.show { display: block; }
.sr-item { padding: 10px 12px; border-radius: 8px; cursor: pointer; }
.sr-item:hover { background: #f4f6fb; }
.sr-top { display: flex; align-items: center; gap: 8px; }
.sr-name { font-weight: 600; font-size: 14px; color: var(--text); }
.sr-phone { margin-left: auto; font-size: 13px; color: var(--brand); font-family: ui-monospace, Menlo, Consolas, monospace; }
.sr-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.sr-empty, .sr-more { padding: 12px; font-size: 13px; color: var(--muted); text-align: center; }
.content { flex: 1; overflow-y: auto; padding: 22px 24px; }

/* 卡片/面板 */
.panel { background: var(--panel); border-radius: 12px; padding: 18px; box-shadow: 0 1px 4px rgba(20,30,60,.04); margin-bottom: 18px; }
.panel h3 { margin: 0 0 14px; font-size: 15px; }
.panel-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:14px; gap:12px; flex-wrap:wrap; }
.panel-head h3 { margin: 0; }
.row-actions { display:flex; gap:8px; }
.filters { display:flex; gap:10px 16px; flex-wrap:wrap; align-items:center; margin-bottom:14px; padding:12px 14px; background:#f7f9fd; border-radius:10px; border:1px solid var(--line); }
.filters label { font-size:12px; color:var(--muted); display:flex; align-items:center; gap:6px; }
.filters input, .filters select { padding:6px 10px; border:1px solid var(--line); border-radius:8px; font-size:13px; background:#fff; min-width:140px; }
.filters input:focus, .filters select:focus { outline:none; border-color:var(--brand); }

/* 权限页 */
.perm-card { border:1px solid var(--line); border-radius:12px; padding:16px 18px; margin-bottom:14px; background:#fff; }
.perm-head { display:flex; align-items:flex-start; justify-content:space-between; gap:14px; }
.perm-name { font-size:15px; font-weight:600; color:var(--text); }
.perm-name .badge { vertical-align:middle; margin-left:6px; }
.perm-actions { display:flex; gap:8px; flex-shrink:0; }
.perm-grid { display:grid; grid-template-columns:1fr 1fr; gap:24px; margin-top:14px; }
.perm-col h4 { display:flex; align-items:center; gap:6px; font-size:13px; margin:0 0 10px; padding-bottom:8px; border-bottom:1px dashed var(--line); color:var(--brand-d); }
.perm-col h4 .ico { color:var(--gold); }
.perm-checks { display:grid; grid-template-columns:repeat(auto-fill, minmax(130px, 1fr)); gap:8px 14px; }
.check { display:flex; align-items:center; gap:8px; font-size:13px; color:var(--text); cursor:pointer; }
.check input[type=checkbox] { width:16px; height:16px; accent-color:var(--brand); cursor:pointer; }
.check span { user-select:none; }
.perm-foot { display:flex; justify-content:space-between; align-items:center; margin-top:14px; padding-top:12px; border-top:1px dashed var(--line); }
.perm-foot .small { color:var(--muted); }

table .empty { text-align:center; padding:24px 12px; color:var(--muted); font-size:13px; }
.grid { display: grid; gap: 16px; }
.grid.c4 { grid-template-columns: repeat(4, 1fr); }
.grid.c3 { grid-template-columns: repeat(3, 1fr); }
.grid.c2 { grid-template-columns: repeat(2, 1fr); }
.kpi { background: var(--panel); border-radius: 12px; padding: 18px; box-shadow: 0 1px 4px rgba(20,30,60,.04); }
.kpi .n { font-size: 26px; font-weight: 700; color: var(--brand); }
.kpi .n.g { color: var(--gold); }
.kpi .n.o { color: var(--orange); }
.kpi .n.gr { color: var(--green); }
.kpi .l { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* 表格 */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; background: #fafbfe; }
tr:hover td { background: #fafbff; }
.tag { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 20px; background: rgba(48,86,211,.1); color: var(--brand); margin: 2px 4px 2px 0; }
.badge { font-size: 11px; padding: 2px 9px; border-radius: 20px; }
.badge.private { background: rgba(48,86,211,.12); color: var(--brand); }
.badge.public { background: rgba(255,159,26,.14); color: #d98800; }
.badge.claimed { background: rgba(25,190,107,.14); color: #0f9d58; }
.badge.管理员 { background: rgba(201,162,39,.16); color: var(--gold); }
.badge.放粉人 { background: rgba(255,159,26,.14); color: #d98800; }
.badge.接粉业务 { background: rgba(25,190,107,.14); color: #0f9d58; }
.badge.on { background: rgba(25,190,107,.14); color: #0f9d58; }
.badge.off { background: rgba(140,147,167,.18); color: var(--muted); }
.src { display:inline-block; padding:2px 10px; border-radius:8px; background:rgba(201,162,39,.12); color:#8a6a05; font-size:11px; font-weight:600 }
.mono { font-family: "Courier New", monospace; letter-spacing: 1px; }

/* 按钮 */
.btn { border: none; border-radius: 8px; padding: 9px 16px; font-size: 13px; font-weight: 600; cursor: pointer; background: var(--brand); color: #fff; }
.btn.gold { background: var(--gold); }
.btn.ghost { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.btn.warn { background: #fff; color: var(--red); border: 1px solid #f3c2c2; }
.btn.sm { padding: 5px 11px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* 表单 */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 14px; outline: none; font-family: inherit; background: #fff;
}
.field textarea { min-height: 60px; resize: vertical; }
.inline { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline .field { margin-bottom: 0; flex: 1; }

/* 登录 */
.login-screen { flex: 1; display: flex; align-items: center; justify-content: center; }
.login-box { width: 360px; background: #fff; border-radius: 14px; padding: 30px; box-shadow: 0 8px 30px rgba(20,30,60,.12); }
.login-box .lg { width: 56px; height: 56px; border-radius: 14px; background: linear-gradient(135deg, var(--brand), var(--gold)); color: #fff; font-size: 26px; font-weight: 700; display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; }
.login-box h2 { text-align: center; margin: 0 0 4px; font-size: 19px; }
.login-box p { text-align: center; color: var(--muted); font-size: 12px; margin: 0 0 20px; }
.login-box .field { margin-bottom: 14px; }
.login-box .err { color: var(--red); font-size: 13px; min-height: 18px; text-align: center; margin-bottom: 8px; }
.login-box .btn { width: 100%; }
.login-box .hint { font-size: 12px; color: var(--muted); text-align: center; margin-top: 14px; }

/* toast */
.toast { position: fixed; left: 50%; top: 30px; transform: translateX(-50%); background: rgba(28,35,49,.92); color: #fff; padding: 11px 20px; border-radius: 9px; font-size: 14px; z-index: 200; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }

.empty { color: var(--muted); text-align: center; padding: 40px; }
.note { font-size: 12.5px; color: var(--muted); background: rgba(27,58,140,.05); border-left: 3px solid var(--brand); padding: 10px 12px; border-radius: 0 8px 8px 0; line-height: 1.6; }
.barmini { display: flex; gap: 8px; flex-wrap: wrap; }
.baritem { background: #f4f6fb; border-radius: 8px; padding: 8px 12px; font-size: 12px; display: inline-flex; align-items: center; gap: 6px; }
.baritem b { color: var(--brand); }
.baritem .rm { color: var(--red); cursor: pointer; font-size: 12px; }
.baritem .rm:hover { text-decoration: underline; }

/* 团队管理（并入管控中枢） */
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mt10 { margin-top: 10px; }
.grow { flex: 1; min-width: 0; }
.team-card { border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 14px; background: #fff; }
.team-card .field { margin-bottom: 0; }
.pool-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.pool-row .un { font-weight: 600; }

/* 数据概览图表 */
.chart-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.chart-donut { flex: 0 0 auto; }
.chart-legend { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 140px; }
.lg-item { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); }
.lg-item i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; flex-shrink: 0; }
.lg-item b { color: var(--brand); margin-left: 2px; }
.big-ratio { font-size: 14px; margin-top: 4px; }
.big-ratio b { color: var(--gold); font-size: 22px; font-weight: 700; }

/* 团队管理：左右双列 + 中间间隔线 */
.teams-wrap { display: grid; grid-template-columns: 1fr 1px 1fr; gap: 18px; align-items: start; }
.teams-divider { background: linear-gradient(180deg, transparent, var(--line), transparent); }
.teams-col > .col-title { font-size: 14px; font-weight: 700; color: var(--brand-d); margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.teams-col > .col-title .cnt { font-size: 12px; color: var(--muted); font-weight: 400; }
.team-card .members-box { margin-top: 10px; display: none; border-top: 1px dashed var(--line); padding-top: 10px; }
.team-card.expanded .members-box { display: block; }
.member-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.member-row .un { font-weight: 600; }
.member-row .badge { margin-left: 0; }
.member-row .mbtns { margin-left: auto; display: flex; gap: 6px; }

/* 账号管理：删除按钮 */
.btn.danger { background: #fff; color: var(--red); border: 1px solid #f3c2c2; }

/* 员工权限：双列 + 搜索 */
.perm-search { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.perm-search input { flex: 1; max-width: 360px; border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; font-size: 14px; }
.perm-search input:focus { outline: none; border-color: var(--brand); }
.perm-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.perm-col-box > .col-title { font-size: 14px; font-weight: 700; color: var(--brand-d); margin: 0 0 12px; }
.perm-card.highlight { box-shadow: 0 0 0 2px var(--gold); }
@media (max-width: 860px) {
  .teams-wrap { grid-template-columns: 1fr; }
  .teams-divider { display: none; }
  .perm-cols { grid-template-columns: 1fr; }
}

/* 修改密码弹窗 */
.modal-overlay { position: fixed; inset: 0; background: rgba(20,30,60,.45); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-box { background: #fff; border-radius: 12px; width: 420px; max-width: 90vw; box-shadow: 0 20px 60px rgba(20,30,60,.2); overflow: hidden; }
.modal-head { padding: 18px 20px; font-size: 16px; font-weight: 700; border-bottom: 1px solid var(--line); }
.modal-body { padding: 18px 20px; }
.modal-body .field { margin-bottom: 14px; }
.modal-body .field:last-child { margin-bottom: 0; }
.modal-foot { padding: 14px 20px 18px; display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--line); }
.modal-foot .btn { padding: 9px 22px; }
