:root {
  --bg: #070a12;
  --bg-elevated: #0d1322;
  --card-bg: #111827;
  --panel-bg: #172033;
  --panel-hover: #1e2942;
  --border: #222f49;
  --border-light: rgba(255, 255, 255, 0.08);
  --border-focus: #f0cf7b;
  --accent: #f0cf7b;
  --accent-glow: rgba(240, 207, 123, 0.22);
  --discord: #5865F2;
  --discord-hover: #4752c4;
  --success: #10b981;
  --green: #10b981;
  --blue: #38bdf8;
  --purple: #a78bfa;
  --amber: #f59e0b;
  --danger: #ef4444;
  --red: #ef4444;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --code-bg: #05080f;
  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(circle at 50% 0%, rgba(240, 207, 123, 0.07) 0%, transparent 55%), var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9em;
  background: rgba(88, 101, 242, 0.16);
  color: #c7d2fe;
  padding: 0.08rem 0.34rem;
  border-radius: 4px;
  border: 1px solid rgba(88, 101, 242, 0.28);
}

/* ==========================================
   TOP NAVIGATION BAR
   ========================================== */
.navbar {
  background: rgba(13, 19, 34, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 250;
  min-height: 64px;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
}

.navbar-container {
  max-width: 1360px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 1.15rem;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-weight: 800;
  font-size: 1.05rem;
  color: #fff;
  text-decoration: none !important;
  flex-shrink: 0;
}

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(240, 207, 123, 0.12);
  border: 1px solid rgba(240, 207, 123, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-icon img {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  object-fit: cover;
}

.brand-title {
  background: linear-gradient(135deg, #ffffff 0%, #f0cf7b 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-tag {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  border: 1px solid var(--border-light);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 0.22rem;
  border-radius: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-links::-webkit-scrollbar {
  display: none;
}

.nav-link {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.34rem 0.72rem;
  border-radius: 7px;
  text-decoration: none !important;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.04);
}

.nav-link.active {
  background: var(--panel-bg);
  color: var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

/* Navbar Live Daylight Pill */
.nav-daylight-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.68rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none !important;
  font-variant-numeric: tabular-nums;
  transition: all 0.16s ease;
  white-space: nowrap;
}

.nav-daylight-pill:hover {
  border-color: rgba(240, 207, 123, 0.45);
  background: var(--panel-bg);
}

.nav-daylight-pill.is-day {
  border-color: rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.08);
}

.nav-daylight-pill.is-twilight {
  border-color: rgba(249, 115, 22, 0.38);
  background: rgba(249, 115, 22, 0.1);
}

.nav-daylight-pill.is-night {
  border-color: rgba(99, 102, 241, 0.38);
  background: rgba(99, 102, 241, 0.1);
}

.nav-dl-icon {
  font-size: 0.86rem;
  line-height: 1;
}

.nav-dl-time {
  letter-spacing: 0.02em;
}

/* ==========================================
   BUTTONS
   ========================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.86rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  text-decoration: none !important;
  font-family: inherit;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-discord {
  background: var(--discord);
  color: #fff !important;
  border-color: rgba(255, 255, 255, 0.12);
}

.btn-discord:hover {
  background: var(--discord-hover);
  box-shadow: 0 4px 16px rgba(88, 101, 242, 0.35);
}

.btn-secondary {
  background: var(--panel-bg);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--panel-hover);
  border-color: #36496e;
}

.btn-primary {
  background: linear-gradient(135deg, #f0cf7b 0%, #d4af37 100%);
  color: #090d16 !important;
  font-weight: 700;
}

.btn-primary:hover {
  filter: brightness(1.06);
  box-shadow: 0 4px 18px var(--accent-glow);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.14);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.24);
}

.btn-sm {
  padding: 0.38rem 0.75rem;
  font-size: 0.8rem;
  border-radius: 7px;
}

.btn-xs {
  padding: 0.28rem 0.58rem;
  font-size: 0.74rem;
  border-radius: 6px;
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
  border-radius: 10px;
}

/* ==========================================
   USER PROFILE DROPDOWN
   ========================================== */
.user-menu-wrapper {
  position: relative;
  display: inline-block;
}

.user-pill-btn {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  padding: 0.26rem 0.72rem 0.26rem 0.3rem;
  border-radius: 9999px;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  font-size: 0.83rem;
  font-weight: 600;
  transition: all 0.15s ease;
}

.user-pill-btn:hover {
  border-color: #3b4e75;
  background: var(--panel-hover);
}

.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--border);
}

.chevron {
  color: var(--text-dim);
  transition: transform 0.2s ease;
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 240px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.65);
  z-index: 1000;
  display: none;
  flex-direction: column;
  padding: 0.45rem 0;
  animation: fadeIn 0.14s ease;
}

.user-dropdown.open {
  display: flex;
}

.user-dropdown-header {
  padding: 0.65rem 1rem;
}

.user-dropdown-title {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

.user-dropdown-name {
  font-size: 0.92rem;
  color: #fff;
  font-weight: 700;
  margin-top: 0.1rem;
}

.user-dropdown-meta {
  font-size: 0.78rem;
  color: var(--accent);
  margin-top: 0.15rem;
}

.user-dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 0.35rem 0;
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none !important;
  transition: background 0.12s ease, color 0.12s ease;
  cursor: pointer;
}

.user-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.user-dropdown-item.text-danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

/* ==========================================
   SHARED LAYOUT & COMPONENTS
   ========================================== */
