/* == Themes ==============================================================
   Toutes les couleurs de l'application sont ici, et **nulle part ailleurs** :
   une couleur ecrite en dur dans une regle ne suivrait pas le theme choisi.
   `tests/test_themes_css.py` le verifie.

   Trois themes, selectionnes par l'attribut `data-theme` sur <html> :
   absent ou "clair" (defaut), "nuit", "contraste".

   Les jetons sont **semantiques** (ce que la couleur signifie), pas
   descriptifs : `--danger`, pas `--rouge`. Un theme peut alors rendre le
   danger orange sans que le nom devienne un mensonge.

   /!\ Ajouter un jeton impose de le definir dans **les trois** themes. Un
   jeton manquant ne leve rien : la propriete est simplement ignoree, et
   l'element devient invisible ou illisible dans ce theme-la seulement.
   ====================================================================== */

:root, [data-theme="clair"] {
  /* Fonds et texte */
  --bg: #f5f4f1;
  --surface: #ffffff;
  --surface2: #faf9f7;
  --border: #e0dbd3;
  --border2: #ccc7be;
  --text: #1a1a1a;
  --muted: #72706a;

  /* Accent (bleu editorial) */
  --accent: #2d5a8e;
  --accent-light: #e8f0f8;
  --accent-hover: #1e4070;
  --accent-bord: #c6d8ef;
  --compteur-bg: #c6d8ef;
  --compteur-txt: #2d5a8e;

  /* Barre de navigation : un theme peut la vouloir sombre sans toucher a
     l'accent, d'ou ces jetons propres. */
  --nav-bg: #2d5a8e;
  --nav-txt: #ffffff;
  --nav-txt-attenue: rgba(255,255,255,.75);
  --nav-survol: rgba(255,255,255,.15);

  /* Texte pose sur un aplat colore plein (bouton primaire, badge, toast) */
  --sur-accent: #ffffff;

  /* Couleurs de sens */
  --green: #2a7a4b;
  --green-light: #e5f3ec;
  --green-bord: #b5dcc6;
  --orange: #b85a10;
  --orange-light: #fdf0e3;
  --orange-bord: #f0c8a0;
  --red: #aa1e1e;
  --red-light: #fce8e8;
  --red-bord: #e8b8b8;
  --red-survol: #f8dcdc;
  --yellow: #7a6010;
  --yellow-light: #fdf6dc;
  --gray-light: #f0ede8;
  --warn: #e8a13c;
  --danger: #cc0000;

  /* Groupements du planning */
  --year-bg: #1e3a5f;
  --year-text: #ffffff;
  --month-bg: #eaf0f8;
  --month-text: #2d5a8e;

  /* Coefficient CEP : quatre paliers, a garder distincts a l'oeil */
  --coef-rouge: #b02020;
  --coef-orange: #c05c1a;
  --coef-vert: #2a7a4b;
  --coef-vert-fonce: #14532d;

  /* Statuts livre aux teintes propres */
  --statut-valide-bg: #e7f0e2;
  --statut-valide-txt: #3d6b2e;
  --statut-termine-bg: #ded9d2;
  --statut-termine-txt: #6b6560;

  /* Voiles et ombres */
  --voile: rgba(0,0,0,.35);
  --voile-bouton: rgba(0,0,0,.6);
  --shadow: 0 1px 4px rgba(0,0,0,.1);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.18);
  --shadow-nav: 0 2px 6px rgba(0,0,0,.2);
  --shadow-tiroir: -6px 0 30px rgba(0,0,0,.2);
  --shadow-toast: 0 4px 16px rgba(0,0,0,.18);

  /* Mesures (identiques d'un theme a l'autre) */
  --radius: 6px;
  --radius-sm: 4px;
  --drawer-w: 520px;
}

/* -- Nuit ---------------------------------------------------------------
   Les teintes de sens sont **eclaircies et desaturees**, pas seulement
   inversees : le rouge #aa1e1e du theme clair est illisible sur fond
   sombre. La barre de navigation devient sombre elle aussi, un bandeau
   bleu vif au-dessus d'une page sombre eblouit. */
