/* ═══════════════════════════════════════════════════════════════════════════
   COCKPIT SMART — feuille de style
   Cible : iPhone (poignet, une main) ET Mac (grand écran, souris).
   Règles : cibles tactiles ≥ 56 px, contraste fort, aucune information
   critique qui dépende d'un survol de souris.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --fond: #0b0f16;
  --fond-carte: #151c27;
  --fond-carte-2: #1d2634;
  --texte: #eef3fa;
  --texte-doux: #93a3b8;
  --accent: #3ddc97;
  --accent-2: #4aa8ff;
  --alerte: #ffb020;
  --critique: #ff5c5c;
  --rayon: 18px;
  --cible: 56px;
  --safe-haut: env(safe-area-inset-top, 0px);
  --safe-bas: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: light) {
  :root {
    --fond: #f4f6fa;
    --fond-carte: #ffffff;
    --fond-carte-2: #eef1f6;
    --texte: #10151d;
    --texte-doux: #5a6879;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--fond);
  color: var(--texte);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

/* ─────────────────────────── EN-TÊTE ─────────────────────────── */
.entete {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: calc(var(--safe-haut) + 12px) 16px 10px;
  background: color-mix(in srgb, var(--fond) 88%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--texte) 12%, transparent);
}
.entete-titre { display: flex; align-items: center; gap: 10px; }
.entete h1 { font-size: 20px; margin: 0; letter-spacing: -0.02em; }

/* ⚠️ LE BOUTON DE DÉCONNEXION EST TOUJOURS VISIBLE.
 *   La session porte les données clients de deux boutiques : la fermer doit
 *   prendre un geste, pas une chasse au menu. */
