/* ============================================================
   TMR Comptage — application de saisie
   Design v4 « TMR Mobility » (mobile) :
   rouge corporate #e1251b, bandeau course en dégradé, cartes 16px,
   tuiles résumé, FAB sync sombre flottant.
   ============================================================ */

:root {
  --primary:        #e1251b;
  --primary-grad:   linear-gradient(135deg, #e1251b 0%, #f04a3f 100%);
  --primary-fixed:  #ffdad5;
  --bg:             #f9f9f9;
  --surface-white:  #ffffff;
  --surface-low:    #f3f3f3;
  --surface-cont:   #eeeeee;
  --surface-high:   #e8e8e8;
  --surface-var:    #e2e2e2;
  --text:           #1a1c1c;
  --text-dark:      #333333;
  --secondary:      #5f5e5e;
  --label-grey:     #9ca3af;
  --error:          #ba1a1a;
  --ok-green:       #4ade80;
  --warn:           #d4870d;
  --shadow-card:    0 4px 12px rgba(0,0,0,.05);
  --r:              16px;
  --font-head:      'Moderat', 'Hanken Grotesk', 'Segoe UI', system-ui, sans-serif;
  --font-body:      'Moderat', 'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-mono:      'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
/* Aucun défilement horizontal possible : un élément trop large est
   coupé au lieu de décaler toute la page */
html, body { overflow-x: hidden; overflow-x: clip; max-width: 100%; }
body {
  margin: 0;
  font-family: var(--font-head);
  background: var(--bg);
  color: var(--text);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }
.muted { color: var(--secondary); font-size: 13px; }
.warn-text { color: var(--error); font-size: 12px; font-weight: 600; font-style: normal; }

.ic { width: 22px; height: 22px; fill: currentColor; flex-shrink: 0; }

label {
  display: block;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--label-grey);
  margin-bottom: 6px; padding-left: 2px;
}

input, select {
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--r);
  padding: 11px 13px;
  /* 16px minimum : en dessous, iOS zoome automatiquement au focus */
  font-size: 16px; font-weight: 500;
  background: var(--surface-low);
  color: var(--text);
  font-family: var(--font-head);
  min-height: 46px;
}
input:focus, select:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
}

/* ── Login (plein écran blanc) ──────────────────────────── */
#viewLogin {
  position: fixed; inset: 0; z-index: 50;
  background: #fff;
  display: grid; place-items: center;
  padding: 24px;
}
.login-inner { width: 100%; max-width: 360px; text-align: center; }
.login-logo { width: 150px; max-width: 60%; margin: 0 auto 26px; display: block; }
.login-inner h2 { margin: 0 0 8px; font-size: 24px; font-weight: 700; }
.login-sub { color: var(--secondary); font-size: 14px; margin: 0 0 30px; font-family: var(--font-body); }
.login-inner form { text-align: left; }
.login-inner input {
  height: 56px; text-align: center;
  font-size: 22px; font-weight: 700; letter-spacing: 2px;
}
.login-error { color: var(--error); font-size: 12px; font-weight: 500; min-height: 18px; margin-top: 8px; }
.login-btn {
  width: 100%; height: 56px; margin-top: 6px;
  background: var(--primary); color: #fff;
  border: none; border-radius: var(--r);
  font-family: var(--font-head); font-weight: 700; font-size: 16px;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(225,37,27,.25);
  transition: transform .1s;
}
.login-btn:active { transform: scale(.95); }

/* ── Header rouge ───────────────────────────────────────── */
header {
  position: sticky; top: 0; z-index: 30;
  background: var(--primary);
  color: #fff;
  padding: 14px 20px;
  padding-top: max(14px, env(safe-area-inset-top));
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
}
header .brand { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; cursor: pointer; }
/* Le bloc titre doit pouvoir rétrécir pour que l'ellipse fonctionne
   (sinon le badge de sync se superpose au titre sur mobile) */
