/* Tribu sans famille - gestion
   Pensé d'abord pour le téléphone. Polices système (aucun appel à un service externe). */

:root {
  --fond: #eef1ec;
  --surface: #ffffff;
  --encre: #1c2b2d;
  --encre-2: #4f6064;
  --petrole: #1f5a5e;
  --petrole-fonce: #15413f;
  --moutarde: #e2a32a;
  --moutarde-pale: #fbefd3;
  --rouge: #a23b2a;
  --trait: #d5ddd7;
  --arrondi: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", "Segoe UI", system-ui, sans-serif;
  --texte: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fond: #121c1d;
    --surface: #1a2729;
    --encre: #e6ecea;
    --encre-2: #a3b2b0;
    --petrole: #5fa7a9;
    --petrole-fonce: #0f2c2d;
    --moutarde: #e7b24a;
    --moutarde-pale: #3a3120;
    --rouge: #e0826f;
    --trait: #2d3d3f;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--fond);
  color: var(--encre);
  font: 16px/1.5 var(--texte);
}
img { max-width: 100%; display: block; }
a { color: var(--petrole); }
h1, h2 { font-family: var(--arrondi); line-height: 1.2; }
h1 { font-size: 1.75rem; font-weight: 800; margin: 0 0 .75rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; font-weight: 700; margin: 0 0 .75rem; }
:focus-visible { outline: 3px solid var(--moutarde); outline-offset: 2px; border-radius: 4px; }
.masque { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------------------------------------------------------------- En-tête et rubriques */
.entete {
  background: var(--petrole-fonce);
  color: #f4f6f2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .5rem 1rem;
  padding: .7rem 1rem;
}
.marque {
  display: flex;
  align-items: center;
  gap: .55rem;
  color: #f4f6f2;
  text-decoration: none;
  font-family: var(--arrondi);
  font-weight: 800;
  font-size: 1.15rem;
}
.compte { display: flex; align-items: center; gap: .9rem; font-size: .9rem; }
.compte a, .compte .lien { color: #d7e4e2; }
.compte form { margin: 0; }

.rubriques {
  background: var(--surface);
  border-bottom: 1px solid var(--trait);
  position: sticky;
  top: 0;
  z-index: 5;
}
.rubriques > div {
  display: flex;
  gap: .35rem;
  overflow-x: auto;
  padding: .55rem 1rem;
  max-width: 60rem;
  margin: 0 auto;
  scrollbar-width: none;
}
.rubriques > div::-webkit-scrollbar { display: none; }
.rubriques a {
  flex: none;
  padding: .4rem .85rem;
  border-radius: 999px;
  text-decoration: none;
  color: var(--encre-2);
  font-weight: 600;
  font-size: .92rem;
}
.rubriques a:hover { background: var(--fond); color: var(--encre); }
.rubriques a[aria-current] { background: var(--petrole); color: #fff; }

main { max-width: 60rem; margin: 0 auto; padding: 1.25rem 1rem 4rem; }

/* ---------------------------------------------------------------- Boutons */
.bouton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: .55rem 1.1rem;
  border: 2px solid var(--petrole);
  border-radius: 12px;
  background: var(--petrole);
  color: #fff;
  font: 600 .95rem/1.2 var(--texte);
  text-decoration: none;
  cursor: pointer;
}
.bouton:hover { background: var(--petrole-fonce); border-color: var(--petrole-fonce); }
.bouton.secondaire { background: transparent; color: var(--petrole); }
.bouton.secondaire:hover { background: var(--surface); }
.bouton.danger { background: var(--rouge); border-color: var(--rouge); }
.lien {
  background: none;
  border: 0;
  padding: 0;
  color: var(--petrole);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}
.lien.discret { color: var(--encre-2); font-size: .88rem; }

/* ---------------------------------------------------------------- Messages */
.note { padding: .75rem 1rem; border-radius: 12px; margin: 0 0 1rem; border-left: 5px solid; }
.note.ok { background: var(--surface); border-color: var(--petrole); }
.note.erreur { background: var(--surface); border-color: var(--rouge); color: var(--rouge); }
.aide { color: var(--encre-2); font-size: .9rem; margin: .4rem 0 0; }
.intro { color: var(--encre-2); margin-top: -.25rem; }
.vide { color: var(--encre-2); font-style: italic; }
.erreur { color: var(--rouge); }

/* ---------------------------------------------------------------- Cartes, blocs */
.carte, .bloc {
  background: var(--surface);
  border: 1px solid var(--trait);
  border-radius: 16px;
  padding: 1.1rem 1.2rem;
  margin: 0 0 1rem;
}
.carte.etroite { max-width: 26rem; margin: 2rem auto; }
.pile { display: grid; gap: 1rem; }

.titre-page {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: 1rem;
}
.titre-page h1 { margin: 0; }
.retour { margin: 0 0 .5rem; font-size: .92rem; }
.retour a::before { content: "‹ "; }

/* ---------------------------------------------------------------- Accueil */
.bonjour { font-size: 2rem; margin-bottom: 1.25rem; }
.a-faire { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.a-faire a {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  padding: .7rem .9rem;
  border-radius: 12px;
  background: var(--moutarde-pale);
  color: var(--encre);
  text-decoration: none;
  font-weight: 500;
}
.a-faire a:hover { outline: 2px solid var(--moutarde); }
.a-faire strong {
  font-family: var(--arrondi);
  font-size: 1.35rem;
  font-weight: 800;
  min-width: 1.6ch;
  text-align: right;
  color: var(--petrole-fonce);
}
@media (prefers-color-scheme: dark) { .a-faire strong { color: var(--moutarde); } }
.calme { margin: 0; color: var(--encre-2); }
.raccourcis { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ---------------------------------------------------------------- Liste */
.onglets { display: flex; gap: .35rem; overflow-x: auto; margin-bottom: .75rem; padding-bottom: .15rem; }
.onglets a {
  flex: none;
  padding: .35rem .8rem;
  border: 1px solid var(--trait);
  border-radius: 999px;
  background: var(--surface);
  color: var(--encre-2);
  text-decoration: none;
  font-size: .9rem;
}
.onglets a[aria-current] { border-color: var(--petrole); color: var(--petrole); font-weight: 700; box-shadow: inset 0 0 0 1px var(--petrole); }
.recherche { display: flex; gap: .5rem; margin-bottom: .5rem; }
.recherche input { flex: 1; }
.compte-fiches { color: var(--encre-2); font-size: .88rem; margin: .25rem 0 .5rem; }

.fiches { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
@media (min-width: 42rem) { .fiches { grid-template-columns: 1fr 1fr; } }
.fiche {
  display: flex;
  gap: .85rem;
  align-items: center;
  padding: .8rem .9rem;
  background: var(--surface);
  border: 1px solid var(--trait);
  border-radius: 14px;
  color: inherit;
  text-decoration: none;
  height: 100%;
}
.fiche:hover { border-color: var(--petrole); }
.fiche img, .sans-photo {
  flex: none;
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 12px;
  object-fit: cover;
  background: var(--fond);
}
.sans-photo { background: var(--fond) url("/static/favicon.svg") center / 45% no-repeat; opacity: .5; }
.corps { display: grid; gap: .3rem; min-width: 0; }
.ligne-titre { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .5rem; }
.titre { font-family: var(--arrondi); font-weight: 700; font-size: 1.08rem; }
.infos { display: flex; flex-wrap: wrap; gap: .1rem .9rem; color: var(--encre-2); font-size: .88rem; }
.pastille {
  display: inline-block;
  padding: .1rem .55rem;
  border-radius: 999px;
  color: #1c2b2d;
  font-size: .8rem;
  font-weight: 600;
  white-space: nowrap;
}
.vide-page { text-align: center; padding: 2.5rem 1rem; color: var(--encre-2); }
.pages { display: flex; justify-content: space-between; margin-top: 1rem; }

/* ---------------------------------------------------------------- Fiche */
.statut {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  margin-bottom: 1rem;
}
.statut label { font-weight: 600; }
.statut select { width: auto; min-width: 12rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.actions form { margin: 0; }

.infos-fiche { margin: 0; display: grid; gap: .75rem 1.5rem; }
@media (min-width: 42rem) { .infos-fiche { grid-template-columns: 1fr 1fr; } }
.infos-fiche dt { color: var(--encre-2); font-size: .85rem; }
.infos-fiche dd { margin: .1rem 0 0; }
.texte { white-space: pre-line; }

.pieces { list-style: none; margin: 0 0 .75rem; padding: 0; display: flex; flex-wrap: wrap; gap: .75rem; }
.pieces li { display: grid; gap: .25rem; justify-items: start; }
.pieces img { width: 8rem; height: 8rem; object-fit: cover; border-radius: 12px; }
.pieces .doc {
  display: flex;
  align-items: center;
  width: 8rem;
  min-height: 3rem;
  padding: .5rem;
  border: 1px dashed var(--trait);
  border-radius: 12px;
  font-size: .85rem;
  word-break: break-word;
}
.pieces form { margin: 0; }
.envoi { position: relative; overflow: hidden; }
.envoi input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.envoi:focus-within { outline: 3px solid var(--moutarde); outline-offset: 2px; }
.etat-envoi { margin: .5rem 0 0; font-size: .9rem; color: var(--encre-2); }
.etat-envoi:empty { display: none; }

.lies { list-style: none; margin: 0 0 .75rem; padding: 0; }
.lies li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: .5rem 0;
  border-bottom: 1px solid var(--trait);
}
.lies li:last-child { border-bottom: 0; }
.lies form { margin: 0; }
.ajout-lien { display: flex; gap: .5rem; }
.ajout-lien select { flex: 1; min-width: 0; }

.zone-danger { margin-top: 2rem; color: var(--encre-2); }
.zone-danger summary { cursor: pointer; color: var(--rouge); font-weight: 600; }
.zone-danger p { max-width: 38rem; }

/* ---------------------------------------------------------------- Formulaires */
input, select, textarea {
  width: 100%;
  min-height: 2.75rem;
  padding: .55rem .7rem;
  border: 1px solid var(--trait);
  border-radius: 10px;
  background: var(--surface);
  color: var(--encre);
  font: 16px/1.4 var(--texte); /* 16px : évite le zoom automatique sur iPhone */
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--petrole); outline: 2px solid var(--petrole); outline-offset: 0; }
input[type="checkbox"] { width: 1.3rem; min-height: 1.3rem; height: 1.3rem; accent-color: var(--petrole); flex: none; }

.champ { display: grid; gap: .3rem; align-content: start; }
.champ > label, .champ > legend { font-weight: 600; font-size: .92rem; }
.champ.case { display: flex; align-items: center; gap: .6rem; min-height: 2.75rem; }
.champ.case label { font-weight: 500; }
.multi { border: 1px solid var(--trait); border-radius: 12px; padding: .6rem .9rem .8rem; margin: 0; display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; }
.multi legend { padding: 0 .3rem; }
.multi label { display: flex; align-items: center; gap: .45rem; font-weight: 400; }

.grille-champs {
  display: grid;
  gap: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--trait);
  border-radius: 16px;
  padding: 1.1rem 1.2rem;
}
@media (min-width: 42rem) {
  .grille-champs { grid-template-columns: 1fr 1fr; }
  .grille-champs .large { grid-column: 1 / -1; }
}
.pied-formulaire { display: flex; flex-wrap: wrap; gap: .5rem; padding-top: .5rem; }

/* ---------------------------------------------------------------- Comptes */
.comptes { list-style: none; margin: 0; padding: 0; }
.comptes li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .5rem 1rem;
  padding: .75rem 0;
  border-bottom: 1px solid var(--trait);
}
.comptes li:last-child { border-bottom: 0; }
.comptes li > div:first-child { display: grid; }
.comptes li span { color: var(--encre-2); font-size: .9rem; }
.comptes li.inactif { opacity: .6; }
.actions-compte { display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: center; }
.actions-compte form { margin: 0; }
.mdp-provisoire .mdp {
  font: 700 1.4rem/1.2 ui-monospace, "Cascadia Mono", Consolas, monospace;
  background: var(--moutarde-pale);
  padding: .5rem .8rem;
  border-radius: 10px;
  display: inline-block;
  user-select: all;
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
