@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --brand:       #ad005f;
  --brand-light: #d4006f;
  --brand-dim:   rgba(173,0,95,0.15);
  --green:       #10b981;
  --green-dim:   rgba(16,185,129,0.15);
  --red:         #ef4444;
  --red-dim:     rgba(239,68,68,0.15);
  --blue:        #3b82f6;
  --blue-dim:    rgba(59,130,246,0.15);
  --bg:          #0d0d0d;
  --surface:     #161616;
  --surface2:    #1e1e1e;
  --border:      #272727;
  --text:        #f0f0f0;
  --text-sub:    #888;
  --text-muted:  #555;
  --gold:        #f59e0b;
  --silver:      #94a3b8;
  --bronze:      #b45309;
}

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

html, body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }

/* ─── Layout ─────────────────────────────────────────────────────────── */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-mark {
  width: 36px;
  height: 36px;
  background: var(--brand);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.5px;
  color: #fff;
  flex-shrink: 0;
}

.header-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.header-sub {
  font-size: 12px;
  color: var(--text-sub);
  margin-top: 1px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

#clock {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
}

#date-display {
  font-size: 12px;
  color: var(--text-sub);
  text-align: right;
  margin-top: 2px;
}

.icon-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-sub);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.15s;
}
.icon-btn:hover {
  background: var(--brand-dim);
  border-color: var(--brand);
  color: var(--brand);
}

/* ─── Period Tabs ─────────────────────────────────────────────────────── */

.tabs-bar {
  display: flex;
  gap: 6px;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  align-items: center;
}

.tab-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-sub);
  border-radius: 8px;
  padding: 7px 20px;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}
.tab-btn:hover {
  background: var(--surface2);
  color: var(--text);
}
.tab-btn.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 600;
}

.refresh-info {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.refresh-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
}
.refresh-dot.loading {
  background: var(--gold);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ─── Main content ────────────────────────────────────────────────────── */

.main {
  padding: 22px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ─── Summary Cards ───────────────────────────────────────────────────── */

.cards-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.card-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.card-icon.green  { background: var(--green-dim); }
.card-icon.red    { background: var(--red-dim); }
.card-icon.blue   { background: var(--blue-dim); }
.card-icon.brand  { background: var(--brand-dim); }

.card-body {}

.card-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.card-value {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.1;
  margin-top: 2px;
}

.card-value.green { color: var(--green); }
.card-value.red   { color: var(--red); }
.card-value.blue  { color: var(--blue); }
.card-value.brand { color: var(--brand); }

/* ─── Charts + Leaderboard row ────────────────────────────────────────── */

.content-row {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 14px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.panel-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.panel-legend {
  display: flex;
  gap: 14px;
  font-size: 11px;
  color: var(--text-sub);
}

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

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.chart-wrap {
  padding: 18px 20px;
  position: relative;
  min-height: 280px;
}

/* ─── Leaderboard ─────────────────────────────────────────────────────── */

.leaderboard-list {
  padding: 8px 0;
}

.lb-row {
  display: grid;
  grid-template-columns: 32px 1fr 52px 52px 52px 64px;
  align-items: center;
  padding: 10px 20px;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.lb-row:last-child { border-bottom: none; }
.lb-row:hover { background: var(--surface2); }

.lb-rank {
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  color: var(--text-muted);
}
.lb-rank.gold   { color: var(--gold); }
.lb-rank.silver { color: var(--silver); }
.lb-rank.bronze { color: var(--bronze); }

.lb-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-cell {
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}
.lb-cell.green { color: var(--green); }
.lb-cell.red   { color: var(--red); }
.lb-cell.blue  { color: var(--blue); }

.lb-rate {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}

.lb-rate-num {
  font-size: 12px;
  font-weight: 700;
}

.lb-rate-bar {
  width: 52px;
  height: 4px;
  background: var(--surface2);
  border-radius: 2px;
  overflow: hidden;
}

.lb-rate-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.6s ease;
}

.lb-header {
  display: grid;
  grid-template-columns: 32px 1fr 52px 52px 52px 64px;
  align-items: center;
  padding: 8px 20px;
  gap: 8px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}

.lb-header-cell {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  text-align: center;
}
.lb-header-cell:nth-child(2) { text-align: left; }

/* ─── Empty / loading states ──────────────────────────────────────────── */

.state-msg {
  padding: 48px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-bottom: 12px;
}

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

/* ─── Individual cards ────────────────────────────────────────────────── */

.individuals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  padding: 16px;
}

.ind-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 12px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: border-color 0.15s;
}
.ind-card:hover { border-color: var(--brand); }

.ind-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand-dim);
  border: 1px solid var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--brand);
}

.ind-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.ind-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  justify-content: center;
  margin-top: 2px;
}

.ind-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.ind-val {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1;
}
.ind-val.green { color: var(--green); }
.ind-val.blue  { color: var(--blue); }

.ind-lbl {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.ind-divider {
  width: 1px;
  height: 28px;
  background: var(--border);
}

.ind-rate-bar {
  width: 100%;
  height: 3px;
  background: var(--surface);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 4px;
}

.ind-rate-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.6s ease;
}

.ind-rate-num {
  font-size: 11px;
  font-weight: 700;
}

/* ─── Settings page ───────────────────────────────────────────────────── */

.settings-wrap {
  max-width: 680px;
  margin: 40px auto;
  padding: 0 20px;
}

.settings-title {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 6px;
  letter-spacing: -0.5px;
}

.settings-sub {
  font-size: 13px;
  color: var(--text-sub);
  margin-bottom: 24px;
}

.search-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  margin-bottom: 12px;
  outline: none;
  transition: border-color 0.15s;
}
.search-input:focus { border-color: var(--brand); }
.search-input::placeholder { color: var(--text-muted); }

.user-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 20px;
}

.user-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
  user-select: none;
}
.user-item:last-child { border-bottom: none; }
.user-item:hover { background: var(--surface2); }
.user-item.selected { background: var(--brand-dim); }

.user-checkbox {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}
.user-item.selected .user-checkbox {
  background: var(--brand);
  border-color: var(--brand);
}
.user-checkbox::after {
  content: '';
  display: none;
  width: 5px;
  height: 9px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translate(-1px, -1px);
}
.user-item.selected .user-checkbox::after { display: block; }

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--brand-dim);
  border: 1px solid var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--brand);
  flex-shrink: 0;
}

.user-info {}
.user-name { font-size: 13px; font-weight: 500; }
.user-email { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

.actions-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--brand-light); }

.btn-secondary {
  background: var(--surface2);
  color: var(--text-sub);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
}
.btn-secondary:hover { background: var(--surface); color: var(--text); }

.selected-count {
  font-size: 12px;
  color: var(--text-sub);
  margin-left: auto;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--green);
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.3s;
  pointer-events: none;
}
.toast.show {
  transform: translateY(0);
  opacity: 1;
}
