/* Pensé d'abord pour un petit téléphone (320 px de large). */

:root {
  --bg: #f2f7f4; --accent: #2d7a4f; --accent-light: #7ab899;
  --text: #1a2618; --muted: #7a9070; --red: #c0616a;
  --red-pale: #f9e6e8; --blanc: #fff;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.35;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) calc(14px + env(safe-area-inset-right))
           calc(24px + env(safe-area-inset-bottom)) calc(14px + env(safe-area-inset-left));
}

h1 {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  font-size: 32px;
  font-weight: 600;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: .55; cursor: default; }

/* --- Boutons --- */

.bouton {
  display: block; width: 100%; min-height: 54px; padding: 12px 14px;
  font-weight: 600; color: var(--blanc);
  background: var(--accent); border: 1px solid var(--accent); border-radius: 12px;
}
.bouton.secondaire { color: var(--accent); background: var(--blanc); }
.bouton.danger { color: var(--red); background: var(--blanc); border-color: var(--red); }
.bouton.danger-plein { color: var(--blanc); background: var(--red); border-color: var(--red); }

.retour {
  min-height: 48px; padding: 8px 8px 8px 0; margin-bottom: 4px;
  color: var(--accent); font-weight: 600; background: none; border: 0;
}

/* --- Écran du code --- */

.ecran-code { padding-top: 32px; }
.ecran-code h1 { margin-bottom: 20px; }
.ecran-code .aide {
  padding: 12px; margin: 0 0 18px;
  background: var(--blanc); border-left: 4px solid var(--accent-light); border-radius: 8px;
}
.ecran-code input { letter-spacing: 2px; text-transform: uppercase; }

/* --- Accueil --- */

