/* Nos finances — même famille que les autres apps (Mon Aquarium, Vie à Québec…) : bleu nuit, or, un point blanc.
   Grandes cibles (≥ 44 px), chiffres alignés, thème clair dans les Réglages. */
:root {
  --bg: #0b1526; --frame: #070e1a; --card: #11203a; --card-2: #152843; --line: #213254;
  --ink: #eef1f7; --ink-soft: #a9b9d0; --faint: #7d90ad;
  --accent: #c9a44c; --accent-2: #e0c27a; --accent-bg: #2a2313; --accent-line: #4a3d1c; --on-accent: #171310;
  --blue: #5b9bf5; --ok: #63c991; --ok-bg: #17331f; --warn: #e8b54d; --warn-bg: #3a2f17; --danger: #ef7b6f; --danger-bg: #3a1c1d;
  --dot: #eef1f7;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
  --disp: 'Newsreader', Georgia, 'Times New Roman', serif;
  --body: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}
/* Thème clair (Réglages › Affichage) : mêmes rôles, contraste AA sur blanc. */
:root[data-theme="light"] {
  --bg: #f6f3ec; --frame: #e4dfd2; --card: #ffffff; --card-2: #f1ece0; --line: #ddd6c6;
  --ink: #0b1526; --ink-soft: #3a4860; --faint: #56657e;
  --accent: #7d5f17; --accent-2: #6a5013; --accent-bg: #f7eed7; --accent-line: #d8bf88; --on-accent: #ffffff;
  --blue: #1d5bb8; --ok: #1b7243; --ok-bg: #e4f4ea; --warn: #7f5300; --warn-bg: #fff4d9; --danger: #b3261e; --danger-bg: #fde9e7;
  --dot: #0b1526;
  color-scheme: light;
}
* { box-sizing: border-box; min-width: 0; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--frame); }
body { color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.5; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); }

/* #app ancré aux vrais bords ; cadre « téléphone » sur grand écran. */
#app { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg); overflow: hidden; }
@media (min-width: 641px) {
  #app { inset: 24px auto 24px 50%; transform: translateX(-50%); width: 430px; border: 1px solid var(--line); border-radius: 34px; box-shadow: 0 30px 80px rgba(0,0,0,.45); }
}
.boot { margin: auto; color: var(--ink-soft); }