.bouton-deconnexion {
  margin-left: auto;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  line-height: 1;
  color: var(--texte-doux);
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--texte) 14%, transparent);
  border-radius: 12px;
  cursor: pointer;
}
.bouton-deconnexion:hover,
.bouton-deconnexion:focus-visible {
  color: var(--critique);
  border-color: color-mix(in srgb, var(--critique) 45%, transparent);
}
.pastille {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--texte-doux); flex: none;
  transition: background .2s;
}
.pastille.ok { background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
.pastille.ko { background: var(--critique); box-shadow: 0 0 0 4px color-mix(in srgb, var(--critique) 22%, transparent); }

.commutateur { display: flex; gap: 8px; margin-top: 12px; }
.onglet {
  flex: 1 1 0; min-height: var(--cible);
  border: 1px solid color-mix(in srgb, var(--texte) 16%, transparent);
  background: var(--fond-carte);
  color: var(--texte-doux);
  border-radius: 14px; font-size: 15px; font-weight: 600;
  cursor: pointer; padding: 0 8px;
}
.onglet.actif { background: var(--accent); color: #06120c; border-color: transparent; }
.horodatage { margin: 10px 0 0; font-size: 12.5px; color: var(--texte-doux); }

/* ─────────────────────────── BLOCS ─────────────────────────── */
main { padding: 16px 16px calc(40px + var(--safe-bas)); max-width: 1100px; margin: 0 auto; }
.bloc { margin: 0 0 26px; }
.bloc h2 {
  font-size: 12.5px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--texte-doux); margin: 0 0 10px; font-weight: 700;
}

/* ─────────────────────────── TUILES ─────────────────────────── */
.tuiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.tuile {
  background: var(--fond-carte); border-radius: var(--rayon);
  padding: 14px 16px; border: 1px solid color-mix(in srgb, var(--texte) 8%, transparent);
}
.tuile-libelle { font-size: 12.5px; color: var(--texte-doux); display: block; margin-bottom: 6px; }
.tuile-valeur { font-size: 26px; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.tuile.vide .tuile-valeur { color: var(--texte-doux); font-size: 19px; font-weight: 600; }
.tuile.accent .tuile-valeur { color: var(--accent); }
.tuile.alerte .tuile-valeur { color: var(--alerte); }
/* La marge matière n'est pas un bénéfice : elle est neutre, jamais « accent ». */
.tuile.neutre .tuile-valeur { color: var(--texte); }

/* ─────────────────────────── ACTIONS ─────────────────────────── */
.actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 720px) { .actions { grid-template-columns: repeat(4, 1fr); } }
.action {
  min-height: 108px; border: none; cursor: pointer;
  border-radius: var(--rayon); padding: 14px;
  background: linear-gradient(160deg, var(--fond-carte-2), var(--fond-carte));
  color: var(--texte); text-align: left;
  display: flex; flex-direction: column; justify-content: space-between; gap: 8px;
  box-shadow: 0 1px 0 color-mix(in srgb, var(--texte) 10%, transparent) inset;
}
.action:active { transform: scale(.985); }
.action-nombre { font-size: 34px; font-weight: 780; line-height: 1; font-variant-numeric: tabular-nums; }
.action-libelle { font-size: 13px; color: var(--texte-doux); line-height: 1.3; }
.action.urgent .action-nombre { color: var(--alerte); }
.action.vide .action-nombre { color: var(--texte-doux); }

.note { font-size: 12.5px; color: var(--texte-doux); margin: 10px 0 0; line-height: 1.45; }

/* ─────────────────────────── LISTES ─────────────────────────── */
.liste-alertes { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.liste-alertes li {
  background: color-mix(in srgb, var(--critique) 12%, var(--fond-carte));
  border-left: 3px solid var(--critique);
  border-radius: 12px; padding: 12px 14px; font-size: 14px;
}
.liste-alertes li.warning { background: color-mix(in srgb, var(--alerte) 12%, var(--fond-carte)); border-left-color: var(--alerte); }
.liste-alertes li.note { background: none; border-left: none; color: var(--texte-doux); font-size: 12.5px; }

.tableau-liste { display: grid; gap: 8px; }
/* Un enfant de grille ne doit JAMAIS imposer sa largeur : sinon une seule
   ligne trop longue fait déborder toute la page sur un téléphone. */
.tableau-liste > * { min-width: 0; }

/* ─────────────────────── TABLEAU (RENTABILITÉ) ─────────────────────── */
/*
 * ⚠️ UN TABLEAU À SIX COLONNES NE RENTRE PAS DANS 390 PX.
 *   Sans conteneur à défilement horizontal, le tableau pousse la page
 *   entière et le reste de l'écran sort du cadre. Le conteneur défile,
 *   la page ne bouge pas.
 */
.tableau-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 0 10px; }
.tableau { width: 100%; border-collapse: collapse; font-size: 13px; }
.tableau th, .tableau td {
  padding: 9px 12px; text-align: left; white-space: nowrap;
  border-bottom: 1px solid color-mix(in srgb, var(--texte) 10%, transparent);
}
.tableau th {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--texte-doux); font-weight: 700;
}
.tableau td:nth-child(3), .tableau td:nth-child(4), .tableau td:nth-child(5), .tableau td:nth-child(6) {
  font-variant-numeric: tabular-nums;
}
/* Un montant négatif se voit, un montant positif se lit : la couleur porte
   l'information, pas la seule lecture du signe. */
.tableau td.negatif { color: var(--critique); font-weight: 700; }
.tableau td.positif { color: var(--texte); }
.ligne {
  background: var(--fond-carte); border-radius: 14px; padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 1px solid color-mix(in srgb, var(--texte) 8%, transparent);
}
.ligne-principal { min-width: 0; }
.ligne-ref { font-weight: 700; font-size: 15px; }
.ligne-detail { font-size: 12.5px; color: var(--texte-doux); margin-top: 2px; overflow-wrap: anywhere; }
.ligne-montant { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

/*
 * ⚠️ SUR UN TÉLÉPHONE, LE MONTANT DÉBORDAIT DE L'ÉCRAN.
 *   `.ligne-montant` est en `white-space: nowrap` : le bloc
 *   « 89,00 € marge nette 29,61 € » ne peut pas se réduire, il pousse donc
 *   la carte plus large que l'écran — et le prix devient ILLISIBLE, coupé
 *   au bord droit. Mesuré le 01/12/2026 (capture iPhone).
 *   Sous 560 px, la ligne s'empile : le montant passe en dessous du détail,
 *   et le texte peut se replier.
 */
@media (max-width: 560px) {
  .ligne { flex-direction: column; align-items: flex-start; gap: 4px; }
  .ligne-montant { white-space: normal; }
}
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .02em;
  background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent);
}
.badge.attente { background: color-mix(in srgb, var(--alerte) 20%, transparent); color: var(--alerte); }
.badge.gris { background: color-mix(in srgb, var(--texte) 14%, transparent); color: var(--texte-doux); }
.badge.ok { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); }
.badge.ko { background: color-mix(in srgb, var(--critique) 20%, transparent); color: var(--critique); }
.vide-message { color: var(--texte-doux); font-size: 14px; padding: 14px 2px; }

