:root {
  --fond: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f0eee9;
  --texte: #1d1d1b;
  --texte-2: #5d5b55;
  --bord: #dedbd3;
  --accent: #2f5d50;
  --accent-texte: #ffffff;
  --accent-doux: #e3ede9;
  --ok: #2f6b3a;
  --ok-doux: #e5f1e6;
  --attention: #8a5a00;
  --attention-doux: #fbf0d9;
  --erreur: #a33a2c;
  --erreur-doux: #f8e4e0;
  --rayon: 10px;
  --ombre: 0 1px 2px rgba(0, 0, 0, .05), 0 2px 8px rgba(0, 0, 0, .04);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fond: #161715;
    --surface: #1f201e;
    --surface-2: #272926;
    --texte: #ecebe7;
    --texte-2: #a9a7a0;
    --bord: #383a36;
    --accent: #7fb8a6;
    --accent-texte: #10201b;
    --accent-doux: #22332e;
    --ok: #8cc79a;
    --ok-doux: #1f3124;
    --attention: #e2b55a;
    --attention-doux: #362c17;
    --erreur: #ee8f80;
    --erreur-doux: #3b2420;
    --ombre: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 1.45rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 1.6rem 0 .6rem; }
h3 { font-size: 1rem; margin: 0 0 .4rem; }
p { margin: .4rem 0; }
.sous-titre { color: var(--texte-2); margin: 0 0 1.2rem; }
.discret { color: var(--texte-2); font-size: .9em; }
code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); padding: .05em .3em; border-radius: 4px; }

/* barre du haut */
.barre {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1rem;
  padding: .55rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--bord);
}
.marque { font-weight: 650; color: var(--texte); text-decoration: none; white-space: nowrap; }
.barre nav { display: flex; gap: .15rem; overflow-x: auto; flex: 1; scrollbar-width: none; }
.barre nav::-webkit-scrollbar { display: none; }
.barre nav a {
  white-space: nowrap; text-decoration: none; color: var(--texte-2);
  padding: .35rem .6rem; border-radius: 7px;
}
.barre nav a:hover { background: var(--surface-2); color: var(--texte); }
.barre nav a.actif { background: var(--accent-doux); color: var(--accent); font-weight: 600; }
.pastille {
  display: inline-block; min-width: 1.35em; padding: 0 .35em; margin-left: .2em;
  border-radius: 99px; background: var(--accent); color: var(--accent-texte);
  font-size: .75em; font-weight: 650; text-align: center; line-height: 1.5;
}
.pastille.zero { background: var(--surface-2); color: var(--texte-2); }

main { max-width: 1040px; margin: 0 auto; padding: 1.4rem 16px 4rem; }

/* messages */
.flash, .bandeau {
  padding: .65rem .9rem; border-radius: var(--rayon); margin: 0 0 .8rem;
  border: 1px solid transparent;
}
.flash.ok, .bandeau.ok { background: var(--ok-doux); color: var(--ok); }
.flash.attention { background: var(--attention-doux); color: var(--attention); }
.flash.erreur, .bandeau.erreur { background: var(--erreur-doux); color: var(--erreur); }
.bandeau.encours { background: var(--accent-doux); color: var(--accent); }
.bandeau .roue {
  display: inline-block; width: .9em; height: .9em; margin-right: .45em; vertical-align: -.1em;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: tourne .8s linear infinite;
}
@keyframes tourne { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .bandeau .roue { animation: none; } }

/* cartes et grilles */
.carte {
  background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon);
  padding: 1rem 1.1rem; box-shadow: var(--ombre); margin-bottom: 1rem;
}
.grille { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 1rem; }
.chiffre { display: block; text-decoration: none; color: inherit; }
.chiffre .valeur { display: block; font-size: 1.9rem; font-weight: 650; line-height: 1.1; font-variant-numeric: tabular-nums; }
.chiffre .libelle { color: var(--texte-2); font-size: .9rem; }
a.chiffre:hover { border-color: var(--accent); }
.chiffre.fort { border-color: var(--accent); background: var(--accent-doux); }
.deux-colonnes { display: grid; gap: 1rem; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; }
@media (max-width: 820px) { .deux-colonnes { grid-template-columns: minmax(0, 1fr); } }

