/* ══════════════════════════════════════════════════════════
   PULg — Interface locale
   Palette neutre et sobre ; la couleur ne sert qu'à porter du
   sens (étiquettes, accent d'action). Clair et sombre gérés.
   ══════════════════════════════════════════════════════════ */

:root {
  --fond:        #ffffff;
  --surface:     #fbfbfa;
  --lateral:     #f7f7f5;
  --bordure:     #e9e9e7;
  --bordure-appuyee: #dcdcd8;
  --texte:       #37352f;
  --texte-doux:  #787774;
  --texte-tres-doux: #9b9a97;
  --accent:      #337ea9;
  --accent-fond: #e7f1f7;
  --survol:      #f1f1ef;
  --selection:   #e8f0f5;
  --danger:      #c4554d;
  --ombre:       0 1px 2px rgba(15,15,15,.06), 0 4px 14px rgba(15,15,15,.08);
  --rayon:       6px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fond:        #191919;
    --surface:     #1d1d1d;
    --lateral:     #202020;
    --bordure:     #2e2e2e;
    --bordure-appuyee: #3a3a3a;
    --texte:       #e6e6e4;
    --texte-doux:  #9b9a97;
    --texte-tres-doux: #6f6f6c;
    --accent:      #5a9fd4;
    --accent-fond: #1c3141;
    --survol:      #252525;
    --selection:   #23313b;
    --danger:      #d97b72;
    --ombre:       0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }

/* L'attribut `hidden` doit l'emporter sur tout `display` déclaré plus bas
   (le tiroir et les panneaux sont en `display:flex`, le bouton Supprimer
   en `display:grid`) : sans cela, les masquer par JavaScript reste sans
   effet visible. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font: 14px/1.5 ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
h1, h2 { margin: 0; font-weight: 600; }

#appli { display: flex; height: 100vh; overflow: hidden; }

/* ───────────── Barre latérale ───────────── */

#lateral {
  width: 252px;
  flex: 0 0 252px;
  background: var(--lateral);
  border-right: 1px solid var(--bordure);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.marque {
  display: flex; align-items: center;
  padding: 18px 14px 16px;
  /* Le gris du logo est posé en `currentColor` : le texte suit donc le
     thème, tandis que l'ambre de la marque reste lui-même. Un filtre
     global aurait délavé l'ambre pour sauver le gris. */
  color: var(--texte-doux);
}
.marque-logo {
  width: 100%; height: auto; display: block;
}

#navigation { flex: 1; overflow-y: auto; padding: 4px 8px 16px; }

.groupe-base { margin-bottom: 14px; }
.groupe-titre {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 6px 8px 4px;
  font-size: 11px; font-weight: 600; letter-spacing: .05em;
  text-transform: uppercase; color: var(--texte-tres-doux);
}
.groupe-titre .n { font-weight: 400; letter-spacing: 0; text-transform: none; }

.lien-vue {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 5px 8px; margin: 1px 0;
  border: 0; background: none; border-radius: var(--rayon);
  font-size: 13.5px; text-align: left; color: var(--texte);
  cursor: pointer;
}
.lien-vue:hover { background: var(--survol); }
.lien-vue.actif { background: var(--selection); color: var(--accent); font-weight: 500; }
.lien-vue .ic { width: 16px; text-align: center; color: var(--texte-doux); flex: 0 0 16px; }
.lien-vue.actif .ic { color: var(--accent); }
.lien-vue .nom { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Réordonnancement : la vue glissée s'estompe, un liseré marque
   l'endroit où elle se posera. */
.lien-vue.glisse-vue { opacity: .35; }
.lien-vue.cible-avant { box-shadow: inset 0 2px 0 var(--accent); }
.lien-vue.cible-apres { box-shadow: inset 0 -2px 0 var(--accent); }

.renommage {
  flex: 1; min-width: 0; padding: 2px 6px;
  border: 1px solid var(--accent); border-radius: 4px;
  background: var(--fond); color: var(--texte);
  font: inherit; font-size: 13.5px; outline: none;
}

.lien-vue .menu-vue {
  margin-left: auto; flex: 0 0 auto;
  width: 20px; height: 20px; display: grid; place-items: center;
  border: 0; background: none; border-radius: 4px;
  color: var(--texte-doux); font-size: 13px; line-height: 1; cursor: pointer;
  opacity: 0; transition: opacity .12s;
}
.lien-vue:hover .menu-vue, .lien-vue.actif .menu-vue { opacity: 1; }
.lien-vue .menu-vue:hover { background: var(--bordure); color: var(--texte); }

.action-panneau {
  display: block; width: 100%; text-align: left;
  padding: 7px 10px; border: 0; background: none;
  border-radius: var(--rayon); font-size: 13.5px; color: var(--texte); cursor: pointer;
}
.action-panneau:hover { background: var(--survol); }
.action-panneau.danger { color: var(--danger); }
.renommer { display: flex; gap: 6px; padding: 4px; }
.renommer input {
  flex: 1; padding: 6px 9px; border: 1px solid var(--bordure);
  border-radius: 5px; background: var(--surface); font-size: 13.5px;
}
.renommer input:focus { outline: none; border-color: var(--accent); }

.lien-vue .perso {
  flex: 0 0 auto; width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent); opacity: .55;
}
.lien-vue.actif .perso { opacity: 1; }

