/* Pattounes des Sacres : maquette. Lisible d'abord (NF-004), utilisable au doigt (NF-001). */
:root {
  --fond: #f6f4f0;
  --carte: #ffffff;
  --texte: #1c1b1a;
  --texte-doux: #55504a;
  --bord: #ddd6cc;
  --primaire: #1f5f66;
  --primaire-fonce: #174a50;
  --primaire-clair: #e3f0f1;
  --accent: #b85c1e;
  --urgence: #b42318;
  --urgence-fond: #fee4e2;
  --avert: #93370d;
  --avert-fond: #fef0c7;
  --info: #175cd3;
  --info-fond: #d1e9ff;
  --succes: #067647;
  --succes-fond: #dcfae6;
  --attente: #5925dc;
  --attente-fond: #ebe9fe;
  --neutre-fond: #eeeae4;
  --rayon: 10px;
  --ombre: 0 1px 3px rgba(40, 30, 20, 0.08), 0 1px 2px rgba(40, 30, 20, 0.05);
  --haut: env(safe-area-inset-top, 0px);
  --bas: env(safe-area-inset-bottom, 0px);
  --gauche: env(safe-area-inset-left, 0px);
  --droite: env(safe-area-inset-right, 0px);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--texte);
  background: var(--fond);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--fond); }
