:root {
  --bg-0: #070912;
  --bg-1: #0d1020;
  --panel: rgba(20, 24, 42, 0.6);
  --panel-solid: #141a2e;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f1f3f9;
  --muted: #8a93ab;
  --muted-2: #5e667d;

  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --accent-3: #f472b6;
  --success: #34d399;
  --warn: #fbbf24;

  --gold: #ffd36b;
  --silver: #d6dde8;
  --bronze: #e3a178;

  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg-0);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ---------- animated background orbs ---------- */
.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
  animation: float 18s ease-in-out infinite;
}
.orb-1 {
  width: 520px; height: 520px;
  background: radial-gradient(circle, #7c5cff 0%, transparent 70%);
  top: -160px; left: -160px;
}
.orb-2 {
  width: 460px; height: 460px;
  background: radial-gradient(circle, #22d3ee 0%, transparent 70%);
  top: 30%; right: -180px;
  animation-delay: -6s;
}
.orb-3 {
  width: 520px; height: 520px;
  background: radial-gradient(circle, #f472b6 0%, transparent 70%);
  bottom: -220px; left: 20%;
  animation-delay: -12s;
}
@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%      { transform: translate(30px, -40px) scale(1.08); }
}

/* ---------- layout ---------- */
.shell {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}

/* ---------- hero ---------- */
.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 2rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}
.hero-left { flex: 1 1 320px; }

.eyebrow {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-2);
  background: rgba(34, 211, 238, 0.08);
  border: 1px solid rgba(34, 211, 238, 0.25);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  margin-bottom: 1rem;
}

.hero h1 {
  font-size: clamp(2.2rem, 4.5vw, 3.4rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.05;
  margin: 0 0 0.75rem;
}
.gradient-text {
  background: linear-gradient(100deg, #7c5cff 0%, #22d3ee 50%, #f472b6 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
  max-width: 38rem;
}

.hero-stats { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.hero-stat {
  background: var(--panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  min-width: 110px;
}
.hero-stat .val {
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.hero-stat .lbl {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 0.15rem;
}

/* ---------- cards ---------- */
.card {
  background: var(--panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 1rem;
}
.card-head h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.card-sub {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ---------- presets ---------- */
.presets {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.presets button {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.85rem;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.presets button:hover {
  color: var(--text);
  border-color: var(--border-strong);
}
.presets button.active {
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.3), rgba(34, 211, 238, 0.2));
  border-color: rgba(124, 92, 255, 0.6);
  color: var(--text);
  box-shadow: 0 0 0 1px rgba(124, 92, 255, 0.35);
}

/* ---------- filters ---------- */
.filters-card { padding: 1.25rem 1.5rem; }
.filters-row {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 1.1rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--border);
}
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.filter-group.grow { flex: 1 1 220px; }
.filter-group label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 600;
}
.filter-group input[type="date"],
.filter-group select {
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  font: inherit;
  font-size: 0.88rem;
  color-scheme: dark;
  transition: border-color 0.15s, background 0.15s;
}
.filter-group input:focus,
.filter-group select:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(124, 92, 255, 0.08);
}

/* ---------- chips ---------- */
.chips { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.5rem 0.95rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover {
  color: var(--text);
  border-color: var(--border-strong);
}
.chip.active {
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.25), rgba(34, 211, 238, 0.2));
  border-color: rgba(124, 92, 255, 0.6);
  color: var(--text);
  box-shadow: 0 0 0 1px rgba(124, 92, 255, 0.4), 0 8px 24px -8px rgba(124, 92, 255, 0.5);
}
.chip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--accent-2);
}
.chip.active .chip-icon {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

/* ---------- podium ---------- */
.podium {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.podium-card {
  background: var(--panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s;
  cursor: pointer;
}
.podium-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, var(--accent-bg) 0%, transparent 60%);
  opacity: 0.25;
  pointer-events: none;
}
.podium-card:hover { transform: translateY(-4px); }

.podium-card.p1 { --accent-bg: var(--gold); border-color: rgba(255, 211, 107, 0.3); }
.podium-card.p2 { --accent-bg: var(--silver); border-color: rgba(214, 221, 232, 0.25); }
.podium-card.p3 { --accent-bg: var(--bronze); border-color: rgba(227, 161, 120, 0.28); }

.podium-medal {
  display: inline-block;
  font-size: 1rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: var(--accent-bg);
  color: #0b0d17;
  margin-bottom: 0.85rem;
  position: relative;
}
.podium-card img {
  width: 64px; height: 64px;
  border-radius: 50%;
  border: 2px solid var(--accent-bg);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  position: relative;
}
.podium-name {
  position: relative;
  font-weight: 600;
  margin: 0.75rem 0 0.35rem;
  font-size: 1.05rem;
}
.podium-value {
  position: relative;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent-bg);
  font-variant-numeric: tabular-nums;
}
.podium-metric {
  position: relative;
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-top: 0.2rem;
}
.podium-ext {
  position: relative;
  display: inline-block;
  margin-top: 0.4rem;
  font-size: 0.7rem;
  font-family: "JetBrains Mono", monospace;
  color: var(--accent-2);
  background: rgba(34, 211, 238, 0.1);
  border: 1px solid rgba(34, 211, 238, 0.2);
  border-radius: 6px;
  padding: 0.1rem 0.45rem;
}
.ext-badge {
  display: inline-block;
  margin-left: 0.4rem;
  font-size: 0.65rem;
  font-family: "JetBrains Mono", monospace;
  color: var(--accent-2);
  background: rgba(34, 211, 238, 0.08);
  border: 1px solid rgba(34, 211, 238, 0.18);
  border-radius: 5px;
  padding: 0.05rem 0.35rem;
  vertical-align: middle;
}

/* ---------- chart ---------- */
.chart-card .chart-wrap {
  position: relative;
  height: 280px;
}

/* ---------- table ---------- */
.board-card { padding: 1.5rem 0.5rem 0.75rem; }
.board-card .card-head { padding: 0 1.25rem; }

.board-wrap { overflow-x: auto; }

#board {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 6px;
  padding: 0 1rem;
}
#board th {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted-2);
  font-weight: 600;
  text-align: left;
  padding: 0.5rem 0.75rem;
}
#board th.col-rank { width: 3.5rem; }
#board th.col-val,
#board td.col-val { text-align: right; }
#board th.col-bar { width: 30%; }