/* ─────────────────────── CENTRE DE COMMANDES ─────────────────────── */
/* ⚠️ LA RECHERCHE EST INSTANTANÉE ET VISIBLE, JAMAIS UN MENU CACHÉ.
     Sur iPhone, un filtre derrière un sous-menu, c'est un filtre qu'on ne
     trouve pas quand on cherche un colis à 8 h du matin. */
.barre-recherche {
  display: grid; gap: 8px; margin-bottom: 12px;
  grid-template-columns: 1fr;
}
@media (min-width: 720px) {
  .barre-recherche { grid-template-columns: 2fr 1fr 1fr 1fr; }
}
.barre-recherche input, .barre-recherche select {
  min-height: var(--cible); font-size: 15px; font-family: inherit;
  border-radius: 14px; border: 1px solid color-mix(in srgb, var(--texte) 16%, transparent);
  background: var(--fond-carte); color: var(--texte); padding: 0 14px; width: 100%;
}
.barre-recherche input::placeholder { color: var(--texte-doux); }

.commande {
  background: var(--fond-carte); border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--texte) 8%, transparent);
}
.commande > summary { list-style: none; cursor: pointer; }
.commande > summary::-webkit-details-marker { display: none; }
.commande[open] > summary { border-bottom: 1px solid color-mix(in srgb, var(--texte) 8%, transparent); }
.commande[open] .ligne { border: none; background: transparent; }

