/* MecaThill - feuille de style unique, thème clair par défaut, mobile d'abord. */

/*
 * Thèmes.
 *
 * Le clair est le thème par défaut : l'application est faite pour être lue
 * en atelier et en extérieur, où un fond sombre renvoie les reflets. Le
 * sombre reste disponible, et le mode automatique suit le réglage du
 * téléphone. Le choix se fait dans les paramètres de l'application.
 *
 * Toutes les couleurs passent par des variables : aucune valeur en dur dans
 * les composants, sans quoi un thème finit toujours par avoir un coin
 * illisible.
 */
:root {
  /* Rythme d'espacement. L'interface respire : sur un téléphone tenu à bout
     de bras dans un atelier, une liste trop dense se lit mal et se touche
     encore plus mal. */
  --espace-xs: 6px;
  --espace-s: 10px;
  --espace: 16px;
  --espace-l: 22px;
  --espace-xl: 30px;

  --rayon: 16px;
  --rayon-s: 11px;

  --marge-basse: env(safe-area-inset-bottom, 0px);
  --marge-haute: env(safe-area-inset-top, 0px);
  --hauteur-onglets: 66px;

  --police: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  --police-chiffres: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;

  /* --- Thème clair, appliqué par défaut ------------------------------- */
  --fond: #f4f6fa;
  --fond-carte: #ffffff;
  --fond-carte-haut: #eef1f7;
  --fond-saisie: #ffffff;

  --bord: #dfe4ed;
  --bord-fort: #c4cddc;

  --texte: #141a24;
  --texte-doux: #4f5b6e;
  --texte-faible: #78849a;

  --accent: #2563eb;
  --accent-fort: #1d4ed8;
  --accent-sourd: #e7effd;
  --sur-accent: #ffffff;

  --succes: #0f9d63;
  --succes-sourd: #e4f6ee;
  --texte-succes: #0a6b44;

  --alerte: #c2760a;
  --alerte-sourd: #fdf1de;
  --texte-alerte: #8a5306;

  --danger: #d92d20;
  --danger-sourd: #fdeceb;
  --texte-danger: #a32016;

  --ombre: 0 4px 20px rgb(16 24 40 / 10%);
  --ombre-forte: 0 8px 28px rgb(16 24 40 / 16%);

  /* Fond des vignettes produit : les visuels sont détourés sur blanc. */
  --fond-vignette: #ffffff;

  color-scheme: light;
}

/* --- Thème sombre --------------------------------------------------- */
:root[data-theme="sombre"] {
  --fond: #0b0f16;
  --fond-carte: #141a25;
  --fond-carte-haut: #1c2432;
  --fond-saisie: #0f151f;

  --bord: #253044;
  --bord-fort: #35425c;

  --texte: #e8edf5;
  --texte-doux: #9aa8bf;
  --texte-faible: #6c7a92;

  --accent: #3d8bfd;
  --accent-fort: #5c9dff;
  --accent-sourd: #16233a;
  --sur-accent: #ffffff;

  --succes: #35c48a;
  --succes-sourd: #10281f;
  --texte-succes: #6fdcae;

  --alerte: #f0a338;
  --alerte-sourd: #2a2011;
  --texte-alerte: #f5bd6b;

  --danger: #f26d6d;
  --danger-sourd: #2c1618;
  --texte-danger: #ff9c9c;

  --ombre: 0 6px 24px rgb(0 0 0 / 45%);
  --ombre-forte: 0 10px 32px rgb(0 0 0 / 55%);

  --fond-vignette: #ffffff;

  color-scheme: dark;
}