[data-theme="nuit"] {
  --bg: #16181c;
  --surface: #1e2127;
  --surface2: #23262d;
  --border: #33383f;
  --border2: #474d56;
  --text: #e6e4e1;
  --muted: #9aa0a8;

  --accent: #6aa9de;
  --accent-light: #1b2a3a;
  --accent-hover: #8dc1ee;
  --accent-bord: #2c4560;
  --compteur-bg: #2c4560;
  --compteur-txt: #dbe7f4;

  --nav-bg: #11151b;
  --nav-txt: #e6e4e1;
  --nav-txt-attenue: rgba(230,228,225,.65);
  --nav-survol: rgba(255,255,255,.08);

  /* Sur un aplat clair (accent, vert, rouge eclaircis), c'est un texte
     SOMBRE qui se lit, pas du blanc. */
  --sur-accent: #11151b;

  --green: #5cc98f;
  --green-light: #17302a;
  --green-bord: #2f5f47;
  --orange: #e2a057;
  --orange-light: #33261a;
  --orange-bord: #6b4a26;
  --red: #ef7373;
  --red-light: #3a1f1f;
  --red-bord: #6b3636;
  --red-survol: #482424;
  --yellow: #d9c05a;
  --yellow-light: #2f2a15;
  --gray-light: #2a2e35;
  --warn: #e8a13c;
  --danger: #ff7b7b;

  --year-bg: #0e1c2c;
  --year-text: #dbe7f4;
  --month-bg: #1b2a3a;
  --month-text: #8fbdec;

  --coef-rouge: #ff7b7b;
  --coef-orange: #f0ab63;
  --coef-vert: #5cc98f;
  --coef-vert-fonce: #3fae74;

  --statut-valide-bg: #1d3320;
  --statut-valide-txt: #8cd39a;
  --statut-termine-bg: #2e3138;
  --statut-termine-txt: #9aa0a8;

  --voile: rgba(0,0,0,.6);
  --voile-bouton: rgba(0,0,0,.7);
  --shadow: 0 1px 4px rgba(0,0,0,.5);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.6);
  --shadow-nav: 0 2px 6px rgba(0,0,0,.5);
  --shadow-tiroir: -6px 0 30px rgba(0,0,0,.6);
  --shadow-toast: 0 4px 16px rgba(0,0,0,.6);
}

/* -- Contraste eleve ----------------------------------------------------
   Pour les ecrans en plein jour et les longues sessions : fond blanc pur,
   texte noir, bordures franches, teintes de sens assombries pour passer
   largement le seuil de contraste sur blanc. */
