:root {
  --bg: #05060a;
  --panel: #0b0f1a;
  --text: #f8fafc;
  --muted: #9fb0d0;
  --accent: #5b4bff;
  --accent-2: #2ad1e0;
  --accent-3: #a855f7;
  --stroke: rgba(255,255,255,0.08);
  --radius: 14px;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }

.hero {
  position: relative;
  padding: 32px 24px 20px;
  background: linear-gradient(180deg, #0f1020 0%, #05060a 100%);
  border-bottom: 1px solid var(--stroke);
}
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 80% at 20% 10%, rgba(90,75,255,0.2), transparent 50%),
              radial-gradient(90% 70% at 80% 10%, rgba(42,209,224,0.25), transparent 55%);
  mix-blend-mode: screen;
}
.hero__content {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  max-width: 1100px;
  margin: 0 auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand__mark {
  width: 160px;
  height: 160px;
  position: relative;
  padding: 0;
}
.mountain {
  position: absolute;
  inset: 0;
  background: url('./MTT-Circle.png') center/cover no-repeat;
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 12px;
  color: var(--accent-2);
  margin: 0 0 6px;
}
.hero h1 { margin: 0 0 8px; font-size: 30px; letter-spacing: 0.2px; }
.lede { margin: 0; color: var(--muted); max-width: 560px; }
.hero__meta { display: flex; gap: 8px; align-items: center; }

.shell { max-width: 1100px; margin: 0 auto; padding: 28px 24px 48px; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
.section { margin-top: 32px; }
.section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }
.all-head { align-items: flex-end; }

.list-detail { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 18px; align-items: start; }
.detail-panel { border: 1px solid var(--stroke); border-radius: var(--radius); background: var(--panel); padding: 14px; min-height: 320px; }

.cards { display: grid; gap: 12px; }
.card {
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(91,75,255,0.12), rgba(42,209,224,0.08));
}
.card h3 { margin: 0 0 4px; }
.meta { display: flex; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 14px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--stroke);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--muted);
}
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(91,75,255,0.2);
  color: var(--text);
  font-weight: 600;
}
.hidden { display: none !important; }
.small { font-size: 0.9rem; }
.login-screen { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #0f1020, #0b0f1a); padding: 24px; }
.login-card { background: #0b0f1a; padding: 24px; border-radius: 16px; box-shadow: 0 10px 30px rgba(0,0,0,0.5); max-width: 380px; width: 100%; text-align: center; border: 1px solid var(--stroke); }
.link-btn { background: none; border: none; color: var(--accent); font-weight: 700; cursor: pointer; padding: 0; }
.auth-chip { display: flex; align-items: center; gap: 10px; background: rgba(91,75,255,0.12); border-radius: 999px; padding: 4px 10px; font-weight: 600; }
.auth-chip span { display: inline-block; }

.actions-row { margin-top: 10px; }
.cta {
  display: inline-block;
  padding: 10px 16px;
  border-radius: 999px;
  background: linear-gradient(135deg, #5b4bff 0%, #2ad1e0 100%);
  color: #0a0b10;
  font-weight: 700;
  text-decoration: none;
  border: none;
  cursor: pointer;
}
.cta:hover { filter: brightness(1.05); }
.cta.full { width: 100%; text-align: center; }

.table-wrap { overflow-x: auto; border: 1px solid var(--stroke); border-radius: var(--radius); background: var(--panel); }
table { width: 100%; border-collapse: collapse; min-width: 480px; table-layout: auto; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--stroke); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; }
tbody tr:hover { background: rgba(255,255,255,0.04); }
a.view-results { color: var(--accent); font-weight: 600; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.selected-row { background: rgba(91,75,255,0.12) !important; }

.results-body { border: 1px solid var(--stroke); border-radius: var(--radius); padding: 16px; background: #0b1222; }
.result-card { border: 1px solid var(--stroke); border-radius: 12px; padding: 12px; margin-bottom: 12px; background: rgba(255,255,255,0.02); }
.result-card h4 { margin: 0 0 8px; }
.result-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.result-two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; }
.stack-gap > * + * { margin-top: 8px; }
.muted { color: var(--muted); margin: 0; }
.time { font-variant-numeric: tabular-nums; }
.finishers-table { width: 100%; min-width: 900px; table-layout: auto; }
.finishers-table th, .finishers-table td { white-space: nowrap; text-align: left; }
.finishers-table .place-col { width: 56px; }
.finishers-table .points-col { width: 60px; }
.finishers-table .wide-col { width: auto; }
.finishers-table .time-col { width: 120px; font-variant-numeric: tabular-nums; }
.finishers-table .small-col { width: 70px; }
.finishers { margin-top: 8px; }
.division-section { margin-top: 16px; }
.division-grid { display: grid; grid-template-columns: repeat(2, minmax(360px, 1fr)); gap: 12px; }
.division-card { border: 1px solid var(--stroke); border-radius: 10px; padding: 10px; background: rgba(255,255,255,0.04); }
.division-card h5 { margin: 0 0 4px; }
.division-inline { margin-top: 8px; }
.team-results { margin-top: 8px; }
.team-list { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 8px; }
.team-list-item { display: grid; grid-template-columns: 60px 1fr; gap: 10px; align-items: center; border: 1px solid var(--stroke); border-radius: 12px; padding: 10px; background: rgba(255,255,255,0.03); }
.team-place { font-size: 28px; font-weight: 800; line-height: 1; text-align: center; }
.team-body { display: grid; gap: 4px; }
.team-name { font-weight: 700; }
.team-score { font-weight: 600; }
.team-runners { line-height: 1.4; }
.division-card .finishers-table { table-layout: fixed; min-width: 0; }
.division-card .runner-col { width: 58%; }
.division-card .time-col { width: 100px; }
.grouped-tables table { table-layout: fixed; }
.grouped-tables th:nth-child(1),
.grouped-tables td:nth-child(1) { width: 45%; }
.grouped-tables th:nth-child(2),
.grouped-tables td:nth-child(2) { width: 25%; }
.grouped-tables th:nth-child(3),
.grouped-tables td:nth-child(3) { width: 30%; }

.all-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-left: auto; }
#search-races {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: #0f1424;
  color: var(--text);
  min-width: 240px;
}

/* Login page */
.login-page { background: radial-gradient(120% 100% at 20% 20%, rgba(91,75,255,0.18), transparent 50%), #05060a; min-height: 100vh; }
.login-shell { max-width: 900px; margin: 0 auto; padding: 32px 20px 48px; }
.login-card.wide { background: #0b0f1a; border-radius: 18px; border: 1px solid var(--stroke); box-shadow: 0 20px 80px rgba(0,0,0,0.4); padding: 24px; }
.login-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.login-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-top: 18px; }
.login-option { border: 1px solid var(--stroke); border-radius: 12px; padding: 14px; background: rgba(255,255,255,0.02); }
.inline-alert { margin-top: 10px; padding: 10px 12px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.2); background: rgba(255,255,255,0.05); font-size: 0.9rem; }
.inline-alert.success { border-color: rgba(76, 175, 80, 0.35); color: #9be28f; }
.dev-form { display: grid; gap: 6px; margin-top: 10px; }
.dev-form input { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--stroke); background: #0f1424; color: var(--text); }
.input-inline { width: 100%; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--stroke); background: #0f1424; color: var(--text); }
#user-table select { padding: 8px 10px; border-radius: 10px; border: 1px solid var(--stroke); background: #0f1424; color: var(--text); }
#user-table td { vertical-align: middle; }

.toggle-row { display: inline-flex; gap: 8px; align-items: center; margin: 0 0 12px; }
.toggle-btn {
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
}
.toggle-btn.active { background: linear-gradient(135deg, #5b4bff 0%, #2ad1e0 100%); color: #0a0b10; border-color: transparent; }

@media (max-width: 640px) {
  .hero__content { flex-direction: column; align-items: flex-start; }
  .shell { padding: 18px; }
  table { min-width: 100%; }
  .login-head { flex-direction: column; align-items: flex-start; }
}
