/* ActifBase — design system commun (mobile d'abord, mode sombre automatique). */

:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #efede6;
  --ink: #14202e;
  --muted: #55606d;
  --line: #dedad0;
  --accent: #0d5c4b;
  --accent-ink: #ffffff;
  --accent-soft: #e2efe9;
  --brass: #8a6420;
  --danger: #a3261b;
  --focus: #1a66d6;
  --c-verse: #3a5573;
  --c-gains: #2f8f6f;
  --c-reel: #b07a1f;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgb(20 32 46 / 6%), 0 8px 24px rgb(20 32 46 / 6%);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-titre: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --pad: clamp(0.875rem, 4vw, 1.5rem);
  --max: 72rem;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c131b;
    --surface: #121b25;
    --surface-2: #18232f;
    --ink: #e7ebef;
    --muted: #a0abb7;
    --line: #263443;
    --accent: #5cc4a1;
    --accent-ink: #062019;
    --accent-soft: #143229;
    --brass: #dcb36a;
    --danger: #ff8a7d;
    --focus: #7fb0ff;
    --c-verse: #7d97b5;
    --c-gains: #4fbf95;
    --c-reel: #e0b45e;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px rgb(0 0 0 / 25%);
  }
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.65 var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-wrap: break-word;
}
main { flex: 1; }
img, svg { max-width: 100%; }
a { color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { font-family: var(--font-titre); line-height: 1.2; font-weight: 600; letter-spacing: -0.01em; text-wrap: balance; }
h1 { font-size: clamp(1.6rem, 6vw, 2.6rem); margin: 0 0 0.75rem; }
h2 { font-size: clamp(1.3rem, 4.5vw, 1.75rem); margin: 2.5rem 0 0.75rem; }
h3 { font-size: clamp(1.1rem, 3.8vw, 1.3rem); margin: 1.75rem 0 0.5rem; }
p, ul, ol { margin: 0 0 1rem; }
ul, ol { padding-left: 1.25rem; }
li + li { margin-top: 0.35rem; }
strong { font-weight: 650; }
code, .formule { font-family: var(--mono); font-size: 0.92em; }
.formule {
  display: block;
  overflow-x: auto;
  padding: 0.75rem 1rem;
  margin: 0 0 1rem;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
[hidden] { display: none !important; }
.visuellement-cache {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.lien-evitement { position: absolute; left: 0.5rem; top: -3rem; z-index: 10; padding: 0.5rem 1rem; background: var(--surface); }
.lien-evitement:focus { top: 0.5rem; }

/* Mise en page */
.conteneur { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 var(--pad); }
.etroit { max-width: 46rem; }
.section { padding: 2rem 0; }

/* En-tête */
.entete { border-bottom: 1px solid var(--line); background: var(--surface); }
.entete .conteneur { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.25rem 1rem; min-height: 3.75rem; padding-block: 0.5rem; }
.logo { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--ink); text-decoration: none; font: 650 1.15rem/1 var(--font-titre); letter-spacing: 0.01em; }
.logo svg { width: 1.6rem; height: 1.6rem; flex: none; }
.nav ul { display: flex; flex-wrap: wrap; gap: 0 1.1rem; list-style: none; margin: 0; padding: 0; }
.nav li + li { margin: 0; }
.nav a { display: inline-block; padding: 0.45rem 0; color: var(--muted); text-decoration: none; font-size: 0.95rem; }
.nav a:hover, .nav a[aria-current] { color: var(--ink); }
.nav a[aria-current] { box-shadow: inset 0 -2px 0 var(--accent); }

/* Fil d'Ariane */
.ariane { font-size: 0.85rem; color: var(--muted); margin: 1.25rem 0 0.75rem; }
.ariane ol { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.25rem; }
.ariane li + li { margin: 0; }
.ariane li + li::before { content: "›"; margin-right: 0.35rem; color: var(--muted); }
.ariane a { color: var(--muted); }

/* En-tête de page */
.chapeau { font-size: 1.075rem; color: var(--muted); max-width: 46rem; }
.hero { padding: 2.5rem 0 1.5rem; }
.hero .sur-titre { color: var(--brass); font-size: 0.8rem; font-weight: 650; letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 0.5rem; }

/* Cartes */
.carte { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--pad); box-shadow: var(--shadow); }
.grille { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); }
.carte-outil { position: relative; display: flex; flex-direction: column; gap: 0.5rem; }
.carte-outil h2, .carte-outil h3 { margin: 0; font-size: 1.2rem; }
.carte-outil p { margin: 0; color: var(--muted); font-size: 0.95rem; }
.carte-outil a.etirer { color: var(--ink); text-decoration: none; }
.carte-outil a.etirer::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.carte-outil:hover { border-color: var(--accent); }
.carte-outil .lien-action { margin-top: auto; padding-top: 0.5rem; color: var(--accent); font-weight: 600; font-size: 0.95rem; }
.carte-outil.bientot { box-shadow: none; background: transparent; border-style: dashed; }
.carte-outil.bientot:hover { border-color: var(--line); }
.carte-outil.bientot h3 { color: var(--muted); }
.badge { align-self: flex-start; font-size: 0.72rem; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; padding: 0.2rem 0.55rem; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.badge.neutre { background: var(--surface-2); color: var(--muted); }

.atouts { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); padding: 0; list-style: none; }
.atouts li + li { margin: 0; }
.atouts strong { display: block; font-family: var(--font-titre); font-size: 1.1rem; margin-bottom: 0.25rem; }
.atouts span { color: var(--muted); font-size: 0.95rem; }

