/* ========================================================================
   统计页 - 与小程序紫色调统一
   ======================================================================== */

.stats-topbar {
  display: flex;
  align-items: center;
  padding: 0 24px;
  height: 88px;
  background: var(--purple);
  color: #fff;
}

.stats-topbar .home-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.stats-topbar .back-text { color: #fff; }

.stats-title {
  font-size: 36px;
  font-weight: 600;
  margin-left: 16px;
  color: #fff;
  letter-spacing: 1px;
}

.stats-content {
  padding: 32px;
  max-width: 1400px;
  margin: 0 auto;
  background: #f5f0fa;
  min-height: calc(100vh - 88px);
  color: #333;
}

/* 周期切换 - 紫色调 */
.period-tabs {
  display: flex;
  gap: 12px;
  margin-bottom: 28px;
}

.period-tab {
  padding: 12px 32px;
  border-radius: 24px;
  border: 2px solid var(--purple);
  background: #fff;
  color: var(--purple);
  font-size: 24px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}

.period-tab:hover {
  background: #f3efff;
}

.period-tab.active {
  background: var(--purple);
  color: #fff;
  box-shadow: 0 4px 16px rgba(155, 123, 184, 0.4);
}

/* KPI 大卡 - 白卡+紫字 */
.stats-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 36px;
}

.stats-card {
  background: #fff;
  border-radius: 16px;
  padding: 36px 32px;
  position: relative;
  overflow: hidden;
  border: 1px solid #e8def4;
  box-shadow: 0 4px 16px rgba(155, 123, 184, 0.1);
}

.stats-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 4px;
  background: linear-gradient(90deg, var(--purple) 0%, #c9b8dc 100%);
}

.stats-card.kpi-money::after {
  background: linear-gradient(90deg, #b8956a 0%, #d4b896 100%);
}

.stats-card-icon {
  font-size: 36px;
  margin-bottom: 12px;
}

.stats-num {
  font-size: 72px;
  font-weight: 700;
  color: var(--purple);
  margin-bottom: 8px;
  letter-spacing: -1px;
  line-height: 1.1;
}

.stats-card.kpi-money .stats-num {
  color: #8b6f47;
}

.stats-label {
  font-size: 22px;
  color: #888;
  letter-spacing: 1px;
}

.stats-unit {
  font-size: 32px;
  font-weight: 600;
  margin-left: 8px;
  color: inherit;
}

/* 排名区 - 白卡片 */
.stats-rank-section {
  background: #fff;
  border-radius: 16px;
  padding: 32px;
  border: 1px solid #e8def4;
  box-shadow: 0 4px 16px rgba(155, 123, 184, 0.1);
}

.stats-rank-title {
  font-size: 30px;
  font-weight: 600;
  color: #333;
  margin-bottom: 24px;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.stats-rank-title::before {
  content: '';
  width: 4px;
  height: 24px;
  background: var(--purple);
  border-radius: 2px;
}

.stats-rank-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stats-rank-item {
  display: flex;
  align-items: center;
  padding: 18px 24px;
  background: #f8f4ff;
  border-radius: 12px;
  border: 1px solid #e8def4;
  position: relative;
  overflow: hidden;
  transition: all 0.2s;
}

.stats-rank-item:hover {
  border-color: var(--purple);
  transform: translateX(4px);
}

.stats-rank-item.top1 {
  background: linear-gradient(135deg, #fff8e1 0%, #ffecb3 100%);
  border-color: #ffc107;
}
.stats-rank-item.top2 {
  background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
  border-color: #bdbdbd;
}
.stats-rank-item.top3 {
  background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
  border-color: #ff9800;
}

.rank-badge {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--purple);
  color: #fff;
  font-size: 30px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 22px;
  flex-shrink: 0;
}

.rank-badge.gold { background: linear-gradient(135deg, #FFD700, #FFA500); color: #fff; }
.rank-badge.silver { background: linear-gradient(135deg, #C0C0C0, #A8A8A8); color: #fff; }
.rank-badge.bronze { background: linear-gradient(135deg, #CD7F32, #B87333); color: #fff; }

.rank-info {
  flex: 1;
  min-width: 0;
}

.rank-name {
  font-size: 30px;
  font-weight: 600;
  color: #333;
  margin-bottom: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-bar {
  height: 10px;
  background: #e8def4;
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 10px;
}

.rank-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--purple) 0%, #c9b8dc 100%);
  border-radius: 5px;
  transition: width 0.6s ease-out;
}

.stats-rank-item.top1 .rank-bar-fill {
  background: linear-gradient(90deg, #FFD700, #FFA500);
}
.stats-rank-item.top2 .rank-bar-fill {
  background: linear-gradient(90deg, #C0C0C0, #A8A8A8);
}
.stats-rank-item.top3 .rank-bar-fill {
  background: linear-gradient(90deg, #CD7F32, #B87333);
}

.rank-detail {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 20px;
}

.rank-tag {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 12px;
  background: #f3efff;
  color: var(--purple);
  font-size: 20px;
  font-weight: 500;
}

.rank-tag.money {
  background: linear-gradient(135deg, #f3efff 0%, #e8def4 100%);
  color: var(--purple);
  font-weight: 600;
}

.rank-tag.vip {
  background: linear-gradient(135deg, #fff8e1, #ffecb3);
  color: #b8860b;
}

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: #888;
  font-size: 24px;
}

.loading {
  text-align: center;
  padding: 60px 20px;
  color: #888;
  font-size: 24px;
}

/* 响应式 */
@media (max-width: 900px) {
  .stats-content { padding: 20px; }
  .stats-summary { grid-template-columns: 1fr; gap: 16px; }
  .stats-num { font-size: 48px; }
  .stats-label, .period-tab { font-size: 20px; }
  .stats-rank-title, .rank-name { font-size: 24px; }
  .rank-badge { width: 48px; height: 48px; font-size: 22px; margin-right: 16px; }
  .rank-tag { font-size: 16px; padding: 3px 10px; }
  .stats-rank-item { padding: 14px 16px; }
}