[data-theme="contraste"] {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface2: #f2f2f2;
  --border: #6f6f6f;
  --border2: #3d3d3d;
  --text: #000000;
  --muted: #3a3a3a;

  --accent: #0b4a8f;
  --accent-light: #dceaf8;
  --accent-hover: #063569;
  --accent-bord: #0b4a8f;
  --compteur-bg: #dceaf8;
  --compteur-txt: #00264d;

  --nav-bg: #00264d;
  --nav-txt: #ffffff;
  --nav-txt-attenue: rgba(255,255,255,.88);
  --nav-survol: rgba(255,255,255,.28);

  --sur-accent: #ffffff;

  --green: #0f6b34;
  --green-light: #ddf1e5;
  --green-bord: #0f6b34;
  --orange: #8a3d00;
  --orange-light: #ffe8d1;
  --orange-bord: #8a3d00;
  --red: #8a0000;
  --red-light: #ffdede;
  --red-bord: #8a0000;
  --red-survol: #ffcccc;
  --yellow: #5a4500;
  --yellow-light: #fff3cc;
  --gray-light: #e8e8e8;
  --warn: #8a5200;
  --danger: #8a0000;

  --year-bg: #00264d;
  --year-text: #ffffff;
  --month-bg: #dceaf8;
  --month-text: #00264d;

  --coef-rouge: #8a0000;
  --coef-orange: #8a3d00;
  --coef-vert: #0f6b34;
  --coef-vert-fonce: #063d1c;

  --statut-valide-bg: #ddf1e5;
  --statut-valide-txt: #0f4a23;
  --statut-termine-bg: #e0e0e0;
  --statut-termine-txt: #333333;

  --voile: rgba(0,0,0,.5);
  --voile-bouton: rgba(0,0,0,.75);
  --shadow: 0 0 0 1px #6f6f6f;
  --shadow-lg: 0 0 0 2px #3d3d3d;
  --shadow-nav: 0 2px 0 #00264d;
  --shadow-tiroir: -2px 0 0 #3d3d3d;
  --shadow-toast: 0 0 0 2px #3d3d3d;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

/* ── Nav ── */
.nav {
  background: var(--nav-bg);
  color: var(--nav-txt);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 18px;
  height: 46px;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: var(--shadow-nav);
}
.nav-brand { color: var(--nav-txt); font-weight: 700; font-size: 14px; text-decoration: none; letter-spacing: .02em;
             white-space: nowrap; flex-shrink: 0; }
.nav-links { display: flex; gap: 2px; }
.nav-links a {
  color: var(--nav-txt-attenue);
  text-decoration: none;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  transition: all .15s;
}
.nav-links a:hover, .nav-links a.active {
  background: var(--nav-survol);
  color: var(--nav-txt);
}

/* ── Main ── */
.main { padding: 16px 20px; max-width: 100%; }

/* ── Filtres ── */
.filtres {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.filtre-group { display: flex; flex-direction: column; gap: 2px; }
.filtres label { font-size: 10px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.filtres select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 12px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  height: 28px;
}
.filtres select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.filtre-sep { width: 1px; background: var(--border); align-self: stretch; margin: 4px 0; }

.amalgames-chips { display: flex; flex-wrap: wrap; gap: 5px; max-width: 600px; }
.amalg-chip {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  cursor: default;
}
.amalg-chip.ok   { background: var(--green-light); color: var(--green); border: 1px solid var(--green-bord); }
.amalg-chip.warn { background: var(--orange-light); color: var(--orange); border: 1px solid var(--orange-bord); }

/* ── Boutons ── */
.btn-outline {
  border: 1px solid var(--border2);
  background: var(--surface);
  color: var(--muted);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all .15s;
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

.btn-primary {
  background: var(--accent);
  color: var(--sur-accent);
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-primary:hover { background: var(--accent-hover); }

/* ── Table wrapper ── */
.table-wrapper-outer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  box-shadow: var(--shadow);
}

/* ── Table planning ── */
.planning-table { width: 100%; border-collapse: collapse; min-width: 900px; }

.planning-table thead th {
  background: var(--surface2);
  border-bottom: 2px solid var(--border);
  padding: 7px 10px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}

/* ── Ligne année ── */
.year-row td {
  background: var(--year-bg);
  color: var(--year-text);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 6px 14px;
}

/* ── Ligne mois ── */
.month-row td {
  background: var(--month-bg);
  color: var(--month-text);
  padding: 5px 12px;
  font-size: 12px;
  border-top: 2px solid var(--accent-bord);
  border-bottom: 1px solid var(--accent-bord);
}
.month-label { font-weight: 700; margin-right: 8px; }
.month-count {
  background: var(--compteur-bg);
  color: var(--compteur-txt);
  border-radius: 8px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 700;
  margin-right: 10px;
}
.month-count.warn { background: var(--orange-light); color: var(--orange); }
.month-rc {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
}

/* ── Lignes titres ── */
.livre-row td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.livre-row:last-child td { border-bottom: none; }
.livre-row { cursor: pointer; transition: background .1s; }
.livre-row:hover td { background: var(--accent-light); }
.livre-row.titre-prov .titre-text { font-style: italic; color: var(--muted); }
/* Ligne estompée : compte ou prestataire inactif, fiche archivée (≠ titre provisoire) */
tr.ligne-estompee > td { color: var(--muted); font-style: italic; }

.titre-text { font-weight: 500; }
.muted { color: var(--muted); }

/* Registre des documents : lignes finalisées (émis/signé) en lecture seule */
tr.doc-fige td { background: var(--gray-light); }
.small { font-size: 11px; max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.date-cell { font-size: 11px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.date-urgent { color: var(--orange) !important; }

/* ── Widths colonnes ── */
.col-titre      { min-width: 180px; max-width: 240px; }
.col-editeur    { min-width: 75px; font-size: 11px; }
.col-parution   { min-width: 80px; }
.col-serie      { min-width: 100px; max-width: 140px; font-size: 11px; color: var(--muted); }
.col-prix       { width: 55px; text-align: right; }
.col-isbn       { min-width: 110px; font-size: 11px; font-family: monospace; }
.col-statut     { min-width: 90px; }
.col-note       { min-width: 110px; max-width: 170px; font-size: 11px; }
.col-rc         { min-width: 78px; }
.col-diffuseur  { min-width: 80px; }
.col-amalg      { min-width: 130px; }
.col-notes      { min-width: 150px; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-signe    { background: var(--green-light);  color: var(--green); }
.badge-nego     { background: var(--yellow-light); color: var(--yellow); }
.badge-proposer { background: var(--orange-light); color: var(--orange); }
.badge-valider  { background: var(--accent-light); color: var(--accent); }
.badge-reimpr   { background: var(--gray-light);   color: var(--muted); }
.badge-definir  { background: var(--gray-light);   color: var(--muted); }
.badge-erreur   { background: var(--red-light);    color: var(--red); }
.badge-avert    { background: var(--gray-light);   color: var(--muted); }
.badge-amalg-ok   { background: var(--green-light); color: var(--green); }

/* ── Tiroir ── */
.drawer-overlay {
  position: fixed; inset: 0;
  background: var(--voile);
  z-index: 300;
  display: none;
}
.drawer-overlay.open { display: block; }

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: var(--drawer-w);
  background: var(--surface);
  z-index: 400;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-tiroir);
  transform: translateX(100%);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
}
.drawer.open { transform: translateX(0); }

.drawer-header {
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  background: var(--surface2);
}
.drawer-titre { font-size: 16px; font-weight: 700; line-height: 1.3; }
.drawer-serie { font-size: 12px; color: var(--muted); margin-top: 2px; }
.drawer-close {
  background: none; border: none;
  font-size: 18px; color: var(--muted);
  cursor: pointer; padding: 0 4px;
  line-height: 1;
}
.drawer-close:hover { color: var(--text); }

.drawer-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  background: var(--surface2);
  padding: 0 18px;
  gap: 0;
}
.dtab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all .15s;
}
.dtab:hover { color: var(--text); }
.dtab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }

.drawer-body { flex: 1; overflow-y: auto; padding: 18px; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

.drawer-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface2);
  display: flex;
  align-items: center;
  gap: 12px;
}
.save-status { font-size: 12px; color: var(--muted); }
.save-status.ok  { color: var(--green); }
.save-status.err { color: var(--red); }

