:root {
  --paper: #f3f1eb;
  --ink: #1b2a30;
  --muted: #5d6e75;
  --pine: #143f3c;
  --pine-soft: #1d524e;
  --leaf: #1f8a70;
  --mint: #e5f6f0;
  --gold: #c6a15b;
  --line: #e3ddd0;
  --card: #fffcf8;
  --ok: #0e7a4b;
  --danger: #9d2c3a;
  --loan: #fff4cc;
  --late: #f6ddb0;
  --serif: "Fraunces", "Iowan Old Style", Palatino, Georgia, serif;
  --sans: "Figtree", "Segoe UI", sans-serif;
  --shadow: 0 1px 0 rgba(27, 42, 48, 0.04), 0 16px 40px rgba(27, 42, 48, 0.06);
  --radius: 18px;
  color: var(--ink);
  background: var(--paper);
  font: 16px/1.5 var(--sans);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; }
a { color: var(--pine); }
h1, h2, h3 { font-family: var(--serif); font-weight: 560; line-height: 1.15; letter-spacing: -0.02em; }
h1 { font-size: 2rem; margin: 0; }
h2 { font-size: 1.3rem; margin: 0 0 0.8rem; }
h2.suite { margin-top: 1.6rem; }
p { margin: 0.35rem 0; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--leaf); outline-offset: 2px; }

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  background: white;
  padding: 0.5rem 0.8rem;
  z-index: 6;
  border-radius: 8px;
}
.skip:focus { top: 1rem; }

.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 252px;
  flex: none;
  background: var(--pine);
  color: #f3f7f4;
  padding: 1.3rem 0.9rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}
.marque { padding: 0.2rem 0.7rem 0.4rem; }
.marque-nom {
  display: block;
  font-family: var(--serif);
  font-size: 1.35rem;
  line-height: 1.15;
}
.logo-sous { display: block; color: #c9ddd6; font-size: 0.78rem; margin-top: 0.25rem; }
.sidebar nav { display: flex; flex-direction: column; gap: 0.15rem; }
.sidebar a {
  color: #e7f3ef;
  text-decoration: none;
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
}
.sidebar a:hover, .sidebar a.active { background: rgba(255, 255, 255, 0.1); color: white; }
.sidebar a.active { box-shadow: inset 3px 0 0 var(--gold); }
.workspace { flex: 1; min-width: 0; }
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 0.85rem 1.6rem;
  background: rgba(255, 252, 248, 0.9);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 2;
  backdrop-filter: blur(10px);
}
.qui { display: flex; flex-direction: column; }
.qui small, .sous, .page-entete p, .hint, .legende { color: var(--muted); }
.top-actions, .actions, .ligne-actions { display: flex; gap: 0.55rem; align-items: center; flex-wrap: wrap; }
.top-actions a { text-decoration: none; }
button.menu-btn { display: none; }
main { padding: 1.6rem; }
.papier { max-width: 860px; margin: 0 auto; }
.page-entete, .fiche-entete {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1.1rem;
}
.page-entete p { margin-top: 0.3rem; }

.carte h2:not(:first-child) { margin-top: 1.35rem; }
.carte, .simple-carte {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem;
  box-shadow: var(--shadow);
}
.simple {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(circle at top left, rgba(31, 138, 112, 0.18), transparent 26rem),
    var(--paper);
}
.simple-carte { width: min(480px, 100%); }
.simple-carte h1 { margin-bottom: 0.2rem; }
.marque-login {
  font-family: var(--serif);
  font-size: 1.8rem;
  margin: 0;
}