/* Mode automatique : le thème suit le réglage du téléphone. */
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --fond: #0b0f16;
    --fond-carte: #141a25;
    --fond-carte-haut: #1c2432;
    --fond-saisie: #0f151f;
    --bord: #253044;
    --bord-fort: #35425c;
    --texte: #e8edf5;
    --texte-doux: #9aa8bf;
    --texte-faible: #6c7a92;
    --accent: #3d8bfd;
    --accent-fort: #5c9dff;
    --accent-sourd: #16233a;
    --succes: #35c48a;
    --succes-sourd: #10281f;
    --texte-succes: #6fdcae;
    --alerte: #f0a338;
    --alerte-sourd: #2a2011;
    --texte-alerte: #f5bd6b;
    --danger: #f26d6d;
    --danger-sourd: #2c1618;
    --texte-danger: #ff9c9c;
    --ombre: 0 6px 24px rgb(0 0 0 / 45%);
    --ombre-forte: 0 10px 32px rgb(0 0 0 / 55%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

/* Toute règle `display` explicite l'emporterait sur le comportement par
   défaut de l'attribut `hidden`. Comme l'interface masque des champs, des
   alertes et le calque modal par cet attribut, la règle doit être absolue :
   sans elle, un calque « caché » recouvre la page et avale tous les clics. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--fond);
  color: var(--texte);
  font-family: var(--police);
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

body { overflow: hidden; }

button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-fort); }

/* ------------------------------------------------------------------ */
/* Structure                                                           */
/* ------------------------------------------------------------------ */

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

.entete {
  flex: 0 0 auto;
  padding: calc(var(--marge-haute) + 12px) var(--espace) 12px;
  background: var(--fond-carte);
  border-bottom: 1px solid var(--bord);
  display: flex;
  align-items: center;
  gap: var(--espace-s);
  min-height: 58px;
}

.entete__titre {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entete__sous {
  display: block;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--texte-faible);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.entete__actions { display: flex; gap: 8px; flex: 0 0 auto; }

.vue {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: var(--espace) var(--espace)
    calc(var(--espace-l) + var(--hauteur-onglets) + var(--marge-basse));
}

.onglets {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  background: var(--fond-carte);
  border-top: 1px solid var(--bord);
  padding-bottom: var(--marge-basse);
  z-index: 30;
}

.onglet {
  border: 0;
  background: none;
  padding: 8px 2px 10px;
  color: var(--texte-faible);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s;
}

.onglet svg { width: 22px; height: 22px; stroke-width: 1.7; }
.onglet--actif { color: var(--accent-fort); }
.onglet__pastille {
  position: absolute;
  transform: translate(14px, -4px);
  background: var(--danger);
  color: #fff;
  font-size: 0.6rem;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  padding: 0 4px;
}

/* ------------------------------------------------------------------ */
/* Composants de base                                                  */
/* ------------------------------------------------------------------ */

.carte {
  background: var(--fond-carte);
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  padding: var(--espace-l) var(--espace);
  margin-bottom: var(--espace);
}

.carte--plate { padding: 0; overflow: hidden; }

.titre-section {
  margin: var(--espace-xl) 0 var(--espace-s);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--texte-faible);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.titre-section:first-child { margin-top: var(--espace-xs); }

.bouton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 15px;
  border-radius: var(--rayon-s);
  border: 1px solid var(--bord-fort);
  background: var(--fond-carte-haut);
  color: var(--texte);
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: filter 0.15s, background 0.15s;
}
.bouton:active { filter: brightness(1.25); }
.bouton:disabled { opacity: 0.45; cursor: not-allowed; }
.bouton svg { width: 18px; height: 18px; stroke-width: 1.9; }

.bouton--primaire {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--sur-accent);
}
.bouton--danger {
  background: var(--danger-sourd);
  border-color: var(--danger);
  color: var(--texte-danger);
}
.bouton--succes {
  background: var(--succes-sourd);
  border-color: var(--succes);
  color: var(--texte-succes);
}
.bouton--fantome { background: transparent; border-color: transparent; color: var(--texte-doux); }
.bouton--large { width: 100%; }
.bouton--petit { min-height: 34px; padding: 0 11px; font-size: 0.83rem; }
.bouton--icone { min-width: 44px; padding: 0 10px; }

.champ { display: block; margin-bottom: var(--espace); }
.champ__label {
  display: block;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--texte-doux);
  margin-bottom: 5px;
  letter-spacing: 0.01em;
}
.champ__saisie {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  background: var(--fond-saisie);
  border: 1px solid var(--bord);
  border-radius: var(--rayon-s);
  color: var(--texte);
  outline: none;
  transition: border-color 0.15s;
}
.champ__saisie:focus { border-color: var(--accent); }
.champ__saisie::placeholder { color: var(--texte-faible); }
textarea.champ__saisie { min-height: 84px; resize: vertical; line-height: 1.45; }
select.champ__saisie { appearance: none; background-image: none; }
.champ__aide { display: block; margin-top: 5px; font-size: 0.74rem; color: var(--texte-faible); }
.champ__erreur { color: var(--texte-danger); }

