/* === KPI Cards === */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  border-top: 3px solid var(--primary);
}

.kpi-sales { border-top-color: #4f6ef7; }
.kpi-customers { border-top-color: #f59e0b; }

.kpi-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.kpi-icon { font-size: 22px; }

.kpi-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.kpi-body { margin-bottom: 14px; }

.kpi-main-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.kpi-target {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 10px;
}

.kpi-progress-bar {
  height: 8px;
  background: #e9ecef;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}

.kpi-progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.8s ease, background 0.3s;
  background: #22c55e;
}

.kpi-progress-fill.warn { background: #f59e0b; }
.kpi-progress-fill.danger { background: #ef4444; }

.kpi-progress-text {
  font-size: 12px;
  color: var(--text-light);
}

.kpi-footer {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid #f0f0f0;
}

.kpi-sub { text-align: center; }

.kpi-sub-label {
  display: block;
  font-size: 11px;
  color: var(--text-light);
  margin-bottom: 2px;
}

.kpi-sub-value {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

/* === Section Card === */
.section-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  margin-bottom: 20px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

/* === Tabs === */
.tab-group {
  display: flex;
  gap: 4px;
  background: #f0f1f5;
  border-radius: 6px;
  padding: 3px;
}

.tab-btn {
  padding: 6px 16px;
  border: none;
  background: transparent;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-light);
  transition: all 0.2s;
}

.tab-btn.active {
  background: var(--white);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* === Data Table === */
.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #f0f0f0;
  white-space: nowrap;
}

.data-table th {
  font-weight: 600;
  color: var(--text-light);
  font-size: 12px;
  text-transform: uppercase;
  background: #fafbfc;
}

.data-table tbody tr:hover {
  background: #f8f9ff;
}

.row-dept td { font-weight: 600; }
.row-person td:first-child { padding-left: 28px; }

.toggle-dept {
  cursor: pointer;
  user-select: none;
  margin-right: 4px;
  font-size: 11px;
  display: inline-block;
  transition: transform 0.2s;
}

.toggle-dept.collapsed { transform: rotate(-90deg); }

.status-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
}

.status-ok { background: #dcfce7; color: #16a34a; }
.status-warn { background: #fef3c7; color: #d97706; }
.status-danger { background: #fee2e2; color: #dc2626; }

/* === Charts === */
.chart-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.chart-card { margin-bottom: 0; }

.chart-container {
  position: relative;
  height: 260px;
}

/* === Rank List - legacy selectors kept for compat === */
.rank-list { display: flex; flex-direction: column; gap: 10px; }

/* === Module Picker === */
.dash-module-picker {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  padding: 10px 16px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}

.dash-picker-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-right: 4px;
}

.dash-picker-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.dash-picker-item input[type="checkbox"] {
  accent-color: var(--primary);
  cursor: pointer;
}

/* === 排行榜突出区域 === */
.rank-highlight {
  margin-bottom: 24px;
}
.rank-card {
  background: linear-gradient(135deg, #f8faff 0%, #fff 100%);
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 4px 12px rgba(79, 110, 247, 0.08);
}
.rank-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.rank-time-switch {
  display: flex;
  gap: 4px;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 3px;
}
.rank-time-btn {
  padding: 6px 14px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: #64748b;
  transition: all 0.2s;
}
.rank-time-btn.active {
  background: #fff;
  color: #4f6ef7;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.rank-columns {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 24px;
}
.rank-column {
  min-width: 0;
}
.rank-col-title {
  font-size: 14px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid #e2e8f0;
}

/* === 排行项（新版） === */
.rank-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  transition: background 0.2s;
}
.rank-item:hover {
  background: #f8fafc;
}
.rank-item-me {
  background: #eff6ff !important;
  border-left: 3px solid #4f6ef7;
}
.rank-top3 {
  padding: 10px;
}
.rank-top3 .rank-name {
  font-weight: 600;
}
.rank-pos {
  min-width: 28px;
  text-align: center;
  font-size: 16px;
}
.rank-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #e9ecef;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
}
.rank-info {
  flex: 1;
  min-width: 0;
}
.rank-name {
  font-size: 13px;
  color: #334155;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rank-me-tag {
  display: inline-block;
  background: #4f6ef7;
  color: #fff;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 4px;
}
.rank-bar {
  height: 6px;
  background: #f1f5f9;
  border-radius: 3px;
  overflow: hidden;
}
.rank-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease;
}
.rank-bar-sales { background: linear-gradient(90deg, #4f6ef7, #818cf8); }
.rank-bar-cust { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.rank-bar-stu { background: linear-gradient(90deg, #10b981, #34d399); }
.rank-val {
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
  white-space: nowrap;
  min-width: 70px;
  text-align: right;
}

/* === 部门排行 === */
.dept-rank-item {
  padding: 12px 10px;
}
.dept-rank-name {
  font-size: 14px;
  font-weight: 600;
}
.dept-rank-val {
  min-width: 100px;
}
.dept-pct {
  font-size: 11px;
  color: #64748b;
  margin-left: 4px;
}
.dept-bar-green { background: linear-gradient(90deg, #10b981, #34d399); }
.dept-bar-yellow { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.dept-bar-red { background: linear-gradient(90deg, #ef4444, #f87171); }

/* === 响应式 === */
@media (max-width: 900px) {
  .kpi-row, .chart-row {
    grid-template-columns: 1fr;
  }
  .rank-columns {
    grid-template-columns: 1fr;
  }
}