:root {
  color-scheme: dark;
  --fond: #1b1d20;
  --surface: #26292d;
  --surface-active: #30343a;
  --bordure: #3b4047;
  --texte: #f1f3f5;
  --discret: #a9b0b8;
  --accent: #4169e1;
  --accent-clair: #93a9f5;
  --bleu-icone: #6b8cf6; /* icônes des tuiles du chantier et des dossiers */
  --erreur: #ff9d9d;
  --gouttiere: 16px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent-clair); }
h1, h2, p { margin: 0; }

button {
  min-height: 44px;
  padding: 8px 18px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
button:disabled { opacity: .5; cursor: default; }

a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent-clair);
  outline-offset: 2px;
}

.bouton-discret {
  background: transparent;
  border: 1px solid var(--bordure);
  color: var(--texte);
  font-weight: 400;
}

/* En-tête */
.entete {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 60px;
  padding: 8px max(var(--gouttiere), env(safe-area-inset-right)) 8px max(var(--gouttiere), env(safe-area-inset-left));
  background: var(--fond);
  border-bottom: 1px solid var(--bordure);
}

.marque {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--texte);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.logo {
  display: block;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  outline: 1px solid var(--bordure);
}
.logo-grand { display: block; width: 80px; height: 96px; }

.session { display: flex; align-items: center; gap: 12px; min-width: 0; }
.qui { color: var(--discret); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Roue dentée ⚙ de l'en-tête */
.bouton-icone {
  display: grid;
  flex: none;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--bordure);
  border-radius: 10px;
  color: var(--texte);
}
.bouton-icone:active { border-color: var(--accent); background: var(--surface-active); }

/* Paramètres */
.param-bloc {
  display: grid;
  justify-items: start;
  gap: 10px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: 10px;
}
.param-nom { font-weight: 600; overflow-wrap: anywhere; }
.param-detail { color: var(--discret); overflow-wrap: anywhere; }
.param-resultat { color: var(--accent-clair); }
.param-resultat:empty { display: none; }

