/* ==== Styles de Cap : thème clair / sombre, mise en page, composants. ==== */

:root {
  color-scheme: light;
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #f6f6f3;
  --border: rgba(11, 11, 11, 0.08);
  --border-fort: rgba(11, 11, 11, 0.14);
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --grid: #ecebe6;
  --accent: #2a78d6;
  --accent-doux: #e8f1fc;
  --positif: #006300;
  --negatif: #d03b3b;
  --alerte-bg: #fdf3e7;
  --alerte-texte: #8a4b0b;
  --ok-bg: #eaf6ea;
  --ombre: 0 1px 2px rgba(11, 11, 11, 0.04), 0 4px 16px rgba(11, 11, 11, 0.04);
  /* Couleurs des séries (graphiques), ordre fixe */
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --s4: #eda100;
  --s5: #e87ba4;
  --s6: #008300;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232322;
    --border: rgba(255, 255, 255, 0.08);
    --border-fort: rgba(255, 255, 255, 0.16);
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --accent: #3987e5;
    --accent-doux: #172a42;
    --positif: #0ca30c;
    --negatif: #e66767;
    --alerte-bg: #33240f;
    --alerte-texte: #f3c47a;
    --ok-bg: #12291a;
    --ombre: 0 1px 2px rgba(0, 0, 0, 0.4);
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --s4: #c98500;
    --s5: #d55181;
    --s6: #0ca30c;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232322;
  --border: rgba(255, 255, 255, 0.08);
  --border-fort: rgba(255, 255, 255, 0.16);
  --text: #f0efec;
  --text-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --accent: #3987e5;
  --accent-doux: #172a42;
  --positif: #0ca30c;
  --negatif: #e66767;
  --alerte-bg: #33240f;
  --alerte-texte: #f3c47a;
  --ok-bg: #12291a;
  --ombre: 0 1px 2px rgba(0, 0, 0, 0.4);
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --s4: #c98500;
  --s5: #d55181;
  --s6: #0ca30c;
}

