:root {
  color-scheme: light dark;
  --fond: #f3f4f7;
  --carte: #ffffff;
  --texte: #12141a;
  --texte-att: #63697a;
  --texte-faible: #9096a3;
  --accent: #3454d1;
  --accent-fort: #2842ac;
  --accent-doux: #ebf0ff;
  --vert: #158a44;
  --vert-doux: #e8f7ee;
  --rouge: #dc2626;
  --rouge-doux: #fdeded;
  --orange: #d97706;
  --orange-doux: #fdf3e3;
  --gris: #9aa1ac;
  --bordure: #e7e9ef;
  --bordure-forte: #d7dae3;
  --rayon-sm: 8px;
  --rayon-md: 12px;
  --rayon-lg: 16px;
  --rayon-pilule: 999px;
  --ombre-sm: 0 1px 2px rgba(20, 24, 38, 0.05), 0 1px 1px rgba(20, 24, 38, 0.04);
  --ombre-md: 0 10px 24px -10px rgba(20, 24, 38, 0.16), 0 2px 6px -2px rgba(20, 24, 38, 0.06);
  --ombre-modal: 0 24px 60px -12px rgba(10, 12, 20, 0.35);
  --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --serie-1: #2a78d6;
  --serie-2: #eb6834;
  --serie-3: #1baf7a;
  --serie-4: #eda100;
  --serie-5: #e87ba4;
  --serie-6: #008300;
  --serie-7: #4a3aa7;
  --serie-8: #e34948;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fond: #0c0d11;
    --carte: #17191f;
    --texte: #f1f2f4;
    --texte-att: #9aa0ac;
    --texte-faible: #6b7180;
    --accent: #6d8bff;
    --accent-fort: #8ba3ff;
    --accent-doux: #1a2340;
    --vert: #34c973;
    --vert-doux: #112b1e;
    --rouge: #f2726b;
    --rouge-doux: #351717;
    --orange: #e7ab52;
    --orange-doux: #332512;
    --gris: #757c89;
    --bordure: #262932;
    --bordure-forte: #34384a;
    --ombre-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --ombre-md: 0 12px 28px -10px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.3);
    --ombre-modal: 0 24px 60px -12px rgba(0, 0, 0, 0.7);
    --serie-1: #3987e5;
    --serie-2: #d95926;
    --serie-3: #199e70;
    --serie-4: #c98500;
    --serie-5: #d55181;
    --serie-6: #17a04b;
    --serie-7: #9085e9;
    --serie-8: #e66767;
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--fond);
  color: var(--texte);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Pages "liste" (Opérations, Budget) : l'en-tête (nav, filtres, résumé) reste fixe à
   l'écran, seule la zone de défilement dédiée bouge — cf. .zone-defilante plus bas. */
body:has(.container-liste) {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
body:has(.container-liste) .container {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 10px 24px;
  background: var(--carte);
  border-bottom: 1px solid var(--bordure);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-shrink: 0;
}

.nav-marque {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--texte);
  text-decoration: none;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.nav-logo {
  display: block;
  width: 27px;
  height: 27px;
  border-radius: 8px;
  box-shadow: var(--ombre-sm);
}

.nav-liens {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
}

.nav-liens a {
  color: var(--texte-att);
  text-decoration: none;
  padding: 7px 12px;
  border-radius: var(--rayon-sm);
  font-size: 13.5px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.nav-liens a:hover { background: var(--fond); color: var(--texte); }
.nav-liens a.actif { background: var(--accent-doux); color: var(--accent); }

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 20px 28px;
  width: 100%;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bordure-forte); border-radius: var(--rayon-pilule); border: 2px solid var(--fond); }
* { scrollbar-width: thin; scrollbar-color: var(--bordure-forte) transparent; }

h1 { font-size: 21px; font-weight: 700; letter-spacing: -0.01em; margin: 4px 0 18px; flex-shrink: 0; }
h2 { letter-spacing: -0.005em; }

