:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --text: #132130;
  --muted: #5a6a7a;
  --border: #dbe3ec;
  --primary: #0f3d5e;
  --primary-ink: #ffffff;
  --accent: #12805c;
  --accent-soft: #e2f3eb;
  --warn: #8a5300;
  --warn-soft: #fcf1de;
  --c-inv: #a9bfd4;
  --c-gain: #12805c;
  --grid: #e4e9ef;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 6px 20px rgba(16, 24, 40, .06);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d141b;
    --surface: #151f29;
    --surface-2: #1c2834;
    --text: #e6edf3;
    --muted: #93a3b3;
    --border: #2a3846;
    --primary: #7cc0ef;
    --primary-ink: #0d141b;
    --accent: #4fd1a1;
    --accent-soft: #143529;
    --warn: #f3bf6b;
    --warn-soft: #33270f;
    --c-inv: #3d5670;
    --c-gain: #36b98a;
    --grid: #22303d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  }
}

:root[data-theme="dark"] {
  --bg: #0d141b;
  --surface: #151f29;
  --surface-2: #1c2834;
  --text: #e6edf3;
  --muted: #93a3b3;
  --border: #2a3846;
  --primary: #7cc0ef;
  --primary-ink: #0d141b;
  --accent: #4fd1a1;
  --accent-soft: #143529;
  --warn: #f3bf6b;
  --warn-soft: #33270f;
  --c-inv: #3d5670;
  --c-gain: #36b98a;
  --grid: #22303d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

a { color: var(--primary); }

.container { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

/* En-tête */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.site-header .container { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; color: var(--text); text-decoration: none; letter-spacing: -.01em; }
.logo span span { color: var(--accent); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { padding: 6px 12px; border-radius: 999px; text-decoration: none; color: var(--muted); font-size: .95rem; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: var(--primary); color: var(--primary-ink); }
.nav .soon { opacity: .55; pointer-events: none; }

/* Hero */
.hero { padding-top: 36px; padding-bottom: 20px; }
.breadcrumb { font-size: .85rem; color: var(--muted); margin-bottom: 8px; }
.breadcrumb a { color: var(--muted); }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); line-height: 1.2; margin: 0 0 12px; letter-spacing: -.02em; }
.lead { color: var(--muted); font-size: 1.08rem; max-width: 760px; margin: 0; }
.badges { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.badge { font-size: .8rem; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* Simulateur */
.layout { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: 24px; align-items: start; padding-top: 12px; padding-bottom: 40px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.form-card { position: sticky; top: 16px; }
.card h2 { font-size: 1.1rem; margin: 0 0 16px; }

.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 6px; }
.field .hint { display: block; font-weight: 400; color: var(--muted); font-size: .8rem; }
.field-row { display: flex; align-items: center; gap: 12px; }
.field-row input[type="range"] { flex: 1; min-width: 0; accent-color: var(--accent); }
.num { display: flex; align-items: center; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); padding: 0 8px; width: 118px; flex-shrink: 0; }
.num input { width: 100%; border: 0; background: transparent; color: var(--text); font: inherit; font-size: .95rem; padding: 7px 0; text-align: right; -moz-appearance: textfield; }
.num input::-webkit-outer-spin-button, .num input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.num input:focus { outline: none; }
.num:focus-within { border-color: var(--accent); }
.num span { color: var(--muted); font-size: .85rem; margin-left: 4px; }
select { width: 100%; font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); }

.results { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.kpi .label { font-size: .82rem; color: var(--muted); }
.kpi .value { overflow-wrap: anywhere; font-size: clamp(1.2rem, 2.4vw, 1.5rem); font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi.main { background: var(--primary); border-color: var(--primary); }
.kpi.main .label, .kpi.main .value { color: var(--primary-ink); }
.kpi.main .label { opacity: .85; }

.chart-card h2 { margin-bottom: 4px; }
.chart-sub { color: var(--muted); font-size: .85rem; margin: 0 0 12px; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 13px; }
.chart .bar-inv { fill: var(--c-inv); }
.chart .bar-gain { fill: var(--c-gain); }
.chart .marker { stroke: var(--warn); stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart .marker-label { fill: var(--warn); font-size: 13px; font-weight: 600; }
.legend { display: flex; gap: 18px; font-size: .85rem; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

.insights { display: grid; gap: 12px; }
.insight { border-radius: 12px; padding: 14px 16px; background: var(--accent-soft); color: var(--text); border-left: 4px solid var(--accent); font-size: .95rem; }
.insight.warn { background: var(--warn-soft); border-left-color: var(--warn); }
.insight strong { font-variant-numeric: tabular-nums; }

.breakdown { width: 100%; border-collapse: collapse; font-size: .92rem; font-variant-numeric: tabular-nums; }
.breakdown td { padding: 8px 0; border-bottom: 1px solid var(--border); }
.breakdown td:last-child { text-align: right; font-weight: 600; }
.breakdown tr.total td { border-bottom: 0; font-size: 1.02rem; color: var(--accent); }

details.table-wrap summary { cursor: pointer; font-weight: 600; }
.scroll { overflow-x: auto; margin-top: 12px; }
.yearly { width: 100%; border-collapse: collapse; font-size: .85rem; font-variant-numeric: tabular-nums; min-width: 520px; }
.yearly th, .yearly td { padding: 7px 8px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
.yearly th:first-child, .yearly td:first-child { text-align: left; }
.yearly th { color: var(--muted); font-weight: 600; background: var(--surface-2); }
.yearly tr.milestone td { background: var(--warn-soft); }

/* Contenu éditorial */
.content { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; padding-bottom: 40px; min-width: 0; }
.prose { max-width: 780px; }
.prose h2 { font-size: 1.45rem; margin: 32px 0 10px; letter-spacing: -.01em; }
.prose h3 { font-size: 1.1rem; margin: 22px 0 6px; }
.prose p, .prose li { color: var(--text); }
.fiscal { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: .93rem; }
.fiscal th, .fiscal td { border: 1px solid var(--border); padding: 9px 12px; text-align: left; vertical-align: top; }
.fiscal th { background: var(--surface-2); }
.faq details { border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; margin-bottom: 10px; background: var(--surface); }
.faq summary { cursor: pointer; font-weight: 600; }
.faq p { margin: 10px 0 0; }

.author { display: flex; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; max-width: 780px; }
.author .avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--primary); color: var(--primary-ink); display: grid; place-items: center; font-weight: 700; flex-shrink: 0; }
.author p { margin: 0; font-size: .9rem; color: var(--muted); }
.author strong { color: var(--text); }

.cta { display: inline-block; background: var(--accent); color: #fff; padding: 10px 18px; border-radius: 999px; text-decoration: none; font-weight: 600; }
:root[data-theme="dark"] .cta { color: #0d141b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .cta { color: #0d141b; } }

.disclaimer { font-size: .82rem; color: var(--muted); max-width: 780px; }

.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding: 24px 0; font-size: .85rem; color: var(--muted); }
.site-footer .container { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.site-footer a { color: var(--muted); }

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .form-card { position: static; }
}
@media (max-width: 420px) {
  .kpis { grid-template-columns: 1fr; }
  .num { width: 104px; }
}
@media (max-width: 640px) {
  .fiscal { display: block; overflow-x: auto; }
}

/* Navigation : défilement horizontal sur mobile */
@media (max-width: 860px) {
  .site-header .container { padding-top: 8px; }
  .nav { flex-wrap: nowrap; overflow-x: auto; width: 100%; padding-bottom: 8px; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; }
}

.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; }

/* Formulaire de contact */
.lead-card { border: 2px solid var(--accent); }
.lead-sub { color: var(--muted); margin: -8px 0 16px; font-size: .95rem; }
.lead-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.lead-form label { font-size: .88rem; font-weight: 600; }
.lead-form input:not([type="checkbox"]) { display: block; width: 100%; margin-top: 4px; font: inherit; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); }
.lead-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.lead-form .consent { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; color: var(--muted); font-size: .82rem; margin-bottom: 14px; }
.lead-form .consent input { margin-top: 3px; accent-color: var(--accent); }
.lead-form button { border: 0; cursor: pointer; font: inherit; font-weight: 600; }
.lead-form button:disabled { opacity: .6; cursor: wait; }
.lead-msg { margin: 10px 0 0; font-size: .9rem; min-height: 1em; }
.lead-msg.ok { color: var(--accent); }
.lead-msg.err { color: var(--warn); }
.hp { position: absolute; left: -9999px; }
@media (max-width: 640px) { .lead-grid { grid-template-columns: 1fr; } }

/* Encadré taux du moment */
.rate-box { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; background: var(--primary); color: var(--primary-ink); border-radius: var(--radius); padding: 18px 22px; margin-top: 20px; max-width: 760px; }
.rate-box .big { font-size: 2.4rem; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.rate-box p { margin: 0; opacity: .9; font-size: .95rem; }

/* Accueil */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; padding: 8px 0 40px; }
.tile { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; text-decoration: none; color: var(--text); transition: transform .15s, border-color .15s; }
.tile:hover { transform: translateY(-2px); border-color: var(--accent); }
.tile h2 { font-size: 1.15rem; margin: 0 0 6px; }
.tile p { margin: 0 0 12px; color: var(--muted); font-size: .92rem; }
.tile .go { color: var(--accent); font-weight: 600; font-size: .9rem; }
.tile .tag { display: inline-block; font-size: .75rem; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 2px 9px; margin-bottom: 10px; }

.compare { width: 100%; border-collapse: collapse; font-size: .9rem; }
.compare th, .compare td { border-bottom: 1px solid var(--border); padding: 10px 12px; text-align: left; }
.compare th { background: var(--surface-2); }
.compare-wrap { overflow-x: auto; }
.compare-wrap .compare { min-width: 640px; }

.legal h1 { margin-top: 32px; }
.legal { padding-bottom: 48px; }

.lead-form textarea { display: block; width: 100%; margin-top: 4px; font: inherit; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); resize: vertical; }

/* Bouton PDF */
.pdf-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 12px 16px; border-radius: 12px; border: 1.5px dashed var(--accent); background: var(--accent-soft); color: var(--accent); font: inherit; font-weight: 700; cursor: pointer; }
.pdf-btn:hover { border-style: solid; }

/* Articles */
.article-list { display: grid; gap: 16px; padding-bottom: 40px; }
.article-meta { color: var(--muted); font-size: .88rem; margin: 0 0 18px; }
.prose blockquote { margin: 16px 0; padding: 12px 16px; border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: 0 10px 10px 0; }

/* Courbe en J (private equity) */
.chart .bar-neg { fill: var(--warn); opacity: .8; }
.chart .zero { stroke: var(--muted); stroke-width: 1; }

.print-only { display: none; }

@media print {
  @page { margin: 14mm; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { background: #fff; color: #132130; font-size: 12px; }
  .site-header, .hero, .form-card, .content, .lead-card, .pdf-btn, .chart-sub, .site-footer .container > span:last-child, details summary, #history-calc { display: none !important; }
  .print-only { display: block !important; }
  .container { max-width: none; padding: 0; }
  .layout { display: block; padding: 0; }
  .results { gap: 12px; }
  .card, .kpi { box-shadow: none; break-inside: avoid; }
  .chart-card { break-inside: avoid; }
  .print-head { margin-bottom: 12px; }
  .ph-top { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #0f3d5e; padding-bottom: 8px; margin-bottom: 10px; color: #5a6a7a; }
  .ph-logo { font-size: 18px; color: #132130; }
  .ph-logo span { color: #12805c; }
  .ph-title { font-size: 20px; margin: 6px 0 10px; }
  .print-head h2 { font-size: 14px; margin: 14px 0 6px; }
  .site-footer { background: #fff; border-top: 1px solid #dbe3ec; margin-top: 14px; padding: 8px 0; }
  .site-footer::after { content: "Simulation non contractuelle fournie à titre indicatif par simul-epargne.fr. Elle ne constitue pas un conseil en investissement. Raoul Dumas Madassamy, conseiller en gestion de patrimoine."; display: block; font-size: 10px; color: #5a6a7a; margin-top: 4px; }
}
@media print {
  :root:not(.print-x), :root[data-theme="dark"] {
    --bg: #fff; --surface: #fff; --surface-2: #eef2f7; --text: #132130; --muted: #5a6a7a; --border: #dbe3ec;
    --primary: #0f3d5e; --primary-ink: #fff; --accent: #12805c; --accent-soft: #e2f3eb; --warn: #8a5300; --warn-soft: #fcf1de;
    --c-inv: #a9bfd4; --c-gain: #12805c; --grid: #e4e9ef;
  }
}

/* Menus déroulants */
.nav { align-items: center; }
.nav-menu { position: relative; }
.nav-menu > summary { list-style: none; cursor: pointer; padding: 6px 12px; border-radius: 999px; color: var(--muted); font-size: .95rem; white-space: nowrap; user-select: none; }
.nav-menu > summary::-webkit-details-marker { display: none; }
.nav-menu > summary::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: translateY(-3px) rotate(45deg); }
.nav-menu > summary:hover, .nav-menu[open] > summary { background: var(--surface-2); color: var(--text); }
.nav-menu.active > summary { background: var(--primary); color: var(--primary-ink); }
.nav-panel { position: absolute; top: calc(100% + 6px); right: 0; z-index: 30; min-width: 240px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; display: grid; }
.nav-panel a { padding: 8px 12px; border-radius: 8px; white-space: nowrap; }
.nav-panel a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
@media (max-width: 860px) {
  .nav { overflow: visible; flex-wrap: wrap; }
  .nav-panel { position: absolute; left: 0; right: auto; }
  .nav-menu:last-of-type .nav-panel { left: auto; right: 0; }
}

/* Alerte e-mail */
.alert-row { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.alert-row input { flex: 1; min-width: 200px; margin-top: 0 !important; }
.alert-row .cta { border: 0; cursor: pointer; font: inherit; font-weight: 600; }

/* Tableaux de résultats multiples (comparateur) */
.rank { width: 100%; border-collapse: collapse; font-size: .9rem; font-variant-numeric: tabular-nums; }
.rank th, .rank td { padding: 9px 8px; border-bottom: 1px solid var(--border); text-align: right; }
.rank th:first-child, .rank td:first-child { text-align: left; }
.rank th { color: var(--muted); font-weight: 600; background: var(--surface-2); }
.rank .bar { display: block; height: 6px; border-radius: 3px; background: var(--accent); margin-top: 4px; }
.rank .flag { color: var(--warn); font-size: .8rem; display: block; }
.mode-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.mode-tabs button { font: inherit; font-size: .9rem; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; }
.mode-tabs button[aria-pressed="true"] { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.field.hidden { display: none; }
.section-title { font-size: 1.3rem; margin: 18px 0 10px; letter-spacing: -.01em; }

/* Offres partenaires (affiliation) */
.offres { display: grid; gap: 10px; margin-bottom: 10px; }
.offre { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px; border: 1px solid var(--border); border-radius: 12px; flex-wrap: wrap; }
.offre p { margin: 2px 0 0; color: var(--muted); font-size: .9rem; }
.prose a[target="_blank"] { text-decoration-thickness: 1px; text-underline-offset: 2px; }
.sources { font-size: .9rem; color: var(--muted); padding-left: 18px; }
.sources li { margin-bottom: 4px; }

/* Actions sous les résultats (PDF, lien de partage) */
.sim-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.share-btn { background: var(--surface); color: var(--primary); border-color: var(--primary); }
@media (max-width: 640px) { .sim-actions { grid-template-columns: 1fr; } }

/* Chiffres clés, exemple chiffré, sommaire */
.keyfigs { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 18px; max-width: 900px; }
.keyfig { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; }
.keyfig b { display: block; font-size: 1.2rem; letter-spacing: -.01em; color: var(--primary); font-variant-numeric: tabular-nums; }
.keyfig span { font-size: .8rem; color: var(--muted); }
.verified { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; font-size: .82rem; color: var(--accent); font-weight: 600; }
.exemple { border: 1px solid var(--border); border-left: 4px solid var(--primary); background: var(--surface); border-radius: 0 12px 12px 0; padding: 14px 18px; margin: 4px 0 18px; }
.exemple strong:first-child { display: block; color: var(--primary); margin-bottom: 4px; }
.toc { background: var(--surface-2); border-radius: 12px; padding: 14px 18px; margin: 0 0 18px; font-size: .92rem; }
.toc ol { margin: 6px 0 0; padding-left: 20px; }
.toc li { margin: 3px 0; }
.toc a { text-decoration: none; }
.toc a:hover { text-decoration: underline; }

/* Recherche en page d'accueil */
.search-box { margin-top: 20px; max-width: 640px; position: relative; }
.search-box input { width: 100%; font: inherit; font-size: 1.05rem; padding: 14px 16px 14px 44px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.search-box input:focus { outline: none; border-color: var(--accent); }
.search-box svg { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.quick a { font-size: .85rem; padding: 5px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--text); text-decoration: none; }
.quick a:hover { border-color: var(--accent); color: var(--accent); }
.no-result { color: var(--muted); display: none; }

/* À propos */
.about-head { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.about-photo { width: 120px; height: 120px; border-radius: 50%; background: var(--primary); color: var(--primary-ink); display: grid; place-items: center; font-size: 2.2rem; font-weight: 800; flex-shrink: 0; overflow: hidden; }
.about-photo img { width: 100%; height: 100%; object-fit: cover; }