/* ── Formulaire dans le tiroir ── */
.form-section {
  margin-bottom: 20px;
}
.form-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  margin-bottom: 10px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.form-row {
  display: flex;
  gap: 10px;
  margin-bottom: 8px;
}
.form-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}
.form-field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}
.form-field input,
.form-field select,
.form-field textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-size: 13px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  width: 100%;
  transition: border .15s;
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}
.form-field textarea { resize: vertical; min-height: 60px; }
.form-field.full { flex: 0 0 100%; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.checkbox-row input[type=checkbox] { width: 14px; height: 14px; cursor: pointer; }
.checkbox-row label { font-size: 13px; color: var(--text); cursor: pointer; }

/* ── CEP ── */
.cep-results {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
}
.cep-result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.cep-result-row:last-child { border-bottom: none; }
.cep-result-row.total {
  font-weight: 700;
  font-size: 14px;
  padding-top: 8px;
  margin-top: 4px;
}
.cep-result-row.seuil { color: var(--accent); font-weight: 700; }
.cep-result-row.positif .cep-val { color: var(--green); font-weight: 700; }
.cep-result-row.negatif .cep-val { color: var(--red); font-weight: 700; }
.cep-label { color: var(--muted); font-size: 12px; }
.cep-val { font-weight: 600; font-variant-numeric: tabular-nums; }

.frais-list { margin-bottom: 10px; }
.frais-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 5px;
}
.frais-row input { flex: 1; }
.frais-row input.frais-montant { width: 90px; flex: 0 0 90px; text-align: right; }
.btn-rm {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  width: 24px; height: 24px;
  cursor: pointer;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.btn-rm:hover { border-color: var(--red); color: var(--red); }
.btn-add-frais {
  background: none;
  border: 1px dashed var(--border2);
  border-radius: var(--radius-sm);
  color: var(--muted);
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: all .15s;
}
.btn-add-frais:hover { border-color: var(--accent); color: var(--accent); }

/* ── Modal config ── */
.config-modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(960px, 94vw);
  max-height: 84vh;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 500;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.config-body { flex: 1; overflow-y: auto; padding: 18px; }
.config-rc-row {
  display: grid;
  grid-template-columns: 110px 1fr 1fr 1fr 1fr 26px;
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
}
.config-rc-row .btn-rm { margin-bottom: 4px; }
.rc-label-auto:disabled { background: var(--gray-light); color: var(--text); font-weight: 600; }

/* ── Calendrier des offices ── */
.distrib-bloc { display: flex; gap: 18px; align-items: flex-start; }
#calendrier { flex: 0 0 280px; }
.cal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px;
}
.cal-titre { font-weight: 700; font-size: 13px; }
.cal-grille {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.cal-jour {
  text-align: center; font-size: 10px; font-weight: 700;
  color: var(--muted); padding: 3px 0;
}
.cal-case {
  text-align: center; padding: 6px 0; font-size: 12px;
  border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid transparent;
}
.cal-case:not(.vide):hover { background: var(--accent-light); border-color: var(--accent); }
.cal-case.sel { background: var(--accent); color: var(--sur-accent); font-weight: 700; }
.cal-case.vide { cursor: default; }

.dp-liste-bloc { flex: 1; }
.dp-liste-titre {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted); margin-bottom: 8px;
}
.dp-ligne {
  display: flex; gap: 10px; align-items: center;
  padding: 3px 0; font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.dp-code { font-weight: 700; color: var(--accent); width: 80px; font-family: monospace; }
.dp-date-txt { width: 90px; font-variant-numeric: tabular-nums; }
.dp-stock { color: var(--muted); font-size: 12px; flex: 1; }

/* ── Rémunération contributeurs (onglet Détails) ── */
.droits-bloc { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); }
.droits-titre {
  font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px;
}
.droits-row { align-items: flex-end; }
.droits-nom { font-size: 13px; align-self: center; }

