:root {
  --fond: #f6f5f1; --carte: #ffffff; --texte: #1f2328; --discret: #6b6f76; --ligne: #e3e1da;
  --accent: #1f6f5c; --accent-clair: #e3f1ec; --rouge: #b3261e; --rouge-clair: #fbe9e7; --vert: #1e7a3c;
  --rayon: 10px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--fond); color: var(--texte); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
button, input, select, textarea { font: inherit; }
input, select, textarea { padding: .45em .6em; border: 1px solid var(--ligne); border-radius: 7px; background: #fff; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label { display: block; font-size: .88rem; color: var(--discret); }
label > input, label > select, label > textarea { margin-top: .2em; color: var(--texte); }
button { cursor: pointer; border: 1px solid var(--ligne); background: #fff; border-radius: 7px; padding: .45em .9em; }
button:hover { border-color: #c9c6bd; }
button.principal { background: var(--accent); color: #fff; border-color: var(--accent); }
button.principal:hover { filter: brightness(1.08); }
button.danger { color: var(--rouge); }
button.lien { border: 0; background: none; color: var(--accent); padding: 0; text-decoration: underline; }
.discret { color: var(--discret); font-size: .88rem; }
.erreur { color: var(--rouge); min-height: 1.2em; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.doit { color: var(--rouge); font-weight: 600; }
.avance { color: var(--vert); font-weight: 600; }

.connexion { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.connexion .carte { width: min(360px, 100%); display: grid; gap: .8em; }
.carte { background: var(--carte); border: 1px solid var(--ligne); border-radius: var(--rayon); padding: 18px; }

.entete { position: sticky; top: 0; z-index: 5; background: #fff; border-bottom: 1px solid var(--ligne);
  display: flex; align-items: center; gap: 16px; padding: 8px 16px; flex-wrap: wrap; }
.marque { font-weight: 700; color: var(--accent); }
#onglets { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
#onglets button { border: 0; background: none; padding: .45em .7em; color: var(--discret); border-radius: 6px; }
#onglets button.actif { background: var(--accent-clair); color: var(--accent); font-weight: 600; }
main { max-width: 1180px; margin: 0 auto; padding: 20px 16px 60px; }

.barre { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.barre h2 { margin: 0; flex: 1; }
.grille { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.pile { display: grid; gap: 14px; }
.formgrille { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.chiffre { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.tableau-defile { overflow-x: auto; border: 1px solid var(--ligne); border-radius: var(--rayon); background: #fff; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: .45em .6em; border-bottom: 1px solid var(--ligne); text-align: left; vertical-align: top; }
th { font-size: .82rem; color: var(--discret); font-weight: 600; background: #faf9f6; position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 700; background: #faf9f6; }
td.actions { white-space: nowrap; text-align: right; }

.encart { padding: 10px 12px; border-radius: 8px; background: var(--accent-clair); }
.encart.alerte { background: var(--rouge-clair); }
.pastille { display: inline-block; font-size: .78rem; padding: .05em .5em; border-radius: 99px; background: #eee; }
.pastille.ok { background: var(--accent-clair); color: var(--accent); }

dialog { border: 0; border-radius: var(--rayon); padding: 0; width: min(680px, calc(100% - 32px)); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.35); }
#dialogue-form { padding: 18px; display: grid; gap: 12px; max-height: 85vh; overflow: auto; }
.pied { display: flex; justify-content: flex-end; gap: 8px; }
pre.apercu { white-space: pre-wrap; background: #faf9f6; border: 1px solid var(--ligne); border-radius: 8px; padding: 12px; font: 13px/1.5 ui-monospace, Consolas, monospace; margin: 0; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #222; color: #fff; padding: .6em 1em; border-radius: 8px; z-index: 50; }

@media print {
  .entete, .barre button, td.actions, .non-imprime { display: none !important; }
  body { background: #fff; }
  main { padding: 0; }
}

/* Aide */
.aide { max-width: 760px; }
.aide section { margin: 26px 0; scroll-margin-top: 70px; }
.aide p, .aide li { max-width: 70ch; }
.aide li { margin: .3em 0; }
.aide code { background: #f0eee8; padding: .05em .35em; border-radius: 4px; }
.aide .sommaire ol { margin: .4em 0 0; padding-left: 1.3em; columns: 2; }
.aide .sommaire a { color: var(--accent); }
.aide ol.etapes { padding-left: 1.3em; }
.aide table.petit { width: auto; border: 1px solid var(--ligne); border-radius: 8px; background: #fff; margin: .6em 0; }
@media (max-width: 560px) { .aide .sommaire ol { columns: 1; } }
