/* -----------------------------------------------------------------
   Palette et typographie reprises des outils internes existants
   (admin-pension, agenda), pour que l'ensemble reste homogene.
   Mobile d'abord : tout est dimensionne pour une main, l'ecran large
   se contente d'elargir le conteneur.
   ----------------------------------------------------------------- */

:root {
  --bg: #F9FAF7;
  --bg2: #E8ECE8;
  --dark: #4d5c4e;
  --sage: #617462;
  --gold: #D4A574;
  --gold-dark: #b8895a;
  --text: #2a342b;
  --muted: #7a8c7b;
  --white: #ffffff;
  --red: #c0392b;
  --amber: #b8860b;
  --green: #2d6a4f;
  --border: rgba(77, 92, 78, .15);
  --ombre: 0 4px 24px rgba(77, 92, 78, .10);
  --ombre-forte: 0 12px 48px rgba(77, 92, 78, .18);
  --rayon: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 16px;             /* jamais moins : evite le zoom auto iOS */
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

/* ---------------------------------------------------------- connexion */

.fond-connexion {
  display: flex; align-items: center; justify-content: center;
  background: var(--dark);
  background-image: radial-gradient(ellipse at 30% 50%, rgba(212, 165, 116, .12) 0%, transparent 60%);
  padding: 24px;
}
.carte-connexion {
  background: var(--white); border-radius: 16px; padding: 40px 28px;
  width: 100%; max-width: 360px; box-shadow: var(--ombre-forte);
}
.marque-connexion { font-size: 28px; font-weight: 600; color: var(--dark); text-align: center; }
.sous-marque {
  font-size: 12px; color: var(--muted); letter-spacing: 2px; text-transform: uppercase;
  text-align: center; margin: 4px 0 28px;
}
.carte-connexion input { margin-bottom: 20px; }
.erreur-connexion { color: var(--red); font-size: 14px; text-align: center; margin-top: 14px; }

/* ------------------------------------------------------------ chrome */

.entete {
  background: var(--dark); color: var(--white);
  padding: 14px 16px; padding-top: max(14px, env(safe-area-inset-top));
  display: flex; align-items: center; gap: 10px;
}
.marque { font-size: 18px; font-weight: 600; color: var(--white); text-decoration: none; }
.badge {
  background: rgba(212, 165, 116, .2); border: 1px solid var(--gold); color: var(--gold);
  font-size: 10px; font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase;
  padding: 3px 8px; border-radius: 20px;
}
.deconnexion { margin-left: auto; }
.deconnexion button {
  background: none; border: 1px solid rgba(255, 255, 255, .3); color: rgba(255, 255, 255, .85);
  font: inherit; font-size: 13px; padding: 5px 12px; border-radius: 6px; cursor: pointer;
}

.onglets {
  display: flex; overflow-x: auto; background: var(--white);
  border-bottom: 1px solid var(--border); -webkit-overflow-scrolling: touch;
}
.onglets a {
  flex: 0 0 auto; padding: 13px 16px; font-size: 14px; font-weight: 500;
  color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.onglets a.on { color: var(--dark); border-bottom-color: var(--gold); }

main { max-width: 720px; margin: 0 auto; padding: 20px 16px 64px; }
main a { color: var(--sage); text-decoration-color: var(--border); text-underline-offset: 3px; }
main a:hover { color: var(--dark); }
.retour { display: inline-block; margin-bottom: 16px; font-size: 14px; }

/* ------------------------------------------------------------ blocs */

h1 { font-size: 24px; color: var(--dark); margin-bottom: 4px; font-weight: 600; }
h2 { font-size: 17px; color: var(--dark); margin: 24px 0 10px; font-weight: 600; }
.sous-titre { color: var(--muted); font-size: 14px; margin-bottom: 20px; }

.carte {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--rayon);
  padding: 16px; margin-bottom: 14px; box-shadow: var(--ombre);
}
.carte-titre {
  font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 1px;
  text-transform: uppercase; margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
.carte-titre::before {
  content: ''; width: 3px; height: 13px; background: var(--gold); border-radius: 2px;
}

.bandeau { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; }
.bandeau.ok { background: rgba(45, 106, 79, .1); color: var(--green); border: 1px solid rgba(45, 106, 79, .25); }
.bandeau.ko { background: rgba(192, 57, 43, .08); color: var(--red); border: 1px solid rgba(192, 57, 43, .25); }

.vide { color: var(--muted); font-style: italic; padding: 20px 0; text-align: center; }

/* ------------------------------------------------------------ listes */

.liste { list-style: none; }
.liste li { border-bottom: 1px solid var(--border); }
.liste li:last-child { border-bottom: none; }
.liste a {
  display: flex; align-items: center; gap: 10px; padding: 14px 4px;
  text-decoration: none; color: var(--text);
}
.liste .nom { font-weight: 600; }
.liste .detail { font-size: 13px; color: var(--muted); }
.liste .fleche { margin-left: auto; color: var(--muted); }

/* ------------------------------------------------------------ pastilles */

.pastille {
  display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .4px;
  padding: 3px 9px; border-radius: 20px; text-transform: uppercase;
}
.pastille.actif        { background: rgba(45, 106, 79, .12);  color: var(--green); }
.pastille.a_verifier   { background: rgba(184, 134, 11, .14); color: var(--amber); }
.pastille.archive      { background: var(--bg2);              color: var(--muted); }
.pastille.a_venir      { background: rgba(212, 165, 116, .18); color: var(--gold-dark); }
.pastille.en_cours     { background: rgba(45, 106, 79, .12);  color: var(--green); }
.pastille.termine      { background: var(--bg2);              color: var(--muted); }
.pastille.annule       { background: rgba(192, 57, 43, .08);  color: var(--red); }
.pastille.orphelin     { background: rgba(192, 57, 43, .12);  color: var(--red); }
.pastille.brouillon    { background: rgba(184, 134, 11, .14); color: var(--amber); }
.pastille.validee      { background: rgba(45, 106, 79, .12);  color: var(--green); }

.niveau-ras       { color: var(--green); }
.niveau-vigilance { color: var(--amber); }
.niveau-probleme  { color: var(--red); }
.niveau-non_renseigne { color: var(--muted); }

/* ------------------------------------------------------------ formulaires */

label {
  display: block; font-size: 12px; font-weight: 600; color: var(--muted);
  letter-spacing: .6px; text-transform: uppercase; margin-bottom: 6px;
}
input[type=text], input[type=search], input[type=password], input[type=date], select, textarea {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: 9px;
  font: inherit; font-size: 16px; color: var(--text); background: var(--bg);
  outline: none; transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); background: var(--white); }
textarea { resize: vertical; min-height: 76px; line-height: 1.5; }
.champ { margin-bottom: 16px; }

button, .bouton {
  font: inherit; font-size: 15px; font-weight: 600; border-radius: 10px;
  padding: 13px 20px; border: none; cursor: pointer; display: inline-block;
  text-align: center; text-decoration: none;
}
.principal { width: 100%; background: var(--dark); color: var(--white); }
.principal:hover { background: var(--sage); }
.secondaire { background: transparent; color: var(--muted); border: 1.5px solid var(--border); }
.danger { background: rgba(192, 57, 43, .08); color: var(--red); border: 1.5px solid rgba(192, 57, 43, .3); }
button:disabled { opacity: .5; cursor: not-allowed; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.actions > * { flex: 1 1 auto; }

/* Choix de niveau : cibles tactiles larges, lisibles debout. */
.niveaux { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.niveaux input { position: absolute; opacity: 0; pointer-events: none; }
.niveaux label {
  margin: 0; padding: 11px 4px; text-align: center; border: 1.5px solid var(--border);
  border-radius: 9px; background: var(--white); font-size: 11px; letter-spacing: 0;
  text-transform: none; font-weight: 600; color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center; min-height: 46px;
}
.niveaux input:checked + label { border-color: currentColor; }
.niveaux input:checked + label.n-ras       { background: rgba(45, 106, 79, .12);  color: var(--green); }
.niveaux input:checked + label.n-vigilance { background: rgba(184, 134, 11, .14); color: var(--amber); }
.niveaux input:checked + label.n-probleme  { background: rgba(192, 57, 43, .10);  color: var(--red); }
.niveaux input:checked + label.n-non_renseigne { background: var(--bg2); color: var(--muted); }
.niveaux input:focus-visible + label { outline: 2px solid var(--gold); outline-offset: 2px; }

.categorie { border-bottom: 1px solid var(--border); padding: 16px 0; }
.categorie:last-child { border-bottom: none; }
.categorie h3 { font-size: 15px; font-weight: 600; margin-bottom: 10px; color: var(--text); }
.categorie textarea { margin-top: 8px; }

/* ------------------------------------------------------------ tableaux de synthese */

.paires { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.paires dt { color: var(--muted); }
.paires dd { font-weight: 500; word-break: break-word; }

.compteurs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.compteur {
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px; text-align: center;
}
.compteur .n { font-size: 22px; font-weight: 700; color: var(--dark); display: block; }
.compteur .l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }

.extrait { font-size: 13px; color: var(--muted); }
mark { background: rgba(212, 165, 116, .35); color: inherit; padding: 0 2px; border-radius: 3px; }

@media (min-width: 620px) {
  main { padding: 28px 24px 64px; }
  h1 { font-size: 30px; }
  .carte { padding: 22px; }
  .compteurs { grid-template-columns: repeat(4, 1fr); }
  .actions > * { flex: 0 1 auto; }
  .principal { width: auto; min-width: 200px; }
}

/* ------------------------------------------------------- journal du jour */

.journal {
  background: var(--white); border: 1px solid var(--border); border-left: 4px solid var(--sage);
  border-radius: var(--rayon); padding: 14px 16px; margin-bottom: 20px; box-shadow: var(--ombre);
}
.journal.a-faire { border-left-color: var(--gold); background: rgba(212, 165, 116, .06); }
.journal-ligne {
  display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline;
  justify-content: space-between; font-size: 15px;
}
.journal-ligne strong { color: var(--dark); }
.journal-ligne span { color: var(--muted); font-size: 14px; }
.journal-detail { font-size: 13px; color: var(--muted); margin-top: 6px; }
.journal-action { margin-top: 14px; width: 100%; }
.journal-retard {
  display: block; margin-top: 12px; font-size: 13px; font-weight: 600; color: var(--red);
  text-decoration: none;
}

/* ------------------------------------------------------- etats de suivi */

.carte.alerte { border-color: rgba(184, 134, 11, .4); }

.pastille.signe               { background: rgba(45, 106, 79, .12);  color: var(--green); }
.pastille.contrat_envoye      { background: rgba(212, 165, 116, .18); color: var(--gold-dark); }
.pastille.attente_formulaire  { background: var(--bg2);              color: var(--muted); }
.pastille.abandonnee          { background: var(--bg2);              color: var(--muted); }
.pastille.echec               { background: rgba(192, 57, 43, .12);  color: var(--red); }

.paires dd.manquant { color: var(--red); font-style: italic; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; background: var(--bg2); padding: 1px 5px; border-radius: 4px;
}

@media (min-width: 620px) {
  .journal-action { width: auto; }
}

/* ------------------------------------------------- etiquettes discretes */

.etiquettes {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin: -8px 0 18px;
}
.etiquettes-libelle {
  font-size: 11px; font-weight: 600; letter-spacing: .8px; text-transform: uppercase;
  color: var(--muted); margin-right: 2px;
}
.etiquette {
  display: inline-flex; align-items: baseline; gap: 5px;
  background: var(--bg2); color: var(--text); text-decoration: none;
  font-size: 12px; font-weight: 500; padding: 3px 9px; border-radius: 20px;
  border: 1px solid transparent;
}
.etiquette span { color: var(--muted); font-size: 11px; }
.etiquette:hover { border-color: var(--border); color: var(--dark); }

/* --------------------------------------------------------- case a cocher */

.case {
  display: flex; gap: 10px; align-items: flex-start; margin: 0 0 16px;
  padding: 13px 14px; background: var(--white); border: 1.5px solid var(--border);
  border-radius: 10px; cursor: pointer;
  font-size: 14px; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--text);
}
.case input { width: 20px; height: 20px; margin: 0; flex: 0 0 auto; accent-color: var(--dark); }
.case:has(input:checked) { border-color: var(--green); background: rgba(45, 106, 79, .06); }
