:root {
  --fond: #f6f7f9;
  --surface: #ffffff;
  --texte: #1d2330;
  --discret: #5f6b7a;
  --bordure: #dde1e7;
  --accent: #305496;      /* bleu des en-têtes des tableurs actuels */
  --vert: #c6efce;        /* vert « rapproché » des tableurs actuels */
  --orange: #fce4d6;      /* orange « cours » des tableurs actuels */
  --alerte: #b4441c;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #14171c; --surface: #1d2129; --texte: #e6e9ee; --discret: #9aa4b2;
    --bordure: #303643; --accent: #7fa2e0; --vert: #1f4d2b; --orange: #5a3a26; --alerte: #f08a5d;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--fond); color: var(--texte); }
a { color: var(--accent); }
.entete { display: flex; justify-content: space-between; align-items: center; padding: .75rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--bordure); }
.entete nav { display: flex; gap: .4rem 1rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.entete nav a, .entete nav .utilisateur { white-space: nowrap; }
.entete nav a { text-decoration: none; }
.entete nav a:hover { text-decoration: underline; }
.marque { font-weight: 700; text-decoration: none; color: var(--texte); }
.utilisateur { color: var(--discret); }
.contenu { max-width: 1400px; margin: 0 auto; padding: 1.5rem 1rem; }
.inline { display: inline; }
button { font: inherit; padding: .5rem 1rem; border-radius: 6px; border: 0; background: #305496; color: #fff; cursor: pointer; }
button.lien { background: none; color: var(--accent); padding: 0; }
.carte { background: var(--surface); border: 1px solid var(--bordure); border-radius: 10px; padding: 1rem 1.25rem; }
.grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
a.carte.structure { text-decoration: none; color: inherit; }
a.carte.structure:hover { border-color: var(--accent); }
.carte h2 { margin: 0; color: var(--accent); }
.sous-titre { margin: 0 0 .75rem; color: var(--discret); }
dl { margin: 0; }
dl div { display: flex; justify-content: space-between; padding: .2rem 0; border-top: 1px solid var(--bordure); }
dt { color: var(--discret); }
dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 600; }
dl div.alerte dd, dl div.alerte dt { color: var(--alerte); }
.connexion { max-width: 360px; margin: 3rem auto; display: block; }
.connexion form { display: grid; gap: .5rem; }
input[type=text], input[type=password], input[type=search], input[type=date], select { font: inherit; padding: .5rem; border: 1px solid var(--bordure); border-radius: 6px; background: var(--fond); color: var(--texte); }
.message.success { border-color: #3c8d52; }
.message { margin: .4rem 0; padding: .6rem .9rem; border-radius: 6px; background: var(--surface); border: 1px solid var(--bordure); }
.message.error, .message.warning { border-color: var(--alerte); color: var(--alerte); }
table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--bordure); }
th, td { text-align: left; padding: .45rem .7rem; border-bottom: 1px solid var(--bordure); }
th { background: #305496; color: #fff; font-weight: 600; }
.nombre { text-align: right; font-variant-numeric: tabular-nums; }
.sigle { font-size: .6em; color: var(--discret); font-weight: 400; }
.vide { color: var(--discret); }

/* Écran Relevé */
.titre-page { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.bouton { display: inline-block; padding: .45rem .9rem; border-radius: 6px; text-decoration: none; background: #305496; color: #fff; }
.bouton.secondaire { background: var(--surface); color: var(--accent); border: 1px solid var(--accent); }
.filtres { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .6rem .8rem; align-items: end;
  background: var(--surface); border: 1px solid var(--bordure); border-radius: 10px; padding: .9rem 1rem; margin: 1rem 0; }
.filtres .champ { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.filtres .champ.large { grid-column: span 2; }
.filtres label { font-size: .8rem; color: var(--discret); }
.filtres input, .filtres select { width: 100%; padding: .4rem .5rem; }
.filtres .actions { display: flex; gap: .8rem; align-items: center; }
.resume { display: flex; flex-wrap: wrap; gap: 1.5rem; margin: 0 0 1rem; }
.resume div { display: flex; flex-direction: column; }
.resume .etiquette { font-size: .8rem; color: var(--discret); }
.resume strong { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.debit { color: var(--alerte); }
.credit { color: #3c8d52; }
.tableau-defilant { overflow-x: auto; }
table.releve { font-size: .9rem; }
table.releve td { vertical-align: top; }
table.releve td.date, table.releve td.compte { white-space: nowrap; }
table.releve td.nombre { white-space: nowrap; }
table.releve td.libelle { min-width: 260px; }
table.releve td.note { color: var(--discret); max-width: 360px; font-size: .85rem; }
table.releve summary { cursor: pointer; }
table.releve .details { color: var(--discret); font-size: .85rem; margin-top: .3rem; }
/* Moitié gauche (date, compte, libellé) : étiquette ou catégorie ; moitié droite : statut. */
tr[style] td { background: var(--fond-d, transparent); color: var(--texte-d, inherit); }
tr[style] td.g { background: var(--fond-g, var(--fond-d, transparent)); color: var(--texte-g, var(--texte-d, inherit)); }
tr[style] td.note { color: var(--texte-d, var(--discret)); }
tr[style] td a { color: inherit; text-decoration: underline; }
.pastille { display: inline-block; width: .9em; height: .9em; border-radius: 3px; border: 1px solid var(--bordure); vertical-align: -1px; margin-left: 1rem; }
.pastille.statut-rapprochee, .pastille.statut-justifiee { background: var(--vert); }
.pastille.statut-justifiee { background: repeating-linear-gradient(45deg, var(--vert), var(--vert) 3px, var(--surface) 3px, var(--surface) 5px); }
tr.statut-justifiee td:first-child { box-shadow: inset 4px 0 0 #3c8d52; }
.pastille.cat-cours { background: var(--orange); }
.legende { color: var(--discret); font-size: .85rem; }
.pagination { display: flex; gap: 1rem; justify-content: center; margin: 1rem 0; }
form.import { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin-top: 1rem; }
@media (max-width: 700px) {
  .filtres .champ.large { grid-column: span 1; }
  .entete { flex-wrap: wrap; gap: .5rem; }
}

/* Pièces */
.boutons { display: flex; gap: .6rem; flex-wrap: wrap; }
.badge { font-size: .75rem; padding: .05rem .4rem; border-radius: 4px; background: var(--orange); color: var(--texte); margin-left: .4rem; }
.badge.envoye { background: #dbe7f7; color: #1d3a63; }
.statut { font-size: .8rem; padding: .1rem .5rem; border-radius: 99px; border: 1px solid var(--bordure); white-space: nowrap; }
.statut-piece-rapprochee, .statut-piece-prete { background: var(--vert); }
.statut-piece-a_valider, .statut-piece-a_trier { background: var(--orange); }
.statut-piece-incoherence { border-color: var(--alerte); color: var(--alerte); }
.discret { color: var(--discret); font-size: .85rem; }
.nom-piece { font-size: 1.3rem; word-break: break-word; }
.validation { display: grid; grid-template-columns: minmax(0, 3fr) minmax(320px, 2fr); gap: 1.2rem; align-items: start; }
.apercu iframe, .apercu img { width: 100%; height: 78vh; border: 1px solid var(--bordure); border-radius: 8px; background: #fff; object-fit: contain; }
.panneau { background: var(--surface); border: 1px solid var(--bordure); border-radius: 10px; padding: 1rem 1.2rem; }
.panneau h2 { font-size: 1.05rem; margin: 1.2rem 0 .4rem; }
form.saisie fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .6rem; }
form.saisie .champ { display: flex; flex-direction: column; gap: .2rem; }
form.saisie .champ.case { flex-direction: row; align-items: center; gap: .4rem; }
form.saisie label { font-size: .8rem; color: var(--discret); }
form.saisie input, form.saisie select, form.saisie textarea { font: inherit; padding: .4rem .5rem; border: 1px solid var(--bordure); border-radius: 6px; background: var(--fond); color: var(--texte); width: 100%; }
form.saisie input[type=checkbox] { width: auto; }
form.saisie .deux { display: grid; grid-template-columns: 1fr 1fr 70px; gap: .6rem; }
form.saisie .actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-top: .4rem; }
button.secondaire { background: var(--surface); color: var(--accent); border: 1px solid var(--accent); }
.errorlist { color: var(--alerte); margin: 0; padding-left: 1rem; font-size: .85rem; }
.liste-lignes { padding-left: 1rem; margin: .3rem 0; }
form.import label { display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; color: var(--discret); }
@media (max-width: 900px) { .validation { grid-template-columns: 1fr; } .apercu iframe, .apercu img { height: 60vh; } }

/* Rapprochements */
.proposition { margin-bottom: .8rem; }
.proposition-entete { display: flex; gap: .8rem; align-items: baseline; flex-wrap: wrap; margin-bottom: .4rem; }
.proposition-corps { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.proposition-corps h3 { font-size: .8rem; color: var(--discret); margin: 0 0 .2rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.proposition-corps p { margin: .2rem 0; }
.proposition-actions { display: flex; gap: .6rem; margin-top: .6rem; }
.regle-autre_structure { border-left: 4px solid var(--alerte); }
.regle-multi, .regle-remboursement { border-left: 4px solid var(--accent); }
.ligne-actions { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; }
button.petit { padding: .15rem .55rem; font-size: .8rem; margin-right: .4rem; }
.candidates li { margin: .35rem 0; }
.lien-piece { font-size: .85rem; }
.lien-piece.propose { font-style: italic; color: var(--discret); }
.resume-ligne { margin: 0 0 .8rem; }
@media (max-width: 700px) { .proposition-corps { grid-template-columns: 1fr; } }

/* Traitement groupé des propositions */
.barre-lot { position: sticky; top: 0; z-index: 2; display: flex; gap: .8rem; align-items: center; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--bordure); border-radius: 10px; padding: .6rem 1rem; margin-bottom: .8rem; }
.case-tout { display: flex; gap: .4rem; align-items: center; }
.case-lot { width: 1.1rem; height: 1.1rem; margin-right: .2rem; }
.proposition.selectionnee { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
button:disabled { opacity: .45; cursor: not-allowed; }

.recherche-lignes { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; margin-bottom: .5rem; }
.recherche-lignes input { padding: .3rem .4rem; border: 1px solid var(--bordure); border-radius: 6px; background: var(--fond); color: var(--texte); max-width: 11rem; font: inherit; font-size: .85rem; }

/* Étiquettes et couleurs */
.etiquette { display: inline-block; font-size: .75rem; padding: .05rem .45rem; margin: .1rem .2rem 0 0; border-radius: 99px;
  border: 1px solid var(--bordure); background: var(--surface); color: var(--texte); white-space: nowrap; }
.grille-couleurs { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .5rem 1rem; margin-bottom: 1rem; }
.choix-couleur { display: flex; align-items: center; gap: .5rem; }
.choix-couleur input[type=color] { width: 2.4rem; height: 1.8rem; border: 1px solid var(--bordure); border-radius: 6px; padding: 0; background: none; }
.choix-couleur .aucune { margin-left: auto; font-size: .8rem; color: var(--discret); display: flex; gap: .2rem; align-items: center; }
.couleurs h2 { font-size: 1rem; margin: .8rem 0 .5rem; }
a.utilisateur { color: var(--discret); }
