/* Loan Cost Simulator — thème clair/sombre via variables, design sobre type iOS. */
:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: #e5e5ea;
  --accent: #0a84ff;
  --accent-soft: rgba(10, 132, 255, 0.10);
  --fill: #f2f2f6;
  --good: #1faa55;
  --bad: #e0342c;
  --col-a: #0a84ff;
  --col-b: #ff9500;
  --col-capital: #0a84ff;
  --col-interest: #ff9500;
  --col-insurance: #30b0c7;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
[data-theme="dark"] {
  --bg: #000000;
  --card: #1c1c1e;
  --text: #f5f5f7;
  --muted: #98989d;
  --line: #38383a;
  --accent: #0a84ff;
  --accent-soft: rgba(10, 132, 255, 0.18);
  --fill: #2c2c2e;
  --shadow: none;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 40px;
}
main { max-width: 660px; margin: 0 auto; padding: 0 14px; }

/* --- En-tête --- */
.site-head {
  max-width: 660px; margin: 0 auto; padding: 18px 14px 8px;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
}
.brand { display: flex; gap: 10px; align-items: center; }
.brand-icon { font-size: 34px; }
.brand h1 { font-size: 22px; letter-spacing: -0.02em; }
.tagline { color: var(--muted); font-size: 13px; }
.head-actions { display: flex; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 600; cursor: pointer;
}

/* --- Bannière sauvegarde --- */
.banner {
  max-width: 632px; margin: 8px auto 0; padding: 10px 14px;
  background: var(--accent-soft); border-radius: 12px; font-size: 13px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}

/* --- Onglets --- */
.tabs {
  max-width: 660px; margin: 12px auto 4px; padding: 0 14px;
  display: flex; gap: 6px; overflow-x: auto;
}
.tab {
  border: none; background: var(--card); color: var(--text);
  padding: 9px 16px; border-radius: 999px; font-size: 15px; font-weight: 600;
  cursor: pointer; white-space: nowrap; box-shadow: var(--shadow);
}
.tab.active { background: var(--accent); color: #fff; }
.pane { display: none; }
.pane.active { display: block; }

/* --- Cartes --- */
.card {
  background: var(--card); border-radius: 16px; padding: 16px;
  margin: 12px 0; box-shadow: var(--shadow);
}
.card.accent { background: linear-gradient(135deg, var(--accent-soft), var(--card) 70%); }
.card h2 { font-size: 15px; font-weight: 700; margin-bottom: 10px; }
.card h3 { font-size: 14px; font-weight: 700; margin: 14px 0 8px; }

/* --- Champs --- */
.field {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 7px 0; border-bottom: 1px solid var(--line);
}
.card .field:last-of-type { border-bottom: none; }
.field label { font-size: 15px; }
.input-wrap { display: flex; align-items: center; gap: 6px; }
input[type="number"], select {
  font: inherit; color: var(--text); background: var(--fill);
  border: 1px solid var(--line); border-radius: 9px; padding: 6px 9px;
  max-width: 8.5em; text-align: right;
}
select { text-align: left; max-width: none; }
input:focus, select:focus { outline: 2px solid var(--accent); border-color: transparent; }
input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); }
.unit { color: var(--muted); font-size: 13px; white-space: nowrap; }
.footnote { color: var(--muted); font-size: 12px; margin: 6px 0 2px; }
.footnote.bold { font-weight: 700; }
.muted { color: var(--muted); }

/* --- Résultats --- */
.rows .row {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 15px;
}
.rows .row:last-child { border-bottom: none; }
.stat-label { color: var(--muted); font-size: 14px; }
.headline-grid { display: flex; gap: 24px; flex-wrap: wrap; }
.headline-grid > div { flex: 1 1 220px; }
.big-number {
  font-size: 42px; font-weight: 800; color: var(--accent);
  font-variant-numeric: tabular-nums; letter-spacing: -0.02em; line-height: 1.15;
}
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.tile { background: var(--fill); border-radius: 12px; padding: 12px; }
.tile.emphasized { background: var(--accent-soft); }
.tile .t-title { color: var(--muted); font-size: 12px; }
.tile .t-value { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile.emphasized .t-value { color: var(--accent); }
.tile .t-sub { color: var(--muted); font-size: 11px; }

/* --- Graphiques --- */
.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 14px; margin-top: 8px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; }

/* --- Tableaux --- */
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-size: 11px; font-weight: 600; }
th:first-child, td:first-child { text-align: left; }
tbody tr:nth-child(even) td { background: var(--fill); }
/* Tableau d'amortissement : hauteur bornée (vue « Par mois »), en-tête collant */
#amort-table { max-height: 520px; overflow-y: auto; }
#amort-table th { position: sticky; top: 0; background: var(--card); z-index: 1; }

