:root {
  --brand: #e8622c;
  --brand-dark: #1c1f26;
  --bg: #f4f5f7;
  --panel-bg: #ffffff;
  --border: #dcdfe4;
  --text: #22262e;
  --text-muted: #6b7280;
  --alert: #c0392b;
  --alert-bg: #fdecea;
  --ok: #1f8a4c;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* ---------- Header / nav ---------- */
.app-header {
  background: var(--brand-dark);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 10px 20px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 150;
}
.brand { font-size: 22px; font-weight: 800; letter-spacing: 0.5px; white-space: nowrap; }
.brand-c { color: #fff; }
.brand-pneu { color: var(--brand); }
.main-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav-btn {
  background: transparent;
  border: none;
  color: #cfd2d8;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.nav-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-btn.active { background: var(--brand); color: #fff; }

main { padding: 16px 20px 60px; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Sous-navigation (ex: Stock -> Articles / Mouvement de stock / Consommation) : même principe que
   .main-nav/.tab-panel, un niveau en dessous. */
/* Reste visible sous l'en-tête fixe quand on fait défiler la page (--header-h est mesuré en JS, car
   l'en-tête passe sur deux lignes sur les écrans étroits). */
.sub-nav { display: flex; gap: 4px; flex-wrap: wrap; margin: -8px 0 14px; border-bottom: 2px solid var(--border); padding: 8px 0 10px; position: sticky; top: var(--header-h, 0px); z-index: 120; background: var(--bg); }
.sub-nav-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.sub-nav-btn:hover { background: #f5f5f5; }
.sub-nav-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.sub-tab-panel { display: none; }
.sub-tab-panel.active { display: block; }

/* ---------- Panels / layout ---------- */
.panel {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}
.panel h2 { margin: 0 0 12px; font-size: 16px; color: var(--brand-dark); }
.panel h3 { margin: 16px 0 8px; font-size: 14px; color: var(--brand-dark); }
.hint { color: var(--text-muted); font-size: 12.5px; }

.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.clients-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }

@media (max-width: 1100px) {
  .dash-grid, .clients-grid { grid-template-columns: 1fr; }
}

/* ---------- KPI cards ---------- */
.kpi-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.kpi-card {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 18px;
  min-width: 140px;
  flex: 1 1 140px;
}
.kpi-card.kpi-alert { border-color: var(--alert); background: var(--alert-bg); }
.kpi-value { font-size: 24px; font-weight: 800; color: var(--brand-dark); }
.kpi-card.kpi-alert .kpi-value { color: var(--alert); }
.kpi-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ---------- Forms ---------- */
.field-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 14px;
  margin-bottom: 10px;
}
.field-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  position: relative;
  min-width: 0;
}
.field-grid label input, .field-grid label select, .field-grid label textarea { width: 100%; min-width: 0; }
.field-grid label textarea { resize: vertical; font-family: inherit; }

/* ---------- FAQ démo ---------- */
.faq-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: #fff;
}
.faq-card.faq-sans-reponse { border-left: 4px solid var(--brand); }
.faq-question { font-weight: 800; color: var(--brand-dark); margin-bottom: 6px; }
.faq-reponse { white-space: pre-wrap; margin-bottom: 8px; }
.faq-reponse.faq-vide { color: var(--text-muted); font-style: italic; }
.faq-actions { display: flex; gap: 6px; }
.field-wide { grid-column: span 3; }
.field-wide-2 { grid-column: span 2; }
@media (max-width: 700px) {
  .field-grid { grid-template-columns: 1fr; }
  .field-wide { grid-column: span 1; }
}

/* Ligne de facture : le code article se saisit directement dans le tableau (colonne
   Référence), avec une liste d'autocomplete ancrée sous le champ — inspiré du tableau
   "Lignes de devis" du projet DEVIS. */
.fl-code-cell { position: relative; }
.fl-code-cell input.fl-code { border-color: var(--border); }
.fl-code-cell input.fl-code.fl-code-invalid { border-color: var(--alert); }
.fl-results {
  position: fixed;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  max-height: 260px;
  overflow-y: auto;
  z-index: 200;
  box-shadow: 0 4px 10px rgba(0,0,0,0.12);
  display: none;
}
.fl-results.show { display: block; }
.autocomplete-list.cf-l-results {
  position: fixed;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  max-height: 260px;
  overflow-y: auto;
  z-index: 220;
  display: none;
}
.autocomplete-list.cf-l-results.show { display: block; }

/* Blocs "Véhicule" (un par véhicule sur la facture, chacun avec ses propres lignes/prestations) */
.vehicule-block {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 16px;
  background: #fafafb;
}
.vehicule-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.vehicule-header .vehicule-immat { flex: 0 1 320px; font-weight: 700; text-transform: uppercase; }
.vehicule-header .vehicule-km { flex: 0 1 180px; }
.vehicule-header .vehicule-titre { font-weight: 700; color: var(--text-muted); font-size: 12.5px; white-space: nowrap; }
input, select, textarea {
  font-family: inherit;
  font-size: 13.5px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #fff;
  color: var(--text);
}
input:read-only { background: #f0f1f3; color: var(--text-muted); }
.checkbox-inline { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-muted); }
.checkbox-inline input { width: auto; }

/* ---------- Buttons ---------- */
.btn {
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: #d4551f; }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: #f0f1f3; }
.btn-danger { background: var(--alert); color: #fff; }
.btn-small { padding: 4px 9px; font-size: 12px; }

/* Cellule "Actions" avec plusieurs boutons (Modifier/Reçue/Annuler/Suppr...) : disposés en grille
   qui s'aligne proprement d'une ligne à l'autre, au lieu de s'enchaîner comme du texte (repli
   irrégulier selon la largeur du libellé de chaque bouton). S'applique à tous les tableaux de
   l'appli sans avoir à taguer chaque cellule au cas par cas. */
.data-table td:has(> .btn) { display: flex; flex-wrap: nowrap; gap: 5px; align-items: flex-start; white-space: nowrap; }
/* Colonne à texte potentiellement long (nom de fournisseur...) : tronquée avec "..." plutôt que
   repliée sur plusieurs lignes, pour ne pas gonfler la hauteur de ligne ni pousser les boutons
   d'action à se replier eux-mêmes faute de place. Le nom complet reste lisible via l'info-bulle
   (attribut title). */
.cell-truncate { max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Tableau Articles : les colonnes courtes (code, chiffres, actions) prennent juste la largeur de leur
   contenu (width: 1 % en disposition automatique) ; Modèle et Fournisseur (.col-flex) se partagent
   toute la place restante, le nom complet du fournisseur s'affiche donc sans être tronqué. Quand
   l'écran est trop étroit, ces deux colonnes passent à la ligne au lieu de se couper, et le tableau
   ne défile horizontalement qu'en dernier recours. */
#table-stock thead th, #table-stock tbody td { width: 1%; white-space: nowrap; }
#table-stock thead th[data-sort] { white-space: normal; }
#table-stock thead th .th-label { white-space: normal; }
#table-stock th.col-flex, #table-stock td.col-flex { width: auto; white-space: normal; min-width: 150px; }
#table-stock td.col-flex { overflow-wrap: anywhere; }
@media (max-width: 1400px) {
  #table-stock thead th { padding: 6px 6px; font-size: 12px; }
  #table-stock tbody td { padding: 6px 6px; font-size: 12.5px; }
  #table-stock th.col-flex, #table-stock td.col-flex { min-width: 120px; }
}

/* Réception d'une commande : zone des frais d'approche (fret, douane...). */
.frais-box { border: 1px solid var(--border); border-radius: 8px; background: #fafafb; padding: 10px 14px; margin: 12px 0; }
.frais-box h3 { margin: 0 0 4px; font-size: 14px; }
.frais-box .field-grid { grid-template-columns: repeat(4, minmax(120px, 1fr)); }
.frais-box .frais-total { margin: 8px 0 0; font-size: 13px; }
@media (max-width: 700px) { .frais-box .field-grid { grid-template-columns: repeat(2, 1fr); } }

/* Recherche par dimensions (onglet Articles) : largeur / profil / jante + champ libre. */
.dim-search { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin-bottom: 10px; }
.dim-search > strong { align-self: center; font-size: 13px; color: var(--brand-dark); }
.dim-search label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; font-weight: 600; color: var(--text-muted); }
.dim-search input { width: 110px; }
.dim-search .hint { align-self: center; margin: 0; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input[type="text"] { min-width: 220px; flex: 1 1 220px; }

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; max-height: calc(100vh - 260px); overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; }
.table-scroll-sm { max-height: 320px; }
table.data-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  min-width: 600px;
}
.data-table thead th {
  position: sticky;
  top: 0;
  background: var(--brand-dark);
  color: #fff;
  text-align: left;
  padding: 8px 10px;
  font-size: 12.5px;
  z-index: 2;
}
.data-table thead th[data-sort] { user-select: none; white-space: nowrap; vertical-align: top; }
.data-table thead th .sort-ic { opacity: 0.55; margin-left: 4px; font-size: 10.5px; }
.data-table thead th.sort-active { font-weight: 800; }
.data-table thead th.sort-active .sort-ic { opacity: 1; }
/* Tri : clic sur le libellé uniquement (pas sur tout le th, qui contient aussi le filtre de
   colonne) — règle appliquée à tous les tableaux triables de l'appli. */
.th-label { cursor: pointer; display: flex; align-items: center; }
.th-label:hover { opacity: 0.85; }
.col-filter {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin-top: 5px;
  font-size: 11px;
  font-weight: 400;
  padding: 3px 5px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.15);
  color: #fff;
  cursor: text;
}
.col-filter::placeholder { color: rgba(255,255,255,0.65); }
.col-filter option { color: #111; }
select.col-filter { cursor: pointer; }

/* Filtre à choix multiple (Statut, Fournisseur, Type, Catégorie...) : bouton dans l'en-tête qui
   ouvre une liste à cases à cocher — remplace un <select> mono-valeur partout où plusieurs valeurs
   doivent pouvoir être cochées à la fois. */
.multi-filter { margin-top: 5px; position: relative; }
.multi-filter-btn {
  display: block;
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  font-size: 11px;
  font-weight: 400;
  text-align: left;
  padding: 3px 18px 3px 5px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.15) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath fill='white' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E") no-repeat right 6px center/8px;
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.multi-filter-list {
  display: none;
  position: fixed;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.18);
  z-index: 220;
  min-width: 180px;
  max-height: 260px;
  overflow-y: auto;
  padding: 4px 0;
}
.multi-filter-list.open { display: block; }
.multi-filter-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  font-size: 12.5px;
  font-weight: 400;
  color: var(--text-dark, #1c1e21);
  cursor: pointer;
  white-space: nowrap;
}
.multi-filter-item:hover { background: #fdf1ea; }
.multi-filter-item input { margin: 0; }
/* Sans cette règle, la règle générique ".data-table input" (largeur 100 %) étire les cases à cocher
   et les décale d'une ligne à l'autre selon la longueur du libellé. */
.data-table .multi-filter-item input { width: auto; min-width: 0; padding: 0; flex: 0 0 auto; }
.data-table tbody td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: top;
}
.data-table tbody tr:hover { background: #fafafa; }
.data-table tbody tr.row-alert td { background: var(--alert-bg); }
.data-table tbody tr.total-row td { font-weight: 800; border-top: 2px solid var(--brand-dark); }
.data-table tbody tr.clickable-row { cursor: pointer; }
.data-table tbody tr.row-selected td { background: #fdf1ea; }
.data-table input, .data-table select { width: 100%; min-width: 60px; padding: 4px 6px; font-size: 12.5px; }

/* ---------- Autocomplete ---------- */
.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: 0 4px 10px rgba(0,0,0,0.12);
}
.autocomplete-list:empty { display: none; border: none; box-shadow: none; }
.autocomplete-item { padding: 7px 10px; cursor: pointer; font-size: 12.5px; border-bottom: 1px solid #f0f1f3; }
.autocomplete-item:hover { background: #fdf1ea; }
.autocomplete-item small { display: block; color: var(--text-muted); }

/* ---------- Prestations (montage/équilibrage) ---------- */
.prestations-box {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  background: #f8f8f9;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 12px;
  width: 100%;
}
.prestations-box .qte-mini { width: 60px; padding: 5px 6px; }
/* Grille sur 2 lignes, remplie colonne par colonne : 1 en haut / 2 en dessous, puis 3 à droite de 1,
   4 en dessous de 3, etc. — répartie sur toute la largeur (celle du tableau Référence...Stock). */
.v-prestations-checks {
  display: grid;
  grid-template-rows: repeat(2, auto);
  grid-auto-flow: column;
  grid-auto-columns: minmax(150px, 1fr);
  column-gap: 16px;
  row-gap: 6px;
}
.v-prestations-checks .presta-item { display: flex; align-items: center; gap: 8px; }
.v-prestations-checks .presta-item .checkbox-inline { flex: 1 1 auto; }
@media (max-width: 700px) {
  .v-prestations-checks { grid-template-rows: none; grid-auto-flow: row; }
}

/* ---------- Totaux ---------- */
.totaux-box {
  display: flex;
  gap: 20px;
  justify-content: flex-end;
  padding: 10px 14px;
  background: #f8f8f9;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 10px 0;
}
.totaux-box div { display: flex; flex-direction: column; align-items: flex-end; font-size: 12px; color: var(--text-muted); }
.totaux-box strong { font-size: 16px; color: var(--brand-dark); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20,22,26,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal-overlay[hidden] { display: none; }
.modal-box {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  max-width: 560px;
  width: 92%;
  max-height: 88vh;
  overflow-y: auto;
}
.modal-box.modal-wide { max-width: 920px; }
/* Les tableaux du catalogue imposent min-width:600px (utile en pleine page) — dans une popup
   étroite ça forçait un défilement horizontal inutile pour un tableau à 3-4 colonnes. */
.modal-box table.data-table { min-width: 0; }
/* Les popups n'affichent que des listes courtes (commandes d'un article, 12 mois, panier) —
   pas besoin du plafond de hauteur des tableaux pleine page, la modale entière sert déjà de
   filet de sécurité (max-height:88vh) si jamais la fenêtre du navigateur est très petite. */
.modal-box .table-scroll { max-height: none; }
.modal-box { padding: 16px 20px; }
.modal-box h2 { margin: 0 0 6px; }
.modal-box > p.hint { margin: 0 0 8px; }
.modal-box h3 { margin: 6px 0 4px; }
.modal-box .field-grid { margin-bottom: 4px; gap: 6px 12px; }
.modal-box .toolbar:last-child { margin-bottom: 0; }
.modal-box .toolbar { margin-bottom: 8px; }
.modal-box .mini-stats { margin-bottom: 2px; }
.modal-box .data-table td, .modal-box .data-table th { padding: 5px 8px; }
.mini-stats { display: flex; gap: 24px; margin-bottom: 8px; }
.mini-stats div { display: flex; flex-direction: column; }
.mini-stats strong { font-size: 20px; color: var(--brand-dark); }
.mini-stats span { font-size: 11px; color: var(--text-muted); }
.modal-two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: start; margin-top: 10px; }
@media (max-width: 800px) { .modal-two-col { grid-template-columns: 1fr; } }
#inventaire-box { background: #f8f8f9; border: 1px solid var(--border); border-radius: 6px; padding: 12px; margin-bottom: 12px; }
#inventaire-box h3 { margin-top: 0; }
#inventaire-box label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 8px; }
#inventaire-box input { width: 100%; box-sizing: border-box; }

/* ---------- Fiche article (popup ouverte au clic sur un article) ---------- */
.modal-box.modal-xwide { max-width: 1180px; width: 96%; position: relative; padding: 22px; }
.ap-x { position: absolute; top: 6px; right: 8px; width: 26px; height: 26px; border: 1px solid var(--border); border-radius: 50%; background: #fff; cursor: pointer; font-size: 12px; line-height: 1; z-index: 2; }
.ap-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 12px; align-items: start; }
@media (max-width: 900px) { .ap-grid { grid-template-columns: 1fr; } }
.ap-card { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 14px; min-width: 0; }
.ap-card h3 { margin: 0 0 8px; font-size: 12px; letter-spacing: 0.4px; text-transform: uppercase; color: var(--text-muted); }
.ap-card h3 small { text-transform: none; letter-spacing: 0; margin-left: 4px; }
.ap-grid #inventaire-box { margin-bottom: 0; background: #fff; border-radius: 8px; padding: 14px; }
.ap-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.ap-code { font-family: Consolas, "Courier New", monospace; font-size: 22px; font-weight: 800; color: var(--brand-dark); }
.ap-desig { font-size: 12.5px; color: var(--text-muted); }
.ap-title-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; margin-right: 18px; }
.ap-nav-count { font-size: 12px; color: var(--text-muted); font-family: Consolas, "Courier New", monospace; }
.ap-badge { background: #e6f4ea; color: #1e7a46; border-radius: 999px; padding: 4px 12px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.ap-badge-alerte { background: var(--alert-bg); color: var(--alert); }
.ap-stats { display: flex; gap: 28px; margin: 8px 0 12px; }
.ap-stats div { display: flex; flex-direction: column; }
.ap-stats strong { font-size: 24px; color: var(--brand-dark); }
.ap-stats span { font-size: 11px; color: var(--text-muted); }
.ap-commentaire { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 12px; }
.ap-commentaire textarea { width: 100%; box-sizing: border-box; resize: vertical; }
/* Catégorie de l'article, dans la fiche : même gabarit que le commentaire, liste à largeur de contenu. */
.ap-categorie { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin: 0 0 12px; }
.ap-categorie select { width: auto; align-self: flex-start; min-width: 160px; }
.ap-orderbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: space-between; background: var(--brand-dark); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.ap-nav-btn { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,0.45); padding: 6px 10px; font-size: 12px; }
.ap-nav-btn:hover:not(:disabled) { background: rgba(255,255,255,0.15); }
.ap-nav-btn:disabled { opacity: 0.35; cursor: default; }
.ap-qty label { display: block; color: #fff; font-size: 10.5px; font-weight: 700; text-transform: uppercase; margin-bottom: 3px; }
.ap-qty input { width: 100px; font-size: 16px; font-weight: 700; }
.ap-reco { background: #e6f4ea; color: #1e7a46; border: none; border-radius: 6px; padding: 7px 12px; cursor: pointer; font-size: 12px; font-weight: 700; }
.ap-reco strong { font-size: 15px; }
.ap-suppr { margin-left: auto; }
.bc-ar { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 10px; }
.bc-ar input { width: 100%; max-width: 380px; box-sizing: border-box; }
.link-btn { background: none; border: none; color: var(--brand-dark); text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }
.ap-chart { display: flex; align-items: flex-end; gap: 6px; height: 140px; margin-bottom: 14px; }
.ap-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 3px; min-width: 0; }
.ap-bar { width: 100%; max-width: 26px; background: #f2b497; border-radius: 3px 3px 0 0; }
.ap-bar-courant .ap-bar { background: var(--brand); }
.ap-bar-val { font-size: 11px; font-weight: 700; }
.ap-bar-label { font-size: 10px; color: var(--text-muted); }
.ap-livraisons div { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.ap-livraisons strong { font-size: 15px; }
.ap-scroll { max-height: 250px; overflow: auto; }
.ap-soustotal td { font-weight: 700; background: #f8f8f9; }
.panier-groupe { border: 1px solid var(--border); border-radius: 6px; padding: 10px; margin-bottom: 10px; background: #f8f8f9; }
.panier-groupe-titre { margin-bottom: 6px; }
.panier-groupe label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin: 8px 0; }
.panier-groupe .pg-qte { width: 70px; min-width: 0; }
.choix-overlay { z-index: 230; }
.choix-liste { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.choix-btn { display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: left; }
.choix-btn small { color: var(--text-muted); font-weight: 400; }

.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20,22,26,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 210;
}
.confirm-overlay[hidden] { display: none; }
.confirm-box { background: #fff; border-radius: 8px; padding: 20px; max-width: 420px; width: 90%; }

.panel-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.panel-title-row h2 { margin: 0; }

/* ---------- Ventes : saisie de devis, listes, fenêtre de visualisation ---------- */
.ventes-info-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.ventes-info-cols .field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ventes-info-cols .field-wide { grid-column: span 2; }
@media (max-width: 900px) { .ventes-info-cols { grid-template-columns: 1fr; } }
.vue-actions { position: sticky; top: 0; background: #fff; z-index: 3; padding-bottom: 8px; margin-bottom: 4px; }
.vue-doc .doc-page { min-height: 0; }
.cc-label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.cc-label input { width: 100%; box-sizing: border-box; }
.cc-results { max-height: 260px; overflow: auto; display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.cc-item { text-align: left; }
.cc-item small { color: var(--text-muted); font-weight: 400; margin-left: 6px; }
#print-root { display: none; }

/* ---------- Print area (facture) ---------- */
.print-area { margin-top: 0; }
/* Charte « Garage de Coko » du devis / de la facture : couleurs tirées du logo (fond anthracite, halo violet,
   texte dégradé jaune, vert, turquoise) — à modifier ici. Les fonds sont forcés pour sortir à l'impression. */
.doc-page {
  --coko-noir: #1f1f22; --coko-noir-degrade: linear-gradient(180deg, #000000 0%, #808080 100%); --coko-violet: #8b3ddb; --coko-violet-fonce: #6a22b0; --coko-lavande: #f3ecfb;
  --coko-jaune: #f2e205; --coko-lime: #b9e000; --coko-lime-fonce: #55700a; --coko-turquoise: #14b8a6;
  --coko-texte: #1b1325; --coko-gris: #d6d3dc; --coko-muted: #6b6275;
  background: #fff; color: var(--coko-texte); border: 1px solid var(--border); max-width: 850px; margin: 0 auto;
  min-height: 1120px; display: flex; flex-direction: column; -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.doc-band { background: var(--coko-noir-degrade); color: #fff; padding: 14px 18px; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.doc-band-id { display: flex; align-items: center; gap: 16px; min-width: 0; }
/* Le logo garde ses proportions (rond ou rectangulaire) : hauteur fixe, coins légèrement arrondis. */
.doc-logo { height: 104px; width: auto; max-width: 130px; object-fit: contain; flex: none; border-radius: 6px; }
.doc-band-societe { display: flex; flex-direction: column; font-size: 11.5px; color: #f2f0f5; line-height: 1.5; }
.doc-band-societe strong { color: #fff; font-size: 16px; font-weight: 700; }
.doc-band-titre { text-align: right; flex: none; }
.doc-title { color: var(--coko-lime); font-size: 28px; font-weight: 800; letter-spacing: 1px; text-align: right; line-height: 1.1; }
.doc-band-numero { font-size: 13px; font-weight: 700; margin-top: 2px; }
.doc-band-sub { font-size: 11.5px; color: #f2f0f5; }
/* Liseret aux couleurs du texte du logo : jaune, vert, turquoise. */
.doc-liseret { height: 6px; background: linear-gradient(90deg, var(--coko-jaune), var(--coko-lime) 45%, var(--coko-turquoise)); }
.doc-page > :not(.doc-footer) { margin-left: 24px; margin-right: 24px; }
.doc-page > .doc-band { margin-top: 24px; }
.doc-cartes { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; margin-bottom: 14px; font-size: 13px; }
.doc-carte { padding: 9px 12px; line-height: 1.5; }
.doc-carte-client, .doc-carte-doc { border-left: 4px solid var(--coko-violet); background: var(--coko-lavande); }
.doc-carte-titre { font-size: 11.5px; font-weight: 700; color: var(--coko-violet-fonce); }
.doc-vehicule-groupe { break-inside: avoid; page-break-inside: avoid; margin-bottom: 14px; }
.doc-vehicule-titre { background: var(--coko-violet); color: #fff; padding: 6px 12px; font-weight: 700; font-size: 13px; }
table.doc-lines { width: 100%; border-collapse: collapse; }
table.doc-lines th { background: var(--coko-noir-degrade); color: var(--coko-lime); padding: 7px 8px; font-size: 12px; text-align: left; font-weight: 700; }
table.doc-lines td { padding: 6px 8px; font-size: 12.5px; }
table.doc-lines tbody tr:nth-child(even) td { background: var(--coko-lavande); }
table.doc-lines th:nth-child(n+3), table.doc-lines td:nth-child(n+3) { text-align: right; }
table.doc-lines tr { break-inside: avoid; }
table.doc-lines-bc th:nth-child(3), table.doc-lines-bc td:nth-child(3) { text-align: left; }
.doc-bas { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 18px; align-items: start; margin-top: auto; padding-top: 6px; }
.doc-ventilation { width: 100%; border-collapse: collapse; font-size: 12px; }
.doc-ventilation th { background: var(--coko-lavande); color: var(--coko-violet-fonce); padding: 5px 8px; text-align: right; font-weight: 700; }
.doc-ventilation td { padding: 5px 8px; text-align: right; border-bottom: 1px solid #ece6f3; }
.doc-ventilation th:first-child, .doc-ventilation td:first-child { text-align: left; }
.doc-totaux > div { display: flex; justify-content: space-between; padding: 4px 12px; font-size: 13px; }
.doc-totaux > .doc-total-ttc { background: var(--coko-noir-degrade); color: var(--coko-lime); font-size: 17px; font-weight: 800; padding: 9px 12px; margin-top: 4px; }
.doc-accord { margin-top: 18px; border: 1.5px dashed var(--coko-violet); padding: 9px 12px; min-height: 80px; font-size: 12px; color: var(--coko-muted); break-inside: avoid; display: flex; flex-direction: column; gap: 3px; }
.doc-page > .doc-footer { margin: 20px 24px 24px; background: var(--coko-noir-degrade); color: var(--coko-gris); border-top: 4px solid var(--coko-violet); padding: 9px 18px; font-size: 11px; text-align: center; }

@media print {
  .app-header, .main-nav, .toolbar, .panel:not(.print-area), main > section > .panel { }
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { position: absolute; top: 0; left: 0; width: 100%; margin: 0; }
  .doc-page { min-height: 267mm; border: none; }
  #print-root { display: block; }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--brand-dark);
  color: #fff;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 600;
  z-index: 300;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
}
.toast[hidden] { display: none; }
.toast.toast-error { background: var(--alert); }
.toast.toast-ok { background: var(--ok); }

/* ---------- Connexion et droits utilisateurs ---------- */
/* Les éléments réservés à certains profils portent une classe need-<droit> ; js/auth.js pose sur <body>
   la classe no-<droit> pour chaque droit que l'utilisateur connecté n'a pas (règles générées en JS). */
/* Écran de connexion aux couleurs du Garage de Coko (même charte que les devis et factures). */
.login-overlay {
  --coko-noir-degrade: linear-gradient(180deg, #000000 0%, #808080 100%); --coko-violet: #8b3ddb; --coko-violet-fonce: #6a22b0;
  --coko-jaune: #f2e205; --coko-lime: #b9e000; --coko-turquoise: #14b8a6;
  position: fixed; inset: 0; z-index: 400;
  background: var(--coko-noir-degrade);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.login-overlay[hidden] { display: none; }
.login-box { background: #fff; border-radius: 10px; padding: 26px 28px 22px; width: 100%; max-width: 360px; box-shadow: 0 10px 40px rgba(0,0,0,0.35); }
.login-brand { display: flex; align-items: center; gap: 12px; background: var(--coko-noir-degrade); border-radius: 8px 8px 0 0; padding: 12px 14px; }
.login-logo { width: 54px; height: 54px; border-radius: 50%; flex: none; }
.login-brand-nom { color: #fff; font-size: 17px; font-weight: 800; letter-spacing: 0.5px; line-height: 1.15; }
.login-liseret { height: 5px; margin-bottom: 16px; border-radius: 0 0 4px 4px; background: linear-gradient(90deg, var(--coko-jaune), var(--coko-lime) 45%, var(--coko-turquoise)); }
.login-box h2 { margin: 0 0 8px; font-size: 17px; color: var(--coko-violet-fonce); }
.login-box input:focus, .login-box select:focus { outline: none; border-color: var(--coko-violet); box-shadow: 0 0 0 2px rgba(139, 61, 219, 0.25); }
.login-box .btn-primary { background: var(--coko-violet); color: #fff; }
.login-box .btn-primary:hover { background: var(--coko-violet-fonce); }
.login-box label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 10px; }
.login-box label input, .login-box label select { display: block; width: 100%; margin-top: 4px; }
.login-erreur { color: var(--alert); font-size: 13px; font-weight: 600; min-height: 18px; margin: 4px 0 8px; }
.login-actions { display: flex; gap: 8px; }
.login-actions .btn-primary { flex: 1; }

/* Période d'essai (copie client) : écran de verrouillage au-dessus de la connexion + compteur dans l'en-tête. */
.essai-overlay { z-index: 500; }
.essai-restant { margin-left: auto; font-size: 11.5px; font-weight: 700; color: #cfd2d8; background: rgba(255,255,255,0.08); border-radius: 10px; padding: 3px 10px; white-space: nowrap; }
.essai-restant[hidden] { display: none; }
.essai-restant.essai-bientot { color: #fff; background: var(--alert); }
.essai-restant:not([hidden]) + .user-box { margin-left: 12px; }

.user-box { margin-left: auto; position: relative; }
.user-box[hidden], .user-menu[hidden] { display: none; }
.user-btn {
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.18); color: #fff;
  border-radius: 8px; padding: 5px 12px; cursor: pointer; text-align: left; font-size: 13px; font-weight: 700;
  display: flex; flex-direction: column; line-height: 1.25;
}
.user-btn small { font-weight: 500; color: #cfd2d8; font-size: 11.5px; }
.user-btn:hover { background: rgba(255,255,255,0.16); }
.user-menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; z-index: 160;
  background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,0.2); overflow: hidden;
}
.user-menu button { display: block; width: 100%; text-align: left; background: #fff; border: none; padding: 10px 14px; cursor: pointer; font-size: 13px; color: var(--text); }
.user-menu button:hover { background: var(--bg); }
#table-utilisateurs tbody tr { cursor: pointer; }
.badge-statut { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11.5px; font-weight: 700; background: #e6f4ec; color: var(--ok); }
.badge-statut.off { background: var(--alert-bg); color: var(--alert); }

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
  .field-grid { grid-template-columns: 1fr; }
}