/* ── Autocomplétion classification ── */
.ac-box {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 50;
  background: var(--surface); border: 1px solid var(--accent);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  max-height: 240px; overflow-y: auto;
}
.ac-item { padding: 5px 8px; font-size: 12px; cursor: pointer; }
.ac-item:hover { background: var(--accent-light); }

/* ── Bibliographie interne (fiche auteur) ── */
.biblio-liste { display: flex; flex-direction: column; gap: 3px; }
.biblio-item { font-size: 13px; padding: 3px 0; border-bottom: 1px solid var(--border); }
.biblio-item:last-child { border-bottom: none; }
.biblio-titre { font-weight: 600; }
.biblio-co { font-size: 11px; margin-top: 1px; }

/* ── Page d'erreur ── */
.erreur-page { text-align: center; padding: 80px 20px; }
.erreur-code { font-size: 64px; font-weight: 800; color: var(--border2); line-height: 1; }
.erreur-message { font-size: 16px; color: var(--muted); margin: 12px 0 24px; }

/* ── Visuels / uploads ── */
.visuels-groupe { margin-bottom: 12px; }
.visuels-label { font-size: 11px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.visuels-grille { display: flex; flex-wrap: wrap; gap: 8px; }
.visuel-vignette {
  position: relative; width: 90px; height: 120px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--surface2);
}
.visuel-vignette img { width: 100%; height: 100%; object-fit: cover; }
.btn-rm-img {
  position: absolute; top: 2px; right: 2px;
  width: 20px; height: 20px; border: none; border-radius: 50%;
  background: var(--voile-bouton); color: var(--sur-accent); cursor: pointer;
  font-size: 14px; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.btn-rm-img:hover { background: var(--red); }
.upload-zone {
  display: flex; align-items: center; justify-content: center; text-align: center;
  width: 90px; height: 120px; padding: 6px;
  border: 1px dashed var(--border2); border-radius: var(--radius-sm);
  color: var(--muted); font-size: 12px; cursor: pointer; transition: all .15s;
}
.upload-zone:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.upload-zone.petite { width: 90px; }
.photo-ronde { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); }

/* ── ISBN ── */
.isbn-row { display: flex; gap: 6px; }
.isbn-row input { flex: 1; }
.btn-isbn { white-space: nowrap; padding: 6px 10px; font-size: 12px; }
.isbn-check { font-size: 11px; font-weight: 600; margin-left: 6px; }
.isbn-check.ok { color: var(--green); }
.isbn-check.ko { color: var(--red); }
input.isbn-ok { border-color: var(--green); }
input.isbn-ko { border-color: var(--red); }

/* ── Validation du CEP ── */
.cep-validation {
  border: 1px dashed var(--border2);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 13px;
}
.cep-validation.valide {
  border-style: solid;
  border-color: var(--green);
  background: var(--green-light);
}

/* ── Jalons « Fait ! » ── */
.jalon-row { display: flex; gap: 8px; align-items: center; }
.jalon-row input[type=date] { flex: 1; }
.jalon-row input[type=date]:disabled { background: var(--gray-light); color: var(--muted); }
.jalon-fait {
  display: flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600; color: var(--muted);
  white-space: nowrap; cursor: pointer;
}
.jalon-fait.fait { color: var(--green); }
.jalon-fait input { cursor: pointer; }

