/* =====================================================================
   Innovibe ERP — feuille de style
   ---------------------------------------------------------------------
   Organisation :
     1. Jetons (clair, puis sombre)       6. Formulaires et boutons
     2. Base et typographie               7. Composants (etiquettes, onglets...)
     3. Marque : logotype, orbites        8. Pages (tableau de bord, documents...)
     4. Coque : barre laterale, haut      9. Animations
     5. Cartes, grilles, tableaux        10. Mouvement reduit, impression

   Les couleurs sont celles de l'identite INNOVIBE (public/identity.html,
   DESIGN.md) : marine, turquoise, blanc, or en accent. Les documents PDF
   portent les memes : l'ecran et le papier restent la meme marque.

   Une regle pour le theme sombre : aucune couleur n'est ecrite en dur
   dans les composants. Tout passe par un jeton, redefini pour le sombre.
   `--navy` designe la couleur du texte fort (titres, montants) et
   s'eclaircit en sombre ; le marine de marque, qui sert de fond, est
   `--marque`. Seule exception : les panneaux marine (barre laterale,
   marque de la connexion), identiques dans les deux themes, ecrivent
   leurs blancs attenues en dur.
   ===================================================================== */

/* ------------------------------------------------------------------ */
/* 1. Jetons                                                          */
/* ------------------------------------------------------------------ */
:root {
  color-scheme: light;

  /* Valeurs de l'identite (public/identity.html, DESIGN.md). Contrastes
     controles par tests/verif-palette.php, en clair et en sombre. */
  --fond:        #f4f7fa;   /* brume : page */
  --surface:     #ffffff;   /* cartes */
  --surface-2:   #f6f9fb;   /* en-tetes de tableau, zones douces */
  --survol:      #edf3f7;
  --soft:        var(--surface-2);   /* nom historique, garde pour les vues */

  --ink:         #1d3349;   /* texte courant */
  --navy:        #102b47;   /* texte fort : titres, montants */
  --muted:       #607387;   /* texte secondaire, 4.5:1 sur la brume */
  --line:        #d9e2eb;
  --line-forte:  #bccbd9;

  --marque:      #102b47;   /* marine de marque, en fond */
  --marque-point: #00a6ae;  /* couleur invariante du logotype */
  --marque-signature: #68d9de;
  --accent:      #00a6ae;   /* turquoise : point du logo, filets, focus */
  --lien:        #007c84;   /* turquoise lisible en texte */
  --gold:        #c99a22;   /* or : accent secondaire, avec retenue */

  --primaire:    #102b47;
  --primaire-survol: #1c4164;
  --sur-primaire: #ffffff;

  --green:       #17804a;
  --warn:        #a8620f;
  --danger:      #b02e32;

  /* Departements : repli quand la base ne fournit pas de couleur. */
  --dep-it:      #00a6ae;
  --dep-meca:    #c99a22;
  --dep:         var(--accent);   /* departement actif ; pose sur <body> */

  /* Graphique : annee en cours / annee precedente (objets, 3:1). */
  --serie-1:     #0096a0;
  --serie-2:     #607387;

  /* Types de document. Texte lisible sur fond teinte. */
  --type-devis:   #006b72;
  --type-facture: #102b47;
  --type-avoir:   #7d5c10;

  --rayon:       12px;
  --rayon-petit: 9px;
  --ombre:       0 1px 2px rgba(16, 43, 71, 0.04), 0 8px 24px -16px rgba(16, 43, 71, 0.18);
  --ombre-haute: 0 2px 4px rgba(16, 43, 71, 0.05), 0 20px 40px -22px rgba(16, 43, 71, 0.30);
  --anneau:      0 0 0 3px rgba(0, 166, 174, 0.30);

  --sidebar-width: 260px;
  --topbar-height: 64px;

  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Le sombre : choisi explicitement, ou suivi du systeme quand rien n'est
   choisi. Les deux blocs sont identiques — le CSS ne sait pas partager un
   bloc entre un selecteur et une requete media. */
:root[data-theme="dark"] {
  color-scheme: dark;

  --fond: #0a1626; --surface: #10233a; --surface-2: #142a44; --survol: #183150;
  --ink: #d5dee8; --navy: #f2f6fa; --muted: #93a6b9; --line: #1f3550; --line-forte: #2b4664;
  --marque: #071322; --accent: #1fb8c0; --lien: #4fd3d9; --gold: #d9ae3c;
  --primaire: #1fb8c0; --primaire-survol: #4fd3d9; --sur-primaire: #102b47;
  --green: #3cc47f; --warn: #e4a14a; --danger: #f0776b;
  --dep-it: #1fb8c0; --dep-meca: #d9ae3c;
  --serie-1: #1fb8c0; --serie-2: #6f86a0;
  --type-devis: #4fd3d9; --type-facture: #d5dee8; --type-avoir: #d9ae3c;
  --ombre: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px -18px rgba(0, 0, 0, 0.7);
  --ombre-haute: 0 2px 6px rgba(0, 0, 0, 0.35), 0 24px 48px -20px rgba(0, 0, 0, 0.8);
  --anneau: 0 0 0 3px rgba(31, 184, 192, 0.38);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --fond: #0a1626; --surface: #10233a; --surface-2: #142a44; --survol: #183150;
    --ink: #d5dee8; --navy: #f2f6fa; --muted: #93a6b9; --line: #1f3550; --line-forte: #2b4664;
    --marque: #071322; --accent: #1fb8c0; --lien: #4fd3d9; --gold: #d9ae3c;
    --primaire: #1fb8c0; --primaire-survol: #4fd3d9; --sur-primaire: #102b47;
    --green: #3cc47f; --warn: #e4a14a; --danger: #f0776b;
    --dep-it: #1fb8c0; --dep-meca: #d9ae3c;
    --serie-1: #1fb8c0; --serie-2: #6f86a0;
    --type-devis: #4fd3d9; --type-facture: #d5dee8; --type-avoir: #d9ae3c;
    --ombre: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px -18px rgba(0, 0, 0, 0.7);
    --ombre-haute: 0 2px 6px rgba(0, 0, 0, 0.35), 0 24px 48px -20px rgba(0, 0, 0, 0.8);
    --anneau: 0 0 0 3px rgba(31, 184, 192, 0.38);
  }
}

/* ------------------------------------------------------------------ */
/* 2. Base et typographie                                             */
/* ------------------------------------------------------------------ */
/* Fira Sans auto-hebergee (licence OFL dans fonts/). Deux fichiers
   seulement : toutes les graisses de cette feuille valent 400 ou 700. */
@font-face { font-family: "Fira Sans"; src: url('fonts/FiraSans-Regular.ttf') format("truetype"); font-style: normal; font-weight: 400; font-display: swap; }
@font-face { font-family: "Fira Sans"; src: url('fonts/FiraSans-Bold.ttf') format("truetype"); font-style: normal; font-weight: 700; font-display: swap; }

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Fira Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--fond);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

h1 { color: var(--navy); font-size: 28px; font-weight: 700; margin: 0 0 4px; letter-spacing: -0.02em; line-height: 1.2; text-wrap: balance; }
h2 { color: var(--navy); font-size: 16px; font-weight: 700; margin: 0 0 12px; letter-spacing: -0.01em; }
h3 { color: var(--navy); font-size: 14px; font-weight: 700; margin: 0 0 8px; }
p  { margin: 0 0 10px; }

a { color: var(--lien); text-decoration: none; text-underline-offset: .22em; transition: color 0.15s ease; }
a:hover { color: var(--navy); }

strong { color: var(--navy); font-weight: 700; }
code, kbd, pre { font-family: "Fira Mono", ui-monospace, SFMono-Regular, Menlo, monospace; }
code { font-size: 0.9em; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }

:focus-visible { outline: 2px solid var(--lien); outline-offset: 3px; border-radius: var(--rayon-petit); }
.sidebar :focus-visible { outline-color: var(--marque-signature); }

::selection { background: color-mix(in srgb, var(--accent) 25%, var(--surface)); color: var(--navy); }
input, textarea { caret-color: var(--lien); }
html { scrollbar-color: var(--line-forte) var(--fond); }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icone {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
  vertical-align: -0.22em;
}