/* ─────────────────────────── LA FICHE ─────────────────────────── */
.fiche { padding: 4px 14px 16px; }
.fiche h4 {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--texte-doux); margin: 18px 0 8px; font-weight: 700;
}
.fiche-grille {
  display: grid; gap: 8px 14px; margin-top: 12px;
  grid-template-columns: 1fr;
}
@media (min-width: 720px) { .fiche-grille { grid-template-columns: 1fr 1fr; } }
.fiche-grille > div { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.fiche-cle { font-size: 12.5px; color: var(--texte-doux); flex: none; }
.fiche-valeur { font-size: 13.5px; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.fiche-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.fiche-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--texte-doux); padding: 6px 4px; border-bottom: 1px solid color-mix(in srgb, var(--texte) 12%, transparent);
}
.fiche-table td { padding: 7px 4px; border-bottom: 1px solid color-mix(in srgb, var(--texte) 7%, transparent); }
.fiche-table .num, .num { text-align: right; font-variant-numeric: tabular-nums; }
.fiche-lignes { display: grid; gap: 6px; }
.fiche-ligne { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.fiche-ligne > span:first-child { color: var(--texte-doux); }
.fiche-historique { margin: 0; padding-left: 18px; font-size: 13px; display: grid; gap: 5px; }
.muted { color: var(--texte-doux); font-weight: 500; }

/* ─────────────── LES SIX GROS BOUTONS / LES ANALYSES AVANCÉES ─────────────── */
.actions.gros { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 720px) { .actions.gros { grid-template-columns: repeat(3, 1fr); } }
.action.gros { min-height: 124px; }
.action.gros .action-nombre { font-size: 40px; }
.action.gros .action-libelle { font-size: 14px; color: var(--texte); font-weight: 600; }
.bloc-secondaire { opacity: .92; }
.bloc-secondaire h2 { color: var(--texte-doux); }

/* ─────────────────────── BANDEAU DE VENTE ─────────────────────── */
.bandeau-vente {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + var(--safe-bas));
  z-index: 40; padding: 16px 18px; border-radius: 18px;
  background: linear-gradient(135deg, #1f9c6b, #0f6f4b);
  color: #fff; box-shadow: 0 18px 40px rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  animation: monte .35s cubic-bezier(.2,.9,.3,1.2);
}
/*
 * ⚠️ LE BANDEAU DOIT POUVOIR DISPARAÎTRE.
 *   La règle ci-dessus pose `display: flex`, qui est PLUS SPÉCIFIQUE que le
 *   `[hidden] { display: none }` du navigateur : sans cette ligne, l'attribut
 *   `hidden` ne masque plus rien, et une **barre verte vide** reste collée
 *   en bas de l'écran en permanence — visible sur les captures Mac.
 *   Mesuré le 01/12/2026 (capture `cockpit-premier-ecran-mac.png`).
 */
.bandeau-vente[hidden] { display: none; }
@keyframes monte { from { transform: translateY(120%); } to { transform: translateY(0); } }
.bandeau-vente strong { font-size: 24px; font-variant-numeric: tabular-nums; }
.bandeau-vente span { font-size: 13px; opacity: .9; text-align: right; }

/* ─────────────────────────── MODE D'EXPÉDITION ─────────────────────────── */
/*
 * ⚠️ LE MODE EST AFFICHÉ EN PERMANENCE, PAS DANS UN MENU.
 *   Tant que les actions réelles sont coupées, l'exploitant doit le voir
 *   sans le chercher : une étiquette simulée prise pour une vraie, c'est
 *   un colis déposé sans lettre de transport.
 */
.bandeau-mode {
  margin: 8px 0 0; padding: 9px 12px; border-radius: 12px;
  font-size: 12.5px; font-weight: 650; line-height: 1.35;
  background: color-mix(in srgb, var(--alerte) 16%, var(--fond-carte));
  border: 1px solid color-mix(in srgb, var(--alerte) 40%, transparent);
  color: var(--alerte);
}

/* ─────────────────────── ALERTE DE VENTE (SON) ─────────────────────── */
/*
 * ⚠️ LE BOUTON « ACTIVER LE SON » EST VISIBLE, PAS UN MENU.
 *   Un son dont on ne sait pas s'il est prêt est un son qu'on ne peut pas
 *   compter. La cible fait 56 px de haut (la cible tactile du cockpit), le
 *   bloc passe sur une ligne au-delà de 720 px et rien ne déborde à 390 px.
 */
.bloc-son {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 16px 0;
}
.bloc-son h2 {
  font-size: 12.5px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--texte-doux); margin: 0 0 10px; font-weight: 700;
}
.actions-son { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 720px) { .actions-son { grid-template-columns: 1fr 1fr; } }
.bouton-son {
  min-height: var(--cible);
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 0 16px; border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--texte) 18%, transparent);
  background: var(--fond-carte-2); color: var(--texte);
  font-size: 15px; font-weight: 650; font-family: inherit; cursor: pointer;
  text-align: center;
}
.bouton-son:active { transform: scale(.985); }
.bouton-son:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
/* L'état ACTIVÉ est visible : le bouton ne change pas de couleur au hasard. */
.bouton-son[aria-pressed="true"] {
  background: color-mix(in srgb, var(--accent) 18%, var(--fond-carte));
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}
.bouton-son:disabled { opacity: .5; cursor: not-allowed; }
.bouton-son-icone { font-size: 18px; line-height: 1; }
.note-son { margin-top: 6px; }

/*
 * ⚠️ LE BOUTON SECONDAIRE EST UN BOUTON, PAS UN TEXTE.
   La cible tactile minimale est respectée : sur un iPhone, un lien de
   12 px est impossible à toucher sans zooming.
*/
.bouton-secondaire {
  min-height: var(--cible);
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 14px; border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--texte) 22%, transparent);
  background: transparent; color: var(--texte);
  font-size: 14px; font-weight: 600; font-family: inherit; cursor: pointer;
}
.bouton-secondaire:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.bouton-secondaire:active { transform: scale(.985); }

/* ─────────────────────────── MESSAGE D'ACTION ─────────────────────────── */
/*
 * ⚠️ LE RÉSULTAT D'UN GESTE RESTE VISIBLE.
 *   Un message qui disparaît au bout de trois secondes est un message que
 *   l'exploitant n'a pas vu — et « l'étiquette a bien été créée » est
 *   précisément une information qu'on relit.
 */
