:root {
  --orange: #f97316;
  --orange-dark: #ea580c;
  --blue: #0f172a;
  --green: #16a34a;
  --red: #dc2626;
  --grey: #64748b;
  --bg: #f8fafc;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 30px;
}
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: var(--blue);
  color: white;
  position: sticky;
  top: 0;
  z-index: 10;
}
header h1 { margin: 0; font-size: 1.1rem; }
.eyebrow { font-size: .7rem; opacity: .7; letter-spacing: .05em; }
.headerRight { display: flex; gap: 8px; align-items: center; }
.badge {
  font-size: .65rem;
  padding: 3px 8px;
  border-radius: 99px;
  background: var(--orange);
  color: white;
  font-weight: 700;
  letter-spacing: .05em;
}
.badge-manual { background: var(--green); }
.badge-warn { background: #eab308; }

.tabs {
  display: flex;
  background: white;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 60px;
  z-index: 9;
}
.tab {
  flex: 1;
  padding: 12px 6px;
  background: none;
  border: none;
  font-size: .9rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
}
.tab.active {
  color: var(--orange);
  border-bottom-color: var(--orange);
}
.tabContent { display: none; padding: 12px; }
.tabContent.active { display: block; }

.card {
  background: var(--card);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.card h3 { margin: 0 0 10px; font-size: 1rem; }
.card h4 { margin: 0; font-size: .9rem; }

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: .85rem; }

button {
  cursor: pointer;
  font-family: inherit;
  font-size: .9rem;
}
.btn-primary {
  background: var(--orange);
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 600;
}
.btn-primary:active { background: var(--orange-dark); }
.btn-secondary {
  background: var(--blue);
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 600;
}
.ghost {
  background: none;
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 8px;
  color: var(--text);
}
.full { width: 100%; display: block; }

.runnerBig {
  border-radius: 14px;
  padding: 18px 16px;
  margin-bottom: 10px;
  text-align: center;
  color: white;
}
.runnerBig .lbl { font-size: .7rem; letter-spacing: .1em; opacity: .9; }
.runnerBig .name { font-size: 1.6rem; font-weight: 800; margin: 6px 0; }
.runnerBig .sub { font-size: .85rem; opacity: .9; }
.runnerBig-current { background: linear-gradient(135deg, var(--orange), var(--orange-dark)); }
.runnerBig-next { background: linear-gradient(135deg, #2563eb, #1e40af); }

.runnerRow {
  display: flex;
  align-items: center;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}
.runnerRow:last-child { border-bottom: none; }
.runnerRow.current { background: #fff7ed; border-radius: 6px; }
.runnerRow.next { background: #eff6ff; border-radius: 6px; }
.runnerRow.skipped { opacity: .5; text-decoration: line-through; }
.pos {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--blue);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 700;
}
.runnerRow.current .pos { background: var(--orange); }
.runnerRow .name { flex: 1; font-weight: 600; }
.runnerRow .actions { display: flex; gap: 4px; }
.runnerRow button { font-size: .75rem; padding: 4px 8px; }

.team-staff-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
  background: var(--bg);
}
.team-staff-card.finished { opacity: .6; }
.team-staff-card .topline {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.team-staff-card .team-name { font-weight: 700; font-size: 1rem; }
.team-staff-card .team-bib { color: var(--muted); font-size: .8rem; }
.team-staff-card .runner-info {
  display: flex;
  justify-content: space-between;
  font-size: .85rem;
  margin: 6px 0;
}
.team-staff-card .runner-info .current { font-weight: 700; color: var(--orange); }
.team-staff-card .runner-info .next { color: var(--muted); }
.team-staff-card .lap-counter {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--blue);
  margin: 8px 0;
}
.team-staff-card .lap-counter span { font-size: .9rem; color: var(--muted); font-weight: 500; }
.team-staff-card .actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}
.team-staff-card .btn-tour {
  background: var(--green);
  color: white;
  border: none;
  padding: 16px 8px;
  border-radius: 8px;
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: .03em;
}
.team-staff-card .btn-tour:active { background: #15803d; transform: scale(0.97); }
.team-staff-card .btn-tour:disabled { background: #94a3b8; }
.team-staff-card .btn-tour-change {
  background: #2563eb;
  color: white;
  border: none;
  padding: 16px 8px;
  border-radius: 8px;
  font-weight: 800;
  font-size: .95rem;
  letter-spacing: .02em;
}
.team-staff-card .btn-tour-change:active { background: #1e40af; transform: scale(0.97); }
.team-staff-card .btn-tour-change:disabled { background: #94a3b8; }
.team-staff-card .btn-notify {
  background: #f59e0b;
  color: white;
  border: none;
  padding: 12px 6px;
  border-radius: 8px;
  font-size: .85rem;
  font-weight: 700;
}
.team-staff-card .btn-notify:active { background: #d97706; transform: scale(0.97); }
.team-staff-card .btn-notify:disabled { background: #94a3b8; }
.team-staff-card .btn-cancel {
  background: #fef2f2;
  color: var(--red);
  border: 1px solid #fecaca;
  padding: 12px 6px;
  border-radius: 8px;
  font-size: .85rem;
  font-weight: 700;
}
.team-staff-card .btn-skip {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
  padding: 12px 6px;
  border-radius: 8px;
  font-size: .85rem;
  font-weight: 700;
}

.rank-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
}
.rank-row:last-child { border-bottom: none; }
.rank-row .rank-pos { font-weight: 700; width: 30px; color: var(--orange); }
.rank-row .rank-name { flex: 1; }
.rank-row .rank-laps { font-weight: 700; }

.searchResult {
  background: var(--bg);
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}
.searchResult:active { background: #e2e8f0; }
.searchResult .rbib { color: var(--muted); font-size: .75rem; }

.savedTeam {
  background: var(--bg);
  padding: 9px 12px;
  border-radius: 8px;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}
.savedTeam:active { background: #e2e8f0; }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: var(--blue);
  color: white;
  padding: 12px 20px;
  border-radius: 99px;
  font-size: .9rem;
  z-index: 1000;
  transition: transform .3s;
  max-width: 90%;
  text-align: center;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }

.updateBanner, .offlineBanner {
  background: var(--orange);
  color: white;
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .85rem;
}
.offlineBanner { background: var(--grey); }
.updateBanner button {
  background: white;
  color: var(--orange);
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-weight: 700;
}

.timer-big {
  text-align: center;
  font-size: 2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--blue);
}
.timer-big .lbl { display:block; font-size: .7rem; font-weight: 500; color: var(--muted); letter-spacing: .1em; }

/* ── Chat d'équipe ── */
.chat-fab {
  position: fixed;
  bottom: 18px;
  right: 18px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #2563eb;
  color: white;
  border: none;
  font-size: 1.6rem;
  box-shadow: 0 4px 14px rgba(37, 99, 235, .4);
  z-index: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-fab:active { background: #1e40af; transform: scale(0.95); }
.chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--red);
  color: white;
  font-size: .7rem;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 99px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

.chat-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  z-index: 600;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, .2);
  max-height: 75vh;
  display: flex;
  flex-direction: column;
}
.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: #2563eb;
  color: white;
  border-radius: 16px 16px 0 0;
}
.chat-header .muted { color: rgba(255,255,255,.7); }
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  background: #f8fafc;
  min-height: 200px;
  max-height: 50vh;
}
.chat-msg {
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  max-width: 80%;
}
.chat-msg.mine { align-self: flex-end; align-items: flex-end; margin-left: 20%; }
.chat-msg.theirs { align-self: flex-start; margin-right: 20%; }
.chat-msg .meta {
  font-size: .7rem;
  color: var(--muted);
  margin-bottom: 2px;
  padding: 0 4px;
}
.chat-msg .bubble {
  background: white;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: .9rem;
  word-wrap: break-word;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.chat-msg.mine .bubble {
  background: #2563eb;
  color: white;
}
.chat-msg.staff-target .bubble {
  border: 2px solid var(--orange);
}
.chat-msg.from-staff .bubble {
  background: #1e40af;
  color: white;
  border: 2px solid #facc15;
}
.chat-msg.from-staff .meta {
  color: #1e40af;
  font-weight: 700;
}
.chat-quick {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 6px;
  background: white;
  border-top: 1px solid var(--border);
}
.chat-quick-btn {
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 4px;
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
}
.chat-quick-btn:active { background: #e2e8f0; }
.chat-quick-staff {
  background: #fef2f2;
  border-color: #fecaca;
  color: var(--red);
}
.chat-input-row {
  display: flex;
  gap: 6px;
  padding: 8px;
  background: white;
  border-top: 1px solid var(--border);
}
.chat-input-row input {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: .9rem;
  outline: none;
}
.chat-input-row input:focus { border-color: #2563eb; }
.chat-input-row button {
  padding: 9px 16px;
  border-radius: 20px;
  font-size: 1.1rem;
}