a { color: var(--primaire); }
a:hover { color: var(--primaire-fonce); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.6rem; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 0.8rem; }
.evitement { position: absolute; left: -999px; top: 0; }
.evitement:focus { left: 1rem; top: 1rem; z-index: 100; background: #fff; padding: 0.5rem 1rem; }
.chargement { padding: 2rem; color: var(--texte-doux); }
.discret { color: var(--texte-doux); font-size: 0.92rem; }
.petit { font-size: 0.86rem; }
.gras { font-weight: 600; }
.cache { display: none !important; }

.bandeau-demo {
  background: #3b2f25;
  color: #fbe9d7;
  font-size: 0.82rem;
  text-align: center;
  padding: calc(0.3rem + var(--haut)) calc(0.8rem + var(--droite)) 0.3rem calc(0.8rem + var(--gauche));
}
.bandeau-horloge { background: var(--avert-fond); color: var(--avert); padding: 0.5rem 1rem; font-size: 0.9rem; border-bottom: 1px solid #f7d58b; }

/* ── Mise en page ─────────────────────────────────────────────────────── */
.entete {
  display: flex; align-items: center; gap: 0.75rem;
  background: var(--primaire); color: #fff;
  padding: 0.55rem calc(1rem + var(--droite)) 0.55rem calc(1rem + var(--gauche));
  position: sticky; top: 0; z-index: 20;
}
.entete .marque { display: flex; align-items: center; gap: 0.5rem; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.05rem; white-space: nowrap; min-height: 44px; min-width: 44px; justify-content: center; }
.entete .marque img { width: 30px; height: 30px; }
.entete form.recherche { flex: 1; max-width: 420px; display: flex; }
.entete form.recherche input { width: 100%; border-radius: 999px; border: 0; padding: 0.5rem 0.9rem; min-height: 44px; }
.entete .espace { flex: 1; }
.entete .bouton-icone { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,0.35); border-radius: 8px; min-height: 44px; min-width: 44px; padding: 0 0.7rem; cursor: pointer; font-size: 0.95rem; text-decoration: none; display: inline-flex; align-items: center; gap: 0.3rem; }
.entete .bouton-icone:hover { background: rgba(255,255,255,0.12); color: #fff; }
.entete .compteur { background: var(--accent); border-radius: 999px; padding: 0 0.45rem; font-size: 0.75rem; font-weight: 700; }
.entete .qui { font-size: 0.9rem; opacity: 0.95; white-space: nowrap; }
.entete .libelle-court { display: none; }
.bouton-menu { display: none; }
/* Téléphone : l'en-tête garde menu, logo, notifications et sortie, sans rien faire déborder. */
@media (max-width: 600px) {
  .entete { gap: 0.4rem; padding-left: calc(0.6rem + var(--gauche)); padding-right: calc(0.6rem + var(--droite)); }
  .entete .nom-marque, .entete .libelle-long { display: none; }
  .entete .libelle-court { display: inline; }
}

.cadre { display: grid; grid-template-columns: 250px 1fr; min-height: calc(100vh - 90px); }
.menu {
  background: var(--carte); border-right: 1px solid var(--bord);
  padding: 1rem 0.6rem calc(1rem + var(--bas)) calc(0.6rem + var(--gauche));
}
.menu a, .menu span.futur {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.6rem 0.8rem; border-radius: 8px; color: var(--texte); text-decoration: none; min-height: 44px; font-size: 0.97rem;
}
.menu a:hover { background: var(--primaire-clair); }
.menu a.actif { background: var(--primaire); color: #fff; font-weight: 600; }
.menu span.futur { color: #9a928a; cursor: default; font-size: 0.9rem; }
.menu span.futur small { margin-left: auto; font-size: 0.72rem; }
.menu .titre-menu { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--texte-doux); margin: 1rem 0.8rem 0.3rem; }

main#contenu { padding: 1.4rem calc(1.4rem + var(--droite)) calc(2rem + var(--bas)) 1.4rem; min-width: 0; outline: none; }

@media (max-width: 900px) {
  .cadre { grid-template-columns: 1fr; }
  .bouton-menu { display: inline-flex; }
  .menu {
    position: fixed; z-index: 30; top: 0; bottom: 0; left: 0; width: min(84vw, 300px);
    padding-top: calc(1rem + var(--haut)); overflow-y: auto; transform: translateX(-105%); transition: transform 0.2s ease;
    box-shadow: 4px 0 16px rgba(0,0,0,0.15);
  }
  .menu.ouvert { transform: translateX(0); }
  .voile { position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 25; }
  .entete form.recherche { display: none; }
  .entete .qui { display: none; }
  main#contenu { padding: 1rem calc(0.9rem + var(--droite)) calc(2rem + var(--bas)) calc(0.9rem + var(--gauche)); }
}

/* ── Éléments ─────────────────────────────────────────────────────────── */
.carte { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 1rem 1.1rem; box-shadow: var(--ombre); margin-bottom: 1rem; }
.carte > h2:first-child, .carte > h3:first-child { margin-top: 0; }
.carte.obligatoire { border-left: 4px solid var(--primaire); }
.carte.alerte-urgence { border-left: 4px solid var(--urgence); }
.titre-ligne { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.8rem; }
.titre-ligne h1, .titre-ligne h2 { margin: 0; }
.grille { display: grid; gap: 1rem; }
.grille-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grille-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.indicateurs { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.8rem; margin-bottom: 1rem; }
.indicateur { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 0.8rem 0.9rem; box-shadow: var(--ombre); text-decoration: none; color: var(--texte); display: block; }
.indicateur .valeur { font-size: 1.45rem; font-weight: 700; display: block; }
.indicateur .libelle { font-size: 0.85rem; color: var(--texte-doux); }
.indicateur.negatif .valeur { color: var(--urgence); }

.badge { display: inline-flex; align-items: center; gap: 0.25rem; border-radius: 999px; padding: 0.12rem 0.6rem; font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.badge-urgence { background: var(--urgence-fond); color: var(--urgence); }
.badge-avertissement { background: var(--avert-fond); color: var(--avert); }
.badge-info { background: var(--info-fond); color: var(--info); }
.badge-succes { background: var(--succes-fond); color: var(--succes); }
.badge-attente { background: var(--attente-fond); color: var(--attente); }
.badge-neutre { background: var(--neutre-fond); color: var(--texte-doux); }
.badge-archive { background: #3b3732; color: #fff; }

.liste-alertes { list-style: none; padding: 0; margin: 0; }
.liste-alertes li { display: flex; gap: 0.6rem; align-items: flex-start; padding: 0.6rem 0; border-bottom: 1px solid var(--bord); }
.liste-alertes li:last-child { border-bottom: 0; }
.liste-alertes .corps { flex: 1; min-width: 0; }
.liste-alertes .corps a { font-weight: 600; display: inline-flex; align-items: center; min-height: 44px; }
.liste-simple { list-style: none; padding: 0; margin: 0; }
.liste-simple li { padding: 0.5rem 0; border-bottom: 1px solid var(--bord); display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; justify-content: space-between; }
.liste-simple li:last-child { border-bottom: 0; }
.vide { color: var(--texte-doux); font-style: italic; }

.defilement { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tableau { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
table.tableau th, table.tableau td { text-align: left; padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--bord); vertical-align: top; }
table.tableau th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--texte-doux); background: #faf8f5; }
table.tableau td.nombre, table.tableau th.nombre { text-align: right; white-space: nowrap; }
table.tableau tr.total td { font-weight: 700; background: #faf8f5; }
table.tableau tr.barree td { color: #9a928a; text-decoration: line-through; }
.montant-recette { color: var(--succes); }
.montant-depense { color: var(--urgence); }

/* ── Formulaires ──────────────────────────────────────────────────────── */
form .champs { display: grid; gap: 0.85rem 1rem; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.champ { display: flex; flex-direction: column; gap: 0.25rem; }
.champ.large { grid-column: 1 / -1; }
.champ label, .champ .etiquette { font-weight: 600; font-size: 0.92rem; }
.champ .aide { font-size: 0.82rem; color: var(--texte-doux); }
.champ .requis { color: var(--urgence); }
input[type='text'], input[type='email'], input[type='password'], input[type='number'], input[type='date'], input[type='datetime-local'], input[type='search'], input[type='month'], select, textarea {
  font: inherit; color: var(--texte); background: #fff; border: 1px solid #b9b0a4; border-radius: 8px; padding: 0.55rem 0.7rem; min-height: 44px; width: 100%;
}
textarea { min-height: 90px; resize: vertical; }
input[type='file'] { font: inherit; min-height: 44px; }
.case { display: flex; align-items: center; gap: 0.5rem; min-height: 44px; font-weight: 500; }
.case input { width: 22px; height: 22px; }
fieldset { border: 1px solid var(--bord); border-radius: var(--rayon); padding: 0.8rem 1rem; margin: 0 0 1rem; }
legend { font-weight: 700; padding: 0 0.3rem; }
.actions { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; margin-top: 1rem; }
.filtres { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: flex-end; margin-bottom: 1rem; }
.filtres .champ { min-width: 150px; flex: 1; }

.bouton, button.bouton {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 8px; border: 1px solid var(--primaire);
  background: var(--primaire); color: #fff; padding: 0.55rem 1rem; min-height: 44px; display: inline-flex; align-items: center; gap: 0.4rem; text-decoration: none;
}
.bouton:hover { background: var(--primaire-fonce); color: #fff; }
.bouton.secondaire { background: #fff; color: var(--primaire); }
.bouton.secondaire:hover { background: var(--primaire-clair); color: var(--primaire-fonce); }
.bouton.danger { background: var(--urgence); border-color: var(--urgence); }
.bouton.danger:hover { background: #912018; }
.bouton.discret { background: transparent; border-color: transparent; color: var(--primaire); padding: 0.4rem 0.6rem; }
.bouton.discret:hover { background: var(--primaire-clair); }
.bouton.petit { min-height: 36px; padding: 0.3rem 0.7rem; font-size: 0.88rem; }
.bouton[disabled], .bouton[aria-disabled='true'] { opacity: 0.55; cursor: not-allowed; }
.onglets { display: flex; gap: 0.3rem; flex-wrap: wrap; border-bottom: 1px solid var(--bord); margin-bottom: 1rem; }
.onglets a { padding: 0.55rem 0.9rem; text-decoration: none; color: var(--texte-doux); border-bottom: 3px solid transparent; min-height: 44px; display: inline-flex; align-items: center; }
.onglets a.actif { color: var(--primaire); border-bottom-color: var(--primaire); font-weight: 600; }

.message { border-radius: var(--rayon); padding: 0.7rem 0.9rem; margin-bottom: 1rem; font-size: 0.95rem; }
.message.urgence { background: var(--urgence-fond); color: var(--urgence); }
.message.avertissement { background: var(--avert-fond); color: var(--avert); }
.message.info { background: var(--info-fond); color: var(--info); }
.message.succes { background: var(--succes-fond); color: var(--succes); }
.message.verrou { background: #efe9ff; color: #3e1c96; }

.fiche-chat { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.photo { width: 88px; height: 88px; border-radius: 14px; object-fit: cover; background: var(--neutre-fond); border: 1px solid var(--bord); }
.photo.petite { width: 56px; height: 56px; border-radius: 10px; }
.cartes-chats { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0.8rem; }
.carte-chat { display: flex; gap: 0.7rem; align-items: center; background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 0.7rem; text-decoration: none; color: var(--texte); box-shadow: var(--ombre); }
.carte-chat:hover { border-color: var(--primaire); }
.carte-chat .nom { font-weight: 700; }
dl.details { display: grid; grid-template-columns: minmax(110px, max-content) minmax(0, 1fr); gap: 0.35rem 1rem; margin: 0; }
dl.details dt { color: var(--texte-doux); font-size: 0.9rem; }
/* Une adresse e-mail longue se coupe au lieu d'élargir la page sur téléphone. */
dl.details dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.liste-simple li > span, .liste-simple li > a { min-width: 0; overflow-wrap: anywhere; }
.historique { list-style: none; padding: 0; margin: 0; font-size: 0.92rem; }
.historique li { padding: 0.45rem 0; border-bottom: 1px dashed var(--bord); }
.historique .quand { color: var(--texte-doux); font-size: 0.82rem; display: block; }
table.diff { font-size: 0.85rem; margin-top: 0.3rem; border-collapse: collapse; }
table.diff td, table.diff th { padding: 0.15rem 0.5rem; border: 1px solid var(--bord); text-align: left; }
progress { width: 100%; height: 12px; }

.calendrier { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.calendrier .jour { background: var(--carte); border: 1px solid var(--bord); border-radius: 8px; min-height: 92px; padding: 0.3rem; font-size: 0.8rem; overflow: hidden; }
.calendrier .jour.hors { background: transparent; border-style: dashed; }
.calendrier .jour.aujourdhui { border: 2px solid var(--primaire); }
.calendrier .numero { font-weight: 700; }
.calendrier .evt { display: block; border-radius: 5px; padding: 0.1rem 0.3rem; margin-top: 0.2rem; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.calendrier .evt.rdv { background: var(--info-fond); color: var(--info); }
.calendrier .evt.echeance { background: var(--avert-fond); color: var(--avert); }
.calendrier .evt.realise { background: var(--succes-fond); color: var(--succes); }
.calendrier .entete-jour { text-align: center; font-weight: 700; font-size: 0.8rem; color: var(--texte-doux); }
@media (max-width: 700px) { .calendrier .jour { min-height: 64px; font-size: 0.7rem; } }

.connexion { max-width: 460px; margin: 2rem auto; padding: 0 1rem; }
.connexion .logo { text-align: center; margin-bottom: 1rem; }
.connexion .logo img { width: 64px; height: 64px; }
.comptes-demo { font-size: 0.9rem; }
.comptes-demo button { width: 100%; justify-content: space-between; margin-bottom: 0.4rem; text-align: left; }

dialog#dialogue { border: 0; border-radius: 14px; padding: 0; width: min(640px, 94vw); max-height: 88vh; box-shadow: 0 20px 50px rgba(0,0,0,0.3); }
dialog#dialogue::backdrop { background: rgba(20, 15, 10, 0.45); }
dialog#dialogue .interieur { padding: 1.2rem 1.3rem; overflow-y: auto; max-height: 88vh; }

#toasts { position: fixed; right: calc(1rem + var(--droite)); bottom: calc(1rem + var(--bas)); z-index: 60; display: flex; flex-direction: column; gap: 0.5rem; max-width: min(420px, 92vw); }
.toast { background: #2a2622; color: #fff; padding: 0.7rem 1rem; border-radius: 10px; box-shadow: var(--ombre); font-size: 0.93rem; }
.toast.erreur { background: var(--urgence); }
.toast.succes { background: var(--succes); }

/* Notifications, courriels simulés, calendrier */
.liste-simple li.non-lue { font-weight: 600; border-left: 4px solid var(--primaire); padding-left: 0.6rem; }
details.courriel { border-bottom: 1px solid var(--bord); padding: 0.4rem 0; }
details.courriel summary { cursor: pointer; min-height: 44px; display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; }
pre.corps-courriel { white-space: pre-wrap; font: inherit; background: #faf8f5; border-radius: 8px; padding: 0.7rem; margin: 0.4rem 0 0; }
.legende { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 0.8rem; font-size: 0.85rem; }
.legende .evt { display: inline-block; border-radius: 5px; padding: 0.15rem 0.45rem; }
.legende .evt.rdv { background: var(--info-fond); color: var(--info); }
.legende .evt.echeance { background: var(--avert-fond); color: var(--avert); }
.legende .evt.realise { background: var(--succes-fond); color: var(--succes); }
.navigation-mois { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

@media print {
  .entete, .menu, .bandeau-demo, .actions, .filtres, .onglets { display: none !important; }
  .cadre { display: block; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ── Outil réel : banque, rapprochement, connecteurs, boutique, association ── */
/* Toute cible tactile fait au moins 44 px, y compris les petits boutons et les liens de tableau. */
.bouton.petit { min-height: 44px; }
.lien-cible, td a, dd a, .liste-simple li > span > a, .liste-simple li > a, .carte > a, .actions a { display: inline-flex; align-items: center; min-height: 44px; }
/* Un lien-cible au texte court (ex. « Reçu ») doit aussi atteindre 44 px en largeur, pas seulement en hauteur. */
.lien-cible { min-width: 44px; justify-content: center; }
.actions-ligne { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.filtres-ligne { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: flex-end; }
.filtres-ligne .champ { min-width: 150px; flex: 1; }
.champs.compact { margin-top: 0.8rem; }
tr.surligne td { background: var(--avert-fond); }
.proposition .face-a-face { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0.8rem; }
.proposition .cote { border: 1px solid var(--bord); border-radius: 8px; padding: 0.7rem 0.8rem; min-width: 0; overflow-wrap: anywhere; }
.proposition .cote.ligne-banque { border-left: 4px solid var(--primaire); }
.proposition .cote h3 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--texte-doux); }
.proposition .montant { font-size: 1.2rem; font-weight: 700; }
.proposition.ambigu { border-left: 4px solid var(--avert); }
.confrontation { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; margin: 0.8rem 0; font-size: 0.92rem; }
.connecteur details.reglages { margin-top: 0.8rem; border-top: 1px solid var(--bord); padding-top: 0.6rem; }
details > summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; }
code { overflow-wrap: anywhere; word-break: break-all; }
.document-asso details ul { margin: 0.4rem 0 0.6rem; }
fieldset.feuille { border: 1px solid var(--bord); border-radius: 8px; margin: 0 0 1rem; padding: 0.8rem; min-width: 0; }
.page-legale { margin-top: 1rem; overflow-wrap: anywhere; }
mark.a-remplir { background: #fff3c4; color: #5c3b00; padding: 0 0.2rem; border-radius: 3px; }
.page-retour { max-width: 560px; margin: 2rem auto; padding: 0 1rem; }
.connexion .carte { overflow-wrap: anywhere; }
.message.succes { overflow-wrap: anywhere; }
