:root {
  --sidebar-width: 260px;
  --surface: #f4f6fb;
  --card-border: rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 10px 30px rgba(15, 23, 42, 0.06);
  --brand: #0d6efd;
  --brand-dark: #0a58ca;
}

html[data-bs-theme="dark"] {
  --surface: #0f1419;
  --card-border: rgba(255, 255, 255, 0.08);
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--surface);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

a {
  color: inherit;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #111827 0%, #0b1220 100%);
  color: #e5e7eb;
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1.25rem 1.1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand i {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(13, 110, 253, 0.2);
  color: #6ea8fe;
  font-size: 1.25rem;
}

.sidebar-brand small {
  display: block;
  color: #9ca3af;
}

.sidebar-nav {
  padding: 1rem 0.75rem;
  gap: 0.25rem;
  overflow-y: auto;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #cbd5e1;
  border-radius: 0.75rem;
  padding: 0.7rem 0.85rem;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active {
  background: rgba(13, 110, 253, 0.18);
  color: #fff;
}

.sidebar-nav .nav-link i {
  font-size: 1.1rem;
  width: 1.25rem;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  padding: 1rem 1.1rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.main-wrap {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  background: color-mix(in srgb, var(--bs-body-bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--card-border);
  padding: 0.75rem 1.25rem;
  gap: 0.5rem;
}

.topbar-title {
  font-weight: 700;
  font-size: 1.05rem;
}

.season-picker {
  flex-shrink: 0;
}

.season-picker #league-select {
  min-width: 140px;
  max-width: 180px;
  font-weight: 600;
}

.season-picker #season-select {
  min-width: 90px;
  max-width: 110px;
  font-weight: 600;
}

.chart-box {
  position: relative;
  width: 100%;
  height: 240px;
  max-height: 240px;
}

.chart-box canvas {
  width: 100% !important;
  height: 100% !important;
}

.provider-select-wrap {
  min-width: 140px;
}

.provider-select-wrap .form-select {
  font-weight: 600;
}

.content-area {
  flex: 1;
  padding: 1.25rem;
}

.app-footer {
  padding: 0.85rem 1.25rem 1.25rem;
  color: var(--bs-secondary-color);
  font-size: 0.85rem;
}

.page-title {
  font-weight: 750;
  letter-spacing: -0.02em;
}

.card {
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-soft);
  border-radius: 1rem;
}

.entity-card,
.menu-tile,
.match-card {
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.entity-card:hover,
.menu-tile:hover,
.match-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.12);
}

.stat-card .stat-label,
.stat-label {
  color: var(--bs-secondary-color);
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}

.stat-value {
  font-size: 1.55rem;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.stat-icon,
.menu-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.entity-logo {
  object-fit: contain;
  border-radius: 8px;
  background: rgba(148, 163, 184, 0.12);
  padding: 2px;
}

.entity-logo.placeholder {
  display: grid;
  place-items: center;
  color: var(--bs-secondary-color);
  background: rgba(148, 163, 184, 0.15);
}

.player-avatar {
  border-radius: 50%;
  background: linear-gradient(135deg, #0d6efd, #6610f2);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.form-row {
  display: inline-flex;
  gap: 0.25rem;
}

.form-pill {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: inline-grid;
  place-items: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
}

.form-w { background: #198754; }
.form-d { background: #6c757d; }
.form-l { background: #dc3545; }
.form-u { background: #adb5bd; }

.score-box {
  min-width: 64px;
  font-size: 1.25rem;
  font-weight: 750;
}

.search-box {
  position: relative;
  min-width: 220px;
}

.search-box i {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--bs-secondary-color);
  pointer-events: none;
}

.search-box .form-control {
  padding-left: 2.1rem;
}

.standings-table th,
.standings-table td {
  white-space: nowrap;
}

.nav-tabs .nav-link {
  border: none;
  color: var(--bs-secondary-color);
  font-weight: 600;
}

.nav-tabs .nav-link.active {
  color: var(--brand);
  border-bottom: 2px solid var(--brand);
  background: transparent;
}

.global-loader {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.25);
  display: grid;
  place-items: center;
  z-index: 2000;
}

html[data-bs-theme="dark"] .global-loader {
  background: rgba(0, 0, 0, 0.45);
}

.skeleton {
  background: linear-gradient(90deg, rgba(148, 163, 184, 0.18), rgba(148, 163, 184, 0.35), rgba(148, 163, 184, 0.18));
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
  border-radius: 0.5rem;
}

.skeleton-line {
  height: 12px;
  width: 100%;
}

.skeleton-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}

.skeleton-card {
  min-height: 140px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.empty-state,
.error-panel {
  background: var(--bs-body-bg);
  border: 1px dashed var(--card-border);
  border-radius: 1rem;
}

.sidebar-backdrop {
  display: none;
}

@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-105%);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  body.sidebar-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1035;
  }

  .main-wrap {
    margin-left: 0;
  }

  .topbar-search {
    max-width: 180px;
  }

  .season-picker #league-select {
    min-width: 110px;
    max-width: 140px;
  }
}

@media (max-width: 575.98px) {
  .content-area {
    padding: 1rem 0.85rem;
  }

  .topbar-search {
    display: none;
  }

  .topbar-title {
    display: none;
  }

  .season-picker #league-select {
    min-width: 100px;
    max-width: 120px;
    font-size: 0.8rem;
  }

  .season-picker #season-select {
    min-width: 78px;
    font-size: 0.8rem;
  }
}