.sous-titre { color: var(--muted); font-size: 14px; margin: 0 0 14px; }
.aide { font-size: 12.5px; color: var(--muted); }
.a-droite { text-align: right; }
.nombre { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.mono { font-family: "Fira Mono", ui-monospace, monospace; font-size: 12.5px; color: var(--muted); }
td.mono { white-space: nowrap; }

.visuellement-cache {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

[hidden] { display: none !important; }

/* L'habillage de l'interface ne se selectionne pas : un double-clic sur un
   bouton ou le menu ne surligne plus rien. Les donnees (numeros, noms,
   montants dans les tableaux et fiches) et les champs restent copiables. */
.sidebar, .topbar, .wordmark, .marque,
button, .bouton, .bouton-icone, .onglet, .onglets, .dep-option,
label, summary, h1, h2, h3, .sous-titre, .surtitre, .aide,
.etiquette, .compteur, .tuile-libelle, .nav-groupe, th,
.toast, .panneau-lien, .lien-discret, .pagination { -webkit-user-select: none; user-select: none; }
input, textarea, select, [contenteditable] { -webkit-user-select: text; user-select: text; }
.saut-contenu {
  position: fixed; top: 12px; left: 16px; z-index: 210;
  padding: 10px 16px; background: var(--surface); color: var(--navy);
  border-radius: var(--rayon-petit); transform: translateY(-160%);
}
.saut-contenu:focus { transform: none; }

/* Filet bicolore, motif des titres de section des PDF. Il prend la
   couleur du departement actif. */
.filet {
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(to right, var(--dep) 0, var(--dep) 72px, var(--line) 72px, var(--line) 100%);
  margin: 6px 0 24px;
}

/* ------------------------------------------------------------------ */
/* 3. Marque : le logotype INNOVIBE et son point turquoise            */
/*                                                                    */
/* Du texte, pas une image : il suit la police et le theme. Le point  */
/* garde le turquoise de marque sur tous les fonds sombres ou clairs. */
/* ------------------------------------------------------------------ */
.wordmark {
  font-weight: 700; letter-spacing: -0.035em; line-height: 1;
  white-space: nowrap;
}
.wordmark-point { color: var(--marque-point); }

/* Deux disques plats, turquoise profond et or, en bas des panneaux
   marine. Repris de la page d'identite ; purement decoratifs. */
.orbites { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.orbites span { position: absolute; border-radius: 50%; }
.orbite-turquoise { background: #216f7c; width: 300px; height: 300px; right: -75px; bottom: -105px; }
.orbite-or { background: #c99a22; width: 155px; height: 155px; right: 150px; bottom: -73px; opacity: 0.95; }

/* ------------------------------------------------------------------ */
/* 4. Coque                                                           */
/* ------------------------------------------------------------------ */
.app-shell { position: relative; z-index: 1; display: flex; min-height: 100vh; }

/* --- Barre laterale : aplat marine --------------------------------- */
/* Toujours marine, en clair comme en sombre : les textes y sont donc   */
/* ecrits en blanc plus ou moins attenue, tous au-dessus de 4.5:1.      */
.sidebar {
  width: var(--sidebar-width);
  position: fixed; inset: 0 auto 0 0;
  z-index: 100;
  display: flex; flex-direction: column;
  color: rgba(255, 255, 255, 0.86);
  background: var(--marque);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 18px 16px 22px;
}

.marque {
  display: inline-flex; flex-direction: column; gap: 8px;
  color: #fff; font-size: 23px;
}
.marque:hover { color: #fff; }
.marque-signature { font-size: 11px; font-weight: 400; line-height: 1.2; color: var(--marque-signature); }

/* --- Selecteur de departement ------------------------------------- */
/* Controle segmente plat. L'option active se marque par un fond clair */
/* et un trait de la couleur du departement, sans degrade.             */
.dep-switch {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
  margin: 4px 16px 14px;
  padding: 4px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.dep-option {
  --c: var(--accent);
  display: flex; align-items: center; justify-content: center; gap: 6px;
  height: auto; min-height: 0; padding: 7px 4px;
  border: 0; border-radius: 7px;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}
.dep-option .icone { width: 16px; height: 16px; }
.dep-option:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.dep-option[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.13); color: #fff;
  box-shadow: inset 0 -2px 0 var(--c);
}
.dep-option[aria-pressed="true"] .icone { color: var(--c); }
.dep-option-it   { --c: var(--dep-it); }
.dep-option-meca { --c: var(--dep-meca); }

/* --- Navigation ---------------------------------------------------- */
/* Le menu doit tenir sans defiler sur un portable courant (fenetre de
   650 px de haut environ) : voir les resserrements par hauteur plus bas.
   Le defilement vertical ne reste qu'en dernier recours. */
.sidebar-nav { flex: 1; min-height: 0; overflow: hidden auto; padding: 0 12px 10px; scrollbar-width: thin; scrollbar-color: #607387 transparent; }
.nav-groupe {
  margin: 12px 10px 5px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: rgba(255, 255, 255, 0.58);
}
.sidebar-nav a {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px; margin-bottom: 2px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
  transition: background 0.2s ease, color 0.2s ease;
}
.sidebar-nav a .icone { transition: color 0.2s ease; opacity: 0.85; }
.sidebar-nav a:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.sidebar-nav a:hover .icone { opacity: 1; }
.sidebar-nav a.active { background: rgba(255, 255, 255, 0.1); color: #fff; font-weight: 700; }
.sidebar-nav a.active .icone { color: var(--dep); opacity: 1; }
.sidebar-nav a.active::before {
  content: "";
  position: absolute; left: -12px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--dep);
  animation: indicateur 0.2s var(--ease);
}
.nav-commun {
  margin-left: auto;
  font-size: 10px; letter-spacing: 0.04em;
  padding: 1px 6px; border-radius: 999px;
  color: rgba(255, 255, 255, 0.62);
  background: rgba(255, 255, 255, 0.07);
}

/* --- Pied : compte, theme, deconnexion ----------------------------- */
.sidebar-footer {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.utilisateur {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: 8px;
  color: #fff;
  transition: background 0.2s ease;
}
.utilisateur:hover, .utilisateur.active { background: rgba(255, 255, 255, 0.08); color: #fff; }
/* Initiales marine sur turquoise : la regle de l'identite pour ecrire
   sur le turquoise. */
.avatar {
  display: grid; place-items: center; flex: none;
  width: 34px; height: 34px; border-radius: 50%;
  font-size: 13px; font-weight: 700; color: #102b47;
  background: #00a6ae;
}
.utilisateur-texte { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.utilisateur-nom { font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.utilisateur-lien { font-size: 11.5px; color: rgba(255, 255, 255, 0.62); }
.sidebar-outils { display: flex; gap: 4px; }
.sidebar-outils form { margin: 0; }
.sidebar .bouton-icone { color: rgba(255, 255, 255, 0.75); }
.sidebar .bouton-icone:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }

/* Fenetres basses (portable 1366x768, navigateur avec barres) : on
   resserre tout, pour que les dix entrees restent visibles d'un coup. */
@media (max-height: 760px) {
  .sidebar-header { padding: 14px 16px 10px 18px; }
  .dep-switch { margin: 0 16px 6px; }
  .dep-option { padding: 6px 4px; }
  .nav-groupe { margin: 8px 10px 2px; font-size: 10px; }
  .sidebar-nav a { padding: 6px 12px; margin-bottom: 1px; }
  .sidebar-nav a.active::before { top: 6px; bottom: 6px; }
  .sidebar-footer { padding: 8px 12px 10px; }
}

/* Tres basses : les titres de groupe deviennent de simples filets. Ils
   restent dans le document pour les lecteurs d'ecran. */
@media (max-height: 620px) {
  .nav-groupe {
    height: 1px; margin: 6px 10px; overflow: hidden;
    font-size: 0; background: rgba(255, 255, 255, 0.1);
  }
  .sidebar-nav a { padding: 5px 12px; }
}

/* Soleil en sombre, lune en clair : l'icone montre ou l'on va. */
.theme-soleil { display: none; }
:root[data-theme="dark"] .theme-lune { display: none; }
:root[data-theme="dark"] .theme-soleil { display: inline-flex; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-lune { display: none; }
  :root:not([data-theme="light"]) .theme-soleil { display: inline-flex; }
}

/* --- Contenu principal --------------------------------------------- */
.main-content {
  flex: 1; min-width: 0;
  margin-left: var(--sidebar-width);
  display: flex; flex-direction: column;
}

.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-height);
  display: flex; align-items: center; gap: 16px;
  padding: 0 32px;
  background: var(--fond);
  border-bottom: 1px solid var(--line);
}

/* --- Recherche globale --------------------------------------------- */
.recherche { position: relative; flex: 1; max-width: 620px; margin: 0; }
.recherche .recherche-icone { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.recherche input[type="search"] {
  height: 42px; padding-left: 42px; padding-right: 72px;
  border-radius: var(--rayon-petit);
  background: var(--surface);
  text-overflow: ellipsis;
}
.recherche-raccourci {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  font-size: 11px; color: var(--muted);
  padding: 2px 7px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--surface-2);
  pointer-events: none;
}
.recherche-resultats {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  max-height: min(70vh, 520px); overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--rayon);
  box-shadow: var(--ombre-haute);
  padding: 8px;
  animation: panneau 0.18s var(--ease);
}
.recherche-groupe { padding: 6px 4px; }
.recherche-groupe + .recherche-groupe { border-top: 1px solid var(--line); }
.recherche-groupe-titre {
  display: flex; align-items: center; gap: 8px;
  margin: 2px 8px 6px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.recherche-item {
  display: flex; flex-direction: column;
  padding: 8px 10px; border-radius: 10px;
  color: var(--ink);
}
.recherche-item-libelle { font-weight: 700; color: var(--navy); font-size: 14px; }
.recherche-item-detail { font-size: 12.5px; color: var(--muted); }
.recherche-item:hover, .recherche-item[aria-selected="true"] { background: var(--survol); color: var(--ink); }
.recherche-vide { padding: 14px; color: var(--muted); font-size: 14px; margin: 0; }

/* Page de resultats (sans JavaScript, ou « Entree »). */
.resultats-groupes { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.resultats-groupes .recherche-item { border: 1px solid transparent; }

.contenu {
  flex: 1;
  width: 100%;
  padding: 30px clamp(18px, 3vw, 44px) 56px;
}

/* --- Menu mobile (case a cocher + libelles, sans JavaScript) -------- */
.menu-bascule { display: none; }
.topbar .ouvrir-menu, .sidebar .fermer-menu { display: none; }
.voile { display: none; }

@media (max-width: 960px) {
  .menu-bascule {
    display: block;
    position: fixed; top: 0; left: 0; width: 1px; height: 1px; opacity: 0;
  }
  .topbar .ouvrir-menu, .sidebar .fermer-menu { display: inline-grid; }

  .sidebar {
    transform: translateX(-102%);
    visibility: hidden;
    transition: transform 0.18s var(--ease), visibility 0.18s;
  }
  .menu-bascule:checked ~ .app-shell .sidebar { transform: none; visibility: visible; }
  body.menu-ouvert { overflow: hidden; }
  .menu-bascule:focus-visible ~ .app-shell .ouvrir-menu { box-shadow: var(--anneau); }

  .voile {
    display: block;
    position: fixed; inset: 0; z-index: 90;
    background: rgba(5, 12, 20, 0.45);
    -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
    opacity: 0; pointer-events: none;
    transition: opacity 0.18s ease;
  }
  .menu-bascule:checked ~ .app-shell .voile { opacity: 1; pointer-events: auto; }

  .main-content { margin-left: 0; }
  .topbar { padding: 0 14px; gap: 10px; }
  .recherche-raccourci { display: none; }
  .recherche input[type="search"] { padding-right: 14px; }
  .contenu { padding: 20px 16px 40px; }
}

/* --- Toasts -------------------------------------------------------- */
.toasts {
  position: fixed; top: calc(var(--topbar-height) + 14px); right: 18px;
  z-index: 200;
  display: flex; flex-direction: column; gap: 10px;
  width: min(420px, calc(100vw - 36px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 12px;
  padding: 13px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 1px solid var(--green);
  box-shadow: var(--ombre-haute);
  animation: toast-entree 0.18s var(--ease) both;
}
.toast p { margin: 0; flex: 1; font-size: 14px; color: var(--ink); }
.toast > .icone { margin-top: 2px; color: var(--green); }
.toast-erreur { border-left-color: var(--danger); }
.toast-erreur > .icone { color: var(--danger); }
.toast.sortie { animation: toast-sortie 0.18s var(--ease) forwards; }
.toast-fermer {
  height: auto; padding: 2px; border: 0; background: none; color: var(--muted);
  border-radius: 6px; cursor: pointer;
}
.toast-fermer:hover { color: var(--navy); background: var(--survol); }
.toast-fermer .icone { width: 16px; height: 16px; }

/* ------------------------------------------------------------------ */
/* 5. Cartes, grilles, tableaux                                       */
/* ------------------------------------------------------------------ */
.carte {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--rayon);
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: none;
}
a.carte { display: block; color: inherit; transition: border-color 0.18s ease, background-color 0.18s ease; }
a.carte:hover { background: var(--surface-2); border-color: var(--line-forte); }
.carte-vide { color: var(--muted); font-size: 14px; }
p.carte.carte-vide { text-align: center; padding: 34px 20px; }

.grille { display: grid; gap: 18px; }
.grille-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grille-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.grille-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.grille > *, .resultats-groupes > *, .tableau-bord-bas > * { min-width: 0; }

.entre-deux { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }

.titre-section { font-size: 15px; color: var(--navy); margin: 0 0 14px; font-weight: 700; }
.titre-section .aide { font-weight: 400; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead tr { background: var(--surface-2); }
/* En-tetes en surtitre (style Label/Overline de DESIGN.md). */
th {
  text-align: left; padding: 11px 18px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}
td { padding: 12px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr { transition: background 0.15s ease; }
tbody tr:hover { background: var(--survol); }
tbody tr:last-child td { border-bottom: 0; }
tfoot th, tfoot td { border-top: 1px solid var(--line); border-bottom: 0; color: var(--navy); font-size: 13px; }
td.lien-ligne a, .lien-ligne { color: var(--navy); font-weight: 700; }
td.lien-ligne a:hover { color: var(--lien); }
tr.ligne-inactive td { color: var(--muted); }
tr.ligne-inactive td.lien-ligne a, tr.ligne-inactive strong { color: var(--muted); }

/* Largeurs de colonnes, en classes plutot qu'en style="width". */
.col-80 { width: 80px; } .col-90 { width: 90px; } .col-110 { width: 110px; } .col-120 { width: 120px; }
.col-130 { width: 130px; } .col-150 { width: 150px; } .col-170 { width: 170px; } .col-190 { width: 190px; }
/* Colonne libre d'un tableau large : un nom de client ne se casse pas
   mot par mot ; la carte defile plutot. */
.col-libre-160 { min-width: 160px; }

.carte > table:first-child thead tr:first-child th:first-child { border-top-left-radius: var(--rayon); }
.carte > table:first-child thead tr:first-child th:last-child { border-top-right-radius: var(--rayon); }

/* Initiales d'un client, d'un fournisseur, dans une ligne de liste. */
.avatar-ligne {
  display: inline-grid; place-items: center; flex: none;
  width: 32px; height: 32px; border-radius: 50%;
  font-size: 12px; font-weight: 700; color: var(--lien);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}
.cellule-identite { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cellule-identite > span:last-child { min-width: 0; }

/* Barre d'avancement : turquoise, verte a partir de 70 %. */
.progression { display: inline-flex; flex-direction: column; gap: 4px; min-width: 90px; width: 100%; }
.progression-piste { display: block; height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progression-rempli { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--accent); }
.progression-rempli.avancee { background: var(--green); }
.progression-texte { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Titre de groupe : surtitre turquoise suivi d'un filet (catalogue). */
.genre-titre {
  display: flex; align-items: center; gap: 12px;
  margin: 22px 0 10px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--lien);
}
.genre-titre::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ------------------------------------------------------------------ */
/* 6. Formulaires et boutons                                          */
/*                                                                    */
/* Tous les types de champ, y compris ceux sans attribut `type` (qui   */
/* valent « text ») : l'ancienne feuille ne listait que text, email,   */
/* password, date, number et tel, si bien que les champs mois, fichier,  */
/* recherche — et tous ceux ecrits sans `type` — gardaient l'allure     */
/* brute du navigateur.                                               */
/* ------------------------------------------------------------------ */
.champ { display: flex; flex-direction: column; gap: 7px; margin-bottom: 18px; min-width: 0; }
label { font-size: 13.5px; font-weight: 700; color: var(--navy); }

/* Champ obligatoire : un asterisque pose par la feuille, d'apres
   l'attribut `required` du champ, sans toucher aux vues. Les lecteurs
   d'ecran annoncent deja `required` ; l'asterisque est pour l'oeil. La
   connexion, a deux champs evidents, s'en passe comme sur la reference. */
.champ:has(> :is(input, select, textarea):required) > label::after {
  content: " *"; color: var(--danger); font-weight: 700;
}
.login-form .champ > label::after { content: none; }

/* Champ refuse : par le serveur (aria-invalid, pose par app.js avec le
   message sous le champ), ou par le navigateur une fois le champ quitte
   (:user-invalid, jamais avant la premiere saisie). */
:where(input, select, textarea)[aria-invalid="true"],
:where(input, select, textarea):user-invalid {
  border-color: var(--danger);
}
:where(input, select, textarea)[aria-invalid="true"]:focus,
:where(input, select, textarea):user-invalid:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 22%, transparent);
}
.champ-erreur {
  margin: 2px 0 0;
  font-size: 13px; line-height: 1.4; color: var(--danger);
}
.champ-erreur::before { content: "! "; font-weight: 700; }

/* :where() ramene la specificite a zero : sans lui, les huit :not()
   pesaient plus lourd que `.recherche input` et ecrasaient ses marges. */
:where(input:not([type="checkbox"], [type="radio"], [type="hidden"], [type="file"], [type="submit"], [type="button"], [type="range"], [type="color"])),
:where(select),
:where(textarea) {
  width: 100%;
  min-height: 44px;
  padding: 9px 13px;
  font: inherit; font-size: 14.5px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-forte);
  border-radius: var(--rayon-petit);
  box-shadow: inset 0 1px 2px rgba(16, 43, 71, 0.04);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  -webkit-appearance: none; appearance: none;
}
:where(input:not([type="checkbox"], [type="radio"], [type="file"])):hover,
:where(select):hover, :where(textarea):hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line-forte)); }

:where(input, select, textarea):focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--anneau);
}
:where(input, select, textarea):focus-visible { outline: 2px solid var(--lien); outline-offset: 2px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:disabled, select:disabled, textarea:disabled { opacity: 0.6; cursor: not-allowed; background: var(--surface-2); }
textarea { resize: vertical; min-height: 84px; line-height: 1.5; }

/* Fleche des listes deroulantes, dessinee (data: est autorise par la CSP). */
select {
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23607387' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  cursor: pointer;
}
select[multiple] { background-image: none; padding-right: 13px; }

/* Choix d'un mois (app.js remplace la fenetre native, non stylisable). */
.selecteur-mois { position: relative; }
.selecteur-mois-bouton {
  width: 100%; height: 44px; padding: 0 12px 0 13px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font: inherit; font-size: 15px; color: var(--ink); text-align: left; cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--line-forte); border-radius: var(--rayon-petit);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.selecteur-mois-bouton span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selecteur-mois-bouton span::first-letter { text-transform: uppercase; }
.selecteur-mois-bouton.vide { color: var(--muted); }
.selecteur-mois-bouton .icone { color: var(--muted); }
.selecteur-mois-bouton:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line-forte)); }
.selecteur-mois-bouton[aria-expanded="true"], .selecteur-mois-bouton:focus-visible {
  outline: none; border-color: var(--accent); box-shadow: var(--anneau);
}
.selecteur-mois-panneau {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 60;
  width: 272px; padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--rayon);
  box-shadow: var(--ombre-haute);
  animation: panneau 0.18s var(--ease);
}
.selecteur-mois-panneau.a-gauche { left: auto; right: 0; }
.selecteur-mois-entete { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.selecteur-mois-entete strong { font-size: 15px; color: var(--navy); font-variant-numeric: tabular-nums; }
.selecteur-mois-grille { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
.selecteur-mois-case {
  height: 38px; min-height: 0; min-width: 0; padding: 0; border: 0; border-radius: var(--rayon-petit);
  background: transparent; color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 400; cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.selecteur-mois-case:hover { background: var(--survol); color: var(--navy); }
.selecteur-mois-case:active { transform: none; }
.selecteur-mois-case.actuel { box-shadow: inset 0 0 0 1px var(--accent); font-weight: 700; color: var(--lien); }
.selecteur-mois-case[aria-pressed="true"] { background: var(--primaire); color: var(--sur-primaire); font-weight: 700; box-shadow: none; }
.selecteur-mois-case:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--lien); }
.selecteur-mois-pied {
  display: flex; justify-content: space-between;
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line);
}
.selecteur-mois-pied .lien-discret { background: none; border: 0; padding: 4px 2px; font: inherit; font-size: 13px; font-weight: 700; color: var(--lien); cursor: pointer; }
@media (max-width: 640px) { .selecteur-mois-panneau { width: min(272px, calc(100vw - 32px)); } }

/* Selecteurs de date et de mois : l'icone du calendrier suit le theme. */
input[type="date"], input[type="month"], input[type="time"], input[type="datetime-local"], input[type="week"] {
  font-variant-numeric: tabular-nums;
}
input::-webkit-calendar-picker-indicator { cursor: pointer; opacity: 0.6; transition: opacity 0.15s ease; }
input::-webkit-calendar-picker-indicator:hover { opacity: 1; }
:root[data-theme="dark"] input::-webkit-calendar-picker-indicator { filter: invert(0.85); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) input::-webkit-calendar-picker-indicator { filter: invert(0.85); }
}
input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }

/* Cases et boutons radio : taille lisible, couleur de marque. */
input[type="checkbox"], input[type="radio"] {
  width: 17px; height: 17px; margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
  vertical-align: -0.2em;
}

/* Champ fichier : le bouton natif prend l'allure d'un bouton discret. */
input[type="file"] {
  width: 100%;
  font: inherit; font-size: 14px; color: var(--muted);
  padding: 6px;
  border: 1.5px dashed var(--line-forte);
  border-radius: var(--rayon-petit);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}
input[type="file"]:hover { border-color: var(--accent); background: var(--survol); }
input[type="file"]::file-selector-button {
  font: inherit; font-size: 13.5px; font-weight: 700;
  margin-right: 12px; padding: 8px 14px;
  border: 1px solid var(--line-forte); border-radius: 8px;
  background: var(--surface); color: var(--navy);
  cursor: pointer;
  transition: border-color 0.18s ease, color 0.18s ease;
}
input[type="file"]::file-selector-button:hover { border-color: var(--accent); color: var(--lien); }

.ligne-champs { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
/* Champs alignes par le haut (une aide sous un champ ne decale plus son
   voisin) ; un bouton dans la rangee reste au niveau des champs. */
.ligne-champs > .bouton, .ligne-champs > button, .ligne-champs > .actions,
.ligne-champs > .champ:has(> .bouton, > button) { align-self: flex-end; }
.ligne-champs .champ { margin-bottom: 0; flex: 1 1 180px; }
.ligne-champs .etroit { flex: 0 0 150px; }
form.carte .ligne-champs + .ligne-champs, form.carte .ligne-champs + .champ { margin-top: 18px; }

/* --- Boutons ------------------------------------------------------- */
button, .bouton {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  font: inherit; font-size: 14px; font-weight: 700; line-height: 1.2;
  border: 1px solid transparent;
  border-radius: var(--rayon-petit);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, box-shadow 0.2s ease, transform 0.12s ease;
}
button:active, .bouton:active { transform: translateY(1px) scale(0.985); }
button:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

/* Une action principale marine, aplat sans ombre comme sur la reference ;
   les autres en blanc borde. */
.bouton-primaire { background: var(--primaire); color: var(--sur-primaire); }
.bouton-primaire:hover { background: var(--primaire-survol); color: var(--sur-primaire); }
.bouton-discret { background: var(--surface); border-color: var(--line-forte); color: var(--navy); }
.bouton-discret:hover { border-color: var(--accent); color: var(--lien); }
.bouton-large { width: 100%; }
.bouton-petit { min-height: 34px; padding: 0 12px; font-size: 13px; }

/* Lien secondaire : Annuler, retour. Remplace les style="color: muted". */
.lien-discret { color: var(--muted); font-size: 14px; }
.lien-discret:hover { color: var(--navy); }

.bouton-icone {
  display: inline-grid; place-items: center;
  min-height: 0; width: 38px; height: 38px; padding: 0;
  border: 0; border-radius: 10px;
  background: transparent; color: var(--muted);
  cursor: pointer;
}
.bouton-icone:hover { background: var(--survol); color: var(--navy); }
.bouton-icone .icone { width: 19px; height: 19px; }

.lien-danger {
  min-height: 0; height: auto; padding: 0;
  background: none; border: 0;
  color: var(--muted); font-size: 13px; font-weight: 400;
  cursor: pointer;
}
.lien-danger:hover { color: var(--danger); }
.lien-danger:active { transform: none; }

.actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.actions-fin { justify-content: flex-end; }
form.carte > .actions:last-child { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }

/* Formulaire long : la barre d'actions reste visible en bas de l'ecran
   tant que le formulaire defile, pour enregistrer sans tout redescendre. */
.contenu form.carte > .actions:last-child {
  position: sticky; bottom: 0; z-index: 2;
  margin-bottom: -22px; padding-bottom: 16px;
  background: var(--surface);
  border-radius: 0 0 var(--rayon) var(--rayon);
}

/* Repli/depli d'un formulaire secondaire : creation detaillee d'une
   tache, en-tete d'un brouillon. Ferme, il ne prend qu'une ligne. */
details.carte { padding: 0; }
details.carte > summary {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 20px;
  font-weight: 700; color: var(--navy);
  cursor: pointer; list-style: none;
  border-radius: var(--rayon);
}
details.carte > summary::-webkit-details-marker { display: none; }
details.carte > summary::before {
  content: "+"; display: grid; place-items: center; flex: none;
  width: 22px; height: 22px; border-radius: 6px;
  font-weight: 700; line-height: 1; color: var(--lien);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
details.carte[open] > summary::before { content: "−"; }
details.carte > summary:hover { background: var(--survol); }
details.carte > form { padding: 4px 20px 20px; }
details.carte > form > .actions:last-child { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }

.ligne-champs .champ-large { flex: 2 1 280px; }

/* Petit repli en ligne, sans carte : champ facultatif d'un formulaire. */
.details-simple { margin-top: 10px; }
.details-simple > summary { cursor: pointer; font-size: 13px; color: var(--lien); width: max-content; }
.decision-devis { margin-top: 24px; }
.decision-devis h2 { margin-bottom: 8px; }
.decision-devis > p { margin-bottom: 16px; }
.decision-devis .details-simple { margin-top: 16px; }
.decision-devis .details-simple > summary { max-width: 100%; min-height: 44px; display: flex; align-items: center; }
.decision-devis .details-simple > form { max-width: 65ch; padding-top: 12px; }
.decision-motif { white-space: pre-wrap; overflow-wrap: anywhere; }
.encaissements-document { margin-top: 24px; }
.encaissements-document .entre-deux { flex-wrap: wrap; gap: 12px; }
.historique-encaissements { list-style: none; margin: 16px 0 0; padding: 0; }
.historique-encaissements > li { padding: 16px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.historique-encaissements p { margin: 6px 0 0; }
.formulaire-encaissement { max-width: 760px; margin-top: 24px; }
.formulaire-encaissement .ligne-champs { align-items: flex-start; }
.ajout-fournisseur .titre-section { margin-bottom: 12px; }

/* Utilitaires qui remplacent les style="" des vues. Peu nombreux et
   nommes d'apres leur effet ; un composant reste preferable des qu'un
   motif se repete. */
.texte-discret { color: var(--muted); }
.texte-navy { color: var(--navy); }
.texte-vert { color: var(--green); }
.texte-danger { color: var(--danger); }
.texte-warn { color: var(--warn); }
.lien-fort { color: var(--navy); font-weight: 700; }
a.lien-fort:hover { color: var(--lien); }
.gras { font-weight: 700; }
.taille-15 { font-size: 15px; } .taille-18 { font-size: 18px; } .taille-20 { font-size: 20px; }
.sans-marge { margin: 0; }
.bloc { display: block; }
/* Fichier et son bouton d'envoi sur une meme ligne ; empiles sur telephone. */
.champ-fichier { display: flex; gap: 12px; align-items: stretch; }
.champ-fichier input[type="file"] { flex: 1 1 auto; min-width: 0; }
.champ-fichier .bouton { flex: none; }
@media (max-width: 640px) { .champ-fichier { flex-direction: column; } }
.centre { text-align: center; }
.fin { justify-content: flex-end; }
.flex-1 { flex: 1; }
.ligne-flex { display: flex; align-items: center; gap: 8px; }
.gap-6 { gap: 6px; }
.pousse-droite { margin-left: auto; }
.pousse-gauche { margin-right: auto; }
.sans-souligne { text-decoration: none; }
.largeur-auto { width: auto; }
.largeur-max-280 { max-width: 280px; }
.pad-20 { padding: 20px; } .pad-34-20 { padding: 34px 20px; }
.mh-0 { margin-top: 0; } .mh-12 { margin-top: 12px; } .mh-14 { margin-top: 14px; } .mh-16 { margin-top: 16px; } .mh-20 { margin-top: 20px; } .mh-32 { margin-top: 32px; }
.mb-16 { margin-bottom: 16px; } .mb-18 { margin-bottom: 18px; } .mb-20 { margin-bottom: 20px; } .mb-24 { margin-bottom: 24px; } .mb-28 { margin-bottom: 28px; }
.m-0-0-4 { margin: 0 0 4px; } .m-0-0-10 { margin: 0 0 10px; } .m-4-0-0 { margin: 4px 0 0; } .m-6-0-18 { margin: 6px 0 18px; }
.m-10-0-0 { margin: 10px 0 0; } .m-12-0-0 { margin: 12px 0 0; } .m-18-0-0 { margin: 18px 0 0; }
.separation-haut { border-top: 1px solid var(--line); padding-top: 20px; margin-top: 24px; }
.col-100 { width: 100px; } .col-140 { width: 140px; } .col-160 { width: 160px; } .col-180 { width: 180px; }
.actions-serrees { gap: 8px; }
.lien-retour { margin: 0 0 14px; }
.en-retard { color: var(--danger); }

/* Garde-fou double clic : le script pose .en-cours sur le bouton envoye. */
.en-cours { pointer-events: none; opacity: 0.85; }
.en-cours::after {
  content: "";
  width: 14px; height: 14px; margin-left: 2px;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%;
  animation: tourne 0.7s linear infinite;
}

/* --- Messages en ligne (dans les pages) ----------------------------- */
.message {
  display: flex; align-items: flex-start; gap: 10px;
  border-radius: 12px; padding: 12px 14px;
  font-size: 14px; margin-bottom: 20px;
  border: 1px solid;
}
.message .icone { margin-top: 1px; }
.message-ok { background: color-mix(in srgb, var(--green) 8%, var(--surface)); border-color: color-mix(in srgb, var(--green) 35%, transparent); color: var(--green); }
.message-erreur { background: color-mix(in srgb, var(--danger) 7%, var(--surface)); border-color: color-mix(in srgb, var(--danger) 35%, transparent); color: var(--danger); }
.message-avert { background: color-mix(in srgb, var(--gold) 9%, var(--surface)); border-color: color-mix(in srgb, var(--gold) 45%, transparent); color: var(--ink); }

/* ------------------------------------------------------------------ */
/* 7. Composants                                                      */
/* ------------------------------------------------------------------ */

/* --- Etiquettes : le fond est une teinte de la couleur du texte ----- */
.etiquette {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: 999px; padding: 2px 10px;
  font-size: 12px; font-weight: 700; line-height: 1.6;
  color: var(--c, var(--muted));
  background: color-mix(in srgb, var(--c, var(--muted)) 13%, transparent);
  white-space: nowrap;
}
.etiquette .icone { width: 13px; height: 13px; }
.etiquette-neutre { --c: var(--muted); }
.etiquette-accent { --c: var(--lien); }
.etiquette-vert   { --c: var(--green); }
.etiquette-warn   { --c: var(--warn); }
.etiquette-danger { --c: var(--danger); }

/* --- Pastilles de departement -------------------------------------- */
.dep {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px 2px 7px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.04em;
  color: var(--ink);
  background: color-mix(in srgb, var(--c, var(--muted)) 14%, transparent);
  white-space: nowrap;
}
.dep::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--muted)); }
.dep-it   { --c: var(--dep-it); }
.dep-meca { --c: var(--dep-meca); }

