/* =============================================================================
   SaraPay — interface « billet et bulletin »
   Vert forêt pour la structure, or kola pour l'unique accent, papier vert-gris pour le fond.
   La navigation porte un guilloché discret, comme l'impression de sécurité d'un billet :
   c'est le seul ornement ; le reste est calme, à plat, lisible.
   Montants et titres en Bricolage Grotesque (chiffres tabulaires), texte en IBM Plex Sans.
   Polices embarquées : fonctionne sans Internet.
   ============================================================================= */
@font-face { font-family: "IBM Plex Sans"; src: url("fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("fonts/ibm-plex-sans-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Bricolage"; src: url("fonts/bricolage-grotesque-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Bricolage"; src: url("fonts/bricolage-grotesque-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Bricolage"; src: url("fonts/bricolage-grotesque-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --papier: #eef1ec;        /* fond de page */
  --fond: var(--papier);
  --surface: #ffffff;
  --surface-2: #f6f8f5;     /* en-têtes de tableau, pieds de fenêtre */
  --encre: #17211c;
  --doux: #57635c;
  --trait: #d7ddd6;
  --trait-leger: #e9ede7;
  --foret: #123d30;         /* structure : navigation, actions principales */
  --foret-2: #1b5443;
  --foret-voile: #c7d6ce;
  --foret-pale: #e3ece7;
  --kola: #c4912f;          /* accent unique : marque, pastilles, élément actif */
  --kola-pale: #f6ecd8;
  --ambre: #9a6210;
  --ambre-pale: #f8eedb;
  --vert: #2e7d4f;
  --vert-pale: #e2f1e7;
  --rouge: #b23a2c;
  --rouge-pale: #f9e6e3;
  --rayon: 10px;
  --rayon-petit: 6px;
  --titre: "Bricolage", "IBM Plex Sans", system-ui, sans-serif;
  --texte: "IBM Plex Sans", system-ui, sans-serif;
  /* Guilloché : deux réseaux de cercles concentriques qui interfèrent */
  --guilloche:
    repeating-radial-gradient(circle at 0% 105%, transparent 0 11px, rgba(196, 145, 47, .13) 11px 12px),
    repeating-radial-gradient(circle at 110% -5%, transparent 0 15px, rgba(255, 255, 255, .06) 15px 16px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
#racine { min-height: 100%; }
body { font: 14px/1.5 var(--texte); color: var(--encre); background: var(--papier); -webkit-font-smoothing: antialiased; }
h1 { font: 600 27px/1.15 var(--titre); letter-spacing: -.02em; margin: 0; }
h2 { font: 600 17px/1.3 var(--titre); letter-spacing: -.01em; margin: 0 0 12px; }
h3 { font-size: 14px; font-weight: 600; margin: 0 0 8px; }
a { color: var(--foret-2); text-underline-offset: 2px; }
a:hover { color: var(--foret); }
:focus-visible { outline: 2px solid var(--kola); outline-offset: 2px; }
/* Chiffres et codes : alignés en colonnes, sans police à chasse fixe */
.mono, .num, .chiffre { font-variant-numeric: tabular-nums; }
.mono { letter-spacing: .02em; }
.num { text-align: right; white-space: nowrap; }
.doux { color: var(--doux); }
.petit { font-size: 12.5px; }
.cache { display: none !important; }

/* --- Marque ----------------------------------------------------------------------------- */
.marque { display: flex; align-items: baseline; gap: 1px; margin-bottom: 4px; font-family: var(--titre); }
.marque b { font-size: 28px; font-weight: 700; color: var(--foret); letter-spacing: -.03em; }
.marque span { color: var(--kola); font-weight: 700; font-size: 28px; letter-spacing: -.03em; }

/* --- Connexion ----------------------------------------------------------------------------- */
.connexion { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: var(--guilloche), var(--foret); }
.connexion-carte { width: 100%; max-width: 400px; background: var(--surface); border-radius: 14px; padding: 36px 34px 30px;
  border-top: 5px solid var(--kola); box-shadow: 0 24px 60px rgba(4, 22, 16, .45); }
.connexion-carte .marque b, .connexion-carte .marque span { font-size: 34px; }
.signature { color: var(--doux); margin: 2px 0 26px; font-size: 15px; }

/* --- Disposition ------------------------------------------------------------------------ */
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.nav { background: var(--guilloche), var(--foret); color: #c4d3ca; display: flex; flex-direction: column;
  padding: 22px 14px 18px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.nav .marque { padding: 0 10px 22px; }
.nav .marque b { color: #fff; font-size: 24px; }
.nav .marque span { font-size: 24px; }
.nav a { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-radius: var(--rayon-petit); color: #c4d3ca;
  text-decoration: none; font-weight: 500; position: relative; margin-bottom: 1px; }
.nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav a.actif { background: rgba(255, 255, 255, .11); color: #fff; }
.nav a.actif::before { content: ""; position: absolute; left: -14px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0;
  background: var(--kola); }
.nav .pastille { margin-left: auto; background: var(--kola); color: var(--foret); border-radius: 10px; font-size: 11px;
  padding: 0 7px; font-weight: 700; font-variant-numeric: tabular-nums; }
.nav .bas { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid rgba(255, 255, 255, .12); font-size: 12.5px; color: #fff; }
.nav .bas .doux { color: #9fb4a8; }
.principal { display: flex; flex-direction: column; min-width: 0; }
.barre { display: flex; align-items: center; gap: 12px; padding: 12px 32px; background: var(--surface);
  border-bottom: 1px solid var(--trait); position: sticky; top: 0; z-index: 5; }
.barre .espace { flex: 1; }
.contenu { padding: 28px 32px 56px; max-width: 1320px; width: 100%; }
.entete { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }
.entete .espace { flex: 1; }
.entete > .doux { font-size: 13px; }

/* --- Éléments ---------------------------------------------------------------------------- */
.carte { background: var(--surface); border: 1px solid var(--trait); border-radius: var(--rayon); padding: 20px; }
.carte > h2:first-child { margin-bottom: 14px; }
.grille { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g5 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* Indicateurs : le montant d'abord, en grand ; un filet or le relie à la marque */
.indicateur { position: relative; padding-top: 18px; }
.indicateur .libelle { color: var(--doux); font-size: 13px; font-weight: 500; }
.indicateur .valeur { font: 600 32px/1.1 var(--titre); letter-spacing: -.02em; margin-top: 6px; font-variant-numeric: tabular-nums;
  color: var(--foret); }
.indicateur .sous { color: var(--doux); font-size: 12.5px; margin-top: 6px; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--trait); background: var(--surface);
  color: var(--encre); padding: 8px 15px; border-radius: var(--rayon-petit); font: 500 14px/1.3 var(--texte);
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background-color .12s, border-color .12s; }
.btn:hover { border-color: #aebcb3; background: var(--surface-2); }
.btn.primaire { background: var(--foret); border-color: var(--foret); color: #fff; }
.btn.primaire:hover { background: var(--foret-2); border-color: var(--foret-2); }
.btn.succes { background: var(--vert); border-color: var(--vert); color: #fff; }
.btn.succes:hover { background: #276b43; }
.btn.danger { color: var(--rouge); }
.btn.danger:hover { border-color: var(--rouge); background: var(--rouge-pale); }
.btn.lien { border: 0; background: none; padding: 4px 6px; color: var(--foret-2); text-decoration: underline;
  text-decoration-color: var(--foret-voile); text-underline-offset: 3px; }
.btn.lien:hover { text-decoration-color: currentColor; background: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.petit { padding: 4px 10px; font-size: 12.5px; }

label.champ { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--doux); font-weight: 500; }
input, select, textarea { font: 14px/1.4 var(--texte); color: var(--encre); padding: 8px 10px; border: 1px solid var(--trait);
  border-radius: var(--rayon-petit); background: #fff; width: 100%; }
input:hover, select:hover, textarea:hover { border-color: #b9c6bd; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--foret-pale); border-color: var(--foret-2); }
input[type=number] { font-variant-numeric: tabular-nums; }
input[type=checkbox] { accent-color: var(--foret); }
.formulaire { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.formulaire .large { grid-column: 1 / -1; }
.formulaire h3 { grid-column: 1 / -1; margin: 10px 0 0; padding-top: 14px; border-top: 1px solid var(--trait-leger);
  font: 600 15px/1.3 var(--titre); color: var(--foret); }
.formulaire h3:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.case { flex-direction: row !important; align-items: center; gap: 8px !important; color: var(--encre) !important; }
.case input { width: auto; }

/* Tableaux : en-têtes en casse normale, montants alignés, total souligné d'un double filet comme sur un bulletin */
table.tab { width: 100%; border-collapse: collapse; background: var(--surface); }
.tab th { text-align: left; font-size: 12.5px; color: var(--doux); font-weight: 600; padding: 10px 14px;
  border-bottom: 1px solid var(--trait); background: var(--surface-2); white-space: nowrap; }
.tab td { padding: 11px 14px; border-bottom: 1px solid var(--trait-leger); vertical-align: middle; }
table.tab th.num, table.tab td.num { text-align: right; }
.tab tbody tr:last-child td { border-bottom: 0; }
.tab tbody tr:hover td { background: #fafbf9; }
.tab tr.cliquable { cursor: pointer; }
.tab tr.cliquable:hover td { background: var(--foret-pale); }
.tab td.num b, .tab td.num strong { font-family: var(--titre); font-weight: 600; }
.tab tfoot td { font-weight: 600; background: var(--surface); border-top: 3px double var(--encre); border-bottom: 0; }
.tableau-cadre { border: 1px solid var(--trait); border-radius: var(--rayon); overflow: auto; background: var(--surface); }
.carte .tableau-cadre { border-radius: var(--rayon-petit); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.5;
  background: var(--trait-leger); color: var(--doux); white-space: nowrap; }
.badge.vert { background: var(--vert-pale); color: var(--vert); }
.badge.ambre { background: var(--ambre-pale); color: var(--ambre); }
.badge.rouge { background: var(--rouge-pale); color: var(--rouge); }
.badge.marine { background: var(--foret-pale); color: var(--foret); }

.alerte { display: flex; gap: 10px; padding: 10px 12px; border-radius: var(--rayon-petit); background: var(--ambre-pale);
  color: #5f3d08; margin-bottom: 8px; border-left: 3px solid var(--kola); }
.alerte a { color: inherit; }
.info { padding: 10px 12px; border-radius: var(--rayon-petit); background: var(--foret-pale); color: var(--foret); }
.vide { padding: 30px 20px; text-align: center; color: var(--doux); }
.carte.vide { padding: 40px 20px; }
details summary { cursor: pointer; }

.onglets { display: flex; gap: 2px; border-bottom: 1px solid var(--trait); margin-bottom: 18px; overflow-x: auto; scrollbar-width: thin; }
.onglets button { border: 0; background: none; padding: 10px 12px; font: 500 14px/1.3 var(--texte); color: var(--doux);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.onglets button:hover { color: var(--encre); }
.onglets button.actif { color: var(--foret); border-bottom-color: var(--kola); font-weight: 600; }

.puces { display: flex; gap: 6px; flex-wrap: wrap; }
.puce { display: inline-flex; gap: 6px; align-items: center; background: var(--foret-pale); color: var(--foret);
  border-radius: 999px; padding: 2px 4px 2px 10px; font-size: 12.5px; }
.puce.retenue { background: var(--rouge-pale); color: var(--rouge); }
.puce button { border: 0; background: rgba(0, 0, 0, .07); border-radius: 50%; width: 18px; height: 18px; cursor: pointer;
  line-height: 1; color: inherit; }

dl.fiche { display: grid; grid-template-columns: 160px 1fr; gap: 8px 14px; margin: 0; }
dl.fiche dt { color: var(--doux); }
dl.fiche dd { margin: 0; }

/* Frise du dossier RH : la date à gauche, un filet vertical relie les événements */
ol.frise { list-style: none; margin: 0; padding: 0; }
.frise li { display: grid; grid-template-columns: 92px 1fr; gap: 14px; padding: 0 0 16px; position: relative; }
.frise li::before { content: ""; position: absolute; left: 100px; top: 6px; bottom: 0; width: 1px; background: var(--trait); }
.frise li:last-child::before { display: none; }
.frise li > div:last-child { padding-left: 14px; position: relative; display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.frise li > div:last-child::before { content: ""; position: absolute; left: -4px; top: 5px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--kola); }
.frise-date { color: var(--doux); font-size: 12.5px; font-variant-numeric: tabular-nums; text-align: right; padding-top: 1px; }

/* Barres horizontales (âges, ancienneté, budgets, trésorerie) */
.barre-ligne { display: grid; grid-template-columns: 130px 1fr 34px; gap: 10px; align-items: center; padding: 4px 0; font-size: 13px; }
.barre-piste { display: inline-block; width: 100%; max-width: 220px; height: 8px; border-radius: 4px; background: var(--trait-leger);
  overflow: hidden; vertical-align: middle; }
.barre-ligne .barre-piste { max-width: none; }
.barre-piste > span { display: block; height: 100%; background: var(--foret); border-radius: 4px; }

/* Organigramme : arborescence en retrait, filets de rattachement */
ul.organigramme, ul.organigramme ul { list-style: none; margin: 0; padding: 0; }
ul.organigramme ul { margin-left: 10px; padding-left: 16px; border-left: 1px solid var(--trait); }
ul.organigramme li { padding: 5px 0; }
ul.organigramme li > a { text-decoration: none; color: var(--encre); margin-right: 6px; }
ul.organigramme li > a:hover b { color: var(--foret-2); text-decoration: underline; }

/* Feuille de temps : jours de repos teintés */
.feuille-temps tr.repos td { background: var(--surface-2); }
.feuille-temps input[type=time] { max-width: 130px; }

/* Saisie rapide : cases serrées, sans cadre tant qu'on n'y est pas, comme un tableur */
.saisie-rapide td { padding: 3px 6px; vertical-align: top; }
.saisie-rapide input { border-color: transparent; background: transparent; padding: 6px 8px; font-variant-numeric: tabular-nums; }
.saisie-rapide input:hover { border-color: var(--trait); }
.saisie-rapide input:focus { background: #fff; }
.saisie-rapide input[aria-invalid=true] { border-color: var(--rouge); background: var(--rouge-pale); }
.saisie-rapide .sr-lib { padding: 0 8px 4px; min-height: 0; font-size: 11.5px; }
.saisie-rapide tbody tr:hover td { background: transparent; }

/* --- Fenêtre modale et messages --------------------------------------------------------- */
.voile { position: fixed; inset: 0; background: rgba(9, 30, 23, .5); display: grid; place-items: center; padding: 20px;
  z-index: 50; animation: apparait .14s ease-out; }
.modale { background: var(--surface); border-radius: 14px; width: 100%; max-width: 740px; max-height: 92vh; overflow: auto;
  box-shadow: 0 24px 70px rgba(4, 22, 16, .35); animation: monte .18s ease-out; }
.modale.etroite { max-width: 470px; }
.modale header { padding: 18px 22px; border-bottom: 1px solid var(--trait); display: flex; align-items: center; }
.modale header h2 { margin: 0; flex: 1; }
.modale .corps { padding: 20px 22px; }
.modale footer { padding: 14px 22px; border-top: 1px solid var(--trait); display: flex; gap: 8px; justify-content: flex-end;
  background: var(--surface-2); }
.erreur-form { color: var(--rouge); margin-top: 10px; font-size: 13px; }
.erreur-form:empty { display: none; }
#toasts { position: fixed; right: 22px; bottom: 22px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--foret); color: #fff; padding: 11px 16px; border-radius: var(--rayon-petit); max-width: 400px;
  box-shadow: 0 10px 30px rgba(4, 22, 16, .25); border-left: 4px solid var(--kola); animation: monte .18s ease-out; }
.toast.erreur { background: var(--rouge); border-left-color: #fff3; }
.toast.ok { background: var(--vert); border-left-color: #fff5; }
@keyframes apparait { from { opacity: 0; } }
@keyframes monte { from { opacity: 0; transform: translateY(8px); } }

/* --- Graphique --------------------------------------------------------------------------- */
.graphique svg { width: 100%; height: auto; display: block; }
.graphique text { font-family: var(--texte); }

/* --- Adaptation aux petits écrans ------------------------------------------------------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .nav { flex-direction: row; overflow-x: auto; padding: 8px; height: auto; position: static; gap: 2px; }
  .nav a { white-space: nowrap; }
  .nav a.actif::before { left: 10px; right: 10px; top: auto; bottom: 2px; width: auto; height: 3px; border-radius: 3px 3px 0 0; }
  .nav .marque, .nav .bas { display: none; }
  .g4, .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .barre { padding: 10px 16px; position: static; }
  .contenu { padding: 18px 16px 40px; }
  h1 { font-size: 23px; }
  .indicateur .valeur { font-size: 26px; }
}
@media (max-width: 560px) {
  .g4, .g3, .g2, .formulaire { grid-template-columns: 1fr; }
  .grille[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
  .frise li { grid-template-columns: 1fr; gap: 2px; } .frise li::before { display: none; } .frise-date { text-align: left; }
  .barre { flex-wrap: wrap; }
  .barre select { min-width: 0 !important; flex: 1; }
  .barre label { display: none; }
  dl.fiche { grid-template-columns: 1fr; gap: 2px; }
  dl.fiche dd { margin-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* --- Console de l'éditeur --------------------------------------------------------------------- */
.console .nav .etiquette { margin: -14px 10px 18px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--kola); font-weight: 600; }
.console .barre .role { font-size: 12px; }
.statut { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.statut.ESSAI { background: var(--kola-pale); color: var(--ambre); }
.statut.ACTIF { background: var(--vert-pale); color: var(--vert); }
.statut.IMPAYE { background: var(--rouge-pale); color: var(--rouge); }
.statut.SUSPENDU { background: #2b2f2d; color: #fff; }
.statut.RESILIE { background: var(--trait-leger); color: var(--doux); }
.jauge { height: 6px; border-radius: 3px; background: var(--trait-leger); overflow: hidden; margin-top: 4px; }
.jauge > i { display: block; height: 100%; background: var(--foret-2); }
.jauge.pleine > i { background: var(--rouge); }
.filtres { display: flex; gap: 6px; flex-wrap: wrap; }
.filtres button { border: 1px solid var(--trait); background: var(--surface); border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 13px; cursor: pointer; color: var(--doux); }
.filtres button.actif { background: var(--foret); border-color: var(--foret); color: #fff; }
.filtres button b { margin-left: 4px; }
.fil { border-left: 2px solid var(--trait); padding-left: 14px; }
.fil .element { position: relative; padding-bottom: 12px; }
.fil .element::before { content: ""; position: absolute; left: -19px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--foret-voile); }
.secret { font: 600 16px/1.4 var(--titre); letter-spacing: .04em; background: var(--kola-pale); padding: 8px 12px; border-radius: 6px; user-select: all; }
.jauge.limite > i { background: var(--kola); }
.console .nav { position: sticky; top: 0; height: 100vh; }

/* Barre de période : dates Du / Au + raccourcis (Aujourd'hui, Ce mois, Mois précédent, Cette année, Tout) */
.barre-periode { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; padding: 14px 18px; margin-bottom: 16px; }
.barre-periode .champ { min-width: 150px; }
.barre-periode .espace { flex: 1; }
.barre-periode .raccourcis { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--trait); border-radius: var(--rayon-petit); padding: 3px; gap: 2px; background: var(--surface); }
.barre-periode .raccourcis button { border: 0; background: none; font: inherit; font-size: 13px; color: var(--doux); padding: 6px 12px; border-radius: 5px; cursor: pointer; }
.barre-periode .raccourcis button:hover { color: var(--encre); background: var(--surface-2); }
.barre-periode .raccourcis button.actif { background: var(--foret-pale); color: var(--foret); font-weight: 600; }
.barre-periode .raccourcis button:focus-visible { outline: 2px solid var(--kola); outline-offset: 1px; }
@media (max-width: 720px) { .barre-periode .espace { display: none; } }