/* --- Analyse : double colonne --- */
.dual { margin: 8px 0; }
.dual .d-label { font-size: 14px; margin-bottom: 5px; }
.dual .d-boxes { display: flex; gap: 10px; }
.d-box { flex: 1; border-radius: 9px; padding: 8px; background: var(--fill); }
.d-box.tinted { background: var(--accent-soft); }
.d-box .d-cap { color: var(--muted); font-size: 11px; }
.d-box .d-val { font-size: 15px; font-variant-numeric: tabular-nums; }
.d-box .d-val.bold { font-weight: 700; }
.bullet { display: flex; gap: 10px; align-items: baseline; padding: 4px 0; }
.bullet .b-icon { flex: 0 0 22px; text-align: center; }
.bullet p { color: var(--muted); font-size: 13px; }

/* --- Comparer --- */
.col-a { color: var(--col-a); font-weight: 700; }
.col-b { color: var(--col-b); font-weight: 700; }
.duel-head, .duel-row-vals { display: flex; gap: 8px; }
.duel-head > span { flex: 1; font-size: 12px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.duel-head { margin: 10px 0 4px; }
.duel-row { padding: 5px 0; border-bottom: 1px solid var(--line); }
.duel-row .m-label { color: var(--muted); font-size: 12px; }
.duel-row-vals > div { flex: 1; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.duel-row-vals .delta { text-align: right; }
.duel-row-vals .sub { color: var(--muted); font-size: 11px; }
.delta.good { color: var(--good); }
.delta.bad { color: var(--bad); }
.delta .d-pct { font-size: 11px; display: block; }
.scenario-card { border-bottom: 1px solid var(--line); padding: 10px 0; }
.scenario-card:last-child { border-bottom: none; }
.scenario-card .s-head { display: flex; justify-content: space-between; align-items: center; }
.scenario-card h4 { font-size: 15px; }
.scenario-card .s-row { display: flex; justify-content: space-between; font-size: 12.5px; padding: 2px 0; }
.scenario-card .s-row span:first-child { color: var(--muted); }

/* --- Boutons --- */
.btn {
  display: inline-block; border: 1px solid var(--line); background: var(--fill);
  color: var(--text); font: inherit; font-size: 14px; font-weight: 600;
  border-radius: 10px; padding: 8px 14px; cursor: pointer; text-decoration: none;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.danger { color: var(--bad); }
.linklike {
  border: none; background: none; color: var(--accent); font: inherit;
  font-size: inherit; cursor: pointer; padding: 0; text-decoration: underline;
}
.about-p { font-size: 14px; margin: 6px 0; }
.reading-item { display: block; padding: 8px 0; border-bottom: 1px solid var(--line); text-decoration: none; }
.reading-item:last-of-type { border-bottom: none; }
.reading-item .r-title { color: var(--accent); font-size: 14px; font-weight: 600; }
.reading-item .r-sub { color: var(--muted); font-size: 12px; }

/* --- Lectures recommandées (visible sur tous les onglets) --- */
.extras { max-width: 660px; margin: 0 auto; padding: 0 14px; }

/* --- Pied de page --- */
footer { max-width: 660px; margin: 24px auto 0; padding: 0 14px; text-align: center; }
.donate {
  display: inline-block; background: var(--accent-soft); color: var(--accent);
  font-weight: 700; font-size: 14px; text-decoration: none;
  border-radius: 999px; padding: 10px 18px; margin-bottom: 12px;
}
.fineprint { color: var(--muted); font-size: 11.5px; margin: 6px 0; }

/* --- Modale (tuto) --- */
.modal {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal-box {
  background: var(--card); border-radius: 18px; padding: 22px;
  max-width: 420px; width: 100%; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}
.modal-box h3 { font-size: 18px; margin-bottom: 8px; }
.modal-box p { color: var(--muted); font-size: 14px; }
.tuto-emoji { font-size: 40px; margin-bottom: 6px; }
.modal-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; }
#tuto-dots { color: var(--muted); letter-spacing: 4px; font-size: 11px; }

/* --- Impression : seul le rapport sort --- */
#print-report { display: none; }
@media print {
  body > *:not(#print-report) { display: none !important; }
  #print-report { display: block; font-size: 12px; color: #000; }
  #print-report h1 { font-size: 18px; margin-bottom: 2px; }
  #print-report h2 { font-size: 14px; margin: 14px 0 6px; }
  #print-report .p-muted { color: #555; font-size: 10.5px; }
  #print-report table { width: 100%; border-collapse: collapse; font-size: 10.5px; }
  #print-report th, #print-report td { border-bottom: 1px solid #ccc; padding: 3px 6px; text-align: right; }
  #print-report th:first-child, #print-report td:first-child { text-align: left; }
  body { background: #fff; padding: 0; }
}

@media (max-width: 480px) {
  .brand h1 { font-size: 19px; }
  .big-number { font-size: 34px; }
  .tiles { grid-template-columns: 1fr 1fr; }
}

/* --- Desktop : contenu élargi, deux colonnes par onglet --- */
@media (min-width: 980px) {
  .site-head, .tabs, main, .extras, footer { max-width: 1160px; }
  .banner { max-width: 1132px; }
  .pane.active { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; }
  .pane .col { flex: 1 1 0; min-width: 0; }
  .pane > .card.full { flex: 1 1 100%; margin: 0; }
  #out-reading { display: grid; grid-template-columns: 1fr 1fr; column-gap: 28px; }
}
