/* Feuille de style unique pour le formulaire public et le back-office.
   Objectif : lisible, rapide, utilisable au pouce sur un téléphone. */

:root {
  --texte: #16181d;
  --texte-doux: #5b6270;
  --fond: #ffffff;
  --fond-doux: #f5f6f8;
  --bord: #d8dbe2;
  --bord-fort: #b3b8c2;
  --accent: #b3261e;
  --accent-fond: #fdeceb;
  --ok: #1a6b3c;
  --ok-fond: #e8f4ed;
  --focus: #1c5ed6;
  --rayon: 8px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  color: var(--texte);
  background: var(--fond);
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 .4em; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.15rem; }
p  { margin: 0 0 1em; }
a  { color: var(--focus); }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.enveloppe { max-width: 720px; margin: 0 auto; padding: 0 16px 64px; }
.large     { max-width: 1400px; }

/* ---------- En-tête ---------- */
.bandeau {
  background: var(--fond-doux);
  border-bottom: 1px solid var(--bord);
  padding: 20px 16px;
  margin-bottom: 20px;
}
.bandeau .enveloppe { padding: 0; }
.bandeau p { margin: 0; color: var(--texte-doux); font-size: .95rem; }

.encart {
  background: var(--accent-fond);
  border: 1px solid var(--accent);
  border-radius: var(--rayon);
  padding: 12px 14px;
  margin: 0 0 24px;
  font-size: .95rem;
}
.encart strong { color: var(--accent); }

/* ---------- Formulaire ---------- */
fieldset {
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  padding: 16px;
  margin: 0 0 20px;
  /* Sans ça un fieldset refuse de passer sous la largeur minimale de son
     contenu et déborde de l'écran sur les petits téléphones. */
  min-width: 0;
}
legend {
  font-weight: 600;
  padding: 0 6px;
  font-size: 1.05rem;
}
.aide { color: var(--texte-doux); font-size: .875rem; margin: -4px 0 14px; }

label { display: block; font-weight: 500; margin-bottom: 4px; }
.champ { margin-bottom: 16px; }
.champ:last-child { margin-bottom: 0; }

input[type=text], input[type=tel], input[type=email], input[type=date],
input[type=password], input[type=search], select, textarea {
  width: 100%;
  font: inherit;
  color: inherit;
  background: var(--fond);
  padding: 11px 12px;
  border: 1px solid var(--bord-fort);
  border-radius: var(--rayon);
}
textarea { min-height: 90px; resize: vertical; }
select { appearance: none; background-image: none; }

.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .duo { grid-template-columns: 1fr; gap: 0; } }

.obligatoire { color: var(--accent); }