.container {
  max-width: 1360px;
  width: 100%;
  margin: 1.5rem auto 2.5rem auto;
  padding: 0 1.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-title-block h1 {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.page-subtitle {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.3rem 1.4rem;
  box-shadow: 0 14px 32px -12px rgba(0, 0, 0, 0.5);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.85rem;
  margin-bottom: 1.05rem;
  flex-wrap: wrap;
}

.card-title {
  font-size: 1.02rem;
  font-weight: 800;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-sub,
.card-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* Pills & Segmented Controls */
.pill-group {
  display: inline-flex;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
  flex-wrap: wrap;
}

.pill-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.36rem 0.72rem;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.14s ease;
}

.pill-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.04);
}

.pill-btn.active {
  background: var(--panel-bg);
  color: var(--accent);
  border-color: rgba(240, 207, 123, 0.26);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.segmented-control {
  display: inline-flex;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 2px;
}

.seg-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.3rem 0.65rem;
  border-radius: 5px;
  cursor: pointer;
}

.seg-btn.active {
  background: var(--accent);
  color: #090d16;
  font-weight: 700;
}

/* Unified Stats Hub Sub-Tab Bar */
.stats-subnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.stats-subnav-tabs {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.32rem;
  flex-wrap: wrap;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);
}

.stats-subnav-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.48rem;
  padding: 0.46rem 0.95rem;
  border-radius: 9px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-muted);
  border: 1px solid transparent;
  text-decoration: none !important;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.stats-subnav-tab:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.stats-subnav-tab.active {
  background: rgba(240, 207, 123, 0.14);
  color: var(--accent);
  border-color: rgba(240, 207, 123, 0.42);
  box-shadow: 0 2px 10px rgba(240, 207, 123, 0.12);
}

@media (max-width: 560px) {
  .stats-subnav-tabs {
    width: 100%;
  }
  .stats-subnav-tab {
    flex: 1;
    justify-content: center;
    padding: 0.45rem 0.65rem;
    font-size: 0.8rem;
  }
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.69rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-green {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.badge-red {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.badge-amber {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.badge-blue {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.badge-purple {
  background: rgba(167, 139, 250, 0.16);
  color: #d8b4fe;
  border: 1px solid rgba(167, 139, 250, 0.36);
}

.badge-gold {
  background: rgba(240, 207, 123, 0.14);
  color: var(--accent);
  border: 1px solid rgba(240, 207, 123, 0.36);
}

.badge-muted {
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-muted);
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.14);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: blink 2s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.progress-track {
  height: 7px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.35s ease;
}

.text-input {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-family: inherit;
  outline: none;
  width: 100%;
}

.text-input:focus {
  border-color: var(--accent);
}

.empty-state {
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--text-dim);
  font-size: 0.84rem;
}

/* ==========================================
   SHARED DRIVER SEARCH & AUTOCOMPLETE
   ========================================== */
.stage-search-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.68rem;
  flex: 1;
  min-width: 220px;
}

.stage-search-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.stage-search-bar svg {
  color: var(--text-dim);
  flex-shrink: 0;
}

.stage-search-bar input {
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  width: 100%;
  outline: none;
}

.stage-search-bar input::-webkit-search-cancel-button {
  display: none;
}

.search-clear-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.95rem;
  line-height: 1;
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.search-clear-btn.visible {
  display: inline-flex;
}

.search-clear-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.driver-suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #141c2f;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-sm);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.72);
  z-index: 400;
  max-height: 310px;
  overflow-y: auto;
  display: none;
  padding: 0.3rem;
}

.driver-suggestions.open {
  display: block;
  animation: fadeIn 0.12s ease;
}

.suggestion-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s ease;
}

.suggestion-item:hover,
.suggestion-item.active {
  background: rgba(240, 207, 123, 0.13);
}

.suggestion-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.suggestion-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.suggestion-sub {
  font-size: 0.72rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.suggestion-badge {
  font-size: 0.67rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.suggestion-badge.online {
  background: rgba(16, 185, 129, 0.16);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.suggestion-badge.saved {
  background: rgba(240, 207, 123, 0.16);
  color: var(--accent);
  border: 1px solid rgba(240, 207, 123, 0.3);
}

.suggestion-badge.community {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

/* ==========================================
   TOAST & FOOTER
   ========================================== */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: #172135;
  border: 1px solid var(--border);
  color: #fff;
  padding: 0.75rem 1.2rem;
  border-radius: var(--radius-sm);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55);
  display: none;
  align-items: center;
  gap: 0.55rem;
  font-weight: 600;
  font-size: 0.86rem;
  z-index: 9999;
}

.toast.show {
  display: flex;
  animation: fadeIn 0.18s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.footer {
  border-top: 1px solid var(--border);
  padding: 1.4rem 1.5rem;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: auto;
}

.footer-links {
  margin-bottom: 0.4rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

/* ==========================================
   RESPONSIVE NAVBAR & BASE LAYOUT
   ========================================== */
@media (max-width: 1020px) {
  .brand-tag {
    display: none;
  }
}

@media (max-width: 820px) {
  .navbar {
    padding: 0.45rem 0.85rem;
    min-height: 58px;
  }
  .navbar-container {
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .nav-left {
    width: 100%;
    justify-content: space-between;
    gap: 0.55rem;
  }
  .nav-actions {
    width: 100%;
    justify-content: flex-end;
    gap: 0.45rem;
  }
  .nav-links {
    padding: 0.16rem;
    gap: 0.16rem;
  }
  .nav-link {
    font-size: 0.74rem;
    padding: 0.28rem 0.54rem;
  }
  .hide-mobile-text {
    display: none;
  }
  .container {
    padding: 0 0.9rem;
    margin-top: 1rem;
  }
  .toast {
    left: 0.85rem;
    right: 0.85rem;
    bottom: 0.85rem;
    justify-content: center;
  }
}

