:root {
  --bg: #ffffff;
  --surface: #fafafa;
  --line: #e5e7eb;
  --line-strong: #d4d4d8;
  --text: #18181b;
  --muted: #71717a;
  --faint: #a1a1aa;
  --primary: #1f4e8c;
  --primary-hover: #173c6d;
  --primary-weak: #eef3f9;
  --danger: #9f1d1d;
  --radius: 4px;
  --gap: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: 13px; color: var(--text); }
a { color: var(--primary); text-decoration: none; }
[hidden] { display: none !important; }

/* 登录 */
.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
}
.login-card {
  width: 320px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 28px 24px;
}
.login-card h1 { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.login-card p { font-size: 12px; color: var(--muted); margin-bottom: 20px; }
.login-card .field { margin-bottom: 12px; }
.login-card button { width: 100%; margin-top: 4px; }

/* 布局 */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 200px;
  flex-shrink: 0;
  border-right: 1px solid var(--line);
  background: var(--bg);
  padding: 18px 0;
  display: flex;
  flex-direction: column;
}
.brand { padding: 0 18px 16px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.brand strong { font-size: 14px; font-weight: 600; letter-spacing: .2px; }
.nav { flex: 1; overflow-y: auto; }
.nav-group { padding: 10px 18px 4px; font-size: 11px; color: var(--faint); letter-spacing: .4px; }
.nav-item {
  display: block;
  padding: 8px 18px;
  color: var(--muted);
  cursor: pointer;
  border-left: 2px solid transparent;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { color: var(--primary); border-left-color: var(--primary); background: var(--primary-weak); }

.main { flex: 1; min-width: 0; padding: 22px 26px 40px; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 44px;
  margin: -22px -26px 14px;
  padding: 0 26px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.topbar .topbar-log {
  flex: none;
  height: 26px;
  padding: 0 10px;
  font-size: 12px;
  color: var(--muted);
  border-color: var(--line);
  background: var(--bg);
}
.topbar .topbar-log:hover { color: var(--primary); border-color: var(--line-strong); background: var(--primary-weak); }
.topbar .topbar-user {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 220px;
  height: 26px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar .topbar-user:hover { color: var(--primary); }
.topbar .topbar-logout {
  flex: none;
  height: 26px;
  padding: 0 2px;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: 12px;
  cursor: pointer;
}
.topbar .topbar-logout:hover { color: var(--primary-hover); text-decoration: underline; }
@media (max-width: 1280px) {
  .topbar { gap: 10px; }
  .topbar .topbar-user { max-width: 140px; }
}
@media (max-width: 900px) {
  .main { padding-left: 18px; padding-right: 18px; }
  .topbar { margin: -22px -18px 12px; padding: 0 18px; }
}
.page { display: none; }
.page.active { display: block; }
.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}
.page-head h2 { font-size: 15px; font-weight: 600; }
.page-head .sub { font-size: 12px; color: var(--muted); }

/* 控件 */
button {
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text);
  white-space: nowrap;
}
button:hover { border-color: var(--muted); }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
button.ghost { border-color: transparent; background: transparent; color: var(--muted); padding: 0 6px; }
button.ghost:hover { color: var(--text); background: var(--surface); }
button.danger { color: var(--danger); }
button:disabled { opacity: .45; cursor: not-allowed; }

input, select {
  height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg);
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
input::placeholder { color: var(--faint); }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; color: var(--muted); }
.field input, .field select, .field textarea { width: 100%; }
.field textarea {
  padding: 7px 9px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg);
  outline: none;
  resize: vertical;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.toolbar .spacer { flex: 1; }
.toolbar input[type="search"] { width: 200px; }

/* KPI */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.kpi {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  min-height: 66px;
}
.kpi .label { font-size: 12px; color: var(--muted); }
.kpi .value { font-size: 20px; font-weight: 600; margin-top: 5px; line-height: 1.15; }
.kpi .note { font-size: 11px; color: var(--faint); margin-top: 4px; }

/* 页签：通栏页签条，底部一条分隔线 */
.tabs {
  display: flex;
  align-items: stretch;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  margin: 0;
}
.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 18px;
  font-size: 13px;
  line-height: 1;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  cursor: pointer;
  transition: color 120ms linear;
}
.tab::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 0;
  height: 2px;
  background: transparent;
  transition: background-color 120ms linear;
}
.tab:hover { color: #3f3f46; background: none; border: 0; }
.tab.active { color: var(--primary); background: none; }
.tab.active::after { background: var(--primary); }

.tabs + .toolbar { border-top: 0; padding-top: 16px; }

/* 面板 */
.panel { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; }
.panel-head {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; margin-bottom: 14px; }
.chart { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.chart h3 { font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 10px; }
.chart .canvas { position: relative; height: 220px; }

.notes { font-size: 12px; color: var(--muted); line-height: 1.9; }
.note-warn { color: var(--danger); }
.footnote { font-size: 11px; color: var(--faint); border-top: 1px dashed var(--line); padding-top: 10px; margin-top: 6px; }

/* 仪表盘进度条 */
.meters { padding: 12px 14px; display: grid; gap: 10px; }
.meter-head { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.meter-head span:last-child { color: var(--text); font-variant-numeric: tabular-nums; }
.meter-track { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.meter-fill { height: 100%; background: var(--primary); border-radius: 4px; }

/* 仪表盘自研迷你图表（纯 SVG / CSS） */
.viz-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; margin-bottom: 14px; }
.viz { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; min-width: 0; }
.viz h3 { font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 10px; }
.viz-empty { padding: 24px 12px; text-align: center; color: var(--faint); font-size: 12px; }
.viz-donut-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.viz-donut { width: 160px; height: 160px; flex: 0 0 auto; }
.donut-seg { transition: opacity 120ms linear; }
.donut-seg:hover { opacity: .82; }
.donut-center-value { font-size: 22px; font-weight: 600; fill: var(--text); }
.donut-center-label { font-size: 11px; fill: var(--muted); }
.viz-legend { flex: 1; min-width: 140px; display: grid; gap: 6px; }
.viz-legend-item { display: grid; grid-template-columns: 8px 1fr auto; gap: 8px; align-items: center; font-size: 12px; }
.viz-dot { width: 8px; height: 8px; border-radius: 2px; }
.viz-legend-label { color: var(--text); }
.viz-legend-value { color: var(--muted); font-variant-numeric: tabular-nums; }
.viz-legend-note { grid-column: 2 / 4; color: var(--faint); font-size: 11px; }
.stack-bar { display: flex; height: 22px; border-radius: 4px; overflow: hidden; background: var(--line); }
.stack-seg { display: block; height: 100%; min-width: 2px; }
.stack-seg:hover { opacity: .85; }
.viz-stack .viz-legend { margin-top: 10px; }
.hbar-list { display: grid; gap: 9px; }
.hbar { display: grid; grid-template-columns: 90px 1fr 64px; gap: 10px; align-items: center; font-size: 12px; }
.hbar-label { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 2px; }
.hbar-value { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.range-list { display: grid; gap: 8px; }
.range-row { display: grid; grid-template-columns: 56px 1fr 96px; gap: 10px; align-items: center; font-size: 12px; }
.range-label { display: flex; flex-direction: column; color: var(--text); }
.range-count { color: var(--faint); font-size: 10.5px; }
.range-track { position: relative; height: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 3px; }
.range-fill { height: 100%; background: var(--primary); border-radius: 2px; }
.range-fill.inverted { background: var(--danger); }
.range-mark { position: absolute; top: -2px; bottom: -2px; width: 0; border-left: 2px dashed var(--text); }
.range-median { position: absolute; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: var(--bg); border: 1.5px solid var(--text); }
.range-value { text-align: right; font-variant-numeric: tabular-nums; }
.range-value .faint { font-size: 11px; }
.viz-hint { margin-top: 8px; font-size: 11px; color: var(--faint); }
.heat-wrap { overflow: auto; }
.heat-table { width: 100%; font-size: 11.5px; }
.heat-table th, .heat-table td { border: 1px solid var(--line); padding: 6px 8px; text-align: center; white-space: nowrap; }
.heat-corner { background: var(--surface); color: var(--muted); font-weight: 500; }
.heat-row-head { background: var(--surface); color: var(--text); font-weight: 500; text-align: left; }
.heat-cell { font-variant-numeric: tabular-nums; }
.heat-cell:hover { outline: 1px solid var(--primary); }
.viz-spark svg { width: 100%; height: 72px; display: block; }
.viz-spark circle { fill: var(--primary); }
.viz-spark circle:hover { fill: var(--danger); }
.spark-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 4px; }

/* 表格 */
.table-wrap { overflow: auto; max-height: calc(100vh - 210px); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { padding: 8px 10px; text-align: center; white-space: nowrap; border-bottom: 1px solid var(--line); }
thead th {
  position: sticky;
  top: 0;
  background: var(--surface);
  font-weight: 500;
  color: var(--muted);
  font-size: 12px;
  z-index: 1;
}
tbody tr:hover { background: #fcfcfd; }
tbody tr:last-child td { border-bottom: none; }
td.left, th.left { text-align: left; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-variant-numeric: tabular-nums; }
.row-actions { display: inline-flex; gap: 2px; }

.pager { display: flex; align-items: center; gap: 10px; padding: 10px 2px; font-size: 12px; color: var(--muted); }

/* 历史绩效矩阵 */
.perf-toolbar { flex-wrap: nowrap; overflow-x: auto; }
.perf-wrap { max-height: calc(100vh - 248px); }
.perf-table { width: max-content; min-width: 100%; }
.perf-table th, .perf-table td { padding: 6px 8px; }
.perf-table .perf-month { width: 54px; min-width: 54px; }
.perf-table .perf-c1, .perf-table .perf-c2, .perf-table .perf-c3 {
  position: sticky;
  background: var(--bg);
  z-index: 2;
}
.perf-table .perf-c1 { left: 0; width: 110px; min-width: 110px; }
.perf-table .perf-c2 { left: 110px; width: 120px; min-width: 120px; }
.perf-table .perf-c3 { left: 230px; width: 100px; min-width: 100px; }
.perf-table thead .perf-c1,
.perf-table thead .perf-c2,
.perf-table thead .perf-c3 { background: var(--surface); z-index: 4; }
.perf-table tbody tr:hover .perf-c1,
.perf-table tbody tr:hover .perf-c2,
.perf-table tbody tr:hover .perf-c3 { background: #fcfcfd; }
.perf-table .perf-summary { background: var(--surface); }
.perf-badge {
  display: inline-block;
  min-width: 28px;
  padding: 2px 7px;
  border-radius: 3px;
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
}
.perf-raise {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 11.5px;
  font-weight: 600;
}
.perf-raise.meets { background: #dcfce7; color: #166534; }
.perf-raise.hasD { background: #fee2e2; color: #b91c1c; }
.perf-raise.cHigh { background: #fef9c3; color: #a16207; }
.perf-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--muted);
}
.perf-empty { padding: 28px; text-align: center; color: var(--muted); }

/* 年终奖计算 */
.bonus-toolbar { flex-wrap: nowrap; overflow-x: auto; }
.bonus-wrap { max-height: calc(100vh - 210px); }
.bonus-table { width: max-content; min-width: 100%; }
.bonus-table th, .bonus-table td { padding: 6px 8px; white-space: nowrap; }
.bonus-table .b-c1, .bonus-table .b-c2, .bonus-table .b-c3,
.bonus-table .b-c4, .bonus-table .b-c5 {
  position: sticky;
  background: var(--bg);
  z-index: 2;
}
.bonus-table .b-c1 { left: 0; width: 80px; min-width: 80px; }
.bonus-table .b-c2 { left: 80px; width: 120px; min-width: 120px; }
.bonus-table .b-c3 { left: 200px; width: 90px; min-width: 90px; }
.bonus-table .b-c4 { left: 290px; width: 90px; min-width: 90px; }
.bonus-table .b-c5 { left: 380px; width: 70px; min-width: 70px; }
.bonus-table thead .b-c1,
.bonus-table thead .b-c2,
.bonus-table thead .b-c3,
.bonus-table thead .b-c4,
.bonus-table thead .b-c5 { background: var(--surface); z-index: 4; }
.bonus-table tbody tr:hover .b-c1,
.bonus-table tbody tr:hover .b-c2,
.bonus-table tbody tr:hover .b-c3,
.bonus-table tbody tr:hover .b-c4,
.bonus-table tbody tr:hover .b-c5 { background: #fcfcfd; }
.bonus-table tbody tr.bonus-drow > td { background: #fef2f2; color: #b91c1c; }
.bonus-table tbody tr.bonus-drow > td.b-c1,
.bonus-table tbody tr.bonus-drow > td.b-c2,
.bonus-table tbody tr.bonus-drow > td.b-c3,
.bonus-table tbody tr.bonus-drow > td.b-c4,
.bonus-table tbody tr.bonus-drow > td.b-c5 { background: #fef2f2; }
.bonus-table tfoot td { background: var(--surface); font-weight: 600; }
.bonus-review {
  width: 64px;
  padding: 3px 5px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--bg);
  text-align: right;
  outline: none;
}
.bonus-review:focus { border-color: var(--primary); }



/* 模态框 */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(24, 24, 27, .28);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 16px;
  z-index: 50;
  overflow: auto;
}
.modal {
  width: 620px;
  max-width: 100%;
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
}
.modal.narrow { width: 380px; }
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
}
.modal-head button { height: 24px; width: 24px; padding: 0; border-color: transparent; color: var(--muted); background: transparent; }
.modal-body { padding: 16px; max-height: calc(100vh - 220px); overflow: auto; }
.modal-foot { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-error { color: var(--danger); font-size: 12px; margin-top: 10px; min-height: 16px; }

/* 提示 */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: #18181b;
  color: #fff;
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 12px;
  z-index: 60;
}

/* 版本记录 */
.timeline { border-left: 1px solid var(--line); margin-left: 6px; padding-left: 18px; }
.timeline-item { margin-bottom: 22px; }
.timeline-item .ver { font-weight: 600; }
.timeline-item .date { color: var(--faint); font-size: 11px; margin-left: 8px; }
.timeline-item ul { margin: 8px 0 0 16px; color: var(--muted); line-height: 1.9; }

/* 账号与角色 */
.modal.wide { width: 820px; max-width: 100%; }
.check-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; }
.check-item { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); }
.check-item input { height: auto; }
.perm-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.perm-table th, .perm-table td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; white-space: nowrap; }
.perm-table th { background: var(--surface); font-weight: 500; color: var(--muted); }
.perm-table td:first-child { width: 190px; }
.perm-actions { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.perm-actions label { display: flex; align-items: center; gap: 5px; font-size: 13px; }
.field-group-title { font-size: 12px; color: var(--muted); margin: 14px 0 6px; }
.temp-password {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 20px;
  letter-spacing: 1px;
  text-align: center;
  padding: 14px;
  border: 1px dashed var(--line);
  margin: 8px 0 4px;
  user-select: all;
}
.form-hint { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.7; }
.danger-text { color: #b42318; }

/* 在职 / 离职状态徽标（全站统一） */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 8px;
  border: 1px solid;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  vertical-align: middle;
}
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.status-active { color: #0f6848; background: #eef7f2; border-color: #b8d8c8; }
.status-left { color: #525c69; background: #f3f4f6; border-color: #d5dae0; }

/* 司龄阶段标签：低饱和、同明度层级、相邻阶段明度递进；仅用于标签，不参与整行背景 */
.stage-badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border: 1px solid;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  vertical-align: middle;
}
.stage-s1 { color: #3d5473; background: #eef1f6; border-color: #c6d3e3; }
.stage-s2 { color: #35606b; background: #edf3f4; border-color: #bfd6da; }
.stage-s3 { color: #3a6b4e; background: #edf4ef; border-color: #c2d9c9; }
.stage-s4 { color: #63683c; background: #f3f3ec; border-color: #d8d9bb; }
.stage-s5 { color: #75603c; background: #f6f1ea; border-color: #e0d2b8; }
.stage-s6 { color: #7a4a52; background: #f6eeef; border-color: #e2c9cd; }
.stage-s7 { color: #5f4c7d; background: #f2eef6; border-color: #d5cbe3; }
.stage-s8 { color: #4e5260; background: #f0f0f3; border-color: #cfd1d9; }
.stage-none { color: #71717a; background: #f6f6f7; border-color: #e2e2e5; }

.pager-size-select { width: 68px; padding: 3px 6px; }
.pager-info { font-size: 12px; color: var(--muted); }
th.sortable { cursor: pointer; user-select: none; }
th.sortable::after { content: ' ↕'; color: var(--faint); font-size: 10px; }
th.sortable.sort-asc::after { content: ' ↑'; color: var(--text); }
th.sortable.sort-desc::after { content: ' ↓'; color: var(--text); }

@media (max-width: 900px) {
  .sidebar { width: 168px; }
  .main { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .check-grid { grid-template-columns: 1fr; }
}
