/* Toutiao-inspired creator backend tokens */
:root {
  --bg: #f8f8f8;
  --panel: #fff;
  --header-h: 64px;
  --nav-w: 220px;
  --text: #222;
  --text-2: #666;
  --text-3: #999;
  --text-4: #bfbfbf;
  --line: #e8e8e8;
  --control: #d8d8d8;
  --chip: #f5f5f5;
  --th: #fafafa;
  --red: #f04142;
  --red-btn: #ff5e5e;
  --red-hover: #ff8585;
  --red-50: #fff2f2;
  --red-100: #ffd1d1;
  --blue: #3d89ff;
  --teal: #08c9c8;
  --gold: #fbdc3f;
  --orange: #ff8e4f;
  --success: #0fbf60;
  --warning: #ff8b07;
  --radius: 4px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro SC", "PingFang SC",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 14px/1.5 var(--font);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

button { font: inherit; cursor: pointer; }
a { color: var(--red-btn); text-decoration: none; }
a:hover { color: var(--red-hover); }

/* —— Header —— */
.tt-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px 0 28px;
}
.wordmark {
  color: var(--red) !important;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.header-right { display: flex; align-items: center; gap: 14px; }
.hdr-btn {
  height: 32px; padding: 0 14px;
  border: 1px solid var(--control);
  background: #fff; border-radius: var(--radius);
  color: var(--text-2);
}
.hdr-btn:hover { border-color: var(--red-btn); color: var(--red); }
.hdr-meta { color: var(--text-3); font-size: 13px; }
.hdr-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--red-50); color: var(--red);
  display: grid; place-items: center; font-weight: 600;
}

/* —— Shell —— */
.tt-shell { display: flex; min-height: calc(100vh - var(--header-h)); }

.tt-nav {
  width: var(--nav-w);
  flex-shrink: 0;
  padding: 16px 0 40px;
  background: transparent;
}
.nav-group { margin-bottom: 8px; }
.nav-group-title {
  width: 100%;
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 24px;
  border: 0; background: transparent;
  color: var(--text); font-weight: 500;
}
.nav-group-title .chev { color: var(--text-3); font-size: 12px; }
.nav-sub { display: none; padding: 0 0 4px; }
.nav-sub.open { display: block; }
.nav-item {
  display: block; width: 100%;
  text-align: left;
  padding: 9px 24px 9px 40px;
  border: 0; background: transparent;
  color: var(--text-2);
}
.nav-item:hover { color: var(--text); }
.nav-item.active { color: var(--red); font-weight: 500; }

.tt-main {
  flex: 1;
  min-width: 0;
  padding: 16px 32px 48px;
  max-width: 1600px;
}

.panel { display: none; }
.panel.active { display: block; }

.panel-card {
  background: var(--panel);
  padding: 20px 40px 28px;
  margin-bottom: 12px;
}
.panel-card.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}

.section-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin: 8px 0 16px;
}
.section-label .hint,
.hint { color: var(--text-3); font-weight: 400; font-size: 12px; margin-left: 8px; }
.row-between { display: flex; align-items: center; justify-content: space-between; }

/* —— Line tabs —— */
.line-tabs {
  display: flex; align-items: center;
  border-bottom: 1px solid var(--line);
  margin: 0 -8px 20px;
  min-height: 42px;
}
.line-tab {
  position: relative;
  padding: 12px 18px;
  border: 0; background: transparent;
  color: var(--text-2);
}
.line-tab.active {
  color: var(--text);
  font-weight: 500;
}
.line-tab.active::after {
  content: "";
  position: absolute; left: 18px; right: 18px; bottom: -1px;
  height: 2px; background: var(--red);
}
.line-tab-extra {
  margin-left: auto;
  font-size: 13px;
  padding-right: 8px;
  color: var(--text-3) !important;
}
.line-tab-extra:hover { color: var(--red-btn) !important; }