/* --- Types de document : icone + libelle + teinte -------------------- */
.type-doc {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px 3px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 700;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 12%, transparent);
  white-space: nowrap;
}
.type-doc .icone { width: 14px; height: 14px; }
.type-quote       { --c: var(--type-devis); }
.type-invoice     { --c: var(--type-facture); }
.type-credit_note { --c: var(--type-avoir); }

/* --- Onglets en controle segmente ---------------------------------- */
.onglets {
  display: inline-flex; flex-wrap: wrap; gap: 4px;
  padding: 4px; margin-bottom: 20px;
  border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--line);
}
.onglet {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: 9px;
  font-size: 14px; font-weight: 700; color: var(--muted);
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}
.onglet:hover { color: var(--navy); }
.onglet[aria-current="page"] { background: var(--surface); color: var(--navy); box-shadow: var(--ombre); }
.onglet .icone { width: 16px; height: 16px; }
.compteur {
  min-width: 22px; padding: 0 7px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; line-height: 20px; text-align: center;
  background: var(--line); color: var(--ink);
}
.onglet[aria-current="page"] .compteur { background: color-mix(in srgb, var(--dep) 20%, transparent); }
/* Telephone : une seule rangee qui defile, plutot que des onglets
   eparpilles sur deux lignes. */
@media (max-width: 640px) {
  .onglets { display: flex; flex-wrap: nowrap; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .onglet { flex: none; }
}

/* --- Barre de filtres ----------------------------------------------- */
.filtres { padding: 14px 18px; margin-bottom: 20px; background: var(--surface); }
.filtres .ligne-champs { margin: 0; }
.case { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 400; cursor: pointer; color: var(--ink); }
.case input { width: auto; margin: 0; }

/* --- Jauge (mot de passe) -------------------------------------------- */
.jauge { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; margin-top: 2px; }
.jauge-remplie { height: 100%; width: 0; border-radius: inherit; background: var(--danger); transition: background-color 0.18s ease; }

/* ------------------------------------------------------------------ */
/* 8. Pages                                                           */
/* ------------------------------------------------------------------ */

/* --- Connexion : la reference fournie (docs/reference/) --------------- */
/* Une carte blanche sur la brume : panneau de marque marine a gauche,    */
/* formulaire a droite. Le panneau reste marine dans les deux themes.     */
.corps-login { overflow-x: hidden; }
.login {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 40px 24px;
}
.login-carte {
  width: min(1080px, 100%);
  min-height: 572px;
  display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 30px 60px -42px rgba(16, 43, 71, 0.35);
}

.login-marque {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between; gap: 32px;
  padding: 56px 46px 40px;
  background: #102b47;
  color: #fff;
}
.login-marque > :not(.orbites) { position: relative; z-index: 1; }
.login-marque p { margin: 0; }
.login-wordmark { font-size: 28px; }
.login-signature { margin-top: 10px !important; font-size: 13px; color: #68d9de; }
.login-accroche { font-size: clamp(30px, 3.2vw, 39px); font-weight: 700; line-height: 1.2; letter-spacing: -0.025em; }
.login-message > p + p { margin-top: 22px; max-width: 34ch; font-size: 15px; line-height: 1.8; color: #c4d4e2; }
.login-pied { font-size: 12px; letter-spacing: 0.04em; color: #c4d4e2; }

.login-formulaire {
  display: flex; flex-direction: column; justify-content: center;
  padding: 58px 48px 44px;
}
.surtitre {
  margin: 0 0 12px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--lien);
}
.login-titre { font-size: 31px; margin: 0 0 8px; }
.login-formulaire .sous-titre { font-size: 15px; margin: 0 0 28px; }

.login-form .champ { margin-bottom: 18px; }
.login-form input { min-height: 46px; }
.login-form .champ-mdp .bouton-icone { bottom: 4px; }
.login-erreur {
  margin: 0 0 22px; padding: 10px 13px;
  border-radius: var(--rayon-petit);
  font-size: 14px; color: var(--danger);
  background: color-mix(in srgb, var(--danger) 6%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--danger) 32%, transparent);
}
.login-form .bouton-primaire { min-height: 46px; margin-top: 4px; font-weight: 400; font-size: 15px; box-shadow: none; }
.login-aide { margin: 24px 0 0; font-size: 13px; color: var(--muted); }

/* Ecran etroit : le panneau de marque devient un bandeau, le formulaire
   arrive sans defiler. */
@media (max-width: 760px) {
  .login { padding: 0; place-items: stretch; }
  .login-carte {
    min-height: 100vh;
    grid-template-columns: 1fr; grid-template-rows: auto 1fr;
    border: 0; border-radius: 0; box-shadow: none;
  }
  .login-marque { padding: 22px 24px; gap: 0; }
  .login-wordmark { font-size: 24px; }
  .login-message, .login-pied { display: none; }
  .login-marque .orbites { opacity: 0.5; }
  .login-marque .orbite-turquoise { width: 150px; height: 150px; right: -40px; bottom: -70px; }
  .login-marque .orbite-or { width: 80px; height: 80px; right: 70px; bottom: -48px; }
  .login-formulaire { justify-content: flex-start; padding: 32px 22px 40px; }
}

/* --- Parametres : vue d'ensemble -------------------------------------- */
.mise-en-route {
  display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap;
  margin-bottom: 18px; padding: 18px 22px;
}
.mise-en-route .surtitre { margin: 0 0 2px; }
.mise-en-route-titre { margin: 0; font-size: 17px; font-weight: 700; color: var(--navy); }
.mise-en-route-jauge { width: min(320px, 100%); }
.mise-en-route-jauge .progression-piste { height: 8px; }

.reglages { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); }
.reglage { display: flex; flex-direction: column; gap: 12px; padding: 22px; margin: 0; }
.reglage-entete { display: flex; align-items: center; gap: 12px; }
.reglage-icone {
  display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--lien);
}
.reglage-icone .icone { width: 20px; height: 20px; }
.reglage-titre { flex: 1; margin: 0; font-size: 16px; }
.reglage-titre a { color: var(--navy); text-decoration: none; }
.reglage-titre a:hover { color: var(--lien); }
.reglage-role { margin: 0; color: var(--muted); font-size: 13.5px; }
.reglage-apercu {
  flex: 1; display: flex; flex-direction: column; gap: 10px; justify-content: center;
  min-height: 74px; padding: 14px 16px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--line);
}
.reglage-nom { margin: 0; font-weight: 700; color: var(--navy); }
.reglage-faits { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; font-size: 13px; }
.reglage-faits dt { color: var(--muted); }
.reglage-faits dd { margin: 0; overflow-wrap: anywhere; }
.jetons { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.jeton {
  display: inline-flex; align-items: baseline; gap: 6px; padding: 4px 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); color: var(--navy);
  font-size: 12.5px; font-weight: 700;
}
.jeton-detail { color: var(--muted); font-weight: 400; }
.jeton-plus { color: var(--muted); }
.jeton-inactif { color: var(--muted); text-decoration: line-through; }
.reglage-action {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 6px;
  color: var(--lien); font-weight: 700; font-size: 14px; text-decoration: none;
}
.reglage-action .icone { width: 16px; height: 16px; transition: transform 0.15s ease; }
.reglage-action:hover .icone { color: var(--lien); }

