:root {
  --fond: #f4f5f7;
  --surface: #ffffff;
  --texte: #1f2933;
  --secondaire: #6b7785;
  --bordure: #d8dde3;
  --bordure-forte: #b8c0c9;
  --accent: #2463b8;
  --marine: #282058;
  --marine-clair: #ecebf5;
  --orange: #f09000;
  --accent-texte: #ffffff;
  --danger: #b42318;
  --emise: #cfe8d4;
  --emise-bord: #4c9a5f;
  --a-emettre: #ffffff;
  --a-emettre-bord: #2463b8;
  --a-couvrir: #fff1d6;
  --avant: #eef0f2;
  --fin: #e4e7eb;
  --courant: #fff9c4;
  --acompte: #e8e0f8;
  --avoir: #fde2e1;
  --note: #f1f3f5;
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 13px;
  color: var(--texte);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--fond);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  padding: 5px 12px;
  border: 1px solid var(--bordure-forte);
  border-radius: 4px;
  background: var(--surface);
  cursor: pointer;
}
button:hover:not(:disabled) {
  border-color: var(--accent);
}
button:disabled {
  opacity: 0.5;
  cursor: default;
}
button.primaire {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-texte);
}
button.danger {
  color: var(--danger);
}
button.discret {
  border: none;
  background: none;
  font-size: 16px;
}
button.lien {
  border: none;
  background: none;
  padding: 0;
  color: var(--accent);
  text-decoration: underline;
}

input,
select,
textarea {
  padding: 5px 7px;
  border: 1px solid var(--bordure-forte);
  border-radius: 4px;
  background: var(--surface);
}

code {
  font-size: 12px;
  word-break: break-all;
}
.secondaire {
  color: var(--secondaire);
}
.erreur {
  color: var(--danger);
}
.espace {
  flex: 1;
}
.vide {
  padding: 24px;
  text-align: center;
  color: var(--secondaire);
}

/* --- Accueil : choix de base et connexion --- */
.ecran-accueil {
  display: grid;
  place-items: center;
  min-height: 100vh;
}
.carte {
  width: min(520px, 92vw);
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: 8px;
}
.logo-accueil {
  display: block;
  width: 190px;
  margin: 0 auto 18px;
}
.carte h1 {
  margin-top: 0;
  font-size: 20px;
}
.actions,
.liste-utilisateurs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}
.ligne-form {
  display: flex;
  gap: 8px;
}
.ligne-form input {
  flex: 1;
}

/* --- Coque : barre latérale + contenu --- */
.coque {
  display: flex;
  height: 100vh;
}
.laterale {
  display: flex;
  flex-direction: column;
  flex: 0 0 236px;
  gap: 14px;
  padding: 16px 12px 12px;
  background: var(--surface);
  border-right: 1px solid var(--bordure);
  overflow-y: auto;
}
.laterale .logo {
  width: 168px;
  margin: 0 auto;
}
.nom-app {
  margin-top: -6px;
  text-align: center;
  color: var(--marine);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.choix-societe {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.choix-societe span,
.titre-groupe {
  color: var(--secondaire);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.groupe-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 14px;
}
.titre-groupe {
  padding: 0 8px 4px;
}
.groupe-nav button {
  padding: 7px 10px;
  border: none;
  border-left: 3px solid transparent;
  border-radius: 0 6px 6px 0;
  background: none;
  text-align: left;
}
.groupe-nav button:hover {
  background: var(--fond);
}
.groupe-nav button.actif {
  border-left-color: var(--orange);
  background: var(--marine-clair);
  color: var(--marine);
  font-weight: 600;
}
.pied-laterale {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--bordure);
  font-size: 12px;
}
.onglets-modale button {
  border-color: transparent;
}
.onglets-modale button.actif {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
main {
  flex: 1;
  min-width: 0;
  overflow: auto;
}

.page {
  padding: 12px 16px;
}
.page h1 {
  margin: 0;
  font-size: 17px;
}
.barre-outils {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.groupe-cases {
  display: flex;
  gap: 10px;
}
.case {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.plage input {
  margin: 0 4px;
}
.indicateur {
  padding: 4px 8px;
  background: var(--courant);
  border-radius: 4px;
}

/* --- Tableaux simples --- */
.tableau {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}
.tableau th,
.tableau td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--bordure);
  text-align: left;
}
.tableau th {
  background: var(--fond);
  font-weight: 600;
}
.tableau.compact td,
.tableau.compact th {
  padding: 4px 6px;
}
.tableau tr.inactive td {
  color: var(--secondaire);
}
.actions-ligne {
  white-space: nowrap;
  text-align: right !important;
}
.actions-ligne button + button {
  margin-left: 6px;
}

/* --- Grille de suivi --- */
.page-suivi {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.conteneur-grille {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--bordure);
  background: var(--surface);
}
.grille {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}
.grille th,
.grille td {
  padding: 3px 5px;
  border-right: 1px solid var(--bordure);
  border-bottom: 1px solid var(--bordure);
  white-space: nowrap;
  background: var(--surface);
}
.grille thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--fond);
  font-weight: 600;
}
.grille .fixe {
  position: sticky;
  z-index: 1;
}
.grille thead .fixe {
  z-index: 3;
}
.grille .c1 {
  left: 0;
}
.grille .c2 {
  left: 121px;
}
.grille .c3 {
  left: 292px;
  border-right: 2px solid var(--bordure-forte);
}
/* Largeur fixe des colonnes figées : contenu (div) + 10px de marges + 1px de bordure,
   les décalages « left » ci-dessus en dépendent. */
