/* 盛世前程年度员工评比系统 — 双主题（深色驾驶舱 / 清爽浅色） */
:root {
  --bg: #0a0f1c;
  --panel: #101828;
  --panel2: #16203a;
  --line: #23304d;
  --text: #e5ecf8;
  --muted: #8296b8;
  --blue: #3b82f6;
  --blue2: #60a5fa;
  --green: #22c55e;
  --gold: #f0b429;
  --red: #ef4444;
  --s: #f0b429; --a: #60a5fa; --b: #34d399; --c: #7c8db0; --d: #f87171;
  /* 语义变量（深色 = 默认） */
  --head: #ffffff;              /* 标题/强调文字 */
  --soft: #cfe0ff;              /* 次亮文字、悬停态文字 */
  --avatar-c: #cfe0ff;          /* 头像首字颜色 */
  --on-accent: #0a0f1c;         /* 金色色块上的文字 */
  --bg-grad: radial-gradient(1200px 700px at 70% -10%, #14224a 0%, var(--bg) 55%);
  --topbar: rgba(13, 20, 38, .92);
  --bar-solid: rgba(11, 17, 32, .97);
  --card-bg: linear-gradient(180deg, rgba(22,32,58,.75), rgba(16,24,40,.9));
  --card-hover-bg: linear-gradient(180deg, rgba(28,42,74,.75), rgba(16,24,40,.92));
  --card-tint: rgba(255,255,255,.018);
  --chip-bg: rgba(16,24,40,.7);
  --panel-grad: linear-gradient(180deg, #101a2f, #0c1424);
  --panel-line: #2a3a63;
  --hover-line: #3f5c96;
  --tbl-line: rgba(35,48,77,.5);
  --dash-line: rgba(35,48,77,.8);
  --input-bg: rgba(10,16,30,.6);
  --opt-bg: rgba(10,16,30,.45);
  --gp-bg: rgba(10,16,30,.5);
  --avatar-grad: linear-gradient(135deg, #2c4a8a, #1a2c56);
  --sel-opt-bg: #121a2c;
  --mask-bg: rgba(4,8,18,.7);
  --win-shadow: 0 24px 80px rgba(0,0,0,.6);
  --iframe-bg: #0a1122;
  --sum-text: #e2d2a9;
}
/* ---------- 主题：清爽浅色 ---------- */
html[data-theme="light"] {
  --bg: #eef1f6; --panel: #ffffff; --panel2: #f3f6fb; --line: #d8e0ec;
  --text: #243044; --muted: #697a93;
  --blue: #2563eb; --blue2: #1d4ed8; --green: #16a34a; --gold: #b07c0a; --red: #dc2626;
  --s: #a16207; --a: #1d4ed8; --b: #047857; --c: #64748b; --d: #dc2626;
  --head: #101d33; --soft: #2c4a7c; --avatar-c: #46608c; --on-accent: #ffffff;
  --bg-grad: radial-gradient(1100px 600px at 70% -10%, #ffffff 0%, var(--bg) 60%);
  --topbar: rgba(255,255,255,.92);
  --bar-solid: rgba(255,255,255,.97);
  --card-bg: #ffffff;
  --card-hover-bg: #f6faff;
  --card-tint: #fafbfe;
  --chip-bg: #ffffff;
  --panel-grad: linear-gradient(180deg, #ffffff, #f9fbfe);
  --panel-line: #c6d3e7;
  --hover-line: #93b4e8;
  --tbl-line: #e4eaf3;
  --dash-line: #dde5f0;
  --input-bg: #ffffff;
  --opt-bg: #f6f9fd;
  --gp-bg: #f9fbfe;
  --avatar-grad: linear-gradient(135deg, #dce7f7, #c3d4ec);
  --sel-opt-bg: #ffffff;
  --mask-bg: rgba(30,41,59,.45);
  --win-shadow: 0 24px 80px rgba(30,50,90,.25);
  --iframe-bg: #f4f7fb;
  --sum-text: #8a6414;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg-grad);
  color: var(--text);
  font: 14px/1.6 "PingFang SC", "Microsoft YaHei", sans-serif;
  min-height: 100vh;
}
a { color: var(--blue2); text-decoration: none; }

/* 顶栏 */
.topbar {
  display: flex; align-items: center; gap: 16px;
  height: 56px; padding: 0 24px;
  background: var(--topbar); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50; backdrop-filter: blur(6px);
}
.topbar .logo { font-size: 16px; font-weight: 700; letter-spacing: 1px; color: var(--head); }
.topbar .logo b { color: var(--gold); }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a {
  padding: 6px 14px; border-radius: 8px; color: var(--muted); font-size: 13px;
}
.topbar nav a:hover { color: var(--head); background: rgba(59,130,246,.12); }
.topbar nav a.active { color: #fff; background: var(--blue); }
.topbar .user { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.topbar .user .role { color: var(--gold); }

/* 布局 */
.layout { display: flex; min-height: calc(100vh - 56px); }
.sidebar { width: 210px; border-right: 1px solid var(--line); padding: 16px 12px; flex-shrink: 0; }
.sidebar h4 { color: var(--muted); font-size: 12px; margin: 8px 8px 8px; font-weight: 500; }
.sidebar .item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; border-radius: 8px; cursor: pointer; color: var(--text); font-size: 13px;
}
.sidebar .item:hover { background: rgba(59,130,246,.1); }
.sidebar .item.active { background: rgba(59,130,246,.22); color: var(--head); }
.sidebar .item .n { color: var(--muted); font-size: 12px; }
.main { flex: 1; padding: 20px 24px; overflow-x: hidden; }

/* 卡片 */
.card {
  background: var(--card-bg);
  border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px;
}
.card h3 { font-size: 14px; font-weight: 600; margin-bottom: 12px; color: var(--head); }
.card h3 .sub { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 8px; }
.grid { display: grid; gap: 14px; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.kpi { padding: 14px 18px; }
.kpi .v { font-size: 28px; font-weight: 700; color: var(--head); }
.kpi .v small { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 4px; }
.kpi .t { color: var(--muted); font-size: 12px; }
.kpi.blue .v { color: var(--blue2); } .kpi.gold .v { color: var(--gold); } .kpi.green .v { color: var(--green); }

/* 档次徽章 */
.badge {
  display: inline-block; min-width: 22px; text-align: center; padding: 1px 8px;
  border-radius: 20px; font-size: 12px; font-weight: 700; line-height: 20px;
}
.badge.S { background: rgba(240,180,41,.16); color: var(--s); border: 1px solid rgba(240,180,41,.45); }
.badge.A { background: rgba(96,165,250,.16); color: var(--a); border: 1px solid rgba(96,165,250,.45); }
.badge.B { background: rgba(52,211,153,.14); color: var(--b); border: 1px solid rgba(52,211,153,.45); }
.badge.C { background: rgba(124,141,176,.14); color: var(--c); border: 1px solid rgba(124,141,176,.45); }
.badge.D { background: rgba(248,113,113,.14); color: var(--d); border: 1px solid rgba(248,113,113,.45); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 11px; background: rgba(59,130,246,.12); color: var(--blue2); }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 7px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel2); color: var(--text); font-size: 13px;
}
.btn:hover { border-color: var(--blue); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--blue2); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--on-accent); font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--d); border-color: rgba(248,113,113,.4); }
.btn.sm { padding: 4px 10px; font-size: 12px; }

/* 表格 */
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 500; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--tbl-line); vertical-align: top; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: rgba(59,130,246,.07); }

/* 表单 */
.field { margin-bottom: 12px; }
.field label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
input[type=text], input[type=password], input[type=date], select, textarea {
  width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--input-bg); color: var(--text); font-size: 13px; outline: none;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); }
