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

:root {
  --bg: #161b27;
  --card: #1c2233;
  --card-hover: #242b3d;
  --border: #2a3245;
  --text: #f0f0f5;
  --text-dim: #8b8fa8;
  --accent: #e04141;
  --accent2: #ef5a5a;
  --bar-bg: #2a2e3d;
  --gold: linear-gradient(135deg, #f7971e, #ffd200);
  --silver: linear-gradient(135deg, #bdc3c7, #95a5a6);
  --bronze: linear-gradient(135deg, #e67e22, #d35400);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 32px;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 36px;
}

header h1 {
  font-size: 2.6rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 5px;
}

.subtitle {
  font-size: 1.05rem;
  color: var(--text-dim);
  margin-top: 6px;
  font-weight: 500;
}

/* Dashboard Grid */
.dashboard {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 28px;
  margin-bottom: 28px;
}

/* Gauge Cards */
.gauges {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.gauge-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 28px 24px 20px;
  display: flex;
  justify-content: center;
  transition: transform 0.2s, border-color 0.2s;
}

.gauge-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.gauge-wrap {
  position: relative;
  width: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.gauge-svg {
  width: 100%;
}

.gauge-text {
  position: absolute;
  top: 48%;
  left: 50%;
  transform: translate(-50%, -10%);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
}

.gauge-value {
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--text);
  line-height: 1;
}

.gauge-label {
  font-size: 0.78rem;
  color: var(--text-dim);
  font-weight: 600;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Chart Card */
.chart-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.chart-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

.chart-toggle {
  display: flex;
  background: var(--bg);
  border-radius: 12px;
  padding: 3px;
}

.toggle-btn {
  padding: 8px 16px;
  border: none;
  background: transparent;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.25s;
  font-family: inherit;
}

.toggle-btn:hover {
  color: var(--text);
}

.toggle-btn.active {
  background: var(--accent);
  color: #fff;
}

.chart-wrap {
  flex: 1;
  position: relative;
  min-height: 340px;
  width: 100%;
  overflow: hidden;
}

/* Leaderboard */
.leaderboard-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 28px;
}

.leaderboard-card + .leaderboard-card {
  margin-top: 28px;
}

.leaderboard-card h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text);
}

.leaderboard {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lb-group {
  border-radius: 14px;
  transition: background 0.2s;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 0;
}

.lb-row-dept {
  cursor: pointer;
  padding: 10px 12px;
  border-radius: 14px;
  transition: background 0.15s;
}

.lb-row-dept:hover {
  background: var(--card-hover);
}

/* Sub-list (employees inside department) */
.lb-sub-list {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease, padding 0.25s ease;
  padding: 0 12px 0 56px;
}

.lb-group.expanded .lb-sub-list {
  max-height: 1200px;
  padding: 4px 12px 12px 56px;
}

.lb-sub-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
}

.lb-sub-num {
  width: 22px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-dim);
  text-align: center;
  flex-shrink: 0;
}

.lb-sub-row .lb-name {
  font-size: 0.85rem;
  font-weight: 500;
}

.lb-sub-row .lb-steps {
  font-size: 0.85rem;
  font-weight: 700;
  min-width: 70px;
}

.lb-sub-row .lb-bar-wrap {
  height: 6px;
}

.lb-team-header {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-dim);
  padding: 10px 0 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.lb-team-header:first-child {
  padding-top: 0;
}

.lb-team-total {
  font-weight: 600;
  color: var(--accent2);
  font-size: 0.78rem;
  margin-left: 6px;
}

.lb-rank {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.05rem;
  color: #fff;
  flex-shrink: 0;
}

.lb-rank.gold {
  background: var(--gold);
  box-shadow: 0 4px 12px rgba(255,210,0,0.2);
}
.lb-rank.silver {
  background: var(--silver);
  box-shadow: 0 4px 12px rgba(149,165,166,0.2);
}
.lb-rank.bronze {
  background: var(--bronze);
  box-shadow: 0 4px 12px rgba(211,84,0,0.15);
}
.lb-rank.default {
  background: var(--bar-bg);
  color: var(--text-dim);
}

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

.lb-name {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-dept-tag {
  font-size: 0.72rem;
  font-weight: 600;
  margin-bottom: 4px;
  opacity: 0.85;
}

.lb-bar-wrap {
  height: 10px;
  background: var(--bar-bg);
  border-radius: 5px;
  overflow: hidden;
}

.lb-bar {
  height: 100%;
  border-radius: 5px;
  transition: width 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  width: 0;
}

.lb-steps {
  font-weight: 800;
  font-size: 1rem;
  color: var(--text);
  min-width: 90px;
  text-align: right;
  white-space: nowrap;
}

/* Loading */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,17,23,0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 1000;
  transition: opacity 0.4s;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-overlay p {
  font-weight: 600;
  color: var(--text-dim);
  font-size: 0.95rem;
}

/* ====== Mobile Adaptation ====== */

@media (max-width: 1024px) {
  .dashboard {
    grid-template-columns: 1fr;
  }
  .gauges {
    flex-direction: row !important;
  }
  .gauge-card {
    flex: 1;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 12px;
  }
  header {
    margin-bottom: 16px;
  }
  header h1 {
    font-size: 1.4rem;
    letter-spacing: 2px;
  }
  .subtitle {
    font-size: 0.82rem;
    margin-top: 2px;
  }
  .gauges {
    flex-direction: row !important;
    gap: 10px;
  }
  .gauge-card {
    flex: 1;
    padding: 12px 8px 8px;
    border-radius: 16px;
  }
  .gauge-wrap {
    width: 100%;
    max-width: 180px;
  }
  .gauge-text {
    top: 45%;
  }
  .gauge-value {
    font-size: 1.3rem;
  }
  .gauge-label {
    font-size: 0.58rem;
    letter-spacing: 0;
  }
  .dashboard {
    gap: 12px;
    margin-bottom: 12px;
  }
  .chart-card,
  .leaderboard-card {
    padding: 14px;
    border-radius: 16px;
  }
  .chart-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 12px;
  }
  .chart-header h2 {
    font-size: 1rem;
  }
  .chart-wrap {
    min-height: 240px;
  }
  .leaderboard-card h2 {
    font-size: 1rem;
    margin-bottom: 12px;
  }
  .lb-row {
    gap: 10px;
    padding: 5px 0;
  }
  .lb-rank {
    width: 32px;
    height: 32px;
    font-size: 0.85rem;
    border-radius: 9px;
  }
  .lb-name {
    font-size: 0.84rem;
  }
  .lb-steps {
    font-size: 0.84rem;
    min-width: 65px;
  }
  .lb-bar-wrap {
    height: 7px;
  }
  .leaderboard-card + .leaderboard-card {
    margin-top: 12px;
  }
  .lb-row-dept {
    padding: 8px 8px;
  }
  .lb-sub-list {
    padding-left: 42px;
  }
  .lb-group.expanded .lb-sub-list {
    padding: 2px 8px 8px 42px;
  }
  .lb-sub-row .lb-name {
    font-size: 0.78rem;
  }
  .lb-sub-row .lb-steps {
    font-size: 0.78rem;
    min-width: 55px;
  }
}

@media (max-width: 400px) {
  header h1 {
    font-size: 1.15rem;
    letter-spacing: 1px;
  }
  .gauge-value {
    font-size: 1.1rem;
  }
  .gauge-label {
    font-size: 0.52rem;
  }
  .lb-steps {
    min-width: 55px;
    font-size: 0.78rem;
  }
}
