:root {
  color-scheme: light;
  --fond: #f4f4f2;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --texte: #0b0b0b;
  --texte-2: #52514e;
  --texte-3: #7a7974;
  --bord: #e2e1dc;
  --grille: #ecebe7;
  --accent: #2a78d6;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --ok: #0ca30c; --attention: #fab219; --grave: #ec835a; --critique: #d03b3b;
  --ok-texte: #006300; --critique-texte: #b42323; --grave-texte: #a8480f;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --fond: #121211;
    --surface: #1a1a19;
    --surface-2: #232321;
    --texte: #f0efec;
    --texte-2: #c3c2b7;
    --texte-3: #8f8e86;
    --bord: #33332f;
    --grille: #2a2a27;
    --accent: #3987e5;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --ok-texte: #4cc94c; --critique-texte: #f07a7a; --grave-texte: #f0a07c;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --fond: #121211; --surface: #1a1a19; --surface-2: #232321; --texte: #f0efec; --texte-2: #c3c2b7;
  --texte-3: #8f8e86; --bord: #33332f; --grille: #2a2a27; --accent: #3987e5;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --ok-texte: #4cc94c; --critique-texte: #f07a7a; --grave-texte: #f0a07c;
}

* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--fond); color: var(--texte); }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; }
.muted { color: var(--texte-2); }
.petit { font-size: .85rem; }
.num { font-variant-numeric: tabular-nums; }

/* En-tête */
.entete { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--bord); position: sticky; top: 0; z-index: 10; }
.entete h1 { font-size: 1.1rem; }
.entete nav { display: flex; gap: 4px; margin-right: auto; }
.entete nav a { padding: 6px 12px; border-radius: 6px; text-decoration: none; color: var(--texte-2); }
.entete nav a[aria-current="page"] { background: var(--surface-2); color: var(--texte); font-weight: 600; }
.lab211-auth-btn { font: inherit; }

main { max-width: 1280px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
.carte { background: var(--surface); border: 1px solid var(--bord); border-radius: 10px; padding: 16px; min-width: 0; }
.carte > h2 { margin-bottom: 12px; }
.carte-tete { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.grille-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 16px; }

/* Contrôles */
input, select, button, textarea { font: inherit; color: inherit; }
input[type="text"], input[type="number"], input[type="date"], select {
  padding: 6px 10px; border: 1px solid var(--bord); border-radius: 6px; background: var(--surface); min-width: 0;
}
button { padding: 6px 14px; border-radius: 6px; border: 1px solid var(--bord); background: var(--surface); cursor: pointer; }
button:hover { background: var(--surface-2); }
button.primaire { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primaire:hover { filter: brightness(1.08); }
button.danger { color: var(--critique-texte); }
button:disabled { opacity: .5; cursor: default; }
label { display: grid; gap: 4px; font-size: .85rem; color: var(--texte-2); }

.filtres { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: flex-end; }
.groupe { display: grid; gap: 6px; }
.groupe > span { font-size: .8rem; color: var(--texte-2); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.puces { display: flex; flex-wrap: wrap; gap: 6px; }
.puce { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--bord); border-radius: 999px; background: var(--surface); cursor: pointer; user-select: none; font-size: .9rem; }
.puce input { position: absolute; opacity: 0; pointer-events: none; }
.puce { color: var(--texte-2); }
.puce:has(input:checked) { background: color-mix(in srgb, var(--accent) 16%, var(--surface)); border-color: var(--accent); color: var(--texte); font-weight: 600; }
.puce:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.pastille { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.jours .puce { min-width: 40px; justify-content: center; }

/* Indicateurs */
.tuiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tuile { padding: 12px; border-radius: 8px; background: var(--surface-2); }
.tuile .valeur { font-size: 1.6rem; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.2; }
.tuile .libelle { font-size: .8rem; color: var(--texte-2); }
.tuile .detail { font-size: .78rem; color: var(--texte-3); }

/* Aujourd'hui */
.direct { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.voyage { border: 1px solid var(--bord); border-radius: 8px; padding: 12px; display: grid; gap: 8px; }
.voyage-tete { display: flex; gap: 8px; align-items: center; }
.voyage-tete strong { margin-right: auto; }
.horaires { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-variant-numeric: tabular-nums; }
.frise { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; font-size: .85rem; }
.frise li { display: grid; grid-template-columns: 14px 1fr auto; gap: 8px; align-items: center; color: var(--texte-2); }
.frise li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; border: 2px solid var(--texte-3); justify-self: center; }
.frise li.passe::before { background: var(--texte-3); }
.frise li.ici { color: var(--texte); font-weight: 600; }
.frise li.ici::before { background: var(--accent); border-color: var(--accent); width: 10px; height: 10px; }

/* États (toujours icône + libellé, jamais la couleur seule) */
.etat { display: inline-flex; align-items: center; gap: 4px; font-size: .82rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); white-space: nowrap; }
.etat::before { font-size: .9em; }
.etat.ok { color: var(--ok-texte); } .etat.ok::before { content: "✓"; }
.etat.retard { color: var(--grave-texte); } .etat.retard::before { content: "⏱"; }
.etat.supprime { color: var(--critique-texte); } .etat.supprime::before { content: "✕"; }
.etat.neutre { color: var(--texte-2); }

/* Graphiques */
.graphique { position: relative; height: 280px; }
.legende { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: .85rem; color: var(--texte-2); margin-bottom: 8px; }
.legende span { display: inline-flex; align-items: center; gap: 6px; }

/* Tableaux */
.defile { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--grille); white-space: nowrap; }
td.cause { white-space: normal; min-width: 200px; color: var(--texte-2); }
th { font-size: .78rem; color: var(--texte-2); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
td.droite, th.droite { text-align: right; }
tbody tr.cliquable { cursor: pointer; }
tbody tr.cliquable:hover { background: var(--surface-2); }
tr.detail > td { background: var(--surface-2); padding: 12px; white-space: normal; }
.barre-cause { height: 6px; border-radius: 3px; background: var(--s1); }
.reel { margin-left: 6px; color: var(--grave-texte); font-weight: 600; }

/* Paramètres */
.formulaire { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); align-items: end; }
.liste-trajets { display: grid; gap: 10px; }
.ligne-trajet { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; border: 1px solid var(--bord); border-radius: 8px; padding: 10px 12px; }
.ligne-trajet .infos { margin-right: auto; min-width: 200px; }
.ligne-trajet.inactif { opacity: .6; }

.vide { padding: 24px; text-align: center; color: var(--texte-2); }
.connexion { max-width: 420px; margin: 10vh auto; text-align: center; display: grid; gap: 12px; }
[hidden] { display: none !important; }
#toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); padding: 8px 14px; border-radius: 6px; background: var(--texte); color: var(--fond); opacity: 0; transition: opacity .2s; pointer-events: none; max-width: calc(100% - 32px); }
#toast.visible { opacity: 1; }

@media (max-width: 600px) {
  .entete { padding: 8px 12px; }
  main { padding: 12px; }
  .tuile .valeur { font-size: 1.3rem; }
}