/* --- En-tete de page ------------------------------------------------- */
.entete-page { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.entete-page .sous-titre { margin-bottom: 0; }
/* Telephone : les actions de l'en-tete prennent toute la largeur, cote a
   cote, au lieu de s'empiler en boutons de largeurs inegales. */
@media (max-width: 640px) {
  .entete-page > .actions { width: 100%; gap: 10px; }
  .entete-page > .actions > .bouton { flex: 1 1 auto; justify-content: center; }
  .entete-page > .bouton { width: 100%; justify-content: center; }
}

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 18px; }
.pagination-resume { margin: 0; color: var(--muted); font-size: 13px; }
.pagination-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pagination-position { color: var(--muted); font-size: 13px; padding: 8px; }
@media (max-width: 640px) {
  .pagination { justify-content: center; }
  .pagination-actions { justify-content: center; }
}

/* --- Tableau de bord : tuiles ---------------------------------------- */
.tuiles { display: grid; gap: 18px; grid-template-columns: minmax(300px, 1.35fr) repeat(3, minmax(220px, 1fr)); margin-bottom: 22px; }
@media (max-width: 1400px) { .tuiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px)  { .tuiles { grid-template-columns: 1fr; } }
.tuile {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 6px;
  padding: 20px 22px; margin: 0;
}
@media (max-width: 640px) { .tuile { padding: 16px 18px; gap: 4px; } }
/* Bandeau plat de 4 px a la couleur de la tuile (maquette Figma). */
.tuile::after {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px;
  background: var(--c, var(--dep));
}
.tuile-ca       { --c: var(--accent); }
.tuile-encaisser { --c: var(--danger); }
.tuile-devis    { --c: var(--lien); }
.tuile-depenses { --c: var(--gold); }
.tuile-attente  { --c: var(--warn); }
.tuile-marge    { --c: var(--green); }
.tuiles-projet  { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tuiles-interne { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 640px) { .tuiles-interne { grid-template-columns: 1fr; } }
.tuiles-totaux  { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 900px) { .tuiles-totaux { grid-template-columns: 1fr; } }
@media (max-width: 1100px) { .tuiles-projet { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px)  { .tuiles-projet { grid-template-columns: 1fr; } }
.budget { margin-bottom: 22px; }
.budget .panneau-entete { margin-bottom: 12px; }
.budget .progression-piste { height: 8px; }
.tuile-entete { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tuile-libelle { font-size: 13px; font-weight: 700; color: var(--muted); margin: 0; }
.tuile-icone {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 10px;
  color: var(--c, var(--dep));
  background: color-mix(in srgb, var(--c, var(--dep)) 13%, transparent);
}
.tuile-valeur { font-size: clamp(20px, 1.7vw, 26px); font-weight: 700; color: var(--navy); letter-spacing: -0.02em; line-height: 1.15; margin: 0; overflow-wrap: anywhere; }
.tuile-principale .tuile-valeur { font-size: clamp(24px, 2.2vw, 34px); }
/* Valeur coloree (marge negative, justificatifs manquants) : la couleur
   d etat passe devant le marine par defaut de la tuile. */
.tuile-valeur.texte-danger { color: var(--danger); }
.tuile-valeur.texte-vert   { color: var(--green); }
.tuile-valeur.texte-warn   { color: var(--warn); }
.tuile-pied { font-size: 12.5px; color: var(--muted); margin: 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.delta { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; }
.delta .icone { width: 14px; height: 14px; }
.delta-hausse { color: var(--green); }
.delta-baisse { color: var(--danger); }

.tableau-bord { display: grid; gap: 18px; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); align-items: stretch; }
.tableau-bord-bas { display: grid; gap: 18px; margin-top: 18px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
@media (max-width: 1200px) { .tableau-bord { grid-template-columns: 1fr; } }

.panneau { margin: 0; }
.panneau-retards { display: flex; flex-direction: column; }
.panneau-retards > .liste-vide { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; }
.panneau-entete { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panneau-entete h2 { margin: 0; display: flex; align-items: center; gap: 8px; }
.panneau-entete h2 .icone { color: var(--muted); }
.panneau-lien { font-size: 13px; font-weight: 700; display: inline-flex; align-items: center; gap: 4px; }
.panneau-lien .icone { width: 15px; height: 15px; transition: transform 0.2s var(--ease); }
.panneau-lien:hover .icone { color: var(--lien); }

.liste-lignes { list-style: none; margin: 0; padding: 0; }
.liste-lignes li {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 4px;
  border-bottom: 1px solid var(--line);
}
.liste-lignes li:last-child { border-bottom: 0; }
.liste-lignes .ligne-principale { flex: 1; min-width: 0; }
.liste-lignes .ligne-titre { display: block; font-weight: 700; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.liste-lignes .ligne-detail { display: block; font-size: 12.5px; color: var(--muted); }
.liste-vide { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; padding: 14px 4px; margin: 0; }
.liste-vide .icone { color: var(--green); }

/* --- Graphique : histogramme SVG ------------------------------------- */
.graphique { position: relative; }
.graphique svg { display: block; width: 100%; height: auto; overflow: visible; }
.graphique .grille-ligne { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.graphique .axe-texte { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.graphique .etiquette-valeur { fill: var(--navy); font-size: 11px; font-weight: 700; }
.graphique .barre { fill-opacity: 1; }
.graphique .barre-1 { fill: var(--serie-1); }
.graphique .barre-2 { fill: var(--serie-2); }
.graphique .bande { fill: transparent; cursor: pointer; outline: none; }
.graphique .bande:hover, .graphique .bande:focus-visible { fill: var(--survol); }
.graphique .bande:focus-visible { stroke: var(--lien); stroke-width: 2px; }
.legende { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--ink); margin: 0 0 10px; padding: 0; list-style: none; }
.legende li { display: inline-flex; align-items: center; gap: 7px; }
.legende .cle { width: 11px; height: 11px; border-radius: 3px; }
.cle-1 { background: var(--serie-1); }
.cle-2 { background: var(--serie-2); }
.tableau-donnees { margin-top: 10px; font-size: 13px; }
.tableau-donnees summary { cursor: pointer; color: var(--muted); font-weight: 700; }
.tableau-donnees table { margin-top: 10px; }

.infobulle {
  position: fixed; z-index: 300; pointer-events: none;
  min-width: 170px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--ombre-haute);
  font-size: 12.5px;
  animation: panneau 0.12s ease;
}
.infobulle-titre { font-weight: 700; color: var(--navy); margin: 0 0 6px; text-transform: capitalize; }
.infobulle-ligne { display: flex; align-items: center; gap: 8px; margin: 2px 0; }
.infobulle-ligne strong { margin-left: auto; font-variant-numeric: tabular-nums; }
.infobulle-cle { width: 12px; height: 2px; border-radius: 2px; }

/* --- Repartition par departement (quand « Tous ») ------------------- */
.repartition-barre { display: flex; gap: 2px; height: 12px; border-radius: 999px; overflow: hidden; background: var(--line); margin: 6px 0 14px; }
.repartition-barre span { display: block; height: 100%; }
.repartition-legende { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.repartition-legende li { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.repartition-legende .nombre { margin-left: auto; font-weight: 700; color: var(--navy); }
.repartition-legende .aide { white-space: nowrap; }

/* --- Documents -------------------------------------------------------- */
tr.ligne-doc td:first-child { box-shadow: inset 3px 0 0 var(--c, transparent); }
.numero-doc { font-family: "Fira Mono", ui-monospace, monospace; font-size: 13px; font-weight: 700; color: var(--navy); white-space: nowrap; }
.numero-doc.brouillon { color: var(--muted); font-style: italic; font-family: inherit; font-weight: 400; }

.doc-entete {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: center;
  padding: 26px 26px 22px;
}
.doc-entete::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 5px;
  background: linear-gradient(90deg, var(--c), color-mix(in srgb, var(--c) 30%, transparent));
}
.doc-entete::after {
  content: ""; position: absolute; right: -60px; top: -80px;
  width: 240px; height: 240px; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--c) 16%, transparent), transparent 70%);
  pointer-events: none;
}
.doc-numero { font-size: 26px; font-weight: 700; color: var(--navy); margin: 10px 0 2px; letter-spacing: -0.01em; font-family: "Fira Mono", ui-monospace, monospace; }
.doc-numero.brouillon { font-family: inherit; color: var(--muted); }
.doc-client { font-size: 15px; color: var(--ink); margin: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.doc-montant { text-align: right; position: relative; z-index: 1; }
.doc-montant-libelle { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 0; }
.doc-montant-valeur { font-size: 30px; font-weight: 700; color: var(--navy); margin: 2px 0 0; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.doc-dates { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.doc-date {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 8px;
  font-size: 12.5px; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line);
}
.doc-date .icone { width: 14px; height: 14px; color: var(--muted); }
.doc-date-retard { border-color: var(--danger); color: var(--danger); }
.doc-entete-texte { position: relative; z-index: 1; }
.doc-entete .etapes { grid-column: 1 / -1; }
@media (max-width: 720px) { .doc-entete { grid-template-columns: 1fr; } .doc-montant { text-align: left; } }

/* Creation : seule la date utile au type choisi reste visible. */
.formulaire-document:has(input[name="document_type"][value="quote"]:checked) .champ-facture,
.formulaire-document:has(input[name="document_type"][value="invoice"]:checked) .champ-devis { display: none; }

/* --- Lignes d'un document : tableau, edition sur place, ajout --------- */
/* Sur un ecran etroit, le tableau defile dans sa carte au lieu d'etre
   coupe : les montants, en derniere colonne, restent atteignables. */
.carte-tableau { position: relative; padding: 0; overflow-x: auto; }
.carte-tableau > table:has(tr > :nth-child(4)) { min-width: 640px; }
.carte-tableau .cellule-identite { min-width: 180px; }
.carte-tableau > .table-lignes { margin: 0; }

/* Telephone : les tableaux de 4 colonnes et plus (marques par app.js)
   deviennent une pile de fiches, libelle a gauche, valeur a droite. */
@media (max-width: 640px) {
  .carte-tableau > table.tableau-empile:not(.table-lignes) { min-width: 0; }
  .tableau-empile thead {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
  }
  .tableau-empile, .tableau-empile tbody, .tableau-empile tfoot,
  .tableau-empile tr, .tableau-empile td, .tableau-empile tfoot th { display: block; width: auto; }
  .tableau-empile tr { padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .tableau-empile tbody tr:last-child { border-bottom: 0; }
  .tableau-empile tfoot tr { border-top: 1px solid var(--line); border-bottom: 0; }
  .tableau-empile td, .tableau-empile tfoot th { padding: 4px 0; border: 0; text-align: right; }
  .tableau-empile td[data-label] {
    display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  }
  .tableau-empile td[data-label]::before {
    content: attr(data-label); flex: none; max-width: 45%; text-align: left;
    font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
    color: var(--muted); white-space: normal;
  }
  .tableau-empile td[data-label=""]::before { content: none; }
  .tableau-empile td:first-child { display: block; padding-bottom: 8px; text-align: left; white-space: normal; }
  .tableau-empile td:first-child::before { content: none; }
  .tableau-empile .cellule-identite { min-width: 0; }
  .tableau-empile tr.ligne-doc { box-shadow: inset 3px 0 0 var(--c, transparent); }
  .tableau-empile tr.ligne-doc td:first-child { box-shadow: none; }
}
.col-qte { width: 90px; }
.col-taux { width: 80px; }
.col-montant { width: 130px; }
.col-actions { width: 160px; }
.lignes-vide { padding: 20px; margin: 0; }
.montant-fort { color: var(--navy); font-weight: 700; }
.actions-ligne { white-space: nowrap; }
.actions-ligne form { display: inline; margin: 0 0 0 12px; }
.actions-ligne .lien-discret { font-size: 13px; }
.table-lignes tr.ligne-en-edition td { background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.table-lignes tr.ligne-edition td { background: var(--surface-2); padding: 16px 18px 18px; border-bottom: 1px solid var(--line); }
.table-lignes tr.ligne-edition:hover { background: none; }
.ajout-ligne .titre-section { margin-bottom: 12px; }
.ligne-actions { align-items: center; }
.ligne-apercu {
  margin: 0 auto 0 0;
  font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.ligne-formulaire > .actions { margin-top: 16px; }
.prestations-rapides { margin-bottom: 22px; }
.prestations-choix { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); gap: 8px; margin: 10px 0; }
.prestation-choix { text-align: left; display: flex; flex-direction: column; justify-content: space-between; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: var(--rayon-petit); background: var(--surface-2); color: var(--ink); font: inherit; cursor: pointer; }
.prestation-choix:hover { border-color: var(--lien); }
.prestation-choix strong { color: var(--navy); font-variant-numeric: tabular-nums; }
.prestation-choix small { color: var(--muted); font-weight: 400; }
.ligne-options { margin-top: 16px; }
.ligne-options summary { cursor: pointer; color: var(--lien); padding: 10px 0; }
.ligne-options[open] { padding-bottom: 8px; }
.ligne-options .champ { margin-top: 10px; }
.ligne-edition .prestations-rapides { display: none; }
[data-recherche-catalogue] { margin-bottom: 10px; }
.barre-actions-doc { border-top: 1px solid var(--line); padding-top: 20px; margin-top: 28px; }

/* Etapes du cycle de vie : brouillon -> emis -> paye. */
.etapes { display: flex; list-style: none; margin: 18px 0 0; padding: 0; gap: 0; counter-reset: etape; }
.etape { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--muted); text-align: center; }
.etape::before {
  counter-increment: etape; content: counter(etape);
  display: grid; place-items: center; z-index: 1;
  width: 26px; height: 26px; border-radius: 50%;
  font-size: 12px; font-weight: 700;
  background: var(--surface); border: 2px solid var(--line-forte); color: var(--muted);
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}
.etape + .etape::after {
  content: ""; position: absolute; top: 12px; right: 50%; width: 100%; height: 2px;
  background: var(--line-forte); z-index: 0;
}
.etape.faite::before { content: "✓"; background: var(--c); border-color: var(--c); color: var(--surface); }
.etape.faite + .etape::after, .etape.faite + .etape.faite::after { background: var(--c); }
.etape.courante { color: var(--navy); }
.etape.courante::before { border-color: var(--c); color: var(--c); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 18%, transparent); }
.etape.bloquee::before { content: "!"; border-color: var(--danger); color: var(--danger); }

.totaux { margin-left: auto; width: 100%; max-width: 400px; font-size: 14px; padding: 18px 20px; }
.totaux-ligne { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.totaux-net {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 12px; padding: 13px 16px; border-radius: 12px;
  background: var(--primaire); color: var(--sur-primaire);
  font-weight: 700; font-size: 15px;
  box-shadow: 0 10px 22px -14px var(--primaire);
}
.totaux-net .nombre { font-size: 17px; }

/* Choix du type a la creation : cartes radio. */
.choix-type { border: 0; padding: 0; margin: 0 0 20px; min-width: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.choix-type legend { font-size: 13.5px; font-weight: 700; color: var(--navy); margin-bottom: 8px; padding: 0; }
.choix-carte {
  position: relative;
  display: flex; gap: 14px; align-items: flex-start;
  padding: 16px; border-radius: 12px;
  border: 1.5px solid var(--line-forte); background: var(--surface);
  font-weight: 400; color: var(--ink);
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s var(--ease);
}
.choix-carte:hover { border-color: color-mix(in srgb, var(--c) 50%, var(--line-forte)); }
.choix-carte input { position: absolute; opacity: 0; pointer-events: none; }
.choix-carte:has(input:checked) { border-color: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 18%, transparent); }
.choix-carte:has(input:focus-visible) { box-shadow: var(--anneau); }
.choix-icone {
  display: grid; place-items: center; flex: none;
  width: 40px; height: 40px; border-radius: 10px;
  color: var(--c); background: color-mix(in srgb, var(--c) 13%, transparent);
}
.choix-icone .icone { width: 20px; height: 20px; }
.choix-texte { display: flex; flex-direction: column; gap: 2px; }
.choix-texte strong { font-size: 15px; }

/* --- Kanban ----------------------------------------------------------- */
.kanban { position: relative; display: flex; gap: 16px; overflow-x: auto; padding-bottom: 10px; scroll-snap-type: x proximity; }
.kanban-colonne {
  flex: 1 0 260px; scroll-snap-align: start;
  background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--rayon);
  padding: 12px 12px 14px;
}
.kanban-titre {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin: 0 0 12px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--navy);
}
.kanban-titre::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 2px; }
.kanban-colonne[data-colonne="in_progress"] .kanban-titre::before { background: var(--accent); }
.kanban-colonne[data-colonne="review"] .kanban-titre::before { background: var(--warn); }
.kanban-colonne[data-colonne="done"] .kanban-titre::before { background: var(--green); }
.kanban-titre .aide { margin-left: auto; font-size: 12px; background: var(--line); color: var(--ink); padding: 0 8px; border-radius: 999px; letter-spacing: 0; }
.kanban-carte {
  background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; margin-bottom: 10px;
  box-shadow: 0 4px 12px -6px rgba(16, 43, 71, 0.10);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), opacity 0.2s ease, border-color 0.2s ease;
}
.kanban-carte:hover { border-color: var(--line-forte); }
.kanban-carte-titre { margin: 0; font-size: 14px; color: var(--navy); font-weight: 700; }
.kanban-carte-titre a { color: inherit; }
.kanban-carte-titre a:hover { color: var(--lien); text-decoration: underline; text-underline-offset: 0.2em; }
.kanban-description {
  margin: 4px 0 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* Ajout rapide en tete de colonne : un champ en pointilles, qui devient
   plein au focus. Liste du projet et bouton n'apparaissent qu'une fois
   un titre commence, pour garder la colonne lisible. */
.kanban-ajout { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.kanban-ajout input[name="title"] {
  flex: 1 1 140px; min-height: 38px; font-size: 13.5px;
  background: transparent; border-style: dashed;
}
.kanban-ajout input[name="title"]:focus { background: var(--surface); border-style: solid; }
.kanban-ajout select { flex: 1 1 100%; min-height: 34px; font-size: 13px; padding-top: 4px; padding-bottom: 4px; }
.kanban-ajout:has(input[name="title"]:placeholder-shown):not(:focus-within) :is(select, .bouton-petit) { display: none; }
.kanban-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 9px; }
.kanban-actions { display: flex; gap: 10px; align-items: center; margin-top: 10px; }
.kanban-actions form { margin: 0; }
.kanban-actions select { min-height: 32px; font-size: 12.5px; padding: 4px 30px 4px 9px; background-position: right 8px center; }
.kanban-zone { min-height: 48px; border-radius: 10px; transition: background 0.2s ease; }
.kanban-projet { margin: 4px 0 0; }
.kanban-projet a { color: var(--lien); }
.kanban-options { margin-top: 10px; }
.kanban-options > summary { color: var(--muted); font-size: 12.5px; cursor: pointer; }
.kanban-options .kanban-actions { flex-wrap: wrap; }
.kanban-vide { padding: 8px 0; margin: 0; }

.kanban-js .kanban-carte { cursor: grab; }
.kanban-js .kanban-carte:active { cursor: grabbing; }
.kanban-js .kanban-actions form[data-sans-js] { display: none; }
.kanban-carte-deplacee { opacity: 0.4; transform: rotate(1.5deg) scale(0.98); }
.kanban-carte-en-cours { border-color: var(--accent); }
.kanban-zone-survol { background: color-mix(in srgb, var(--accent) 8%, transparent); outline: 2px dashed color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; }

/* --- Depenses : recu et lecture automatique --------------------------- */
.recu-resume {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
.recu-apercu { max-width: 100%; max-height: 340px; border: 1px solid var(--line); border-radius: 12px; display: block; }
.lecture { border-radius: 12px; padding: 14px 16px; margin-top: 14px; border: 1px solid var(--line); }
.lecture-sure { background: color-mix(in srgb, var(--green) 7%, var(--surface)); border-color: color-mix(in srgb, var(--green) 35%, transparent); }
.lecture-douteuse { background: color-mix(in srgb, var(--gold) 8%, var(--surface)); border-color: color-mix(in srgb, var(--gold) 45%, transparent); }
.lecture-titre { margin: 0 0 10px; font-size: 14px; font-weight: 700; color: var(--navy); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.lecture-liste { display: grid; grid-template-columns: auto 1fr; gap: 5px 18px; margin: 0; font-size: 14px; }
.lecture-liste dt { color: var(--muted); }
.lecture-liste dd { margin: 0; color: var(--navy); font-weight: 700; font-variant-numeric: tabular-nums; }
.ocr-brut { margin-top: 12px; font-size: 13px; }
.ocr-brut summary { cursor: pointer; color: var(--muted); font-weight: 700; }
.ocr-brut pre {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; max-height: 260px; overflow: auto; font-size: 12px;
  white-space: pre-wrap; word-break: break-word; margin: 8px 0 0;
}

/* --- Calendrier ------------------------------------------------------- */
.planning-outils { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; margin: 0 0 20px; }
.planning-raccourcis, .planning-vues { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.planning-raccourcis a, .planning-vues a { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 12px; color: var(--muted); border-radius: var(--rayon-petit); text-decoration: none; }
.planning-raccourcis a:hover, .planning-vues a:hover { background: var(--surface-2); color: var(--ink); }
.planning-raccourcis a[aria-current], .planning-vues a[aria-current] { background: var(--surface); color: var(--navy); font-weight: 700; box-shadow: inset 0 -2px var(--lien); }
.planning-raccourcis a span { font-size: 12.5px; font-variant-numeric: tabular-nums; }
.planning-vues { border: 1px solid var(--line); border-radius: var(--rayon-petit); padding: 3px; }
.planning-creation > summary { color: var(--lien); font-weight: 700; }
.planning-filtres > summary { flex-wrap: wrap; }
.planning-filtres > form { margin-bottom: 0; }
.planning-filtres .sources { margin-top: 16px; gap: 8px 16px; }
.planning-details { margin: 8px 0 20px; }
.planning-details > summary { cursor: pointer; color: var(--muted); margin-bottom: 16px; }
.planning-liste { padding: 0 20px; }
.planning-ligne { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.planning-ligne:last-child { border-bottom: 0; }
.planning-identite { display: flex; flex-direction: column; gap: 4px; flex: 1 1 240px; min-width: 0; overflow-wrap: anywhere; }
.planning-ligne form { margin: 0; }
.planning-ligne form select { width: auto; }
.planning-vide { padding: 28px 12px; }
.planning-mois { margin: 0; font-size: 20px; text-transform: capitalize; }
.calendrier-principal, .calendrier-lateral { min-width: 0; }
.calendrier-lateral { display: grid; gap: 18px; }
.calendrier-jour-detail { scroll-margin-top: calc(var(--topbar-height) + 20px); }
.calendrier-jour-detail h2 { margin: 0 0 12px; }
.jour-selectionne { box-shadow: inset 0 0 0 2px var(--lien); }
.jour-numero { text-decoration: none; }
.jour-numero:hover { outline: 1px solid var(--lien); }
.agenda-jour { border-bottom: 1px solid var(--line); padding: 18px 0; }
.agenda-jour:last-child { border-bottom: 0; }
.agenda-jour > summary { cursor: pointer; font-weight: 700; color: var(--navy); }
.agenda-jour > summary .aide { display: inline-block; font-weight: 400; margin-left: 12px; }
.agenda-evenement { display: flex; gap: 12px; align-items: start; padding: 14px 0; border-bottom: 1px solid var(--line); }
.agenda-evenement .puce { margin-top: 7px; }
.agenda-evenement > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; overflow-wrap: anywhere; }
.agenda-ajouter { display: inline-block; padding: 12px 0 0; font-size: 13px; }
.calendrier-agenda { display: none; }
.calendrier-vue-agenda .calendrier-mois { display: none; }
.calendrier-vue-agenda .calendrier-agenda { display: block; }
@media (max-width: 700px) {
  .planning-outils { gap: 12px; }
  .planning-raccourcis { width: 100%; }
  .planning-raccourcis a { padding: 8px; }
  .planning-ligne { gap: 10px 16px; }
  .planning-identite, .planning-ligne form { flex-basis: 100%; }
  .planning-ligne form { flex-wrap: wrap; }
  .planning-mois { font-size: 16px; }
  .calendrier-navigation .actions { flex-wrap: wrap; gap: 8px; }
  .calendrier-vue-auto .calendrier-mois { display: none; }
  .calendrier-vue-auto .calendrier-agenda { display: block; }
  .calendrier-mois { overflow-x: auto; }
  .calendrier-mois .calendrier { min-width: 640px; }
}
.calendrier-page { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
@media (max-width: 1200px) { .calendrier-page { grid-template-columns: 1fr; } }
.calendrier { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.calendrier th { padding: 12px 10px; }
.calendrier td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); vertical-align: top; padding: 8px; height: 118px; }
.calendrier td:last-child { border-right: 0; }
.calendrier tbody tr:hover { background: none; }
.calendrier tbody tr:last-child td { border-bottom: 0; }
.jour { transition: background 0.15s ease; }
.jour:hover { background: var(--survol); }
.jour-numero {
  display: inline-grid; place-items: center;
  min-width: 26px; height: 26px; border-radius: 50%;
  font-size: 12.5px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums;
}
.jour-hors-mois { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.jour-hors-mois .jour-numero { opacity: 0.45; }
.jour-weekend:not(.jour-hors-mois) { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.jour-aujourdhui .jour-numero { background: var(--accent); color: var(--marque); }
.jour-evenements { display: flex; flex-direction: column; gap: 3px; margin-top: 5px; }
/* Evenement : pastille teintee a 12 % de la couleur de son type, avec un
   point plein (maquette Figma). La couleur vient de --c, posee par type. */
.ev {
  --c: var(--muted);
  display: flex; align-items: center; gap: 5px;
  font-size: 11.5px; line-height: 1.35;
  padding: 2px 6px; border-radius: 6px;
  background: color-mix(in srgb, var(--c) 12%, transparent); color: var(--ink);
  transition: transform 0.15s ease, background 0.15s ease;
}
.ev::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.ev-titre { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-note { font-size: 10px; color: var(--muted); text-transform: uppercase; }
.ev-lien { color: inherit; display: block; }
.ev-lien:hover .ev { background: color-mix(in srgb, var(--c) 20%, transparent); }
.puce { --c: var(--muted); display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; }
.ev-tache   { --c: var(--navy); }
.ev-phase   { --c: var(--green); }
.ev-facture { --c: var(--danger); }
.ev-devis   { --c: var(--lien); }
.ev-projet  { --c: var(--accent); }
.ev-abo     { --c: var(--warn); }
.ev-depense { --c: var(--gold); }
.sources { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.a-venir { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.a-venir li { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; padding: 9px 0; border-bottom: 1px solid var(--line); }
.a-venir li:last-child { border-bottom: 0; }
.a-venir .nombre { margin-left: auto; }

/* --- Compte ------------------------------------------------------------ */
.compte-grille { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); align-items: start; }
.compte-grille > *, .compte-identite > div { min-width: 0; }
.compte-identite { overflow-wrap: anywhere; }
.compte-identite { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.compte-identite .avatar { width: 56px; height: 56px; font-size: 20px; }
.champ-mdp { position: relative; }
.champ-mdp input { padding-right: 46px; }
.champ-mdp .bouton-icone { position: absolute; right: 3px; bottom: 2px; width: 38px; height: 38px; }
.activite { list-style: none; margin: 0; padding: 0; }
.activite li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.activite li:last-child { border-bottom: 0; }
.activite li { overflow-wrap: anywhere; }

@media (max-width: 960px) {
  .bouton-icone { min-width: 44px; min-height: 44px; }
  .dep-option, .case { min-height: 44px; }
  .sidebar-nav a { min-height: 44px; }
  .champ-mdp .bouton-icone { width: 44px; height: 44px; bottom: 0; }
  .champ-mdp input { padding-right: 52px; }
  .onglets a, .planning-vues a, .planning-raccourcis a,
  .reglage-titre a, .reglage-action, .lien-discret,
  .agenda-ajouter, .carte-vide a, .planning-vide > a,
  .kanban-options > summary, .planning-details > summary {
    display: inline-flex; align-items: center; min-height: 44px;
  }
  .bouton-petit, .lien-danger { min-height: 44px; }
  .jour-numero { min-width: 44px; height: 44px; }
  .saut-contenu { min-height: 44px; }
}
.activite .icone { color: var(--muted); }

/* ------------------------------------------------------------------ */
/* 9. Animations                                                      */
/* ------------------------------------------------------------------ */
@keyframes panneau  { from { opacity: 0; transform: translateY(-4px) scale(0.985); } to { opacity: 1; transform: none; } }
@keyframes toast-entree { from { opacity: 0; transform: translateX(28px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes toast-sortie { to { opacity: 0; transform: translateX(28px); } }
@keyframes indicateur { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes tourne { to { transform: rotate(360deg); } }
/* Outil consulte plusieurs fois par jour : le contenu est visible immediatement. */
.contenu { animation: none; }

/* ------------------------------------------------------------------ */
/* 10. Mouvement reduit, impression                                   */
/* ------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition-property: color, background-color, border-color, opacity !important;
    transition-duration: 120ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .sidebar, .topbar, .toasts, .voile, .menu-bascule, .dep-switch { display: none !important; }
  .main-content { margin: 0; }
  .contenu { padding: 0; }
  .carte { box-shadow: none; break-inside: avoid; }
  .contenu { animation: none; }
  body { background: #fff; }
}

/* Sécurité personnelle, séparée des réglages de société. */
.parametres-securite { margin-top: 24px; max-width: 760px; }
.parametres-securite-contenu { padding: 0 20px 20px; }