/* Cases à cocher en grille, cible tactile large */
.grille {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 8px;
}
.case {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  cursor: pointer;
  font-weight: 400;
  margin: 0;
  background: var(--fond);
}
.case:hover { background: var(--fond-doux); }
.case input { width: 20px; height: 20px; margin: 1px 0 0; flex: 0 0 auto; accent-color: var(--focus); }
.case.coche { border-color: var(--focus); background: #eef3fd; }
.case span { flex: 1; }

.case-large { font-size: 1.05rem; font-weight: 600; padding: 14px; }

.qte { margin: 6px 0 2px 30px; }
/* 16px minimum : en dessous, iOS zoome tout seul dès qu'on touche le champ. */
.qte input { padding: 10px; font-size: 16px; }
.qte label { font-size: .85rem; color: var(--texte-doux); font-weight: 400; }

.masque { display: none; }
.honeypot { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Boutons ---------- */
button, .bouton {
  font: inherit;
  font-weight: 600;
  padding: 12px 18px;
  border-radius: var(--rayon);
  border: 1px solid var(--bord-fort);
  background: var(--fond);
  color: var(--texte);
  cursor: pointer;
}
button:hover { background: var(--fond-doux); }
.principal {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  width: 100%;
  padding: 16px;
  font-size: 1.1rem;
}
.principal:hover { background: #8e1e18; }
.principal:disabled { background: var(--bord-fort); border-color: var(--bord-fort); cursor: wait; }
.mini { padding: 6px 10px; font-size: .85rem; font-weight: 500; }

.erreur {
  background: var(--accent-fond);
  border: 1px solid var(--accent);
  color: #7d1a15;
  border-radius: var(--rayon);
  padding: 12px 14px;
  margin-bottom: 16px;
}
.succes {
  background: var(--ok-fond);
  border: 1px solid var(--ok);
  border-radius: var(--rayon);
  padding: 24px;
  text-align: center;
}
.succes h2 { color: var(--ok); }

/* ---------- Back-office ---------- */
.barre {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--fond);
  border-bottom: 1px solid var(--bord);
  padding: 10px 16px;
}
.barre-ligne {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  max-width: 1400px;
  margin: 0 auto;
}
.barre input[type=search] { flex: 1 1 240px; min-width: 0; }
.barre select { width: auto; flex: 0 0 auto; padding: 9px 10px; }

.compteurs {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: .9rem;
  color: var(--texte-doux);
  padding: 10px 0;
}
.compteurs b { color: var(--texte); font-size: 1.05rem; }

.puces { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 0 14px; }
.puce {
  font-size: .85rem;
  padding: 5px 10px;
  border: 1px solid var(--bord);
  border-radius: 999px;
  background: var(--fond);
  cursor: pointer;
  white-space: nowrap;
}
.puce b { font-variant-numeric: tabular-nums; color: var(--texte-doux); font-weight: 600; }
.puce.active { background: var(--texte); color: #fff; border-color: var(--texte); }
.puce.active b { color: #fff; }

.fiche {
  border: 1px solid var(--bord);
  border-left: 4px solid var(--bord-fort);
  border-radius: var(--rayon);
  margin-bottom: 10px;
  background: var(--fond);
}
.fiche.neuve { border-left-color: var(--accent); }
.fiche-tete {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: baseline;
  padding: 12px 14px;
  cursor: pointer;
}
.fiche-tete:hover { background: var(--fond-doux); }
.fiche-nom { font-weight: 600; font-size: 1.05rem; }
.fiche-meta { color: var(--texte-doux); font-size: .875rem; }
.fiche-resume { flex-basis: 100%; font-size: .9rem; color: var(--texte-doux); }
.fiche-corps { padding: 0 14px 14px; border-top: 1px solid var(--bord); padding-top: 14px; }

.etiquette {
  display: inline-block;
  font-size: .78rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--fond-doux);
  border: 1px solid var(--bord);
  white-space: nowrap;
}
.st-nouvelle       { background: #e7effc; border-color: #9dbdf0; color: #123a7a; }
.st-contactee      { background: #f0e9fb; border-color: #c2ade8; color: #4a2a86; }
.st-en_cours       { background: #fdf0e0; border-color: #eec48a; color: #7a4a10; }
.st-mobilisee      { background: var(--ok-fond); border-color: #8dc5a5; color: var(--ok); }
.st-terminee       { background: var(--fond-doux); color: var(--texte-doux); }
.st-non_pertinente { background: var(--fond-doux); color: var(--texte-doux); text-decoration: line-through; }

.tags { display: flex; flex-wrap: wrap; gap: 5px; margin: 2px 0; }
.tag {
  font-size: .82rem;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--fond-doux);
  border: 1px solid var(--bord);
}
.tag b { font-weight: 700; }

.detail { display: grid; grid-template-columns: 150px 1fr; gap: 4px 14px; font-size: .93rem; margin-bottom: 14px; }
.detail dt { color: var(--texte-doux); }
.detail dd { margin: 0; }
@media (max-width: 560px) {
  .detail { grid-template-columns: 1fr; gap: 0 0; }
  .detail dt { margin-top: 8px; font-size: .82rem; }
}

.actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.actions .separateur { width: 1px; height: 24px; background: var(--bord); margin: 0 4px; }

.vide { text-align: center; color: var(--texte-doux); padding: 48px 16px; }

.pastille {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ok);
  margin-right: 5px;
  vertical-align: middle;
}
.pastille.hs { background: var(--bord-fort); }

.connexion { max-width: 380px; margin: 12vh auto; padding: 0 16px; }

/* =====================================================================
   Adaptation téléphone.
   Ce bloc doit rester en fin de fichier : à spécificité égale, c'est la
   dernière règle qui gagne, et il doit écraser celles du dessus.
   ===================================================================== */
@media (max-width: 760px) {

  /* La barre collante mangeait la moitié de l'écran, elle défile désormais. */
  .barre { position: static; padding: 8px 12px; }
  .barre-ligne { gap: 6px; }

  /* 16px minimum sur les champs, sinon iOS zoome dès qu'on les touche. */
  .barre select { font-size: 16px; padding: 10px 8px; max-width: 100%; }
  .barre input[type=search] { flex: 1 1 100%; padding: 11px 10px; }

  /* Cibles tactiles d'au moins 44px, doigt et non souris. */
  .mini { min-height: 44px; padding: 10px 12px; font-size: .88rem; }
  .puce {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 8px 13px;
    font-size: .88rem;
    /* Un libellé plus long que l'écran doit pouvoir revenir à la ligne,
       sinon il déborde et fait défiler la page horizontalement. */
    white-space: normal;
    max-width: 100%;
    text-align: left;
  }

  .fiche-tete { padding: 14px; }
  .actions { gap: 8px; }
  .compteurs { gap: 10px; font-size: .88rem; }
}

@media print {
  .barre, .puces, .actions, .no-print { display: none !important; }
  .fiche { break-inside: avoid; border: 1px solid #999; }
  .fiche-corps { display: block !important; }
}