.prenom { margin: 2px 0 14px; color: #56664f; overflow-wrap: anywhere; }

.moyens { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.moyen {
  min-height: 96px; padding: 8px 2px;
  font-size: 19px; font-weight: 700; color: var(--blanc);
  background: var(--accent); border: 0; border-radius: 14px;
}
.moyen:active { background: #236340; }

.vide { margin: 22px 8px; color: #56664f; text-align: center; }

.ticket {
  display: block; width: 100%; padding: 12px 14px; margin-bottom: 8px;
  text-align: left; background: var(--blanc);
  border: 2px solid transparent; border-radius: 12px;
}
.ticket.alerte-normale { border-color: var(--red); }
.ticket.alerte-forte { background: var(--red-pale); border-color: var(--red); }
.ticket-titre { font-weight: 600; overflow-wrap: anywhere; }
.ticket-sous-titre { margin-top: 2px; font-size: 15px; color: #56664f; overflow-wrap: anywhere; }

.badge { display: inline-block; margin-top: 6px; font-size: 14px; font-weight: 600; color: var(--accent); }
.badge.A_COMPLETER { color: #a8424c; }
.badge.EN_LECTURE { color: #56664f; }

/* --- Messages --- */

.message {
  padding: 12px 14px; margin-bottom: 12px;
  font-weight: 600; border-radius: 10px; overflow-wrap: anywhere;
}
.message.ok { color: var(--blanc); background: var(--accent); }
.message.info { background: var(--red-pale); color: #7c2e37; }
.message.attente { color: #7a4d00; background: #fff4dc; }

/* La zone reste en haut de l'écran pendant qu'on fait défiler : impossible à manquer. */
.bandeaux, #message-fiche {
  position: sticky; top: calc(8px + env(safe-area-inset-top)); z-index: 5;
}
.message.erreur {
  color: var(--blanc); background: #a8424c;
  box-shadow: 0 2px 10px rgba(26, 38, 24, .35);
}

.erreur-code { min-height: 1.4em; margin: 12px 0 0; font-weight: 600; color: #a8424c; }
.ecran-code .erreur-code:empty { display: none; }

/* --- Fiche du ticket --- */

.en-tete-fiche { margin-bottom: 12px; }

/* La photo en entier : on lit le ticket en faisant défiler, sans l'ouvrir à chaque case. */
.photos { display: grid; gap: 8px; margin-bottom: 14px; }
.photo {
  width: 100%; min-height: 150px; padding: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 15px;
  background: var(--blanc); border: 0; border-radius: 10px;
}
.photo img { display: block; width: 100%; height: auto; }

fieldset { min-width: 0; padding: 0; margin: 0; border: 0; }

.champ { display: block; margin-bottom: 12px; }
.champ-titre { display: block; margin-bottom: 4px; font-weight: 600; }
.a-verifier { margin-left: 6px; font-size: 14px; color: #a8424c; }

input[type="text"], input[type="date"] {
  display: block; width: 100%; min-height: 50px; padding: 10px 12px;
  /* 16 px au moins : en dessous, l'iPhone zoome tout seul sur la case. */
  font-size: 17px;
  background: var(--blanc); border: 1px solid var(--accent-light); border-radius: 10px;
  -webkit-appearance: none; appearance: none;
}
.en-defaut input { border: 2px solid var(--red); }
input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.montant-bon { margin: -4px 0 12px; }

.choix-moyen { margin: 0 0 12px; }
.choix-moyen-boutons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.choix-moyen label { display: block; }
.choix-moyen input { position: absolute; opacity: 0; width: 0; height: 0; }
.choix-moyen-boutons span {
  display: flex; align-items: center; justify-content: center; min-height: 50px;
  font-weight: 600; color: var(--accent);
  background: var(--blanc); border: 1px solid var(--accent-light); border-radius: 10px;
}
.choix-moyen input:checked + span { color: var(--blanc); background: var(--accent); border-color: var(--accent); }
.choix-moyen input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

details { margin-bottom: 14px; }
summary { min-height: 44px; padding: 10px 0; font-weight: 600; color: var(--accent); cursor: pointer; }

.actions { display: grid; gap: 10px; margin-top: 8px; }

fieldset:disabled input, fieldset:disabled span { opacity: .55; }
.lecture-en-cours { margin: 0 0 12px; font-weight: 600; color: #56664f; }

/* --- Fenêtres --- */

.voile {
  position: fixed; inset: 0; z-index: 20; padding: 16px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(26, 38, 24, .55);
}
.boite { width: 100%; max-width: 360px; padding: 18px; background: var(--blanc); border-radius: 14px; }
.boite p { margin: 0 0 16px; }
.boite-boutons { display: grid; gap: 8px; }

.plein-ecran { position: fixed; inset: 0; z-index: 30; overflow: auto; background: #000; }
.plein-ecran img { display: block; width: 100%; height: auto; }
.plein-ecran .fermer {
  position: fixed; right: 12px; top: calc(12px + env(safe-area-inset-top));
  min-height: 48px; padding: 8px 14px; font-weight: 600;
  color: var(--text); background: var(--blanc); border: 0; border-radius: 10px;
}

/* --- File d'envoi --- */

.compteur {
  display: block; width: 100%; min-height: 48px; padding: 10px 14px; margin-bottom: 8px;
  text-align: left; font-weight: 600; color: var(--accent);
  background: var(--blanc); border: 1px solid var(--accent-light); border-radius: 10px;
}
.compteur.attente { color: #7a4d00; background: #fff4dc; border-color: #d9a441; }
.compteur.action { color: var(--blanc); background: #a8424c; border-color: #a8424c; }

.conseil { margin: 0 0 10px; font-size: 15px; color: #56664f; }
.autres { margin: 0 0 10px; font-size: 15px; font-weight: 600; color: #56664f; }

.deuxieme {
  min-height: 44px; padding: 8px 12px; font-weight: 600; color: var(--accent);
  background: var(--blanc); border: 1px solid var(--accent-light); border-radius: 10px;
}
.message .deuxieme { display: block; width: 100%; margin-top: 8px; }
.bandeaux { max-height: 55vh; overflow-y: auto; }
.alerte-ligne { margin-top: 4px; font-weight: 400; }

.element {
  display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 10px;
  padding: 10px; margin-bottom: 10px; background: var(--blanc); border-radius: 12px;
}
.element img { display: block; width: 76px; height: 96px; object-fit: cover; border-radius: 8px; background: var(--bg); }
.element-etat { font-weight: 600; }
.element-message { margin-top: 4px; font-size: 15px; color: #7c2e37; overflow-wrap: anywhere; }
.element-details { margin-top: 2px; font-size: 15px; color: #56664f; }
.element .actions { grid-column: 1 / -1; margin-top: 0; }
.element-photos { display: grid; gap: 6px; align-content: start; }
.voile-perte { z-index: 110; }   /* au-dessus du masque : l'alerte ne montre aucune donnée */
/* Stockage plein : reste visible sur tous les écrans, sans gêner les boutons. */
#perte-non-ecrite {
  position: fixed; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 105;
  padding: 10px 12px; font-size: 15px; font-weight: 600; color: var(--blanc); background: #a8424c;
  border-radius: 10px; pointer-events: none;
}
/* Recouvre tout en arrière-plan : au-dessus de tout le reste, sans aucune donnée. */
.masque {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 24px; text-align: center; color: var(--muted); background: var(--bg);
}