.grille-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--espace); }
.grille-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--espace); }
@media (max-width: 380px) { .grille-3 { grid-template-columns: repeat(2, 1fr); } }

.rangee { display: flex; align-items: center; gap: var(--espace-s); }
.rangee--espacee { justify-content: space-between; }
.rangee--fin { justify-content: flex-end; }
.pousse { margin-left: auto; }

/* Barre de recherche collante en haut de liste. */
.recherche {
  position: sticky;
  top: -12px;
  z-index: 10;
  background: var(--fond);
  padding: 12px 0 10px;
  margin: -12px 0 4px;
  display: flex;
  gap: 8px;
}
.recherche .champ__saisie { margin: 0; }

.etiquette {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: var(--fond-carte-haut);
  color: var(--texte-doux);
  white-space: nowrap;
}
.etiquette--b2b { background: var(--accent-sourd); color: var(--accent-fort); }
.etiquette--b2c { background: var(--fond-carte-haut); color: var(--texte-doux); }
.etiquette--succes { background: var(--succes-sourd); color: var(--texte-succes); }
.etiquette--alerte { background: var(--alerte-sourd); color: var(--texte-alerte); }
.etiquette--danger { background: var(--danger-sourd); color: var(--texte-danger); }
.etiquette--neutre { background: var(--fond-carte-haut); color: var(--texte-faible); }

.chiffre { font-family: var(--police-chiffres); font-variant-numeric: tabular-nums; }

.alerte {
  padding: 13px 15px;
  border-radius: var(--rayon-s);
  font-size: 0.86rem;
  line-height: 1.5;
  margin: 0 0 var(--espace);
  border: 1px solid transparent;
}
.alerte--erreur {
  background: var(--danger-sourd);
  border-color: var(--danger);
  color: var(--texte-danger);
}
.alerte--info {
  background: var(--accent-sourd);
  border-color: var(--accent);
  color: var(--accent-fort);
}
.alerte--attention {
  background: var(--alerte-sourd);
  border-color: var(--alerte);
  color: var(--texte-alerte);
}

.vide {
  text-align: center;
  padding: 56px var(--espace-l);
  color: var(--texte-faible);
}
.vide__titre { font-weight: 650; color: var(--texte-doux); margin-bottom: 6px; }

/* ------------------------------------------------------------------ */
/* Listes                                                              */
/* ------------------------------------------------------------------ */

.liste { list-style: none; margin: 0; padding: 0; }

.ligne {
  display: flex;
  align-items: center;
  gap: var(--espace);
  width: 100%;
  padding: var(--espace);
  background: var(--fond-carte);
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  margin-bottom: var(--espace-s);
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  color: inherit;
}
.ligne:active { background: var(--fond-carte-haut); }
.ligne__corps { flex: 1 1 auto; min-width: 0; }
.ligne__titre {
  font-weight: 600;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ligne__sous {
  font-size: 0.78rem;
  color: var(--texte-faible);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}
.ligne__fin { flex: 0 0 auto; text-align: right; }
.ligne__montant { font-weight: 650; font-family: var(--police-chiffres); }

.vignette {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 10px;
  background: var(--fond-vignette);
  object-fit: contain;
  padding: 4px;
  border: 1px solid var(--bord);
}
.vignette--vide {
  display: grid;
  place-items: center;
  background: var(--fond-carte-haut);
  color: var(--texte-faible);
  font-size: 0.66rem;
  font-weight: 700;
  padding: 0;
}

/* ------------------------------------------------------------------ */
/* Tableau de bord                                                     */
/* ------------------------------------------------------------------ */

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: var(--espace); }

