:root {
  --bg: #090a0f;
  --bg-card: rgba(18, 20, 29, 0.75);
  --bg-card-hover: rgba(26, 29, 42, 0.85);
  --bg-subtle: rgba(255, 255, 255, 0.03);
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);

  --text: #f1f3f9;
  --text-muted: #9499ab;
  --text-dim: #5c6275;

  --accent: #ff4d00;
  --accent-glow: rgba(255, 77, 0, 0.25);
  --gold: #f59e0b;
  --gold-glow: rgba(245, 158, 11, 0.25);
  --silver: #cbd5e1;
  --bronze: #d97706;
  --green: #10b981;
  --blue: #3b82f6;

  --font-display: 'Chakra Petch', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Background effects */
.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(140px);
  pointer-events: none;
  z-index: 0;
}
.bg-glow-1 {
  top: -15%;
  left: 15%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(255, 77, 0, 0.12), transparent 70%);
}
.bg-glow-2 {
  top: 40%;
  right: -10%;
  width: 700px;
  height: 700px;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.08), transparent 70%);
}

.grid-overlay {
  position: fixed;
  inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: 0;
}

.layout {
  position: relative;
  z-index: 1;
  max-width: 1360px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 32px;
}

.brand-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand-logo {
  text-decoration: none;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.12em;
  padding: 4px 8px;
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
}

.brand-logo h1 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.brand-logo h1 span {
  color: var(--gold);
}

.brand-sub {
  font-size: 13px;
  color: var(--text-muted);
}

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

.period-tabs {
  display: flex;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  padding: 3px;
  border-radius: 8px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

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

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--green);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  letter-spacing: 0.05em;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.admin-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  border-radius: 6px;
  transition: all 0.2s;
}

.admin-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

/* Sections */
.section-highlights, .section-standings, .section-races {
  margin-bottom: 40px;
}

.section-title {
  margin-bottom: 18px;
}

.section-title .tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.12em;
  font-weight: 700;
  margin-bottom: 4px;
}

.section-title h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Podium Grid */
.podium-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.podium-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px 20px;
  position: relative;
  overflow: hidden;
  transition: transform 0.25s, box-shadow 0.25s;
}

.podium-card:hover {
  transform: translateY(-4px);
}

.podium-card.p1 {
  border-color: rgba(245, 158, 11, 0.4);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.08) 0%, rgba(18, 20, 29, 0.8) 100%);
  box-shadow: 0 10px 30px -10px rgba(245, 158, 11, 0.2);
}

.podium-card.p2 {
  border-color: rgba(203, 213, 225, 0.3);
  background: linear-gradient(180deg, rgba(203, 213, 225, 0.06) 0%, rgba(18, 20, 29, 0.8) 100%);
}

.podium-card.p3 {
  border-color: rgba(217, 119, 6, 0.3);
  background: linear-gradient(180deg, rgba(217, 119, 6, 0.06) 0%, rgba(18, 20, 29, 0.8) 100%);
}

.podium-rank {
  position: absolute;
  top: 16px;
  right: 18px;
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  opacity: 0.25;
}

.podium-card.p1 .podium-rank { color: var(--gold); opacity: 0.45; }
.podium-card.p2 .podium-rank { color: var(--silver); }
.podium-card.p3 .podium-rank { color: var(--bronze); }

.podium-medal {
  font-size: 26px;
  margin-bottom: 8px;
  display: inline-block;
}

.podium-driver-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.podium-flag {
  font-size: 18px;
}

.podium-car {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.podium-stats {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.podium-points {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}

.podium-card.p1 .podium-points {
  color: var(--gold);
  text-shadow: 0 0 20px var(--gold-glow);
}

.podium-points-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  display: block;
  margin-top: 4px;
}

.podium-badges {
  display: flex;
  gap: 6px;
}

.badge-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  color: var(--text-muted);
}

.badge-chip.win {
  background: rgba(245, 158, 11, 0.15);
  color: var(--gold);
}

/* Stats Row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.stat-box {
  background: var(--bg-card);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-box-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-box-value {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.stat-box-sub {
  font-size: 12px;
  color: var(--text-dim);
}

/* Table */
.table-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 12px;
}

.table-tools {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auto-update-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}

.refresh-btn {
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.refresh-btn:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

.table-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

.table-responsive {
  overflow-x: auto;
}

.standings-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.standings-table th {
  background: rgba(0, 0, 0, 0.35);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.standings-table td {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  vertical-align: middle;
}

.standings-table tbody tr {
  transition: background 0.15s;
}

.standings-table tbody tr:hover {
  background: var(--bg-subtle);
}

.th-pos, .td-pos {
  width: 50px;
  text-align: center;
  font-family: var(--font-mono);
  font-weight: 700;
}

.pos-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.05);
}

.pos-badge.p1 { background: rgba(245, 158, 11, 0.2); color: var(--gold); border: 1px solid rgba(245, 158, 11, 0.4); }
.pos-badge.p2 { background: rgba(203, 213, 225, 0.15); color: var(--silver); border: 1px solid rgba(203, 213, 225, 0.3); }
.pos-badge.p3 { background: rgba(217, 119, 6, 0.15); color: var(--bronze); border: 1px solid rgba(217, 119, 6, 0.3); }

.driver-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.driver-name {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.driver-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
}

.th-num, .td-num {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 13px;
}

.td-best {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
}

.td-diff {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}

.th-pts, .td-pts {
  text-align: right;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--gold);
}

.td-empty {
  text-align: center;
  padding: 40px !important;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Recent Races Grid */
.races-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 20px;
}

.race-card {
  background: var(--bg-card);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.race-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.race-track-name {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
}

.race-date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}

.race-results-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.race-result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}

.race-result-driver {
  display: flex;
  align-items: center;
  gap: 8px;
}

.race-result-pos {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 11px;
  width: 18px;
  color: var(--text-muted);
}

.race-result-pts {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--gold);
}

/* Footer Rules */
.footer-rules {
  margin-top: 50px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.rules-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
}

.rules-card h3 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text);
}

.rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.rule-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rule-k {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  font-weight: 700;
}

.rule-v {
  font-size: 13px;
  color: var(--text-muted);
}

.copyright {
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
}

/* Responsive */
@media (max-width: 960px) {
  .podium-grid {
    grid-template-columns: 1fr;
  }
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .header {
    flex-direction: column;
    align-items: flex-start;
  }
  .stats-row {
    grid-template-columns: 1fr;
  }
  .races-grid {
    grid-template-columns: 1fr;
  }
}

/* Modal Ficha de Piloto */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  opacity: 1;
  transition: opacity 0.2s ease;
}

.modal-backdrop.hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.driver-modal-card {
  background: #111827;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  position: relative;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.modal-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
}

.driver-profile-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.driver-avatar-flag {
  font-size: 38px;
  line-height: 1;
}

.driver-title-info h2 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  color: #fff;
  margin: 2px 0 6px 0;
}

.dm-car-pill {
  display: inline-block;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: var(--gold);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
}

.dm-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.dm-stat-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}

.dm-k {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.dm-v {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: #fff;
}

.dm-v.highlight {
  color: var(--gold);
}

.dm-sec-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.dm-table-wrap {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow-x: auto;
}

.dm-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 12px;
}

.dm-table th {
  background: rgba(0, 0, 0, 0.4);
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--line);
}

.dm-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  color: var(--text-muted);
}
