/* Palette tirée du logo du club : bleu ciel, marine, jaune de l'avion. */
:root {
  --marine: #0f2d4a;
  --marine-2: #17406a;
  --bleu: #1273c4;
  --bleu-fonce: #0d5c9e;
  --bleu-pale: #e8f2fb;
  --jaune: #f2b705;
  --vert: #1b8a4c;
  --vert-pale: #e3f4ea;
  --orange: #b96a00;
  --orange-pale: #fdf0d9;
  --rouge: #c43c3c;
  --rouge-pale: #fbe6e6;
  --fond: #f3f5f8;
  --carte: #ffffff;
  --bord: #dde3ea;
  --bord-fort: #c5ced9;
  --texte: #1b2633;
  --texte-2: #5a6878;
  --rayon: 10px;
  --ombre: 0 1px 2px rgba(15, 45, 74, 0.06), 0 2px 8px rgba(15, 45, 74, 0.05);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--texte);
  background: var(--fond);
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.25;
  text-wrap: balance;
}

a {
  color: var(--bleu);
}

.chargement {
  padding: 48px;
  text-align: center;
  color: var(--texte-2);
}

/* ---------- Structure ---------- */
.app {
  display: grid;
  /* 264 px (et liens du menu un peu moins espacés) : « Cotisation/Licences FFAM » tient sur une ligne, même avec la barre de défilement. */
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
}