.cartes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.carte {
  background: var(--carte);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-lg);
  box-shadow: var(--ombre-sm);
  padding: 18px;
  transition: box-shadow var(--transition), transform var(--transition);
}

/* Portefeuille : six cartes de synthèse sur une ligne en large */
#resume.cartes { grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }

.carte h2 { font-size: 16px; font-weight: 650; margin: 0 0 10px; }
.carte .nom { color: var(--texte-att); font-size: 13px; margin: 0 0 8px; }
.carte .solde {
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  font-variant-numeric: tabular-nums;
}
.carte .date { color: var(--texte-faible); font-size: 12px; margin-top: 4px; }
.carte .sync-erreur { color: var(--orange); }
.cartes-larges { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.carte .actions-carte { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.carte .actions-carte button:not(.bouton-danger) { width: auto; flex: 1 1 auto; margin-top: 14px; }
.carte .actions-carte button.secondaire {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--bordure);
}
.carte .actions-carte button.secondaire:hover { background: var(--fond); }
.carte .actions-carte button:disabled { opacity: 0.55; cursor: default; }
.carte .actions-carte.liens { margin-top: 2px; gap: 14px; }
.modal-champ textarea {
  padding: 10px 12px;
  border-radius: var(--rayon-sm);
  border: 1px solid var(--bordure);
  background: var(--fond);
  color: var(--texte);
  font: 12.5px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  resize: vertical;
}
.apercu-lignes { list-style: none; margin: 8px 0 0; padding: 0; font-size: 12.5px; }
.apercu-lignes li { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-bottom: 1px solid var(--bordure); }
.apercu-lignes li span:last-child { white-space: nowrap; font-variant-numeric: tabular-nums; }
details.volet { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--bordure); }
details.volet summary { cursor: pointer; font-size: 12.5px; color: var(--texte-faible); }
details.volet[open] summary { margin-bottom: 8px; }
.ajout-versement { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ajout-versement input, .ajout-versement select {
  flex: 1 1 110px;
  min-width: 0;
  padding: 7px 8px;
  border-radius: var(--rayon-sm);
  border: 1px solid var(--bordure);
  background: var(--fond);
  color: var(--texte);
  font-size: 13px;
}
.ajout-versement button { flex: 0 0 auto; margin-top: 0 !important; width: auto; padding: 7px 14px; }
.carte .apercu-lignes button.lien { border: none; background: none; color: var(--texte-faible); cursor: pointer; padding: 0 2px; font-size: 14px; width: auto; margin: 0; }
.carte .apercu-lignes button.lien:hover { color: var(--rouge); background: none; }
.carte .actions-carte button.lien {
  flex: 0 0 auto;
  margin-top: 8px;
  padding: 2px 0;
  background: none;
  color: var(--texte-faible);
  font-size: 12.5px;
  font-weight: 500;
  text-decoration: underline;
}
.carte .actions-carte button.lien:hover { background: none; color: var(--accent); }
.carte .actions-carte button.lien.danger:hover { color: var(--rouge); }

.carte button:not(.bouton-danger) {
  margin-top: 14px;
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: var(--rayon-sm);
  background: var(--accent);
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}
.carte button:not(.bouton-danger):hover { background: var(--accent-fort); }
.carte button:not(.bouton-danger):active { transform: scale(0.98); }

.statut {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  font-size: 12.5px;
  text-transform: capitalize;
  padding: 3px 10px;
  border-radius: var(--rayon-pilule);
}
.statut::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.statut.libre { text-transform: none; }  /* libellés déjà rédigés, pas des codes à mettre en capitales */
.statut-connecte { color: var(--vert); background: var(--vert-doux); }
.statut-en_attente { color: var(--orange); background: var(--orange-doux); }
.statut-expire { color: var(--rouge); background: var(--rouge-doux); }
.statut-non_connecte { color: var(--gris); background: var(--fond); }

.filtres {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.filtres input,
.filtres select {
  flex: 1;
  min-width: 140px;
  padding: 9px 12px;
  border-radius: var(--rayon-sm);
  border: 1px solid var(--bordure);
  background: var(--carte);
  color: var(--texte);
  font-size: 13.5px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

input, select, textarea, button { font-family: inherit; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-doux);
}

.select-categorie {
  padding: 6px 8px;
  border-radius: var(--rayon-sm);
  border: 1px solid var(--bordure);
  background: var(--carte);
  color: var(--texte);
  font-size: 12px;
  max-width: 160px;
}

.filtres button {
  padding: 9px 14px;
  border: none;
  border-radius: var(--rayon-sm);
  background: var(--accent);
  color: white;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
  white-space: nowrap;
}
.filtres button:hover { background: var(--accent-fort); }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--carte);
  font-size: 13.5px;
}