header .brand > div:last-child { min-width: 0; }
header .logo-img {
  height: 32px; width: auto; flex-shrink: 0;
  filter: brightness(0) invert(1);
}
header h1 {
  margin: 0; font-size: clamp(14px, 4.2vw, 18px); font-weight: 700;
  line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* « voyageurs » disparaît quand la place manque */
@media (max-width: 460px) { header h1 .h1-ext { display: none; } }
header .sub {
  font-size: 10px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; opacity: .9; margin-top: 2px;
}

.sync-badge {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(0,0,0,.12);
  border-radius: 999px; padding: 7px 13px;
  font-size: 12px; font-weight: 600;
  font-family: var(--font-body);
  white-space: nowrap;
  flex-shrink: 0;
  max-width: 46vw;
}
.sync-badge #syncLabel { overflow: hidden; text-overflow: ellipsis; }
.sync-badge .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #cfcfcf;
  animation: pulse-sync 2s cubic-bezier(.4,0,.6,1) infinite;
}
.sync-badge.ok .dot { background: var(--ok-green); }
.sync-badge.pending .dot { background: #ffd54f; }
.sync-badge.offline .dot { background: #ff8a80; }
@keyframes pulse-sync {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .5; transform: scale(1.2); }
}

/* Bouton retour (variante guidée) */
.back-btn {
  width: 40px; height: 40px; min-width: 40px;
  display: grid; place-items: center;
  background: rgba(255,255,255,.2); color: #fff;
  border: none; border-radius: 999px;
  transition: transform .1s;
}
.back-btn:active { transform: scale(.9); }
.back-btn .ic { width: 18px; height: 18px; }

main {
  max-width: 460px; margin: 0 auto;
  padding: clamp(12px, 3.5vw, 24px) clamp(10px, 3vw, 16px) 140px;
  display: grid; gap: clamp(10px, 2.5vw, 16px);
}
/* Les enfants d'une grille ont un plancher min-content : sans ceci,
   ouvrir l'accordéon des titres (rangée de chips ~480px) élargit toute
   la page au lieu de laisser les chips défiler dans leur bandeau */
main > * { min-width: 0; }

.card {
  background: var(--surface-white);
  border-radius: var(--r);
  box-shadow: var(--shadow-card);
}

/* ── Contexte (date / dépôt / service) ──────────────────── */
.ctx-card { padding: 20px; display: grid; gap: 18px; }
.ctx-date-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.today {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--text);
  font-weight: 700; font-size: 17px;
  text-transform: capitalize;
}
.today .ic { width: 22px; height: 22px; color: var(--primary); }
#dateFallback label { color: var(--error); }
#dateFallback select { min-height: 40px; padding: 7px 10px; font-size: 14px; }
/* minmax(0,…) : sans lui, une grille « 1fr » refuse de rétrécir sous
   la largeur naturelle de son contenu et fait déborder la page */
.grid-2 { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.3fr); gap: 14px; }
/* Récap service (même style PC et mobile) : « Service 5013 » en titre,
   chip d'avancement à droite, barre de progression fine en dessous.
   PC : infos sur la même ligne que le titre ; mobile : en dessous. */