/* —— KPI 3-up —— */
.kpi-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  text-align: center;
  padding: 8px 0 20px;
}
.kpi-block .kpi-label { color: var(--text-3); font-size: 13px; margin-bottom: 8px; }
.kpi-block .kpi-value {
  font-size: 30px; font-weight: 700; color: var(--text);
  line-height: 1.2; letter-spacing: -0.5px;
}
.kpi-block .kpi-value.pending { color: var(--text-4); font-size: 26px; font-weight: 500; }
.kpi-block .kpi-sub { color: var(--text-3); font-size: 12px; margin-top: 8px; }
.kpi-block .kpi-action { margin-top: 12px; }

.btn-primary {
  height: 32px; padding: 0 16px;
  background: var(--red-btn); color: #fff;
  border: 0; border-radius: var(--radius);
}
.btn-primary:hover { background: var(--red-hover); }
.btn-primary-outline {
  height: 32px; padding: 0 16px;
  background: #fff; color: var(--red);
  border: 1px solid var(--red); border-radius: var(--radius);
}
.btn-primary-outline:hover { background: var(--red-50); }
.btn-ghost-sm {
  height: 28px; padding: 0 10px;
  border: 1px solid var(--control); background: #fff;
  border-radius: var(--radius); color: var(--text-2);
}
.link-text { color: var(--red-btn); font-size: 13px; background: none; border: 0; padding: 0; }

/* —— Formula cards —— */
.formula-row {
  display: flex; align-items: stretch; justify-content: center;
  gap: 10px; flex-wrap: wrap;
  margin: 8px 0 4px;
}
.formula-card {
  min-width: 140px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px;
  text-align: center;
  background: #fff;
}
.formula-card.selected { border-bottom: 2px solid var(--red); }
.f-label { color: var(--text-3); font-size: 12px; }
.f-value { font-size: 20px; font-weight: 600; margin-top: 6px; }
.f-value.pending { color: var(--text-4); font-weight: 500; }
.f-op { align-self: center; color: var(--text-3); font-size: 18px; padding: 0 4px; }
.meta-line { color: var(--text-4); font-size: 12px; text-align: center; margin: 10px 0 0; }

/* —— Filters —— */
.filter-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px 12px;
  margin-bottom: 12px;
}
.filter-label { color: var(--text-2); }
.text-preset {
  border: 0; background: transparent;
  color: var(--text-2); padding: 4px 6px;
}
.text-preset.active { color: var(--red); font-weight: 500; }
.date-range {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--control);
  border-radius: var(--radius);
  padding: 4px 8px;
  background: #fff;
}
.date-range input {
  border: 0; outline: 0; font: inherit; color: var(--text-2);
  background: transparent;
}
.filter-spacer { flex: 1; }
.unit-label { color: var(--text-3); font-size: 13px; }

.view-toggle {
  display: inline-flex;
  border: 1px solid var(--control);
  border-radius: var(--radius);
  overflow: hidden;
}
.vt-btn {
  height: 30px; padding: 0 12px;
  border: 0; background: #fff; color: var(--text-2);
}
.vt-btn + .vt-btn { border-left: 1px solid var(--control); }
.vt-btn.active {
  color: var(--red);
  background: var(--red-50);
  box-shadow: inset 0 0 0 1px var(--red);
}

.chip-row { display: flex; gap: 8px; margin-bottom: 14px; }
.chip-pill {
  height: 28px; padding: 0 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
}
.chip-pill.active {
  border-color: var(--red);
  color: var(--red);
  background: #fff;
}

.chart-wrap {
  position: relative;
  height: 280px;
  margin-top: 8px;
}
.charts-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
.mini-chart h4, .rank-box h4 {
  margin: 0 0 12px; font-size: 13px; color: var(--text-2); font-weight: 500;
}