.profil { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.profil-pastille {
  width: 24px; height: 24px; flex: 0 0 24px;
  display: grid; place-items: center;
  background: var(--accent); color: #fff;
  border-radius: 50%; font-size: 11px; font-weight: 600;
}
.profil select {
  flex: 1; min-width: 0; padding: 4px 6px;
  border: 1px solid transparent; border-radius: 5px;
  background: transparent; font-size: 12.5px; color: var(--texte); cursor: pointer;
}
.profil select:hover { background: var(--survol); border-color: var(--bordure); }
.profil select:focus { outline: none; border-color: var(--accent); }

.lateral-pied { padding: 10px 14px; border-top: 1px solid var(--bordure); }
.etat { font-size: 11.5px; color: var(--texte-tres-doux); line-height: 1.45; }
.couv-etat {
  display: block; width: 100%; margin-top: 7px; padding: 4px 6px;
  border: 0; border-radius: 5px; background: none;
  text-align: left; cursor: pointer; font: inherit;
  font-size: 11.5px; color: var(--texte-tres-doux);
}
.couv-etat:hover { background: var(--survol); color: var(--texte-doux); }

/* ── Couvertures ── */

td.cel-couverture { padding: 4px 12px; }
.vignette {
  display: block; height: 46px; width: auto; border-radius: 3px;
  background: var(--survol);
  box-shadow: 0 1px 3px rgba(15,15,15,.18);
}

.kb-couv {
  display: block; width: 100%; height: auto; max-height: 190px;
  object-fit: cover; object-position: top;
  border-radius: 5px; margin-bottom: 8px;
  background: var(--survol);
}

.couv-fiche {
  display: flex; align-items: flex-start; gap: 16px;
  padding: 14px 0 4px; margin-bottom: 6px;
  border-bottom: 1px solid var(--bordure);
}
.couv-image { display: block; flex: 0 0 auto; line-height: 0; }
.couv-image img {
  max-height: 220px; max-width: 160px; width: auto; height: auto;
  border-radius: 4px; box-shadow: 0 2px 10px rgba(15,15,15,.2);
  transition: box-shadow .15s;
}
.couv-image:hover img { box-shadow: 0 3px 16px rgba(15,15,15,.3); }
/* ── Stocks et mouvements ── */

.stock-val { font-variant-numeric: tabular-nums; }
.stock-val.zero { color: var(--texte-tres-doux); }
.stock-val.negatif { color: var(--danger); font-weight: 600; }

.stock-resume { display: flex; gap: 8px; margin: 4px 0 12px; flex-wrap: wrap; }
.stock-case {
  flex: 1 1 78px; padding: 8px 10px; border-radius: 7px;
  background: var(--surface); border: 1px solid var(--bordure); text-align: center;
}
.stock-case.total { background: var(--accent-fond); border-color: transparent; }
.stock-case.zero .stock-chiffre { color: var(--texte-tres-doux); }
.stock-case.negatif { border-color: var(--danger); }
.stock-case.negatif .stock-chiffre { color: var(--danger); }
.stock-chiffre { font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stock-lieu { font-size: 10.5px; color: var(--texte-doux); margin-top: 2px; line-height: 1.25; }

/* ── Fiche en sections ── */

/* Les pastilles restent au bord haut du tiroir pendant le défilement :
   c'est ce qui permet de sauter d'une section à l'autre sans remonter. */
.fiche-onglets {
  position: sticky; top: 0; z-index: 3;
  display: flex; flex-wrap: wrap; gap: 5px;
  padding: 2px 0 10px; margin-bottom: 4px;
  background: var(--fond); border-bottom: 1px solid var(--bordure);
}
.fiche-onglet {
  padding: 4px 10px; border: 1px solid var(--bordure); border-radius: 20px;
  background: var(--surface); color: var(--texte-doux);
  font-size: 12px; cursor: pointer; white-space: nowrap;
  transition: background .12s, color .12s, border-color .12s;
}
.fiche-onglet:hover { background: var(--survol); color: var(--texte); }
.fiche-onglet.actif {
  background: var(--selection); color: var(--accent); border-color: var(--accent);
}
/* « Tout » n'est pas une section : un léger retrait le dit sans le crier. */
.fiche-onglet-tout { margin-right: 3px; font-weight: 500; }

.fiche-section { margin-bottom: 4px; }
.fiche-section-titre {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 9px 6px 7px; margin-top: 8px;
  border: 0; border-bottom: 1px solid var(--bordure); background: none;
  font-size: 12px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--texte-doux);
  text-align: left; cursor: pointer;
}
.fiche-section-titre:hover { color: var(--texte); }
.fiche-section-n {
  margin-left: auto; font-size: 11px; font-weight: 400; letter-spacing: 0;
  text-transform: none; color: var(--texte-tres-doux);
  font-variant-numeric: tabular-nums;
}
.fiche-section-corps { padding-top: 4px; }

/* Bascule du journal : discrète au repos, elle ne doit pas concurrencer
   les vignettes de stock, qui sont l'information de tous les jours. */
.mvt-bascule {
  display: flex; align-items: center; gap: 7px;
  width: 100%; padding: 6px 8px; margin-bottom: 6px;
  border: 0; border-radius: var(--rayon); background: none;
  font-size: 12.5px; color: var(--texte-doux); text-align: left; cursor: pointer;
}
.mvt-bascule:hover { background: var(--survol); color: var(--texte); }
.mvt-bascule.ouvert { color: var(--texte); }
.mvt-chevron {
  display: inline-block; width: 10px; color: var(--texte-tres-doux);
  font-size: 10px; line-height: 1;
}

.mvt-liste { display: flex; flex-direction: column; gap: 1px; margin-bottom: 6px; }
.mvt {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 6px; border-radius: 5px; font-size: 12.5px;
}
.mvt:hover { background: var(--survol); }
.mvt-date { flex: 0 0 74px; color: var(--texte-doux); font-variant-numeric: tabular-nums; }
.mvt-type { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mvt-qte { flex: 0 0 auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.mvt-lieux { flex: 0 0 auto; font-size: 11.5px; color: var(--texte-tres-doux); white-space: nowrap; }
.mvt-src { font-size: 10.5px; color: var(--texte-tres-doux); }
.mvt-vide { padding: 10px 6px; font-size: 12.5px; color: var(--texte-tres-doux); }

.mvt-form {
  padding: 10px; margin-top: 4px;
  background: var(--surface); border: 1px solid var(--bordure); border-radius: 7px;
}
.mvt-champ { display: flex; align-items: center; gap: 10px; padding: 3px 0; }
.mvt-champ > label { flex: 0 0 96px; font-size: 12px; color: var(--texte-doux); }
.mvt-champ > select, .mvt-champ > input {
  flex: 1; min-width: 0; padding: 5px 8px;
  border: 1px solid var(--bordure); border-radius: 5px;
  background: var(--fond); font-size: 13px;
}
.mvt-champ > select:focus, .mvt-champ > input:focus { outline: none; border-color: var(--accent); }
.mvt-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }

.couv-actions { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }
.couv-actions .btn { text-decoration: none; text-align: center; }

/* ───────────── Zone principale ───────────── */

#principal { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--fond); }

#entete { border-bottom: 1px solid var(--bordure); padding: 14px 22px 0; }

.entete-haut { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.entete-titre { display: flex; align-items: center; gap: 9px; min-width: 0; }
.vue-icone { color: var(--texte-doux); font-size: 15px; }
#vue-nom { font-size: 18px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.compte { font-size: 12.5px; color: var(--texte-tres-doux); white-space: nowrap; }
.badge-etat {
  font-size: 11px; padding: 2px 8px; border-radius: 20px;
  background: var(--survol); color: var(--texte-doux);
  transition: opacity .2s;
}
.badge-etat.encours { background: var(--accent-fond); color: var(--accent); }
.badge-etat.ok { background: var(--survol); color: var(--texte-tres-doux); }
.badge-etat.echec { background: #ffe2dd; color: #7c352f; font-weight: 500; }
/* Ajustement local, non enregistré : visible sans être alarmant. */
.badge-etat.locale { background: #fdecc8; color: #6b5426; font-weight: 500; }
@media (prefers-color-scheme: dark) {
  .badge-etat.echec { background: #522b28; color: #f4b0a6; }
  .badge-etat.locale { background: #56452a; color: #f3d795; }
}

.etat-sauvegarde.encours { color: var(--accent); }
.etat-sauvegarde.echec { color: var(--danger); font-weight: 500; }
.entete-actions { display: flex; gap: 8px; flex: 0 0 auto; }

.btn {
  padding: 6px 13px; border-radius: var(--rayon); border: 1px solid transparent;
  cursor: pointer; font-size: 13.5px; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn-primaire { background: var(--accent); color: #fff; }
.btn-primaire:hover { filter: brightness(1.08); }
.btn-discret { background: transparent; border-color: var(--bordure-appuyee); color: var(--texte); }
.btn-discret:hover { background: var(--survol); }

.barre-outils { display: flex; align-items: center; gap: 6px; padding: 11px 0 10px; }

.champ-recherche {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px; margin-right: 4px;
  background: var(--surface); border: 1px solid var(--bordure);
  border-radius: var(--rayon); color: var(--texte-doux);
  transition: border-color .12s;
}
.champ-recherche:focus-within { border-color: var(--accent); }
.champ-recherche input {
  border: 0; background: none; outline: none; width: 210px; font-size: 13px;
}
.champ-recherche input::-webkit-search-cancel-button { filter: grayscale(1) opacity(.5); }

.btn-outil {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border: 1px solid transparent; background: none;
  border-radius: var(--rayon); font-size: 13px; color: var(--texte-doux); cursor: pointer;
}
.btn-outil:hover { background: var(--survol); color: var(--texte); }
.btn-outil.actif { background: var(--selection); color: var(--accent); }
.pastille {
  min-width: 17px; height: 17px; padding: 0 5px;
  display: none; place-items: center;
  background: var(--accent); color: #fff;
  border-radius: 20px; font-size: 10.5px; font-weight: 600;
}
.pastille.visible { display: inline-grid; }

/* ───────────── Sélecteur de mode d'affichage ───────────── */

.segments {
  display: inline-flex; gap: 2px; padding: 2px; margin-right: 8px;
  background: var(--surface); border: 1px solid var(--bordure);
  border-radius: 7px;
}
.segments button {
  padding: 4px 11px; border: 0; background: none; border-radius: 5px;
  font-size: 12.5px; color: var(--texte-doux); cursor: pointer;
  transition: background .12s, color .12s;
}
.segments button:hover { color: var(--texte); }
.segments button.actif { background: var(--fond); color: var(--texte); font-weight: 500; box-shadow: 0 1px 2px rgba(15,15,15,.07); }

/* ───────────── Kanban ───────────── */

.kanban {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 16px 22px 22px; width: max-content; min-width: 100%;
}
.kb-colonne {
  /* `min-width: 0` n'est pas décoratif : un élément flex vaut par défaut
     `min-width: auto`, et un mot insécable — un long ISBN, une URL —
     élargirait la colonne au-delà des 288 px annoncés. */
  flex: 0 0 288px; min-width: 0;
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--bordure);
  border-radius: 9px; transition: border-color .12s, background .12s;
}
.kb-colonne.cible { border-color: var(--accent); background: var(--selection); }
.kb-entete {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 12px 9px; border-bottom: 1px solid var(--bordure);
}
.kb-entete .n {
  margin-left: auto; font-size: 11.5px; color: var(--texte-tres-doux);
  font-variant-numeric: tabular-nums;
  flex: 0 0 auto;                       /* le compte ne se comprime jamais */
}
/* Les étiquettes sont en `nowrap` — ce qui convient dans une cellule de
   tableau, mais pas ici : « Journal of Cross-Regional Dialogues » est plus
   large que la colonne et la ferait déborder. En en-tête, elle se replie. */
.kb-entete .etiquette {
  white-space: normal; overflow-wrap: anywhere;
  line-height: 16px; padding: 3px 8px; min-width: 0;
}
/* Rangement des colonnes : l'en-tête se saisit, un liseré vertical marque
   l'endroit où la colonne se posera. */
.kb-entete { cursor: grab; }
.kb-entete.glisse-groupe { opacity: .35; }
.kb-entete.cible-avant { box-shadow: inset 2px 0 0 var(--accent); }
.kb-entete.cible-apres { box-shadow: inset -2px 0 0 var(--accent); }

.kb-cartes {
  display: flex; flex-direction: column; gap: 7px;
  padding: 9px; min-height: 54px;
  max-height: calc(100vh - 280px); overflow-y: auto;
}
.kb-carte {
  background: var(--fond); border: 1px solid var(--bordure);
  border-radius: 7px; padding: 9px 11px; cursor: pointer;
  transition: border-color .12s, box-shadow .12s;
}
.kb-carte:hover { border-color: var(--bordure-appuyee); box-shadow: 0 1px 3px rgba(15,15,15,.06); }
.kb-carte.glisse { opacity: .35; }
/* Une colonne cochée = une ligne de carte, au sens du champ et non de la
   ligne typographique : la colonne garde sa largeur, et le texte revient
   à la ligne autant de fois qu'il le faut. Un titre d'ouvrage tronqué ne
   se reconnaît pas, et deux auteurs sur trois ne valent pas mieux.
   `overflow-wrap: anywhere` ne coupe que ce qui ne peut pas l'être
   autrement — un mot insécable plus large que la carte. */
.kb-titre-carte {
  font-size: 13.5px; font-weight: 500; line-height: 1.35;
  overflow-wrap: anywhere;
}
.kb-champ {
  font-size: 12px; color: var(--texte-doux); line-height: 1.4;
  overflow-wrap: anywhere;
}
.kb-carte > div + div { margin-top: 4px; }
.kb-carte .kb-couv + div { margin-top: 7px; }
.kb-vide-carte { color: var(--texte-tres-doux); font-weight: 400; }
.kb-case .coche { color: var(--accent); }
.kb-case .coche-non { color: var(--texte-tres-doux); }
.kb-vide { padding: 14px 12px; font-size: 12.5px; color: var(--texte-tres-doux); text-align: center; }

/* Colonne exclue par le filtre de la vue : on peut y déposer, mais la
   fiche quittera l'écran. Le pointillé le dit avant le geste. */
.kb-colonne.hors-filtre { border-style: dashed; background: transparent; }
.kb-colonne.hors-filtre .kb-entete { opacity: .62; }
.kb-hors {
  font-size: 10px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--texte-tres-doux); border: 1px solid var(--bordure-appuyee);
  border-radius: 4px; padding: 0 4px;
}

/* ───────────── Planning ───────────── */

.planning { --mois-l: 132px; padding-bottom: 24px; width: max-content; min-width: 100%; }

.pl-entete { display: flex; position: sticky; top: 0; z-index: 3; background: var(--fond); }
.pl-mois {
  flex: 0 0 var(--mois-l); padding: 8px 10px;
  border-bottom: 1px solid var(--bordure); border-left: 1px solid var(--bordure);
  font-size: 12px; color: var(--texte-doux); white-space: nowrap;
}
.pl-mois.janvier { border-left: 2px solid var(--bordure-appuyee); }
.pl-mois .an { color: var(--texte-tres-doux); margin-left: 5px; font-size: 11px; }

.pl-note {
  padding: 10px 22px 2px; font-size: 12px; color: var(--texte-tres-doux);
  position: sticky; left: 0; width: 100vw;
}
.pl-note strong { color: var(--texte-doux); font-weight: 500; }

.pl-corps { position: relative; }
.pl-grille { position: absolute; inset: 0; display: flex; pointer-events: none; }
.pl-colonne { flex: 0 0 var(--mois-l); border-left: 1px solid var(--bordure); }
.pl-colonne.janvier { border-left: 2px solid var(--bordure-appuyee); }

.pl-ligne { position: relative; height: 31px; }
.pl-pilule {
  position: absolute; top: 4px; height: 23px;
  display: flex; align-items: center; gap: 6px;
  padding: 0 5px 0 11px; border-radius: 20px;
  font-size: 12px; white-space: nowrap; cursor: pointer;
  /* Fond neutre : la pilule accueille des étiquettes qui portent chacune
     la couleur de son menu. Un fond teinté les ferait toutes mentir. */
  background: var(--fond); color: var(--texte);
  border: 1px solid var(--bordure);
  transition: border-color .12s, box-shadow .12s;
}
.pl-pilule:hover { border-color: var(--accent); box-shadow: 0 1px 3px rgba(15,15,15,.07); }
.pl-pilule .etiquette { flex: 0 0 auto; }
.pl-pilule .date { opacity: .65; font-variant-numeric: tabular-nums; }
/* Le premier champ mène, les suivants s'effacent d'un cran : sur une seule
   ligne, c'est la seule hiérarchie disponible. */
.pl-pilule .pl-champ { opacity: .78; }
.pl-pilule .pl-sep { opacity: .4; margin: 0 -2px; }

.pl-aujourdhui { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--danger); opacity: .55; z-index: 2; }
.pl-etiquette-jour {
  position: absolute; top: 0; transform: translateX(-50%);
  font-size: 10px; color: var(--danger); background: var(--fond);
  padding: 0 4px; z-index: 3;
}

/* ───────────── Tableau ───────────── */

#zone-tableau { flex: 1; overflow: auto; }

#tableau { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; }

#tableau thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--fond);
  border-bottom: 1px solid var(--bordure);
  padding: 8px 12px;
  font-size: 12px; font-weight: 500; color: var(--texte-doux);
  text-align: left; white-space: nowrap;
  cursor: pointer; user-select: none;
}
#tableau thead th:hover { color: var(--texte); }
#tableau thead th .fleche { color: var(--accent); margin-left: 3px; font-size: 10px; }

#tableau tbody td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--bordure);
  font-size: 13px; vertical-align: top;
  max-width: 380px;
}
#tableau tbody tr:hover td { background: var(--survol); }

/* ── Édition directe dans le tableau ── */

#tableau tbody td.cel-modifiable { cursor: text; }
#tableau tbody td.cel-choix { cursor: pointer; }
#tableau tbody td.en-edition { padding: 3px 8px; background: var(--fond); }

.saisie-cellule {
  width: 100%; padding: 3px 6px;
  border: 1px solid var(--accent); border-radius: 4px;
  background: var(--fond); font-size: 13px; outline: none;
}

/* Confirmation d'écriture : un liseré qui s'efface, sans décaler la mise en page. */
@keyframes flashEnregistre {
  from { outline-color: var(--accent); }
  to   { outline-color: transparent; }
}
#tableau tbody td.enregistre {
  outline: 2px solid transparent; outline-offset: -2px;
  animation: flashEnregistre 1s ease;
}

/* Bouton d'ouverture de la fiche, dans la première colonne.

   Le bouton se pose en absolu : la cellule doit donc être positionnée pour
   lui servir de repère. `sticky` en est un autant que `relative` — d'où le
   `:not(.figee)`, sans lequel cette règle, plus spécifique que celle du
   figeage, écraserait le `sticky` et la première colonne défilerait
   pendant que son en-tête reste. */
#tableau tbody td:first-child { padding-right: 32px; }
#tableau tbody td:first-child:not(.figee) { position: relative; }
.btn-ouvrir {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 20px; height: 20px; display: grid; place-items: center;
  border: 1px solid var(--bordure); border-radius: 4px;
  background: var(--fond); color: var(--texte-doux);
  font-size: 11px; line-height: 1; cursor: pointer;
  opacity: 0; transition: opacity .12s;
}
#tableau tbody tr:hover .btn-ouvrir { opacity: 1; }
.btn-ouvrir:hover { background: var(--survol); color: var(--texte); border-color: var(--bordure-appuyee); }
.btn-ouvrir:focus-visible { opacity: 1; outline: 2px solid var(--accent); }

/* Colonnes figées : elles restent visibles au défilement horizontal.
   Le fond doit être opaque, sinon le contenu défilant transparaît. */
#tableau .figee { position: sticky; z-index: 1; background: var(--fond); }
#tableau thead th.figee { z-index: 4; }
#tableau tbody tr:hover td.figee { background: var(--survol); }
#tableau .figee-bord { box-shadow: 1px 0 0 var(--bordure); }
#tableau thead th.figee-bord { box-shadow: 1px 0 0 var(--bordure); }

td.cel-titre { font-weight: 500; white-space: nowrap; }
td.cel-nombre { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.cel-date { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--texte-doux); }
td.cel-long { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

tr.ligne-groupe td {
  background: var(--surface);
  font-size: 12px; font-weight: 600; color: var(--texte-doux);
  padding: 9px 12px; letter-spacing: .01em;
  border-bottom: 1px solid var(--bordure);
}
/* C'est le contenu qui colle à gauche, pas la cellule : celle-ci s'étend
   déjà sur toute la largeur et n'aurait aucune marge de déplacement. */
.grp-contenu { position: sticky; left: 12px; display: inline-flex; align-items: baseline; }
tr.ligne-groupe .n { font-weight: 400; color: var(--texte-tres-doux); margin-left: 6px; }

/* Étiquettes — reprise de la palette Notion */
.etiquette {
  display: inline-block; padding: 1px 8px; border-radius: 20px;
  font-size: 12px; line-height: 18px; white-space: nowrap;
  background: var(--survol); color: var(--texte);
}
.et-default,.et-gray  { background:#e9e9e7; color:#3c3c3a; }
.et-brown  { background:#eee0da; color:#5c4436; }
.et-orange { background:#fadec9; color:#7a4726; }
.et-yellow { background:#fdecc8; color:#6b5426; }
.et-green  { background:#dbeddb; color:#33553f; }
.et-blue   { background:#d3e5ef; color:#28516b; }
.et-purple { background:#e8deee; color:#4f3d63; }
.et-pink   { background:#f5e0e9; color:#68374f; }
.et-red    { background:#ffe2dd; color:#7c352f; }

@media (prefers-color-scheme: dark) {
  .et-default,.et-gray  { background:#373737; color:#d4d4d2; }
  .et-brown  { background:#4a3228; color:#e0c4b4; }
  .et-orange { background:#5c3a22; color:#f6c99f; }
  .et-yellow { background:#56452a; color:#f3d795; }
  .et-green  { background:#2c4434; color:#b3ddc0; }
  .et-blue   { background:#28404f; color:#a9cee2; }
  .et-purple { background:#3f3350; color:#cfb8e0; }
  .et-pink   { background:#4d2f3d; color:#eeb5cd; }
  .et-red    { background:#522b28; color:#f4b0a6; }
}

.coche { color: var(--accent); font-size: 14px; }
.coche-non { color: var(--bordure-appuyee); font-size: 14px; }
.rien { color: var(--texte-tres-doux); }

.vide { padding: 60px 20px; text-align: center; color: var(--texte-tres-doux); }

#pied {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 8px 22px; border-top: 1px solid var(--bordure);
  font-size: 11.5px; color: var(--texte-tres-doux); background: var(--fond);
}
#pied code { font-size: 11px; background: var(--survol); padding: 1px 5px; border-radius: 4px; }

/* ───────────── Panneaux flottants ───────────── */

#voile, #tiroir-voile { position: fixed; inset: 0; z-index: 40; }
#tiroir-voile { background: rgba(15,15,15,.28); }

.panneau {
  position: fixed; z-index: 50;
  width: 380px; max-height: 74vh;
  background: var(--fond); border: 1px solid var(--bordure);
  border-radius: 10px; box-shadow: var(--ombre);
  display: flex; flex-direction: column; overflow: hidden;
}
.panneau-entete {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px; border-bottom: 1px solid var(--bordure);
  font-size: 13px; font-weight: 600;
}
.panneau-corps { overflow-y: auto; padding: 8px; }

.btn-fermer, .btn-icone {
  border: 0; background: none; cursor: pointer; color: var(--texte-doux);
  width: 26px; height: 26px; border-radius: var(--rayon); font-size: 13px;
  display: grid; place-items: center;
}
.btn-fermer:hover, .btn-icone:hover { background: var(--survol); color: var(--texte); }

.opt-colonne {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 8px; border-radius: var(--rayon); cursor: pointer; font-size: 13.5px;
}
.opt-colonne:hover { background: var(--survol); }
.opt-colonne input { accent-color: var(--accent); }
.opt-colonne .type { margin-left: auto; font-size: 11px; color: var(--texte-tres-doux); }

/* En-tête des deux sections du panneau Colonnes, avec son raccourci. */
.titre-section {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 10px 8px 4px;
  font-size: 11px; font-weight: 600; letter-spacing: .05em;
  text-transform: uppercase; color: var(--texte-tres-doux);
}
.titre-section:first-child { padding-top: 4px; }

.lien-discret {
  border: 0; background: none; cursor: pointer; padding: 0;
  font-size: 11px; letter-spacing: 0; text-transform: none;
  color: var(--texte-doux); text-decoration: underline;
  text-underline-offset: 2px; text-decoration-color: var(--bordure-appuyee);
}
.lien-discret:hover { color: var(--accent); text-decoration-color: currentColor; }

/* La poignée n'apparaît qu'au survol : au repos, une colonne de points
   devant chaque ligne ferait du bruit sans rien dire de plus. */
.opt-colonne.affichee { cursor: grab; }
.opt-colonne .poignee {
  flex: 0 0 12px; margin-left: -4px;
  color: var(--texte-tres-doux); font-size: 12px; line-height: 1;
  opacity: 0; transition: opacity .12s;
}
.opt-colonne.affichee:hover .poignee { opacity: 1; }
.opt-colonne.glisse-col { opacity: .35; }
.opt-colonne.cible-avant { box-shadow: inset 0 2px 0 var(--accent); }
.opt-colonne.cible-apres { box-shadow: inset 0 -2px 0 var(--accent); }

.reglage {
  display: flex; align-items: center; gap: 8px;
  padding: 8px; margin-bottom: 5px;
  border-bottom: 1px solid var(--bordure);
  font-size: 13.5px;
}
.reglage select {
  margin-left: auto; padding: 4px 8px;
  border: 1px solid var(--bordure); border-radius: 5px;
  background: var(--surface); font-size: 12.5px;
}
.reglage select:focus { outline: none; border-color: var(--accent); }

.regle {
  display: flex; gap: 6px; align-items: center;
  padding: 6px; border-radius: var(--rayon); margin-bottom: 4px;
}
.regle select, .regle input {
  padding: 5px 7px; border: 1px solid var(--bordure); border-radius: 5px;
  background: var(--surface); font-size: 12.5px; min-width: 0;
}
.regle select:focus, .regle input:focus { outline: none; border-color: var(--accent); }
.regle .col { flex: 1.3; } .regle .op { flex: 1; } .regle .val { flex: 1.2; }
.regle .sup { flex: 0 0 auto; }

.ajouter {
  display: block; width: 100%; text-align: left;
  padding: 7px 8px; margin-top: 2px;
  border: 0; background: none; border-radius: var(--rayon);
  color: var(--accent); font-size: 13px; cursor: pointer;
}
.ajouter:hover { background: var(--survol); }

/* ───────────── Tiroir de fiche ───────────── */

#tiroir {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50;
  width: 520px; max-width: 94vw;
  background: var(--fond); border-left: 1px solid var(--bordure);
  box-shadow: var(--ombre);
  display: flex; flex-direction: column;
  animation: glisser .18s ease;
}
@keyframes glisser { from { transform: translateX(24px); opacity: 0; } }

.tiroir-entete {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--bordure);
}
.tiroir-sur-titre {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--texte-tres-doux); margin-bottom: 3px;
}
#tiroir-titre { font-size: 17px; letter-spacing: -.01em; }
.tiroir-actions { display: flex; gap: 2px; flex: 0 0 auto; }

.tiroir-corps { flex: 1; overflow-y: auto; padding: 8px 20px 20px; }

.champ { display: flex; gap: 12px; padding: 5px 0; align-items: flex-start; }
.champ > label {
  flex: 0 0 168px; padding-top: 6px;
  font-size: 12.5px; color: var(--texte-doux); line-height: 1.35;
}
.champ > .saisie { flex: 1; min-width: 0; }

.saisie input[type=text], .saisie input[type=number], .saisie input[type=date],
.saisie select, .saisie textarea {
  width: 100%; padding: 6px 9px;
  border: 1px solid transparent; border-radius: 5px;
  background: var(--surface); font-size: 13.5px;
  transition: border-color .12s, background .12s;
}
.saisie input:hover, .saisie select:hover, .saisie textarea:hover { background: var(--survol); }
.saisie input:focus, .saisie select:focus, .saisie textarea:focus {
  outline: none; border-color: var(--accent); background: var(--fond);
}
.saisie textarea { resize: vertical; min-height: 62px; line-height: 1.5; }
.saisie .lecture-seule {
  padding: 6px 9px; font-size: 13px; color: var(--texte-doux);
  background: var(--surface); border-radius: 5px; word-break: break-word;
}

.bascule { position: relative; display: inline-block; width: 34px; height: 20px; margin-top: 4px; }
.bascule input { opacity: 0; width: 0; height: 0; }
.bascule .piste {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--bordure-appuyee); border-radius: 20px; transition: background .15s;
}
.bascule .piste::before {
  content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px;
  background: #fff; border-radius: 50%; transition: transform .15s;
  box-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.bascule input:checked + .piste { background: var(--accent); }
.bascule input:checked + .piste::before { transform: translateX(14px); }

.section-titre {
  margin: 18px 0 4px; padding-top: 12px;
  border-top: 1px solid var(--bordure);
  font-size: 11px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--texte-tres-doux);
}
.section-titre:first-child { border-top: 0; margin-top: 4px; padding-top: 0; }

.tiroir-pied {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 20px; border-top: 1px solid var(--bordure);
}
.etat-sauvegarde { font-size: 12px; color: var(--texte-tres-doux); }

/* ───────────── Notifications ───────────── */

#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 90;
  display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 10px 9px 16px; border-radius: 20px;
  background: var(--texte); color: var(--fond);
  font-size: 13px; box-shadow: var(--ombre);
  max-width: min(660px, 92vw); animation: monte .2s ease;
}
.toast-action {
  flex: 0 0 auto; padding: 4px 11px; border: 0; border-radius: 20px;
  background: rgba(255,255,255,.18); color: inherit;
  font-size: 12.5px; font-weight: 500; cursor: pointer;
}
.toast-action:hover { background: rgba(255,255,255,.3); }
.toast.erreur { background: var(--danger); color: #fff; }
@keyframes monte { from { transform: translateY(8px); opacity: 0; } }

/* ───────────── Barres de défilement ───────────── */

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb {
  background: var(--bordure-appuyee); border-radius: 8px;
  border: 3px solid var(--fond); background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--texte-tres-doux); background-clip: padding-box; border: 3px solid var(--fond); }
::-webkit-scrollbar-corner { background: var(--fond); }

/* Emplacement d'une couverture absente : visible mais silencieux, il
   n'existe que pour porter le bouton de dépôt. */
.couv-image.vide {
  display: grid; place-items: center; min-height: 150px;
  border: 2px dashed var(--bordure-appuyee); border-radius: var(--rayon);
  background: var(--surface);
}
.couv-absente { font-size: 12.5px; color: var(--texte-tres-doux); }

/* ───────────── Dépôt d'un relevé ───────────── */

.depot { margin-bottom: 14px; }
.depot-cible {
  display: block; padding: 20px 16px; text-align: center; cursor: pointer;
  border: 2px dashed var(--bordure-appuyee); border-radius: 10px;
  background: var(--surface); transition: border-color .12s, background .12s;
}
.depot-cible:hover, .depot-cible.survol {
  border-color: var(--accent); background: var(--selection);
}
.depot-icone { font-size: 22px; color: var(--accent); line-height: 1; }
.depot-titre { font-size: 13.5px; font-weight: 600; margin-top: 6px; }
.depot-sous { font-size: 12px; color: var(--texte-doux); margin-top: 3px; }

.depot-attente { padding: 10px 4px; font-size: 12.5px; color: var(--texte-doux); }
.depot-echec {
  padding: 10px 12px; margin-top: 8px; border-radius: var(--rayon);
  background: var(--accent-fond); color: var(--danger); font-size: 12.5px;
}
.depot-carte {
  margin-top: 10px; padding: 12px 14px;
  border: 1px solid var(--bordure); border-left: 3px solid var(--accent);
  border-radius: var(--rayon); background: var(--fond);
}
/* Non reconnu : le trait s'éteint plutôt que de virer au rouge — il n'y a
   pas d'erreur, seulement une question posée. */
.depot-carte.inconnu { border-left-color: var(--texte-tres-doux); }
.depot-nom { font-size: 13px; font-weight: 500; margin-bottom: 8px; }
.depot-type {
  width: 100%; padding: 6px 8px; font-size: 13px;
  border: 1px solid var(--bordure); border-radius: 5px; background: var(--surface);
}
.depot-raison {
  margin-top: 6px; font-size: 12px; color: var(--texte-doux); line-height: 1.45;
}
.depot-certitude {
  display: inline-block; padding: 0 6px; margin-right: 5px;
  border-radius: 10px; font-size: 11px; line-height: 17px;
}
.depot-certitude.sûre { background: #dbeddb; color: #2c5a2c; }
.depot-certitude.probable { background: #faedcb; color: #6b5a1e; }
.depot-alerte {
  margin-top: 8px; padding: 7px 10px; border-radius: var(--rayon);
  background: var(--survol); font-size: 12px; color: var(--texte-doux);
}
.depot-actions { display: flex; gap: 6px; margin-top: 10px; }

.fraicheur { margin-bottom: 6px; }
.fr-ligne {
  display: flex; align-items: baseline; gap: 10px;
  padding: 5px 6px; border-bottom: 1px solid var(--bordure); font-size: 12.5px;
}
.fr-ligne:last-child { border-bottom: 0; }
.fr-nom { flex: 1; min-width: 0; }
.fr-age { color: var(--texte-tres-doux); white-space: nowrap; }
.fr-age.tard { color: var(--danger); font-weight: 500; }

/* ───────────── Le travail ───────────── */

.lien-travail {
  display: flex; align-items: center; gap: 8px;
  margin: 0 8px 8px; padding: 8px 10px;
  border: 1px solid var(--bordure); border-radius: var(--rayon);
  background: var(--surface); color: var(--texte);
  font-size: 13.5px; font-weight: 500; text-align: left; cursor: pointer;
}
.lien-travail:hover { background: var(--survol); border-color: var(--bordure-appuyee); }
.lien-travail .ic { color: var(--accent); }
.lien-travail .nom { flex: 1; }
.lien-travail .pastille {
  min-width: 19px; padding: 0 5px; border-radius: 10px;
  background: var(--danger); color: #fff;
  font-size: 11px; line-height: 18px; text-align: center;
  font-variant-numeric: tabular-nums;
}

#travail-voile { position: fixed; inset: 0; z-index: 40; background: rgba(15,15,15,.28); }
#travail {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50;
  width: min(760px, 96vw);
  background: var(--fond); border-left: 1px solid var(--bordure);
  box-shadow: var(--ombre); display: flex; flex-direction: column;
}

.tr-bande {
  display: flex; align-items: baseline; gap: 9px;
  margin: 20px 0 2px; padding-top: 12px;
  border-top: 1px solid var(--bordure);
}
.tr-bande:first-child { margin-top: 2px; border-top: 0; padding-top: 0; }
.tr-bande-titre { font-size: 13px; font-weight: 600; }
.tr-bande-n {
  font-size: 11.5px; color: var(--texte-tres-doux);
  font-variant-numeric: tabular-nums;
}
.tr-bande-note {
  font-size: 12px; color: var(--texte-tres-doux);
  margin-bottom: 8px; line-height: 1.4;
}

.tr-ligne {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 9px 11px; margin-bottom: 4px;
  border: 1px solid var(--bordure); border-radius: var(--rayon);
  background: var(--fond);
}
/* Le retard se voit d'un trait sur le bord, pas d'un fond coloré : sur
   vingt lignes, vingt fonds rouges ne hiérarchisent plus rien. */
.tr-ligne.tr-retard { border-left: 3px solid var(--danger); }
.tr-ligne.tr-corriger { border-left: 3px solid var(--texte-tres-doux); }
.tr-gauche { flex: 1; min-width: 0; }
.tr-libelle { font-size: 13.5px; line-height: 1.35; }
.tr-sous {
  display: flex; flex-wrap: wrap; align-items: center; gap: 5px 10px;
  margin-top: 3px; font-size: 12px; color: var(--texte-doux);
}
.tr-livre {
  border: 0; background: none; padding: 0; cursor: pointer;
  font-size: 12px; font-weight: 500; color: var(--accent);
  text-decoration: underline; text-underline-offset: 2px;
  text-decoration-color: var(--bordure-appuyee);
}
.tr-livre:hover { text-decoration-color: currentColor; }
.tr-qui, .tr-parution { color: var(--texte-tres-doux); }

.tr-droite {
  display: flex; flex-direction: column; align-items: flex-end; gap: 3px;
  flex: 0 0 auto; text-align: right;
}
.tr-charge {
  font-size: 12px; color: var(--texte-doux);
  font-variant-numeric: tabular-nums;
}
.tr-delai { font-size: 11.5px; color: var(--texte-tres-doux); white-space: nowrap; }
.tr-delai-chaud { color: var(--danger); }
.tr-notes { color: var(--texte-tres-doux); font-style: italic; }

/* Les tâches réelles se cochent ; les lignes déduites, non. La case n'est
   donc pas un ornement : c'est ce qui distingue les deux natures à l'œil. */
.tr-case { margin-top: 3px; accent-color: var(--accent); flex: 0 0 auto; }
.tr-ligne.tr-mienne { border-left: 3px solid var(--bordure-appuyee); }
.tr-ligne.tr-mienne.tr-retard { border-left-color: var(--danger); }
.tr-ligne.tr-partie { opacity: .35; transition: opacity .35s; }

.tr-neuve { border-color: var(--accent); align-items: flex-start; }
.tr-neuve .tr-gauche { display: flex; flex-direction: column; gap: 6px; }
.tr-notes-saisie {
  resize: vertical; min-height: 44px; font-family: inherit; line-height: 1.4;
}
.tr-champ, .tr-champ-court {
  border: 1px solid var(--bordure); border-radius: 5px;
  padding: 5px 8px; background: var(--fond); font-size: 13px;
}
.tr-champ { width: 100%; }
.tr-champ-court { font-size: 12px; padding: 3px 6px; }
.tr-neuve .tr-droite { flex-direction: row; align-items: center; gap: 6px; }

/* ───────────── Rapprochement des lignes orphelines ───────────── */

#rappro-voile {
  position: fixed; inset: 0; z-index: 49;
  background: rgba(15, 15, 15, .28);
}
#rapprochement {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50;
  width: 720px; max-width: 96vw;
  background: var(--fond); border-left: 1px solid var(--bordure);
  box-shadow: var(--ombre);
  display: flex; flex-direction: column;
  animation: glisser .18s ease;
}
#rapprochement .tiroir-actions { align-items: center; gap: 10px; }

.rappro-groupe {
  border: 1px solid var(--bordure); border-radius: 10px;
  padding: 12px 14px; margin-bottom: 10px; background: var(--fond);
}
.rappro-groupe.traite { opacity: .62; }
.rappro-titre { display: flex; align-items: baseline; gap: 10px; }
.rappro-titre b { font-size: 13.5px; font-weight: 560; }
.rappro-quantite {
  margin-left: auto; flex: 0 0 auto;
  font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--texte-doux);
}
.rappro-meta {
  margin-top: 3px; font-size: 11.5px; color: var(--texte-tres-doux);
  display: flex; flex-wrap: wrap; gap: 4px 10px;
}
.rappro-meta code { font-size: 11px; }

.rappro-choix { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.rappro-suggestion {
  border: 1px solid var(--bordure-appuyee); border-radius: 7px;
  background: transparent; color: var(--texte);
  padding: 4px 9px; font-size: 12px; cursor: pointer;
  display: inline-flex; align-items: baseline; gap: 6px;
}
.rappro-suggestion:hover { background: var(--selection); border-color: var(--accent); color: var(--accent); }
.rappro-suggestion .motif { font-size: 10.5px; color: var(--texte-tres-doux); }
.rappro-suggestion:hover .motif { color: inherit; }

.rappro-recherche { position: relative; flex: 1 1 220px; min-width: 180px; }
.rappro-recherche input { width: 100%; }
.rappro-resultats {
  position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 3px);
  max-height: 240px; overflow-y: auto;
  background: var(--fond); border: 1px solid var(--bordure-appuyee);
  border-radius: 8px; box-shadow: var(--ombre); padding: 3px;
}
.rappro-resultats button {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 12.5px; color: var(--texte);
}
.rappro-resultats button:hover { background: var(--survol); }
.rappro-resultats .ref { color: var(--texte-tres-doux); font-size: 11px; }

.rappro-vide { padding: 40px 8px; text-align: center; color: var(--texte-doux); }

/* ───────────── Tâches de gestion des ventes et du stock ───────────── */

#taches-voile { position: fixed; inset: 0; z-index: 49; background: rgba(15, 15, 15, .28); }
#taches {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50;
  width: 620px; max-width: 96vw;
  background: var(--fond); border-left: 1px solid var(--bordure);
  box-shadow: var(--ombre);
  display: flex; flex-direction: column;
  animation: glisser .18s ease;
}

.tache {
  border: 1px solid var(--bordure); border-radius: 10px;
  padding: 11px 13px; margin-bottom: 9px;
}
.tache-haut { display: flex; align-items: baseline; gap: 10px; }
.tache-haut b { font-size: 13.5px; font-weight: 560; }
.tache-quand {
  font-size: 11px; color: var(--texte-tres-doux);
  border: 1px solid var(--bordure); border-radius: 20px; padding: 1px 8px;
}
.tache-haut .btn { margin-left: auto; flex: 0 0 auto; }
.tache-detail { margin-top: 4px; font-size: 12px; color: var(--texte-doux); line-height: 1.45; }
.tache-sortie {
  margin-top: 9px; padding: 9px 11px; border-radius: 8px;
  background: var(--survol); border: 1px solid var(--bordure);
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11.5px;
  white-space: pre-wrap; max-height: 260px; overflow-y: auto; line-height: 1.5;
}
.tache-sortie.echec { border-color: var(--danger); }
.tache.occupee { opacity: .75; }
.taches-note {
  font-size: 12px; color: var(--texte-doux); line-height: 1.5;
  padding: 2px 2px 14px;
}

/* Colonnes d'envoi : un total qu'on complète, jamais qu'on remplace. */
.cel-envoi { cursor: cell; }
.envoi-val { font-variant-numeric: tabular-nums; }
.cel-envoi:hover { background: var(--selection); }

/* ───────────── Relations entre fiches ───────────── */

.relation { display: flex; flex-direction: column; gap: 6px; }
.rel-liens { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }

.rel-puce {
  display: inline-flex; align-items: stretch;
  border: 1px solid var(--bordure-appuyee); border-radius: 7px;
  overflow: hidden; background: var(--fond);
}
.rel-puce:hover { border-color: var(--accent); }
.rel-puce.manquant { border-color: var(--danger); }

.rel-nom {
  border: 0; background: transparent; cursor: pointer;
  padding: 4px 8px; font-size: 12.5px; color: var(--texte);
  max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rel-nom:hover { background: var(--selection); color: var(--accent); }
.rel-oter {
  border: 0; border-left: 1px solid var(--bordure); background: transparent;
  cursor: pointer; padding: 0 7px; font-size: 13px; color: var(--texte-tres-doux);
}
.rel-oter:hover { background: var(--danger); color: #fff; }

.rel-ajout { position: relative; display: inline-block; }
.rel-ajout input {
  width: 130px; padding: 4px 8px; font-size: 12.5px;
  border: 1px dashed var(--bordure-appuyee); border-radius: 7px;
  background: transparent; color: var(--texte);
}
.rel-ajout input:focus { border-style: solid; border-color: var(--accent); width: 200px; }

.rel-resultats {
  position: absolute; z-index: 6; left: 0; top: calc(100% + 3px); min-width: 240px;
  max-height: 240px; overflow-y: auto;
  background: var(--fond); border: 1px solid var(--bordure-appuyee);
  border-radius: 8px; box-shadow: var(--ombre); padding: 3px;
}
.rel-resultats button {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 12.5px; color: var(--texte);
}
.rel-resultats button:hover { background: var(--survol); }
.rel-resultats .rel-creer {
  border-top: 1px solid var(--bordure); margin-top: 3px; color: var(--accent);
}

/* Une relation dans le tableau : les noms, pas les identifiants. */
.cel-relation { color: var(--texte-doux); }

/* Une relation dans le tableau : des noms cliquables, une cellule qui s'ouvre. */
.cel-relation { cursor: cell; }
.rel-lien {
  border: 0; background: transparent; padding: 0; cursor: pointer;
  font: inherit; color: var(--texte); border-bottom: 1px solid transparent;
}
.rel-lien:hover { color: var(--accent); border-bottom-color: var(--accent); }
.rel-sep { color: var(--texte-tres-doux); margin: 0 6px; }

/* En édition, la cellule s'élargit assez pour recevoir puces et recherche. */
td.en-edition .relation-cellule { min-width: 260px; }
td.en-edition .relation-cellule .rel-liens { gap: 4px; }

/* Colonne fabriquée depuis une autre : visible, consultable, non saisissable. */
.cel-derivee { color: var(--texte-doux); font-style: italic; }
.lecture-seule.derivee { font-style: italic; }
.note-derivee {
  margin-top: 3px; font-size: 11px; line-height: 1.4;
  color: var(--texte-tres-doux);
}

/* ───────────── Fiche imprimeur ───────────── */

.fi-bloc { margin: 4px 0 10px; }
.fi-zone:empty { display: none; }
.fi-carte {
  margin-top: 8px; padding: 12px 14px;
  border: 1px solid var(--bordure); border-left: 3px solid var(--accent);
  border-radius: var(--rayon); background: var(--fond);
}
.fi-champ { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.fi-libelle { flex: 0 0 82px; font-size: 12.5px; color: var(--texte-doux); }
.fi-champ select {
  flex: 1; padding: 5px 8px; font-size: 13px;
  border: 1px solid var(--bordure); border-radius: 5px; background: var(--surface);
}
.fi-dest { font-size: 12px; color: var(--texte-tres-doux); margin: 2px 0 10px; }
.fi-attente { padding: 8px 4px; font-size: 12.5px; color: var(--texte-tres-doux); }
.fi-titre { font-size: 13.5px; font-weight: 500; }
.fi-sous { font-size: 11.5px; color: var(--texte-tres-doux); margin-top: 2px;
           word-break: break-all; }
.fi-fichier {
  display: flex; align-items: baseline; gap: 8px;
  margin-top: 7px; font-size: 12.5px;
}
.fi-lien { color: var(--accent); text-decoration: underline;
           text-underline-offset: 2px; text-decoration-color: var(--bordure-appuyee); }
.fi-lien:hover { text-decoration-color: currentColor; }
.fi-poids { margin-left: auto; color: var(--texte-tres-doux); font-size: 11.5px;
            font-variant-numeric: tabular-nums; }
/* L'envoi se détache : c'est le seul geste de cet écran qui sorte de la maison. */
.fi-envoi { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--bordure); }
.fi-envoi .btn { width: 100%; }
.fi-carte .btn-discret { margin-top: 8px; width: 100%; }
.fi-tel {
  flex: 0 0 auto; padding: 0 5px; border-radius: 4px;
  color: var(--texte-doux); text-decoration: none; font-size: 13px;
}
.fi-tel:hover { background: var(--survol); color: var(--texte); }

/* ─────────── Étiquettes d'expédition ─────────── */
#etiq-voile { position: fixed; inset: 0; z-index: 49; background: rgba(15,15,15,.28); }
#etiquettes {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50;
  width: min(880px, 96vw);
  background: var(--fond); border-left: 1px solid var(--bordure);
  box-shadow: var(--ombre); display: flex; flex-direction: column;
  animation: glisser .18s ease;
}
#etiquettes .tiroir-actions { align-items: center; gap: 10px; }
#etiquettes .tiroir-pied { display: flex; align-items: center; gap: 12px; }
#etiquettes .tiroir-pied .btn { margin-left: auto; }

.etiq-recherche { margin: 4px 0 16px; }
.etiq-recherche input[type="search"] {
  width: 100%; padding: 8px 10px; font-size: 13.5px;
  border: 1px solid var(--bordure); border-radius: 8px;
  background: var(--fond); color: inherit;
}
.etiq-resultats:not(:empty) {
  margin-top: 6px; border: 1px solid var(--bordure); border-radius: 8px;
  overflow: hidden; max-height: 280px; overflow-y: auto;
}
.etiq-resultat {
  display: flex; align-items: baseline; gap: 10px; width: 100%;
  padding: 7px 10px; text-align: left; font: inherit; cursor: pointer;
  background: none; border: 0; border-bottom: 1px solid var(--bordure);
}
.etiq-resultat:last-child { border-bottom: 0; }
.etiq-resultat:hover { background: var(--survol, rgba(0,0,0,.04)); }
.etiq-ref { flex: 0 0 auto; font-size: 12px; color: var(--texte-doux); min-width: 8rem; }
.etiq-titre { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.etiq-alerte {
  flex: 0 0 auto; font-size: 11px; padding: 1px 6px; border-radius: 999px;
  background: #FDECEA; color: #A6301E;
}

.etiq-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.etiq-table th {
  text-align: left; font-weight: 500; font-size: 11.5px;
  color: var(--texte-doux); padding: 0 8px 6px 0;
  border-bottom: 1px solid var(--bordure);
}
.etiq-table td { padding: 6px 8px 6px 0; border-bottom: 1px solid var(--bordure); vertical-align: middle; }
.etiq-cell-ref { white-space: nowrap; }
.etiq-cell-ref span:first-child { color: var(--texte-doux); font-size: 12px; }
.etiq-cell-ref .etiq-alerte { margin-left: 6px; }
/* Le titre ne pousse pas la table : il se coupe. */
.etiq-cell-titre { max-width: 22rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.etiq-champ {
  padding: 4px 6px; font: inherit; font-size: 12.5px;
  border: 1px solid var(--bordure); border-radius: 6px;
  background: var(--fond); color: inherit;
}
.etiq-choisi {
  flex: 0 0 auto; font-size: 11px; color: var(--texte-doux); display: none;
}
.etiq-resultat.pris { opacity: .5; cursor: default; }
.etiq-resultat.pris .etiq-choisi { display: inline; }
.etiq-selection { margin-top: 4px; }
.etiq-auteur {
  flex: 0 1 auto; font-size: 12px; color: var(--texte-doux);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 14rem;
}
.etiq-tronque {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; font-size: 12px; color: var(--texte-doux);
  background: var(--survol, rgba(0,0,0,.03));
  border-top: 1px solid var(--bordure);
  position: sticky; bottom: 0;
}
.etiq-tout {
  margin-left: auto; font: inherit; font-size: 12px; cursor: pointer;
  background: none; border: 0; color: var(--accent, #1a6ed8);
  text-decoration: underline; padding: 0;
}

/* ─────────── Cartouche du bordereau ─────────── */
.bord-config {
  border: 1px solid var(--bordure); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 12px; background: var(--fond);
}
.bord-config-titre {
  font-size: 11.5px; color: var(--texte-doux); margin-bottom: 8px;
}
.bord-grille { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; }
.bord-champ { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; color: var(--texte-doux); }
.bord-champ input {
  padding: 4px 6px; font: inherit; font-size: 12.5px; color: var(--texte, inherit);
  border: 1px solid var(--bordure); border-radius: 6px; background: var(--fond);
}
.bord-case { display: flex; align-items: center; gap: 5px; font-size: 12.5px; padding-bottom: 5px; }

/* ─────────── Compte connecté ─────────── */
.moi { padding: 6px 2px 2px; }
.moi-nom { font-size: 12.5px; font-weight: 560; }
.moi-role { font-size: 11px; color: var(--texte-doux); margin-bottom: 4px; }
.moi-actions { display: flex; gap: 10px; }
.moi-lien {
  font: inherit; font-size: 11px; padding: 0; cursor: pointer;
  background: none; border: 0; color: var(--texte-doux); text-decoration: underline;
}
.moi-lien:hover { color: inherit; }

/* ─────────── Changement de mot de passe ─────────── */
.voile-modal {
  position: fixed; inset: 0; z-index: 80; background: rgba(15,15,15,.35);
  display: grid; place-items: center;
}
.mdp-boite {
  width: min(380px, 92vw); padding: 22px 22px 18px;
  background: var(--fond); border: 1px solid var(--bordure);
  border-radius: 12px; box-shadow: var(--ombre);
}
.mdp-boite h2 { font-size: 15px; font-weight: 560; margin: 0 0 6px; }
.mdp-note { margin: 0 0 14px; font-size: 12.5px; color: var(--texte-doux); }
.mdp-boite label { display: block; font-size: 11.5px; color: var(--texte-doux); margin-bottom: 4px; }
.mdp-boite input {
  width: 100%; box-sizing: border-box; padding: 7px 9px; font: inherit; font-size: 13px;
  border: 1px solid var(--bordure); border-radius: 7px; background: var(--fond);
  color: inherit; margin-bottom: 12px;
}
.mdp-erreur {
  font-size: 12.5px; color: #A6301E; background: #FDECEA;
  border-radius: 7px; padding: 7px 9px; margin-bottom: 12px;
}
.mdp-erreur[hidden] { display: none; }
.mdp-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ─────────── Créer un champ ─────────── */
.champ-barre { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.champ-boite select, .champ-valeurs {
  width: 100%; box-sizing: border-box; padding: 7px 9px; font: inherit; font-size: 13px;
  border: 1px solid var(--bordure); border-radius: 7px; background: var(--fond);
  color: inherit; margin-bottom: 12px;
}
.champ-valeurs { resize: vertical; font-family: inherit; }
.champ-options[hidden] { display: none; }
/* Une sauvegarde vieille de deux jours mérite d'être vue. */
#etat-extraction .alerte { color: #A6301E; font-weight: 560; }

/* ─────────── Envoi au diffuseur ─────────── */
#diff-voile { position: fixed; inset: 0; z-index: 49; background: rgba(15,15,15,.28); }
#diffusion {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 50;
  width: min(760px, 96vw);
  background: var(--fond); border-left: 1px solid var(--bordure);
  box-shadow: var(--ombre); display: flex; flex-direction: column;
  animation: glisser .18s ease;
}
#diffusion .tiroir-pied { display: flex; align-items: center; gap: 10px; }
#diffusion .tiroir-pied .btn:first-of-type { margin-left: auto; }
.diff-ok { color: #1E7A3C; font-weight: 560; }

/* Un champ multiligne dans une cellule : il doit rester lisible sans
   déformer la ligne du tableau. */
.saisie-multiligne {
  width: 100%; box-sizing: border-box; resize: vertical;
  font: inherit; line-height: 1.4; white-space: pre-wrap;
}
/* Dans la fiche, le texte garde ses sauts de ligne à l'affichage. */
#tiroir textarea { white-space: pre-wrap; overflow-y: auto; }
/* Les champs texte prennent la hauteur de leur contenu : une ligne pour un
   titre court, davantage pour un texte de quatrième de couverture. Sans
   cela, `min-height` les ferait tous hauts de trois lignes. */
.saisie textarea[data-col] { min-height: 0; padding-top: 6px; padding-bottom: 6px; }
