:root {
  --fond: #f6f7f9;
  --carte: #ffffff;
  --texte: #1d2330;
  --doux: #5c6577;
  --bord: #dfe3ea;
  --accent: #1f5fbf;
  --accent-texte: #ffffff;
  --ok-fond: #e6f4ea;
  --ok-texte: #1e6b34;
  --attente-fond: #fff4e0;
  --attente-texte: #8a5300;
  --erreur-fond: #fdecea;
  --erreur-texte: #a3261b;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #14171d;
    --carte: #1d2129;
    --texte: #e6e9ef;
    --doux: #9aa3b4;
    --bord: #323846;
    --accent: #6ea2ff;
    --accent-texte: #0d1a33;
    --ok-fond: #183323;
    --ok-texte: #8fd6a4;
    --attente-fond: #3a2b10;
    --attente-texte: #f2c46d;
    --erreur-fond: #3d1a17;
    --erreur-texte: #ff9b90;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--fond);
  color: var(--texte);
}
a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0 0 1rem; }
h2 { font-size: 1.25rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; color: var(--doux); grid-column: 1 / -1; }
small, .aide { color: var(--doux); font-size: .875rem; }

/* En-tête et menu */
.entete { background: var(--carte); border-bottom: 1px solid var(--bord); }
.entete-haut, .menu { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.entete-haut { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-top: .75rem; }
.marque { font-weight: 700; text-decoration: none; color: var(--texte); }
.choix-annee { display: flex; align-items: center; gap: .5rem; }
.choix-annee select { width: auto; }
.js .sans-js { display: none; }
.menu { display: flex; gap: .25rem; overflow-x: auto; padding-top: .5rem; }
.menu a {
  padding: .5rem .75rem; text-decoration: none; color: var(--doux);
  border-bottom: 3px solid transparent; white-space: nowrap;
}
.menu a[aria-current="page"] { color: var(--texte); border-bottom-color: var(--accent); font-weight: 600; }

main { max-width: 1100px; margin: 0 auto; padding: 1.5rem 16px 4rem; }
section { background: var(--carte); border: 1px solid var(--bord); border-radius: 10px; padding: 1.25rem; margin-bottom: 1.5rem; scroll-margin-top: 1rem; }

/* Messages */
.message { padding: .75rem 1rem; border-radius: 8px; margin: 0 0 1rem; }
.message.ok { background: var(--ok-fond); color: var(--ok-texte); }
.message.erreur { background: var(--erreur-fond); color: var(--erreur-texte); }
.vide { color: var(--doux); background: var(--carte); border: 1px dashed var(--bord); border-radius: 10px; padding: 1.5rem; text-align: center; }

/* Boutons */
button, .bouton {
  display: inline-block; font: inherit; font-weight: 600; cursor: pointer;
  background: var(--accent); color: var(--accent-texte);
  border: 1px solid var(--accent); border-radius: 8px; padding: .5rem 1rem; text-decoration: none;
}
button.secondaire, .bouton.secondaire { background: transparent; color: var(--accent); }
button.danger { background: var(--erreur-texte); border-color: var(--erreur-texte); color: #fff; }
a.danger { color: var(--erreur-texte); }
button.petit { padding: .2rem .6rem; font-size: .85rem; }
.boutons { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: 1rem; }
form.en-ligne { display: inline; }

/* Titres avec bouton */
.titre-ligne { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.titre-ligne h1 { margin: 0; }

/* Chiffres clés */
.chiffres { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.chiffre { background: var(--carte); border: 1px solid var(--bord); border-radius: 10px; padding: 1rem; display: flex; flex-direction: column; }
.chiffre span { color: var(--doux); font-size: .9rem; }
.chiffre strong { font-size: 1.5rem; font-variant-numeric: tabular-nums; }

/* Filtres et sommaire */
.filtres, .sommaire { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filtres a, .sommaire a { padding: .3rem .8rem; border: 1px solid var(--bord); border-radius: 999px; text-decoration: none; background: var(--carte); }
.filtres a[aria-current="true"] { background: var(--accent); color: var(--accent-texte); border-color: var(--accent); }

/* Tableaux */
table { width: 100%; border-collapse: collapse; background: var(--carte); }
table.liste { border: 1px solid var(--bord); border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--bord); vertical-align: top; }
thead th { font-size: .85rem; color: var(--doux); font-weight: 600; }
tfoot th { border-bottom: 0; }
.nombre { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.actions { text-align: right; white-space: nowrap; }
.masque { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.statut { display: inline-block; padding: 0 .5rem; border-radius: 999px; font-size: .8rem; font-weight: 600; }
.statut.paye { background: var(--ok-fond); color: var(--ok-texte); }
.statut.attente { background: var(--attente-fond); color: var(--attente-texte); }

/* Formulaires */
.formulaire { display: flex; flex-direction: column; gap: .75rem; max-width: 760px; }
fieldset { border: 1px solid var(--bord); border-radius: 10px; padding: 1rem; margin: 0; display: flex; flex-direction: column; gap: .75rem; background: var(--carte); }
legend { font-weight: 600; padding: 0 .4rem; }
label { display: flex; flex-direction: column; gap: .25rem; font-weight: 500; }
label.case { flex-direction: row; align-items: center; gap: .5rem; }
input, select, textarea {
  font: inherit; color: var(--texte); background: var(--fond);
  border: 1px solid var(--bord); border-radius: 6px; padding: .45rem .6rem; width: 100%;
}
input[type="checkbox"] { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.ligne { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.parametres { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; max-width: none; }
.parametres > .aide, .parametres > table, .parametres > .case, .parametres > .boutons, .parametres > label:has(+ table) { grid-column: 1 / -1; }
table.bareme { max-width: 520px; }
table.bareme input { max-width: 180px; }

/* Téléphone */
@media (max-width: 700px) {
  .ligne, .parametres { grid-template-columns: 1fr; }
  .entete-haut { flex-wrap: wrap; }
  table.liste thead { display: none; }
  table.liste tr { display: block; border-bottom: 1px solid var(--bord); padding: .5rem 0; }
  table.liste td, table.liste tfoot th { display: block; border: 0; padding: .2rem .75rem; text-align: left; }
  table.liste td[data-titre]::before { content: attr(data-titre) " : "; color: var(--doux); font-size: .85rem; }
  .actions { text-align: left; }
}

/* Étape 3 : tableau de bord, cotisations, impôt */
.bandeau { background: var(--attente-fond); color: var(--attente-texte); border-radius: 8px; padding: .6rem 1rem; margin: 0 0 1.25rem; font-size: .9rem; }
.message.avertissement { background: var(--attente-fond); color: var(--attente-texte); }
.alertes { list-style: none; padding: 0; margin: 0 0 1.25rem; display: flex; flex-direction: column; gap: .5rem; }
.alerte { padding: .65rem 1rem; border-radius: 8px; border-left: 4px solid; }
.alerte.danger { background: var(--erreur-fond); color: var(--erreur-texte); }
.alerte.attention { background: var(--attente-fond); color: var(--attente-texte); }
.alerte.info { background: var(--carte); color: var(--texte); border-color: var(--accent); border-top: 1px solid var(--bord); border-right: 1px solid var(--bord); border-bottom: 1px solid var(--bord); }
.statut.retard { background: var(--erreur-fond); color: var(--erreur-texte); }
tr.retard td { color: var(--erreur-texte); }
.estimation { font-size: .75rem; font-style: normal; color: var(--doux); }
em.estimation { border: 1px solid var(--bord); border-radius: 999px; padding: 0 .4rem; margin-left: .25rem; }
.chiffres.principaux .chiffre.fort { border-color: var(--accent); border-width: 2px; }
.chiffres.principaux .chiffre.fort strong { font-size: 2.1rem; color: var(--accent); }
.chiffre dl { display: grid; grid-template-columns: 1fr auto; gap: .15rem 1rem; margin: .5rem 0; }
.chiffre dt { color: var(--doux); }
.chiffre dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.jauge meter { width: 100%; height: 1.4rem; }
ol.etapes { padding-left: 1.4rem; display: flex; flex-direction: column; gap: .8rem; margin: 0; }
ul.detail { margin: .25rem 0 0; }
.deux-colonnes { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-top: 1rem; }
table.comparaison td:first-child { padding-left: 1.75rem; color: var(--doux); }
@media (max-width: 700px) {
  .deux-colonnes { grid-template-columns: 1fr; }
}

/* Étape 4 : connexion et compte */
main.etroit { max-width: 560px; padding-top: 3rem; }
.deconnexion { margin-left: auto; }
.entete-haut .choix-annee { margin-left: auto; }
.entete-haut .deconnexion { margin-left: 0; }
.qr { background: #fff; padding: .5rem; width: 220px; max-width: 100%; margin: .75rem 0; border-radius: 8px; }
.qr svg { display: block; width: 100%; height: auto; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
pre { background: var(--carte); border: 1px solid var(--bord); border-radius: 8px; padding: .75rem 1rem; }
ol.codes-secours { columns: 2; font-size: 1.25rem; padding-left: 1.75rem; }
ol.codes-secours li { margin: .3rem 0; }
@media print {
  .sans-impression, .entete { display: none; }
  body { background: #fff; color: #000; }
}