/* listes */
.liste { list-style: none; margin: 0; padding: 0; }
.liste > li { border-top: 1px solid var(--bord); padding: .7rem 0; }
.liste > li:first-child { border-top: 0; padding-top: 0; }
.ligne-titre { display: flex; justify-content: space-between; gap: .8rem; align-items: baseline; flex-wrap: wrap; }
.apercu { color: var(--texte-2); margin: .2rem 0 0; overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* tableaux */
.tableau-conteneur { overflow-x: auto; background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--bord); vertical-align: top; }
th { font-weight: 600; color: var(--texte-2); font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td.nombre, th.nombre { text-align: right; font-variant-numeric: tabular-nums; }
td a { text-decoration: none; }

/* étiquettes */
.etiquette {
  display: inline-block; padding: .05rem .5rem; border-radius: 99px; font-size: .8rem; font-weight: 550;
  background: var(--surface-2); color: var(--texte-2); white-space: nowrap;
}
.etiquette.a_contacter { background: var(--surface-2); }
.etiquette.brouillon_pret { background: var(--accent-doux); color: var(--accent); }
.etiquette.envoye { background: var(--attention-doux); color: var(--attention); }
.etiquette.repondu, .etiquette.rdv { background: var(--ok-doux); color: var(--ok); }
.etiquette.refus, .etiquette.desinscrit { background: var(--erreur-doux); color: var(--erreur); }
.note { font-variant-numeric: tabular-nums; font-weight: 650; }
.note.haute { color: var(--ok); }
.note.basse { color: var(--texte-2); }

/* formulaires */
label { display: block; font-weight: 550; margin: .7rem 0 .25rem; font-size: .92rem; }
input[type=text], input[type=password], input[type=email], input[type=url], input[type=number], select, textarea {
  width: 100%; padding: .55rem .65rem; font: inherit; color: var(--texte);
  background: var(--surface); border: 1px solid var(--bord); border-radius: 8px;
}
textarea { min-height: 14rem; resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.champs { display: grid; gap: 0 .9rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.filtres { display: flex; gap: .5rem; flex-wrap: wrap; align-items: end; margin-bottom: 1rem; }
.filtres > * { width: auto; }
.filtres input[type=text] { min-width: 12rem; flex: 1; }

button, .bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  padding: .5rem .95rem; font: inherit; font-weight: 550; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--bord); background: var(--surface); color: var(--texte); text-decoration: none;
  min-height: 2.4rem;
}
button:hover, .bouton:hover { background: var(--surface-2); }
button.principal, .bouton.principal { background: var(--accent); color: var(--accent-texte); border-color: var(--accent); }
button.principal:hover { filter: brightness(1.08); }
button.danger { color: var(--erreur); }
button.danger:hover { background: var(--erreur-doux); }
button.lien { border: 0; background: none; color: var(--texte-2); padding: .3rem .4rem; min-height: 0; font-weight: 400; }
button.lien:hover { color: var(--texte); background: none; text-decoration: underline; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: .8rem; }
.actions form { margin: 0; }
form.en-ligne { display: inline; }

/* message à copier */
.message {
  white-space: pre-wrap; word-wrap: break-word; background: var(--surface-2); border-radius: 8px;
  padding: .8rem .9rem; margin: .5rem 0; font-size: .97rem;
}
.mentions { white-space: pre-wrap; color: var(--texte-2); font-size: .9rem; border-left: 3px solid var(--bord);
  padding: .2rem 0 .2rem .8rem; margin: .6rem 0; }
.compteur-mots { font-size: .85rem; color: var(--texte-2); text-align: right; margin-top: .2rem; }
.compteur-mots.trop { color: var(--erreur); font-weight: 600; }
.conseil { background: var(--accent-doux); color: var(--accent); border-radius: 8px; padding: .55rem .8rem; font-size: .92rem; margin: .6rem 0; }
dl.fiche { display: grid; grid-template-columns: max-content 1fr; gap: .3rem .9rem; margin: 0; font-size: .93rem; }
dl.fiche dt { color: var(--texte-2); }
dl.fiche dd { margin: 0; overflow-wrap: anywhere; }
details > summary { cursor: pointer; font-weight: 600; padding: .2rem 0; }
details[open] > summary { margin-bottom: .4rem; }

/* connexion */
.connexion { max-width: 380px; margin: 12vh auto 0; }
.connexion h1 { margin-bottom: 1rem; }

@media (max-width: 600px) {
  .barre { flex-wrap: wrap; gap: .3rem .8rem; padding: .5rem 12px; }
  .barre nav { order: 3; flex-basis: 100%; }
  .barre form { margin-left: auto; }
  .grille { grid-template-columns: 1fr 1fr; }
  .grille .carte { margin-bottom: 0; }
  main { padding-top: 1rem; }
  .actions > *, .actions form, .actions form button { flex: 1 1 auto; }
  .actions form button { width: 100%; }
  dl.fiche { grid-template-columns: 1fr; gap: 0; }
  dl.fiche dd { margin-bottom: .4rem; }
}

.haut-0 { margin-top: 0; }
.haut-1 { margin-top: 1rem; }
.connexion-large { max-width: 480px; }
