/* ===================== PALETTES (couleur) =====================
   Choix dans Paramètres → attribut data-palette sur <html> (défaut = indigo).
   Chaque palette définit ses tokens en clair ; le sombre (bouton 🌙 ou
   préférence système) a ses propres tokens par palette. « sombre » est une
   palette volontairement toujours sombre. --radius reste commun. */
:root {
  --radius: 16px;
  /* indigo — clair (défaut) */
  --bg:#f7f8fb; --surface:#ffffff; --surface-2:#f2f4f8; --texte:#1a1f2b; --texte-doux:#68707f; --bord:#e6e9ef;
  --accent:#4f46e5; --accent-doux:#ecebfd; --vert:#0f9d63; --vert-doux:#e2f6ec; --rouge:#e0453b; --rouge-doux:#fdeae8; --or:#b7791f;
  --ombre:0 1px 2px rgba(20,23,40,.06),0 10px 30px rgba(20,23,40,.08);
}
:root[data-palette="terracotta"]{ --bg:#f4f1ea; --surface:#fff; --surface-2:#faf8f3; --texte:#24211c; --texte-doux:#6b6459; --bord:#e4ded2; --accent:#b5451f; --accent-doux:#f3ddd2; --vert:#2f7d54; --vert-doux:#dcefe2; --rouge:#c0392b; --rouge-doux:#f7dedb; --or:#c8961e; --ombre:0 1px 3px rgba(0,0,0,.06),0 6px 20px rgba(0,0,0,.05); }
:root[data-palette="ardoise"]{ --bg:#eef2f7; --surface:#fff; --surface-2:#f4f7fb; --texte:#0f1b2d; --texte-doux:#5a6b83; --bord:#dbe3ee; --accent:#12466f; --accent-doux:#e2ecf5; --vert:#0a7d55; --vert-doux:#e0f2ea; --rouge:#b2241c; --rouge-doux:#f8e4e2; --or:#b7791f; }
:root[data-palette="vert"]{ --bg:#f6f5f0; --surface:#fffefb; --surface-2:#efeee7; --texte:#20241f; --texte-doux:#6c7065; --bord:#e2e0d5; --accent:#0f6b52; --accent-doux:#dcefe6; --vert:#0f6b52; --vert-doux:#dcefe6; --rouge:#b23a2e; --rouge-doux:#f6e2de; --or:#a86a1a; }
:root[data-palette="sombre"]{ --bg:#0f1218; --surface:#171b23; --surface-2:#1e232d; --texte:#e8eaf0; --texte-doux:#9098a8; --bord:#272d38; --accent:#7c83ff; --accent-doux:#232544; --vert:#34d399; --vert-doux:#12352b; --rouge:#f77066; --rouge-doux:#3a201e; --or:#e3b452; --ombre:0 1px 3px rgba(0,0,0,.4),0 10px 30px rgba(0,0,0,.45); }

/* ---- Sombre : préférence système (sauf si « clair » forcé) ---- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]){ --bg:#0f1218; --surface:#171b23; --surface-2:#1e232d; --texte:#e8eaf0; --texte-doux:#9098a8; --bord:#272d38; --accent:#7c83ff; --accent-doux:#232544; --vert:#34d399; --vert-doux:#12352b; --rouge:#f77066; --rouge-doux:#3a201e; --or:#e3b452; --ombre:0 1px 3px rgba(0,0,0,.4),0 10px 30px rgba(0,0,0,.45); }
  :root[data-palette="terracotta"]:not([data-theme="light"]){ --bg:#1a1815; --surface:#232019; --surface-2:#2b271f; --texte:#ece7dd; --texte-doux:#a89f90; --bord:#38332a; --accent:#e0703f; --accent-doux:#3a2820; --vert:#5cc98a; --vert-doux:#1f3a2b; --rouge:#e8776b; --rouge-doux:#3a2320; --or:#e3b452; }
  :root[data-palette="ardoise"]:not([data-theme="light"]){ --bg:#0d1420; --surface:#141d2b; --surface-2:#1b2636; --texte:#e6ecf5; --texte-doux:#93a3ba; --bord:#263447; --accent:#5b9bd1; --accent-doux:#1a2c40; --vert:#34d399; --vert-doux:#123528; --rouge:#f0776b; --rouge-doux:#3a2020; --or:#d9b45a; }
  :root[data-palette="vert"]:not([data-theme="light"]){ --bg:#14170f; --surface:#1c2016; --surface-2:#242a1d; --texte:#e8e6da; --texte-doux:#a0a08e; --bord:#33382a; --accent:#4cb88f; --accent-doux:#1c2c24; --vert:#4cb88f; --vert-doux:#163226; --rouge:#e3897c; --rouge-doux:#33221e; --or:#d9b45a; }
}
/* ---- Sombre : forcé via le bouton 🌙 ---- */
:root[data-theme="dark"]{ --bg:#0f1218; --surface:#171b23; --surface-2:#1e232d; --texte:#e8eaf0; --texte-doux:#9098a8; --bord:#272d38; --accent:#7c83ff; --accent-doux:#232544; --vert:#34d399; --vert-doux:#12352b; --rouge:#f77066; --rouge-doux:#3a201e; --or:#e3b452; --ombre:0 1px 3px rgba(0,0,0,.4),0 10px 30px rgba(0,0,0,.45); }
:root[data-palette="terracotta"][data-theme="dark"]{ --bg:#1a1815; --surface:#232019; --surface-2:#2b271f; --texte:#ece7dd; --texte-doux:#a89f90; --bord:#38332a; --accent:#e0703f; --accent-doux:#3a2820; --vert:#5cc98a; --vert-doux:#1f3a2b; --rouge:#e8776b; --rouge-doux:#3a2320; --or:#e3b452; }
:root[data-palette="ardoise"][data-theme="dark"]{ --bg:#0d1420; --surface:#141d2b; --surface-2:#1b2636; --texte:#e6ecf5; --texte-doux:#93a3ba; --bord:#263447; --accent:#5b9bd1; --accent-doux:#1a2c40; --vert:#34d399; --vert-doux:#123528; --rouge:#f0776b; --rouge-doux:#3a2020; --or:#d9b45a; }
:root[data-palette="vert"][data-theme="dark"]{ --bg:#14170f; --surface:#1c2016; --surface-2:#242a1d; --texte:#e8e6da; --texte-doux:#a0a08e; --bord:#33382a; --accent:#4cb88f; --accent-doux:#1c2c24; --vert:#4cb88f; --vert-doux:#163226; --rouge:#e3897c; --rouge-doux:#33221e; --or:#d9b45a; }
* { box-sizing: border-box; }
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--texte);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2, h3 { margin: 0 0 .3em; font-weight: 650; }
a { color: var(--accent); }

/* ---- Barre du haut ---- */
/* Mobile : barre collée classique. Desktop (voir plus bas) : barre fixe qui se
   replie « façon iOS » — la marque disparaît au défilement vers le bas et
   réapparaît vers le haut. Le repli se fait uniquement par `transform` (header +
   contenu translatés de la même hauteur), donc AUCUN recalcul de flux et donc
   aucune boucle de scintillement. */
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--bord);
  padding: 0 clamp(12px, 3vw, 32px); position: sticky; top: 0; z-index: 20;
  box-shadow: var(--ombre);
}
.brand {
  position: relative; display: flex; flex-direction: column; align-items: center;
  text-align: center; gap: 6px; padding: 15px 0 12px;
}

@media (min-width: 561px) {
  .topbar {
    position: fixed; top: 0; left: 0; right: 0;
    transition: transform .34s cubic-bezier(.4, 0, .2, 1);
  }
  .brand { transition: opacity .24s ease; }
  /* Replié : on remonte le header ET le contenu de la hauteur de la marque.
     Les onglets se retrouvent en haut, le contenu juste dessous, sans trou. */
  body.reduit .topbar,
  body.reduit main { transform: translateY(calc(-1 * var(--brand-h, 96px))); }
  body.reduit .brand { opacity: 0; }
  @media (prefers-reduced-motion: reduce) {
    .topbar, main { transition: none; }
  }
}
.theme-btn { position: absolute; top: 13px; right: clamp(12px, 3vw, 32px); background: var(--surface-2); border: 1px solid var(--bord); color: var(--texte); border-radius: 10px; width: 40px; height: 40px; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.theme-btn:hover { border-color: var(--accent); }
.logo-fanions { display: block; line-height: 0; transform: rotate(5deg); transform-origin: center; }
.logo-fanions svg { display: block; }
.brand h1 { font-size: 20px; }
.accent-word { color: var(--accent); }
.brand .sub { margin: 0; color: var(--texte-doux); font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; font-weight: 600; }
.tabs { display: flex; gap: 4px; overflow-x: auto; justify-content: center; }
.tab {
  background: none; border: none; padding: 10px 16px; font: inherit; font-size: 14px;
  color: var(--texte-doux); cursor: pointer; border-bottom: 2.5px solid transparent;
  white-space: nowrap;
}
.tab:hover { color: var(--texte); }
.tab.actif { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab-ico, .tab-mini { display: none; }   /* visibles seulement en barre mobile */

/* ---- Contenu ---- */
main { padding: clamp(14px, 3vw, 28px); max-width: 1120px; margin: 0 auto; }
/* Desktop : réserve en haut pour le header FIXE (placé APRÈS la règle ci-dessus
   pour que le padding-top gagne dans la cascade). Repli iOS animé par transform. */
@media (min-width: 561px) {
  main {
    padding-top: calc(var(--head-h, 200px) + 16px);
    transition: transform .34s cubic-bezier(.4, 0, .2, 1);
  }
}
.vue-titre { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.vue-titre h2 { font-size: 22px; }

/* ---- Cartes stat ---- */
.grille-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat {
  background: var(--surface); border: 1px solid var(--bord); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--ombre);
}
.stat .label { color: var(--texte-doux); font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; }
.stat .valeur { font-size: 26px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .sous { font-size: 12.5px; color: var(--texte-doux); margin-top: 2px; }
.stat.accent { border-left: 4px solid var(--accent); }
.pos { color: var(--vert); } .neg { color: var(--rouge); }

/* ---- Cartes / panneaux ---- */
.carte {
  background: var(--surface); border: 1px solid var(--bord); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--ombre); margin-bottom: 18px;
}
.carte h3 { font-size: 15px; color: var(--texte-doux); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 14px; }
.deux-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
/* min-width:0 : sans ça, un enfant de grille contenant un .tableau-wrap
   s'élargit au lieu de laisser le tableau défiler → débordement horizontal (mobile). */
.deux-col > * { min-width: 0; }
@media (max-width: 780px) { .deux-col { grid-template-columns: 1fr; } }

/* ---- Boutons ---- */
.btn {
  background: var(--accent); color: #fff; border: none; border-radius: 9px;
  padding: 9px 15px; font: inherit; font-weight: 600; cursor: pointer; font-size: 14px;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { filter: brightness(1.06); }
.btn.sec { background: var(--surface-2); color: var(--texte); border: 1px solid var(--bord); }
.btn.danger { background: var(--rouge); }
.btn.mini { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

/* ---- Tableaux ---- */
.tableau-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--bord); white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--texte-doux); font-weight: 600; }
tbody tr:nth-child(even) { background: color-mix(in srgb, var(--texte) 4%, transparent); }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; }
.puce { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--bord); }
.badge-verif { background: var(--rouge-doux); color: var(--rouge); border: none; cursor: help; }

/* Chips de catégories — 8 teintes sûres (distinctes en daltonisme). Une seule teinte
   par classe ; fond doux + texte saturé dérivés par color-mix, adaptés clair/sombre. */
.puce.cat-0 { --hue: #2a78d6; } /* bleu */
.puce.cat-1 { --hue: #1baf7a; } /* aqua */
.puce.cat-2 { --hue: #c98500; } /* jaune/or */
.puce.cat-3 { --hue: #2f9e2f; } /* vert */
.puce.cat-4 { --hue: #6a5acd; } /* violet */
.puce.cat-5 { --hue: #e0453b; } /* rouge */
.puce.cat-6 { --hue: #d0559a; } /* magenta */
.puce.cat-7 { --hue: #e0703f; } /* orange */
.puce[class*="cat-"] {
  background: color-mix(in srgb, var(--hue) 14%, var(--surface));
  color: color-mix(in srgb, var(--hue) 72%, #101010);
  border-color: color-mix(in srgb, var(--hue) 26%, transparent);
}
:root[data-theme="dark"] .puce[class*="cat-"],
:root:not([data-theme="light"]) .puce[class*="cat-"] {
  background: color-mix(in srgb, var(--hue) 26%, var(--surface));
  color: color-mix(in srgb, var(--hue) 60%, #ffffff);
}

/* Éditeur de catégories (Paramètres) */
.cats-titre { font-size: 14px; margin: 0 0 4px; color: var(--texte-doux); }
.cats-liste { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.cat-row { display: flex; align-items: center; gap: 8px; }
.cat-row .cat-apercu { flex: 0 0 auto; min-width: 78px; text-align: center; }
.cat-row .cat-nom { flex: 1; min-width: 0; margin: 0; }
.cat-row .cat-suppr { flex: 0 0 auto; }

/* ---- Formulaires ---- */
label.champ { display: block; margin-bottom: 12px; }
label.champ span { display: block; font-size: 13px; color: var(--texte-doux); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--bord); border-radius: 9px;
  background: var(--surface-2); color: var(--texte); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
/* Grille unifiée recette/dépense : libellé · montant · cellule chip · retirer
   (la cellule chip est vide pour les recettes → montant et bouton alignés partout) */
.ligne-form { display: grid; grid-template-columns: 1fr 130px 120px 30px; gap: 8px; margin-bottom: 7px; align-items: center; }
.ligne-form input { margin: 0; }

/* Champ monétaire avec suffixe € */
.euro-champ { position: relative; display: block; }
.euro-champ > input { padding-right: 24px; text-align: right; }
.euro-champ::after { content: "€"; position: absolute; right: 9px; top: 50%; transform: translateY(-50%); color: var(--texte-doux); pointer-events: none; font-size: 14px; }
.justif-cell { display: flex; }
.justif-badge {
  border: 1px solid var(--bord); background: var(--surface-2); color: var(--texte-doux);
  border-radius: 20px; padding: 5px 9px; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap;
  min-width: 112px; display: inline-flex; align-items: center; justify-content: center; gap: 3px;
}
.justif-badge:hover { filter: brightness(1.05); }
.justif-badge.justif-ok { background: var(--vert-doux); color: var(--vert); border-color: transparent; }
.justif-badge.justif-manq { background: var(--rouge-doux); color: var(--rouge); border-color: transparent; }
.justif-badge.justif-todo { background: var(--accent-doux); color: var(--accent); border-color: transparent; }
.justif-badge.justif-arch { opacity: .7; }
.badge-justif { background: var(--accent-doux); color: var(--accent); border: none; }
.form-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 620px) { .form-2col { grid-template-columns: 1fr; } }
.inline-check { display: flex; align-items: center; gap: 8px; }
.inline-check input { width: auto; }

/* ---- Barres graphiques ---- */
.barres { display: flex; flex-direction: column; gap: 9px; }
.barre-ligne { display: grid; grid-template-columns: 96px 1fr auto; gap: 10px; align-items: center; font-size: 13.5px; }
.barre-piste { background: var(--surface-2); border-radius: 6px; height: 22px; position: relative; overflow: hidden; border: 1px solid var(--bord); }
.barre-fill { position: absolute; top: 0; bottom: 0; }
/* Ligne du zéro au centre de la piste (repère du signe pour les barres divergentes) */
.barres-div .barre-piste::before { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--texte-doux); opacity: .5; }
.barre-val { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 84px; text-align: right; }

/* ---- Bascule segmentée (Saison / Année) ---- */
.segment { display: inline-flex; background: var(--surface-2); border: 1px solid var(--bord); border-radius: 10px; padding: 3px; gap: 2px; }
.seg { border: none; background: none; color: var(--texte-doux); font: inherit; font-size: 13.5px; font-weight: 600; padding: 6px 13px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.seg:hover { color: var(--texte); }
.seg.actif { background: var(--accent); color: #fff; }

.select-periode { width: auto; }

/* ---- Filtres ---- */
.filtres { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filtres input, .filtres select { width: auto; }
.recherche { min-width: 200px; }

/* ---- Modale ---- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-start; justify-content: center; padding: 24px; z-index: 40; overflow-y: auto; }
.modal.cache { display: none; }
.modal-carte { background: var(--surface); border-radius: var(--radius); padding: 22px 24px; width: min(860px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.3); margin: auto; }
.modal-carte h3 { font-size: 18px; margin-bottom: 16px; text-transform: none; letter-spacing: 0; color: var(--texte); }
.modal-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; align-items: center; }
.modal-actions .droite { display: flex; gap: 10px; margin-left: auto; }

/* ---- Sections recettes/dépenses empilées (libellé pleine largeur) ---- */
.sections-lignes { display: flex; flex-direction: column; gap: 18px; }
.h3-section { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.h3-total { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.h3-toggle { cursor: pointer; user-select: none; }
.section-titre { display: inline-flex; align-items: center; gap: 5px; }
.chevron { display: inline-block; font-size: 12px; transition: transform .15s ease; }
.ligne-section:not(.collapsed) .chevron { transform: rotate(90deg); }
.ligne-section.collapsed .section-body { display: none; }
.resultat-h3 {
  margin-top: 18px; padding: 12px 14px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--bord);
  font-size: 16px; text-transform: none; letter-spacing: 0; color: var(--texte);
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
}

/* ---- Écran de connexion ---- */
.login-wrap { display: flex; justify-content: center; padding: 7vh 16px; }
.login-carte { max-width: 400px; width: 100%; text-align: center; }
.login-carte .login-logo { font-size: 44px; }
.login-carte h2 { font-size: 22px; margin-top: 6px; }
.login-carte form { text-align: left; margin-top: 16px; }

/* ---- Toast ---- */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--texte); color: var(--bg); padding: 11px 20px; border-radius: 10px; box-shadow: var(--ombre); z-index: 60; font-weight: 600; }
.toast.cache { display: none; }
.toast.err { background: var(--rouge); color: #fff; }

/* ---- Synthèse de trésorerie (bilan) ---- */
.table-synthese { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table-synthese td { padding: 9px 6px; border-bottom: 1px solid var(--bord); white-space: normal; }
.table-synthese td.num { text-align: right; min-width: 110px; white-space: nowrap; }
.table-synthese tbody tr:nth-child(even), .table-synthese tbody tr:hover { background: none; }
.table-synthese .ligne-resultat td { border-top: 1px solid var(--bord); }
.table-synthese .ligne-solde td { border-top: 2px solid var(--accent); border-bottom: none; font-size: 16px; padding-top: 12px; }

/* ---- Impression / document AG ---- */
.print-only { display: none; }

@media print {
  @page { margin: 15mm; }
  /* impression toujours en clair, quelle que soit la palette / le thème choisi */
  :root, :root[data-theme], :root[data-palette], :root[data-palette][data-theme] {
    --bg: #fff; --surface: #fff; --surface-2: #f4f4f4; --texte: #000; --texte-doux: #555; --bord: #bbb;
    --vert: #1a7a44; --rouge: #b02418; --accent: #8a3a1a; --ombre: none;
  }
  body { background: #fff; color: #000; }
  .topbar, #modal, #toast, .no-print { display: none !important; }
  .print-only { display: block !important; }
  main { max-width: none; margin: 0; padding: 0; }
  .carte { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; page-break-inside: avoid; margin-bottom: 14px; padding: 12px 14px; }
  .carte h3 { color: #000; }
  table { font-size: 11.5px; }
  tbody tr:nth-child(even) { background: none; }
  .tableau-wrap { overflow: visible; }
  .print-entete { text-align: center; margin-bottom: 16px; }
  .print-entete h1 { font-size: 22px; margin: 0; }
  .print-soustitre { font-size: 14px; color: #333; margin-top: 4px; }
  .print-date { font-size: 12px; color: #666; margin-top: 2px; }
  .print-signatures { display: flex !important; justify-content: space-around; margin-top: 34px; break-inside: avoid; }
  .sign-bloc { text-align: center; width: 40%; }
  .sign-role { font-weight: 600; margin-bottom: 44px; }
  .sign-ligne { border-top: 1px solid #333; }
}

/* ---- Divers ---- */
.vide { text-align: center; color: var(--texte-doux); padding: 40px 20px; }
.mono { font-variant-numeric: tabular-nums; }
.aide { font-size: 13px; color: var(--texte-doux); background: var(--surface-2); border: 1px solid var(--bord); border-radius: 9px; padding: 10px 13px; margin-bottom: 14px; }
.legende { display: flex; gap: 16px; font-size: 13px; color: var(--texte-doux); flex-wrap: wrap; }
.legende span::before { content: "●"; margin-right: 5px; }
.pt-rec::before { color: var(--vert); } .pt-dep::before { color: var(--rouge); } .pt-ben::before { color: var(--accent); }

/* ---- Sélecteur de palette (Paramètres) ---- */
.palette-grille { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 4px; }
.palette-choix { display: flex; align-items: center; gap: 10px; padding: 8px 11px; border: 1.5px solid var(--bord); border-radius: 12px; background: var(--surface-2); color: var(--texte); font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; text-align: left; }
.palette-choix:hover { border-color: var(--accent); }
.palette-choix.actif { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-doux); }
.palette-apercu { width: 42px; height: 30px; border-radius: 8px; flex: none; display: flex; align-items: center; justify-content: center; gap: 4px; border: 1px solid rgba(0,0,0,.15); }
.palette-apercu i { width: 8px; height: 8px; border-radius: 50%; display: block; }

/* ============================================================ */
/*  Adaptations mobile                                          */
/* ============================================================ */
@media (max-width: 560px) {
  html, body { overflow-x: hidden; }
  main { padding: 14px 12px 84px; }   /* place pour la barre de nav du bas */
  .brand h1 { font-size: 17px; }
  .brand .logo { font-size: 26px; }
  .theme-btn { width: 36px; height: 36px; }

  /* Barre de navigation fixée en bas (façon appli mobile) */
  .tabs {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--bord);
    box-shadow: 0 -2px 8px rgba(0,0,0,.08);
    display: flex; gap: 0; overflow: visible;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .tab {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 8px 2px 6px; border-bottom: none; font-size: 10.5px;
  }
  .tab-ico { display: block; font-size: 19px; line-height: 1; }
  .tab-full { display: none; }
  .tab-mini { display: block; }
  .tab.actif { border-bottom: none; }

  /* Fenêtres modales : moins de marge, plus de place */
  .modal { padding: 8px; align-items: stretch; }
  .modal-carte { padding: 18px 15px; border-radius: 12px; }
  .modal-carte h3 { font-size: 16.5px; }

  /* Lignes : libellé pleine largeur en haut, puis montant · chip · suppr. dessous */
  .ligne-form {
    grid-template-columns: 130px 1fr 30px;
    grid-template-areas: "lib lib lib" "mnt jus del";
    row-gap: 6px;
  }
  .ligne-form > [data-champ="libelle"] { grid-area: lib; }
  .ligne-form > .euro-champ { grid-area: mnt; }
  .ligne-form > .justif-cell { grid-area: jus; justify-self: start; }
  .ligne-form > button { grid-area: del; }

  /* Cartes stat : une seule colonne, un peu plus compactes */
  .grille-stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 13px 14px; }
  .stat .valeur { font-size: 21px; }

  /* Boutons d'action de la modale : Supprimer en haut (évite les mauvaises manip),
     puis Annuler / Enregistrer côte à côte en dessous */
  .modal-actions { flex-direction: column; align-items: stretch; gap: 10px; }
  .modal-actions > .btn.danger { width: 100%; }
  .modal-actions .droite { margin-left: 0; }
  .modal-actions .droite .btn { flex: 1; }

  .vue-titre h2 { font-size: 19px; }
  .segment { width: 100%; }
  .segment .seg { flex: 1; }

  /* Grands tableaux : figer la 1re colonne (libellé) pendant le défilement horizontal */
  .tableau-wrap table th:first-child,
  .tableau-wrap table td:first-child {
    position: sticky; left: 0; z-index: 1;
    background: var(--surface);
    box-shadow: 1px 0 0 var(--bord);
  }
  thead th:first-child { z-index: 2; }

  /* Mini-graphiques : libellé plus compact, valeur moins large */
  .barre-ligne { grid-template-columns: 74px 1fr auto; gap: 7px; font-size: 12.5px; }
  .barre-val { min-width: 0; }
}
@media (max-width: 380px) {
  .grille-stats { grid-template-columns: 1fr; }
}