.barre-laterale {
  background: var(--marine);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.marque {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 16px 14px;
  text-decoration: none;
  color: #fff;
}

.marque img {
  width: 132px;
  background: #fff;
  border-radius: 12px;
  padding: 6px 8px;
}

.marque span {
  font-size: 12.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #b8cbe0;
}

/* Retour au site vitrine du club (amcb.club) */
.retour-site {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0 16px 4px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  color: #fff;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
}

.retour-site:hover {
  background: rgba(255, 255, 255, 0.08);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  flex: 1;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: #d5e2f0;
  text-decoration: none;
  font-weight: 500;
}

.nav a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.nav a.actif {
  background: var(--bleu);
  color: #fff;
}

.nav .separateur {
  height: 1px;
  background: rgba(255, 255, 255, 0.12);
  margin: 8px 6px;
}

.pied-lateral {
  padding: 12px 16px 16px;
  font-size: 12.5px;
  color: #9fb6ce;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.pied-lateral strong {
  display: block;
  color: #fff;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.pied-lateral .actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  margin-top: 8px;
}

.pied-lateral button {
  background: none;
  border: 0;
  padding: 2px 0;
  color: #cfe0f2;
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.pied-lateral button:hover {
  color: #fff;
}

.principal {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.entete {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 28px 0;
}

.entete h1 {
  font-size: 23px;
  flex: 1;
  min-width: 0;
}

.entete .saison {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--texte-2);
  font-size: 14px;
  white-space: nowrap;
}

.contenu {
  padding: 18px 28px 48px;
  width: 100%;
  max-width: 1500px;
}

/* ---------- Icônes ---------- */
.icone {
  width: 18px;
  height: 18px;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Boutons ---------- */
[hidden] {
  display: none !important;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 6px 13px;
  border: 1px solid var(--bord-fort);
  border-radius: 8px;
  background: #fff;
  color: var(--texte);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  background: #f1f4f8;
}

.btn.primaire {
  background: var(--bleu);
  border-color: var(--bleu);
  color: #fff;
}

.btn.primaire:hover {
  background: var(--bleu-fonce);
}

.btn.danger {
  color: var(--rouge);
  border-color: #e3b5b5;
}

.btn.danger:hover {
  background: var(--rouge-pale);
}

.btn.discret {
  border-color: transparent;
  background: transparent;
  color: var(--bleu);
  padding: 4px 8px;
  min-height: 30px;
}

.btn.discret:hover {
  background: var(--bleu-pale);
}

.btn.petit {
  min-height: 28px;
  padding: 2px 9px;
  font-size: 13px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

:focus-visible {
  outline: 2px solid var(--bleu);
  outline-offset: 2px;
}

/* ---------- Cartes et grilles ---------- */
.carte {
  background: var(--carte);
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 18px 20px;
}

.carte > h2 {
  font-size: 16px;
  margin-bottom: 12px;
}

.carte.sans-marge {
  padding: 0;
  overflow: hidden;
}

.grille {
  display: grid;
  gap: 16px;
}

.grille.kpi {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.grille.deux {
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  align-items: start;
}

.pile {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.kpi .carte {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kpi .libelle {
  color: var(--texte-2);
  font-size: 13.5px;
  font-weight: 600;
}

.kpi .valeur {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.kpi .detail {
  color: var(--texte-2);
  font-size: 13.5px;
}

.barre-progression {
  height: 8px;
  border-radius: 99px;
  background: #e6ebf1;
  overflow: hidden;
  margin: 6px 0 2px;
}

.barre-progression > div {
  height: 100%;
  border-radius: 99px;
  background: var(--bleu);
}

.barre-progression.complet > div {
  background: var(--vert);
}

.suivi {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.suivi .ligne-titre {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-weight: 600;
  font-size: 14px;
}

.suivi .ligne-titre span:last-child {
  font-variant-numeric: tabular-nums;
  color: var(--texte-2);
}

.suivi small {
  color: var(--texte-2);
}

.liste-simple {
  list-style: none;
  margin: 0;
  padding: 0;
}

.liste-simple li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--bord);
}

.liste-simple li:first-child {
  border-top: 0;
}

.a-traiter h3 {
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0 4px;
}

.a-traiter h3:first-of-type {
  margin-top: 0;
}

.a-traiter p {
  margin: 0;
  color: var(--texte-2);
  font-size: 14px;
}

.a-traiter a {
  white-space: nowrap;
}

.rien {
  color: var(--texte-2);
  padding: 22px;
  text-align: center;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 9px;
  border-radius: 99px;
  font-size: 12.5px;
  font-weight: 600;
  background: #e9edf2;
  color: #3d4b5c;
  white-space: nowrap;
}

.badge.vert {
  background: var(--vert-pale);
  color: #136a39;
}

.badge.orange {
  background: var(--orange-pale);
  color: #8a4f00;
}

.badge.rouge {
  background: var(--rouge-pale);
  color: #9f2c2c;
}

.badge.bleu {
  background: var(--bleu-pale);
  color: var(--bleu-fonce);
}

.badge.jaune {
  background: #fdf3cf;
  color: #7a5b00;
}

/* ---------- Barre d'outils, onglets, segments ---------- */
.barre-outils {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.barre-outils .pousse {
  margin-left: auto;
}

.recherche {
  position: relative;
  flex: 1 1 220px;
  max-width: 340px;
}

.recherche .icone {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--texte-2);
}

.recherche input {
  padding-left: 34px;
}

.segments {
  display: inline-flex;
  flex-wrap: wrap;
  border: 1px solid var(--bord-fort);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.segments button {
  border: 0;
  border-right: 1px solid var(--bord);
  background: transparent;
  padding: 7px 12px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--texte-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.segments button:last-child {
  border-right: 0;
}

.segments button:hover {
  background: #f1f4f8;
}

.segments button.actif {
  background: var(--bleu-pale);
  color: var(--bleu-fonce);
}

.segments .compte {
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  opacity: 0.8;
}

.onglets {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  border-bottom: 1px solid var(--bord-fort);
  margin-bottom: 16px;
}

.onglets button {
  border: 0;
  background: none;
  padding: 9px 14px;
  font: inherit;
  font-weight: 600;
  color: var(--texte-2);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
}

.onglets button:hover {
  color: var(--texte);
}

.onglets button.actif {
  color: var(--bleu-fonce);
  border-bottom-color: var(--bleu);
}

/* ---------- Formulaires ---------- */
input,
select,
textarea {
  font: inherit;
  color: inherit;
  width: 100%;
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--bord-fort);
  border-radius: 8px;
  background: #fff;
}

textarea {
  min-height: 76px;
  resize: vertical;
}

input[type='checkbox'] {
  width: 17px;
  height: 17px;
  min-height: 0;
  padding: 0;
  accent-color: var(--bleu);
  flex: none;
  cursor: pointer;
}

input[type='file'] {
  padding: 5px;
}

select.compact {
  width: auto;
}

.formulaire {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px 14px;
}

.champ {
  grid-column: span 3;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.champ.large {
  grid-column: 1 / -1;
}

.champ.tiers {
  grid-column: span 2;
}

.champ > span,
.champ > label {
  font-size: 13.5px;
  font-weight: 600;
  color: #3a4756;
}

.champ .aide {
  font-size: 12.5px;
  color: var(--texte-2);
  font-weight: 400;
}

.champ.case {
  flex-direction: row;
  align-items: center;
  gap: 9px;
}

.champ.case label {
  font-weight: 500;
  font-size: 14.5px;
  color: var(--texte);
  cursor: pointer;
}

.formulaire .section {
  grid-column: 1 / -1;
  font-size: 14px;
  font-weight: 700;
  color: var(--marine-2);
  border-bottom: 1px solid var(--bord);
  padding: 8px 0 5px;
  margin-top: 4px;
}

.formulaire .section:first-child {
  margin-top: 0;
  padding-top: 0;
}

.erreur-formulaire {
  background: var(--rouge-pale);
  color: #8e2626;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  margin-top: 12px;
}

/* ---------- Tableaux ---------- */
.defilement {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
}

.tableau th,
.tableau td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--bord);
  vertical-align: middle;
}

.tableau th {
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--texte-2);
  background: #f7f9fb;
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.tableau th.triable {
  cursor: pointer;
  user-select: none;
}

.tableau th.triable:hover {
  color: var(--texte);
}

.tableau th .sens {
  display: inline-block;
  width: 12px;
  color: var(--bleu);
}

.tableau tbody tr:last-child td {
  border-bottom: 0;
}

.tableau tbody tr.cliquable {
  cursor: pointer;
}

.tableau tbody tr.cliquable:hover {
  background: #f4f8fc;
}

.tableau .num,
.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tableau th.num {
  text-align: right;
}

.tableau .centre {
  text-align: center;
}

.tableau .secondaire,
.secondaire {
  color: var(--texte-2);
  font-size: 13.5px;
}

.tableau .nom-membre {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.negatif {
  color: var(--rouge);
}

.positif {
  color: var(--vert);
}

/* Tableau mensuel de trésorerie */
.mensuel {
  font-size: 13.5px;
  min-width: 980px;
}

.mensuel th,
.mensuel td {
  padding: 6px 9px;
  border-bottom: 1px solid var(--bord);
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.mensuel th:first-child,
.mensuel td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  background: #fff;
  white-space: normal;
  min-width: 190px;
  max-width: 240px;
}

.mensuel thead th {
  background: #f7f9fb;
  color: var(--texte-2);
  font-size: 12.5px;
  text-transform: uppercase;
}

.mensuel thead th:first-child {
  background: #f7f9fb;
}

.mensuel tr.groupe td {
  background: #eef3f8;
  font-weight: 700;
  color: var(--marine-2);
  text-align: left;
}

.mensuel tr.total td {
  font-weight: 700;
  background: #fafbfc;
}

.mensuel tr.solde td {
  font-weight: 700;
  border-top: 2px solid var(--bord-fort);
}

.mensuel td.prevu {
  font-style: italic;
  color: #7a5b00;
  background: #fffaf0;
}

.mensuel td.vide {
  color: #b3bdc9;
}

.mensuel td.mois-courant,
.mensuel th.mois-courant {
  box-shadow: inset 2px 0 0 var(--bleu), inset -2px 0 0 var(--bleu);
}

.legende {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  color: var(--texte-2);
  font-size: 13px;
  margin: 10px 2px 0;
}

.legende .prevu {
  font-style: italic;
  color: #7a5b00;
  background: #fffaf0;
  padding: 0 6px;
  border-radius: 4px;
}

/* ---------- Avatars et trombinoscope ---------- */
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bleu-pale);
  color: var(--bleu-fonce);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex: none;
  object-fit: cover;
  overflow: hidden;
}

.avatar.grand {
  width: 116px;
  height: 116px;
  font-size: 34px;
  border-radius: 16px;
}

.trombinoscope {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
}

.trombinoscope a,
.trombinoscope .vignette {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 14px 8px 12px;
  background: #fff;
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  text-decoration: none;
  color: var(--texte);
  text-align: center;
  font-weight: 600;
  font-size: 14px;
}

.trombinoscope a:hover {
  border-color: var(--bleu);
}

.trombinoscope .avatar {
  width: 92px;
  height: 92px;
  font-size: 28px;
  border-radius: 14px;
}

.trombinoscope small {
  font-weight: 500;
  color: var(--texte-2);
}

/* ---------- Fiche adhérent ---------- */
.fiche-entete {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: center;
}

.fiche-entete .identite {
  flex: 1;
  min-width: 240px;
}

.fiche-entete h2 {
  font-size: 24px;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.fiche-entete .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.photo-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.photo-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}

/* Fiche d'inscription signée en ligne. */
.liste-signee {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
}

.liste-signee li {
  display: flex;
  gap: 8px;
  padding: 3px 0;
}

.coche {
  flex: none;
  margin-right: 6px;
  font-size: 16px;
  line-height: 1.2;
}

.fiche-signee h3 {
  margin: 10px 0 6px;
  font-size: 15px;
}

@media print {
  .fiche-signee .carte {
    break-inside: avoid;
    box-shadow: none;
  }
}

/* Inscription en ligne : ce que la fiche reprend déjà, ce qui manque, ce qui se refait chaque saison. */
.bilan-fiche {
  margin: 0 0 14px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--bleu-pale);
}

.bilan-fiche p {
  margin: 0 0 4px;
}

.bilan-fiche p:last-child {
  margin-bottom: 0;
}

/* Inscription en ligne : la photo en tête du formulaire. */
.photo-inscription {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 4px 0 16px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--bord);
}

.photo-inscription h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.photo-inscription > div:last-child {
  flex: 1;
  min-width: 220px;
}

/* Prise de vue avec la caméra : le cadre carré montre la partie gardée. */
.camera {
  position: relative;
  width: min(480px, 100%, 70vh);
  aspect-ratio: 4 / 3;
  margin: 0 auto;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
}

.camera-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

canvas.camera-video {
  object-fit: contain;
}

.camera-video.miroir {
  transform: scaleX(-1);
}

.camera-cadre {
  position: absolute;
  inset: 0;
  height: 100%;
  aspect-ratio: 1;
  margin: 0 auto;
  border: 2px dashed rgba(255, 255, 255, 0.75);
  border-radius: 14px;
  pointer-events: none;
}

dl.details {
  display: grid;
  grid-template-columns: minmax(120px, 38%) 1fr;
  gap: 7px 14px;
  margin: 0;
}

dl.details dt {
  color: var(--texte-2);
  font-size: 13.5px;
}

dl.details dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.adhesion {
  border: 1px solid var(--bord);
  border-radius: 8px;
  padding: 12px 14px;
  margin-top: 10px;
}

.adhesion header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.adhesion header strong {
  font-size: 15.5px;
}

.adhesion .montants {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  color: var(--texte-2);
  font-size: 14px;
  margin: 6px 0;
}

.adhesion .montants b {
  color: var(--texte);
  font-variant-numeric: tabular-nums;
}

.paiement {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  padding: 6px 0;
  border-top: 1px dashed var(--bord);
  font-size: 14px;
}

.paiement .montant {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 74px;
}

/* ---------- Bureau, événements, documents ---------- */
.dirigeants {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}

.dirigeant {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 5px;
}

.dirigeant .avatar {
  width: 104px;
  height: 104px;
  font-size: 30px;
  border-radius: 16px;
  margin-bottom: 4px;
}

.dirigeant .fonction {
  color: var(--bleu-fonce);
  font-weight: 700;
}

.dirigeant .contact {
  font-size: 13.5px;
  color: var(--texte-2);
  overflow-wrap: anywhere;
}

.evenement {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.evenement .date {
  flex: none;
  width: 64px;
  text-align: center;
  border-radius: 10px;
  background: var(--bleu-pale);
  color: var(--bleu-fonce);
  padding: 7px 4px;
  line-height: 1.15;
}

.evenement .date b {
  display: block;
  font-size: 22px;
}

.evenement .date span {
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 600;
}

.evenement.passe .date {
  background: #eceff3;
  color: var(--texte-2);
}

.evenement .corps {
  flex: 1;
  min-width: 0;
}

.evenement h3 {
  font-size: 16px;
}

.evenement p {
  margin: 4px 0 0;
  white-space: pre-line;
}

.document {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  padding: 10px 0;
  border-top: 1px solid var(--bord);
}

.document:first-of-type {
  border-top: 0;
}

.document .titre {
  flex: 1;
  min-width: 200px;
  font-weight: 600;
}

/* ---------- Fenêtres (dialog) ---------- */
dialog {
  border: 0;
  border-radius: 14px;
  padding: 0;
  width: min(640px, calc(100vw - 24px));
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  box-shadow: 0 20px 60px rgba(10, 30, 55, 0.35);
  color: var(--texte);
}

dialog.large {
  width: min(860px, calc(100vw - 24px));
}

dialog::backdrop {
  background: rgba(12, 30, 52, 0.5);
}

dialog form,
dialog .cadre {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
}

/* Sélecteurs directs : le contenu d'une fenêtre peut lui-même contenir des <header>. */
dialog > * > header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--bord);
}

dialog > * > header h2 {
  font-size: 18px;
  flex: 1;
}

dialog > * > .corps {
  padding: 16px 20px;
  overflow-y: auto;
}

dialog > * > footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--bord);
}

dialog > * > footer .gauche {
  margin-right: auto;
}

/* ---------- Notifications ---------- */
.notifications {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
}

.notification {
  background: var(--marine);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(10, 30, 55, 0.3);
  max-width: 380px;
}

.notification.erreur {
  background: #a52f2f;
}

/* ---------- Connexion ---------- */
.ecran-connexion {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, var(--marine) 0%, var(--marine-2) 55%, var(--bleu) 100%);
}

