:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --line: #d9dde5;
  --line-soft: #e8ebf0;
  --ink: #14181f;
  --ink-2: #4b5462;
  --ink-3: #7a8494;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --warn-bg: #fff4e0;
  --warn-ink: #7a4a00;
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --s4: #eda100;
  --s5: #e87ba4;
  --s6: #008300;
  --s7: #4a3aa7;
  --s8: #e34948;
  --focus: #2a78d6;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #131519;
    --surface: #1b1e24;
    --surface-2: #23272f;
    --line: #333944;
    --line-soft: #2a2f38;
    --ink: #f1f3f6;
    --ink-2: #b5bcc8;
    --ink-3: #7f8896;
    --accent: #3987e5;
    --accent-ink: #ffffff;
    --warn-bg: #3a2a0c;
    --warn-ink: #f4c46a;
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --s4: #c98500;
    --s5: #d55181;
    --s6: #008300;
    --s7: #9085e9;
    --s8: #e66767;
    --focus: #3987e5;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #131519;
  --surface: #1b1e24;
  --surface-2: #23272f;
  --line: #333944;
  --line-soft: #2a2f38;
  --ink: #f1f3f6;
  --ink-2: #b5bcc8;
  --ink-3: #7f8896;
  --accent: #3987e5;
  --accent-ink: #ffffff;
  --warn-bg: #3a2a0c;
  --warn-ink: #f4c46a;
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --s4: #c98500;
    --s5: #d55181;
    --s6: #008300;
    --s7: #9085e9;
    --s8: #e66767;
  --focus: #3987e5;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Public Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
.wrap > * { min-width: 0; }
.wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding-block: 32px 56px;
  padding-inline: 20px;
  display: grid;
  gap: 28px;
}
h1, h2, h3 { margin: 0; text-wrap: balance; line-height: 1.2; }
h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 17px; font-weight: 600; }
p { margin: 0; }
.lede { color: var(--ink-2); max-width: 62ch; margin-top: 8px; }
.eyebrow {
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-3);
}
.num, .mono { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace; font-variant-numeric: tabular-nums; }

/* Form */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px 20px;
}
.field { display: grid; gap: 6px; }
.field label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.input {
  display: flex; align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  height: 40px;
  overflow: hidden;
}
.input:focus-within { outline: 2px solid var(--focus); outline-offset: 1px; }
.input input {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink);
  padding: 0 10px; height: 100%; font: inherit;
  font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 15px;
}
.input input:focus { outline: none; }
.input select {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink);
  padding: 0 8px; height: 100%; font: inherit; font-size: 14.5px; cursor: pointer;
}
.input select:focus { outline: none; }
.input .unit {
  padding: 0 10px; height: 100%; display: flex; align-items: center;
  background: var(--surface-2); color: var(--ink-3); font-size: 13px;
  border-left: 1px solid var(--line);
}
.form-foot {
  margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px 20px;
  color: var(--ink-3); font-size: 13px;
}
details.assump summary { cursor: pointer; color: var(--ink-2); font-size: 13.5px; font-weight: 500; }
details.assump[open] summary { margin-bottom: 14px; }

/* Result tiles */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(186px, 1fr));
  gap: 14px;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  display: grid; gap: 4px; align-content: start;
  position: relative;
}
.tile.best { border-color: var(--accent); }
.tile .name { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; font-weight: 600; }
.tile .kind { color: var(--ink-3); font-size: 12.5px; font-weight: 400; white-space: nowrap; }
.tile .big { font-size: 26px; font-weight: 600; letter-spacing: -0.01em; margin-top: 6px; }
.tile .sub { color: var(--ink-2); font-size: 13px; }
.tile .sub strong { color: var(--ink); font-weight: 500; }
.pill {
  justify-self: start; margin-bottom: 6px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  background: var(--accent); color: var(--accent-ink);
  padding: 3px 8px; border-radius: 999px;
}
.warn {
  background: var(--warn-bg); color: var(--warn-ink);
  border-radius: 6px; padding: 8px 10px; font-size: 13px; margin-top: 8px;
}