[x-cloak] { display: none !important; }
* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 24px; letter-spacing: -0.02em; }
h2 { font-size: 15px; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
svg { fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ---- Mise en page ---- */
.layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 24px;
  padding: 20px 14px;
  border-right: 1px solid var(--border);
  background: var(--surface);
}
.sidebar-haut { display: flex; align-items: center; justify-content: space-between; gap: 4px; }

/* Menu réduit : icônes seules, nom de la page au survol */
.layout { transition: grid-template-columns 0.2s ease; }
.layout.menu-reduit { grid-template-columns: 68px minmax(0, 1fr); }
.menu-reduit .sidebar { padding-left: 10px; padding-right: 10px; }
.menu-reduit .sidebar-haut { flex-direction: column; gap: 12px; }
.menu-reduit .marque span:last-child,
.menu-reduit .nav-item span,
.menu-reduit .badge-bareme span:last-child { display: none; }
.menu-reduit .nav-item { justify-content: center; padding: 10px 0; }
.menu-reduit .badge-bareme { padding: 8px; margin: 0 auto; }
.menu-reduit .actions-pied { flex-direction: column; align-items: center; padding: 0; }

.marque { display: flex; align-items: center; gap: 10px; padding: 4px 8px; font-weight: 600; font-size: 16px; letter-spacing: -0.01em; }
.marque-logo { width: 30px; height: 30px; flex: none; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: 8px; background: none;
  color: var(--text-2); text-align: left; cursor: pointer; white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item .nav-court { display: none; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.actif { background: var(--accent-doux); color: var(--accent); font-weight: 500; }

.sidebar-pied { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.actions-pied { display: flex; gap: 4px; padding: 0 4px; }

.badge-bareme {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 999px; font-size: 12px; font-weight: 500;
  text-decoration: none; color: var(--text-2); background: var(--surface-2); width: fit-content;
}
.badge-bareme .point { width: 7px; height: 7px; border-radius: 50%; background: var(--positif); }
.badge-bareme.alerte { background: var(--alerte-bg); color: var(--alerte-texte); }
.badge-bareme.alerte .point { background: #fab219; }

.contenu { padding: 32px 40px 64px; max-width: 1240px; width: 100%; }
.contenu > section { display: flex; flex-direction: column; gap: 16px; animation: apparition 0.25s ease; }
@keyframes apparition { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* En-tête commun et onglets de « Ma situation » */
.entete-groupe { margin-bottom: 16px; }
.onglets { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.onglets button { border: 0; background: none; padding: 10px 14px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--text-2); font-weight: 500; white-space: nowrap; cursor: pointer; }
.onglets button:hover { color: var(--text); }
.onglets button.actif { color: var(--text); border-bottom-color: var(--accent); }
.entete-onglet { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.entete-onglet .sous-titre { margin: 0; }

.entete-page { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.sous-titre { margin: 4px 0 0; color: var(--text-2); }
.sous-titre::first-letter { text-transform: uppercase; }

.grille-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.pile { display: flex; flex-direction: column; gap: 16px; }
/* Tous les blocs de la grille à la hauteur du plus grand */
.grille-2.egale { align-items: stretch; grid-auto-rows: 1fr; }
.grille-apercu { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; }
.grille-apercu .large { grid-column: 1 / -1; }
.tuiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

/* ---- Cartes ---- */
.carte {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 22px; box-shadow: var(--ombre);
  display: flex; flex-direction: column; gap: 14px; min-width: 0;
}
.carte-entete { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.collante { position: sticky; top: 24px; }
.carte.vide { align-items: flex-start; padding: 40px; }
.carte.vide p { margin: 0; color: var(--text-2); max-width: 520px; }

.libelle { color: var(--text-2); font-size: 13px; font-weight: 500; }
.hero-valeur { font-size: 52px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.05; }
.hero-valeur.moyen { font-size: 34px; }
.hero-detail { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--text-2); }
.sep { width: 3px; height: 3px; border-radius: 50%; background: var(--muted); display: inline-block; vertical-align: middle; margin: 0 4px; }
.complements { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); color: var(--text-2); font-size: 13.5px; }
.complements > div { display: flex; gap: 8px; align-items: baseline; }
.complements .plus-vert { color: var(--positif); font-weight: 600; min-width: 64px; font-variant-numeric: tabular-nums; }
.complements-hors-compte { margin-top: 2px; }
.complements .neutre { color: var(--text); font-weight: 600; min-width: 64px; font-variant-numeric: tabular-nums; }
.complements-total { margin-top: 4px; padding-top: 6px; border-top: 1px solid var(--border); }
.complements-total span:first-child { color: var(--text); font-weight: 600; min-width: 64px; font-variant-numeric: tabular-nums; }
.tuile { justify-content: space-between; gap: 6px; }
.tuile-lignes { display: flex; flex-direction: column; gap: 2px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.tuile-valeur { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }
.tuile-detail { color: var(--muted); font-size: 13px; }
.positif { color: var(--positif); font-weight: 500; }
.aide { color: var(--muted); font-size: 12.5px; margin: 0; }
.aide.bloc { display: block; }

/* ---- Répartition du salaire (barre segmentée haute) ---- */
.repartition-titre { margin-top: 10px; font-size: 13px; font-weight: 500; color: var(--text-2); }
.barre-segmentee { display: flex; gap: 2px; height: 28px; }
/* Chaque bloc affiche son % : un petit bloc s'élargit juste assez pour que le texte tienne */
.segment {
  display: flex; align-items: center; justify-content: center; padding: 0 6px; min-width: fit-content;
  border-radius: 4px; color: #fff; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.segment.encre-sombre { color: #0b0b0b; }
.barre-fine { display: flex; gap: 2px; height: 8px; }
.barre-fine > div { border-radius: 999px; min-width: 4px; }

.legende { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.legende-item { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; }
.legende-item b { color: var(--text); font-weight: 600; }
.pastille { width: 9px; height: 9px; border-radius: 3px; flex: none; }

.alerte-ligne, .info.alerte { background: var(--alerte-bg); color: var(--alerte-texte); }
.alerte-ligne { padding: 10px 12px; border-radius: 10px; font-size: 13px; }

.graph { position: relative; height: 260px; }
.graph.haut { height: 340px; }

/* ---- Formulaires ---- */
.champ { display: flex; flex-direction: column; gap: 6px; }
.champ > span { font-size: 13px; font-weight: 500; color: var(--text-2); }
.champ small { font-weight: 400; color: var(--muted); margin-left: 4px; }

input[type="text"], input[type="password"], input[type="number"], input[type="month"], input[type="date"], select {
  width: 100%; height: 38px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--border-fort); border-radius: 10px;
  outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-doux); }
input.vide { color: var(--muted); }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; font-variant-numeric: tabular-nums; }
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
select { appearance: none; cursor: pointer; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23898781' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; }

/* Champ avec unité : la bordure est sur le conteneur, l'unité prend juste la place dont elle a besoin */
.saisie { display: flex; align-items: center; height: 38px; padding-right: 12px; background: var(--surface); border: 1px solid var(--border-fort); border-radius: 10px; transition: border-color 0.15s, box-shadow 0.15s; }
.saisie:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-doux); }
.saisie input, .saisie input:focus { flex: 1; min-width: 0; height: 36px; padding-right: 6px; border: 0; background: transparent; box-shadow: none; }
.saisie em { flex: none; font-style: normal; color: var(--muted); font-size: 12.5px; pointer-events: none; white-space: nowrap; }

.segmente { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); width: fit-content; max-width: 100%; flex-wrap: wrap; }
.segmente button { border: 0; background: none; padding: 6px 12px; border-radius: 7px; color: var(--text-2); cursor: pointer; font-weight: 500; transition: background 0.15s; }
.segmente button.actif { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }
.segmente.petit button { padding: 4px 10px; font-size: 12.5px; }

.compteur { display: inline-flex; align-items: center; gap: 14px; }
.compteur button { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--border-fort); background: var(--surface); cursor: pointer; font-size: 17px; }
.compteur b { min-width: 16px; text-align: center; font-size: 16px; }

.bouton { height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border-fort); background: var(--surface); cursor: pointer; font-weight: 500; white-space: nowrap; }
.bouton:hover { background: var(--surface-2); }
.bouton.principal { background: var(--text); color: var(--bg); border-color: transparent; }
.bouton.principal:hover { opacity: 0.88; }
.bouton-icone { display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 8px; background: none; color: var(--muted); cursor: pointer; flex: none; }
.bouton-icone svg { width: 17px; height: 17px; }
.bouton-icone:hover { background: var(--surface-2); color: var(--text); }
.bouton-icone.supprimer:hover { color: var(--negatif); }
.lien { align-self: flex-start; margin-top: -6px; padding: 0; border: 0; background: none; color: var(--accent); cursor: pointer; font-size: 13px; font-weight: 500; }

.info { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); color: var(--text-2); font-size: 13px; }
.info.ok { background: var(--ok-bg); }

/* ---- Listes et cascade ---- */
.cascade { margin: 0; display: flex; flex-direction: column; }
.cascade > div { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; font-variant-numeric: tabular-nums; }
.cascade dt { color: var(--text-2); }
.cascade dd { margin: 0; white-space: nowrap; }
.cascade .moins dd { color: var(--text-2); }
.cascade .plus dd { color: var(--positif); }
.cascade .fort dt, .cascade .fort dd { color: var(--text); font-weight: 600; }
.cascade .trait { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 10px; }
.cascade .total { margin: 8px -12px 0; padding: 12px; border-radius: 10px; background: var(--accent-doux); }
.cascade .total dt, .cascade .total dd { color: var(--accent); font-weight: 600; }

.chiffres { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.chiffres > div { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); min-width: 0; }
/* Libellé sur une ligne : les montants restent alignés d'une tuile à l'autre */
.chiffres .libelle { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chiffres b { font-size: 18px; }

/* Impôt tranche par tranche ; la tranche où tu te trouves est mise en avant */
.tranches { display: flex; flex-direction: column; gap: 2px; }
.tranches .libelle { margin-bottom: 4px; }
.tranche { display: grid; grid-template-columns: minmax(0, 1fr) 56px 90px; gap: 8px; padding: 6px 10px; border-radius: 8px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.tranche b { text-align: right; color: var(--text); font-weight: 500; }
.tranche-taux { text-align: right; }
.tranche.tienne { background: var(--accent-doux); color: var(--text); }
.tranche.tienne b { font-weight: 600; }

/* Détail repliable (zakat) */
.detail-calcul summary { cursor: pointer; color: var(--accent); font-size: 13px; font-weight: 500; }
.detail-calcul[open] summary { margin-bottom: 10px; }

.liste { display: flex; flex-direction: column; gap: 8px; }
.ligne-depense, .ligne-don { display: grid; gap: 8px; align-items: center; }
/* Logement : liste plus large que le résumé ; jauge avec un trait au repère d'un tiers des revenus */
.grille-2.large-gauche { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
.ligne-logement { display: grid; grid-template-columns: minmax(0, 1fr) 120px 130px 34px; gap: 8px; align-items: center; }
.jauge-logement { position: relative; height: 10px; border-radius: 999px; background: var(--surface-2); margin: 4px 0 6px; }
.jauge-logement > div { height: 100%; border-radius: 999px; background: var(--positif); }
.jauge-logement > div.depasse { background: var(--negatif); }
.jauge-logement > span { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--text-2); }
/* Projets d'épargne : saisie sur une ligne, résultat en dessous */
.projet { display: flex; flex-direction: column; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.ligne-projet { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) 34px; gap: 8px; align-items: center; }
.ligne-projet > input[type="text"] { grid-column: 1 / 3; } /* nom sur sa ligne, montant et date en dessous */
.ligne-projet > .supprimer { grid-column: 3; grid-row: 1; }
.projet-resultat { display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); color: var(--text-2); font-size: 13px; }
.projet-resultat.ok { background: var(--ok-bg); }
.projet-resultat.alerte { background: var(--alerte-bg); color: var(--alerte-texte); }
/* Répartition 50 / 30 / 20 : jauge avec un trait au repère */
.repartition-ligne { display: flex; flex-direction: column; gap: 6px; }
.repartition-entete { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.jauge-repere { position: relative; height: 10px; border-radius: 999px; background: var(--surface-2); }
.jauge-repere > div { height: 100%; border-radius: 999px; }
.jauge-repere > span { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--text-2); }
.ligne-classement { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 4px 0; border-bottom: 1px solid var(--border); }
.ligne-classement > span:first-child { overflow-wrap: anywhere; }
.ligne-depense { grid-template-columns: minmax(0, 1fr) 150px 110px 120px 34px; }
.ligne-depense .equivalent { grid-column: 1 / -1; margin-top: -4px; text-align: right; padding-right: 42px; }
.ligne-dette { display: grid; grid-template-columns: minmax(0, 1fr) auto 130px 170px 34px; gap: 8px; align-items: center; }
.tuiles.trois { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ligne-exceptionnelle { display: grid; grid-template-columns: minmax(0, 1fr) 140px 170px 34px; gap: 8px; align-items: center; }
.ligne-exceptionnelle.passee, .frise li.passee, .ligne-comparaison.passee { opacity: 0.55; }
.tableau tr.estime td { color: var(--text-2); }
.rappels { display: flex; flex-wrap: wrap; gap: 8px; }
.rappel { border: 1px solid var(--border-fort); background: var(--surface); border-radius: 999px; padding: 6px 14px; font-size: 13px; font-weight: 500; color: var(--text-2); cursor: pointer; }
.rappel.alerte { background: var(--alerte-bg); color: var(--alerte-texte); border-color: transparent; }
.negatif { color: var(--negatif); }
/* Don sur deux lignes : nom en haut, type et montant en dessous */
.ligne-don { grid-template-columns: 92px minmax(0, 1fr) minmax(0, 1fr) 34px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.ligne-don > input[type="text"] { grid-area: 1 / 1 / 2 / 4; }
.ligne-don > .supprimer { grid-area: 1 / 4; }
.ligne-don > select:first-of-type { grid-area: 2 / 1; }
.ligne-don > .saisie { grid-area: 2 / 2; }
.ligne-don > select:last-of-type { grid-area: 2 / 3 / 3 / 5; }
.ligne-depense.auto { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.vide-liste { padding: 12px 0; }

/* Relevés : comparaisons et opérations */
.choix-mois { flex-wrap: wrap; }
.ligne-comparaison { display: grid; grid-template-columns: minmax(0, 1fr) auto 90px; gap: 12px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.ligne-comparaison > span:first-child { overflow-wrap: anywhere; }
.ligne-comparaison > b { text-align: right; }
.ligne-comparaison > .ajuster { grid-column: 1 / -1; justify-self: end; margin: 0; }
.ligne-operation { display: grid; grid-template-columns: 56px minmax(0, 1fr) 90px 200px; gap: 10px; align-items: center; padding: 4px 0; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.ligne-operation > b { text-align: right; }
.operation-libelle { overflow-wrap: anywhere; font-size: 13px; }
.info.ok { background: var(--ok-bg); }

/* Indicateur d'enregistrement en ligne */
.statut-synchro { display: inline-flex; align-items: center; gap: 8px; padding: 0 10px; font-size: 12px; color: var(--muted); }
.statut-synchro .point { width: 7px; height: 7px; border-radius: 50%; background: var(--positif); }
.statut-synchro.envoi .point, .statut-synchro.chargement .point { background: var(--accent); }
.statut-synchro.erreur .point { background: #fab219; }

.categories { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.categorie-ligne { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-2); }
.categorie-ligne b { color: var(--text); }
.jauge { height: 6px; border-radius: 999px; background: var(--accent-doux); margin-top: 4px; }
.jauge > div { height: 100%; border-radius: 999px; background: var(--accent); }

/* ---- Frise des évolutions ---- */
.frise { list-style: none; margin: 0; padding: 0; position: relative; }
.frise::before { content: ""; position: absolute; left: 6px; top: 14px; bottom: 14px; width: 2px; background: var(--grid); }
.frise li { position: relative; padding: 8px 0 8px 28px; }
.frise-point { position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.frise li.actuel .frise-point { background: var(--accent); }
.frise-contenu { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.frise-contenu > div:first-child { display: flex; flex-direction: column; }
.frise-contenu.edition { display: grid; grid-template-columns: 170px minmax(0, 1fr) 160px 170px 84px 34px; }
.frise-montant { font-variant-numeric: tabular-nums; text-align: right; }
.variation { font-size: 13px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.variation.hausse { color: var(--positif); }
.variation.baisse { color: var(--negatif); }

/* ---- Tableaux ---- */
.tableau-defilant { overflow-x: auto; margin: -4px; padding: 4px; }
.tableau { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tableau th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 0 10px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tableau td { padding: 12px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tableau tr:last-child td { border-bottom: 0; }
.tableau .num { text-align: right; }
.tableau.edition td { padding: 6px 4px; }
.tableau.edition td:first-child { min-width: 170px; }
.tableau.edition td:nth-child(2) { min-width: 200px; }
.tableau.edition .saisie { min-width: 120px; }
.tableau.edition .saisie input { text-align: right; }

/* ---- Cours en direct (crypto, or) ---- */
.point-direct { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--positif); margin-right: 6px; animation: pulsation 2s infinite; flex: none; }
@keyframes pulsation { 50% { opacity: 0.35; } }
.statut-cours { display: flex; align-items: center; }
.statut-cours.alerte { color: var(--alerte-texte); }
.statut-cours.alerte .point-direct { background: #fab219; animation: none; }
.valeur-direct { display: flex; align-items: center; justify-content: flex-end; height: 38px; padding-right: 12px; font-variant-numeric: tabular-nums; }

.ticker { display: flex; flex-wrap: wrap; gap: 8px; }
.ticker-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); white-space: nowrap; font-size: 13px; font-variant-numeric: tabular-nums; }
.ticker-item img { border-radius: 50%; }

.ligne-crypto { display: grid; grid-template-columns: minmax(0, 1fr) 170px 120px 110px 34px; gap: 8px; align-items: center; }
.ligne-crypto .aide { text-align: right; white-space: nowrap; }
.valeur-ligne { text-align: right; font-variant-numeric: tabular-nums; }
.total-ligne { display: flex; justify-content: space-between; padding: 12px; border-radius: 10px; background: var(--accent-doux); color: var(--accent); font-weight: 600; }

/* ---- Cases à cocher ---- */
.interrupteur, .case { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.interrupteur input, .case input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; margin: 0; }
.case { padding: 8px 0; border-bottom: 1px solid var(--border); }
.case:last-child { border-bottom: 0; }
.case b { margin-left: auto; font-variant-numeric: tabular-nums; }


/* ---- Écrans moyens et mobiles ---- */
/* ==== Adaptation aux écrans ==== */

/* Chaque carte est un conteneur : ses lignes de saisie s'adaptent à la largeur de la carte, quel que soit l'écran */
.carte { container-type: inline-size; }

/* Dépense : nom, montant et × en haut ; catégorie et fréquence en dessous */
@container (max-width: 700px) {
  .ligne-depense { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 100px 34px; }
  .ligne-depense:not(.auto) { padding-bottom: 10px; border-bottom: 1px solid var(--border); }
  .ligne-depense > input[type="text"] { grid-area: 1 / 1 / 2 / 3; }
  .ligne-depense > .saisie { grid-area: 1 / 3; }
  .ligne-depense > .supprimer { grid-area: 1 / 4; }
  .ligne-depense > select:first-of-type { grid-area: 2 / 1 / 3 / 3; }
  .ligne-depense > select:last-of-type { grid-area: 2 / 3 / 3 / 5; }
  .ligne-depense > .equivalent { grid-area: 3 / 1 / 4 / 5; text-align: left; padding: 0; margin: 0; }
}

/* Dette : nom, sens et × en haut ; montant et mois en dessous */
@container (max-width: 760px) {
  .ligne-dette { grid-template-columns: minmax(0, 1fr) auto 34px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
  .ligne-dette > input[type="text"] { grid-area: 1 / 1; }
  .ligne-dette > .segmente { grid-area: 1 / 2; }
  .ligne-dette > .supprimer { grid-area: 1 / 3; }
  .ligne-dette > .saisie { grid-area: 2 / 1; }
  .ligne-dette > input[type="month"] { grid-area: 2 / 2 / 3 / 4; }
}

/* Dépense exceptionnelle, poste de logement, crypto : nom et × en haut, valeurs en dessous */
@container (max-width: 600px) {
  .ligne-exceptionnelle { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) 34px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
  .ligne-exceptionnelle > input[type="text"] { grid-area: 1 / 1 / 2 / 3; }
  .ligne-exceptionnelle > .supprimer { grid-area: 1 / 3; }
  .ligne-exceptionnelle > .saisie { grid-area: 2 / 1; }
  .ligne-exceptionnelle > input[type="month"] { grid-area: 2 / 2 / 3 / 4; }
}
@container (max-width: 560px) {
  .ligne-logement { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 34px; }
  .ligne-logement > input[type="text"] { grid-area: 1 / 1 / 2 / 3; }
  .ligne-logement > .supprimer { grid-area: 1 / 3; }
  .ligne-logement > .saisie { grid-area: 2 / 1; }
  .ligne-logement > select { grid-area: 2 / 2 / 3 / 4; }
}
@container (max-width: 700px) {
  .ligne-crypto { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 34px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
  .ligne-crypto > select { grid-area: 1 / 1 / 2 / 3; }
  .ligne-crypto > .supprimer { grid-area: 1 / 3; }
  .ligne-crypto > .saisie { grid-area: 2 / 1; }
  .ligne-crypto > .aide { display: none; } /* le cours est déjà dans la bande au-dessus */
  .ligne-crypto > .valeur-ligne { grid-area: 2 / 2 / 3 / 4; }
}

@container (max-width: 640px) {
  .ligne-operation { grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; padding: 8px 0; }
  .ligne-operation > .aide { grid-area: 2 / 1; }
  .ligne-operation > .operation-libelle { grid-area: 1 / 1; }
  .ligne-operation > b { grid-area: 1 / 2; }
  .ligne-operation > select { grid-area: 2 / 2; width: 170px; }
}

/* Évolution du salaire : mois, variation et × ; libellé ; fixe et variable */
@container (max-width: 900px) {
  .frise-contenu:not(.edition) { flex-direction: column; align-items: flex-start; gap: 4px; }
  .frise-contenu:not(.edition) .frise-montant { text-align: left; }
  .frise-contenu.edition { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) 34px; }
  .frise-contenu.edition > input[type="month"] { grid-area: 1 / 1; }
  .frise-contenu.edition > .variation { grid-area: 1 / 2; }
  .frise-contenu.edition > .supprimer { grid-area: 1 / 3; }
  .frise-contenu.edition > input[type="text"] { grid-area: 2 / 1 / 3 / 4; }
  .frise-contenu.edition > .saisie:nth-of-type(1) { grid-area: 3 / 1; }
  .frise-contenu.edition > .saisie:nth-of-type(2) { grid-area: 3 / 2 / 4 / 4; }
}

/* Comptes : une fiche par compte au lieu d'un tableau qui défile sur le côté */
@container (max-width: 800px) {
  .tableau.edition, .tableau.edition tbody { display: block; }
  .tableau.edition thead { display: none; }
  .tableau.edition tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) 34px; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--border); }
  .tableau.edition tr:last-child { border-bottom: 0; }
  .tableau.edition td { display: block; padding: 0; border: 0; min-width: 0 !important; }
  .tableau.edition td:nth-child(1) { grid-area: 1 / 1 / 2 / 4; }
  .tableau.edition td:nth-child(6) { grid-area: 1 / 4; }
  .tableau.edition td:nth-child(2) { grid-area: 2 / 1 / 3 / 3; align-self: end; }
  .tableau.edition td:nth-child(3) { grid-area: 2 / 3 / 3 / 5; }
  .tableau.edition td:nth-child(4) { grid-area: 3 / 1 / 4 / 3; }
  .tableau.edition td:nth-child(5) { grid-area: 3 / 3 / 4 / 5; }
  .tableau.edition .saisie { min-width: 0; }
  .tableau.edition .valeur-direct { justify-content: flex-start; padding: 0 12px; }
}

/* Prévisions : une fiche par année (échéance et patrimoine en haut, le détail en dessous) */
@container (max-width: 900px) {
  .tableau:not(.edition), .tableau:not(.edition) tbody { display: block; }
  .tableau:not(.edition) thead { display: none; }
  .tableau:not(.edition) tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
  .tableau:not(.edition) tr:last-child { border-bottom: 0; }
  .tableau:not(.edition) td { display: block; padding: 0; border: 0; text-align: left; white-space: normal; }
  .tableau:not(.edition) td:first-child { grid-column: 1 / 3; }
  .tableau:not(.edition) td:last-child { grid-area: 1 / 3; text-align: right; font-size: 16px; }
}

/* Libellé au-dessus de la valeur dans les fiches (comptes et prévisions) */
@container (max-width: 900px) {
  .tableau td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 2px; font-size: 11.5px; font-weight: 400; color: var(--muted); }
}

/* Une seule colonne de cartes */
@media (max-width: 1100px) {
  .grille-2, .grille-2.large-gauche, .grille-apercu { grid-template-columns: minmax(0, 1fr); }
  .grille-2.egale { grid-auto-rows: auto; }
  .collante { position: static; }
}

/* Tablette : le menu passe tout seul en icônes pour laisser la place au contenu */
@media (min-width: 761px) and (max-width: 1100px) {
  .layout, .layout.menu-reduit { grid-template-columns: 68px minmax(0, 1fr); }
  .sidebar { padding-left: 10px; padding-right: 10px; }
  .sidebar-haut { flex-direction: column; gap: 12px; }
  .marque span:last-child, .nav-item span, .badge-bareme span:last-child, .statut-synchro span:last-child, .bouton-menu { display: none; }
  .nav-item { justify-content: center; padding: 10px 0; }
  .badge-bareme { padding: 8px; margin: 0 auto; }
  .actions-pied { flex-direction: column; align-items: center; padding: 0; }
  .contenu { padding: 28px 24px 56px; }
}

/* Téléphone : en-tête en haut, navigation en barre fixe en bas (comme une appli) */
@media (max-width: 760px) {
  .layout, .layout.menu-reduit { grid-template-columns: minmax(0, 1fr); }
  .sidebar, .menu-reduit .sidebar {
    position: sticky; top: 0; z-index: 10; height: auto; flex-direction: row; align-items: center; justify-content: space-between;
    gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 16px 8px; border-right: 0; border-bottom: 1px solid var(--border);
  }
  .sidebar-haut, .menu-reduit .sidebar-haut { flex-direction: row; }
  .menu-reduit .marque span:last-child { display: inline; }
  .bouton-menu, .badge-bareme, .statut-synchro span:last-child { display: none; }
  .sidebar-pied, .menu-reduit .sidebar-pied { margin: 0; flex-direction: row; }
  .actions-pied, .menu-reduit .actions-pied { flex-direction: row; padding: 0; }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; flex-direction: row; gap: 0;
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border);
  }
  .layout .nav-item { flex: 1; min-width: 0; flex-direction: column; justify-content: center; gap: 3px; padding: 7px 0; font-size: 10.5px; }
  .layout .nav-item .nav-libelle { display: none; }
  .layout .nav-item .nav-court { display: block; }
  .nav-item svg { width: 21px; height: 21px; }
  .nav-item.actif { background: none; }
  .contenu { padding: 18px 16px calc(84px + env(safe-area-inset-bottom)); }
  h1 { font-size: 22px; }
  .hero-valeur { font-size: 40px; }
  .hero-detail { gap: 2px 12px; }
  .hero-detail .sep { display: none; }
  .tuiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .tuiles.trois { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .tuile-valeur { font-size: 21px; }
  .tuiles.trois .carte { padding: 14px; }
  .tuiles.trois .tuile-valeur { font-size: 17px; }
  .chiffres { gap: 8px; }
  .chiffres > div { padding: 10px; }
  .chiffres .libelle { font-size: 12px; white-space: normal; } /* libellé sur deux lignes plutôt que coupé */
  .saisie { padding-right: 10px; }
  .saisie input, .saisie input:focus { padding-left: 10px; }
  .chiffres b { font-size: 15px; }
  .segmente button, .segmente.petit button { min-height: 36px; }
  .carte { padding: 18px; }
  .carte.vide { padding: 24px; }
}