/* ── Coefficient (4 niveaux de couleur) ── */
.col-coef { width: 52px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.coef-rouge      { color: var(--coef-rouge); }
.coef-orange     { color: var(--coef-orange); }
.coef-vert       { color: var(--coef-vert); }
.coef-vert-fonce { color: var(--coef-vert-fonce); }
.cep-coef.coef-rouge      { color: var(--coef-rouge); }
.cep-coef.coef-orange     { color: var(--coef-orange); }
.cep-coef.coef-vert       { color: var(--coef-vert); }
.cep-coef.coef-vert-fonce { color: var(--coef-vert-fonce); }
.cep-coef { font-size: 15px; }
.amalg-note { margin: -6px 0 12px; }

/* ── Amalgame : édition inline + section CEP ── */
.col-amalg { cursor: text; }
.amalg-vide { color: var(--border2); font-weight: 700; padding: 0 8px; }
.livre-row:hover .amalg-vide { color: var(--accent); }
.amalg-edit {
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  font-size: 12px;
  width: 140px;
}
.amalg-section {
  background: var(--accent-light);
  border: 1px solid var(--accent-bord);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.amalg-info { font-size: 11px; color: var(--muted); margin-bottom: 10px; }
.amalg-membres { margin-top: 10px; border-top: 1px solid var(--accent-bord); padding-top: 8px; }
.amalg-membre {
  display: flex;
  gap: 10px;
  font-size: 12px;
  padding: 2px 0;
}
.amalg-membre.courant { font-weight: 700; }
.amalg-membre-titre { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.amalg-membre-tirage { width: 80px; text-align: right; font-variant-numeric: tabular-nums; }
.amalg-membre-pct { width: 60px; text-align: right; color: var(--accent); font-variant-numeric: tabular-nums; }

/* ── Statut calculé du livre ── */
.col-statut-livre { min-width: 110px; }
.statut-idee      { background: var(--gray-light);   color: var(--muted); }
.statut-dev       { background: var(--accent-light); color: var(--accent); }
.statut-finaliser { background: var(--yellow-light); color: var(--yellow); }
.statut-valide    { background: var(--statut-valide-bg); color: var(--statut-valide-txt); }
.statut-fab       { background: var(--orange-light); color: var(--orange); }
.statut-dispo     { background: var(--green-light);  color: var(--green); }
.statut-paru      { background: var(--green);        color: var(--sur-accent); }
.statut-termine   { background: var(--statut-termine-bg); color: var(--statut-termine-txt); text-decoration: line-through; }
.statut-suffixe   { font-size: 10px; color: var(--muted); display: block; margin-top: 2px; }
.statut-suffixe.alerte { color: var(--orange); font-weight: 600; }
.drawer-statut { margin-top: 4px; display: flex; gap: 6px; align-items: center; }
.drawer-statut .sous { font-size: 11px; color: var(--muted); }

/* ── Badges d'état (Entrée Kiosque / Fiche produit) ── */
.col-kiosque, .col-fiche { min-width: 90px; }
.badge-etat {
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: filter .1s;
}
.badge-etat:hover { filter: brightness(.93); }
.etat-à-faire   { background: var(--gray-light);   color: var(--muted); }
.etat-brouillon { background: var(--yellow-light); color: var(--yellow); }
.etat-validée   { background: var(--green-light);  color: var(--green); }

/* ── Alertes ── */
.col-alerte { width: 26px; text-align: center; padding: 7px 4px !important; }
.alerte-icone {
  color: var(--orange);
  font-size: 13px;
  cursor: help;
}
.alerte-ligne { font-size: 12px; color: var(--orange); padding: 1px 0; }
.alerte-header { color: var(--orange); background: var(--orange-light); border-color: var(--orange-bord); }
.retard-header { color: var(--red); background: var(--red-light); border-color: var(--red-bord); }

/* Fiche sautée à l'affichage : un titre qui disparaît sans bruit serait pire
   qu'une erreur. Jetons existants, déclarés dans les trois thèmes. */
.bandeau-illisible {
  background: var(--red-light);
  color: var(--red);
  border: 1px solid var(--red-bord);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 13px;
}
.bandeau-illisible code { background: none; color: inherit; font-weight: 700; }

/* ── Échéances ── */
.echeance-retard td { background: var(--red-light); }
.echeance-retard:hover td { background: var(--red-survol); }
.echeance-retard .date-cell { color: var(--red); font-weight: 700; }
.badge-ech-diffuseur { background: var(--orange-light); color: var(--orange); }
.badge-ech-stock     { background: var(--accent-light); color: var(--accent); }
.badge-ech-parution  { background: var(--green-light);  color: var(--green); }
.badge-ech-reunion   { background: var(--yellow-light); color: var(--yellow); }

/* ── Archives ── */
.archives-actions { white-space: nowrap; }
.btn-archive {
  border: 1px solid var(--border2);
  background: var(--surface);
  border-radius: var(--radius-sm);
  width: 30px; height: 28px;
  cursor: pointer;
  font-size: 14px;
  margin-right: 4px;
  transition: all .15s;
}
.btn-supprimer:hover   { border-color: var(--red);    background: var(--red-light); }
.btn-desarchiver:hover { border-color: var(--green);  background: var(--green-light); }
.btn-definitif:hover   { border-color: var(--accent); background: var(--accent-light); }

.drawer-actions-fin { margin-left: auto; display: flex; gap: 6px; }
.btn-abandonner:hover { border-color: var(--red); color: var(--red); background: var(--red-light); }
.btn-annuler:hover { border-color: var(--orange); color: var(--orange); background: var(--orange-light); }
.btn-annuler.actif { border-color: var(--orange); color: var(--orange); background: var(--orange-light); }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 13px;
  box-shadow: var(--shadow-toast);
  z-index: 9999;
  transition: opacity .3s, transform .3s;
  transform: translateY(0);
}
.toast.ok  { background: var(--green); color: var(--sur-accent); }
.toast.err { background: var(--red);   color: var(--sur-accent); }
.toast.hidden { opacity: 0; pointer-events: none; transform: translateY(8px); }

/* ── Sélecteur de thème (barre de navigation) ── */
.choix-theme {
  margin-left: auto;
  background: var(--nav-survol);
  color: var(--nav-txt);
  border: 1px solid var(--nav-txt-attenue);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}
/* Le menu déroulant natif s'affiche sur le fond du système : ses options
   doivent rester lisibles quel que soit le thème de la barre. */
.choix-theme option { background: var(--surface); color: var(--text); }

/* ── Accueil (tableau de bord) ── */
.accueil-bloc { margin-bottom: 22px; }
.accueil-titre {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin: 0 0 8px;
}
.accueil-compteurs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.accueil-compteur {
  display: inline-block; padding: 4px 10px; border-radius: 12px; font-size: 12px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  text-decoration: none; white-space: nowrap;
}
.accueil-compteur:hover { border-color: var(--accent); background: var(--accent-light); }
.accueil-compteur.warn { background: var(--orange-light); border-color: var(--orange-bord); color: var(--orange); }
.accueil-deux-colonnes { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 12px; }
.accueil-sous-titre td {
  background: var(--month-bg); color: var(--month-text); font-weight: 700;
  font-size: 12px; padding: 5px 10px;
}
.accueil-vide { padding: 14px 10px; }
.accueil-plus { padding: 6px 10px; text-align: right; font-size: 12px; }
.accueil-plus a { color: var(--accent); text-decoration: none; }

.accueil-cartes { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 12px; }
.carte-maison {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px;
}
.carte-entete { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.carte-entete:hover .carte-nom { color: var(--accent); }
.carte-logo { height: 28px; max-width: 80px; object-fit: contain; }
.carte-nom { font-size: 16px; font-weight: 700; }
.carte-chiffre { margin-left: auto; font-size: 12px; color: var(--muted); }
.carte-chiffre b { font-size: 16px; color: var(--text); }
.carte-chaine { display: flex; gap: 2px; min-height: 20px; align-items: stretch; }
.carte-segment {
  flex-basis: 0; min-width: 22px; text-align: center; font-size: 11px; font-weight: 700;
  line-height: 20px; border-radius: var(--radius-sm); text-decoration: none;
}
.carte-segment:hover { outline: 2px solid var(--accent); }
.carte-legende { display: flex; flex-wrap: wrap; gap: 3px; }
.carte-legende .badge { font-size: 10px; padding: 1px 6px; }
.carte-indics {
  display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px;
  margin: 0; font-size: 12px;
}
.carte-indics dt { color: var(--muted); }
.carte-indics dd { margin: 0; }
.carte-indics a { color: var(--accent); text-decoration: none; }
.carte-indics a.muted { color: var(--muted); }
.carte-pied { display: flex; flex-wrap: wrap; gap: 6px; border-top: 1px solid var(--border); padding-top: 8px; }

.accueil-outils { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.outils-groupe { display: flex; flex-direction: column; gap: 6px; }
.outils-groupe h3 { font-size: 11px; color: var(--muted); margin: 0; text-transform: uppercase; letter-spacing: .06em; }
.outil {
  display: flex; flex-direction: column; gap: 1px; padding: 8px 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  text-decoration: none; color: var(--text);
}
.outil:hover { border-color: var(--accent); background: var(--accent-light); }
.outil b { font-size: 13px; }
.outil span { font-size: 11px; color: var(--muted); }

/* Filtre venu de l'accueil, rappelé en tête du planning / des documents */
.filtre-actif {
  display: inline-flex; align-items: center; gap: 8px; font-size: 12px;
  background: var(--accent-light); color: var(--accent); border: 1px solid var(--accent-bord);
  border-radius: 12px; padding: 3px 10px; margin: 0 0 10px;
}
.filtre-actif a { color: var(--accent); text-decoration: none; font-weight: 700; }

/* ── Échanges JSON ── */
.echange-cases { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; padding-top: 4px; }
.echange-cases label { display: inline-flex; align-items: center; gap: 4px; }
.echange-erreurs, .echange-avertissements {
  border-radius: var(--radius); padding: 8px 12px; margin: 10px 0; font-size: 12px;
}
.echange-erreurs { background: var(--red-light); color: var(--red); border: 1px solid var(--red-bord); }
.echange-avertissements { background: var(--orange-light); color: var(--orange); border: 1px solid var(--orange-bord); }
.echange-erreurs ul, .echange-avertissements ul { margin: 4px 0 0; padding-left: 18px; }
.echange-champ { max-width: none; white-space: normal; color: var(--muted); }

/* L'attribut hidden doit gagner sur les display des composants (flex…) */
[hidden] { display: none !important; }

/* ── Vue d'ensemble (lecture seule) et titre de maison au planning ── */
.planning-maison { font-size: 18px; font-weight: 700; margin: 4px 0 10px; color: var(--text); }
.ensemble-entete { display: flex; align-items: baseline; gap: 12px; }
.badge-lecture {
  display: inline-block; font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 10px;
  background: var(--gray-light); color: var(--muted); border: 1px solid var(--border);
}
/* Rien n'est cliquable dans le tableau en lecture seule : ne pas le promettre */
.planning-lecture .livre-row { cursor: default; }
.planning-lecture .livre-row:hover td { background: transparent; }

.carte-ensemble { text-decoration: none; color: var(--text); border-style: dashed; }
.carte-ensemble:hover { border-color: var(--accent); }
.carte-ensemble:hover .carte-nom,
.carte-ensemble:hover .ensemble-ouvrir { color: var(--accent); }
.ensemble-repartition { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.ensemble-repartition li { display: flex; justify-content: space-between; font-size: 13px;
  border-bottom: 1px dotted var(--border); padding-bottom: 3px; }
.ensemble-pied { display: flex; justify-content: space-between; align-items: center; margin-top: auto; }
.ensemble-ouvrir { font-size: 12px; font-weight: 600; color: var(--muted); }

/* ── Connexion et compte (C1) ── */
.connexion { max-width: 380px; margin: 48px auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px 28px; }
.connexion-titre { font-size: 20px; margin: 0 0 16px; color: var(--text); }
.connexion-form { display: flex; flex-direction: column; gap: 12px; }
.connexion-form .form-field input { width: 100%; }
.connexion-erreur { background: var(--red-light); color: var(--red); border: 1px solid var(--red-bord);
  border-radius: var(--radius-sm); padding: 8px 10px; font-size: 13px; }
.connexion-aide { margin-top: 16px; }
.mon-compte { max-width: 720px; }
.mon-compte .form-section { margin-bottom: 18px; }
.acces-table { max-width: 480px; }

.nav-compte { display: flex; align-items: center; gap: 4px; margin-left: 8px; }
.nav-compte a { color: var(--nav-txt-attenue); text-decoration: none; padding: 5px 10px;
  border-radius: var(--radius-sm); font-size: 13px; white-space: nowrap; }
.nav-compte a:hover, .nav-compte a.active { background: var(--nav-survol); color: var(--nav-txt); }
.nav-compte form { margin: 0; }
.nav-deconnexion { background: transparent; border: none; color: var(--nav-txt-attenue);
  font-size: 15px; cursor: pointer; padding: 4px 8px; border-radius: var(--radius-sm); }
.nav-deconnexion:hover { background: var(--nav-survol); color: var(--nav-txt); }

/* ── Comptes et droits (C1, U5) ── */
.admin-comptes { max-width: 1300px; }
.admin-table td { vertical-align: top; }
.admin-table input:not([type=checkbox]) { width: 100%; min-width: 140px; margin-top: 3px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px 6px;
  background: var(--surface); color: var(--text); font-size: 12px; }
.admin-table select { background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 12px; }
.admin-table tr.ligne-estompee input:not([type=checkbox]), .admin-table tr.ligne-estompee select { color: var(--muted); }
.admin-permission { display: block; font-size: 12px; white-space: nowrap; }
.admin-actions { display: flex; flex-direction: column; gap: 4px; }
.admin-creation { margin-top: 20px; }
.admin-creation .admin-permission { display: inline-block; margin-right: 14px; }
.mdp-provisoire { background: var(--green-light); color: var(--text); border: 1px solid var(--green-bord);
  border-radius: var(--radius-sm); padding: 10px 12px; margin: 10px 0; display: flex; gap: 10px;
  align-items: center; flex-wrap: wrap; }
.mdp-provisoire code { font-size: 15px; background: var(--surface); padding: 2px 8px;
  border-radius: var(--radius-sm); border: 1px solid var(--border); user-select: all; }

/* ── Modèles InDesign de fiche produit ── */
.modeles-espace { margin-bottom: 18px; }
.modeles-entete { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.modeles-entete h3 { margin: 0; font-size: 15px; color: var(--text); }
.modele-description { width: 100%; min-width: 180px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 2px 6px; background: var(--surface); color: var(--text); }
.modele-depot { margin-top: 10px; padding: 10px; border: 1px dashed var(--border2); border-radius: var(--radius); }
.depot-rapport { margin-top: 10px; padding: 8px 10px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; }
.controle-liste { margin: 4px 0 4px 18px; padding: 0; font-size: 12px; }
.controle-liste li { margin-bottom: 3px; }

/* ── Page d'aide ── */
.aide { max-width: 980px; }
.aide .form-section { margin-bottom: 18px; line-height: 1.5; }
.aide-etapes, .aide-liste { margin: 6px 0 6px 20px; padding: 0; }
.aide-etapes li, .aide-liste li { margin-bottom: 6px; }
.aide-table td { vertical-align: top; }
.aide-regle { background: var(--orange-light); border-left: 3px solid var(--orange);
  padding: 8px 12px; margin: 10px 0; border-radius: var(--radius-sm); color: var(--text); }