textarea { resize: vertical; min-height: 60px; }
select option { background: var(--sel-opt-bg); color: var(--text); }
.inline { display: flex; gap: 8px; align-items: center; }

/* 员工小卡 */
.emp-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 8px; cursor: pointer; border: 1px solid transparent;
}
.emp-item:hover { background: rgba(59,130,246,.09); }
.emp-item.active { background: rgba(59,130,246,.18); border-color: rgba(59,130,246,.4); }
.emp-item .avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: var(--avatar-grad);
  display: flex; align-items: center; justify-content: center; font-size: 13px; color: var(--avatar-c);
}
.emp-item .meta { flex: 1; min-width: 0; }
.emp-item .meta .nm { font-size: 13px; color: var(--head); }
.emp-item .meta .ps { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 头像：全站统一用人员信息里的真实头像，覆盖在姓名首字之上；无头像/加载失败自动回退首字 */
.av-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }
.avatar, .av, .av-s { position: relative; overflow: hidden; }
.topbar .user .av, .av-s {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--avatar-grad); font-size: 12px; color: var(--avatar-c); vertical-align: middle;
}
.av-s { width: 24px; height: 24px; font-size: 11px; }
.nm-line { display: flex; align-items: center; gap: 7px; min-width: 0; }

/* 进度条 */
.bar { height: 6px; border-radius: 4px; background: rgba(59,130,246,.15); overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--green)); border-radius: 4px; }

/* 提示 */
.tip { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }
.tip.info { background: rgba(59,130,246,.1); border: 1px solid rgba(59,130,246,.3); color: var(--blue2); }
.tip.warn { background: rgba(240,180,41,.08); border: 1px solid rgba(240,180,41,.3); color: var(--gold); }
.tip.ok { background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.3); color: var(--green); }