/* —— Tables —— */
.table-wrap { overflow-x: auto; }
.tt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.tt-table th {
  background: var(--th);
  color: var(--text-2);
  font-weight: 500;
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.tt-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
}
.tt-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.tt-table .pending { color: var(--text-4); }
.emp-cell { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--chip); color: var(--text-2);
  display: grid; place-items: center; font-size: 12px; flex-shrink: 0;
}
.avatar.alt { background: var(--red-50); color: var(--red); }
.status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 2px;
  font-size: 12px;
  background: var(--chip);
  color: var(--text-2);
}
.status-pill.on { background: #e8f9ef; color: var(--success); }
.status-pill.off { background: var(--chip); color: var(--text-3); }
.status-pill.ok { background: #e8f9ef; color: var(--success); }
.status-pill.watch { background: #fff7e6; color: var(--warning); }
.status-pill.warn { background: #fff7e6; color: var(--warning); }
.status-pill.bad { background: #fff2e8; color: var(--orange); }
.status-pill.critical { background: var(--red-50); color: var(--red); }

.salary-edit { display: inline-flex; gap: 6px; align-items: center; }
.salary-edit input {
  width: 90px; height: 28px;
  border: 1px solid var(--control); border-radius: var(--radius);
  padding: 0 8px; font: inherit;
}

.empty-state {
  text-align: center; color: var(--text-4);
  padding: 48px 16px;
}
.empty-ico { font-size: 36px; margin-bottom: 8px; opacity: 0.6; }

/* —— Alerts / ranks —— */
.legend { display: flex; flex-wrap: wrap; gap: 16px 24px; margin-bottom: 16px; }
.legend-item { display: flex; gap: 8px; align-items: flex-start; color: var(--text-2); font-size: 13px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }

.alert-list { display: flex; flex-direction: column; gap: 8px; }
.alert-item {
  display: flex; gap: 12px; align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.alert-item.orange { border-left: 3px solid var(--warning); }
.alert-item.orangered { border-left: 3px solid var(--orange); }
.alert-item.red { border-left: 3px solid var(--red); }
.alert-title { font-weight: 500; }
.alert-desc { color: var(--text-3); font-size: 12px; margin-top: 2px; }

.rank-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.rank-list { list-style: none; margin: 0; padding: 0; }
.rank-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.rank-num {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--chip); color: var(--text-3);
  display: grid; place-items: center; font-size: 12px; font-weight: 600;
}
.rank-num.gold { background: #fff4cc; color: #b8860b; }
.rank-num.silver { background: #eee; color: #666; }
.rank-num.bronze { background: #f5e6d8; color: #8b5a2b; }
.rank-meta { margin-left: auto; text-align: right; }
.rank-meta .main-v { font-weight: 600; }
.rank-meta .sub-v { color: var(--text-3); font-size: 12px; }

.hr-note { color: var(--text-2); font-size: 13px; line-height: 1.7; max-width: 720px; }
.hr-note code {
  background: var(--chip); padding: 1px 6px; border-radius: 2px; font-size: 12px;
}

.tt-footer {
  color: var(--text-4);
  font-size: 12px;
  padding: 16px 8px 0;
}

/* —— Modal / toast —— */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.35);
  display: none; align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: 6px;
  width: 400px; max-width: calc(100vw - 32px);
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.modal h3 { margin: 0 0 16px; font-size: 16px; }
.form-stack label { display: block; color: var(--text-2); margin-bottom: 6px; font-size: 13px; }
.form-stack input, .form-stack select {
  width: 100%; height: 32px;
  border: 1px solid var(--control); border-radius: var(--radius);
  padding: 0 10px; font: inherit; margin-bottom: 14px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.toast {
  position: fixed; left: 50%; bottom: 40px; z-index: 200;
  transform: translateX(-50%) translateY(20px);
  background: rgba(34,34,34,.92); color: #fff;
  padding: 10px 18px; border-radius: var(--radius);
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  max-width: min(520px, 90vw); font-size: 13px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 1100px) {
  .panel-card.split, .charts-2, .rank-cols { grid-template-columns: 1fr; }
  .tt-nav { width: 180px; }
  .panel-card { padding: 16px 20px 20px; }
}
@media (max-width: 800px) {
  .tt-shell { flex-direction: column; }
  .tt-nav { width: 100%; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .nav-sub { display: flex !important; flex-wrap: wrap; padding: 0 12px 8px; }
  .nav-item { width: auto; padding: 8px 12px; }
  .kpi-3 { grid-template-columns: 1fr; text-align: left; }
}

/* —— Role switch —— */
.role-switch {
  display: flex; align-items: center; gap: 0;
  margin-left: 24px;
  border: 1px solid var(--control);
  border-radius: var(--radius);
  overflow: hidden;
  height: 32px;
}
.role-btn {
  height: 32px; padding: 0 14px;
  border: 0; background: #fff;
  color: var(--text-2); font-size: 13px;
  border-right: 1px solid var(--control);
}
.role-btn:last-child { border-right: 0; }
.role-btn.active { color: var(--red); font-weight: 500; background: var(--red-50); }
.role-btn:hover { color: var(--red); }

.fx-inline {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-3); font-size: 13px;
}
.fx-inline input {
  width: 64px; height: 28px;
  border: 1px solid var(--control); border-radius: var(--radius);
  padding: 0 6px; font: inherit; text-align: right;
}

.freshness-bar {
  display: flex; flex-wrap: wrap; gap: 12px 20px;
  margin-top: 16px; padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 13px; color: var(--text-2);
}
.fresh-item.ok strong { color: var(--success); }
.fresh-item.stale { color: var(--text-3); }
.fresh-item.stale strong { color: var(--warning); }

.emp-select {
  height: 32px; min-width: 220px;
  border: 1px solid var(--control); border-radius: var(--radius);
  padding: 0 10px; font: inherit; background: #fff;
}

.infer-tag {
  display: inline-block;
  font-size: 11px; line-height: 1;
  padding: 2px 6px; margin-left: 4px;
  border-radius: 2px;
  background: #fff7e6; color: #d48806;
  border: 1px solid #ffe7ba;
  vertical-align: middle;
}

.thresh-box {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
  background: var(--th);
}
.thresh-box summary {
  cursor: pointer; color: var(--text-2); font-size: 13px;
}
.thresh-grid {
  display: flex; flex-wrap: wrap; gap: 10px 16px;
  margin-top: 12px; align-items: center;
}
.thresh-grid label {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-2); font-size: 13px;
}
.thresh-grid input {
  width: 72px; height: 28px;
  border: 1px solid var(--control); border-radius: var(--radius);
  padding: 0 6px; font: inherit;
}

.rule-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  background: #fff;
}
.rule-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
}
.rule-head .hint { margin-left: auto; margin-right: 8px; }
.rule-action {
  font-size: 13px; color: var(--text-2);
  margin-bottom: 10px;
  padding: 8px 10px;
  background: var(--red-50);
  border-radius: var(--radius);
}
.alert-people {
  list-style: none; margin: 0; padding: 0;
}
.alert-people li {
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.alert-people .alert-desc {
  font-size: 12px; color: var(--text-3); margin-top: 2px;
}

.tt-header { gap: 12px; flex-wrap: wrap; height: auto; min-height: var(--header-h); padding-top: 10px; padding-bottom: 10px; }
.tt-header .wordmark { flex-shrink: 0; }
.tt-header .header-right { margin-left: auto; flex-wrap: wrap; }

@media (max-width: 1100px) {
  .role-switch { margin-left: 0; }
  .fx-inline { order: 5; }
}

/* —— 重点关注 nav pin —— */
.nav-group-pin { border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-bottom: 10px; }
.nav-group-pin .nav-group-title span:first-child { color: var(--red); }
.nav-item-focus { display: flex; align-items: center; gap: 6px; }
.nav-badge {
  display: inline-block; min-width: 18px; height: 18px; line-height: 18px;
  padding: 0 5px; border-radius: 9px; font-size: 11px; font-weight: 600;
  background: var(--red); color: #fff; text-align: center;
}

/* —— 新人 / 老员工 分组 —— */
.group-tag {
  display: inline-block; font-size: 12px; line-height: 1; font-weight: 600;
  padding: 4px 8px; margin-right: 8px; border-radius: 2px; vertical-align: middle;
}
.group-tag.new { background: var(--red-50); color: var(--red); border: 1px solid var(--red-100); }
.group-tag.old { background: var(--chip); color: var(--text-2); border: 1px solid var(--line); }
.group-tag.sm { font-size: 11px; padding: 2px 5px; margin: 0 0 0 4px; }
.hire-group-new { border-left: 3px solid var(--red); }

/* —— 部门对比 —— */
.rate-pill { display: inline-block; padding: 2px 10px; border-radius: 2px; font-size: 12px; font-weight: 600; }
.rate-pill.strong { background: #e8f9ef; color: var(--success); }
.rate-pill.mid { background: #eef4ff; color: var(--blue); }
.rate-pill.weak { background: var(--red-50); color: var(--red); }
.dept-strong { color: var(--success) !important; }
.dept-weak { color: var(--red) !important; }
.kpi-value.dept-strong, .kpi-value.dept-weak { font-size: 22px; }
.tt-table .up { color: var(--success); }
.tt-table .down { color: var(--red); }
.dept-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.dept-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; background: #fff; border-top: 3px solid var(--blue); }
.dept-card.strong { border-top-color: var(--success); }
.dept-card.weak { border-top-color: var(--red); }
.dept-card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.dept-card-head .hint { margin-left: auto; }
.dept-card-sub { font-size: 12px; color: var(--text-3); margin: 10px 0 0; }
.dept-card .rank-list li { padding: 8px 0; }

/* —— 重点关注信息 —— */
.focus-blocker {
  padding: 12px 14px; margin-bottom: 14px; border-radius: var(--radius);
  background: var(--red-50); border: 1px solid var(--red-100); color: var(--text); font-size: 13px; line-height: 1.8;
}
.focus-blocker.warn { background: #fff7e6; border-color: #ffe7ba; }
.focus-blocker.info { background: #eef4ff; border-color: #cfe0ff; }
.focus-blocker code, .focus-logic code { background: var(--chip); padding: 1px 6px; border-radius: 2px; font-size: 12px; }
.focus-logic { margin-top: 12px; padding-top: 4px; border-top: 1px solid var(--line); font-size: 13px; color: var(--text-2); }
.focus-logic ol { margin: 0; padding-left: 20px; line-height: 1.9; }
.focus-cfg { margin-top: 12px; }
.focus-cfg-row { display: block; color: var(--text-2); font-size: 13px; }
.focus-cfg textarea {
  display: block; width: 100%; margin-top: 6px; font: inherit; padding: 8px 10px;
  border: 1px solid var(--control); border-radius: var(--radius); resize: vertical;
}
.kw-pill {
  display: inline-block; font-size: 12px; padding: 1px 8px; margin: 2px 4px 2px 0; border-radius: 999px;
  background: var(--red-50); color: var(--red); border: 1px solid var(--red-100);
}
mark.kw { background: #ffe58f; color: var(--text); padding: 0 2px; border-radius: 2px; }
.report-card { border: 1px solid var(--line); border-left: 3px solid var(--red); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; background: #fff; }
.report-card.issue { border-left-color: var(--warning); }
.report-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.report-tags { margin-left: auto; text-align: right; }
.rf { display: grid; grid-template-columns: 160px 1fr; gap: 12px; padding: 6px 0; border-top: 1px dashed var(--line); font-size: 13px; }
.rf-k { color: var(--text-3); }
.rf-v { color: var(--text); white-space: pre-wrap; word-break: break-word; }
.rf.hit .rf-k { color: var(--red); font-weight: 500; }
.rf.issue .rf-k { color: var(--warning); }
@media (max-width: 800px) { .rf { grid-template-columns: 1fr; gap: 2px; } }
.conv-h4 { margin: 0 0 12px; font-size: 13px; color: var(--text-2); font-weight: 500; }
.report-card.open { box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.report-card.ok { border-left-color: var(--control); }
.focus-blocker.info strong { color: var(--text); }