/* Tuiles « Actions » de la fiche projet : trois côte à côte, même sur téléphone */
.tuiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.tuile {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 6px;
  min-height: 120px;
  padding: 14px 8px;
  border: 1px solid var(--bordure);
  border-radius: 10px;
  font: inherit;
  font-weight: 400;
  text-align: center;
  text-decoration: none;
}
.tuile-icone { display: block; width: 40px; height: 40px; }
.tuile-nom { font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.tuile-etat { font-size: .78rem; line-height: 1.2; }
.tuile-inactive { background: var(--surface); color: var(--discret); cursor: default; }
.tuile-inactive .tuile-icone { opacity: .55; }
.tuile-inactive { border-color: #33373d; }
.tuile-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tuile-active:active { filter: brightness(1.12); }
.tuiles-chantier { margin: 4px 0 8px; }
/* Tuiles du chantier : fond gris foncé comme les autres, icônes bleues, texte blanc — nettement plus
   vives que les tuiles « Bientôt en service », plus éteintes. */
.tuiles-chantier .tuile-active { background: var(--surface); border-color: #4a515b; color: #fff; }
.tuiles-chantier .tuile-active .tuile-icone { color: var(--bleu-icone); }
.tuiles-chantier .tuile-active:active { background: var(--surface-active); border-color: var(--bleu-icone); filter: none; }
.tuile-inactive .tuile-nom { font-weight: 500; }

/* Caméra (maquette d'essai) */
.camera-plein {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: #000;
}
.camera-barre {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: max(8px, env(safe-area-inset-top)) max(var(--gouttiere), env(safe-area-inset-right)) 8px max(var(--gouttiere), env(safe-area-inset-left));
  background: var(--fond);
}
.camera-titre { color: var(--discret); font-size: .9rem; }
.camera-video { display: block; width: 100%; height: 100%; min-height: 0; object-fit: contain; background: #000; }
.camera-infos {
  position: absolute;
  left: 8px;
  right: 8px;
  top: calc(max(8px, env(safe-area-inset-top)) + 60px);
  margin: 0;
  padding: 8px 10px;
  background: rgba(0, 0, 0, .6);
  border-radius: 8px;
  color: #fff;
  font: 12px/1.4 ui-monospace, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  pointer-events: none;
}
.camera-declencheur {
  position: absolute;
  left: 50%;
  bottom: max(24px, calc(env(safe-area-inset-bottom) + 16px));
  width: 76px;
  height: 76px;
  padding: 0;
  transform: translateX(-50%);
  border: 5px solid #fff;
  border-radius: 50%;
  background: rgba(255, 255, 255, .25);
}
.camera-declencheur:active { background: rgba(255, 255, 255, .6); }
.camera-resultat {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) 8px max(12px, env(safe-area-inset-bottom));
  background: #000;
}
.camera-photo { min-height: 0; overflow: hidden; }
.camera-photo img { display: block; width: 100%; height: 100%; object-fit: contain; }
.camera-photo.taille-reelle { overflow: auto; -webkit-overflow-scrolling: touch; }
.camera-photo.taille-reelle img { width: auto; height: auto; max-width: none; object-fit: none; }
.camera-infos-photo { position: static; pointer-events: auto; }

/* Court message en bas de l'écran */
.annonce {
  position: fixed;
  left: 50%;
  bottom: max(24px, calc(env(safe-area-inset-bottom) + 12px));
  z-index: 70;
  transform: translateX(-50%);
  width: max-content; /* sans cela, la bulle centrée ne prend que la moitié de l'écran */
  pointer-events: none; /* message seulement : ne bloque jamais le déclencheur ni un bouton dessous */
  max-width: calc(100% - 2 * var(--gouttiere));
  padding: 10px 18px;
  background: var(--surface-active);
  border: 1px solid var(--bordure);
  border-radius: 999px;
  color: var(--texte);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .45);
}

/* Recherche dans la liste des projets */
.recherche { position: relative; margin-bottom: 16px; }
.recherche-champ {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 10px 52px 10px 14px;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: 10px;
  color: var(--texte);
  font: inherit;
  font-size: 17px; /* 16 px ou plus : iOS ne zoome pas sur le champ */
  -webkit-appearance: none;
  appearance: none;
}
.recherche-champ::placeholder { color: var(--discret); }
.recherche-champ:focus { outline: none; border-color: var(--accent); }
.recherche-vider {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 44px;
  min-height: 44px;
  padding: 0;
  background: transparent;
  color: var(--discret);
  font-size: 1.1rem;
  font-weight: 400;
}
.recherche-vider:active { color: var(--texte); }

/* Tirer vers le bas pour actualiser */
.tirer {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 60px);
  left: 50%;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--surface-active);
  border: 1px solid var(--bordure);
  border-radius: 999px;
  color: var(--texte);
  font-size: .95rem;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .45);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -80px);
}
.tirer.visible { opacity: 1; }
.tirer-icone { display: inline-block; color: var(--accent-clair); transition: transform .15s; }
.tirer.pret .tirer-icone { transform: rotate(180deg); }
.tirer.en-cours .tirer-icone { animation: tourner .8s linear infinite; }
@keyframes tourner { from { transform: rotate(0); } to { transform: rotate(360deg); } }

/* Accueil déconnecté */
.accueil {
  display: grid;
  justify-items: center;
  gap: 16px;
  max-width: 420px;
  margin: 12vh auto 0;
  padding: 0 var(--gouttiere);
  text-align: center;
}
.accueil p { color: var(--discret); }
.accueil h1 { font-size: 1.6rem; }

/* Contenu */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px var(--gouttiere) 48px;
}