th, td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--bordure);
}

th {
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--texte-faible);
  background: var(--carte);
}

td { font-variant-numeric: tabular-nums; }

tr.debit td:last-child { color: var(--rouge); font-weight: 600; }
tr.credit td:last-child { color: var(--vert); font-weight: 600; }
.debit { color: var(--rouge); }
.credit { color: var(--vert); }

.categorie-bloc { margin-bottom: 12px; }

.categorie-entete {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.categorie-entete input {
  flex: 1;
  font-weight: 600;
  font-size: 15px;
  padding: 9px 12px;
  border-radius: var(--rayon-sm);
  border: 1px solid var(--bordure);
  background: var(--fond);
  color: var(--texte);
}

.sous-categorie-liste {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sous-categorie-liste li {
  display: flex;
  gap: 8px;
  align-items: center;
}

.sous-categorie-liste input {
  flex: 1;
  padding: 8px 10px;
  border-radius: var(--rayon-sm);
  border: 1px solid var(--bordure);
  background: var(--fond);
  color: var(--texte);
  font-size: 13px;
}

.ajout-sous-categorie input { color: var(--texte-att); }

.sous-categorie-liste button:not(.bouton-danger) {
  width: auto;
  margin-top: 0;
  padding: 8px 12px;
  border: none;
  border-radius: var(--rayon-sm);
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.bouton-danger {
  border: none;
  border-radius: var(--rayon-sm);
  background: transparent;
  color: var(--rouge);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background var(--transition);
}
.bouton-danger:hover { background: var(--rouge-doux); }

.filtres button.periode-btn {
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: var(--rayon-pilule);
  background: var(--carte);
  color: var(--texte-att);
  border-color: var(--bordure);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.filtres button.periode-btn:hover { background: var(--fond); }
.filtres button.periode-btn.actif {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.filtres button.periode-btn.actif:hover { background: var(--accent-fort); }

.fil-ariane {
  margin: 2px 0 18px;
  font-size: 13px;
  color: var(--texte-faible);
  flex-shrink: 0;
}
.segment-ariane {
  cursor: pointer;
  color: var(--accent);
  font-weight: 500;
}
.segment-ariane:hover { text-decoration: underline; }
.segment-ariane:last-child {
  color: var(--texte);
  font-weight: 650;
  cursor: default;
}
.segment-ariane:last-child:hover { text-decoration: none; }
.separateur-ariane { margin: 0 6px; color: var(--texte-faible); }

.bloc-budget {
  display: flex;
  gap: 28px;
  align-items: center;
  flex-wrap: wrap;
  background: var(--carte);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-lg);
  box-shadow: var(--ombre-sm);
  padding: 20px;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.donut-conteneur {
  position: relative;
  width: 210px;
  flex-shrink: 0;
}
.donut { width: 100%; height: auto; overflow: visible; }
.part-donut { transition: opacity var(--transition); }
.part-donut.cliquable { cursor: pointer; }
.part-donut.cliquable:hover { opacity: 0.82; }
.donut-total {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-align: center;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
.vide { color: var(--texte-faible); font-size: 13px; }

.legende {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.legende-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  padding: 7px 8px;
  border-radius: var(--rayon-sm);
  transition: background var(--transition);
}
.legende-item.cliquable { cursor: pointer; }
.legende-item.cliquable:hover { background: var(--fond); }
.puce { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.legende-label { flex: 1; }
.legende-valeurs { color: var(--texte-faible); white-space: nowrap; font-variant-numeric: tabular-nums; font-size: 12.5px; }
/* Peu de lignes : sur grand écran, le montant resterait à une page de son libellé */
.bloc-repartition .legende { max-width: 640px; }

.filtre-actif {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent-doux);
  border: 1px solid transparent;
  color: var(--accent);
  border-radius: var(--rayon-pilule);
  padding: 6px 8px 6px 14px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 12px;
  flex-shrink: 0;
}
.filtre-actif button {
  border: none;
  background: rgba(255, 255, 255, 0.5);
  color: var(--accent);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}

.aide-page { font-size: 13px; line-height: 1.55; color: var(--texte-att); margin: 0 0 16px; }
.sous-titre { font-size: 14px; font-weight: 650; color: var(--texte-att); margin: 4px 0 10px; flex-shrink: 0; }

/* Zone de défilement dédiée : seule cette partie bouge sur les pages "liste" ; le
   reste (filtres, résumé, en-tête de tableau) reste visible à l'écran. */
.zone-defilante {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-md);
  box-shadow: var(--ombre-sm);
  background: var(--carte);
}
.zone-defilante table { border-radius: 0; }
.zone-defilante thead th {
  position: sticky;
  top: 0;
  background: var(--carte);
  box-shadow: 0 1px 0 var(--bordure);
}
.zone-defilante tbody tr:last-child td { border-bottom: none; }

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
  padding-top: 2px;
  font-size: 13px;
  color: var(--texte-att);
  flex-shrink: 0;
}
.pager button {
  padding: 6px 12px;
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-sm);
  background: var(--carte);
  color: var(--texte);
  cursor: pointer;
  font-weight: 500;
  transition: background var(--transition), border-color var(--transition);
}
.pager button:hover:not(:disabled) { background: var(--fond); border-color: var(--bordure-forte); }
.pager button:disabled { opacity: 0.4; cursor: default; }

tr.ligne-transaction { cursor: pointer; transition: background var(--transition); }
tr.ligne-transaction:hover { background: var(--fond); }

.modal-fond {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 11, 16, 0.55);
  backdrop-filter: blur(2px);
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal-fond.ouvert { display: flex; }

.modal-carte {
  position: relative;
  background: var(--carte);
  border-radius: var(--rayon-lg);
  box-shadow: var(--ombre-modal);
  padding: 26px;
  width: 100%;
  max-width: 380px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-carte h2 { font-size: 16px; font-weight: 700; margin: 0 0 18px; }

.modal-fermer {
  position: absolute;
  top: 18px; right: 18px;
  border: none;
  background: var(--fond);
  color: var(--texte-att);
  width: 28px; height: 28px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.modal-fermer:hover { background: var(--bordure); color: var(--texte); }

.modal-details {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 7px 12px;
  font-size: 13px;
  margin: 0 0 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--bordure);
}
.modal-details dt { color: var(--texte-faible); }
.modal-details dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.modal-champ {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--texte-att);
  margin-bottom: 14px;
}
.modal-champ input, .modal-champ select {
  padding: 10px 12px;
  border-radius: var(--rayon-sm);
  border: 1px solid var(--bordure);
  background: var(--fond);
  color: var(--texte);
  font-size: 14px;
  font-weight: 400;
}

.modal-case {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--texte-att);
  margin-bottom: 16px;
  cursor: pointer;
}
.modal-case input { cursor: pointer; }

.modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.modal-actions-droite {
  display: flex;
  gap: 8px;
}

.modal-bouton-principal {
  padding: 10px 18px;
  border: none;
  border-radius: var(--rayon-sm);
  background: var(--accent);
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}
.modal-bouton-principal:hover { background: var(--accent-fort); }
.modal-bouton-secondaire {
  padding: 10px 18px;
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-sm);
  background: transparent;
  color: var(--texte);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition);
}
.modal-bouton-secondaire:hover { background: var(--fond); }
.modal-bouton-principal:disabled { opacity: 0.45; cursor: default; }
.modal-actions-fin { justify-content: flex-end; }