.ecran-connexion .carte {
  width: min(420px, 100%);
  padding: 28px 30px 26px;
}

.ecran-connexion img {
  display: block;
  width: 190px;
  margin: 0 auto 14px;
}

.ecran-connexion h1 {
  font-size: 20px;
  text-align: center;
  margin-bottom: 4px;
}

.ecran-connexion p {
  color: var(--texte-2);
  text-align: center;
  margin: 0 0 18px;
}

.ecran-connexion .formulaire {
  grid-template-columns: 1fr;
}

.ecran-connexion .champ {
  grid-column: 1;
}

.ecran-connexion .btn {
  width: 100%;
  margin-top: 16px;
  min-height: 42px;
  font-size: 15px;
}

.ecran-connexion .aide-connexion {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--bord);
  font-size: 14px;
}

.ecran-connexion .aide-connexion p {
  margin: 0 0 8px;
}

.ecran-connexion .aide-connexion .btn {
  width: auto;
  margin-top: 0;
  min-height: 36px;
  font-size: 14px;
}

.ecran-connexion .aide-connexion input {
  flex: 1;
  min-width: 0;
}

button.lien {
  padding: 0;
  border: 0;
  background: none;
  color: var(--bleu);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* ---------- Écrans étroits ---------- */
.bouton-menu {
  display: none;
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .barre-laterale {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .marque {
    flex-direction: row;
    padding: 8px 12px;
  }

  .marque img {
    width: 62px;
    padding: 3px 4px;
    border-radius: 8px;
  }

  /* Dans la barre du haut : retour au site, puis le menu. */
  .retour-site {
    margin: 0 0 0 auto;
    min-height: 40px;
  }

  .bouton-menu {
    display: inline-flex;
    margin-left: 8px;
    margin-right: 12px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    border-radius: 8px;
    padding: 7px 9px;
    cursor: pointer;
  }

  .nav,
  .pied-lateral {
    display: none;
    flex-basis: 100%;
  }

  .barre-laterale.ouvert .nav,
  .barre-laterale.ouvert .pied-lateral {
    display: flex;
    flex-direction: column;
  }

  .entete {
    flex-wrap: wrap;
    padding: 14px 16px 0;
  }

  .contenu {
    padding: 14px 16px 40px;
  }

  .grille.deux {
    grid-template-columns: 1fr;
  }

  .formulaire {
    grid-template-columns: 1fr;
  }

  .champ,
  .champ.tiers {
    grid-column: 1;
  }
}

/* Téléphone : le bouton de retour tient sur la ligne du logo (« amcb.club » seul). */
@media (max-width: 640px) {
  .retour-texte {
    display: none;
  }
}

@media (max-width: 420px) {
  .marque span {
    display: none;
  }
}

/* ---------- Impression ---------- */
.impression-seule {
  display: none;
}

@media print {
  body {
    background: #fff;
    font-size: 11.5pt;
  }

  .barre-laterale,
  .barre-outils,
  .onglets,
  .notifications,
  .entete .saison,
  .non-imprime,
  .btn {
    display: none !important;
  }

  .app {
    display: block;
  }

  .entete,
  .contenu {
    padding: 0;
    max-width: none;
  }

  .entete h1 {
    margin-bottom: 10px;
  }

  .carte {
    box-shadow: none;
    border-color: #999;
    break-inside: avoid;
  }

  .tableau th {
    position: static;
  }

  .tableau th,
  .tableau td {
    padding: 4px 6px;
    font-size: 9.5pt;
  }

  .mensuel {
    min-width: 0;
    font-size: 7.5pt;
  }

  .mensuel th,
  .mensuel td {
    padding: 2px 3px;
  }

  .mensuel th:first-child,
  .mensuel td:first-child {
    min-width: 0;
    position: static;
  }

  .impression-seule {
    display: block;
  }

  a {
    color: inherit;
    text-decoration: none;
  }
}

/* Bandeau de la version de démonstration */
.bandeau-demo {
  background: #fdf3cf;
  color: #6b5000;
  font-size: 13.5px;
  font-weight: 600;
  padding: 7px 28px;
  border-bottom: 1px solid #f0dc94;
}

@media print {
  .bandeau-demo {
    display: none;
  }
}

/* Photo d'un justificatif : toute l'image est gardée, elle s'affiche donc entière. */
.camera.libre .camera-video {
  object-fit: contain;
}

/* Notes de frais : vignettes des justificatifs (photo du ticket ou PDF). */
.justificatifs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.justificatif {
  position: relative;
  display: inline-flex;
  width: 52px;
  height: 52px;
  border: 1px solid var(--bord);
  border-radius: 6px;
  overflow: hidden;
  background: #f7f9fb;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.justificatif img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.justificatif-pdf {
  font-size: 12px;
  font-weight: 700;
  color: #b42318;
}

.justificatif .retirer {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 13px;
  line-height: 18px;
  cursor: pointer;
}

.zone-justificatifs {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ---------- Téléphone ---------- */

/* Contenu d'une cellule de tableau : sans effet sur ordinateur, il sert à la mise en fiche sur téléphone. */
.tableau .cellule {
  display: contents;
}

@media (max-width: 900px) {
  /* Texte d'au moins 16 px dans les champs : sinon l'iPhone agrandit toute la page au moindre toucher. */
  input,
  select,
  textarea {
    font-size: 16px;
  }

  /* Boutons assez grands pour le doigt. */
  .btn {
    min-height: 40px;
  }

  .btn.petit {
    min-height: 36px;
  }
}

/* Bouton « Voir la fiche » d'une liste repliable : seulement sur téléphone, une fois la ligne dépliée. */
.tableau .detail-mobile {
  display: none;
}

@media (max-width: 640px) {
  /* Listes : chaque ligne devient une petite fiche (« Étiquette : valeur »), sans défilement de côté. */
  .defilement:has(> table.cartes) {
    overflow-x: visible;
  }

  table.cartes,
  table.cartes > tbody {
    display: block;
  }

  table.cartes > thead {
    display: none;
  }

  /* Le titre (et la case à cocher éventuelle) en tête de fiche, puis une ligne par colonne. */
  table.cartes > tbody > tr {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--bord);
  }

  table.cartes > tbody > tr:last-child {
    border-bottom: 0;
  }

  table.cartes > tbody > tr > td {
    flex: 1 1 100%;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 3px 0;
    border: 0;
    text-align: right;
    white-space: normal;
  }

  table.cartes > tbody > tr > td[data-titre]::before {
    content: attr(data-titre);
    flex: none;
    max-width: 45%;
    color: var(--texte-2);
    font-size: 13px;
    text-align: left;
  }

  table.cartes > tbody > tr > td:not([data-titre]) {
    justify-content: flex-end;
  }

  table.cartes .cellule {
    display: block;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  table.cartes > tbody > tr > td.titre-mobile {
    order: -1;
    flex: 1 1 0;
    min-width: 60%;
    display: block;
    padding: 0 0 6px;
    text-align: left;
    font-size: 15.5px;
  }

  table.cartes > tbody > tr > td.titre-mobile::before {
    content: none;
  }

  table.cartes > tbody > tr > td.vide,
  table.cartes > tbody > tr > td.masque-mobile {
    display: none;
  }

  /* Liste repliable (adhérents) : une ligne par élément — photo et nom, résumé à droite, flèche — ; un appui déplie le
     reste en « Étiquette : valeur », avec le bouton qui ouvre la fiche. */
  table.cartes.replie > tbody > tr {
    align-items: center;
    padding: 8px 12px;
  }

  table.cartes.replie > tbody > tr > td.titre-mobile {
    min-width: 0;
    padding: 0;
  }

  table.cartes.replie > tbody > tr > td.resume-mobile {
    order: -1;
    flex: none;
    padding: 0;
  }

  table.cartes.replie > tbody > tr > td.resume-mobile::before {
    content: none;
  }

  table.cartes.replie > tbody > tr:not(.ouvert) > td:not(.titre-mobile):not(.resume-mobile):not(.case) {
    display: none;
  }

  table.cartes.replie > tbody > tr.repliable::after {
    content: '';
    order: -1;
    flex: none;
    width: 8px;
    height: 8px;
    margin: 0 4px 4px 2px;
    border-right: 2px solid var(--texte-2);
    border-bottom: 2px solid var(--texte-2);
    transform: rotate(45deg);
    transition: transform 0.15s;
  }

  table.cartes.replie > tbody > tr.ouvert::after {
    margin: 4px 4px 0 2px;
    transform: rotate(-135deg);
  }

  table.cartes.replie > tbody > tr.ouvert {
    background: var(--fond);
  }

  table.cartes.replie > tbody > tr.ouvert > td.titre-mobile {
    padding-bottom: 6px;
  }

  table.cartes.replie > tbody > tr.ouvert > td.detail-mobile {
    display: flex;
    justify-content: flex-end;
    padding-top: 6px;
  }

  table.cartes.replie .nom-membre {
    min-width: 0;
  }

  table.cartes.replie .nom-membre .avatar {
    width: 32px;
    height: 32px;
    flex: none;
  }

  table.cartes.replie .nom-membre > span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  table.cartes.replie > tbody > tr:not(.ouvert) .nom-membre .secondaire {
    display: none;
  }

  /* Case à cocher d'une ligne : à gauche du titre. */
  table.cartes > tbody > tr > td.case {
    order: -2;
    flex: 0 0 auto;
    padding: 0;
  }

  table.cartes > tbody > tr > td.rien {
    display: block;
    text-align: center;
  }

  table.cartes .badges {
    justify-content: flex-end;
  }

  /* Un badge au texte long passe à la ligne plutôt que de dépasser. */
  table.cartes .badge {
    white-space: normal;
  }

  /* Cadres et chiffres plus compacts : on atteint plus vite les listes. */
  .carte {
    padding: 14px 16px;
  }

  .grille {
    gap: 12px;
  }

  .grille.kpi {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  /* Comptes de la trésorerie : un cadre par ligne (chacun détaille plusieurs soldes). */
  .grille.kpi.comptes {
    grid-template-columns: minmax(0, 1fr);
  }

  /* Onglets sur une seule ligne, qui défile d'un glissement du doigt. */
  .onglets {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .onglets::-webkit-scrollbar {
    display: none;
  }

  .onglets button {
    flex: none;
    white-space: nowrap;
    padding: 9px 11px;
  }

  .kpi .carte {
    padding: 12px 14px;
  }

  .kpi .valeur {
    font-size: 21px;
  }

  .kpi .libelle,
  .kpi .detail {
    font-size: 12.5px;
  }

  .entete h1 {
    font-size: 21px;
  }

  /* Boutons d'une barre d'outils : ils se partagent la largeur. L'impression n'a pas de sens sur un téléphone. */
  .barre-outils {
    gap: 8px;
  }

  .barre-outils > .btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  .barre-outils > .btn.pousse {
    margin-left: 0;
  }

  .btn.imprimer {
    display: none;
  }

  /* Événement : le bouton « Modifier » passe sous le texte, qui garde toute la largeur. */
  .evenement {
    flex-wrap: wrap;
    gap: 12px;
  }

  .evenement .corps {
    flex: 1 1 200px;
  }

  .evenement > .btn {
    margin-left: auto;
  }

  /* En-tête d'une fiche (Mon espace, fiche adhérent) : photo plus petite, boutons à côté, pour garder l'essentiel visible. */
  .fiche-entete {
    gap: 12px;
  }

  .fiche-entete .identite {
    flex-basis: 100%;
    min-width: 0;
  }

  .fiche-entete h2 {
    font-size: 21px;
  }

  .photo-zone {
    flex-direction: row;
    gap: 12px;
  }

  .photo-zone .avatar.grand {
    width: 80px;
    height: 80px;
    font-size: 26px;
    border-radius: 12px;
  }

  .photo-zone .photo-actions {
    flex-direction: column;
    align-items: flex-start;
  }

  /* Tableau mensuel de la trésorerie : grille de chiffres, elle défile de côté ; la colonne des libellés reste visible. */
  .mensuel th:first-child,
  .mensuel td:first-child {
    min-width: 118px;
    max-width: 140px;
  }
}
