/* Espace APE : interface inspirée du ruban de Word.
   Une couleur d'accent, des filets plutôt que des boîtes, des angles droits. */

:root {
  --encre: #16150f;
  --encre-2: #33312b;
  --gris: #55524a;
  --filet: #dad6cc;
  --fond: #e9e7e2;
  --ruban: #f5f4f1;
  --accent: #1f3a5f;        /* barre de titre, liens actifs */
  --accent-clair: #dbe4ef;
  --rouge: #a3241b;
  --vert: #2d6a3e;
  --police: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--fond); color: var(--encre); font: 15px/1.5 var(--police); }
a { color: var(--accent); }
a:hover { color: var(--rouge); }
h1, h2 { line-height: 1.15; letter-spacing: -0.01em; }
h1 { font-size: 32px; margin: 4px 0 18px; }
h2 { font-size: 19px; margin: 32px 0 10px; }
.visuellement-cache { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Barre de titre ---------- */
.barre-titre { background: var(--accent); color: #fff; display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: center; justify-content: space-between; padding: 8px 20px; }
.barre-titre .asso { color: #fff; font-weight: 700; text-decoration: none; font-size: 15px; }
.qui { display: flex; align-items: center; gap: 16px; font-size: 13px; }
.qui form { margin: 0; }
.lien-discret { background: none; border: 0; color: inherit; font: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; padding: 4px 0; text-decoration: underline; text-underline-offset: 3px; }
.barre-titre .lien-discret { color: #fff; }

/* ---------- Onglets du ruban ---------- */
.onglets { background: var(--accent); display: flex; gap: 2px; padding: 0 12px; overflow-x: auto; scrollbar-width: thin; }
.onglets a { color: #e8edf4; text-decoration: none; padding: 8px 14px 9px; font-size: 14px; white-space: nowrap; }
.onglets a:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.onglets a[aria-current="page"] { background: var(--ruban); color: var(--encre); font-weight: 600; }

/* ---------- Ruban : groupes de gros boutons ---------- */
.ruban { background: var(--ruban); border-bottom: 1px solid var(--filet); display: flex; overflow-x: auto; padding: 6px 8px 0; scrollbar-width: thin; }
.groupe { display: flex; flex-direction: column; border-right: 1px solid var(--filet); padding: 0 8px; flex: none; }
.groupe:last-child { border-right: 0; }
.groupe-boutons { display: flex; gap: 2px; align-items: stretch; }
.groupe-nom { text-align: center; font-size: 11px; color: var(--gris); padding: 2px 0 5px; }
.form-ruban { margin: 0; display: flex; }
.btn-ruban { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 3px; min-width: 76px; max-width: 104px; min-height: 64px; padding: 6px 6px 4px; border: 1px solid transparent; background: none; color: var(--encre); font: 12px/1.2 var(--police); text-align: center; text-decoration: none; cursor: pointer; }
.btn-ruban:hover { background: #e6e3dc; border-color: #cfcabf; color: var(--encre); }
.btn-ruban.actif { background: var(--accent-clair); border-color: #b5c4d8; }
.btn-ruban svg { color: var(--accent); flex: none; }

/* ---------- La feuille ---------- */
.feuille { background: #fff; max-width: 1180px; margin: 20px auto 48px; padding: 32px 48px 48px; border: 1px solid #d3cfc5; box-shadow: 0 1px 3px rgba(22, 21, 15, 0.08); }
.surtitre { font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gris); }
.chapo { font-size: 17px; color: var(--encre-2); max-width: 70ch; margin: 0 0 20px; }
.discret { color: var(--gris); font-size: 13px; }
.rouge { color: var(--rouge); }
.fort { font-weight: 600; }
.centre { text-align: center; }
.barre td { color: var(--gris); text-decoration: line-through; }
.barre td.actions { text-decoration: none; }

.flash { padding: 10px 0 10px 14px; border-left: 3px solid var(--accent); margin: 0 0 20px; }
.flash-succes { border-color: var(--vert); }
.flash-erreur { border-color: var(--rouge); color: var(--rouge); }
.flash-info { border-color: var(--gris); }

/* Chiffres clés séparés par des filets */
.chiffres { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 2px solid var(--encre); border-bottom: 1px solid var(--encre); margin: 0 0 28px; }
.chiffres.deux { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.chiffres > div { padding: 14px 16px; border-left: 1px solid var(--filet); }
.chiffres > div:first-child { border-left: 0; padding-left: 0; }
.chiffres strong { display: block; font-size: 30px; line-height: 1; letter-spacing: -0.02em; }
.chiffres span { display: block; margin-top: 6px; font-size: 13px; color: var(--gris); }

/* Tableaux */
.tableau { width: 100%; border-collapse: collapse; font-size: 14px; margin: 0 0 8px; }
.tableau th { text-align: left; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gris); border-bottom: 1px solid var(--encre); padding: 8px 10px 8px 0; vertical-align: bottom; }
.tableau td { border-bottom: 1px solid var(--filet); padding: 10px 10px 10px 0; vertical-align: top; }
.tableau.compact td { padding: 6px 10px 6px 0; }
.tableau .nombre { text-align: right; font-variant-numeric: tabular-nums; }
.tableau td.actions { text-align: right; white-space: nowrap; }
.tableau tr.total td { border-top: 1px solid var(--encre); font-weight: 600; }
h2.theme { font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; border-top: 2px solid var(--encre); padding-top: 8px; margin: 28px 0 0; }
.defilement { overflow-x: auto; }
.matrice th.vertical { height: 150px; white-space: nowrap; vertical-align: bottom; padding: 0 4px 8px; }
.matrice th.vertical span { writing-mode: vertical-rl; transform: rotate(180deg); }
.mots { font-size: 12px; color: var(--gris); }

/* Listes */
.liste-lignes { list-style: none; margin: 0 0 8px; padding: 0; border-top: 1px solid var(--encre); }
.liste-lignes li { display: grid; grid-template-columns: 96px 1fr auto; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--filet); }
.quand { font-weight: 700; }
.quand.urgent { color: var(--rouge); }
.liste-num { margin: 0 0 8px; padding-left: 22px; }
.liste-num li { padding: 4px 0; }
.liste-simple { margin: 0; padding-left: 18px; }

/* Colonnes de l'accueil et du tableau de bord */
.colonnes { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 8px 40px; }
.bloc h2 { margin-top: 8px; border-top: 2px solid var(--encre); padding-top: 10px; }
.avec-aside { display: flex; flex-wrap: wrap; gap: 40px; align-items: flex-start; }
.avec-aside .principal { flex: 999 1 560px; min-width: 0; overflow-x: auto; }
.aside { flex: 1 1 280px; min-width: 0; }
.aside h2 { margin-top: 28px; border-top: 2px solid var(--encre); padding-top: 10px; }
.relance { white-space: pre-wrap; font: 14px/1.6 var(--police); margin: 12px 0; }

/* Sous-onglets (événements, classes…) */
.sous-onglets { display: flex; flex-wrap: wrap; gap: 4px 22px; border-bottom: 1px solid var(--filet); margin: 0 0 20px; }
.sous-onglets a { text-decoration: none; color: var(--gris); padding: 8px 0; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.sous-onglets a[aria-current="page"] { color: var(--encre); font-weight: 700; border-color: var(--encre); }

/* Formulaires */
.formulaire { display: flex; flex-direction: column; max-width: 640px; }
.formulaire.etroit { max-width: 400px; }
.formulaire label { font-weight: 600; font-size: 14px; margin: 14px 0 6px; }
.formulaire input:not([type="checkbox"]):not([type="radio"]), .formulaire select, .formulaire textarea, .recherche input {
  font: inherit; padding: 9px 10px; min-height: 42px; border: 1px solid #8d897f; border-radius: 2px; background: #fff; color: var(--encre); width: 100%; }
.formulaire input:focus, .formulaire select:focus, .formulaire textarea:focus, .recherche input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.formulaire.ligne { flex-direction: row; flex-wrap: wrap; align-items: flex-end; gap: 12px; max-width: none; }
.formulaire.ligne > div { display: flex; flex-direction: column; flex: 1 1 200px; }
.formulaire.ligne > div:last-child { flex: none; }
.boutons { display: flex; gap: 16px; align-items: center; margin-top: 20px; }
fieldset.cases { border: 0; padding: 0; margin: 18px 0 0; display: flex; flex-wrap: wrap; gap: 4px 20px; }
fieldset.cases legend { font-weight: 600; font-size: 14px; margin-bottom: 6px; padding: 0; }
.formulaire label.case { font-weight: 400; margin: 6px 0; display: flex; align-items: center; gap: 8px; }
.case input { width: 18px; height: 18px; }
.encadre-simple { border-top: 2px solid var(--encre); margin-top: 40px; }
.encadre-simple h2 { margin-top: 12px; }
.zone-danger { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--filet); }
.recherche { display: flex; gap: 8px; margin: 0 0 16px; max-width: 760px; }

/* Boutons */
.btn-principal, .btn-petit, .btn-mobile { font: 600 14px/1.2 var(--police); border: 1px solid var(--encre); border-radius: 2px; background: var(--encre); color: #fff; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.btn-principal { min-height: 42px; padding: 0 18px; align-self: flex-start; }
.btn-principal.large { width: 100%; }
.btn-petit { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn-petit.secondaire, .btn-mobile.secondaire { background: #fff; color: var(--encre); }
.btn-petit.danger { background: #fff; color: var(--rouge); border-color: var(--rouge); }
.btn-principal:hover, .btn-petit:hover, .btn-mobile:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.en-ligne { display: inline; margin: 0; }
.croix { background: none; border: 0; color: var(--gris); cursor: pointer; font-size: 15px; padding: 0 2px; }
.croix:hover { color: var(--rouge); }

/* Tri des colonnes, filtres, aperçu d'un mail */
.tableau th a.tri { color: inherit; text-decoration: none; }
.tableau th a.tri:hover { color: var(--accent); text-decoration: underline; }
.sous-onglets.filtres { margin-top: -12px; }
.sous-onglets.filtres a { font-size: 14px; }
.apercu-mail { border-top: 1px solid var(--encre); border-bottom: 1px solid var(--encre); padding: 12px 0; max-width: 720px; }
.apercu-mail .fort { font-size: 17px; margin-top: 4px; }

/* Cases à cocher des tableaux, saisie des parents sur la fiche d'un enfant */
.tableau .case-tableau { width: 32px; padding-right: 6px; }
.tableau .case-tableau input { width: 18px; height: 18px; }
.tableau td.actions .btn-petit + .btn-petit { margin-left: 4px; }
.bloc-parent { border: 0; border-top: 1px solid var(--encre); padding: 6px 0 4px; margin: 18px 0 0; display: flex; flex-direction: column; }
.bloc-parent legend { font-weight: 700; padding: 0 8px 0 0; }
.grille-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.grille-2 > div { display: flex; flex-direction: column; }
.btn-principal.secondaire-principal { background: #fff; color: var(--encre); }
.btn-principal.secondaire-principal:hover { background: var(--accent); color: #fff; }
@media (max-width: 760px) { .grille-2 { grid-template-columns: 1fr; } }

/* Zone de dépôt des pièces jointes */
.zone-depot { position: relative; border: 1px dashed #8d897f; padding: 18px 16px; background: var(--ruban); }
.zone-depot.survol { border-color: var(--accent); background: var(--accent-clair); }
.zone-depot input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; min-height: 0; }
.zone-depot p { margin: 0 0 4px; }
.liste-fichiers { margin: 8px 0 0; padding-left: 18px; font-size: 14px; }
.liste-fichiers:empty { display: none; }

/* Idées */
.idees { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--encre); }
.idee { display: flex; gap: 16px; align-items: flex-start; padding: 14px 0; border-bottom: 1px solid var(--filet); }
.ordre { display: flex; flex-direction: column; gap: 2px; }
.ordre form { margin: 0; }
.fleche { width: 36px; height: 30px; border: 1px solid #8d897f; background: #fff; cursor: pointer; font-size: 12px; border-radius: 2px; }
.fleche:hover:not(:disabled) { background: var(--accent); color: #fff; border-color: var(--accent); }
.fleche:disabled { opacity: 0.3; cursor: default; }
.rang { width: 36px; font-size: 22px; font-weight: 700; text-align: center; }
.idee-corps { flex: 1; min-width: 0; }
.idee-titre { font-size: 16px; font-weight: 600; }
.idee-titre a { color: var(--encre); text-decoration: none; }
.idee-titre a:hover { text-decoration: underline; }
.statut { font-size: 12px; font-weight: 600; color: var(--gris); margin-left: 6px; }
.statut-retenue, .statut-en_cours { color: var(--accent); }
.statut-realisee { color: var(--vert); }
.statut-non_retenue { color: var(--rouge); }
.commentaires { list-style: none; padding: 0; border-top: 1px solid var(--encre); }
.commentaires li { border-bottom: 1px solid var(--filet); padding: 10px 0; }
.commentaires p { margin: 4px 0 0; }

/* Affiches */
.grille-affiches { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 28px 24px; }
.affiche { margin: 0; }
.affiche img, .affiche-pdf { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border: 1px solid var(--filet); display: block; background: var(--ruban); }
.affiche-pdf { display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--gris); }
.affiche figcaption { display: flex; flex-direction: column; gap: 2px; padding-top: 8px; font-size: 14px; }

/* ---------- Page publique des parents (téléphone) ---------- */
body.public { background: #fff; }
.mobile { max-width: 520px; margin: 0 auto; padding: 28px 20px 48px; }
.mobile h1 { font-size: 40px; margin: 8px 0 6px; }
.mission { display: flex; gap: 12px; align-items: flex-start; padding: 14px 0; border-bottom: 1px solid var(--filet); }
.mission-texte { flex: 1; min-width: 0; font-size: 14px; }
.mission-texte .fort { font-size: 16px; }
.mission-action { flex: none; padding-top: 2px; }
.btn-mobile { min-width: 112px; min-height: 44px; padding: 0 14px; }
.urgent-mention { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--rouge); }
.feuille-inscription { border-top: 2px solid var(--encre); padding: 16px 0 20px; display: flex; flex-direction: column; }
.feuille-inscription label { font-weight: 600; margin-bottom: 6px; }
.feuille-inscription input { font: inherit; font-size: 16px; min-height: 48px; padding: 0 12px; border: 1px solid var(--encre); border-radius: 2px; }
.piege { position: absolute; left: -9999px; }
.pied { margin-top: 32px; }

/* ---------- Petits écrans ---------- */
@media (max-width: 760px) {
  .feuille { margin: 0; padding: 20px 16px 40px; border: 0; box-shadow: none; }
  h1 { font-size: 26px; }
  .chiffres { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chiffres > div:nth-child(3) { border-left: 0; padding-left: 0; }
  .chiffres > div:nth-child(n+3) { border-top: 1px solid var(--filet); }
  .btn-ruban { min-width: 68px; }
  .tableau { display: block; overflow-x: auto; }
  .liste-lignes li { grid-template-columns: 80px 1fr; }
  .liste-lignes li > :last-child { grid-column: 2; }
  .recherche { flex-direction: column; }
}

/* ---------- Impression : seulement la feuille ---------- */
@media print {
  .barre-titre, .onglets, .ruban, .actions, .zone-danger, .encadre-simple, .sous-onglets, form { display: none !important; }
  body { background: #fff; }
  .feuille { border: 0; box-shadow: none; margin: 0; padding: 0; max-width: none; }
}

/* Passage à l'année suivante : liste repliable des exceptions */
details summary { cursor: pointer; color: var(--gris); font-size: 14px; }
details[open] summary { margin-bottom: 4px; }
details .case { font-weight: 400; margin: 4px 0; display: flex; align-items: center; gap: 8px; }

/* Historique annuel */
.defilement { overflow-x: auto; }
.historique td, .historique th { white-space: nowrap; }
.historique .intertitre th { padding-top: 22px; color: var(--encre); }
.historique .ecart { display: block; font-size: 12px; color: var(--gris); }
.historique .ecart.baisse { color: var(--gris); }

/* ---------- Documents d'AG : pages A4 à imprimer ou enregistrer en PDF ---------- */
.champ-nombre { width: 5.5em; text-align: right; }
body.document { background: var(--fond); }
.barre-document { position: sticky; top: 0; z-index: 2; display: flex; gap: 20px; align-items: center; padding: 10px 20px; background: var(--ruban); border-bottom: 1px solid var(--filet); }
.doc-page { background: #fff; width: 210mm; min-height: 297mm; margin: 20px auto; padding: 18mm 18mm 16mm; font-size: 14px; line-height: 1.5; }
.doc-page h1 { font-size: 26px; margin: 2px 0 4px; }
.doc-page h2 { font-size: 13px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; border-top: 2px solid var(--encre); padding-top: 6px; margin: 24px 0 8px; }
.doc-entete { border-bottom: 1px solid var(--encre); padding-bottom: 10px; margin-bottom: 8px; }
.doc-asso { font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gris); }
.doc-sous-titre { margin: 0; color: var(--gris); }
.doc-chiffres { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--encre); margin: 16px 0; }
.doc-chiffres div { padding: 8px 10px 10px 0; font-size: 12px; color: var(--gris); }
.doc-chiffres strong { display: block; font-size: 22px; color: var(--encre); font-variant-numeric: tabular-nums; }
.doc-deux { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.doc-page .tableau tr.total td { font-weight: 700; border-top: 1px solid var(--encre); }
.doc-a-ecrire { border-left: 3px solid var(--filet); padding: 6px 12px; color: var(--gris); font-style: italic; }
.doc-signatures { display: flex; gap: 40px; margin-top: 36px; }
.doc-signatures > div { flex: 1; border-top: 1px solid var(--encre); padding-top: 6px; min-height: 90px; font-weight: 600; }
.doc-signatures span { display: block; font-weight: 400; font-size: 12px; color: var(--gris); }
.doc-demi { min-height: 125mm; font-size: 13px; line-height: 1.45; }
.doc-demi h2 { border-top: 0; padding-top: 0; font-size: 18px; letter-spacing: 0; text-transform: none; margin: 4px 0 10px; }
.doc-coupe { border-top: 1px dashed var(--gris); margin: 6mm 0; text-align: left; color: var(--gris); line-height: 0; }
.doc-ligne { border-bottom: 1px dotted var(--gris); padding-top: 14px; }
.doc-grille { width: 100%; border-collapse: collapse; margin-top: 12px; }
.doc-grille th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; border-bottom: 1px solid var(--encre); padding: 6px; }
.doc-grille td { border-bottom: 1px solid var(--filet); height: 9.2mm; padding: 0 6px; }
.doc-grille td + td, .doc-grille th + th { border-left: 1px solid var(--filet); }
.doc-affiche { text-align: left; }
.doc-affiche h1 { font-size: 64px; line-height: 1; margin: 30mm 0 10mm; letter-spacing: -0.02em; }
.doc-affiche-quand { font-size: 30px; font-weight: 700; margin: 0; }
.doc-affiche-lieu { font-size: 22px; margin: 4px 0 14mm; }
.doc-affiche ol { font-size: 18px; border-top: 2px solid var(--encre); padding: 12px 0 12px 26px; }
.doc-affiche-appel { font-size: 20px; border-top: 1px solid var(--encre); padding-top: 12px; margin-top: 14mm; }
@media screen and (max-width: 820px) {
  .doc-page { width: auto; min-height: 0; margin: 12px; padding: 20px 16px; }
  .doc-chiffres { grid-template-columns: repeat(2, 1fr); }
  .doc-deux { grid-template-columns: 1fr; }
}
@page document-ag { size: A4; margin: 0; }
@media print {
  body.document { background: #fff; }
  .barre-document { display: none !important; }
  .doc-page { margin: 0; box-shadow: none; break-after: page; page: document-ag; }
  .doc-page:last-child { break-after: auto; }
}
