:root {
  --bleu: #0b3d91;
  --vert: #0a7d2c;
  --orange: #d96c00;
  --rouge: #c4161c;
  --texte: #111;
  --fond: #fff;
  --gris: #f2f4f7;
}

*, *::before, *::after { box-sizing: border-box; }

html { font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; font-size: 20px; line-height: 1.4; color: var(--texte); background-color: var(--fond); }
body { margin: 0; padding-bottom: env(safe-area-inset-bottom); -webkit-tap-highlight-color: transparent; }

.cache { display: none !important; }
.centre { text-align: center; }

.ecran {
  display: flex;
  flex-direction: column;
  padding: 16px;
  max-width: 720px;
  margin: 0 auto;
  /* Espace suffisant pour la barre de navigation fixe */
  padding-bottom: 95px;
}
/* Exception tableau admin sur grand écran */
.ecran.tableau { max-width: 1400px; }

.titre { font-size: 28px; font-weight: bold; margin: 0 0 16px 0; line-height: 1.2; }
.phrase { font-size: 22px; margin: 0 0 16px 0; line-height: 1.3; }
.icone { display: block; width: 64px; height: 64px; text-align: center; line-height: 64px; font-size: 64px; margin: 0 auto 16px auto; }

/* Boutons principaux */
.gros-bouton {
  width: 100%;
  min-height: 120px;
  font-size: 30px;
  font-weight: bold;
  border-radius: 20px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.25);
  background-color: var(--bleu);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s ease;
}
.gros-bouton:active { transform: scale(0.98); }
.gros-bouton:focus-visible { outline: 4px solid #ffd400; outline-offset: 2px; }

.vert { background-color: var(--vert) !important; }
.orange { background-color: var(--orange) !important; }
.rouge { background-color: var(--rouge) !important; }

.bouton {
  min-height: 64px;
  font-size: 22px;
  font-weight: bold;
  width: 100%;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.bouton-secondaire {
  background-color: #fff;
  border: 3px solid var(--bleu);
  color: var(--bleu);
}
/* Accessibilité focus commune */
.gros-bouton:focus-visible, .bouton:focus-visible, .micro:focus-visible, .annuler:focus-visible { outline: 4px solid #ffd400; outline-offset: 2px; }

.grille {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
@media (min-width: 700px) { .grille { grid-template-columns: repeat(3, 1fr); } }

.grille button, .grille [role="button"] {
  aspect-ratio: 1 / 1;
  min-height: 100px;
  font-size: inherit;
  border-radius: 16px;
}
/* Réutilisation pour pavé numérique */
.grille.pave-numerique button, .grille.pave-numerique [role="button"] {
  min-height: 80px;
  font-size: 36px;
}

.barre-bas {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: #fff;
  border-top: 1px solid var(--gris);
  display: flex;
  overflow-x: auto;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 100;
}
.barre-bas button {
  flex: 0 0 auto;
  width: 72px;
  height: 84px; /* 72px + espace libellé */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
}
.barre-bas button span { font-size: 14px; margin-top: 2px; color: var(--texte); }

.liste { list-style: none; padding: 0; margin: 0; }
.ligne {
  min-height: 72px;
  display: flex;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--gris);
}
input[type="checkbox"] {
  width: 36px;
  height: 36px;
  accent-color: var(--vert);
  margin-right: 16px;
  cursor: pointer;
}

.carte {
  background-color: #fff;
  border: 2px solid var(--gris);
  border-radius: 16px;
  margin: 12px 0;
  padding: 16px;
}
.carte.vert { border-left: 10px solid var(--vert); }
.carte.orange { border-left: 10px solid var(--orange); }
.carte.rouge { border-left: 10px solid var(--rouge); }

.champ {
  width: 100%;
  font-size: 24px;
  padding: 16px;
  border: 3px solid var(--gris);
  border-radius: 12px;
  margin-bottom: 16px;
}
.champ:focus { border-color: var(--bleu); outline: none; }

.micro {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background-color: #ffcccc; /* rouge clair */
  color: var(--rouge);
  font-size: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
}
.micro.actif {
  background-color: var(--rouge);
  color: #fff;
  animation: pulse 1.5s infinite ease-in-out;
}
@keyframes pulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(196, 22, 28, 0.7); }
  70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(196, 22, 28, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(196, 22, 28, 0); }
}
@media (prefers-reduced-motion: reduce) { .micro.actif { animation: none; border: 4px solid var(--rouge); } }

.toast {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background-color: var(--vert);
  color: #fff;
  font-size: 24px;
  font-weight: bold;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 200;
}
.toast.rouge { background-color: var(--rouge); }

.annuler {
  background-color: #fff;
  color: var(--texte);
  border: 2px solid var(--gris);
  padding: 8px 16px;
  font-size: 18px;
  border-radius: 8px;
  cursor: pointer;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: bold;
  color: #fff;
}
.badge.vert { background-color: var(--vert); }
.badge.orange { background-color: var(--orange); }
.badge.rouge { background-color: var(--rouge); }

.tableau-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tableau {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
  min-width: 650px; /* Force le défilement horizontal sur mobile */
}
.tableau th, .tableau td { padding: 12px; text-align: left; border-bottom: 1px solid var(--gris); }
.tableau thead th { position: sticky; top: 0; background-color: #fff; font-weight: bold; z-index: 5; }
.tableau tbody tr:nth-child(even) { background-color: var(--gris); }

.onglets { display: flex; overflow-x: auto; border-bottom: 2px solid var(--gris); margin-bottom: 16px; padding-bottom: 0; }
.onglet { padding: 12px 20px; cursor: pointer; font-weight: bold; color: var(--texte); border-bottom: 4px solid transparent; white-space: nowrap; }
.onglet.actif { border-bottom-color: var(--bleu); color: var(--bleu); }

.video-camera {
  position: fixed;
  inset: 0;
  background-color: #000;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
}
.video-camera video, .video-camera canvas { width: 100%; height: 100%; object-fit: cover; }
/* Bouton de capture rond centré en bas */
.video-camera .gros-bouton.capturer {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background-color: #fff;
  color: var(--rouge);
}

.photo-apercu { max-width: 360px; width: 100%; height: auto; border-radius: 12px; display: block; margin: 0 auto; }

@media print {
  .barre-bas, .onglets { display: none !important; }
  body { background: #fff; color: #000; }
  .ecran { max-width: 100%; padding-bottom: 0; }
}