/* Formulaires */
.champs { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 13rem), 1fr)); }
fieldset { border: 0; margin: 0 0 1.25rem; padding: 0; min-width: 0; }
legend { font-weight: 650; font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.75rem; padding: 0; }
.champs + .champ { margin-top: 1rem; }
.champ { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.champ label, .champ .etiquette { font-weight: 600; font-size: 0.92rem; }
.champ.large { grid-column: 1 / -1; }
.champ-pied { display: flex; flex-direction: column; gap: 0.3rem; }
.champ-pied:has(.aide:empty):has(.erreur:empty) { display: none; }
.saisie { position: relative; display: flex; }
.saisie input, .saisie select, .champ textarea, .champ > input {
  width: 100%;
  min-height: 2.9rem;
  padding: 0.6rem 0.8rem;
  font: inherit;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  appearance: none;
}
.saisie select { padding-right: 2.2rem; background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%); background-position: right 1.1rem center, right 0.8rem center; background-size: 0.3rem 0.3rem; background-repeat: no-repeat; }
.saisie .unite { position: absolute; right: 0.8rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; font-size: 0.95rem; }
.saisie:has(.unite) input { padding-right: 2.4rem; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
[aria-invalid="true"] { border-color: var(--danger) !important; }
.aide { font-size: 0.82rem; color: var(--muted); }
.erreur { font-size: 0.85rem; color: var(--danger); font-weight: 600; }
.erreur:empty { display: none; }
.choix { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.choix label { display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.55rem 0.85rem; border: 1px solid var(--line); border-radius: var(--radius-sm); font-weight: 500; cursor: pointer; background: var(--surface); min-height: 2.75rem; }
.choix label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choix input { accent-color: var(--accent); width: 1.05rem; height: 1.05rem; margin: 0; }
.choix label:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.choix input:focus-visible { outline: none; }

/* Boutons */
.bouton { display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; min-height: 2.75rem; padding: 0.55rem 1.1rem; font: 600 0.95rem/1.2 var(--font); border-radius: var(--radius-sm); border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); cursor: pointer; text-decoration: none; }
.bouton:hover { filter: brightness(1.08); }
.bouton.secondaire { background: transparent; color: var(--accent); }
.bouton.discret { background: transparent; border-color: var(--line); color: var(--ink); }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.statut { font-size: 0.85rem; color: var(--muted); min-height: 1.3em; }

/* Outil */
.outil { display: grid; gap: 1.25rem; margin: 1.5rem 0 2rem; }
.outil-resultats { display: flex; flex-direction: column; gap: 1.25rem; min-width: 0; }
@media (min-width: 60rem) {
  .outil { grid-template-columns: minmax(0, 27rem) minmax(0, 1fr); align-items: start; }
  .outil-formulaire { position: sticky; top: 1rem; }
  .outil-formulaire .champs { grid-template-columns: 1fr 1fr; }
  /* Alignement : les libellés, saisies et aides d'une même rangée partagent les mêmes lignes de grille. */
  @supports (grid-template-rows: subgrid) {
    .outil-formulaire .champs { row-gap: 0; }
    .outil-formulaire .champs > .champ { display: grid; grid-row: span 3; grid-template-rows: subgrid; row-gap: 0.3rem; align-content: start; padding-bottom: 1rem; }
    .outil-formulaire .champs > .champ > :first-child { align-self: end; }
  }
}
.chiffres { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 10.5rem), 1fr)); margin: 0; }
.chiffre { padding: 0.85rem 1rem; border-radius: var(--radius-sm); background: var(--surface-2); min-width: 0; }
.chiffre dt { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.chiffre dd { overflow-wrap: anywhere; margin: 0.15rem 0 0; font: 650 clamp(1.05rem, 4.2vw, 1.3rem)/1.25 var(--font); font-variant-numeric: tabular-nums; }
.chiffre.principal { grid-column: 1 / -1; background: var(--accent); color: var(--accent-ink); }
.chiffre.principal dt { color: inherit; opacity: 0.85; }
.chiffre.principal dd { font-size: clamp(1.5rem, 7vw, 2.1rem); }
.phrase-resultat { margin: 0; color: var(--muted); font-size: 0.95rem; }

/* Bandeau de résultat (mobile) : collé en bas tant que le formulaire est affiché et les résultats hors écran */
.bandeau-resultat { position: fixed; left: 0.5rem; right: 0.5rem; bottom: max(0.5rem, env(safe-area-inset-bottom)); z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.6rem 0.9rem; border-radius: var(--radius-sm); background: var(--accent); color: var(--accent-ink); text-decoration: none; box-shadow: var(--shadow); font-variant-numeric: tabular-nums; line-height: 1.3; transform: translateY(calc(100% + 1rem)); visibility: hidden; }
.bandeau-resultat.visible { transform: none; visibility: visible; }
.bandeau-libelle { display: block; font-size: 0.78rem; opacity: 0.9; }
.bandeau-resultat strong { font-size: 1.15rem; }
.bandeau-lien { flex: none; font-size: 0.85rem; font-weight: 600; }
@media (prefers-reduced-motion: no-preference) { .bandeau-resultat { transition: transform 0.2s ease, visibility 0.2s; } }
@media (min-width: 60rem) { .bandeau-resultat { display: none; } }

/* Comparatif (calcul de la flat tax) */
.verdict { padding: 1rem 1.1rem; border-radius: var(--radius-sm); background: var(--accent); color: var(--accent-ink); }
.verdict p { margin: 0; }
.verdict .verdict-titre { font: 650 clamp(1.15rem, 4.5vw, 1.4rem)/1.3 var(--font); }
.verdict .verdict-detail { margin-top: 0.3rem; font-size: 0.92rem; opacity: 0.92; }
.comparatif td:first-child, .comparatif th:first-child { white-space: normal; }
.comparatif tfoot td, .comparatif tfoot th { font-weight: 700; border-top: 2px solid var(--line); border-bottom: 0; }
.comparatif .gagnant { background: var(--accent-soft); }
.notes { display: grid; gap: 0.6rem; padding: 0; margin: 0; list-style: none; font-size: 0.92rem; }
.notes li + li { margin: 0; }
.notes li { padding: 0.7rem 0.9rem; border-radius: var(--radius-sm); background: var(--surface-2); border-left: 3px solid var(--line); }
.notes li.attention { border-left-color: var(--brass); }
details > .notes { margin-top: 0.75rem; }
.autres-outils h2 { margin-top: 3rem; }

/* Graphique */
.legende { display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; list-style: none; padding: 0; margin: 0 0 0.75rem; font-size: 0.85rem; color: var(--muted); }
.legende li + li { margin: 0; }
.legende i { display: inline-block; width: 0.8rem; height: 0.8rem; border-radius: 3px; margin-right: 0.35rem; vertical-align: -0.1rem; }
.legende .ligne i { height: 3px; border-radius: 2px; vertical-align: 0.2rem; }
.legende .verse i { background: var(--c-verse); }
.legende .gains i { background: var(--c-gains); }
.legende .reel i { background: var(--c-reel); }
.outil-resultats h2 { margin: 0; }
.outil-resultats h3 { margin: 0.5rem 0 0.5rem; }
details > .tableau-defilant { margin-top: 0.75rem; }
details > summary.bouton { list-style: none; }
details > summary.bouton::-webkit-details-marker { display: none; }
.graphique { position: relative; aspect-ratio: 16 / 10; min-height: 14rem; max-height: 26rem; width: 100%; touch-action: pan-y; }
.graphique svg { display: block; width: 100%; height: 100%; overflow: visible; }
.graphique text { fill: var(--muted); font: 11px var(--font); font-variant-numeric: tabular-nums; }
.graphique .grille-axe { stroke: var(--line); stroke-width: 1; }
.graphique .curseur { stroke: var(--muted); stroke-dasharray: 3 3; }
.infobulle { position: absolute; top: 0; z-index: 2; min-width: 11rem; padding: 0.55rem 0.7rem; font-size: 0.8rem; line-height: 1.45; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow); pointer-events: none; font-variant-numeric: tabular-nums; }
.infobulle[hidden] { display: none; }
.infobulle b { display: block; margin-bottom: 0.15rem; }
.infobulle span { display: flex; justify-content: space-between; gap: 0.75rem; }
.legende .pea i { background: var(--c-gains); }
.legende .av i { background: var(--c-verse); }
.legende .cto i { background: var(--c-reel); }
.legende .ligne.verse i { height: 0; background: none; border-top: 2px dashed var(--muted); }