.service-info {
  font-size: 12.5px; color: var(--secondary);
  font-family: var(--font-body);
  background: var(--surface-low);
  border: 1px solid var(--surface-cont);
  padding: 13px 14px; border-radius: 12px;
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 10px; row-gap: 9px;
}
.service-info:empty { display: none; }
.service-info .pill {
  flex-shrink: 0;
  background: none; padding: 0; border-radius: 0;
  font-family: var(--font-head); font-size: 15px; font-weight: 700;
  color: var(--text); white-space: nowrap;
}
.service-info .si-meta {
  flex: 1; min-width: 0;
  font-weight: 500; color: var(--secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.service-info .si-done {
  flex-shrink: 0;
  background: var(--surface-var); color: var(--text-dark);
  border-radius: 999px; padding: 2px 10px;
  font-size: 11px; font-weight: 700;
}
.service-info .si-progress {
  flex: 1 1 100%; order: 4;
  height: 5px; border-radius: 999px;
  background: var(--surface-var); overflow: hidden;
}
.service-info .si-progress .bar {
  height: 100%; background: var(--primary); border-radius: 999px;
  transition: width .4s ease;
}
/* Pastille générique (messages hors récap) */
.pill {
  display: inline-block;
  background: var(--primary-fixed); color: var(--primary);
  border-radius: 999px; padding: 2px 10px;
  font-size: 11px; font-weight: 700;
  white-space: nowrap;
}

@media (max-width: 480px) {
  /* Les infos passent sous le titre, avec retour à la ligne naturel ;
     le chip d'avancement reste calé à droite comme sur PC */
  .service-info .si-meta {
    flex: 1 1 100%; order: 3;
    white-space: normal; overflow: visible; line-height: 1.5;
  }
  .service-info .si-done { margin-left: auto; }
}

/* Bouton démarrage (variante guidée) */
.start-btn {
  width: 100%; padding: 16px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--primary); color: #fff;
  border: none; border-radius: var(--r);
  font-family: var(--font-head); font-weight: 700; font-size: 16px;
  box-shadow: 0 8px 20px rgba(225,37,27,.3);
  transition: transform .1s;
}
.start-btn:active { transform: scale(.97); }
.start-btn:disabled { opacity: .4; box-shadow: none; }
.start-btn .ic { width: 18px; height: 18px; }

/* ── Course active : bandeau dégradé rouge ──────────────── */
.course-card { overflow: hidden; }
.course-hero, .course-banner-hero {
  background: var(--primary-grad);
  color: #fff;
  padding: 20px;
}
.hero-row { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.nav-btn {
  width: 40px; height: 40px; min-width: 40px;
  display: grid; place-items: center;
  background: rgba(255,255,255,.2); color: #fff;
  border: none; border-radius: 999px;
  transition: transform .1s;
}
.nav-btn:active { transform: scale(.9); }
.nav-btn .ic { width: 18px; height: 18px; }
.course-center { flex: 1; min-width: 0; text-align: center; }
/* Sélecteur de course : pastille translucide bien visible sur le
   dégradé rouge, avec chevron blanc et texte tronqué proprement */
.course-center select {
  appearance: none; -webkit-appearance: none;
  background: rgba(255,255,255,.16)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E")
    no-repeat right 10px center / 16px;
  border: 1px solid rgba(255,255,255,.25); border-radius: 12px;
  min-height: 0;
  text-align: center; text-align-last: center;
  font-weight: 700; font-size: 15px; color: #fff;
  padding: 10px 34px 10px 12px; width: 100%;
  font-family: var(--font-head);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.course-center select:focus { outline: 2px solid rgba(255,255,255,.6); outline-offset: -1px; }
.course-center select option { color: var(--text); background: #fff; }
.course-center #courseInfo {
  font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em;
  opacity: .85; margin-top: 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.course-progress {
  height: 6px; border-radius: 999px;
  background: rgba(0,0,0,.2); overflow: hidden;
}
.course-progress .bar {
  height: 100%; background: #fff; border-radius: 999px;
  transition: width .5s ease;
}
.course-actions {
  padding: 16px;
  background: var(--surface-low);
  display: flex; justify-content: center;
}
.finish-btn {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  padding: 13px 26px;
  background: var(--surface-white);
  border: 1.5px solid var(--primary); border-radius: var(--r);
  color: var(--primary);
  font-family: var(--font-head); font-weight: 700; font-size: 14.5px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  transition: all .15s;
}
.finish-btn:active { background: var(--primary); color: #fff; }
.finish-btn .ic { width: 20px; height: 20px; }

/* Bandeau course de la variante guidée */
.course-banner { overflow: hidden; }
.cb-top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 4px; }
.cb-num { font-size: 20px; font-weight: 700; }
.cb-time { font-size: 13px; font-weight: 600; opacity: .9; font-variant-numeric: tabular-nums; }
.cb-route {
  font-size: 14.5px; font-weight: 700;
  line-height: 1.3; opacity: .97;
  margin-bottom: 4px;
}
.cb-line {
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; opacity: .7;
  margin-bottom: 14px;
}

/* ── Tuiles résumé ──────────────────────────────────────── */
.summary { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 8px; }
.metric {
  background: var(--surface-white);
  border-radius: var(--r);
  box-shadow: var(--shadow-card);
  padding: 13px 6px;
  text-align: center;
}
.metric span {
  display: block;
  font-size: 9.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--label-grey); margin-bottom: 4px;
}
.metric b {
  font-family: var(--font-head); font-size: 20px; font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.metric.filled {
  background: var(--primary); color: #fff;
  box-shadow: 0 6px 16px rgba(225,37,27,.25);
}
.metric.filled span { color: rgba(255,255,255,.8); }
.metric.edge { border-left: 4px solid var(--primary); }

.error-box { color: var(--error); font-size: 12px; font-weight: 600; padding: 0 4px; font-family: var(--font-body); }
.error-box:empty { display: none; }

/* ── Footer compact (style maquette : carte grise arrondie) ── */
.app-footer {
  margin: 20px 0 8px;
  padding: 26px 16px 20px;
  background: #f5f5f5;
  border-radius: var(--r);
  text-align: center;
}
.app-footer img { height: 26px; margin-bottom: 12px; }
.app-footer p { margin: 2px 0; font-size: 12.5px; color: #8d8f98; }
.app-footer p b { color: #414141; font-weight: 700; }

/* ── Bouton et panneau d'aide (mémo d'utilisation) ──────── */
.help-btn {
  width: 36px; height: 36px; min-width: 36px;
  display: grid; place-items: center;
  background: rgba(255,255,255,.2); color: #fff;
  border: none; border-radius: 999px;
  transition: transform .1s;
}
.help-btn:active { transform: scale(.9); }
.help-btn .ic { width: 20px; height: 20px; }

.help-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: var(--bg);
  overflow-y: auto;
}
.help-head {
  position: sticky; top: 0;
  background: var(--primary); color: #fff;
  padding: 16px 20px;
  padding-top: max(16px, env(safe-area-inset-top));
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
}
.help-head h2 { margin: 0; font-size: 18px; font-weight: 700; }
.help-close {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: rgba(255,255,255,.2); color: #fff;
  border: none; border-radius: 999px;
  transition: transform .1s;
}
.help-close:active { transform: scale(.9); }
.help-close .ic { width: 20px; height: 20px; }
.help-body {
  max-width: 520px; margin: 0 auto;
  padding: 18px 16px 60px;
  display: grid; gap: 10px;
}
/* Étapes : numéro rouge + une ou deux lignes, lisible en 10 secondes */
.help-step {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--surface-white);
  border-radius: var(--r);
  box-shadow: var(--shadow-card);
  padding: 14px 16px;
}
.hs-num {
  width: 34px; height: 34px; min-width: 34px;
  display: grid; place-items: center;
  background: var(--primary); color: #fff;
  border-radius: 999px;
  font-size: 17px; font-weight: 800;
}
.hs-txt { display: grid; gap: 3px; padding-top: 4px; min-width: 0; }
.hs-txt b { font-size: 15.5px; }
.hs-txt > b:first-child { margin-bottom: 1px; }
.hs-txt span { font-size: 14px; color: var(--text); font-family: var(--font-body); line-height: 1.4; }
.hs-txt em {
  font-style: normal; font-size: 12.5px; color: var(--warn);
  font-weight: 600; font-family: var(--font-body);
}
/* Bloc hors-ligne : LE message à retenir */
.help-sync {
  background: var(--text); color: #fff;
  border-radius: var(--r);
  padding: 16px 18px; text-align: center;
}
.hs-label {
  font-size: 11.5px; font-weight: 600; opacity: .75;
  text-transform: uppercase; letter-spacing: .04em;
  margin-bottom: 7px;
}
.hs-label b { color: #ffb4a9; }
.hs-badges {
  display: flex; justify-content: center; gap: 14px;
  font-size: 12.5px; font-weight: 600; opacity: .9;
  margin-bottom: 10px; flex-wrap: wrap;
}
.hs-big { font-size: 16px; line-height: 1.45; }
.hs-big b { color: #ffb4a9; }
/* Consigne SYNC de fin de service : le seul geste à retenir */
.hs-action {
  margin-top: 12px;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px; line-height: 1.5;
  font-family: var(--font-body);
}
.hs-action b { color: #ffb4a9; }
.help-tips {
  text-align: center; font-size: 12.5px; color: var(--secondary);
  font-family: var(--font-body); line-height: 1.6;
  padding: 4px 8px;
}

/* ── Carte d'arrêt ──────────────────────────────────────── */
.stop {
  background: var(--surface-white);
  border-radius: var(--r);
  box-shadow: var(--shadow-card);
  border-left: 4px solid var(--primary);
  margin-bottom: 12px;
  overflow: hidden;
}
.stop-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px 6px;
}
.stop-head .headmain { flex: 1; min-width: 0; }
.stop-head .name {
  font-weight: 700; font-size: 16px; line-height: 1.2;
  color: var(--text);
}
.stop-head .time {
  font-size: 12px; font-weight: 500; color: var(--secondary);
  font-family: var(--font-body); margin-top: 2px;
}
.stop-head .order {
  font-size: 10px; font-weight: 700; color: var(--label-grey);
  background: var(--surface-low); border-radius: 999px; padding: 4px 9px;
  flex-shrink: 0;
}

/* Compteurs montées / descentes */
.stop-counts { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; padding: 8px 16px 14px; }
.count-panel { background: var(--surface-low); border-radius: 12px; padding: 10px 10px 12px; }
.count-panel .panel-label {
  display: flex; align-items: center; gap: 7px;
  font-size: 9.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  margin-bottom: 9px;
}
.count-panel.board .panel-label { color: var(--primary); }
.count-panel.alight .panel-label { color: var(--secondary); }
.count-panel .panel-label .ic { width: 19px; height: 19px; }
/* Panneau verrouillé (départ sans descentes / terminus sans montées) */
.count-panel.disabled { opacity: .45; }
.count-panel.disabled .stepper button { pointer-events: none; }
.stepper { display: flex; align-items: center; gap: 7px; }
.stepper button {
  width: 46px; min-width: 46px; height: 48px;
  border: none; border-radius: 12px;
  font-size: 24px; line-height: 1; font-weight: 600;
  color: #fff;
  transition: transform .1s, filter .12s;
}
.stepper button:active { transform: scale(.9); filter: brightness(.92); }
.count-panel.board .stepper button { background: var(--primary); box-shadow: 0 2px 6px rgba(225,37,27,.25); }
.count-panel.alight .stepper button { background: var(--secondary); box-shadow: 0 2px 6px rgba(95,94,94,.25); }
.stepper button.minus {
  background: var(--surface-white) !important; color: var(--text);
  box-shadow: inset 0 0 0 1px var(--surface-var) !important;
}
.stepper .value {
  flex: 1; min-width: 0; min-height: 0;
  border: none; background: transparent; padding: 0;
  text-align: center;
  font-family: var(--font-head); font-size: 24px; font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.stepper .value:focus { outline: none; }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); } }
.stepper .value.bump, .t-value.bump { animation: bump .25s ease; }

/* ── Titres de transport : accordéon + chips ────────────── */
details.tickets { border-top: 1px solid var(--surface-cont); }
details.tickets summary {
  cursor: pointer; list-style: none;
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--text-dark);
}
details.tickets summary::-webkit-details-marker { display: none; }
details.tickets summary .ic { width: 19px; height: 19px; color: var(--primary); }
details.tickets summary .count-chip {
  margin-left: auto;
  background: var(--primary); color: #fff;
  border-radius: 999px; padding: 3px 11px;
  font-size: 11.5px; font-weight: 700;
}
details.tickets summary .count-chip.zero { background: var(--surface-var); color: var(--secondary); }
details.tickets summary .chev { color: var(--label-grey); transition: transform .2s; }
details.tickets[open] summary .chev { transform: rotate(180deg); }

/* Chips de catégories : inactif gris clair, actif slate foncé */
/* Chips de catégories (sur plusieurs lignes, jamais coupées).
   « ★ Fréquents » est auto-calculé selon les saisies du dépôt. */
.cat-tabs {
  display: flex; flex-wrap: wrap; gap: 7px;
  padding: 0 16px 12px;
  max-width: 100%;
}
.cat-tab {
  border: none; background: var(--surface-low);
  border-radius: 999px; padding: 9px 14px;
  font-family: var(--font-body); font-size: 12.5px; font-weight: 600;
  color: var(--secondary);
  white-space: nowrap; flex-shrink: 0;
  transition: all .15s;
}
.cat-tab.active { background: var(--text-dark); color: #fff; }
.cat-tab.freq { color: var(--primary); }
.cat-tab.freq.active { background: var(--primary); color: #fff; }
.cat-tab .n {
  display: inline-block; min-width: 17px; text-align: center;
  background: var(--primary); color: #fff;
  border-radius: 999px; font-size: 10px; font-weight: 700;
  padding: 1px 4px; margin-left: 5px; vertical-align: 1px;
}
.cat-tab.active .n { background: rgba(255,255,255,.28); }

.cat-panel { padding: 0 16px 12px; }
.ticket-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--surface-var);
}
.ticket-row:last-child { border-bottom: none; }
.ticket-row .t-label {
  flex: 1; font-size: 13px; font-weight: 500; line-height: 1.3;
  font-family: var(--font-body);
}
.ticket-row.has-value .t-label { color: var(--primary); font-weight: 600; }
.ticket-row .t-stepper { display: flex; align-items: center; gap: 6px; }
.ticket-row .t-stepper button {
  width: 42px; min-width: 42px; height: 42px;
  border: none; border-radius: 12px;
  font-size: 20px; font-weight: 600; line-height: 1;
  background: var(--surface-low); color: var(--text-dark);
  transition: transform .1s;
}
.ticket-row .t-stepper button:active { transform: scale(.9); }
.ticket-row .t-stepper button:last-child { background: var(--primary); color: #fff; }
.ticket-row .t-stepper button.minus { background: var(--surface-white); box-shadow: inset 0 0 0 1px var(--surface-var); }
.ticket-row .t-value {
  width: 44px; min-height: 0; padding: 0;
  border: none; background: transparent;
  text-align: center;
  font-family: var(--font-head); font-size: 17px; font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.ticket-row.has-value .t-value { color: var(--primary); }
.ticket-row .t-value:focus { outline: none; }

.ticket-sum {
  padding: 8px 16px 13px;
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; color: var(--label-grey);
}
.ticket-sum.mismatch { color: var(--warn); }
.ticket-sum.mismatch::before { content: '⚠ '; }

/* Ligne à bord */
.load-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  background: var(--surface-low); border-top: 1px solid var(--surface-cont);
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; color: var(--label-grey);
}
.load-row .load-val {
  font-family: var(--font-head); font-size: 16px; font-weight: 800;
  color: var(--text); font-variant-numeric: tabular-nums;
}
.load-row.negative .load-val { color: var(--error); }

/* ── FAB Sync sombre flottant (coin bas droit) ──────────── */
.fab-float {
  position: fixed; right: 18px; z-index: 40;
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 5px;
}
.fab {
  width: 62px; height: 62px;
  background: var(--text); color: #fff;
  border: none; border-radius: 999px;
  display: grid; place-items: center;
  box-shadow: 0 12px 28px rgba(0,0,0,.35);
  transition: transform .12s;
}
.fab:active { transform: scale(.88); }
.fab .ic { width: 27px; height: 27px; }
.fab-label {
  font-size: 9.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em; color: var(--text);
  background: rgba(255,255,255,.9);
  padding: 2px 8px; border-radius: 6px;
  backdrop-filter: blur(4px);
}
/* FAB au-dessus de la barre basse quand elle est visible (variante) */
body:has(.bottom-bar-count:not(.hidden)) .fab-float {
  bottom: max(92px, calc(env(safe-area-inset-bottom) + 86px));
}

/* ── Barre basse du comptage (variante guidée) ──────────── */
.bottom-bar-count {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 39;
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--surface-high);
  display: flex; gap: 12px; align-items: center;
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(0,0,0,.06);
}
.prev-btn {
  width: 56px; min-width: 56px; height: 56px;
  display: grid; place-items: center;
  background: var(--surface-white); color: var(--text-dark);
  border: 1.5px solid var(--surface-var); border-radius: var(--r);
  transition: transform .1s;
}
.prev-btn:active { transform: scale(.92); background: var(--surface-low); }
.prev-btn:disabled { opacity: .35; }
.prev-btn .ic { width: 19px; height: 19px; }
.next-btn {
  flex: 1; min-height: 56px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--primary); color: #fff;
  border: none; border-radius: var(--r);
  font-family: var(--font-head); font-weight: 700; font-size: 16px;
  box-shadow: 0 6px 18px rgba(225,37,27,.3);
  transition: transform .1s;
}
.next-btn:active { transform: scale(.97); }
.next-btn .ic { width: 19px; height: 19px; }

/* ── Toast ──────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
  background: #2f3131; color: #fff;
  padding: 12px 20px; border-radius: 12px;
  font-size: 13.5px; font-weight: 600; z-index: 60;
  font-family: var(--font-body);
  box-shadow: 0 10px 30px rgba(0,0,0,.3);
  max-width: 90vw; text-align: center;
  animation: toast-in .22s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ── Responsive ─────────────────────────────────────────── */

/* Tablette / desktop : une colonne confortable, centrée.
   (Deux colonnes testées puis abandonnées : l'accordéon des titres
   déséquilibrait les hauteurs des cartes voisines.) */
@media (min-width: 760px) {
  main { max-width: 560px; }
}

/* Téléphones compacts (≤ 480px) : tout se resserre en douceur */
@media (max-width: 480px) {
  header { padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); }
  header .brand { gap: 10px; }
  header .logo-img { height: 26px; }
  header h1 { font-size: 15.5px; }
  header .sub { font-size: 9px; }
  .sync-badge { padding: 6px 10px; font-size: 10.5px; gap: 6px; max-width: 38vw; }
  .back-btn { width: 36px; height: 36px; min-width: 36px; }

  .ctx-card { padding: 16px 14px; gap: 14px; }
  .today { font-size: 15px; gap: 8px; }
  .today .ic { width: 19px; height: 19px; }
  .grid-2 { gap: 10px; }

  .course-hero, .course-banner-hero { padding: 16px 14px; }
  .course-actions { padding: 12px 14px; }
  .finish-btn { width: 100%; padding: 12px 16px; }
  .cb-num { font-size: 18px; }

  .summary { gap: 6px; }
  .metric { padding: 10px 4px; border-radius: 12px; }
  .metric span { font-size: 8.5px; }
  .metric b { font-size: 18px; }

  .stop-head { padding: 12px 14px 4px; }
  .stop-head .name { font-size: 15px; }
  .stop-counts { padding: 8px 12px 12px; gap: 8px; }
  .count-panel { padding: 8px 8px 10px; }
  .stepper { gap: 5px; }
  .stepper button { width: 42px; min-width: 42px; height: 46px; font-size: 22px; border-radius: 10px; }
  .stepper .value { font-size: 21px; }

  .cat-tabs { padding: 0 12px 10px; }
  .cat-tab { padding: 8px 12px; font-size: 12px; }
  .cat-panel { padding: 0 12px 10px; }
  .ticket-row .t-stepper button { width: 40px; min-width: 40px; height: 40px; border-radius: 10px; }
  .ticket-sum { padding: 6px 14px 12px; }
  .load-row { padding: 9px 14px; }

  .fab { width: 56px; height: 56px; }
  .fab .ic { width: 24px; height: 24px; }
  .fab-float { right: 12px; }

  .bottom-bar-count { padding: 10px 12px; gap: 8px; }
  .next-btn { min-height: 52px; font-size: 15px; }
  .prev-btn { width: 52px; min-width: 52px; height: 52px; }
}

/* Titres sur mobile : libellé long sur sa propre ligne, stepper
   compact aligné à droite (présentation d'origine) */
@media (max-width: 430px) {
  .ticket-row { flex-wrap: wrap; row-gap: 6px; }
  .ticket-row .t-label { flex: 1 1 100%; }
  .ticket-row .t-stepper { margin-left: auto; }
}

/* Très petits écrans (≤ 360px) : une colonne, résumé en 2×2 */
@media (max-width: 360px) {
  .stop-counts { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .summary { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .ctx-date-row { flex-direction: column; align-items: flex-start; }
}
