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

:root {
  --bg:        #0d0f1a;
  --surface:   #181b2e;
  --surface2:  #1f2340;
  --border:    #2a2f52;
  --accent:    #f59e0b;
  --accent-lo: rgba(245,158,11,.12);
  --green:     #4ade80;
  --green-lo:  rgba(74,222,128,.12);
  --red:       #f87171;
  --red-lo:    rgba(248,113,113,.12);
  --text:      #e2e8f0;
  --muted:     #64748b;
  --muted2:    #94a3b8;
  --radius:    10px;
  --radius-sm: 6px;
}

@media (prefers-color-scheme: light) { :root:not([data-theme]) {
  --bg:        #f1f5f9;
  --surface:   #ffffff;
  --surface2:  #f8fafc;
  --border:    #e2e8f0;
  --text:      #0f172a;
  --muted:     #94a3b8;
  --muted2:    #64748b;
}}
:root[data-theme="light"] {
  --bg:        #f1f5f9;
  --surface:   #ffffff;
  --surface2:  #f8fafc;
  --border:    #e2e8f0;
  --text:      #0f172a;
  --muted:     #94a3b8;
  --muted2:    #64748b;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  font-size: 15px;
  line-height: 1.5;
}

/* ── HEADER ────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 100;
}
.app-header h1 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.3px;
  flex: 1;
}
.back-btn {
  display: none;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}
.back-btn.visible { display: flex; align-items: center; }

/* ── VIEWS ─────────────────────────────────── */
.view { display: none; padding: 20px; max-width: 1200px; margin: 0 auto; }
.view.active { display: block; }

/* ── RACE LIST ─────────────────────────────── */
.race-grid {
  display: grid;
  gap: 12px;
  margin-top: 4px;
}

.race-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  display: flex;
  align-items: center;
  gap: 16px;
}
.race-card:hover { border-color: var(--accent); background: var(--surface2); }
.race-card.active-race { border-color: var(--green); }
.active-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  color: var(--green);
  background: var(--green-lo);
  border: 1px solid var(--green);
  border-radius: 20px;
  padding: 2px 8px;
  margin-left: 8px;
  vertical-align: middle;
}
.race-card-icon {
  font-size: 28px;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-lo);
  border-radius: var(--radius-sm);
}
.race-card-info { flex: 1; min-width: 0; }
.race-card-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.race-card-meta {
  font-size: 12px;
  color: var(--muted2);
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}
.race-card-stats {
  display: flex;
  gap: 16px;
  margin-top: 8px;
}
.race-card-stat {
  font-size: 12px;
  color: var(--muted2);
}
.race-card-stat strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.race-card-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.btn-icon {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted2);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}
.btn-icon:hover { color: var(--red); border-color: var(--red); background: var(--red-lo); }
.btn-icon.edit:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-lo); }

.fab {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 28px;
  background: var(--accent);
  color: #000;
  border: none;
  font-size: 26px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(245,158,11,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .15s, box-shadow .15s;
  z-index: 200;
}
.fab:hover { transform: scale(1.07); box-shadow: 0 6px 28px rgba(245,158,11,.5); }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.empty-state .emoji { font-size: 48px; display: block; margin-bottom: 16px; }
.empty-state p { font-size: 15px; }

/* ── EDITOR ─────────────────────────────────── */
.editor-meta {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.editor-meta h2 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
}
.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.meta-grid.full { grid-template-columns: 1fr; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; color: var(--muted2); font-weight: 500; }
.field input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  padding: 8px 11px;
  font-family: inherit;
  transition: border-color .15s;
  width: 100%;
}
/* textarea et select suivent le même style que les champs texte */
.field textarea, .field select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  padding: 8px 11px;
  font-family: inherit;
  transition: border-color .15s;
  width: 100%;
  resize: vertical;
}
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--accent); }
.field-hint { font-size: 11.5px; color: var(--muted); line-height: 1.35; }