/* Fenêtre "créer une règle" : libellé d'origine en mots cliquables/sélectionnables. */
.modal-carte.modal-regle { max-width: 460px; }
.modal-aide { font-size: 12px; font-weight: 400; color: var(--texte-faible); }
.modal-info { font-size: 13px; color: var(--texte-att); margin: 0 0 12px; line-height: 1.45; }
.modal-info:empty { display: none; }
.modal-info.alerte { color: var(--orange); }
.regle-libelle {
  padding: 10px 12px;
  background: var(--fond);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--texte);
  line-height: 2.1;
}
.mot-libelle {
  padding: 2px 7px;
  border-radius: 6px;
  cursor: pointer;
  background: var(--carte);
  border: 1px solid var(--bordure-forte);
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.mot-libelle:hover { border-color: var(--accent); }
.mot-libelle.retenu {
  background: var(--accent-doux);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 650;
}

.interrupteur {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 21px;
  vertical-align: middle;
}
.interrupteur input {
  opacity: 0;
  width: 0;
  height: 0;
}
.interrupteur .glissiere {
  position: absolute;
  inset: 0;
  background: var(--gris);
  border-radius: 21px;
  cursor: pointer;
  transition: background var(--transition);
}
.interrupteur .glissiere::before {
  content: "";
  position: absolute;
  width: 15px;
  height: 15px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.interrupteur input:checked + .glissiere {
  background: var(--vert);
}
.interrupteur input:checked + .glissiere::before {
  transform: translateX(17px);
}

/* Journal boursier : une dizaine de colonnes, plus large que les autres pages. */
.container.container-large { max-width: 1180px; }
.aide-page summary { cursor: pointer; color: var(--texte-att); font-weight: 600; }
.aide-page p { margin: 8px 0 0; }

.resume-journal {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 22px;
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--texte-att);
  flex-shrink: 0;
}
.resume-journal strong { color: var(--texte); font-variant-numeric: tabular-nums; }

.pastille {
  display: inline-block;
  padding: 2px 9px;
  border-radius: var(--rayon-pilule);
  font-size: 11.5px;
  font-weight: 600;
  background: var(--fond);
  color: var(--texte-att);
  white-space: nowrap;
}
.pastille-achat { color: var(--accent); background: var(--accent-doux); }
.pastille-vente { color: var(--orange); background: var(--orange-doux); }
.pastille-pea { color: var(--vert); background: var(--vert-doux); }
.pastille-dividende { color: var(--serie-5); background: color-mix(in srgb, var(--serie-5) 14%, transparent); }
.pastille-crypto { color: var(--serie-7); background: color-mix(in srgb, var(--serie-7) 14%, transparent); }
.pastille-av { color: var(--serie-5); background: color-mix(in srgb, var(--serie-5) 14%, transparent); }
.pastille-pea-pme { color: var(--serie-4); background: color-mix(in srgb, var(--serie-4) 14%, transparent); }

.tableau-journal th.nombre, .tableau-journal td.nombre { text-align: right; }
.tableau-journal td.nombre { white-space: nowrap; }
.tableau-journal td:nth-child(-n+4) { white-space: nowrap; }
.tableau-journal td:nth-child(2) { white-space: normal; }
.tableau-journal th, .tableau-journal td { padding-left: 10px; padding-right: 10px; }
.tableau-journal td.total { font-weight: 600; }
/* Au journal un dividende se lit en brut : c'est le brut qui ressort, le net reste lisible à côté */
.tableau-journal tr.ligne-dividende td:nth-child(9) { font-weight: 600; }
.tableau-journal tr.ligne-dividende td.total { font-weight: 400; }
table .sous-ligne { display: block; margin-top: 2px; color: var(--texte-faible); font-size: 11.5px; font-weight: 400; }
.alerte-verification { color: var(--orange); cursor: help; }
.lien-operation { color: var(--accent); text-decoration: none; font-weight: 700; margin-left: 4px; }
.lien-operation:hover { text-decoration: underline; }
.rapprochement { font-size: 12.5px; margin: 0 0 12px; flex-shrink: 0; }
.rapprochement-ok { color: var(--texte-att); }
.rapprochement ul { margin: 6px 0 0; padding-left: 18px; font-weight: 400; }
.alerte-estimation { color: var(--accent); cursor: help; }
.encart-alerte {
  margin: 0 0 14px;
  padding: 10px 14px;
  border-radius: var(--rayon-sm);
  background: var(--orange-doux);
  color: var(--orange);
  font-size: 13px;
  font-weight: 600;
}

.tableau-portefeuille th.nombre, .tableau-portefeuille td.nombre,
.tableau-cloturees th.nombre, .tableau-cloturees td.nombre,
.tableau-dividendes th.nombre, .tableau-dividendes td.nombre { text-align: right; white-space: nowrap; }
.tableau-portefeuille th, .tableau-portefeuille td { padding-left: 10px; padding-right: 10px; }
.tableau-portefeuille td.nombre .sous-ligne, .tableau-cloturees td.nombre .sous-ligne { text-align: right; }
.bloc-dividendes { margin-top: 22px; }
.bloc-dividendes summary { cursor: pointer; font-size: 14px; font-weight: 650; color: var(--texte-att); margin-bottom: 10px; }
.tableau-portefeuille td.valeur { font-weight: 600; }
.lien-titre { color: var(--texte); font-weight: 600; text-decoration: none; }
.lien-titre:hover { color: var(--accent); text-decoration: underline; }
.sous-ligne .pastille { margin-right: 4px; }

/* Téléphone : le camembert du Budget occupe déjà beaucoup de hauteur, geler un
   en-tête au-dessus d'une liste ne laisse plus assez de place pour être utile. On
   revient à un défilement de page classique (nav toujours visible en sticky via sa
   règle de base) et les tableaux se transforment en cartes plus lisibles au doigt. */
@media (max-width: 640px) {
  body:has(.container-liste) {
    height: auto;
    overflow: visible;
    display: block;
  }
  .container.container-liste {
    display: block;
    overflow: visible;
  }
  .zone-defilante {
    flex: none;
    overflow: visible;
    border: none;
    box-shadow: none;
    background: transparent;
  }

  .nav { padding: 10px 16px; }
  .container { padding: 16px 14px 24px; }

  /* Portefeuille : cinq cartes de synthèse, deux par ligne (la dernière sur toute la largeur) */
  #resume.cartes { grid-template-columns: 1fr 1fr; gap: 10px; }
  #resume .carte { padding: 12px 14px; }
  #resume .carte h2 { font-size: 12.5px; margin-bottom: 6px; color: var(--texte-att); }
  #resume .carte .solde { font-size: 18px; }

  .donut-conteneur { width: 168px; }
  .bloc-budget { padding: 16px; gap: 16px; }

  .interrupteur { width: 44px; height: 26px; }
  .interrupteur .glissiere::before { width: 20px; height: 20px; }
  .interrupteur input:checked + .glissiere::before { transform: translateX(18px); }

  .tableau-operations thead, .tableau-budget thead, .tableau-portefeuille thead, .tableau-journal thead, .tableau-cloturees thead, .tableau-dividendes thead { display: none; }
  .tableau-operations tbody, .tableau-budget tbody, .tableau-portefeuille tbody, .tableau-journal tbody, .tableau-cloturees tbody, .tableau-dividendes tbody { display: block; }
  .tableau-operations tr, .tableau-budget tr, .tableau-portefeuille tr, .tableau-journal tr, .tableau-cloturees tr, .tableau-dividendes tr {
    display: grid;
    column-gap: 10px;
    row-gap: 3px;
    padding: 12px 4px;
    border-bottom: 1px solid var(--bordure);
    align-items: center;
  }
  .tableau-operations tr:has(td[colspan]), .tableau-budget tr:has(td[colspan]), .tableau-portefeuille tr:has(td[colspan]), .tableau-journal tr:has(td[colspan]), .tableau-cloturees tr:has(td[colspan]), .tableau-dividendes tr:has(td[colspan]) {
    display: block;
    padding: 16px 4px;
  }
  .tableau-operations td, .tableau-budget td, .tableau-portefeuille td, .tableau-journal td, .tableau-cloturees td, .tableau-dividendes td {
    padding: 0 !important;
    border: none !important;
  }

  .tableau-operations tr {
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "date date montant" "libelle libelle libelle" "compte categorie pointe";
  }
  .tableau-operations td:nth-child(1) { grid-area: date; color: var(--texte-faible); font-size: 12px; }
  .tableau-operations td:nth-child(2) { grid-area: compte; color: var(--texte-faible); font-size: 12px; }
  .tableau-operations td:nth-child(3) { grid-area: libelle; font-weight: 600; font-size: 14.5px; }
  .tableau-operations td:nth-child(4) { grid-area: montant; text-align: right; font-size: 14px; }
  .tableau-operations td:nth-child(5) { grid-area: categorie; font-size: 12px; color: var(--texte-att); }
  .tableau-operations td:nth-child(6) { grid-area: pointe; justify-self: end; }

  .tableau-budget tr {
    grid-template-columns: 1fr auto;
    grid-template-areas: "date montant" "libelle libelle" "compte compte";
  }
  .tableau-budget td:nth-child(1) { grid-area: date; color: var(--texte-faible); font-size: 12px; }
  .tableau-budget td:nth-child(2) { grid-area: compte; color: var(--texte-faible); font-size: 12px; }
  .tableau-budget td:nth-child(3) { grid-area: libelle; font-weight: 600; font-size: 14.5px; }
  .tableau-budget td:nth-child(4) { grid-area: montant; text-align: right; font-size: 14px; }

  .tableau-portefeuille tr {
    grid-template-columns: 1fr auto;
    grid-template-areas: "titre valeur" "qte latente" "pru realisee" "divid rendement";
  }
  .tableau-portefeuille td:nth-child(1) { grid-area: titre; font-size: 14.5px; }
  .tableau-portefeuille td:nth-child(2) { grid-area: qte; text-align: left; font-size: 12.5px; }
  .tableau-portefeuille td:nth-child(3) { grid-area: pru; text-align: left; font-size: 12.5px; }
  .tableau-portefeuille td:nth-child(4), .tableau-portefeuille td:nth-child(5), .tableau-portefeuille td.vide { display: none; }
  .tableau-portefeuille td:nth-child(6) { grid-area: valeur; font-size: 14px; }
  .tableau-portefeuille td:nth-child(7) { grid-area: latente; font-size: 12.5px; }
  .tableau-portefeuille td:nth-child(8) { grid-area: realisee; font-size: 12.5px; }
  .tableau-portefeuille td:nth-child(9) { grid-area: divid; text-align: left; font-size: 12.5px; }
  .tableau-portefeuille td:nth-child(10) { grid-area: rendement; font-size: 13.5px; font-weight: 600; }
  .tableau-portefeuille td.nombre .sous-ligne, .tableau-cloturees td.nombre .sous-ligne { display: inline; margin-left: 4px; }

  .tableau-cloturees tr {
    grid-template-columns: 1fr auto;
    grid-template-areas: "titre rendement" "periode periode" "investi encaisse" "pv divid";
  }
  .tableau-cloturees td:nth-child(1) { grid-area: titre; font-size: 14.5px; }
  .tableau-cloturees td:nth-child(2) { grid-area: periode; color: var(--texte-faible); font-size: 12px; }
  .tableau-cloturees td:nth-child(2) .sous-ligne { display: inline; margin-left: 6px; }
  .tableau-cloturees td:nth-child(3) { grid-area: investi; text-align: left; font-size: 12.5px; }
  .tableau-cloturees td:nth-child(4) { grid-area: encaisse; font-size: 12.5px; }
  .tableau-cloturees td:nth-child(5) { grid-area: pv; text-align: left; font-size: 12.5px; }
  .tableau-cloturees td:nth-child(6) { grid-area: divid; font-size: 12.5px; }
  .tableau-cloturees td:nth-child(7) { grid-area: rendement; font-size: 14px; font-weight: 600; }
  .tableau-cloturees td.vide { display: none; }
  .tableau-portefeuille td[data-label]::before, .tableau-cloturees td[data-label]::before, .tableau-dividendes td[data-label]::before {
    content: attr(data-label) " "; color: var(--texte-faible); font-size: 11.5px;
  }

  .tableau-dividendes tr {
    grid-template-columns: 1fr auto auto;
    grid-template-areas: "titre titre net" "date brut impot";
  }
  .tableau-dividendes td:nth-child(1) { grid-area: date; color: var(--texte-faible); font-size: 12px; }
  .tableau-dividendes td:nth-child(2) { grid-area: titre; font-size: 14px; }
  .tableau-dividendes td:nth-child(3), .tableau-dividendes td:nth-child(7) { display: none; }
  .tableau-dividendes td:nth-child(4) { grid-area: brut; font-size: 12px; }
  .tableau-dividendes td:nth-child(5) { grid-area: impot; font-size: 12px; }
  .tableau-dividendes td:nth-child(6) { grid-area: net; font-size: 14px; font-weight: 600; }

  .tableau-journal tr {
    grid-template-columns: 64px 64px 1fr auto;
    grid-template-areas: "date date date total" "libelle libelle libelle libelle" "sens support banque isin" "qte qte prix frais";
  }
  .tableau-journal td:nth-child(1) { grid-area: date; color: var(--texte-faible); font-size: 12px; }
  .tableau-journal td:nth-child(2) { grid-area: banque; color: var(--texte-faible); font-size: 12px; }
  .tableau-journal td:nth-child(3) { grid-area: support; }
  .tableau-journal td:nth-child(4) { grid-area: sens; }
  .tableau-journal td:nth-child(5) { grid-area: libelle; font-weight: 600; font-size: 14.5px; }
  .tableau-journal td:nth-child(6) { grid-area: isin; text-align: right; color: var(--texte-faible); font-size: 11.5px; }
  .tableau-journal td:nth-child(6) .sous-ligne { display: none; }
  .tableau-journal td:nth-child(7) { grid-area: qte; text-align: left; font-size: 12.5px; }
  .tableau-journal td:nth-child(8) { grid-area: prix; text-align: left; font-size: 12.5px; }
  .tableau-journal td:nth-child(9) { display: none; }
  .tableau-journal td:nth-child(10) { grid-area: frais; font-size: 12.5px; }
  .tableau-journal td:nth-child(11) { grid-area: total; font-size: 14px; }
  .tableau-journal td[data-label]::before { content: attr(data-label) " "; color: var(--texte-faible); font-size: 11.5px; }
  .tableau-journal tr.ligne-dividende {
    grid-template-areas: "date date date total" "libelle libelle libelle libelle" "sens support banque isin" "qte qte prix prix" "frais frais net net";
  }
  .tableau-journal tr.ligne-dividende td:nth-child(9) { display: block; grid-area: total; text-align: right; font-size: 14px; }
  .tableau-journal tr.ligne-dividende td:nth-child(11) { grid-area: net; text-align: left; font-size: 12.5px; }
}
