:root {
  --green-900: #1e3a24;
  --green-700: #2f5233;
  --green-600: #3d6b42;
  --green-100: #eef4ea;
  --amber-500: #b8860b;
  /* Palette chaleureuse inspirée du logo EARL (fleurs souci/cosmos) et du futur logo
     Forez Botanica (marguerite dorée) - utilisée pour les CTA, badges d'icône et
     touches d'accent, en complément du vert qui reste la couleur de marque/nav. */
  --gold-500: #d99a1f;
  --gold-600: #b98418;
  --terracotta-500: #e0783a;
  --terracotta-600: #c25f26;
  --plum-500: #a45ea8;
  --blue-600: #3a72a6;
  --red-600: #b91c1c;
  --gray-50: #fafaf8;
  --gray-100: #f2f1ed;
  --gray-200: #e5e3dc;
  --gray-500: #767467;
  --gray-800: #2b2a25;
  --radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--gray-50); color: var(--gray-800); }
a { color: var(--green-700); }

/* ---- Login screen ---- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--green-900), var(--green-600));
}
.login-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 40px 36px;
  text-align: center;
  max-width: 360px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.login-logo { width: 140px; height: auto; margin: 0 auto 16px; display: block; }
.login-card h1 { font-size: 20px; margin: 0 0 4px; color: var(--green-900); }
.muted { color: var(--gray-500); margin: 4px 0 20px; }
.muted.small { font-size: 12px; margin-top: 16px; }

/* ---- Buttons ---- */
.btn {
  display: inline-block;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  background: #fff;
  color: var(--gray-800);
  cursor: pointer;
  font-size: 13.5px;
  text-decoration: none;
  line-height: 1.3;
}
.btn:hover { border-color: var(--green-600); }
.btn-primary {
  background: linear-gradient(135deg, var(--gold-500), var(--terracotta-500));
  color: #fff; border-color: transparent; font-weight: 600;
  box-shadow: 0 2px 8px rgba(224, 120, 58, 0.3);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--gold-600), var(--terracotta-600));
  box-shadow: 0 4px 12px rgba(224, 120, 58, 0.4);
}
.btn-danger { color: var(--red-600); border-color: var(--red-600); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-sm.btn-primary { box-shadow: none; }
.btn-outline { background: transparent; border-color: var(--green-600); color: var(--green-700); }
.btn-block { display: block; width: 100%; text-align: center; margin-top: 10px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* Rangées d'actions denses (ex. table Devis) : icônes seules + tooltip natif (title)
   plutôt qu'un bouton texte par action, pour ne pas exploser la largeur de la colonne. */
.actions-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.mouvement-lien-inline, .mouvement-autres-actions { display: inline-flex; align-items: center; gap: 6px; }
.mouvement-lien-inline[hidden], .mouvement-autres-actions[hidden] { display: none; }
.mouvement-lien-inline select { width: auto; }
/* [hidden] seul ne suffit pas : une feuille auteur (display:inline-flex ci-dessous)
   bat toujours la feuille par défaut du navigateur, même à spécificité égale - même
   piège que .aide-panneau (voir plus haut). */
.btn-icon[hidden] { display: none; }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0;
  border-radius: 6px; border: 1px solid var(--gray-200);
  background: #fff; color: var(--gray-800); cursor: pointer;
}
.btn-icon .icon { width: 16px; height: 16px; }
.btn-icon:hover { border-color: var(--green-600); background: var(--gray-100); }
.btn-icon.primary {
  background: linear-gradient(135deg, var(--gold-500), var(--terracotta-500));
  border-color: transparent; color: #fff;
}
.btn-icon.primary:hover { background: linear-gradient(135deg, var(--gold-600), var(--terracotta-600)); }
.btn-icon.danger { color: var(--red-600); border-color: var(--red-200, var(--red-600)); }
.btn-icon.danger:hover { background: #fdecec; }
/* Actions positives (accepter un devis, marquer une facture payée) - même vert que .pill-green. */
.btn-icon.success { color: var(--green-700); border-color: var(--green-600); }
.btn-icon.success:hover { background: #dcf0dc; }
/* Émettre un avoir : de l'argent qui repart, mérite d'attirer l'œil sans être une alerte -
   même ambre que .pill-amber. */
.btn-icon.warn { color: var(--amber-500); border-color: var(--amber-500); }
.btn-icon.warn:hover { background: #fbe9c8; }
/* Envoi par mail : catégorie "communication", distincte des actions de cycle de vie. */
.btn-icon.info { color: var(--blue-600); border-color: var(--blue-600); }
.btn-icon.info:hover { background: #e4edf4; }

/* Menu "⋮" des actions secondaires (Devis/Factures) - voir attachActionMenuHandlers.
   .action-menu est juste le gabarit caché à côté du déclencheur (jamais affiché tel
   quel) ; .action-menu-popup est le vrai menu flottant, déplacé dans document.body au
   clic pour échapper au overflow du tableau. */
.action-menu-wrap { position: relative; display: inline-flex; }
.action-menu[hidden] { display: none; }
.action-menu-popup {
  position: fixed; z-index: 300;
  background: #fff; border: 1px solid var(--gray-200); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14); min-width: 175px; padding: 4px;
}
.action-menu-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 7px 10px; border: none; background: none; border-radius: 6px;
  font-size: 13px; color: var(--gray-800); cursor: pointer; text-align: left;
}
.action-menu-item:hover { background: var(--gray-100); }
.action-menu-item .icon { width: 16px; height: 16px; flex-shrink: 0; color: var(--gray-500); }
.action-menu-item.danger { color: var(--red-600); }
.action-menu-item.danger:hover { background: #fdecec; }
.action-menu-item.danger .icon { color: var(--red-600); }
.action-menu-item.warn { color: var(--amber-500); }
.action-menu-item.warn:hover { background: #fbe9c8; }
.action-menu-item.warn .icon { color: var(--amber-500); }

/* ---- App shell ---- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 210px;
  background: var(--green-900);
  color: #fff;
  padding: 0 14px 20px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  /* Reste à sa place pendant que la page défile (menu plus haut que l'écran) - sans ça,
     cliquer un lien tout en bas du menu laissait la nouvelle page affichée en plein
     milieu/bas de l'écran au lieu de repartir du haut. Défile elle-même si son propre
     contenu (logo + nav + pied) dépasse la hauteur de la fenêtre. */
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
/* Panneau blanc en tête de sidebar : le logo (fond clair, pas de transparence) était
   posé directement sur le vert foncé et faisait tache incrustée - il repose maintenant
   sur son propre bandeau clair, bords arrondis en bas pour la transition vers le vert. */
.sidebar-header {
  display: block;
  background: #fff;
  margin: 0 -14px 16px;
  padding: 22px 14px 16px;
  border-radius: 0 0 18px 18px;
  text-align: center;
  text-decoration: none;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.18);
  transition: box-shadow 0.15s ease;
}
.sidebar-header:hover { box-shadow: 0 6px 14px rgba(0, 0, 0, 0.3); }
.sidebar-logo { width: 100%; max-width: 130px; height: auto; display: block; margin: 0 auto 10px; border-radius: 6px; }
.sidebar-header h2 { font-size: 15px; margin: 0 0 4px; color: var(--green-900); }
.sidebar-header .muted { color: var(--gray-500); font-size: 11.5px; margin: 0; }
.sidebar-nav { flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 10px;
  border-radius: 6px;
  color: #d7e6d5;
  text-decoration: none;
  font-size: 13.5px;
  margin-bottom: 2px;
  cursor: pointer;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.08); }
.nav-item.active {
  background: rgba(255, 255, 255, 0.13);
  color: #fff;
  font-weight: 600;
  border-left-color: var(--gold-500);
}
.nav-item .icon { flex-shrink: 0; opacity: 0.85; }
.nav-item.active .icon { opacity: 1; color: var(--gold-500); }
.sidebar-footer { margin-top: 12px; border-top: 1px solid rgba(255, 255, 255, 0.15); padding-top: 12px; }
.sidebar-footer a { display: flex; align-items: center; gap: 8px; color: #b9ceb8; font-size: 12px; }

.icon { width: 18px; height: 18px; }
.mobile-menu-btn .icon { width: 22px; height: 22px; }

.main { flex: 1; padding: 28px 34px; max-width: 1100px; min-width: 0; }
.main h1 { display: flex; align-items: center; gap: 12px; font-size: 21px; margin: 0 0 18px; color: var(--green-900); }
.page-icon {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--gold-500), var(--terracotta-500));
  color: #fff;
}
.page-icon .icon { width: 19px; height: 19px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 10px; flex-wrap: wrap; }
.toolbar-search { width: 240px; flex: 0 1 240px; }
.toolbar select, .filter-bar select { width: auto; flex: 0 0 auto; }

/* Rangée secondaire sous le toolbar (recherche + filtres de statut/paiement) - séparée
   du titre+bouton principal pour ne pas se retrouver à mi-hauteur d'un titre sur deux
   lignes (badge année) quand ça passe à la ligne sur un écran étroit. */
.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }

/* ---- Mobile top bar (hidden on desktop) ---- */
.mobile-topbar { display: none; }

/* ---- Cards / tables ---- */
.card { background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--gray-100); }
th { color: var(--gray-500); font-weight: 600; font-size: 11.5px; text-transform: uppercase; }
tr:hover td { background: var(--gray-50); }
td.num, th.num { text-align: right; }

/* Tables are data-dense (up to 7-8 columns) - on a narrow viewport they scroll
   horizontally inside their own container rather than squeezing/wrapping every cell,
   which would make amounts and status pills unreadable on a phone. */
/* overflow-y:visible explicite - sans lui, fixer overflow-x:auto seul convertit
   implicitement overflow-y en 'auto' aussi (règle CSS peu connue), ce qui coupait le
   menu ⋮ (position:absolute) dès qu'il dépassait la hauteur du tableau. */
.table-scroll { overflow-x: auto; overflow-y: visible; -webkit-overflow-scrolling: touch; }
.table-scroll > table { min-width: 640px; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.pill-gray { background: var(--gray-100); color: var(--gray-500); }
.pill-green { background: #dcf0dc; color: var(--green-700); }
.pill-amber { background: #fbe9c8; color: var(--amber-500); }
.pill-red { background: #fbdada; color: var(--red-600); }

/* ---- Forms ---- */
label { display: block; font-size: 12.5px; color: var(--gray-500); margin: 10px 0 4px; }
input, select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 13.5px;
  font-family: inherit;
  background: #fff;
}
textarea { resize: vertical; }
input[type="checkbox"] { width: auto; padding: 0; accent-color: var(--green-700); cursor: pointer; }
.form-row { display: flex; gap: 12px; }
.form-row > * { flex: 1; }
fieldset { border: 1px solid var(--gray-200); border-radius: var(--radius); margin: 16px 0; padding: 14px 16px; }
legend { font-size: 12.5px; color: var(--gray-500); padding: 0 6px; }

.lignes-table th, .lignes-table td { padding: 6px 8px; }
.lignes-table input, .lignes-table select { padding: 5px 7px; font-size: 13px; }
.col-desc { width: 34%; }
.col-num { width: 11%; }

.month-year-nav { display: flex; align-items: center; gap: 8px; }
.month-year-nav select { width: auto; }

.toolbar-actions-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.annee-nav { display: flex; align-items: center; gap: 6px; }
/* width fixe (pas "auto") : un <select> "auto" se dimensionne sur son option la plus
   large ("Toutes années"), ce qui donnait une case bien trop large et un "2026" plaqué
   à gauche au lieu d'être centré. La liste déroulante, elle, reste lisible en entier
   une fois ouverte même si elle dépasse la largeur de la case fermée. */
.annee-nav select { width: 92px; text-align: center; text-align-last: center; }
.annee-nav select.annee-actuelle {
  background: linear-gradient(135deg, var(--gold-500), var(--terracotta-500));
  color: #fff; border-color: transparent; font-weight: 700;
}

.piece-journal { border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; }
.piece-journal-header { margin-bottom: 8px; font-size: 13.5px; }

/* ---- Tableau de bord (Accueil) ---- */
.dash-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.dash-card {
  display: block; background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius);
  padding: 16px 18px; text-decoration: none; color: inherit;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.dash-card:hover { box-shadow: 0 5px 16px rgba(0, 0, 0, 0.09); transform: translateY(-1px); border-color: var(--gray-200); }
.dash-card-alert { border-color: var(--amber-500); background: #fffaf0; }
.dash-card-label { display: flex; align-items: center; gap: 9px; font-size: 12px; color: var(--gray-500); margin-bottom: 10px; }
.dash-icon-badge {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 30px; height: 30px; border-radius: 8px;
}
.dash-icon-badge .icon { width: 16px; height: 16px; }
.dash-icon-badge.c-green { background: var(--green-100); color: var(--green-700); }
.dash-icon-badge.c-gold { background: #fdf1dc; color: var(--gold-600); }
.dash-icon-badge.c-terracotta { background: #fbe6da; color: var(--terracotta-600); }
.dash-icon-badge.c-blue { background: #e4edf4; color: var(--blue-600); }
.dash-icon-badge.c-plum { background: #f3e6f4; color: var(--plum-500); }
.dash-icon-badge.c-red { background: #fbdada; color: var(--red-600); }
.dash-card-value { font-size: 22px; font-weight: 700; color: var(--green-900); }
.dash-card-sub { font-size: 11.5px; color: var(--gray-500); margin-top: 3px; }

.chart-bars { position: relative; display: flex; align-items: flex-end; }
.chart-bar-col {
  position: absolute; bottom: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: flex-end; height: 100%; padding: 0 4px;
}
.chart-bar { width: 100%; max-width: 34px; background: var(--green-600); border-radius: 4px 4px 0 0; }
.chart-bar-neg { background: var(--red-600); }
.chart-bar-value { font-size: 10px; color: var(--gray-500); margin-bottom: 4px; white-space: nowrap; }
.chart-bar-label { font-size: 11px; color: var(--gray-500); margin-top: 6px; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 20, 15, 0.45);
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 20px;
  overflow-y: auto; z-index: 50;
}
.modal { background: #fff; border-radius: var(--radius); padding: 24px 28px; width: 100%; max-width: 640px; }
/* Devis/facture : la table de lignes (min-width 640px) ne tenait pas dans la modale
   standard (640px - 56px de padding = 584px de large disponible) et forçait un
   ascenseur horizontal même en plein écran desktop. Modale un peu plus large pour ces
   deux formulaires uniquement (les autres modales restent compactes). */
.modal.modal-wide { max-width: 740px; }
.modal h2 { margin-top: 0; font-size: 17px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.toast {
  position: fixed; bottom: 20px; right: 20px; background: var(--gray-800); color: #fff;
  padding: 10px 16px; border-radius: 6px; font-size: 13px; z-index: 100; max-width: 360px;
}
.toast.error { background: var(--red-600); }

/* Overlay plein écran affiché pendant un traitement long (upload + OCR d'un
   document) - sans ça l'utilisateur ne sait pas si son clic a bien été pris
   en compte (retour du 2026-07-31). */
.global-loading {
  position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
  background: rgba(255,255,255,0.85); color: var(--gray-700); font-size: 14px; font-weight: 600;
}
.global-loading[hidden] { display: none; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 4px solid var(--gray-200); border-top-color: var(--green-600);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; padding: 40px 0; color: var(--gray-500); }

.suivi-liste { list-style: none; margin: 0; padding: 0; }
.suivi-liste li {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--gray-100); font-size: 13.5px;
}
.suivi-liste li:last-child { border-bottom: none; }

/* ---- Dropzone (achats/notes de frais) ---- */
.dropzone {
  display: flex; align-items: center; justify-content: center; text-align: center;
  background: transparent; border: 2px dashed var(--gray-200); color: var(--gray-500);
  padding: 28px 20px; border-radius: var(--radius); cursor: pointer;
  font-size: 13.5px; font-weight: 600; width: 100%; margin-bottom: 16px;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--green-600); color: var(--green-700); }
.preview-frame { width: 100%; height: 260px; border: 1px solid var(--gray-200); border-radius: 6px; }
.preview-img { max-width: 100%; border-radius: 6px; display: block; margin: 10px 0; }
.totals-box { margin-left: auto; width: 260px; font-size: 13.5px; }
.totals-box .row { display: flex; justify-content: space-between; padding: 4px 0; }
.totals-box .row.final { border-top: 1px solid var(--gray-200); margin-top: 4px; padding-top: 8px; font-weight: 700; font-size: 15px; }

/* ==================================================================
   Responsive - tablette (≤900px) et smartphone (≤600px).
   La sidebar fixe devient un tiroir escamotable derrière un bouton
   hamburger dans une barre du haut, pour laisser toute la largeur au
   contenu (tableaux, formulaires) sur petit écran.
   ================================================================== */
@media (max-width: 900px) {
  .shell { position: relative; }
  .mobile-topbar {
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 40;
    background: var(--green-900); color: #fff; padding: 12px 16px;
  }
  .mobile-topbar .mobile-topbar-title {
    font-size: 15px; font-weight: 600; flex: 1; text-align: center;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 8px;
  }
  .mobile-menu-btn {
    background: rgba(255, 255, 255, 0.12); border: none; color: #fff;
    width: 38px; height: 38px; border-radius: 6px; font-size: 18px; cursor: pointer;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  }
  .shell { flex-direction: column; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 45; width: 240px; max-width: 80vw;
    overflow-y: auto; transform: translateX(-100%); transition: transform 0.2s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4); z-index: 44;
  }
  .sidebar-backdrop.open { display: block; }
  .main { padding: 18px; max-width: 100%; }
  .nav-item { padding: 13px 12px; font-size: 15px; }

  .form-row { flex-direction: column; gap: 0; }
  .modal-backdrop { padding: 0; align-items: stretch; }
  .modal, .modal.modal-wide { max-width: 100%; min-height: 100%; border-radius: 0; padding: 18px 16px 28px; }
  .totals-box { width: 100%; }
  .preview-frame { height: 200px; }
}

@media (max-width: 480px) {
  .login-card { padding: 28px 20px; max-width: 100%; }
  .btn { padding: 10px 14px; }
  .toolbar .btn, .toolbar > div .btn { flex: 1 1 auto; }
  /* Le titre de page (icône + texte) prend toute la largeur pour se caler sur sa
     propre ligne - sinon, comme item flex à côté d'un bouton/filtre dans .toolbar, il
     se compresse au lieu de laisser le bouton passer proprement à la ligne suivante. */
  .toolbar h1 { flex: 1 1 100%; font-size: 18px; }
  .toolbar h1 .page-icon { width: 30px; height: 30px; }
  .toolbar-actions-right { flex: 1 1 100%; }
  .toolbar-search { flex: 1 1 auto; width: auto; }
  .toolbar select { flex: 1 1 auto; }
}

/* Éditeur de lignes (devis/facture) : au lieu de forcer un ascenseur horizontal comme
   les autres tableaux (7 colonnes, min-width 640px - trop large sur un petit écran),
   chaque ligne devient une mini-carte empilée avec ses champs en grille 2 colonnes,
   donc tout reste visible sans défiler latéralement. */
@media (max-width: 740px) {
  .lignes-scroll { overflow-x: visible; }
  /* Sélecteur volontairement aussi spécifique que `.table-scroll > table` (règle de base,
     min-width:640px) - le conteneur porte les deux classes `table-scroll lignes-scroll`,
     donc un simple `.lignes-table { min-width: 0 }` (moins spécifique) perdait le combat
     de spécificité CSS et restait bloqué à 640px de large malgré cette media query
     (constaté réellement : la modale facture débordait encore sur mobile). */
  .table-scroll.lignes-scroll > .lignes-table { min-width: 0; }
  .lignes-table thead { display: none; }
  .lignes-table, .lignes-table tbody { display: block; width: 100%; }
  .lignes-table tr.ligne-row {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px;
    border: 1px solid var(--gray-200); border-radius: var(--radius);
    padding: 12px 12px 10px; margin-bottom: 10px; background: #fff;
  }
  .lignes-table tr.ligne-row td { display: block; padding: 0; border-bottom: none; width: auto; }
  .lignes-table tr.ligne-row td.col-desc { grid-column: 1 / -1; }
  .lignes-table tr.ligne-row td.ligne-montant { grid-column: 1 / -1; font-weight: 700; }
  .lignes-table tr.ligne-row td.col-remove { grid-column: 1 / -1; text-align: right; }
  .lignes-table td[data-label]::before {
    content: attr(data-label); display: block; font-size: 11px; font-weight: 600;
    color: var(--gray-500); text-transform: uppercase; margin-bottom: 3px;
  }
}

/* Tableaux de données génériques (Tiers, Factures, Devis, Achats, Banque, Comptabilité,
   Immobilisations, TVA...) : même principe que l'éditeur de lignes ci-dessus, mais en
   liste "étiquette: valeur" plutôt qu'en grille 2 colonnes, vu le nombre de colonnes très
   variable d'un tableau à l'autre. Les `data-label` sont posés automatiquement par
   applyResponsiveTableLabels() dans app.js à partir du texte des <th>, donc ce bloc CSS
   s'applique à tout tableau de l'appli sans édition au cas par cas. `.lignes-table` est
   explicitement exclu : il garde sa mise en page grille dédiée ci-dessus. */
@media (max-width: 700px) {
  .table-scroll { overflow-x: visible; }
  .table-scroll table:not(.lignes-table) { min-width: 0; }
  .table-scroll table:not(.lignes-table) thead { display: none; }
  .table-scroll table:not(.lignes-table),
  .table-scroll table:not(.lignes-table) tbody { display: block; width: 100%; }
  .table-scroll table:not(.lignes-table) tr {
    display: block; border: 1px solid var(--gray-200); border-radius: var(--radius);
    padding: 10px 12px; margin-bottom: 10px; background: #fff;
  }
  .table-scroll table:not(.lignes-table) tr:hover td { background: transparent; }
  .table-scroll table:not(.lignes-table) td {
    display: flex; justify-content: flex-end; align-items: center; gap: 10px;
    padding: 6px 0; border-bottom: 1px dashed var(--gray-100); text-align: right;
  }
  .table-scroll table:not(.lignes-table) td:last-child { border-bottom: none; }
  .table-scroll table:not(.lignes-table) td[data-label] { justify-content: space-between; }
  .table-scroll table:not(.lignes-table) td[data-label]::before {
    content: attr(data-label); font-size: 11px; font-weight: 600; color: var(--gray-500);
    text-transform: uppercase; text-align: left; flex-shrink: 0;
  }
}

/* ---- Centre d'aide (recherche par mots-clés, voir AIDE_ENTREES dans app.js) ---- */
.aide-bouton {
  position: fixed; right: 20px; bottom: 20px; z-index: 60;
  width: 48px; height: 48px; border-radius: 50%; border: none;
  background: linear-gradient(135deg, var(--gold-500), var(--terracotta-500));
  color: #fff; font-size: 20px; font-weight: 700; cursor: pointer;
  box-shadow: 0 4px 14px rgba(224, 120, 58, 0.4);
}
.aide-bouton:hover { box-shadow: 0 6px 18px rgba(224, 120, 58, 0.5); }
.aide-panneau {
  position: fixed; right: 20px; bottom: 78px; z-index: 60;
  width: 360px; max-width: calc(100vw - 40px); max-height: min(560px, calc(100vh - 120px));
  background: #fff; border-radius: var(--radius); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
  display: flex; flex-direction: column; overflow: hidden;
}
/* Sans ce override, [hidden] (attribut HTML natif, display:none par défaut du
   navigateur) est battu par le display:flex explicite ci-dessus (même spécificité,
   feuille de style auteur toujours prioritaire sur la feuille par défaut du
   navigateur) - le panneau restait affiché en permanence, ouvert au chargement de la
   page, constaté réellement en production. */
.aide-panneau[hidden] { display: none; }
.aide-panneau-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--gray-200); flex-shrink: 0;
}
.aide-panneau #aide-recherche { margin: 10px 14px; width: calc(100% - 28px); flex-shrink: 0; }
.aide-resultats { overflow-y: auto; padding: 0 14px 14px; }
.aide-fiche { padding: 10px 0; border-bottom: 1px solid var(--gray-100); }
.aide-fiche:last-child { border-bottom: none; }
.aide-fiche h4 { margin: 0 0 4px; font-size: 13.5px; color: var(--green-900); }
.aide-fiche p { margin: 0; font-size: 12.5px; color: var(--gray-800); line-height: 1.5; }

@media (max-width: 480px) {
  .aide-panneau { right: 12px; left: 12px; width: auto; bottom: 74px; }
  .aide-bouton { right: 16px; bottom: 16px; }
}