.legende .reinvesti i { background: var(--c-gains); }
.legende .percu i { background: var(--c-reel); }

/* Onglets (simulateur de dividendes) : défilement horizontal sur petit écran, hauteur fixe */
.onglets { display: flex; gap: 0.25rem; margin: 1.5rem 0 0; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.onglets [role="tab"] { flex: none; min-height: 2.9rem; padding: 0.6rem 1rem; font: 600 0.95rem/1.2 var(--font); color: var(--muted); background: transparent; border: 0; border-bottom: 3px solid transparent; border-radius: var(--radius-sm) var(--radius-sm) 0 0; cursor: pointer; }
.onglets [role="tab"]:hover { color: var(--ink); background: var(--surface-2); }
.onglets [role="tab"][aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.onglets [role="tab"]:focus-visible { outline-offset: -3px; }
.onglets + .outil { margin-top: 1.25rem; }

/* Comparateur d'enveloppes : classement et emplacements d'affiliation (inactifs) */
.comparatif tr.gagnant > * { background: var(--accent-soft); }
.affiliation h3 { margin-top: 0; }
.affiliation .actions { margin-bottom: 0.5rem; }
.bouton:disabled { opacity: 0.6; cursor: not-allowed; filter: none; }

/* Tableaux */
.tableau-defilant { overflow: auto; max-height: 28rem; border: 1px solid var(--line); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; font-variant-numeric: tabular-nums; }
caption { text-align: left; font-weight: 600; padding: 0.6rem 0.75rem; }
th, td { padding: 0.5rem 0.75rem; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; }
thead th { position: sticky; top: 0; background: var(--surface-2); font-size: 0.78rem; color: var(--muted); font-weight: 650; }
tbody tr:last-child td { border-bottom: 0; }

/* Encadrés */
.encadre { padding: 1rem 1.15rem; border-radius: var(--radius-sm); background: var(--surface-2); border-left: 4px solid var(--brass); margin: 1.5rem 0; font-size: 0.95rem; }
.encadre p:last-child { margin: 0; }
.source { font-size: 0.85rem; color: var(--muted); }

/* FAQ */
.faq { border-top: 1px solid var(--line); }
.faq details { border-bottom: 1px solid var(--line); }
.faq summary { display: flex; justify-content: space-between; gap: 1rem; padding: 1rem 0; cursor: pointer; font-weight: 650; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 1.3rem; line-height: 1; color: var(--accent); flex: none; }
.faq details[open] summary::after { content: "−"; }
.faq details > div { padding: 0 0 1rem; color: var(--ink); }

/* Emplacements publicitaires (inactifs : hauteur réservée pour éviter tout décalage) */
.pub-slot { min-height: 280px; margin: 2rem 0; border-radius: var(--radius-sm); background: repeating-linear-gradient(135deg, transparent 0 10px, var(--surface-2) 10px 11px); border: 1px dashed var(--line); display: grid; place-items: center; }
.pub-slot::before { content: "Publicité"; font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
@media (min-width: 48rem) { .pub-slot { min-height: 250px; } }

/* Contenu éditorial */
.prose { max-width: 46rem; }
.prose > h2:first-child { margin-top: 0; }
.legal h2 { font-size: 1.25rem; margin-top: 2rem; }

/* Pied de page */
.pied { margin-top: 3rem; padding: 2.5rem 0 1.5rem; background: var(--surface); border-top: 1px solid var(--line); font-size: 0.9rem; color: var(--muted); }
.pied-colonnes { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr)); }
.pied h2 { font: 650 0.78rem/1.4 var(--font); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink); margin: 0 0 0.6rem; }
.pied ul { list-style: none; padding: 0; margin: 0; }
.pied a { color: var(--muted); }
.pied a:hover { color: var(--ink); }
.pied .lien-bouton { padding: 0; border: 0; background: none; font: inherit; color: var(--muted); text-decoration: underline; text-underline-offset: 0.18em; text-decoration-thickness: 1px; cursor: pointer; }
.pied .lien-bouton:hover:enabled { color: var(--ink); }
.pied .lien-bouton:disabled { text-decoration: none; cursor: default; }
.pied .mention { border-top: 1px solid var(--line); margin-top: 2rem; padding-top: 1rem; font-size: 0.82rem; }

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
@media print {
  .entete, .pied, .pub-slot, .actions, .ariane { display: none !important; }
  body { background: #fff; color: #000; }
}
