/* ─── Design Tokens ──────────────────────────────────────────────────────── */
:root {
  --orange:       #FC4C02;
  --orange-light: rgba(252, 76, 2, 0.12);
  --bg:           #f1f3f6;
  --surface:      #ffffff;
  --border:       #e5e8ee;
  --header-bg:    #12151c;
  --text:         #1a1d23;
  --text-muted:   #6b7280;
  --shadow-xs:    0 1px 2px rgba(0,0,0,.05);
  --shadow-sm:    0 2px 8px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:    0 4px 16px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
  --r:            12px;
  --r-sm:         8px;
  --r-pill:       999px;
}

/* ─── Reset / Base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

/* ─── Loading Overlay ────────────────────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(241, 243, 246, 0.88);
  backdrop-filter: blur(6px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
}
.loading-overlay.hidden { display: none; }

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
.loading-overlay p {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ─── Header ─────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--header-bg);
  border-bottom: 3px solid var(--orange);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 1rem;
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.brand-icon {
  width: 40px;
  height: 40px;
  background: var(--orange);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.25rem;
  flex-shrink: 0;
}
.brand-title {
  font-size: clamp(1rem, 2.5vw, 1.25rem);
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.025em;
  line-height: 1.2;
}
.brand-sub {
  font-size: 0.7rem;
  color: #6b7280;
  margin-top: 1px;
  white-space: nowrap;
}

.btn-refresh {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 1rem;
  border: 1.5px solid rgba(255,255,255,0.15);
  border-radius: var(--r-pill);
  background: transparent;
  color: #e5e7eb;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, color 0.18s;
  white-space: nowrap;
}
.btn-refresh:hover { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn-refresh:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-refresh i { font-size: 0.78rem; }

/* ─── Main Container ─────────────────────────────────────────────────────── */
.main {
  max-width: 1360px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 3rem;
}

/* ─── Stats Strip ────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}
@media (max-width: 768px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 420px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow-xs);
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  transition: box-shadow 0.2s, transform 0.2s;
}
.stat-card:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }

.stat-icon-wrap {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  background: var(--orange-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--orange);
  font-size: 0.95rem;
  flex-shrink: 0;
  margin-top: 2px;
}
.stat-body {}
.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1;
}
.stat-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-top: 0.3rem;
}
.stat-delta {
  font-size: 0.72rem;
  font-weight: 600;
  margin-top: 0.25rem;
}
.stat-delta.pos { color: #16a34a; }
.stat-delta.neg { color: #dc2626; }

/* ─── Card ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
  margin-bottom: 1.25rem;
}
.card-header {
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.card-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.card-title-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--orange);
  flex-shrink: 0;
}
.card-body { padding: 1.25rem; }

/* ─── Filters ────────────────────────────────────────────────────────────── */
.filters-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 1.25rem;
  align-items: end;
}
@media (max-width: 900px) { .filters-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 540px) { .filters-grid { grid-template-columns: 1fr; } }

.filter-group {}
.filter-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.45rem;
}

/* Sport-type pill tags */
.sport-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  min-height: 36px;
  align-items: center;
}
.sport-tag {
  padding: 0.28rem 0.7rem;
  border-radius: var(--r-pill);
  font-size: 0.78rem;
  font-weight: 500;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  transition: all 0.15s;
  white-space: nowrap;
}
.sport-tag:hover:not(.active) { border-color: var(--orange); color: var(--orange); }
.sport-tag.active { background: var(--orange); border-color: var(--orange); color: #fff; }

/* Native selects / inputs */
.filter-select,
.filter-input {
  width: 100%;
  height: 36px;
  padding: 0 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 0.85rem;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.filter-select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.6rem center; padding-right: 1.8rem; }
.filter-select:focus, .filter-input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(252,76,2,0.12); }

/* Segmented mode toggle */
.mode-toggle {
  display: flex;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
  height: 36px;
}
.mode-btn {
  flex: 1;
  border: none;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  padding: 0 0.5rem;
}
.mode-btn + .mode-btn { border-left: 1.5px solid var(--border); }
.mode-btn.active { background: var(--orange); color: #fff; }
.mode-btn:hover:not(.active) { background: var(--orange-light); color: var(--orange); }

/* ─── Charts ─────────────────────────────────────────────────────────────── */
.chart-wrap {
  width: 100%;
  height: 400px;
}
.heatmap-wrap { height: 190px; }
@media (max-width: 600px) {
  .chart-wrap { height: 280px; }
  .heatmap-wrap { height: 160px; }
}

/* ─── Utility ────────────────────────────────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}
.spinning { animation: spin 0.8s linear infinite; }