.flash { padding: 0.75rem 0.9rem; border-radius: 12px; margin-bottom: 1rem; }
.flash.ok { background: #e7f6ee; color: var(--ok); }
.flash.erreur, .error { color: var(--danger); }
.flash.erreur { background: #fdeceb; }
.field-error input, .field-error select, .field-error textarea { border-color: var(--danger); }

.form-grid, .grille-2, .stats {
  display: grid;
  gap: 0.9rem 1rem;
}
.form-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form-ligne { display: grid; gap: 0.9rem 1rem; margin-bottom: 0.9rem; }
.form-ligne.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-ligne.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-ligne.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
dialog.fenetre {
  width: min(42rem, 75vw);
  max-width: 75vw;
  max-height: 75vh;
  overflow: auto;
  border: 0;
  border-radius: 16px;
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow);
  color: inherit;
}
dialog.fenetre::backdrop { background: rgba(16, 32, 30, 0.48); }
dialog.fenetre h2 { margin-top: 0; }
ul.historique { margin: 0; padding-left: 1.1rem; }
ul.historique li { margin: 0.15rem 0; }
.grille-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); align-items: start; }
.stats { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 1rem; }
.wide { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 0.35rem; }
label { font-size: 0.92rem; }
.req { color: var(--leaf); }
input, select, textarea {
  background: white;
  border: 1px solid #d9d3c6;
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
  width: 100%;
}
textarea { resize: vertical; min-height: 7rem; }
.hint { font-size: 0.85rem; margin: 0; }
.checks { display: flex; flex-direction: column; gap: 0.45rem; margin: 0.4rem 0 1rem; }
.checks.ligne { flex-direction: row; flex-wrap: wrap; gap: 0.35rem 1.4rem; }
.grille-contact {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem 1.25rem;
}
.check { display: flex; gap: 0.55rem; align-items: flex-start; }
.check input { width: auto; margin-top: 0.25rem; }