/* Chart */
.chart-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px 16px; margin-bottom: 14px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.rows { display: grid; gap: 18px; }
.row { display: grid; grid-template-columns: 150px 1fr; gap: 12px; align-items: center; }
.row .lab { font-size: 14px; font-weight: 500; }
.row .lab small { display: block; color: var(--ink-3); font-weight: 400; font-size: 12px; }
.track { position: relative; height: 24px; }
.bar { position: absolute; inset: 0 auto 0 0; display: flex; height: 24px; }
.seg { height: 100%; position: relative; cursor: default; }
.seg + .seg { margin-left: 2px; }
.seg:last-child { border-radius: 0 4px 4px 0; }
.seg:hover { filter: brightness(1.12); }
.seg.c1 { background: var(--s1); }
.seg.c2 { background: var(--s2); }
.seg.c3 { background: var(--s3); }
.seg.c4 { background: var(--s4); }
.seg.c5 { background: var(--s5); }
.tip {
  position: absolute; left: 100%; top: 50%; transform: translateY(-50%);
  margin-left: 10px; white-space: nowrap; font-size: 13.5px; color: var(--ink);
  font-weight: 500;
}
.axis { position: relative; height: 18px; margin-left: 162px; margin-top: 4px; border-top: 1px solid var(--line-soft); }
.axis span { position: absolute; top: 2px; transform: translateX(-50%); font-size: 11.5px; color: var(--ink-3); }
.tooltip {
  position: fixed; pointer-events: none; z-index: 10;
  background: var(--ink); color: var(--bg);
  padding: 6px 10px; border-radius: 6px; font-size: 12.5px; line-height: 1.4;
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
}
.tooltip[hidden] { display: none; }

/* Donuts */
.donuts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 18px 12px; }
.donut { display: grid; justify-items: center; gap: 8px; text-align: center; }
.donut svg { width: 150px; height: 150px; max-width: 100%; overflow: visible; }
.donut .slice { fill: none; stroke-width: 20; cursor: default; }
.donut .slice:hover { stroke-width: 24; }
.donut .slice.k-invested { stroke: var(--s1); }
.donut .slice.k-gain { stroke: var(--s3); }
.donut .slice.k-fees { stroke: var(--s2); }
.donut .ring { fill: none; stroke: var(--surface-2); stroke-width: 20; }
.donut .ctr { font-family: "JetBrains Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; font-size: 15px; font-weight: 600; fill: var(--ink); }
.donut .ctr-sub { font-size: 10.5px; fill: var(--ink-3); }
.donut .dname { font-weight: 600; font-size: 14px; line-height: 1.25; }
.donut .dname small { display: block; color: var(--ink-3); font-weight: 400; font-size: 12px; }
.donut .dvals { display: grid; gap: 2px; font-size: 12.5px; color: var(--ink-2); }
.donut .dvals span { display: flex; justify-content: space-between; gap: 10px; }
.donut .dvals b { font-weight: 500; color: var(--ink); }
@media (prefers-reduced-motion: no-preference) { .donut .slice { transition: stroke-width 120ms ease; } }

/* Table */
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
th { font-weight: 600; color: var(--ink-2); font-size: 12.5px; }
th:first-child, td:first-child { text-align: left; }
tbody tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 600; border-top: 1px solid var(--line); }
.grp { color: var(--ink-3); font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }

/* Grille */
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.card h3 { font-size: 15px; margin-bottom: 8px; }
.card ul { margin: 0; padding-left: 18px; color: var(--ink-2); font-size: 13.5px; display: grid; gap: 4px; }
.sources { color: var(--ink-3); font-size: 12.5px; line-height: 1.7; }
.sources a { color: var(--ink-2); }

@media (max-width: 760px) {
  .tiles, .grid3 { grid-template-columns: 1fr; }
  .tile .big { font-size: 26px; }
  .row { grid-template-columns: 1fr; gap: 6px; }
  .axis { margin-left: 0; }
  .tip { font-size: 12.5px; }
}
@media (prefers-reduced-motion: no-preference) {
  .seg { transition: width 260ms ease; }
}