/* Interrupteur de module (ex. nutrition) */
.module-toggle {
  display: flex; align-items: center; gap: 12px;
  margin-top: 14px; padding: 12px 14px;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 10px;
}
.module-toggle-text { display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
.module-toggle-text b { font-size: 13px; color: var(--text); }
.module-toggle-text span { color: var(--muted); line-height: 1.35; }
.switch { position: relative; flex-shrink: 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
/* Bascule sobre : plus petite que la précédente (46×26 avec un blanc pur, qui
   écrasait le libellé à 13px), et accompagnée d'un ON/OFF en texte — même
   grammaire que les interrupteurs de l'onglet Simulation des apps de suivi. */
.switch-track {
  display: block; width: 38px; height: 22px; border-radius: 11px;
  background: var(--border); transition: background .18s;
}
.switch-knob {
  display: block; width: 16px; height: 16px; margin: 3px; border-radius: 50%;
  background: rgba(255,255,255,.82); transition: transform .18s, background .18s;
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track .switch-knob { transform: translateX(16px); background: #fff; }
.switch-state {
  font-size: 10px; font-weight: 800; letter-spacing: .06em;
  color: var(--muted); min-width: 26px; flex-shrink: 0;
  font-family: inherit; transition: color .18s;
}
.switch-state.on { color: var(--accent); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.strat-hint { font-size: 12px; color: var(--muted); line-height: 1.4; margin: 0 0 10px; }
.gph-cell { font-weight: 700; font-size: 13px; color: var(--muted2); }
.gph-cell.gph-ok { color: #36c98a; }
.gph-cell.gph-off { color: var(--accent); }
.gph-cell.gph-bad { color: #ff4d4f; animation: gphBlink 1s steps(1,end) infinite; }
@keyframes gphBlink { 50% { opacity: 0.15; } }
/* Ligne repère « point de ravito » dans le tableau nutrition */
.rv-cp-row td {
  background: var(--accent-lo);
  border-top: 1px solid var(--accent);
  border-bottom: 1px solid var(--accent) !important;
  padding: 5px 10px !important;
  white-space: nowrap;
}
.rv-cp-icon { font-size: 13px; margin-right: 6px; }
.rv-cp-name { font-size: 11.5px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .05em; }
.rv-cp-km   { font-size: 11px; color: var(--muted2); margin-left: 8px; }
.rv-cp-time { font-size: 11px; font-weight: 600; color: var(--muted2); margin-left: 8px; }
/* Départ et arrivée : repères neutres, sans réglage de section pour l'arrivée */
.rv-cp-row.is-start td, .rv-cp-row.is-finish td {
  background: var(--surface2, rgba(255,255,255,.04));
  border-color: var(--border) !important;
}
.rv-cp-row.is-start .rv-cp-name, .rv-cp-row.is-finish .rv-cp-name { color: var(--text); }
/* Fin de section : boisson seule, pas de solide possible */
.rv-gap-row td { background: rgba(255,255,255,.02); }
.rv-gap-row .rv-elapsed-label { color: var(--muted2); }
.gap-note { font-size: 11px; font-style: italic; color: var(--muted2); white-space: nowrap; }
/* Cellule de totaux d'une ligne de repère : libellé + hydratation ml/h */
.tot-cell { text-align: right; white-space: nowrap; }
.tot-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted2); margin-right: 10px;
}
.tot-ml { font-size: 13px; font-weight: 700; color: var(--muted2); }
.tot-ml.gph-ok  { color: #36c98a; }
.tot-ml.gph-off { color: var(--accent); }
.tot-ml.gph-bad { color: #ff4d4f; animation: gphBlink 1s steps(1,end) infinite; }
/* 2e ligne d'un repère : les réglages */
.rv-cp-row.rv-cp-set td { border-top: none !important; padding-top: 0 !important; }
.sect-set-label {
  text-align: right; font-size: 10px; font-style: italic;
  color: var(--muted2); opacity: .8;
}
/* Réglages de section, affichés en lecture sur chaque ravito */
.rate-label  { font-size: 12px; font-weight: 600; color: var(--muted2); }
.drink-label {
  font-size: 12px; color: var(--muted2);
  display: inline-block; max-width: 160px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: middle;
}
.rv-cp-row .sect-gph, .rv-cp-row .sect-mark { font-size: 13px; }
.gph-mark { font-size: 14px; font-weight: 700; color: var(--muted2); }
.gph-mark.gph-ok  { color: #36c98a; }
.gph-mark.gph-off { color: var(--accent); }
.gph-mark.gph-bad { color: #ff4d4f; animation: gphBlink 1s steps(1,end) infinite; }
input.code-input { text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
input.code-input:disabled { opacity: .65; cursor: not-allowed; }
/* Encart identifiant de course (section « Course en direct ») */
.code-box { display: flex; align-items: center; gap: 10px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 12px; }
.code-box .code-val { font-size: 18px; font-weight: 700; letter-spacing: .08em; color: var(--text); flex: 1; word-break: break-all; font-family: inherit; }
.code-box .code-val.none { font-size: 13px; font-weight: 500; letter-spacing: normal; color: var(--muted); }
.code-box .code-label { font-size: 11px; color: var(--muted2); text-transform: uppercase; letter-spacing: .05em; }
.race-code-chip { display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .05em; color: var(--muted2); background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 1px 7px; }

/* ── Onglets principaux + Fiches produits ───────────────────── */
.main-tabs { display: flex; gap: 6px; padding: 12px 16px 0; max-width: 900px; margin: 0 auto; width: 100%; }
.main-tab { flex: 1; padding: 10px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--muted2); font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit; transition: all .15s; }
.main-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
#viewProducts { max-width: 900px; margin: 0 auto; width: 100%; padding: 16px; }
.prod-toolbar { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.prod-search { width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-size: 14px; padding: 10px 12px; font-family: inherit; }
.prod-filter-row { display: flex; gap: 8px; flex-wrap: wrap; }
.prod-filter-row select { flex: 1; min-width: 120px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-size: 13px; padding: 8px 10px; font-family: inherit; }
.prod-fav-toggle { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--muted2); font-size: 16px; padding: 8px 12px; cursor: pointer; }
.prod-fav-toggle.on { background: rgba(255,193,7,.15); border-color: #ffc107; color: #ffc107; }
.prod-count { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.prod-grid { display: flex; flex-direction: column; gap: 8px; }
.prod-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: flex; gap: 12px; align-items: flex-start; }
.prod-card .pc-photo { position: relative; width: 46px; height: 46px; border-radius: 8px; background: #0b0b0d; flex-shrink: 0; border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.prod-card .pc-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.prod-card .pc-main { flex: 1; min-width: 0; }
.pc-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pc-name { font-weight: 700; font-size: 14px; }
.pc-brand { font-size: 12px; color: var(--muted2); }
.pc-type { font-size: 10px; font-weight: 700; color: var(--accent); background: rgba(255,122,24,.12); border-radius: 20px; padding: 2px 8px; white-space: nowrap; }
/* Même étiquette verte que dans admin */
.pc-cert {
  font-size: 10px; font-weight: 700; color: var(--green);
  background: var(--green-lo); border-radius: 20px; padding: 2px 8px;
  white-space: nowrap;
}
.pc-nutri { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 6px; font-size: 11.5px; color: var(--muted2); }
.pc-nutri b { color: var(--text); font-weight: 600; }
.pc-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; flex-shrink: 0; }
.pc-fav { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--muted); line-height: 1; }
.pc-fav.on { color: #ffc107; }
.pc-edit { background: none; border: none; font-size: 15px; cursor: pointer; opacity: .7; }
/* Mes demandes de correction, en tête de la page produits */
.msg-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted2); margin-bottom: 6px; }
.msg {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 12px; margin-bottom: 6px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--border); font-size: 12.5px;
}
.msg-flag { font-size: 11px; font-weight: 700; white-space: nowrap; }
.msg.attente { border-color: var(--accent); }
.msg.attente .msg-flag { color: var(--accent); }
.msg.ok  { border-color: var(--green); }
.msg.ok  .msg-flag { color: var(--green); }
.msg.ko  { border-color: var(--red); }
.msg.ko  .msg-flag { color: var(--red); }
.msg-nom { font-weight: 600; color: var(--text); }
.msg-champs { color: var(--muted); }
.msg-x { margin-left: auto; background: none; border: none; color: var(--muted); font-size: 14px; cursor: pointer; padding: 0 2px; }
.msg-x:hover { color: var(--red); }
/* Proposer une correction sur une fiche certifiée (non modifiable directement) */
.pc-suggest {
  background: none; border: none; cursor: pointer; padding: 0;
  font-size: 15px; line-height: 1; color: var(--muted); opacity: .75;
}
.pc-suggest:hover { color: var(--accent); opacity: 1; }
.pc-certif {
  background: none; border: none; cursor: pointer; padding: 0;
  font-size: 14px; line-height: 1; opacity: .55; filter: grayscale(1);
}
.pc-certif:hover { opacity: 1; filter: none; }
.cf-source { font-size: 12px; color: var(--muted); word-break: break-all; }
/* Fiche « proposer une correction » : valeur actuelle → valeur proposée */
.sg-intro { font-size: 12.5px; color: var(--muted); line-height: 1.4; margin-bottom: 12px; }
.sg-product { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.sg-grid { display: flex; flex-direction: column; gap: 8px; }
.sg-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.sg-head { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted2); }
.sg-label { font-size: 12px; color: var(--muted2); }
.sg-now { font-size: 13px; color: var(--muted); padding: 8px 10px; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-arrow { color: var(--muted2); font-size: 13px; }
/* Les champs de proposition doivent se voir comme des champs de saisie */
.sg-row input, .sg-row select {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 13px; padding: 8px 10px;
  font-family: inherit;
}
.sg-row input:focus, .sg-row select:focus { outline: none; border-color: var(--accent); }
.sg-row.changed .sg-now { opacity: .5; }
.sg-row.changed input, .sg-row.changed select { border-color: var(--accent); }
.sg-count { font-size: 12px; color: var(--accent); font-weight: 600; margin-top: 10px; }
.prod-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0; }
.prod-form-grid .field.full { grid-column: 1 / -1; }
.prod-form-error { font-size: 13px; color: #ef5868; min-height: 16px; }
/* Boutons des dialogues : ils n'avaient aucun style, d'où des boutons navigateur bruts. */
.dialog-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.dialog-actions button {
  padding: 9px 20px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600;
  cursor: pointer; border: 1px solid transparent; font-family: inherit; transition: all .15s;
}
.dialog-actions .primary { background: var(--accent); color: #000; border-color: var(--accent); }
.dialog-actions .primary:hover { filter: brightness(1.1); }
.dialog-actions .secondary { background: none; color: var(--muted2); border-color: var(--border); }
.dialog-actions .secondary:hover { border-color: var(--muted2); color: var(--text); }
.dialog-actions .link-clear {
  margin-right: auto; padding: 9px 0; background: none; border: none;
  color: var(--red); font-size: 13px; font-weight: 500; text-decoration: underline;
}
/* --card n'existe pas dans ce thème : c'est --surface (le dialogue était transparent). */
#productDialog, #suggestDialog, #certifDialog { border: none; border-radius: 16px; background: var(--surface); color: var(--text); padding: 22px; width: 92%; max-width: 460px; box-shadow: 0 16px 48px rgba(0,0,0,.5); }
#productDialog::backdrop, #suggestDialog::backdrop, #certifDialog::backdrop { background: rgba(0,0,0,.55); }
#productDialog h2, #suggestDialog h2, #certifDialog h2 { font-size: 17px; font-weight: 800; }
#suggestDialog { max-width: 560px; max-height: 88vh; overflow-y: auto; }

/* ── PANELS (pleine largeur, empilés) ───────── */
.editor-panels {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.panel-header h3 {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted2);
}
.panel-count {
  font-size: 12px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 8px;
  font-variant-numeric: tabular-nums;
}

/* ── TABLE ───────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  padding: 9px 10px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }
tbody td { padding: 6px 10px; vertical-align: middle; }

.cell-input {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--text);
  font-size: 13px;
  padding: 5px 7px;
  font-family: inherit;
  width: 100%;
  transition: border-color .12s, background .12s;
}
.cell-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg);
}
.cell-input.time {
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, monospace;
  /* Le sélecteur d'heure natif réserve la place de son icône d'horloge :
     à 80px le dernier chiffre passait dessous. */
  width: 96px;
}
.cell-input.km { width: 60px; font-variant-numeric: tabular-nums; }
.cell-input.wide { width: 140px; }
/* Tableau des coureurs : les colonnes d'effort ajoutées en 0.71 avaient réduit
   la colonne Nom à trois caractères. On leur donne une largeur fixe et étroite,
   et le nom garde de quoi être lu. */
#runBody td:nth-child(2), thead th:nth-child(2) { min-width: 130px; }
#runBody .cell-input.effort { width: 62px; text-align: center; font-variant-numeric: tabular-nums; }
/* Un D+ de segment atteint quatre chiffres en montagne (2294 m) : 60px coupait.
   Le cumulé en atteint cinq sur un ultra (10 000 m et plus). */
#cpBody input[data-dplus] { width: 74px; }
#cpBody input[data-dpluscum] { width: 82px; }
.cell-input.jour { width: 58px; padding: 5px 4px; font-size: 12px; }
.cell-check {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
  cursor: pointer;
  vertical-align: middle;
}

/* ── ICON PICKER ─────────────────────────────── */
/* Assez large pour une icône double (base de vie avec assistance, ravito),
   et nowrap : sans ça la paire se coupait sur deux lignes dans le bouton. */
.icon-btn {
  font-size: 17px;
  width: 56px;
  height: 32px;
  white-space: nowrap;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .12s;
  position: relative;
}
.icon-btn:hover { border-color: var(--accent); }
.icon-picker-wrap { position: relative; display: inline-block; }
.icon-popup {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  display: none;
  z-index: 400;
  padding: 6px;
}
.icon-popup.open { display: block; }
/* Une colonne, libellée : le dessin seul ne dit pas ce que le point déclenche
   (recharge du plan de nutrition, notification à l'équipe). Le nom, si. */
.icon-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px;
  min-width: 230px;
}
.icon-opt {
  height: 34px;
  font-size: 18px;
  background: none;
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 9px;
  text-align: left;
  transition: background .1s, border-color .1s;
}
/* Largeur fixe : les icônes doubles (base de vie avec assistance) ne doivent
   pas décaler les libellés des autres lignes. */
.icon-opt-glyphe { flex: 0 0 44px; white-space: nowrap; }
.icon-opt-nom { font-size: 13px; color: var(--text); font-weight: 500; }
.icon-opt:hover { background: var(--accent-lo); border-color: var(--accent); }
.icon-opt.selected { background: var(--accent-lo); border-color: var(--accent); }

/* ── INTERVAL BAR ───────────────────────────── */
.rv-interval-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--accent-lo);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted2);
  font-weight: 500;
}
.rv-interval-input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
}
.rv-interval-input-wrap input {
  width: 48px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-size: 13px;
  padding: 4px 7px;
  font-family: ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.rv-interval-input-wrap input:focus { outline: none; border-color: var(--accent); }
.rv-runner-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 16px 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex-wrap: wrap;
}
.rv-runner-tabs::-webkit-scrollbar { display: none; }
.rv-runner-tab {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text2);
  white-space: nowrap;
  transition: border-color .15s, background .15s;
}
.rv-runner-tab.active {
  border-color: var(--accent);
  background: rgba(255,122,24,.12);
  color: var(--accent);
}
.rv-time-label {
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  color: var(--muted2);
  white-space: nowrap;
}

/* ── OPT / PESS times ──────────────────────────── */
.time-opt {
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  color: var(--green);
  font-weight: 700;
  white-space: nowrap;
}
.time-pess {
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  color: var(--red);
  font-weight: 700;
  white-space: nowrap;
}
.th-group {
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 6px 8px 4px;
  border-bottom: none !important;
}
.th-opt-group  { color: var(--green); background: var(--green-lo); }
.th-pess-group { color: var(--red);   background: var(--red-lo); }
.th-sub { font-size: 10px; padding-top: 4px; }
.th-sub-opt  { color: var(--green); }
.th-sub-pess { color: var(--red); }
.cell-input.dur { width: 92px; }
.cell-input.allure { width: 72px; text-align: center; font-variant-numeric: tabular-nums; }
/* Sous l'allure saisie (par km-effort), celle que montrera la montre. */
.allure-plat {
  font-size: 10px;
  color: var(--muted2);
  text-align: center;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  margin-top: 3px;
}
.cell-input.arret { width: 64px; text-align: center; font-variant-numeric: tabular-nums; }
/* Durée encore calée sur la barrière : elle bougera si la barrière ou l'arrêt
   change. Une saisie manuelle la fige, et l'italique disparaît. */
.cell-input.calee { font-style: italic; color: var(--muted2); }

/* ── BARRIÈRES ───────────────────────────────── */
.barriere {
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
}
.barriere-ok { color: var(--green); background: var(--green-lo); }
.barriere-ko { color: var(--red);   background: var(--red-lo); animation: barriere-clignote 1s steps(1, end) infinite; }
.barriere-vide { color: var(--muted2); font-size: 12px; }
.barriere-jour { font-size: 10px; font-weight: 700; opacity: .75; margin-left: 3px; }
@keyframes barriere-clignote {
  50% { color: var(--surface); background: var(--red); }
}
/* Un clignotement permanent est pénible, voire risqué, pour qui y est
   sensible : on garde alors le rouge plein, sans animation. */
@media (prefers-reduced-motion: reduce) {
  .barriere-ko { animation: none; color: var(--surface); background: var(--red); }
}
thead tr.th-row-sub th {
  padding: 3px 8px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.rv-elapsed-label {
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}

/* ── ROW MOVE ────────────────────────────────── */
.row-move {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  padding: 3px 5px;
  border-radius: 4px;
  transition: color .12s, background .12s;
  line-height: 1;
}
.row-move:hover { color: var(--accent); background: var(--accent-lo); }
.row-move:disabled { opacity: .25; cursor: default; }
.row-actions { display: flex; align-items: center; gap: 2px; }

.row-del {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  padding: 4px 6px;
  border-radius: 4px;
  transition: color .12s, background .12s;
  line-height: 1;
}
.row-del:hover { color: var(--red); background: var(--red-lo); }

.add-row-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 11px 16px;
  background: none;
  border: none;
  border-top: 1px solid var(--border);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s;
  font-family: inherit;
}
.add-row-btn:hover { background: var(--accent-lo); }

/* ── SAVE BAR ────────────────────────────────── */
.save-bar {
  position: sticky;
  bottom: 0;
  left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  z-index: 50;
  padding-bottom: calc(14px + env(safe-area-inset-bottom));
}
/* ── MATÉRIEL ────────────────────────────────── */
.mat-titre {
  font-size: 13px;
  font-weight: 700;
  margin: 18px 0 8px;
  color: var(--text);
}
#materielBody .table-wrap { margin-bottom: 4px; }

/* Repoussé à gauche : l'état de l'enregistrement automatique se lit sans
   quitter des yeux les boutons. */
.autosave-etat {
  margin-right: auto;
  font-size: 12px;
  color: var(--muted2);
  white-space: nowrap;
}
.autosave-etat.echec { color: var(--red); font-weight: 600; }
#autosaveBtn.actif { color: var(--green); border-color: var(--green); background: var(--green-lo); }
.btn-mini { padding: 4px 10px; font-size: 12px; margin-left: auto; }
.btn {
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  font-family: inherit;
  transition: all .15s;
}
.btn-primary {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-secondary {
  background: none;
  color: var(--muted2);
  border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--muted2); color: var(--text); }

/* ── TOAST ───────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--green);
  color: #000;
  font-size: 13px;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: 100px;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  pointer-events: none;
  white-space: nowrap;
  z-index: 999;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── MODAL ───────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  width: 100%;
  max-width: 440px;
}
.modal h2 { font-size: 17px; font-weight: 700; margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ── CONFIRM ─────────────────────────────────── */
.confirm-modal { max-width: 360px; }
.confirm-modal p { color: var(--muted2); font-size: 14px; line-height: 1.5; }
.btn-danger {
  background: var(--red-lo);
  color: var(--red);
  border-color: var(--red);
}
.btn-danger:hover { background: var(--red); color: #fff; }

/* ── PARTAGER ───────────────────────────────── */
.share-section {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.share-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}
.share-list { display: flex; flex-direction: column; gap: 10px; }
.share-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.share-icon { font-size: 22px; flex-shrink: 0; }
.share-info { flex: 1; min-width: 0; }
.share-name { font-weight: 700; font-size: 14px; }
.share-url {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-copy {
  flex-shrink: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted2);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
  min-width: 80px;
  text-align: center;
}
.btn-copy:hover { border-color: var(--accent); color: var(--accent); }
.btn-copy.copied { background: var(--green-lo); border-color: var(--green); color: var(--green); }

/* ── AUTH WALL ──────────────────────────────── */
.auth-wall { position:fixed; inset:0; background:var(--bg); z-index:2000; display:flex; align-items:center; justify-content:center; padding:20px; }
.auth-wall.hidden { display:none; }
.auth-card { width:100%; max-width:360px; background:var(--surface); border:1px solid var(--border); border-radius:16px; padding:32px 28px; text-align:center; }
.auth-logo { font-size:48px; margin-bottom:14px; }
.auth-card h2 { font-size:21px; font-weight:800; margin-bottom:4px; }
.auth-sub { font-size:13px; color:var(--muted); margin-bottom:26px; }
.auth-field { margin-bottom:13px; text-align:left; }
.auth-field label { display:block; font-size:12px; color:var(--muted); font-weight:600; margin-bottom:6px; letter-spacing:.03em; }
.auth-field input { width:100%; background:var(--bg); border:1px solid var(--border); border-radius:10px; color:var(--text); font-size:15px; padding:11px 14px; font-family:inherit; transition:border-color .15s; }
.auth-field input:focus { outline:none; border-color:var(--accent); }
.auth-submit { width:100%; margin-top:6px; padding:13px; background:var(--accent); color:#1b1b1f; border:none; border-radius:10px; font-size:15px; font-weight:700; cursor:pointer; font-family:inherit; }
.auth-error { font-size:13px; color:var(--red); margin-top:11px; min-height:18px; }
.user-chip-header { font-size:11px; color:var(--muted); margin-top:2px; display:flex; align-items:center; gap:6px; }
.logout-link { background:none; border:none; color:var(--muted); font-size:11px; cursor:pointer; padding:0; font-family:inherit; text-decoration:underline; }
.auth-version { display:inline-block; font-size:10px; letter-spacing:.05em; color:var(--muted); background:rgba(255,255,255,0.06); border:1px solid rgba(255,255,255,0.12); border-radius:100px; padding:2px 10px; margin-bottom:16px; cursor:pointer; font-family:inherit; transition:background .15s, border-color .15s; }
.auth-version:hover { background:rgba(255,255,255,.12); border-color:rgba(255,255,255,.3); }
#changelogDialog { border:none; border-radius:18px; background:var(--card); color:var(--text); padding:0; width:88%; max-width:340px; box-shadow:0 16px 48px rgba(0,0,0,.5); }
#changelogDialog::backdrop { background:rgba(0,0,0,.55); }
.changelog-content { padding:24px 20px 20px; }
.changelog-title { font-size:17px; font-weight:800; margin-bottom:16px; }
.changelog-list { list-style:none; padding:0; margin:0 0 20px; display:flex; flex-direction:column; gap:10px; }
.changelog-list li { font-size:13px; display:flex; gap:10px; align-items:baseline; }
.changelog-badge { font-size:10px; font-weight:700; color:var(--accent); background:rgba(255,122,24,.12); border-radius:20px; padding:2px 8px; white-space:nowrap; flex-shrink:0; }
.changelog-close { width:100%; padding:12px; background:var(--card); border:1px solid var(--border); border-radius:10px; color:var(--text); font-size:14px; font-weight:600; cursor:pointer; font-family:inherit; }
.auth-switch { background:none; border:none; color:var(--muted); font-size:13px; cursor:pointer; margin-top:14px; display:block; width:100%; font-family:inherit; text-align:center; padding:0; text-decoration:underline; }

/* iPhone : empêche le zoom auto de Safari sur les champs (police < 16px) */
@media (max-width: 640px) {
  input, textarea, select { font-size: 16px !important; }
}
.btn-version { opacity: .7; font-variant-numeric: tabular-nums; }
.btn-version:hover { opacity: 1; }
/* Les contenances vont jusqu'à 4 chiffres (1500 ml) : la largeur des cellules
   kilomètres les rognait à l'écran alors que la valeur était juste. */
.cell-input.ml { width: 80px; }