.stat {
  background: var(--fond-carte);
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  padding: var(--espace);
}
.stat__label {
  font-size: 0.71rem;
  font-weight: 600;
  color: var(--texte-faible);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.stat__valeur {
  font-size: 1.42rem;
  font-weight: 700;
  font-family: var(--police-chiffres);
  letter-spacing: -0.02em;
  margin-top: 3px;
  line-height: 1.15;
}
.stat__delta { font-size: 0.74rem; margin-top: 3px; color: var(--texte-faible); }
.stat__delta--haut { color: var(--texte-succes); }
.stat__delta--bas { color: var(--texte-danger); }

/* Histogramme des 12 derniers mois, en CSS pur. */
.histo {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 96px;
  padding-top: 6px;
}
.histo__col { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.histo__barre {
  width: 100%;
  min-height: 2px;
  background: linear-gradient(180deg, var(--accent-fort), var(--accent));
  border-radius: 4px 4px 0 0;
  transition: height 0.3s;
}
.histo__mois { font-size: 0.6rem; color: var(--texte-faible); }

.jauge {
  height: 7px;
  border-radius: 4px;
  background: var(--fond-saisie);
  overflow: hidden;
  margin-top: 7px;
}
.jauge__part { height: 100%; background: var(--accent); border-radius: 4px; }
.jauge__part--succes { background: var(--succes); }
.jauge__part--alerte { background: var(--alerte); }
.jauge__part--danger { background: var(--danger); }

/* ------------------------------------------------------------------ */
/* Catalogue                                                           */
/* ------------------------------------------------------------------ */

.filtres {
  display: flex;
  gap: var(--espace-s);
  overflow-x: auto;
  padding: 2px 0 var(--espace);
  margin: 0 -14px 2px;
  padding-left: 14px;
  padding-right: 14px;
  scrollbar-width: none;
}
.filtres::-webkit-scrollbar { display: none; }
.puce {
  flex: 0 0 auto;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--bord);
  background: var(--fond-carte);
  color: var(--texte-doux);
  font-size: 0.81rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.puce--active { background: var(--accent); border-color: var(--accent); color: #fff; }

.produits { display: grid; grid-template-columns: 1fr 1fr; gap: var(--espace); }
@media (min-width: 560px) { .produits { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 820px) { .produits { grid-template-columns: repeat(4, 1fr); } }

.produit {
  background: var(--fond-carte);
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 0;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}
.produit:active { border-color: var(--bord-fort); }
.produit__image {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: var(--fond-vignette);
  padding: 10px;
}
.produit__image--vide {
  display: grid;
  place-items: center;
  background: var(--fond-carte-haut);
  color: var(--texte-faible);
  font-size: 0.7rem;
  padding: 0;
}
.produit__corps {
  padding: 13px 14px 15px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}
.produit__ref {
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--texte-faible);
  letter-spacing: 0.04em;
}
.produit__nom {
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.produit__contenance { font-size: 0.71rem; color: var(--texte-faible); }
.produit__prix {
  margin-top: auto;
  padding-top: 6px;
  font-family: var(--police-chiffres);
  font-weight: 700;
  font-size: 0.95rem;
}
.produit__badges { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }

/* Fiche article */
.fiche__image {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  background: var(--fond-vignette);
  border-radius: var(--rayon);
  padding: 16px;
  border: 1px solid var(--bord);
}
.detail {
  display: flex;
  justify-content: space-between;
  gap: var(--espace);
  padding: 13px 0;
  border-bottom: 1px solid var(--bord);
}
.detail:last-child { border-bottom: 0; }
.detail__label { color: var(--texte-doux); font-size: 0.85rem; }
.detail__valeur { font-weight: 600; text-align: right; font-family: var(--police-chiffres); }
.detail__valeur--texte { font-family: var(--police); font-weight: 500; }

.bloc-texte { font-size: 0.87rem; color: var(--texte-doux); line-height: 1.55; white-space: pre-line; }

/* ------------------------------------------------------------------ */
/* Devis                                                               */
/* ------------------------------------------------------------------ */

.panier {
  position: fixed;
  left: 12px; right: 12px;
  bottom: calc(var(--hauteur-onglets) + var(--marge-basse) + 12px);
  background: var(--accent);
  color: var(--sur-accent);
  border-radius: var(--rayon);
  padding: var(--espace) var(--espace-l);
  display: flex;
  align-items: center;
  gap: var(--espace);
  box-shadow: var(--ombre-forte);
  border: 0;
  font-weight: 650;
  cursor: pointer;
  z-index: 25;
}
.panier__compte {
  background: rgb(255 255 255 / 22%);
  border-radius: 999px;
  min-width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  font-size: 0.83rem;
  padding: 0 7px;
}

.ligne-devis {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--espace-s) var(--espace);
  padding: var(--espace) 0;
  border-bottom: 1px solid var(--bord);
}
.ligne-devis:last-of-type { border-bottom: 0; }
.ligne-devis__nom { font-weight: 600; font-size: 0.9rem; }
.ligne-devis__meta { font-size: 0.74rem; color: var(--texte-faible); margin-top: 2px; }
.ligne-devis__controle { display: flex; align-items: center; gap: 6px; }

.compteur { display: flex; align-items: center; gap: 2px; }
.compteur__bouton {
  width: 36px; height: 36px;
  border-radius: 9px;
  border: 1px solid var(--bord-fort);
  background: var(--fond-carte-haut);
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.compteur__valeur {
  width: 52px;
  text-align: center;
  background: var(--fond-saisie);
  border: 1px solid var(--bord);
  border-radius: 9px;
  height: 36px;
  font-family: var(--police-chiffres);
  font-weight: 650;
}

.totaux { border-top: 1px solid var(--bord-fort); margin-top: 6px; padding-top: 10px; }
.totaux__ligne {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 0.9rem;
  color: var(--texte-doux);
}
.totaux__ligne--fort {
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--texte);
  padding-top: 9px;
  margin-top: 5px;
  border-top: 1px solid var(--bord);
}
.totaux__ligne .chiffre { font-weight: 650; }

/* ------------------------------------------------------------------ */
/* Feuille modale                                                      */
/* ------------------------------------------------------------------ */

.calque {
  position: fixed;
  inset: 0;
  background: rgb(9 14 22 / 62%);
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fondu 0.16s ease;
}
@keyframes fondu { from { opacity: 0; } }

.feuille {
  background: var(--fond-carte);
  border: 1px solid var(--bord);
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 620px;
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
  animation: monte 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes monte { from { transform: translateY(100%); } }

.feuille__entete {
  padding: var(--espace) var(--espace-l) 12px;
  border-bottom: 1px solid var(--bord);
  display: flex;
  align-items: center;
  gap: 10px;
}
.feuille__poignee {
  position: absolute;
  top: 7px; left: 50%;
  transform: translateX(-50%);
  width: 38px; height: 4px;
  border-radius: 3px;
  background: var(--bord-fort);
}
.feuille__titre { margin: 0; font-size: 1rem; font-weight: 650; flex: 1; }
.feuille__corps {
  padding: var(--espace-l) var(--espace-l) calc(var(--espace-l) + var(--marge-basse));
  overflow-y: auto;
  flex: 1;
}
.feuille__pied {
  padding: var(--espace) var(--espace-l) calc(var(--espace) + var(--marge-basse));
  border-top: 1px solid var(--bord);
  display: flex;
  gap: var(--espace-s);
}
.feuille__pied .bouton { flex: 1; }

/* ------------------------------------------------------------------ */
/* Scanner de code-barres                                              */
/* ------------------------------------------------------------------ */

.scanner { position: fixed; inset: 0; background: #000; z-index: 80; display: flex; flex-direction: column; }
.scanner__flux { flex: 1; width: 100%; object-fit: cover; }
.scanner__cible {
  position: absolute;
  left: 8%; right: 8%;
  top: 50%;
  transform: translateY(-50%);
  height: 165px;
  border: 2px solid rgb(255 255 255 / 85%);
  border-radius: 14px;
  box-shadow: 0 0 0 100vmax rgb(0 0 0 / 55%);
}
.scanner__laser {
  position: absolute;
  left: 6px; right: 6px;
  top: 50%;
  height: 2px;
  background: #ff4d4d;
  box-shadow: 0 0 10px #ff4d4d;
  animation: balayage 1.9s ease-in-out infinite;
}
@keyframes balayage {
  0%, 100% { transform: translateY(-72px); }
  50% { transform: translateY(72px); }
}
.scanner__barre {
  position: absolute;
  left: 0; right: 0;
  bottom: 0;
  padding: 16px 16px calc(20px + var(--marge-basse));
  display: flex;
  gap: 10px;
  background: linear-gradient(0deg, rgb(0 0 0 / 82%), transparent);
}
.scanner__info {
  position: absolute;
  top: calc(var(--marge-haute) + 16px);
  left: 16px; right: 16px;
  text-align: center;
  color: #fff;
  font-size: 0.86rem;
  text-shadow: 0 1px 4px #000;
}

/* ------------------------------------------------------------------ */
/* Divers                                                              */
/* ------------------------------------------------------------------ */

.connexion {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--espace-l);
  padding: var(--espace-l) 18px calc(var(--espace-l) + var(--marge-basse));
  background:
    radial-gradient(1000px 460px at 50% -8%, var(--accent-sourd) 0%, transparent 62%),
    var(--fond);
}
.connexion__carte {
  width: 100%;
  max-width: 380px;
  background: var(--fond-carte);
  border: 1px solid var(--bord);
  border-radius: 18px;
  padding: var(--espace-xl) var(--espace-l);
  box-shadow: var(--ombre);
}
.connexion__note { font-size: 0.75rem; color: var(--texte-faible); text-align: center; margin: 14px 0 0; }
.marque { display: flex; align-items: center; gap: 13px; margin-bottom: 22px; }
.marque__logo { border-radius: 13px; }
.marque__nom { margin: 0; font-size: 1.32rem; font-weight: 700; letter-spacing: -0.02em; }
.marque__sous { margin: 1px 0 0; font-size: 0.78rem; color: var(--texte-faible); }

.chargement {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--fond);
  z-index: 100;
}
.chargement[hidden] { display: none; }
.chargement__cercle {
  width: 34px; height: 34px;
  border: 3px solid var(--bord-fort);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: tourne 0.75s linear infinite;
}
@keyframes tourne { to { transform: rotate(360deg); } }

.toasts {
  position: fixed;
  left: 12px; right: 12px;
  /* Les messages descendent du haut : c'est là que le regard revient après
     une action, et le bas de l'écran est déjà occupé par la barre d'onglets
     et le bouton du devis en cours. */
  top: calc(var(--marge-haute) + 10px);
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--espace-s);
  pointer-events: none;
}
/* Bulle centrée, largeur ajustée au texte, ombre portée pour se détacher
   du contenu sur lequel elle passe. */
.toast {
  background: var(--fond-carte);
  border: 1px solid var(--bord-fort);
  border-radius: 999px;
  padding: 11px 18px;
  font-size: 0.87rem;
  font-weight: 550;
  text-align: center;
  max-width: 100%;
  box-shadow: var(--ombre-forte);
  animation: descendToast 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.toast--succes {
  border-color: var(--succes);
  background: var(--succes-sourd);
  color: var(--texte-succes);
}
.toast--erreur {
  border-color: var(--danger);
  background: var(--danger-sourd);
  color: var(--texte-danger);
}
@keyframes descendToast {
  from { opacity: 0; transform: translateY(-12px) scale(0.96); }
}

.bandeau-hors-ligne {
  background: var(--alerte-sourd);
  color: var(--texte-alerte);
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 7px;
  border-bottom: 1px solid var(--alerte);
}

.squelette {
  background: linear-gradient(90deg, var(--fond-carte) 25%, var(--fond-carte-haut) 50%, var(--fond-carte) 75%);
  background-size: 200% 100%;
  animation: brille 1.3s infinite;
  border-radius: var(--rayon);
  height: 68px;
  margin-bottom: 8px;
}
@keyframes brille { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ------------------------------------------------------------------ */
/* Aperçu du document de vente                                         */
/* ------------------------------------------------------------------ */

/* Le document s'affiche sur fond clair, tel qu'il partira au client :
   le commercial doit voir exactement ce que le client recevra. */
.document {
  background: #fff;
  color: #14181f;
  border-radius: var(--rayon);
  padding: 20px 18px 24px;
  font-size: 0.84rem;
  line-height: 1.45;
  margin-bottom: 12px;
  overflow-x: auto;
}

.document__entete {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.document__emetteur { font-size: 0.74rem; color: #5a6472; line-height: 1.5; }
.document__emetteur strong {
  display: block;
  font-size: 1.05rem;
  color: #14181f;
  margin-bottom: 3px;
}
.document__client {
  font-size: 0.76rem;
  text-align: right;
  line-height: 1.5;
  max-width: 52%;
}
.document__client strong {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #5a6472;
  margin-bottom: 3px;
}

.document__titre { font-size: 1.25rem; font-weight: 700; margin: 0 0 5px; }
.document__meta { font-size: 0.76rem; color: #5a6472; line-height: 1.55; margin-bottom: 16px; }

.document table { width: 100%; border-collapse: collapse; }
.document th {
  text-align: left;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #5a6472;
  border-bottom: 2px solid #14181f;
  padding: 0 4px 5px;
  white-space: nowrap;
}
.document td {
  padding: 7px 4px;
  border-bottom: 1px solid #e4e8ee;
  vertical-align: top;
  font-size: 0.79rem;
}
.document .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.document__ref { color: #5a6472; font-size: 0.72rem; }

.document__totaux { margin-left: auto; width: 240px; margin-top: 12px; }
.document__totaux td { border: 0; padding: 2px 4px; font-size: 0.79rem; color: #5a6472; }
.document__totaux tr:last-child td {
  border-top: 2px solid #14181f;
  font-weight: 700;
  font-size: 1rem;
  color: #14181f;
  padding-top: 7px;
}

.document__conditions {
  margin-top: 20px;
  font-size: 0.72rem;
  color: #5a6472;
  line-height: 1.5;
}
.document__conditions strong { color: #14181f; display: block; margin-bottom: 2px; }

.document__signature {
  margin-top: 26px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  font-size: 0.7rem;
  color: #5a6472;
}
.document__signature div {
  flex: 1;
  border-top: 1px solid #9aa4b2;
  padding-top: 4px;
}
.document__signature div:last-child { text-align: right; }

/* Barre d'actions fixe sous l'aperçu. */
.barre-actions {
  position: fixed;
  left: 12px; right: 12px;
  bottom: calc(var(--hauteur-onglets) + var(--marge-basse) + 12px);
  display: flex;
  gap: 9px;
  z-index: 25;
}
.barre-actions .bouton { flex: 1; box-shadow: var(--ombre); }

.destinataire {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--fond-saisie);
  border: 1px solid var(--bord);
  border-radius: var(--rayon-s);
  padding: 7px 10px;
  margin-bottom: 8px;
  font-size: 0.86rem;
}
.destinataire__retirer {
  margin-left: auto;
  background: none;
  border: 0;
  color: var(--texte-faible);
  cursor: pointer;
  padding: 4px;
  display: grid;
  place-items: center;
}

/* ------------------------------------------------------------------ */
/* Pied de page                                                        */
/* ------------------------------------------------------------------ */

.pied {
  margin-top: var(--espace-xl);
  padding-top: var(--espace-l);
  border-top: 1px solid var(--bord);
  text-align: center;
  font-size: 0.76rem;
  color: var(--texte-faible);
  line-height: 1.7;
}
.pied__marque { font-weight: 600; color: var(--texte-doux); }
.pied__coeur { color: var(--danger); font-style: normal; }
.pied__version {
  font-family: var(--police-chiffres);
  font-size: 0.7rem;
  letter-spacing: 0.02em;
}
.pied a { color: inherit; text-decoration: none; }
.pied a:hover { text-decoration: underline; }

/* Le pied de l'écran de connexion reste discret et hors de la carte. Il est
   ancré en bas plutôt que placé dans le flux : sinon la marge automatique
   absorbe l'espace et chasse la carte de connexion vers le haut. */
.connexion__pied {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--espace) + var(--marge-basse));
  text-align: center;
  font-size: 0.74rem;
  color: var(--texte-faible);
  line-height: 1.7;
}