/* Navigation entre les deux simulateurs */
.nav { display: inline-flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); margin-bottom: 0; justify-self: start; }
.nav a { text-decoration: none; color: var(--ink-2); font-weight: 500; font-size: 14px; padding: 8px 16px; border-radius: 5px; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }
.nav a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Graphique temporel */
.linechart { width: 100%; height: auto; display: block; overflow: visible; }
.linechart .grid { stroke: var(--line-soft); stroke-width: 1; }
.linechart .axis-t { font-size: 11px; fill: var(--ink-3); font-family: "JetBrains Mono", ui-monospace, monospace; }
.linechart .ln { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.linechart .ln.ref { stroke: var(--ink-3); stroke-dasharray: 4 4; stroke-width: 1.5; }
.linechart .dot { stroke: var(--surface); stroke-width: 2; }
.linechart .xhair { stroke: var(--ink-3); stroke-width: 1; }
.linechart .hit { fill: transparent; }
.linechart .ln.obj { stroke-width: 1.5; stroke-dasharray: 6 3; }
.linechart .ln.obj.ok { stroke: var(--s3); }
.linechart .ln.obj.ko { stroke: var(--s8); }
.linechart .vmark { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 2 3; }
.linechart .obj-label { font-size: 11px; font-weight: 600; }
.linechart .obj-label.ok { fill: var(--s3); }
.linechart .obj-label.ko { fill: var(--s8); }
.legend .lk.obj { border-top-style: dashed; }
.legend .lk.obj.ok { border-color: var(--s3); }
.legend .lk.obj.ko { border-color: var(--s8); }
.obj-status { margin-top: 12px; font-size: 13.5px; font-weight: 600; }
.obj-status.ok { color: var(--s3); }
.obj-status.ko { color: var(--s8); }
.obj-list { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--ink-2); margin-top: 6px; }
.obj-list .dotk, .tooltip .dotk { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
td.note { white-space: normal; min-width: 240px; text-align: left; color: var(--ink-3); font-size: 12px; line-height: 1.4; }
th.grp[colspan] { text-align: center; border-left: 1px solid var(--line); }
#wdTable th:not(.grp) { font-size: 12px; }
#wdTable td:first-child { white-space: normal; min-width: 130px; }
.legend .lk { width: 14px; height: 0; border-top: 2px solid; display: inline-block; }
.legend .lk.ref { border-top-style: dashed; border-color: var(--ink-3); }
.tooltip table { border-collapse: collapse; margin-top: 2px; }
.tooltip td { padding: 1px 6px 1px 0; border: 0; color: inherit; font-size: 12px; white-space: nowrap; }
.tooltip td.num { text-align: right; }
.tooltip .dotk { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

/* Établissement personnalisé */
.custom-list { display: grid; gap: 8px; margin-top: 14px; }
.custom-item { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 13.5px; }
.custom-item b { font-weight: 600; }
.custom-item .meta { color: var(--ink-3); font-size: 12.5px; flex: 1; }
.btn { font: inherit; font-size: 13.5px; font-weight: 500; padding: 8px 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--ink-2); height: 40px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.tile.custom { border-style: dashed; }
.tile.custom.best { border-style: solid; }

/* Index */
html:has(body.index-page), body.index-page { height: 100%; }
.index { min-height: 100%; display: grid; place-items: center; padding-block: 48px; padding-inline: 20px; }
.index-card { max-width: 640px; width: 100%; display: grid; gap: 20px; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.choice { display: grid; gap: 8px; padding: 22px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); text-decoration: none; }
.choice:hover { border-color: var(--accent); }
.choice:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.choice .ct { font-size: 20px; font-weight: 700; }
.choice .cd { color: var(--ink-2); font-size: 14px; }
.choice .cp { color: var(--ink-3); font-size: 12.5px; }