.fil {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 8px;
  margin-bottom: 8px;
  color: var(--discret);
  font-size: .9rem;
  overflow-wrap: anywhere;
}
.fil > * { min-width: 0; line-height: 32px; }
.fil a { display: block; }
.fil-actuel { color: var(--texte); font-weight: 700; }
.fil-sep { flex: none; }

/* Téléphone : le fil tient sur une ligne. Les étapes du milieu se coupent d'abord (« … »),
   puis l'endroit affiché ; « Projets » ne se coupe jamais. */
@media (max-width: 699px) {
  .fil { flex-wrap: nowrap; overflow: hidden; overflow-wrap: normal; }
  .fil > :not(.fil-sep) { flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .fil > .fil-etape { flex-shrink: 4; min-width: 2.2em; }
  .fil > .fil-racine { flex-shrink: 0; min-width: auto; }
  .fil > .fil-actuel { flex-shrink: 1; }
}

.titre-page { margin-bottom: 16px; font-size: 1.5rem; line-height: 1.25; overflow-wrap: anywhere; }
.sous-titre { margin: -10px 0 16px; color: var(--discret); overflow-wrap: anywhere; white-space: pre-line; }
.section-titre { margin: 28px 0 10px; color: var(--discret); font-size: .85rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }

.grille { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.liste { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }

@media (min-width: 700px) {
  .grille { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
}

.carte {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 72px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: 10px;
  color: var(--texte);
  text-decoration: none;
}
a.carte:hover { background: var(--surface-active); }
a.carte:active { border-color: var(--accent); }

.carte-inactive { color: var(--discret); }

.icone { flex: none; display: block; width: 40px; height: 40px; color: var(--bleu-icone); }
.carte-inactive .icone { color: var(--discret); }

.carte-texte { display: grid; gap: 1px; min-width: 0; flex: 1; }
.carte-nom { font-weight: 600; overflow-wrap: anywhere; }
.carte-info { color: var(--discret); font-size: .92rem; overflow-wrap: anywhere; white-space: pre-line; }
/* Hauteur égale : chaque texte sur une ligne, coupé avec « … » */
.carte-une-ligne .carte-nom,
.carte-une-ligne .carte-info { overflow: hidden; overflow-wrap: normal; white-space: nowrap; text-overflow: ellipsis; }

.etat { padding: 24px 0; color: var(--discret); overflow-wrap: anywhere; }
.etat.erreur { color: var(--erreur); }
.erreur-reessayer { display: block; margin: 0 0 20px; }

.erreur-globale { max-width: 720px; margin: 16px auto; padding: 0 var(--gouttiere); color: var(--erreur); overflow-wrap: anywhere; }

/* Visionneuse PDF : occupe tout l'écran sous l'en-tête */
body.mode-pdf { overflow: hidden; }
body.mode-pdf main {
  display: flex;
  flex-direction: column;
  max-width: none;
  height: calc(100vh - 61px);
  height: calc(100dvh - 61px);
  padding: 0;
}

.pdf-barre {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px var(--gouttiere);
  border-bottom: 1px solid var(--bordure);
  background: var(--surface);
}
.pdf-retour { display: inline-flex; align-items: center; flex: none; min-height: 44px; }
.pdf-nom { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .95rem; }
.pdf-zoom { display: flex; align-items: center; gap: 4px; flex: none; }
.pdf-zoom button { min-width: 44px; padding: 4px 10px; }
.pdf-niveau { min-width: 3.4em; color: var(--discret); font-size: .9rem; text-align: center; }

.pdf-zone {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y; /* le pincement est géré par la visionneuse */
  background: #121315;
}
.pdf-zone > .etat { padding: 24px var(--gouttiere); }

.pdf-pages { display: grid; justify-content: center; gap: 12px; padding: 12px; width: max-content; min-width: 100%; }
.pdf-page { position: relative; overflow: hidden; background: #fff; }
.pdf-fond { display: block; width: 100%; height: 100%; }
.pdf-net { position: absolute; display: block; }

/* Photos */
.bouton-danger { background: #c0392b; }
.bouton-archive { background: var(--surface-active); color: var(--discret); font-weight: 400; }
.etat.avis { color: var(--texte); }

.photos-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.bouton-ajout { min-height: 52px; padding: 10px 22px; }

.envoi {
  margin-top: 16px;
  padding: 4px 14px 14px;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: 10px;
}
.envoi .section-titre { margin-top: 12px; }
.envoi-liste { display: grid; gap: 10px; }
.envoi-element {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--bordure);
}
.envoi-element:first-child { border-top: 0; }
.envoi-apercu { width: 64px; height: 64px; border-radius: 6px; background: var(--surface-active); overflow: hidden; }
.envoi-apercu img { display: block; width: 100%; height: 100%; object-fit: cover; }
.envoi-corps { display: grid; gap: 6px; min-width: 0; }
.envoi-legende {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--bordure);
  border-radius: 8px;
  background: var(--fond);
  color: var(--texte);
  font: inherit;
  font-size: 16px; /* évite le zoom automatique de Safari */
}
.envoi-legende:focus-visible { outline: 2px solid var(--accent-clair); outline-offset: 1px; }
.envoi-legende:disabled { opacity: .6; }
.envoi-etat { color: var(--discret); font-size: .9rem; overflow-wrap: anywhere; }
.envoi-element[data-etat="echec"] .envoi-etat,
.envoi-element[data-etat="invalide"] .envoi-etat { color: var(--erreur); }
.envoi-element[data-etat="ok"] .envoi-etat { color: #8fd19e; }
.envoi-element-boutons { display: flex; flex-direction: column; gap: 6px; }
.envoi-resume { margin-top: 12px; color: var(--discret); }
.envoi-resume.erreur { color: var(--erreur); }
.envoi-boutons { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }

.barre { height: 6px; border-radius: 3px; background: var(--fond); overflow: hidden; }
.barre-plein { width: 0; height: 100%; background: var(--accent); transition: width .15s linear; }
.barre-totale { height: 10px; margin-top: 14px; border-radius: 5px; }

.galerie { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 700px) {
  .galerie { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
}
.galerie > .etat { grid-column: 1 / -1; }

.photo-tuile {
  display: grid;
  align-content: start;
  gap: 6px;
  min-height: 0;
  padding: 0 0 8px;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: 10px;
  overflow: hidden;
  color: var(--texte);
  font-weight: 400;
  text-align: left;
}
.photo-tuile:active { border-color: var(--accent); }
.photo-cadre { display: grid; place-items: center; aspect-ratio: 1; background: var(--surface-active); }
.photo-cadre img { display: block; width: 100%; height: 100%; object-fit: cover; }
.photo-attente { padding: 8px; color: var(--discret); font-size: .8rem; text-align: center; }
.photo-info { display: grid; gap: 1px; padding: 0 8px; min-width: 0; font-size: .85rem; line-height: 1.3; }
.photo-date { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.photo-auteur { color: var(--discret); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.photo-legende {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

/* Photo en plein écran */
body.mode-photo { overflow: hidden; }
.photo-plein {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: #000;
}
.photo-barre {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: max(6px, env(safe-area-inset-top)) max(var(--gouttiere), env(safe-area-inset-right)) 6px max(var(--gouttiere), env(safe-area-inset-left));
  background: var(--fond);
  border-bottom: 1px solid var(--bordure);
}
.photo-position { flex: 1; color: var(--discret); font-size: .95rem; text-align: center; }
.photo-scene { position: relative; flex: 1; min-height: 0; overflow: hidden; touch-action: none; }
.photo-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: center;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.photo-image.anime { transition: transform .2s ease-out; }
.photo-chargement {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(27, 29, 32, .85);
  color: var(--discret);
  font-size: .85rem;
  pointer-events: none;
}
.photo-fleche {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  min-height: 64px;
  padding: 0;
  background: rgba(27, 29, 32, .6);
  font-size: 1.8rem;
  line-height: 1;
}
.photo-fleche:disabled { visibility: hidden; }
.photo-fleche-g { left: 8px; }
.photo-fleche-d { right: 8px; }
@media (max-width: 699px) { .photo-fleche { display: none; } }
.photo-pied {
  padding: 8px max(var(--gouttiere), env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(var(--gouttiere), env(safe-area-inset-left));
  background: var(--fond);
  border-top: 1px solid var(--bordure);
}
.photo-pied-legende { overflow-wrap: anywhere; }
.photo-pied-info { color: var(--discret); font-size: .9rem; }
.photo-note { display: grid; gap: 6px; margin-bottom: 6px; }
.photo-note-champ {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--bordure);
  border-radius: 8px;
  background: var(--surface);
  color: var(--texte);
  font: inherit;
  font-size: 16px; /* 16 px : iOS ne zoome pas la page en touchant la boîte */
  resize: none;
}
.photo-note-champ:focus-visible { outline: 2px solid var(--accent-clair); outline-offset: 1px; }
.photo-note-bas { display: flex; align-items: center; justify-content: flex-end; gap: 10px; min-height: 0; }
.photo-note-etat { flex: 1; color: var(--discret); font-size: .9rem; overflow-wrap: anywhere; }
.photo-note-etat:empty { display: none; }
.photo-note-bas button { min-height: 40px; padding: 6px 14px; }

/* Appareil photo : l'image prend tout l'écran */
.cam { position: fixed; inset: 0; z-index: 55; background: #000; overflow: hidden; touch-action: none; }
.cam-video, .cam-apercu { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
.cam-retour {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  z-index: 2;
  background: rgba(0, 0, 0, .55);
  border: 1px solid rgba(255, 255, 255, .35);
  color: #fff;
}
.cam-declencheur {
  position: absolute;
  left: 50%;
  bottom: max(28px, calc(env(safe-area-inset-bottom) + 18px));
  z-index: 2;
  width: 80px;
  height: 80px;
  padding: 0;
  transform: translateX(-50%);
  border: 5px solid #fff;
  border-radius: 50%;
  background: rgba(255, 255, 255, .3);
}
.cam-declencheur:active { background: rgba(255, 255, 255, .7); }
/* Annuler : en haut à droite, loin du déclencheur ; l'anneau se vide pendant les 4 s */
.cam-annuler {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 3;
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  padding: 0;
  border-radius: 50%;
  background: rgba(192, 57, 43, .9);
  color: #fff;
  font-weight: 700;
}
.cam-anneau { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.cam-anneau circle {
  fill: none;
  stroke: #fff;
  stroke-width: 5;
  stroke-dasharray: 289;
  stroke-dashoffset: 0;
  animation: cam-decompte 4s linear forwards;
}
@keyframes cam-decompte { to { stroke-dashoffset: 289; } }
.cam-annuler-texte { position: relative; font-size: .95rem; }
.cam-message {
  position: absolute;
  top: 50%;
  left: 24px;
  right: 24px;
  z-index: 1;
  transform: translateY(-50%);
  color: #fff;
  text-align: center;
}
.cam-alerte {
  position: absolute;
  top: calc(max(12px, env(safe-area-inset-top)) + 56px);
  left: max(12px, env(safe-area-inset-left));
  z-index: 2;
  min-height: 40px;
  padding: 6px 14px;
  background: #c0392b;
  font-size: .9rem;
}

/* Lien qui a l'allure d'un bouton (Paramètres) */
.bouton-lien {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 18px;
  border: 1px solid var(--bordure);
  border-radius: 8px;
  color: var(--texte);
  text-decoration: none;
}
.bouton-lien:active { border-color: var(--accent); }

/* Notes de terrain */
.notes-liste { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
@media (min-width: 700px) {
  .notes-liste { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
}
.notes-liste > .etat { grid-column: 1 / -1; }
.note-carte {
  display: grid;
  align-content: start;
  gap: 4px;
  min-height: 96px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: 10px;
  color: var(--texte);
  font-weight: 400;
  text-align: left;
}
.note-carte:active { border-color: var(--accent); }
.note-titre { font-weight: 600; overflow-wrap: anywhere; }
.note-meta { color: var(--discret); font-size: .88rem; }
.note-extrait {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--texte);
  font-size: .95rem;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.note-plein, .note-edition {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 100%;
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: var(--fond);
}
.note-corps {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 20px max(var(--gouttiere), env(safe-area-inset-right)) max(32px, env(safe-area-inset-bottom)) max(var(--gouttiere), env(safe-area-inset-left));
}
.note-plein-titre { font-size: 1.35rem; line-height: 1.3; overflow-wrap: anywhere; }
.note-plein-meta { margin: 6px 0 18px; color: var(--discret); font-size: .92rem; }
.note-plein-texte { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }

.note-message { padding: 8px var(--gouttiere); background: var(--surface); color: var(--texte); overflow-wrap: anywhere; }
.note-message.erreur { color: var(--erreur); }
.note-formulaire {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 12px max(var(--gouttiere), env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(var(--gouttiere), env(safe-area-inset-left));
}
.note-champ-titre, .note-champ-texte {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--bordure);
  border-radius: 8px;
  background: var(--surface);
  color: var(--texte);
  font: inherit;
  font-size: 17px; /* 16 px et plus : pas de zoom automatique de Safari */
}
.note-champ-titre { min-height: 48px; font-weight: 600; }
.note-champ-texte { flex: 1; min-height: 120px; resize: none; line-height: 1.5; }
.note-champ-titre:focus-visible, .note-champ-texte:focus-visible { outline: 2px solid var(--accent-clair); outline-offset: 1px; }

/* Fenêtre de confirmation */
.dialogue-fond {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: var(--gouttiere);
  background: rgba(0, 0, 0, .65);
}
.dialogue {
  display: grid;
  gap: 14px;
  width: 100%;
  max-width: 440px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: 12px;
}
.dialogue-titre { font-size: 1.15rem; }
.dialogue-texte { white-space: pre-line; overflow-wrap: anywhere; }
.dialogue-erreur { color: var(--erreur); overflow-wrap: anywhere; }
.dialogue-boutons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }

@media (max-width: 520px) {
  .marque-nom, .qui { display: none; }
  .pdf-niveau { display: none; }
  .envoi-element { grid-template-columns: 56px minmax(0, 1fr); }
  .envoi-apercu { width: 56px; height: 56px; }
  .envoi-element-boutons { grid-column: 1 / -1; flex-direction: row; justify-content: flex-end; }
}

/* Pastille « Hors ligne » de l'en-tête : discrète, grise */
.hors-ligne {
  flex: none;
  padding: 3px 10px;
  border: 1px solid var(--bordure);
  border-radius: 999px;
  background: var(--surface);
  color: var(--discret);
  font-size: .82rem;
  white-space: nowrap;
}

/* Bandeau « X éléments en attente d'envoi », collé sous l'en-tête */
.attente {
  position: sticky;
  top: 61px;
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px max(var(--gouttiere), env(safe-area-inset-right)) 8px max(var(--gouttiere), env(safe-area-inset-left));
  background: #2c2a1f;
  border-bottom: 1px solid #5c5330;
  color: #f3e3a8;
}
.attente-texte { min-width: 0; font-size: .95rem; }
.attente-envoyer { flex: none; min-height: 40px; padding: 6px 14px; font-size: .95rem; }

/* Note gardée sur l'appareil, pas encore envoyée */
.note-carte.note-attente { border-style: dashed; border-color: #8a7a3e; }
.note-badge {
  justify-self: start;
  padding: 1px 8px;
  border-radius: 999px;
  background: #3b3520;
  color: #f3e3a8;
  font-size: .8rem;
}
.notes-avis { padding: 4px 0 12px; }

/* Bons de travail : section de la fiche projet et des directives */
.bt-liste { display: grid; gap: 8px; }
.bt-ligne {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--bordure);
  color: var(--texte);
  font-weight: 400;
  text-align: left;
}
.bt-ligne:active { background: var(--surface-active); }
.bt-ligne-titre { font-weight: 600; }
.bt-ligne-numerote .bt-ligne-titre { color: var(--accent-clair); }
.bt-ligne-attente { border-style: dashed; }
.bt-ligne-attente .bt-ligne-titre { color: #f3e3a8; }
.bt-ligne-info { color: var(--discret); font-size: .9rem; overflow-wrap: anywhere; }

/* Bons de travail : formulaire (pensé pour l'iPad, une colonne sur téléphone) */
.bt-form { max-width: 900px; padding-bottom: 32px; }
.bt-grille { display: grid; grid-template-columns: repeat(2, minmax(200px, 1fr)); gap: 12px; }
.bt-champ { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.bt-etiquette { color: var(--discret); font-size: .85rem; }
.bt-entree {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--bordure);
  border-radius: 8px;
  background: var(--surface);
  color: var(--texte);
  font: inherit;
}
textarea.bt-entree { min-height: 96px; resize: vertical; }
/* Safari (iPad) donne au sélecteur de date une largeur minimale propre : sans ceci, la case déborde de sa
   colonne et passe sous la case voisine. Elle reste maintenant dans sa colonne (au moins 200 px partout). */
.bt-entree[type="date"] { -webkit-appearance: none; appearance: none; display: block; min-width: 0; max-width: 100%; }
.bt-entree[type="date"]::-webkit-date-and-time-value { text-align: left; }
.bt-entree:focus { outline: 2px solid var(--accent-clair); outline-offset: 1px; }
.bt-entree:disabled { opacity: .8; }
.bt-compteur { align-self: flex-end; color: var(--discret); font-size: .8rem; }
.bt-compteur-plein { color: var(--erreur); }
.bt-choix { display: flex; gap: 10px; margin-top: 12px; }
.bt-option { background: transparent; border: 1px solid var(--bordure); color: var(--texte); font-weight: 400; }
.bt-option-active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.bt-lignes { display: grid; gap: 10px; }
.bt-ligne-materiel, .bt-ligne-mo {
  display: grid;
  gap: 10px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--bordure);
  border-radius: 10px;
}
.bt-ligne-materiel { grid-template-columns: 90px minmax(0, 1fr) 44px; }
/* Main-d'œuvre : UNE rangée sur iPad, en portrait comme en paysage. Date, heures et camion ont une largeur
   fixe et compacte ; le nom prend le reste. Sur téléphone seulement, la ligne passe sur deux rangées. */
.bt-ligne-mo {
  grid-template-columns: 100px minmax(0, 1fr) 106px 92px 62px 44px;
  grid-template-areas: "date nom reg supp cam x";
}
/* Case compacte : texte court affiché ; contrôle natif invisible posé dessus, qui s'ouvre au toucher. */
.bt-compact-boite {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 8px 8px 8px 10px;
  border: 1px solid var(--bordure);
  border-radius: 8px;
  background: var(--surface);
  color: var(--texte);
  overflow: hidden;
  white-space: nowrap;
}
.bt-compact-texte { overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.bt-compact-menu .bt-compact-boite::after { content: "▾"; margin-left: auto; color: var(--discret); font-size: .8rem; pointer-events: none; }
.bt-compact-natif {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  font-size: 16px; /* évite le zoom de Safari au toucher */
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.bt-compact-boite:focus-within { outline: 2px solid var(--accent-clair); outline-offset: 1px; }
.bt-lecture .bt-compact-boite { background: transparent; }
.bt-mo-date { grid-area: date; }
.bt-mo-nom { grid-area: nom; }
.bt-mo-reg { grid-area: reg; }
.bt-mo-supp { grid-area: supp; }
.bt-ligne-mo .bt-camion { grid-area: cam; }
.bt-ligne-mo .bt-retirer { grid-area: x; }
.bt-camion { align-items: center; }
.bt-camion input { width: 26px; height: 26px; margin: 9px 0; }
.bt-retirer { min-width: 44px; padding: 0; background: transparent; border: 1px solid var(--bordure); color: var(--discret); font-weight: 400; }
.bt-ajouter { margin-top: 10px; }
.bt-note { color: #f3e3a8; font-size: .9rem; }
.bt-signature { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; align-items: flex-start; }
.bt-toile {
  width: 100%;
  max-width: 600px;
  aspect-ratio: 600 / 180;
  background: #fff;
  border-radius: 8px;
  touch-action: none;
}
.bt-boutons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 28px; }
.bt-supprimer { margin-top: 16px; color: var(--erreur); }
.bt-rappels { margin: 8px 0 0; padding-left: 20px; color: var(--texte); }
.bt-rappels li { margin: 2px 0; }
.bt-lecture .bt-entree { background: transparent; }

@media (max-width: 700px) {
  .bt-grille { grid-template-columns: minmax(0, 1fr); }
  .bt-ligne-mo {
    grid-template-columns: 106px minmax(0, 1fr) 62px 44px;
    grid-template-areas: "date nom nom x" "reg supp cam cam";
  }
  .bt-ligne-materiel { grid-template-columns: 70px minmax(0, 1fr) 44px; }
}

/* ---------- Bons de commande ---------- */
.bc-form { max-width: 760px; }
.bc-entete {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 20px;
  margin: 0 0 20px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: 10px;
}
.bc-entete-ligne { min-width: 0; }
.bc-entete dt { color: var(--discret); font-size: .85rem; }
.bc-entete dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.bc-service { margin-bottom: 20px; }
.bc-service { margin-bottom: 20px; }
.bc-materiel { min-height: 14em; resize: vertical; line-height: 1.45; font-family: inherit; }
.bc-materiel-lu {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--bordure);
  border-radius: 8px;
  font: inherit;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.bc-statut { padding: 0 0 16px; }
.bc-titre-numerote { color: var(--accent-clair); }
.bc-ligne-titre { display: flex; align-items: center; gap: 8px; }
.bc-moi {
  padding: 0 7px;
  border: 1px solid var(--bordure);
  border-radius: 999px;
  color: var(--discret);
  font-size: .75rem;
  font-weight: 400;
  line-height: 1.5;
}
.bc-ligne-annulee .bt-ligne-titre > span:first-child { color: var(--discret); text-decoration: line-through; }

/* Après l'envoi : « Nous procédons à votre commande… », puis le numéro avec un crochet bleu. */
.bc-suivi { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 48px 0 8px; text-align: center; }
.bc-suivi-marque {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  font-size: 40px;
  font-weight: 700;
  line-height: 1;
}
.bc-suivi-attente { border: 4px solid var(--bordure); border-top-color: var(--accent); animation: bc-tourne 1s linear infinite; }
.bc-suivi-fait { background: var(--accent); color: #fff; }
.bc-suivi-avis { border: 3px solid #f3e3a8; color: #f3e3a8; }
.bc-suivi-titre { margin: 8px 0 0; font-size: 1.6rem; font-weight: 700; }
.bc-suivi-detail { max-width: 460px; margin: 0; color: var(--discret); }
.bc-suivi-boutons { justify-content: center; }
@keyframes bc-tourne { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .bc-suivi-attente { animation: none; } }

@media (max-width: 700px) {
  .bc-entete { grid-template-columns: minmax(0, 1fr); }
}