/* Barre du haut */
.topbar { flex: none; display: flex; align-items: center; gap: 10px; padding: calc(var(--safe-t) + 10px) calc(var(--safe-r) + 16px) 10px calc(var(--safe-l) + 16px); border-bottom: 1px solid var(--line); }
.topbar img { width: 30px; height: 30px; border-radius: 8px; flex: none; }
.topbar .titre { flex: 1; font-family: var(--disp); font-size: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pastille-sync { flex: none; display: flex; align-items: center; gap: 6px; background: none; border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: 12px; color: var(--ink-soft); cursor: pointer; min-height: 32px; }
.pastille-sync i { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-soft); }
.pastille-sync[data-etat="ok"] i { background: var(--ok); }
.pastille-sync[data-etat="cache"] i, .pastille-sync[data-etat="hors-ligne"] i, .pastille-sync[data-etat="demo"] i { background: var(--warn); }
.pastille-sync[data-etat="erreur"] i { background: var(--danger); }
.pastille-sync[data-etat="synchro"] i { background: var(--blue); animation: pulse 1s infinite alternate; }
@keyframes pulse { from { opacity: .35; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .pastille-sync[data-etat="synchro"] i { animation: none; } }

/* Contenu */
main { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain; padding: 18px calc(var(--safe-r) + 16px) 32px calc(var(--safe-l) + 16px); display: flex; flex-direction: column; gap: 18px; }
h1, h2, h3 { font-family: var(--disp); font-weight: 500; margin: 0; text-wrap: balance; }
h1 { font-size: 28px; line-height: 1.15; }
h2 { font-size: 20px; line-height: 1.25; }
p { margin: 0; }
.soft { color: var(--ink-soft); }
.petit { font-size: 13.5px; }
.sur-titre { font-size: 13px; color: var(--accent); font-weight: 600; }
.pile { display: flex; flex-direction: column; gap: 10px; }
.rangee { display: flex; align-items: center; gap: 10px; }
.rangee > .grandit { flex: 1; }
.chiffre { font-variant-numeric: tabular-nums; white-space: nowrap; }
.carte { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
a.carte { text-decoration: none; color: inherit; }
a.carte:active { background: var(--card-2); }
.bandeau { border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; border: 1px solid var(--accent-line); background: var(--accent-bg); }
.bandeau[data-genre="erreur"] { border-color: var(--danger); background: var(--danger-bg); }
.bandeau[data-genre="attention"] { border-color: var(--warn); background: var(--warn-bg); }

/* La valeur nette */
.heros { display: flex; flex-direction: column; gap: 4px; }
.grand-chiffre { font-family: var(--disp); font-size: clamp(38px, 11vw, 48px); line-height: 1.05; font-variant-numeric: tabular-nums; white-space: nowrap; }
.grand-chiffre.moyen { font-size: 34px; }
.variation { font-size: 14px; color: var(--ink-soft); }
.variation[data-sens="+"] b { color: var(--ok); }
.variation[data-sens="-"] b { color: var(--danger); }
.deux { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 10px; }
.tuile { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: inherit; }
a.tuile:active { background: var(--card-2); }
.tuile .etiquette { font-size: 13px; color: var(--ink-soft); }
.tuile .valeur { font-family: var(--disp); font-size: 22px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* La courbe */
.courbe { display: block; width: 100%; height: 130px; overflow: visible; }
.courbe .ligne { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.courbe .aire { fill: url(#degrade-courbe); }
.courbe .zero { stroke: var(--line); stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
.courbe-legende { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--ink-soft); }

/* Listes */
.groupe { display: flex; flex-direction: column; gap: 8px; }
.groupe-titre { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 0 4px; }
.groupe-titre h2 { font-size: 18px; }
.liste { background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.liste > a, .liste > button, .liste > div { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 11px 16px; border: 0; background: none; text-align: left; text-decoration: none; color: var(--ink); cursor: pointer; }
.liste > * + * { border-top: 1px solid var(--line); }
.liste > a:active, .liste > button:active { background: var(--card-2); }
.liste .grandit { flex: 1; }
.liste .grandit small { display: block; color: var(--ink-soft); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.liste .montant { font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.liste .montant small { display: block; font-size: 12px; color: var(--ink-soft); }
.chevron { color: var(--faint); flex: none; }
.puce { font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-soft); white-space: nowrap; flex: none; }
.puce.or { color: var(--accent); border-color: var(--accent-line); }
.vide { text-align: center; padding: 24px 12px; color: var(--ink-soft); display: flex; flex-direction: column; gap: 12px; align-items: center; }

/* Fiche */
.infos { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; align-items: baseline; }
.infos dt { color: var(--ink-soft); font-size: 14px; }
.infos dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.infos dd small { display: block; color: var(--ink-soft); font-size: 12.5px; }
.barre-parts { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--card-2); }
.barre-parts span:first-child { background: var(--accent); }
.barre-parts span:last-child { background: var(--blue); }
.legende-parts { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.legende-parts i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.notes { white-space: pre-wrap; }

/* Boutons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--card-2); color: var(--ink); font-weight: 500; cursor: pointer; text-decoration: none; }
.btn.primaire { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.danger { color: var(--danger); }
.btn.large { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.btn:focus-visible, .liste > a:focus-visible, .liste > button:focus-visible, .onglets a:focus-visible, a.tuile:focus-visible, a.carte:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.actions .btn { flex: 1 1 auto; }

/* Formulaires : saisie au pouce, champs larges */
form.fiche { display: flex; flex-direction: column; gap: 14px; }
fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
legend { font-family: var(--disp); font-size: 18px; padding: 6px 0 2px; }
.champ { display: flex; flex-direction: column; gap: 6px; }
.champ label, .champ .label { font-size: 13.5px; color: var(--ink-soft); }
.saisie { display: flex; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.saisie:focus-within { border-color: var(--accent); }
.saisie input, .saisie select, .saisie textarea { flex: 1; width: 100%; background: transparent; border: 0; padding: 12px 14px; font-size: 16px; outline: none; min-height: 46px; }
.saisie textarea { min-height: 90px; resize: vertical; }
.saisie select { appearance: none; -webkit-appearance: none; background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a9b9d0' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E") no-repeat right 12px center / 16px; padding-right: 36px; }
.saisie select option { background: var(--card); color: var(--ink); }
.saisie .unite { padding: 0 14px 0 2px; color: var(--ink-soft); }
.aide { font-size: 12.5px; color: var(--ink-soft); }
.erreur-champ { font-size: 13px; color: var(--danger); }
.deux-champs { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 10px; }
.choix { display: flex; gap: 6px; flex-wrap: wrap; }
.choix button, .choix label { flex: 1 1 auto; min-height: 40px; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink-soft); font-size: 14px; cursor: pointer; text-align: center; }
.choix input { position: absolute; opacity: 0; pointer-events: none; }
.choix label:has(input:checked) { color: var(--accent); background: var(--accent-bg); border-color: var(--accent-line); }
.choix label:has(input:focus-visible) { outline: 2px solid var(--accent); }

/* Barre d'onglets */
.onglets { flex: none; display: flex; border-top: 1px solid var(--line); padding: 6px calc(var(--safe-r) + 4px) calc(var(--safe-b) + 6px) calc(var(--safe-l) + 4px); background: var(--bg); }
.onglets a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; border-radius: 12px; color: var(--ink-soft); text-decoration: none; font-size: 11px; white-space: nowrap; }
.onglets a svg { width: 24px; height: 24px; }
.onglets a[aria-current="page"] { color: var(--accent); background: var(--accent-bg); }

/* Écran de connexion */
.accueil-connexion { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 18px; text-align: center; padding: 24px; max-width: 360px; }
.accueil-connexion img { width: 120px; height: 120px; border-radius: 27px; box-shadow: 0 12px 30px rgba(0,0,0,.4); }

/* Message flottant */
.toast { position: fixed; left: 50%; transform: translateX(-50%); width: min(398px, calc(100% - 32px)); bottom: calc(var(--safe-b) + 88px); background: var(--card-2); color: var(--ink); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; box-shadow: 0 10px 30px rgba(0,0,0,.35); z-index: 10; }
@media (min-width: 641px) { .toast { bottom: 120px; } }

/* La courbe : dégradé doré sous la ligne */
.courbe .haut { stop-color: var(--accent); stop-opacity: .28; }
.courbe .bas { stop-color: var(--accent); stop-opacity: 0; }

[hidden] { display: none !important; }