.message-action {
  position: fixed; left: 12px; right: 12px;
  /*
   * ⚠️ LE MESSAGE SE POSE AU-DESSUS DU BANDEAU DE VENTE.
   *   Les deux sont fixes, en bas de l'écran. À la même hauteur, ils se
   *   chevauchent : le message passe sous le bandeau, et le bandeau cache
   *   le résultat d'un geste. Le message est au-dessus, toujours lisible.
   */
  bottom: calc(96px + var(--safe-bas));
  z-index: 46; padding: 14px 16px; border-radius: 16px;
  font-size: 14px; font-weight: 600; line-height: 1.4;
  background: color-mix(in srgb, var(--accent) 20%, var(--fond-carte));
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--texte);
  box-shadow: 0 14px 34px rgba(0,0,0,.32);
}
.message-action.ko {
  background: color-mix(in srgb, var(--critique) 20%, var(--fond-carte));
  border-color: color-mix(in srgb, var(--critique) 50%, transparent);
}
.message-action.alerte {
  background: color-mix(in srgb, var(--alerte) 20%, var(--fond-carte));
  border-color: color-mix(in srgb, var(--alerte) 50%, transparent);
}

/* ─────────────────────────── SOUS-VUES ─────────────────────────── */
.sous-titre {
  font-size: 13px; font-weight: 700; letter-spacing: .01em;
  color: var(--texte); margin: 22px 0 10px;
}
.titre-boutique {
  font-size: 15px; font-weight: 750; margin: 0 0 4px;
  color: var(--accent-2);
}
.bloc-boutique {
  background: var(--fond-carte); border-radius: var(--rayon);
  padding: 14px 16px; margin: 0 0 14px;
  border: 1px solid color-mix(in srgb, var(--texte) 8%, transparent);
}
.bloc-boutique .bloc-boutique { background: transparent; padding: 0; border: none; }
.bloc-boutique .tableau-liste { margin-top: 8px; }

/* ─────────────────────────── ACTIONS DE FICHE ─────────────────────────── */
.actions-actions {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px;
}
.bouton-action {
  min-height: 48px; padding: 0 16px; border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--texte) 18%, transparent);
  background: var(--fond-carte-2); color: var(--texte);
  font-size: 14px; font-weight: 650; font-family: inherit; cursor: pointer;
}
.bouton-action:active { transform: scale(.985); }
.bouton-action:disabled {
  opacity: .45; cursor: not-allowed; text-decoration: line-through;
}
/*
 * ⚠️ LE BOUTON D'ACTION EST UN GESTE, PAS UN LIEN.
 *   Il ne déclenche jamais un paiement, un envoi réel ou une suppression
 *   sans session « admin » : le serveur le refuse, et l'écran montre le
 *   refus au lieu de l'ignorer.
 */

/* ─────────────────────────── FORMULAIRES ─────────────────────────── */
.formulaire {
  display: grid; gap: 8px; margin: 14px 0 20px;
  padding: 14px 16px; border-radius: var(--rayon);
  background: var(--fond-carte-2);
  border: 1px solid color-mix(in srgb, var(--texte) 8%, transparent);
}
.formulaire h4 { margin: 0 0 4px; font-size: 14px; }
.formulaire label {
  font-size: 12.5px; color: var(--texte-doux); font-weight: 600;
}
.formulaire input, .formulaire select, .saisie {
  min-height: 48px; font-size: 16px; font-family: inherit;
  border-radius: 12px; border: 1px solid color-mix(in srgb, var(--texte) 16%, transparent);
  background: var(--fond-carte); color: var(--texte); padding: 0 12px;
  width: 100%;
}
/*
 * ⚠️ 16 PX SUR LES SAISIES.
 *   En dessous, iOS zoome automatiquement à la mise au point, et l'écran
 *   saute : sur un formulaire de coût, ça veut dire saisir un prix dans le
 *   mauvais champ.
 */
.saisie { min-height: 42px; padding: 0 8px; width: auto; max-width: 130px; }

/* ─────────────────────────── RESPONSIVE ─────────────────────────── */
/*
 * ⚠️ LES TABLEURS DE COÛTS DÉBORDENT SUR UN TÉLÉPHONE.
 *   Un tableau à quatre colonnes ne rentre pas dans 390 px : il faut
 *   qu'il soit dans un conteneur qui défile HORIZONTALEMENT, sinon il
 *   pousse la page entière et le bouton « appliquer » sort de l'écran.
 */
.fiche-table { display: block; overflow-x: auto; white-space: nowrap; }
.fiche-table thead, .fiche-table tbody { display: table; width: 100%; }
.fiche-table td, .fiche-table th { white-space: normal; }

