:root {
  --night:  #0C1826;
  --blue:   #1D3A58;
  --jaune:  #F7C948;
  --paper:  #F5F2EB;
  --white:  #FFFFFF;
  --ink:    #1A1A1A;
  --muted:  #6B6257;
  --border: #D6CEBC;
  --green:  #2B6044;
  --red:    #C43B28;
}

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

body {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────────── */
.site-header {
  background: var(--night);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,.3);
}

.site-header::before {
  content: '';
  display: block;
  height: 4px;
  background: repeating-linear-gradient(90deg, var(--jaune) 0, var(--jaune) 50px, var(--night) 50px, var(--night) 66px);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo {
  font-size: 16px;
  font-weight: 900;
  color: #fff;
  text-decoration: none;
  letter-spacing: -.01em;
}

.logo em { font-style: normal; color: var(--jaune); }

nav { display: flex; align-items: center; gap: 4px; }

nav a {
  color: #9BAFBF;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 4px;
  transition: color .15s, background .15s;
}

nav a:hover { color: #fff; background: rgba(255,255,255,.08); }

.nav-btn {
  background: none;
  border: 1px solid rgba(255,255,255,.2);
  color: #9BAFBF;
  font-size: 13px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}

.nav-btn:hover { color: #fff; border-color: rgba(255,255,255,.4); }

/* ── Main content ────────────────────────────────────── */
.main-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

/* ── Flash messages ──────────────────────────────────── */
.flash {
  padding: 12px 16px;
  border-radius: 4px;
  margin-bottom: 20px;
  font-size: 14px;
}

.flash--success { background: #D6EFE0; color: #1F5C36; border-left: 3px solid var(--green); }
.flash--error   { background: #FCE4E0; color: #8B1A12; border-left: 3px solid var(--red); }

/* ── Auth forms ──────────────────────────────────────── */
.auth-wrap {
  max-width: 420px;
  margin: 48px auto;
}

.auth-wrap h1 { font-size: 26px; font-weight: 800; margin-bottom: 24px; color: var(--blue); }

.form { display: flex; flex-direction: column; gap: 14px; }

.form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.form input, .form select {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 15px;
  background: var(--white);
  color: var(--ink);
  transition: border-color .15s;
}

.form input:focus, .form select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(29,58,88,.12);
}

.form-error {
  font-size: 13px;
  color: var(--red);
  background: #FCE4E0;
  padding: 10px 14px;
  border-radius: 4px;
  margin-bottom: 4px;
}

.auth-alt { margin-top: 16px; font-size: 13px; color: var(--muted); }
.auth-alt a { color: var(--blue); }

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 18px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border: none;
  transition: background .15s, color .15s;
  white-space: nowrap;
}

.btn--primary { background: var(--blue); color: #fff; }
.btn--primary:hover { background: #152C46; }

.btn--ghost { background: transparent; color: var(--blue); border: 1px solid var(--border); }
.btn--ghost:hover { background: var(--paper); }

.btn--sm { padding: 5px 10px; font-size: 12px; }

/* ── Standings ───────────────────────────────────────── */
.standings-wrap { max-width: 640px; }

.standings-header { margin-bottom: 24px; }
.standings-header h1 { font-size: 28px; font-weight: 900; color: var(--blue); letter-spacing: -.02em; }
.standings-meta { font-size: 13px; color: var(--muted); margin-top: 4px; }

.standings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.standings-table th {
  text-align: left;
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 12px;
  border-bottom: 2px solid var(--border);
}

.standings-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.standings-table tr:hover td { background: rgba(0,0,0,.02); }
.standings-table .top-1 td { background: rgba(247,201,72,.08); }
.standings-table .top-2 td { background: rgba(0,0,0,.02); }
.standings-table .top-3 td { background: rgba(139,90,43,.05); }

.rank-cell { width: 48px; }
.pts-col, .pts-cell { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }

.standings-name-link { color: var(--ink); text-decoration: none; font-weight: 600; }
.standings-name-link:hover { color: var(--blue); text-decoration: underline; }

.team-size-cell { font-size: 12px; }
.team-full-chip    { background: #D5EEE1; color: #1C5234; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 3px; white-space: nowrap; }
.team-partial-chip { background: #FEF2C0; color: #7A5800; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 3px; white-space: nowrap; }
.team-empty-chip   { background: var(--paper); color: var(--muted); font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 3px; white-space: nowrap; border: 1px solid var(--border); }

/* ── View team page ───────────────────────────────────── */
.view-team-wrap { max-width: 900px; }

.view-team-header {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.view-team-header h1 {
  font-size: 24px;
  font-weight: 900;
  color: var(--blue);
  letter-spacing: -.02em;
  flex: 1;
}

.view-team-header h1 em { font-style: normal; color: var(--ink); }

.back-link {
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
}
.back-link:hover { color: var(--blue); }

.view-team-grid {
  columns: 2;
  column-gap: 24px;
}

.view-team-grid .team-group {
  break-inside: avoid;
  margin-bottom: 20px;
}

@media (max-width: 600px) {
  .view-team-grid { columns: 1; }
}

.badge {
  display: inline-flex;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
}

.badge.gold   { background: #F7C948; color: #7A5800; }
.badge.silver { background: #DDD; color: #555; }
.badge.bronze { background: #D4A574; color: #5A3010; }

/* ── Team layout ─────────────────────────────────────── */
.team-layout {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 760px) {
  .team-layout { grid-template-columns: 1fr; }
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.section-head h1, .section-head h2 {
  font-size: 20px;
  font-weight: 800;
  color: var(--blue);
  letter-spacing: -.01em;
}

.team-stats { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.stat-chip {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 3px;
  background: var(--white);
  border: 1px solid var(--border);
  color: var(--muted);
}

.stat-chip.full { background: #D6EFE0; color: var(--green); border-color: #A8D5BC; }

.my-team, .all-riders {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 20px;
}

.my-team { position: sticky; top: 72px; max-height: calc(100vh - 100px); overflow-y: auto; }

/* ── Rider lists ─────────────────────────────────────── */
.team-group { margin-bottom: 20px; }
.team-name {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.team-count {
  font-size: 10px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 7px;
  color: var(--muted);
}

.rider-list { list-style: none; }

.rider-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 6px;
  border-radius: 3px;
  gap: 8px;
  font-size: 14px;
}

.rider-item:hover { background: var(--paper); }

.rider-name { flex: 1; }
.nat { font-size: 11px; color: var(--muted); }

.btn-add {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--white);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  color: var(--green);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .1s, border-color .1s;
}

.btn-add:hover { background: #D6EFE0; border-color: var(--green); }
.btn-add-disabled { width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; color: var(--border); font-size: 16px; flex-shrink: 0; }

.btn-remove {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: none;
  font-size: 11px;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .1s, color .1s;
}

.btn-remove:hover { background: #FCE4E0; color: var(--red); border-color: var(--red); }

.in-team { font-size: 11px; color: var(--green); font-weight: 600; flex-shrink: 0; }

/* ── Search ──────────────────────────────────────────── */
.search-input {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  background: var(--paper);
  width: 220px;
}

.search-input:focus {
  outline: none;
  border-color: var(--blue);
  background: var(--white);
}

/* ── Substitution page ───────────────────────────────── */
.sub-info {
  font-size: 14px;
  color: var(--muted);
  background: var(--paper);
  padding: 12px 16px;
  border-radius: 4px;
  margin-bottom: 20px;
  border-left: 3px solid var(--jaune);
}

/* ── Rider photo avatar ──────────────────────────────── */
.r-photo {
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
}

.r-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }

.r-photo.no-photo {
  background: linear-gradient(135deg, var(--blue) 0%, #2a527a 100%);
}
.r-photo.no-photo span {
  color: rgba(255,255,255,.75);
  font-weight: 800;
  letter-spacing: .03em;
  line-height: 1;
}

.r-photo--md { width: 64px; height: 80px; border-radius: 6px; }
.r-photo--md.no-photo span { font-size: 18px; }

.r-photo--sm { width: 36px; height: 44px; border-radius: 4px; }
.r-photo--sm.no-photo span { font-size: 11px; }

/* ── Rider type badges ───────────────────────────────── */
.r-types { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; }

.r-type {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 2px 5px;
  border-radius: 3px;
  white-space: nowrap;
}

.r-type--aanvaller  { background: #FDDDD9; color: #8B2015; }
.r-type--klassement { background: #FEF2C0; color: #7A5800; }
.r-type--tijdrit    { background: #D6E8F9; color: #1A4D7F; }
.r-type--sprinter   { background: #D5EEE1; color: #1C5234; }
.r-type--klimmer    { background: #EAD9F7; color: #5B2D80; }
.r-type--jongere    { background: #E8F4F8; color: #1A607A; }

/* ── Rider card grid ─────────────────────────────────── */
.rider-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  margin-bottom: 6px;
}

.rider-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: border-color .15s, box-shadow .15s;
}

.rider-card:hover { border-color: #b8b2a0; box-shadow: 0 2px 8px rgba(0,0,0,.06); }

.rider-card--in-team {
  border-color: #A8D5BC;
  background: #F3FBF6;
}

.r-card-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.r-card-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
  word-break: break-word;
}

.r-card-action {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.in-team-check {
  font-size: 14px;
  color: var(--green);
  font-weight: 800;
}

/* ── My team compact list ────────────────────────────── */
.my-rider-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  border-radius: 4px;
  border-bottom: 1px solid var(--border);
}

.my-rider-row:last-child { border-bottom: none; }
.my-rider-row:hover { background: var(--paper); }

.my-rider-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.my-rider-name { font-size: 13px; font-weight: 700; color: var(--ink); line-height: 1.2; }
.my-rider-team { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Riders page ─────────────────────────────────────── */
.riders-page-head { margin-bottom: 20px; }
.riders-page-head h1 { font-size: 28px; font-weight: 900; color: var(--blue); }

/* keep old selector for anything that still uses it */
.riders-page .section-head { margin-bottom: 20px; }
.riders-page .section-head h1 { font-size: 28px; font-weight: 900; color: var(--blue); }

/* ── Spelregels ──────────────────────────────────────── */
.spelregels-wrap { max-width: 720px; }
.spelregels-wrap h1 { font-size: 28px; font-weight: 900; color: var(--blue); margin-bottom: 32px; letter-spacing: -.02em; }

.rules-section { margin-bottom: 36px; }
.rules-section h2 { font-size: 17px; font-weight: 800; color: var(--blue); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 2px solid var(--jaune); display: inline-block; }
.rules-section h3 { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 8px; }

.rules-text { font-size: 15px; color: var(--ink); line-height: 1.6; margin-bottom: 12px; }

.rules-list { list-style: none; display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.rules-list li { font-size: 14px; display: flex; align-items: center; gap: 8px; }
.rules-ok { background: #D5EEE1; color: #1C5234; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 3px; }
.rules-no { background: #FDDDD9; color: #8B2015; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 3px; }

.rules-table { border-collapse: collapse; font-size: 14px; min-width: 220px; }
.rules-table th { text-align: left; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); padding: 6px 14px 6px 0; border-bottom: 2px solid var(--border); }
.rules-table td { padding: 7px 14px 7px 0; border-bottom: 1px solid var(--border); color: var(--ink); }
.rules-table--pts { min-width: 160px; }
.pts-val { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--blue); }

.jersey {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 3px;
  margin-right: 4px;
  vertical-align: middle;
}
.jersey--yellow   { background: #F7C948; color: #7A5800; }
.jersey--green    { background: #4CAF50; color: #fff; }
.jersey--mountain { background: #fff; color: #C43B28; border: 1px solid #eee; background-image: radial-gradient(circle, #C43B28 30%, transparent 30%); background-size: 8px 8px; }
.jersey--white    { background: #fff; color: #555; border: 1px solid #ddd; }

.final-pts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
@media (max-width: 560px) { .final-pts-grid { grid-template-columns: 1fr; } }

/* ── Admin ───────────────────────────────────────────── */
.admin-wrap { max-width: 960px; }
.admin-wrap h1 { font-size: 28px; font-weight: 900; color: var(--blue); margin-bottom: 24px; }

.admin-section { margin-bottom: 40px; }
.admin-section h2 { font-size: 16px; font-weight: 800; color: var(--blue); margin-bottom: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }

.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th { text-align: left; padding: 7px 10px; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); border-bottom: 2px solid var(--border); }
.admin-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }

.stage-status { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 3px; }
.stage-status.done    { background: #D6EFE0; color: var(--green); }
.stage-status.active  { background: #FFF3CC; color: #7A5800; }
.stage-status.pending { background: var(--paper); color: var(--muted); }

.stage-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

details.results-form summary { list-style: none; cursor: pointer; }
details.results-form summary::-webkit-details-marker { display: none; }

.results-inner { padding: 16px; background: var(--paper); border: 1px solid var(--border); border-radius: 4px; margin-top: 8px; }
.results-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 14px; }
.results-cols h4 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 8px; }
.results-cols label { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 6px; }
.results-cols select { flex: 1; padding: 5px 8px; border: 1px solid var(--border); border-radius: 3px; font-size: 13px; }

.final-form .final-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 640px) { .final-form .final-grid { grid-template-columns: 1fr; } }

.final-block h3 { font-size: 13px; font-weight: 800; color: var(--blue); margin-bottom: 10px; text-transform: uppercase; letter-spacing: .1em; }
.final-block label { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 6px; }
.final-block select { flex: 1; padding: 5px 8px; border: 1px solid var(--border); border-radius: 3px; font-size: 13px; }

.hint { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ── Empty state ─────────────────────────────────────── */
.empty-state { font-size: 14px; color: var(--muted); padding: 32px 0; text-align: center; }
.empty-state a { color: var(--blue); }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 480px) {
  .header-inner { padding: 0 16px; }
  .main-content { padding: 20px 16px 48px; }
  nav a { padding: 6px 6px; font-size: 12px; }
  .search-input { width: 150px; }
  .results-cols { grid-template-columns: 1fr; }
}