.grille .fixe > div {
  overflow: hidden;
  text-overflow: ellipsis;
}
.grille .c1 > div {
  width: 110px;
}
.grille .c2 > div {
  width: 160px;
}
.grille .c3 > div {
  width: 170px;
}
.grille .cliquable {
  cursor: pointer;
}
.grille tr:hover td.cliquable {
  color: var(--accent);
  text-decoration: underline;
}
.grille .nombre {
  text-align: right;
}
.grille th.mois,
.grille td.mois {
  width: 84px;
  min-width: 84px;
  text-align: center;
}
.grille td.mois {
  cursor: pointer;
  color: var(--secondaire);
  font-size: 11px;
}
.grille td.mois:hover {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.grille th.courant {
  background: var(--courant);
}
.grille td.m-avant {
  background: var(--avant);
}
.grille td.m-a_couvrir {
  background: var(--a-couvrir);
}
.grille td.m-fin,
.grille td.m-annule {
  background: var(--fin);
  font-size: 10px;
}
.grille td.m-annule {
  color: var(--danger);
}
.grille td.courant {
  box-shadow:
    inset 2px 0 0 #e0c200,
    inset -2px 0 0 #e0c200;
}
.grille tr.statut-termine td,
.grille tr.statut-annule td {
  color: var(--secondaire);
}

.pastille {
  display: block;
  margin: 1px 0;
  padding: 1px 3px;
  border: 1px dashed var(--a-emettre-bord);
  border-radius: 3px;
  background: var(--a-emettre);
  color: var(--texte);
  line-height: 1.25;
  white-space: normal;
}
.pastille.emise {
  border: 1px solid var(--emise-bord);
  background: var(--emise);
}
.pastille.t-acompte {
  background: var(--acompte);
}
.pastille.t-avoir {
  background: var(--avoir);
}
.pastille.t-note {
  border: 1px solid var(--bordure);
  background: var(--note);
  font-style: italic;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.pastille.deborde,
.puce.deborde {
  border: 2px solid var(--danger);
}
.lignes-mois .pastille {
  display: inline-block;
}

.legende {
  margin: 6px 0 0;
  color: var(--secondaire);
  font-size: 12px;
}
.puce {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin: 0 3px -2px 8px;
  border-radius: 2px;
}
.puce.emise {
  background: var(--emise);
  border: 1px solid var(--emise-bord);
}
.puce.a-emettre {
  border: 1px dashed var(--a-emettre-bord);
}
.puce.a-couvrir {
  background: var(--a-couvrir);
  border: 1px solid var(--bordure);
}

.badge {
  margin-left: 4px;
  padding: 0 4px;
  border-radius: 3px;
  background: var(--acompte);
  font-size: 10px;
}
.etiquette {
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
}
.etiquette.actif {
  background: var(--emise);
}
.etiquette.termine {
  background: var(--fin);
}
.etiquette.annule {
  background: var(--avoir);
  color: var(--danger);
}

/* --- Modales et formulaires --- */
.voile {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgb(15 23 42 / 0.35);
}
.modale {
  width: min(560px, 94vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: 0 10px 40px rgb(0 0 0 / 0.25);
}
.modale.large {
  width: min(860px, 94vw);
}
.modale header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--bordure);
}
.modale h2 {
  margin: 0;
  font-size: 15px;
}
.modale .contenu {
  padding: 14px 16px;
  overflow: auto;
}
.onglets-modale {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}

.formulaire {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.formulaire.grille-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
}
.formulaire .large {
  grid-column: 1 / -1;
}
.champ {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.champ > span {
  color: var(--secondaire);
  font-size: 12px;
}
.champ.en-erreur input,
.champ.en-erreur select {
  border-color: var(--danger);
}
.champ-avec-bouton {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}
.champ-avec-bouton .champ {
  flex: 1;
}
.duo {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 10px;
}
.pied {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}

.lignes-mois {
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}
.lignes-mois li {
  display: grid;
  grid-template-columns: 120px 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--bordure);
}

.notes {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}
.notes li {
  padding: 8px 0;
  border-bottom: 1px solid var(--bordure);
}
.notes p {
  margin: 3px 0 0;
  white-space: pre-wrap;
}
.details-audit {
  max-width: 420px;
  white-space: normal;
  color: var(--secondaire);
}

.notifications {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.notification {
  max-width: 420px;
  padding: 10px 14px;
  border-radius: 6px;
  background: #1f2933;
  color: #fff;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.2);
}
.notification.erreur {
  background: var(--danger);
}

/* --- Prix moyen mensuel par crèche --- */
.tableau-pm .p1 {
  left: 0;
  min-width: 170px;
  max-width: 170px;
  white-space: normal;
  vertical-align: middle;
  font-weight: 600;
}
.tableau-pm .p2 {
  left: 170px;
  min-width: 110px;
  border-right: 2px solid var(--bordure-forte);
  color: var(--secondaire);
}
.tableau-pm td.nombre {
  min-width: 84px;
  text-align: right;
}
.tableau-pm td.courant {
  background: var(--courant);
}
.tableau-pm tr.nb td {
  border-bottom: 1px solid var(--bordure-forte);
  color: var(--secondaire);
}
.tableau-pm tr.total td {
  background: var(--fond);
  font-weight: 600;
}

/* --- Comptes et mots de passe --- */
.saisie-mdp {
  display: flex;
  align-items: center;
  gap: 6px;
}
.saisie-mdp input {
  flex: 1;
  font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
}
.saisie-mdp button.discret {
  font-size: 12px;
  color: var(--accent);
}
.regles-mdp {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  columns: 2;
  font-size: 12px;
  color: var(--secondaire);
}
.regles-mdp li.ok {
  color: var(--emise-bord);
}
.avertissement {
  padding: 8px 10px;
  border-radius: 4px;
  background: var(--a-couvrir);
}
.liens-compte {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  margin-top: 6px;
}

.recalcul {
  max-width: 560px;
}
.recalcul h3 {
  margin: 14px 0 4px;
  font-size: 13px;
  color: var(--marine);
}
.recalcul ul {
  margin: 0;
  padding-left: 20px;
}
.recalcul ul.supprimees {
  color: var(--danger);
}
.recalcul .fleche {
  color: var(--secondaire);
}

.version {
  margin: 8px 0 0;
  font-size: 11px;
  color: var(--secondaire);
}
.carte .version {
  margin-top: 18px;
  text-align: center;
}

/* --- Sélection pour facturation (clic droit) --- */
.pastille.selectionnee,
.puce.selectionnee {
  border: 2px solid var(--orange);
  background: #fff3df;
}
.pastille.selectionnee::before {
  content: '✓ ';
  color: var(--orange);
  font-weight: 700;
}
.indicateur-selection {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.indicateur-selection button.selection {
  padding: 4px 10px;
  border: 1px solid var(--orange);
  border-radius: 4px;
  background: var(--orange);
  color: #fff;
  cursor: pointer;
}
.indicateur-selection button.selection:hover {
  background: #d98200;
}
.emission p {
  margin: 0 0 10px;
}
.emission .champ {
  max-width: 220px;
  margin-bottom: 12px;
}
.emission table {
  margin-bottom: 10px;
}
.tableau tfoot td {
  font-weight: 600;
  background: var(--fond);
}

/* --- Suivi de la facturation --- */
.page-facturation {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.conteneur-tableau {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--bordure);
  background: var(--surface);
}
.registre th {
  position: sticky;
  top: 0;
  z-index: 1;
}
.registre tfoot td {
  position: sticky;
  bottom: 0;
}
.registre td {
  white-space: nowrap;
}
.registre td.secondaire {
  white-space: normal;
}
.tableau tr.cliquable {
  cursor: pointer;
}
.tableau tr.cliquable:hover td {
  background: var(--marine-clair);
}
.non-paye {
  color: #b45309;
}
.resume-facture {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 12px;
  margin: 0 0 6px;
  padding: 8px 10px;
  background: var(--fond);
  border-radius: 6px;
}
.resume-facture dt {
  color: var(--secondaire);
}
.resume-facture dd {
  margin: 0;
}

/* --- Relances d'une facture --- */
.relances {
  margin-top: 14px;
}
.relances h3 {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--marine);
}
.relances tfoot td {
  background: var(--fond);
}
.saisie-relance input,
.saisie-relance select {
  width: 100%;
}
.saisie-relance td:first-child {
  width: 150px;
}
.saisie-relance .en-erreur {
  border-color: var(--danger);
  background: #fff5f5;
}
.modale > .contenu > .pied {
  margin-top: 14px;
}

/* --- Boutons-icônes (actions en début de ligne) --- */
.icones-ligne {
  width: 1%;
  white-space: nowrap;
}
button.icone {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 4px;
  background: none;
  color: var(--marine);
  cursor: pointer;
}
button.icone + button.icone {
  margin-left: 2px;
}
button.icone:hover:not(:disabled) {
  border-color: var(--bordure);
  background: var(--marine-clair);
}
button.icone.danger {
  color: var(--danger);
}
button.icone.danger:hover:not(:disabled) {
  background: #fdecea;
}
button.icone:disabled {
  opacity: 0.35;
  cursor: default;
}
button.icone.valider {
  color: #2e7d32;
}
button.icone.valider:hover:not(:disabled) {
  background: #e7f4e8;
}