#board tbody tr {
  background: rgba(255, 255, 255, 0.02);
  transition: background 0.15s, transform 0.15s;
  cursor: pointer;
}
#board tbody tr:hover { background: rgba(124, 92, 255, 0.08); }
#board td {
  padding: 0.85rem 0.75rem;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
#board td:first-child {
  border-left: 1px solid var(--border);
  border-top-left-radius: var(--radius-sm);
  border-bottom-left-radius: var(--radius-sm);
}
#board td:last-child {
  border-right: 1px solid var(--border);
  border-top-right-radius: var(--radius-sm);
  border-bottom-right-radius: var(--radius-sm);
}

#board td.rank {
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
  color: var(--muted);
}
#board tr.top-1 td.rank { color: var(--gold); }
#board tr.top-2 td.rank { color: var(--silver); }
#board tr.top-3 td.rank { color: var(--bronze); }

#board td.user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
#board td.user img {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
}
#board td.user .user-login {
  color: var(--text);
  font-weight: 500;
}

#board td.col-val {
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.bar-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #7c5cff, #22d3ee);
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* ---------- footer ---------- */
footer {
  text-align: center;
  color: var(--muted-2);
  font-size: 0.8rem;
  margin-top: 2rem;
}
footer code {
  background: rgba(255, 255, 255, 0.05);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.78rem;
}

/* ---------- modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  animation: fadeIn 0.15s ease;
}
.modal.hidden { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 4, 12, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.modal-content {
  position: relative;
  background: #0f1328;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: 0 40px 120px -20px rgba(0, 0, 0, 0.8);
  padding: 2rem;
  max-width: 880px;
  width: 100%;
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
}
.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s;
}
.modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-strong);
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.profile-head {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.profile-head img {
  width: 84px; height: 84px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
}
.profile-head h2 {
  margin: 0 0 0.25rem;
  font-size: 1.6rem;
  font-weight: 700;
}
.profile-head a {
  color: var(--accent-2);
  text-decoration: none;
  font-size: 0.9rem;
}
.profile-head a:hover { text-decoration: underline; }

.profile-h3 {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin: 1.75rem 0 0.85rem;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.75rem;
}
.metric-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.metric-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}
.metric-value {
  font-family: "JetBrains Mono", monospace;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.metric-total {
  font-size: 0.7rem;
  color: var(--muted-2);
  font-variant-numeric: tabular-nums;
}
.metric-ext {
  font-size: 0.65rem;
  color: var(--accent-2);
  font-family: "JetBrains Mono", monospace;
  opacity: 0.85;
}
.metric-rank {
  font-size: 0.72rem;
  font-family: "JetBrains Mono", monospace;
  font-weight: 600;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.1rem 0.4rem;
  align-self: flex-start;
}
.metric-rank--top {
  color: var(--warn);
  background: rgba(251, 191, 36, 0.08);
  border-color: rgba(251, 191, 36, 0.25);
}
.metric-rank--none {
  color: var(--muted-2);
  background: transparent;
  border-color: transparent;
}
.profile-global-rank {
  display: inline-block;
  margin-top: 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-2);
  letter-spacing: 0.02em;
}

.repo-table-wrap { overflow-x: auto; }
.repo-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.repo-table th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-2);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.repo-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-family: "JetBrains Mono", monospace;
  font-variant-numeric: tabular-nums;
}
.repo-table td:first-child { font-family: "Inter"; color: var(--text); }
.repo-table .repo-name { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.repo-table tbody tr:hover { background: rgba(124, 92, 255, 0.06); }

.user-chart-wrap {
  position: relative;
  height: 240px;
  margin-top: 0.5rem;
}
.muted { color: var(--muted); font-size: 0.85rem; }

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .podium { grid-template-columns: 1fr; }
  .shell { padding: 2rem 1rem 3rem; }
  .hero { flex-direction: column; align-items: flex-start; }
  .modal-content { padding: 1.5rem 1.25rem; }
  .profile-head { flex-direction: column; text-align: center; }
}