/* 区块标题 */
.sec-title {
  display: flex; align-items: center; gap: 8px; margin: 22px 0 12px;
  color: var(--head); font-size: 14px; font-weight: 600;
}
.sec-title::before { content: ""; width: 4px; height: 16px; border-radius: 2px; background: var(--gold); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* 弹层 */
.mask { position: fixed; inset: 0; background: var(--mask-bg); z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal { width: 560px; max-width: 92vw; max-height: 86vh; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px 22px; }
.modal h3 { margin-bottom: 14px; }

/* 完整档案弹窗（全站通用） */
.profile-mask { position: fixed; inset: 0; background: var(--mask-bg); z-index: 200; display: flex; align-items: center; justify-content: center; }
.profile-win {
  width: 1040px; max-width: 95vw; height: 92vh; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--panel-line); border-radius: 16px;
  box-shadow: var(--win-shadow); overflow: hidden; animation: ppop .18s ease-out;
}
@keyframes ppop { from { transform: scale(.97); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.profile-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--topbar); flex-shrink: 0; }
.profile-head .t { color: var(--head); font-weight: 600; font-size: 14px; }
.profile-head .x { margin-left: auto; cursor: pointer; padding: 5px 14px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 13px; }
.profile-head .x:hover { color: var(--head); border-color: var(--red); }
.profile-win iframe { flex: 1; width: 100%; border: none; background: var(--iframe-bg); }
@media (max-width: 760px) {
  .profile-win { width: 100vw; max-width: 100vw; height: 100dvh; border-radius: 0; border: none; }
  .profile-mask { align-items: stretch; }
}

@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2,1fr); } .sidebar { display: none; } }

/* ---------- 手机端适配 ---------- */
@media (max-width: 760px) {
  body { font-size: 13px; }
  .topbar { height: auto; flex-wrap: wrap; padding: 8px 12px; gap: 8px 10px; }
  .topbar .logo { font-size: 14px; letter-spacing: 0; }
  .topbar nav { order: 3; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  .topbar nav a { padding: 6px 12px; white-space: nowrap; font-size: 13px; }
  .topbar .user { margin-left: auto; font-size: 12px; gap: 6px; }
  .layout { flex-direction: column; }
  .main { padding: 12px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .layout > .main { max-width: 100vw; }
  .kpis { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi .v { font-size: 22px; }
  .card { padding: 12px; border-radius: 10px; }
  .card h3 .sub { display: block; margin-left: 0; margin-top: 2px; }
  /* 树形布局：部门导航收起为可展开面板 */
  .layout-tree { grid-template-columns: minmax(0, 1fr) !important; gap: 10px; }
  .sidebar {
    display: block; width: auto; min-width: 0; border: 1px solid var(--line); border-radius: 10px;
    padding: 8px 10px; max-height: 46px; overflow: hidden; transition: max-height .2s ease;
  }
  .sidebar.open { max-height: 46vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .sidebar h4 { cursor: pointer; margin: 4px 4px; display: flex; align-items: center; justify-content: space-between; color: var(--soft); }
  .sidebar h4::after { content: "▾ 展开部门"; font-size: 11px; color: var(--blue2); }
  .sidebar.open h4::after { content: "▴ 收起"; }
  /* 弹层改为底部抽屉，全宽便于操作 */
  .mask { align-items: flex-end; }
  .modal { width: 100%; max-width: 100vw; max-height: 92dvh; border-radius: 16px 16px 0 0; padding: 16px 14px; }
  table.tbl { font-size: 12px; }
  .tbl th, .tbl td { padding: 7px 8px; }
  .inline { flex-wrap: wrap; }
  select, input, textarea { font-size: 16px; } /* 防 iOS 聚焦自动放大 */
  .btn { padding: 8px 14px; }
  .btn.sm { padding: 6px 10px; }
}

/* ---------- 部门树导航（钉钉一/二/三级层级） ---------- */
.dt-item { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--muted); transition: background .12s, color .12s; }
.dt-item:hover { background: rgba(59,130,246,.08); color: var(--soft); }
.dt-item.on { background: rgba(59,130,246,.16); color: var(--head); }
.dt-item .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dt-item .n { font-size: 11px; color: var(--muted); background: rgba(124,141,176,.1); padding: 0 7px; border-radius: 8px; }
.dt-item.on .n { color: var(--blue2); }
.dt-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.dt-dot.l1 { background: var(--gold); border-radius: 50%; }
.dt-dot.l2 { background: var(--blue2); }
.dt-dot.l3 { background: #7c8db0; }
.dt-dot.all { background: linear-gradient(135deg, var(--gold), var(--blue2)); border-radius: 50%; }
.layout-tree { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 16px; align-items: start; }

/* ---------- 主题切换器（右下角悬浮胶囊，common.js 注入） ---------- */
.theme-sw {
  position: fixed; right: 14px; bottom: 14px; z-index: 300;
  display: flex; gap: 3px; padding: 4px; border-radius: 22px;
  background: var(--panel); border: 1px solid var(--line);
  box-shadow: 0 6px 24px rgba(0,0,0,.22); user-select: none;
}
.theme-sw button {
  width: 34px; height: 28px; border: none; border-radius: 16px; cursor: pointer;
  background: transparent; color: var(--muted); font-size: 12px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 3px;
  transition: .14s;
}
.theme-sw button:hover { color: var(--head); background: rgba(59,130,246,.1); }
.theme-sw button.on { background: var(--blue); color: #fff; }
