:root {
  color-scheme: dark;
  --bg: #121212;
  --surface: #151515;
  --surface-2: #1A1A1A;
  --surface-3: #222;
  --border: #2A2A2A;
  --border-light: #333;
  --accent: #FF3202;
  --accent-hover: #E62D00;
  --accent-soft: rgba(255, 50, 2, 0.12);
  --text: #FFFFFF;
  --text-secondary: #999;
  --text-muted: #666;
  --green: #34C759;
  --yellow: #FFD60A;
  --blue: #0A84FF;
  --purple: #BF5AF2;
  --red: #FF453A;
}

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

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

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px;
}

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

.header h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.header h1 .accent { color: var(--accent); }

.header .subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 4px;
}

.status-banner {
  text-align: center;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 24px;
}

.status-banner.not-started {
  background: rgba(255, 214, 10, 0.12);
  color: var(--yellow);
  border: 1px solid rgba(255, 214, 10, 0.25);
}

.status-banner.final {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(255, 50, 2, 0.25);
}

/* Stat cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.stat-card .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-card .value {
  font-size: 24px;
  font-weight: 700;
}

.stat-card .value.accent { color: var(--accent); }

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.tab {
  padding: 10px 20px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Table */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

thead th:hover { color: var(--text-secondary); }
thead th.sorted { color: var(--accent); }

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

tbody td {
  padding: 12px 16px;
  white-space: nowrap;
}

/* Rank highlights */
tr.rank-1 td:first-child { border-left: 3px solid var(--yellow); }
tr.rank-2 td:first-child { border-left: 3px solid var(--text-secondary); }
tr.rank-3 td:first-child { border-left: 3px solid #CD7F32; }

tr.not-connected td { color: var(--text-muted); }

/* Avatar / initials */
.member-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.member-name { font-weight: 500; }
.streak-star { color: var(--yellow); margin-left: 4px; }

/* Category pills */
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

.pill-reach { background: rgba(10, 132, 255, 0.15); color: var(--blue); }
.pill-eng { background: rgba(191, 90, 242, 0.15); color: var(--purple); }
.pill-cons { background: rgba(52, 199, 89, 0.15); color: var(--green); }
.pill-leads { background: var(--accent-soft); color: var(--accent); }

/* Week selector */
.week-selector {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.week-selector select {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
}

.week-selector label {
  font-size: 13px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Rules section */
.rules-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  line-height: 1.7;
  color: var(--text-secondary);
}

.rules-content h3 {
  color: var(--text);
  margin: 20px 0 8px;
  font-size: 16px;
}

.rules-content h3:first-child { margin-top: 0; }

.rules-content ul {
  padding-left: 20px;
  margin: 8px 0;
}

.rules-content li { margin: 4px 0; }

.rules-content code {
  background: var(--surface-3);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  color: var(--accent);
}

.synced-note {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 16px;
}

/* Legend */
.legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Number formatting */
.num-total { font-weight: 700; font-size: 15px; }
.num-imp { color: var(--text-secondary); }
.num-zero { color: var(--text-muted); }

/* Loading */
.loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

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

/* Cash prize badge */
.prize-badge {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  margin-left: 6px;
}

.prize-1 { background: rgba(255, 214, 10, 0.15); color: var(--yellow); }
.prize-2 { background: rgba(153, 153, 153, 0.15); color: var(--text-secondary); }
.prize-3 { background: rgba(205, 127, 50, 0.15); color: #CD7F32; }

/* Responsive */
@media (max-width: 768px) {
  .container { padding: 16px 12px; }
  .header h1 { font-size: 22px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .tabs { overflow-x: auto; }
  table { font-size: 13px; }
  tbody td, thead th { padding: 10px 12px; }
}