.btn, button, input[type="submit"] {
  border: 0;
  background: var(--pine);
  color: white;
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.btn.second, button.second { background: transparent; color: var(--pine); border: 1px solid #c9c2b3; }
.btn.danger, button.danger { background: var(--danger); color: white; }
.btn.small, button.small { padding: 0.28rem 0.6rem; font-size: 0.85rem; }
button:hover, .btn:hover { filter: brightness(1.05); }
button:disabled { opacity: 0.55; cursor: not-allowed; }
.lien-discret { color: var(--muted); font-size: 0.9rem; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; background: white; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.7rem 0.8rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); background: #f7f4ee; }
tr.en-pret td { background: var(--loan); }
tr.en-pret.retard td { background: var(--late); }
tbody tr:last-child td { border-bottom: 0; }
.badge {
  display: inline-block;
  padding: 0.08rem 0.5rem;
  border-radius: 99px;
  background: var(--mint);
  color: var(--pine);
  font-size: 0.78rem;
  margin-right: 0.25rem;
}
.badge.ok { background: #e5f4ec; color: var(--ok); }
.badge.mute { background: #eeeae3; color: #555; }
.badge.alert { background: #f0c36d; color: #5a3b00; }
.stat strong { display: block; font-family: var(--serif); font-size: 1.8rem; font-weight: 560; }
.stat a { text-decoration: none; }
.fiche-personne {
  display: grid;
  grid-template-columns: minmax(17rem, 24rem) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}
.fiche-identite { padding: 1rem 1.1rem; }
fieldset.acces, fieldset.groupe {
  border: 1px solid var(--line);
  border-radius: 12px;
  margin: 0.9rem 0 0;
  padding: 0.7rem 0.9rem 0.15rem;
}
fieldset.groupe { margin: 0 0 1rem; padding: 0.85rem 1rem 0.3rem; }
fieldset.acces legend, fieldset.groupe legend { font-weight: 700; padding: 0 0.3rem; }
.niveau-fixe { margin: 0.35rem 0 0.2rem; }
.portrait { width: 96px; height: 96px; object-fit: cover; border-radius: 16px; }
select[multiple] { min-height: 7.5rem; }
.onglets { display: flex; gap: 0.35rem; flex-wrap: wrap; margin: 0.2rem 0 1rem; }
.onglets a {
  text-decoration: none;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.38rem 0.75rem;
}
.onglets a.actif { background: white; color: var(--pine); box-shadow: inset 0 -2px 0 var(--leaf); }
.filtres { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: end; margin-bottom: 1rem; }
.filtres .field { min-width: 180px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover;
  display: inline-grid; place-items: center; background: var(--mint); color: var(--pine);
  font-size: 0.75rem; font-weight: 700;
}
.avatar.grand { width: 84px; height: 84px; font-size: 1.2rem; }
.personne { display: flex; gap: 0.65rem; align-items: center; }
.outils-note { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin: 0.4rem 0; }
.outils-note .hint { flex-basis: 100%; margin: 0.15rem 0 0; }
.definition { display: grid; grid-template-columns: minmax(140px, 220px) 1fr; gap: 0.4rem 1rem; margin: 0; }
.definition dt { color: var(--muted); }
.definition dd { margin: 0; }
.legende { font-size: 0.9rem; margin: 0.35rem 0 0.8rem; }
.pastille { display: inline-block; width: 0.85rem; height: 0.85rem; border-radius: 3px; vertical-align: -1px; margin-right: 0.25rem; }
.pastille.jaune { background: var(--loan); border: 1px solid #ead78a; }
.pastille.ambre { background: var(--late); border: 1px solid #e2c07a; }
.vide { color: var(--muted); }
.recu { max-width: 780px; margin: 0 auto; background: white; padding: 2rem; border: 1px solid var(--line); border-radius: 16px; }
.recu h1 { font-size: 1.7rem; }
.recu .montant { font-family: var(--serif); font-size: 1.8rem; margin: 0.4rem 0; }
.feuille-recu {
  width: min(8.5in, 100%);
  margin: 0 auto;
  background: white;
  color: #111;
  font-family: "Times New Roman", Times, serif;
  font-size: 11.5px;
  line-height: 1.3;
  padding: 0.35in 0.4in;
}
.exemplaire-haut { display: grid; grid-template-columns: 1.15in minmax(0, 1fr) minmax(2.4in, 38%); gap: 0.35rem 0.6rem; align-items: start; }
.logo-recu {
  font-family: "Segoe Script", "Brush Script MT", "Snell Roundhand", cursive;
  color: #1f8a4c;
  font-size: 15px;
  line-height: 1.05;
  font-weight: 700;
}
.org-recu strong { font-size: 13px; }
.exemplaire-droit { text-align: right; }
.numero-recu { font-size: 15px; font-weight: 700; letter-spacing: 0.04em; }
.titre-recu { font-weight: 700; margin-top: 0.45rem; }
.enregistrement { margin-top: 0.35rem; }
.ligne-recu, .ligne-montants, .precision-recu, .admissible, .merci, .avis-cra { margin: 0.12rem 0; }
.libelle-recu { display: inline-block; min-width: 4.6rem; }
.ligne-montants { display: flex; flex-wrap: wrap; gap: 0.2rem 0.55rem; align-items: baseline; }
.valeur-avantage { margin-left: 1.2rem; }
.precision-recu { margin-left: 46%; font-size: 10px; }
.admissible, .merci { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; }
.merci em { font-style: italic; font-weight: 700; }
.signature { white-space: nowrap; }
.avis-cra { text-align: center; font-size: 10px; margin-top: 0.2rem; }
.decoupe { display: flex; align-items: center; gap: 0.35rem; margin: 0.28rem 0 0.2rem; color: #222; }
.decoupe::after { content: ""; flex: 1; border-top: 1px dotted #222; }
.note-complete { border-left: 3px solid var(--leaf); padding-left: 0.8rem; margin: 1rem 0; }
.barre-impression { display: flex; gap: 0.6rem; margin: 0 auto 1rem; max-width: 780px; }
.apercu { background: #faf8f3; border-radius: 12px; padding: 0.8rem 1rem; margin-top: 0.6rem; }
.choix-liste { list-style: none; padding: 0; margin: 0 0 0.8rem; }
.choix-liste li { display: flex; justify-content: space-between; gap: 1rem; align-items: center; padding: 0.35rem 0; border-bottom: 1px solid var(--line); }
.extrait {
  white-space: pre-wrap;
  background: #f7f4ee;
  border-radius: 12px;
  padding: 0.8rem 1rem;
  font-family: ui-monospace, monospace;
}
.seance { margin-top: 0.8rem; }
.nom-usager { display: block; color: var(--muted); font-size: 0.82rem; }

@media (max-width: 860px) {
  button.menu-btn { display: inline-flex; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 4;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
  }
  .sidebar.ouvert { transform: none; box-shadow: 8px 0 24px rgba(20, 63, 60, 0.2); }
  .topbar, main { padding-left: 1rem; padding-right: 1rem; }
  .page-entete, .fiche-entete, .topbar { align-items: stretch; flex-direction: column; }
  .definition, .grille-contact, .form-ligne.cols-3, .form-ligne.cols-4, .form-ligne.cols-5, .fiche-personne { grid-template-columns: 1fr; }
}

@media print {
  .sidebar, .topbar, .no-print, .menu-btn, .barre-impression { display: none !important; }
  body, .workspace, main, .papier { background: white; padding: 0; margin: 0; }
  .carte, .recu, .feuille-recu { box-shadow: none; border: 0; width: auto; max-width: none; padding: 0; }
  .exemplaire, .decoupe { break-inside: avoid; }
  @page { size: letter; margin: 0.35in; }
}
