/* ============================================================================
   L'Entrepôt — système visuel, celui du Garde-Manger.
   Palette de marque : turquoise #44BFD6, teal #1A7D92 / #0F5C6E.
   Pensé d'abord pour l'iPhone du quai : cibles de 48 px, texte de 16 px (Safari ne zoome pas),
   barre d'onglets en bas, à portée du pouce.
   ============================================================================ */

:root {
  color-scheme: light;
  --marque: #1A7D92; --marque-fonce: #0F5C6E; --marque-vive: #44BFD6; --marque-pale: #E8F6FA;
  --page: #F3F7F9; --surface: #FFFFFF; --surface-2: #F7FAFB; --surface-3: #EDF3F6;
  --lateral: #0B3A45; --lateral-encre: #D7EDF3; --lateral-encre-2: #8FB9C6;
  --encre: #0F1F24; --encre-2: #4A5F67; --encre-3: #5F737B;
  --bord: #DCE6EA; --bord-2: #C9D7DD;
  --accent: #1A7D92; --accent-encre: #FFFFFF; --accent-doux: #E1F2F6;
  --ok: #0A8A0A; --ok-encre: #0A6B0A; --ok-doux: #E6F6E6;
  --attention: #fab219; --attention-encre: #7A5300; --attention-doux: #FFF6DD;
  --serieux: #ec835a; --serieux-encre: #8A3C1A; --serieux-doux: #FDEDE5;
  --critique: #d03b3b; --critique-encre: #A21F1F; --critique-doux: #FBE7E7;
  /* Les missions humanitaires : le bleu de leur aire au plan. */
  --missions: #2f6fd1; --missions-encre: #1D4F9E; --missions-doux: #E6EEFB;
  --ombre-1: 0 1px 2px rgba(15,31,36,.05), 0 1px 3px rgba(15,31,36,.04);
  --ombre-2: 0 2px 6px rgba(15,31,36,.06), 0 8px 24px rgba(15,31,36,.06);
  --ombre-3: 0 12px 40px rgba(10,69,83,.22);
  --rayon: 12px; --rayon-s: 8px;
  --transition: 160ms cubic-bezier(.2,.7,.3,1);
  --bas: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0D1417; --surface: #141C1F; --surface-2: #192327; --surface-3: #1F2B30;
    --lateral: #0A1518; --encre: #EEF4F6; --encre-2: #A9BBC2; --encre-3: #8A9DA5;
    --bord: #24323A; --bord-2: #2E3F47; --marque-pale: #10262D;
    --accent: #2FAFC8; --accent-encre: #06232A; --accent-doux: #0F2A32;
    --ok-encre: #4CC94C; --ok-doux: #0F2A0F; --attention-encre: #F5C860; --attention-doux: #2D2410;
    --serieux-encre: #F5A585; --serieux-doux: #2E1A12; --critique-encre: #F08080; --critique-doux: #2E1414;
    --missions-encre: #8FB5F5; --missions-doux: #13213A;
    --ombre-1: 0 1px 2px rgba(0,0,0,.4); --ombre-2: 0 2px 8px rgba(0,0,0,.45); --ombre-3: 0 16px 48px rgba(0,0,0,.6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0D1417; --surface: #141C1F; --surface-2: #192327; --surface-3: #1F2B30;
  --lateral: #0A1518; --encre: #EEF4F6; --encre-2: #A9BBC2; --encre-3: #8A9DA5;
  --bord: #24323A; --bord-2: #2E3F47; --marque-pale: #10262D;
  --accent: #2FAFC8; --accent-encre: #06232A; --accent-doux: #0F2A32;
  --ok-encre: #4CC94C; --ok-doux: #0F2A0F; --attention-encre: #F5C860; --attention-doux: #2D2410;
  --serieux-encre: #F5A585; --serieux-doux: #2E1A12; --critique-encre: #F08080; --critique-doux: #2E1414;
  --missions-encre: #8FB5F5; --missions-doux: #13213A;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--page); color: var(--encre);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0; line-height: 1.2; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.1rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .6rem; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
.ico { width: 20px; height: 20px; flex: none; }
.discret { color: var(--encre-3); font-size: .88rem; }
.chiffre { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .02em; }
.cache { display: none !important; }

/* ---------------------------------------------------------------- coquille */

.coquille { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.lateral { background: var(--lateral); color: var(--lateral-encre); position: sticky; top: 0; height: 100vh;
           display: flex; flex-direction: column; padding: 1rem .8rem; gap: .2rem;
           /* Un long menu sur un petit écran : il défile, pour que son pied (thème, sortie) reste atteignable. */
           overflow-y: auto; overscroll-behavior: contain; }
.lateral .marque { display: flex; gap: .65rem; align-items: center; padding: .3rem .45rem 1rem; }
.lateral .marque img { width: 36px; height: 36px; border-radius: 9px; background: #fff; padding: 3px; }
.lateral .marque b { color: #fff; display: block; line-height: 1.15; }
.lateral .marque span { font-size: .75rem; color: var(--lateral-encre-2); }
.lien-nav { display: flex; align-items: center; gap: .65rem; padding: .6rem .65rem; border-radius: 9px; border: 0;
            background: none; color: var(--lateral-encre); cursor: pointer; text-align: left; width: 100%; font-size: .95rem; }
.lien-nav:hover { background: rgba(255,255,255,.07); }
.lien-nav[aria-current="page"] { background: rgba(68,191,214,.16); color: #fff; box-shadow: inset 3px 0 0 var(--marque-vive); }
/* Les groupes du menu d'un rôle (« Au quai », « Suivi », « Gestion ») ; un groupe sans titre, un trait. */
.titre-nav { font-size: .7rem; font-weight: 650; text-transform: uppercase; letter-spacing: .08em; color: var(--lateral-encre-2); padding: .85rem .65rem .2rem; }
.separe-nav { border-top: 1px solid rgba(255,255,255,.08); margin: .55rem .45rem; }
.titre-plus { font-size: .75rem; text-transform: uppercase; letter-spacing: .07em; color: var(--encre-3); margin: 1.1rem 0 .15rem; }
.titre-plus:first-child { margin-top: 0; }
.separe-plus { border-top: 1px solid var(--bord); margin-top: .7rem; }
.lien-nav .compte { margin-left: auto; background: var(--critique); color: #fff; border-radius: 99px; font-size: .72rem; padding: 0 .45rem; font-weight: 700; }
.lateral .pied { margin-top: auto; border-top: 1px solid rgba(255,255,255,.08); padding-top: .8rem; font-size: .85rem; }
.lateral .pied b { color: #fff; display: block; }
.lateral .pied button { margin-top: .5rem; }
/* Les sélecteurs du thème et des mesures dans le menu, toujours sombre : leurs propres couleurs. */
.lateral .choix-theme, .lateral .choix-mesures { background: rgba(255,255,255,.08); }
.lateral .choix-theme button, .lateral .choix-mesures button { color: var(--lateral-encre-2); min-height: 32px; padding: .3rem .4rem; margin: 0; font-size: .8rem; }
.lateral .choix-theme button[aria-pressed="true"], .lateral .choix-mesures button[aria-pressed="true"] { background: rgba(255,255,255,.16); color: #fff; box-shadow: none; }

.principal { min-width: 0; display: flex; flex-direction: column; }
.barre { display: flex; align-items: center; gap: .75rem; padding: .8rem 1.4rem; border-bottom: 1px solid var(--bord); background: var(--page); }
.barre h1 { font-size: 1.2rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* La signature de la barre, comme au Garde-Manger ; sur un écran étroit, le titre passe avant elle. */
.signature { flex: none; display: flex; gap: .4rem; align-items: baseline; white-space: nowrap; font-size: .7rem; color: var(--encre-2); letter-spacing: .01em; }
.signature .sig-version { font-variant-numeric: tabular-nums; font-weight: 650; }
@media (max-width: 860px) { .signature { display: none; } }
.contenu { padding: 1.2rem 1.4rem 2rem; max-width: 1200px; width: 100%; }
.bandeau-bac { background: #e8590c; color: #fff; text-align: center; font-weight: 700; font-size: .8rem; padding: .25rem; letter-spacing: .04em; }
.onglets-bas { display: none; }

@media (max-width: 860px) {
  .coquille { grid-template-columns: 1fr; }
  .lateral { display: none; }
  .barre { position: sticky; top: 0; z-index: 20; padding: .7rem 1rem; padding-top: max(.7rem, env(safe-area-inset-top)); }
  .contenu { padding: 1rem 1rem calc(6rem + var(--bas)); }
  .onglets-bas {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
    background: var(--surface); border-top: 1px solid var(--bord); padding-bottom: var(--bas); box-shadow: 0 -4px 16px rgba(0,0,0,.05);
  }
  .onglets-bas button { border: 0; background: none; padding: .5rem 0 .45rem; display: flex; flex-direction: column; align-items: center;
                        gap: .1rem; font-size: .7rem; color: var(--encre-3); cursor: pointer; min-height: 56px; }
  .onglets-bas button[aria-current="page"] { color: var(--accent); font-weight: 650; }
  .onglets-bas .ico { width: 24px; height: 24px; }
  .onglets-bas .scan { color: var(--accent); }
  .onglets-bas .scan .rond { color: var(--accent-encre); }
  .onglets-bas .scan .rond { background: var(--accent); border-radius: 99px; width: 52px; height: 52px; margin-top: -18px;
                             display: grid; place-items: center; box-shadow: var(--ombre-3); }
  .onglets-bas .scan .ico { width: 28px; height: 28px; }
}

/* ---------------------------------------------------------------- blocs */

.grille { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); align-items: start; }
.carte { background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); box-shadow: var(--ombre-1); padding: 1rem 1.1rem; }
.carte > h2 { display: flex; align-items: center; gap: .5rem; margin-bottom: .7rem; }
.carte > h2 .ico { color: var(--accent); }
.carte.critique { border-color: var(--critique); box-shadow: inset 4px 0 0 var(--critique), var(--ombre-1); }
.carte.attention { border-color: var(--attention); box-shadow: inset 4px 0 0 var(--attention), var(--ombre-1); }
.carte.ok { box-shadow: inset 4px 0 0 var(--ok), var(--ombre-1); }
.pile > * + * { margin-top: 1rem; }
.rangee { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.rangee.fin { justify-content: flex-end; }
.espace { flex: 1; }
.tuiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; }
.tuile { background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); padding: .8rem .9rem; }
.tuile .valeur { font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tuile .libelle { font-size: .8rem; color: var(--encre-3); }
.vide { color: var(--encre-3); text-align: center; padding: 1.2rem .5rem; font-size: .92rem; }

.pastille { display: inline-flex; align-items: center; gap: .3rem; border-radius: 99px; padding: .08rem .55rem; font-size: .76rem;
            font-weight: 650; white-space: nowrap; background: var(--surface-3); color: var(--encre-2); }
.pastille.ok { background: var(--ok-doux); color: var(--ok-encre); }
.pastille.attention { background: var(--attention-doux); color: var(--attention-encre); }
.pastille.serieux { background: var(--serieux-doux); color: var(--serieux-encre); }
.pastille.critique { background: var(--critique-doux); color: var(--critique-encre); }
.pastille.missions { background: var(--missions-doux); color: var(--missions-encre); }
/* Une carte des missions : le liseré bleu de leur aire. */
.carte.missions { box-shadow: inset 4px 0 0 var(--missions), var(--ombre-1); }

/* Une ligne qu'on touche : un lot, une denrée, une sortie. */
.liste { list-style: none; margin: 0; padding: 0; }
.liste > li { border-top: 1px solid var(--bord); }
.liste > li:first-child { border-top: 0; }
.item { display: flex; gap: .75rem; align-items: center; padding: .7rem .2rem; width: 100%; background: none; border: 0; text-align: left; cursor: pointer; min-height: 52px; }
.item:hover { background: var(--surface-2); }
.item .corps { flex: 1; min-width: 0; }
.item .titre { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.item .sous { font-size: .84rem; color: var(--encre-3); }
.item .droite { text-align: right; flex: none; }
.item.pris { opacity: .55; }
.item.pris .titre { text-decoration: line-through; }
.coche { width: 28px; height: 28px; border-radius: 99px; border: 2px solid var(--bord-2); display: grid; place-items: center; flex: none; }
.pris .coche { background: var(--ok); border-color: var(--ok); color: #fff; }

/* ---------------------------------------------------------------- formulaires */

.bouton { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 44px; padding: .55rem 1rem;
          border-radius: 10px; border: 1px solid var(--bord-2); background: var(--surface); cursor: pointer; font-weight: 600;
          transition: background var(--transition), transform var(--transition); text-decoration: none; color: var(--encre); }
.bouton:hover { background: var(--surface-2); }
.bouton:active { transform: scale(.98); }
.bouton.primaire { background: var(--accent); border-color: var(--accent); color: var(--accent-encre); }
.bouton.primaire:hover { filter: brightness(1.06); }
.bouton.danger { background: var(--critique); border-color: var(--critique); color: #fff; }
.bouton.discret { border-color: transparent; background: none; color: var(--accent); }
.bouton.grand { min-height: 56px; font-size: 1.05rem; width: 100%; border-radius: 14px; }
.bouton[disabled] { opacity: .5; pointer-events: none; }
.champ { display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.champ > span { font-size: .82rem; font-weight: 600; color: var(--encre-2); }
.champ input, .champ select, .champ textarea {
  border: 1px solid var(--bord-2); border-radius: 10px; padding: .6rem .7rem; background: var(--surface); min-height: 46px; width: 100%;
  font-size: 16px;
}
.champ input:focus, .champ select:focus, .champ textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-doux); }
.champ.erreur input, .champ.erreur select, .champ.erreur textarea { border-color: var(--critique); }
/* L'attribut hidden l'emporte sur un display posé par une règle (la bande « suite » est en flex). */
[hidden] { display: none !important; }
.champs { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.case { display: flex; gap: .55rem; align-items: flex-start; font-size: .92rem; }
.case input { width: 22px; height: 22px; margin: .1rem 0 0; flex: none; accent-color: var(--accent); }
.segments { display: flex; gap: .3rem; background: var(--surface-3); padding: .25rem; border-radius: 12px; overflow-x: auto; }
.segments button { flex: 1; border: 0; background: none; padding: .5rem .7rem; border-radius: 9px; cursor: pointer; font-weight: 600;
                   color: var(--encre-2); white-space: nowrap; min-height: 40px; }
.segments button[aria-pressed="true"] { background: var(--surface); color: var(--encre); box-shadow: var(--ombre-1); }
.quantite { display: flex; align-items: center; gap: .3rem; }
.quantite input { width: 5.5rem; text-align: center; border: 1px solid var(--bord-2); border-radius: 10px; min-height: 44px; font-size: 16px; background: var(--surface); }
.quantite button { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--bord-2); background: var(--surface); font-size: 1.3rem; cursor: pointer; }

table.tableau { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tableau th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--encre-3); font-weight: 650;
              padding: .45rem .5rem; border-bottom: 1px solid var(--bord); }
.tableau td { padding: .5rem; border-bottom: 1px solid var(--bord); vertical-align: top; }
.tableau td.nombre, .tableau th.nombre { text-align: right; font-variant-numeric: tabular-nums; }
.defile { overflow-x: auto; }

/* ---------------------------------------------------------------- messages et modales */

.messages { position: fixed; z-index: 90; left: 50%; transform: translateX(-50%); bottom: calc(5.5rem + var(--bas));
            display: flex; flex-direction: column; gap: .5rem; width: min(520px, calc(100vw - 2rem)); pointer-events: none; }
@media (min-width: 861px) { .messages { bottom: 1.5rem; } }
.message { background: var(--encre); color: var(--page); border-radius: 12px; padding: .75rem 1rem; box-shadow: var(--ombre-3);
           font-size: .95rem; pointer-events: auto; animation: monte .2s ease both; }
.message.erreur { background: var(--critique); color: #fff; }
.message.ok { background: var(--ok); color: #fff; }
.message.attention { background: var(--attention); color: #3a2800; }
@keyframes monte { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.voile { position: fixed; inset: 0; z-index: 60; background: rgba(8,20,24,.5); display: grid; place-items: end center; }
@media (min-width: 861px) { .voile { place-items: center; } }
.modale { background: var(--surface); width: min(560px, 100vw); max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0;
          padding: 1.1rem 1.1rem calc(1.1rem + var(--bas)); box-shadow: var(--ombre-3); }
@media (min-width: 861px) { .modale { border-radius: 16px; } }
.modale h2 { margin-bottom: .8rem; }

/* ---------------------------------------------------------------- le scanner */

.scanner { position: fixed; inset: 0; z-index: 80; background: #000; color: #fff; display: flex; flex-direction: column; }
.scanner .tete { display: flex; align-items: center; gap: .6rem; padding: .7rem .9rem; padding-top: max(.7rem, env(safe-area-inset-top)); }
.scanner .tete h2 { flex: 1; color: #fff; font-size: 1.05rem; }
.scanner .tete button { background: rgba(255,255,255,.15); color: #fff; border: 0; border-radius: 99px; min-width: 44px; height: 44px; padding: 0 .9rem; font-weight: 600; cursor: pointer; }
.scanner .vue { position: relative; flex: 1; overflow: hidden; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scanner .cadre { position: absolute; left: 8%; right: 8%; top: 32%; height: 26%; border-radius: 16px;
                  box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); border: 3px solid rgba(255,255,255,.85); transition: border-color .15s; }
.scanner .cadre.arme { border-color: var(--marque-vive); border-width: 4px; }
.scanner .cadre.ok { border-color: #3ddc52; } .scanner .cadre.attention { border-color: #ffc53d; } .scanner .cadre.erreur { border-color: #ff5a5a; }
.scanner .aide { position: absolute; left: 0; right: 0; top: calc(58% + 12px); text-align: center; font-size: .9rem; color: rgba(255,255,255,.85); padding: 0 1rem; }
.scanner .resultat { min-height: 4.2rem; padding: .7rem 1rem; font-size: 1rem; background: #111; border-top: 1px solid #222;
                     display: flex; align-items: center; gap: .6rem; }
/* Des fonds francs, lisibles à bout de bras : on ne devrait pas avoir à lire la phrase. */
.scanner .resultat.ok { background: #1e9e45; color: #fff; } .scanner .resultat.attention { background: #ffc21a; color: #1a1300; }
.scanner .resultat.erreur { background: #d62828; color: #fff; }
.scanner .resultat .marque { font-size: 2.2rem; font-weight: 900; line-height: 1; min-width: 2.2rem; text-align: center; }
.scanner .resultat .mot { font-weight: 900; letter-spacing: .04em; font-size: 1.05rem; }
.scanner .resultat .texte { flex: 1; min-width: 0; }
/* La suite : la prochaine ligne à prendre, ce qui reste à compter, le lot qui attend sa place. */
.scanner .suite { display: flex; align-items: center; gap: .6rem; padding: .55rem 1rem; background: #1d2a2f; color: #e8f6fa; font-size: .95rem; border-top: 1px solid #2c3d44; }
.scanner .suite span { flex: 1; min-width: 0; }
.scanner .suite button { background: rgba(255,255,255,.16); color: #fff; border: 0; border-radius: 99px; min-height: 40px; padding: 0 .9rem; font-weight: 700; cursor: pointer; }
/* Le pavé du comptage : dans le scanner, caméra ouverte ; pas de clavier de l'iPhone à faire surgir. */
.scanner .pave { background: #111; padding: .5rem .9rem .3rem; border-top: 1px solid #222; }
.scanner .pave .libelle { font-size: .9rem; color: #cfe3e9; }
.scanner .pave .valeur { font-size: 2rem; font-weight: 800; text-align: right; padding: .1rem .3rem; font-variant-numeric: tabular-nums; }
.scanner .pave .touches { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; }
.scanner .pave button { min-height: 50px; border: 0; border-radius: 10px; background: #262626; color: #fff; font-size: 1.35rem; font-weight: 700;
                        touch-action: manipulation; cursor: pointer; }
.scanner .pave .actions { display: grid; grid-template-columns: 1fr 2fr; gap: .4rem; margin-top: .4rem; }
.scanner .pave .noter { background: var(--marque-vive); color: #002; }
.scanner .pave .annuler { background: #3a3a3a; font-size: 1rem; }
.scanner.compte .barre-declencheur, .scanner.compte .saisie { display: none; }
.scanner.compte .pave { padding-bottom: calc(.5rem + var(--bas)); }
@media (max-height: 700px) { .scanner .pave button { min-height: 42px; } .scanner .pave .valeur { font-size: 1.6rem; } }
.scanner .barre-declencheur { display: flex; justify-content: center; padding: .7rem 0 .4rem; background: #111; }
.declencheur { border: 0; background: none; color: #fff; display: flex; flex-direction: column; align-items: center; gap: .3rem;
               cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none; font-weight: 700; }
.declencheur .rond-declencheur { width: 84px; height: 84px; border-radius: 99px; background: var(--marque-vive); color: #002;
                                  display: grid; place-items: center; box-shadow: 0 0 0 5px rgba(255,255,255,.25); transition: transform .12s; }
.declencheur .rond-declencheur .ico { width: 38px; height: 38px; }
.declencheur:active .rond-declencheur { transform: scale(.94); }
.declencheur.arme .rond-declencheur { background: #fff; animation: pulse .6s ease-in-out infinite alternate; }
.declencheur[disabled] { opacity: .35; }
@keyframes pulse { from { box-shadow: 0 0 0 5px rgba(68,191,214,.4); } to { box-shadow: 0 0 0 14px rgba(68,191,214,.1); } }
.scanner .saisie { display: flex; gap: .5rem; padding: .6rem .9rem calc(.6rem + var(--bas)); background: #111; }
.scanner .saisie input { flex: 1; border-radius: 10px; border: 1px solid #333; background: #1c1c1c; color: #fff; padding: .6rem .7rem; font-size: 16px; min-height: 46px; }
.scanner .saisie button { border-radius: 10px; border: 0; background: var(--marque-vive); color: #002; font-weight: 700; padding: 0 1rem; min-height: 46px; }
.scanner .panne { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 2rem; color: #ddd; }
.scanner .panne a { color: var(--marque-vive); }
/* Une erreur d'enregistrement : elle reste en tête du formulaire, la ligne en faute bordée de rouge. */
.faute-formulaire { display: flex; align-items: flex-start; gap: .6rem; background: var(--critique-doux); color: var(--critique-encre);
                    border: 1px solid var(--critique); border-radius: var(--rayon); padding: .7rem .9rem; font-weight: 600; }
.faute-formulaire > span { flex: 1; }
.faute-formulaire .bouton { min-height: 0; padding: .1rem; color: inherit; }
.en-faute { outline: 3px solid var(--critique); outline-offset: 2px; border-radius: var(--rayon); flex-wrap: wrap !important; }
.faute-ligne { flex-basis: 100%; margin: .5rem 0 0; color: var(--critique-encre); font-weight: 600; font-size: .92rem; }
.eclair { position: fixed; inset: 0; z-index: 85; pointer-events: none; animation: eclair .35s ease-out both; }
@keyframes eclair { from { opacity: .45; } to { opacity: 0; } }

/* ---------------------------------------------------------------- connexion */

.accueil-connexion { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: linear-gradient(160deg, var(--lateral), var(--marque-fonce)); }
.accueil-connexion .carte { width: min(400px, 100%); padding: 1.6rem; }
.accueil-connexion img { width: 56px; height: 56px; border-radius: 14px; background: #fff; padding: 4px; }

/* ---------------------------------------------------------------- impression */

.etiquettes { display: flex; flex-wrap: wrap; gap: 6mm; }
.etiquette { width: 62mm; height: 29mm; border: 1px dashed var(--bord-2); border-radius: 2mm; padding: 1.2mm 2mm; background: #fff; color: #000;
             display: flex; flex-direction: column; gap: .3mm; overflow: hidden; font-family: system-ui, sans-serif; }
.etiquette .nom { font-weight: 800; font-size: 8.5pt; line-height: 1.05; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: none; }
.etiquette .date { font-size: 12pt; font-weight: 800; line-height: 1.05; flex: none; }
.etiquette .date small { font-size: 6.5pt; font-weight: 700; display: block; letter-spacing: .03em; }
.etiquette .code { margin-top: auto; display: flex; align-items: flex-end; flex: none; }
.etiquette .code svg { height: 10.5mm; width: auto; max-width: 58mm; display: block; flex: none; }
.etiquette .infos { font-size: 6.5pt; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: none; }
.etiquette .infos b { font-size: 7.5pt; font-family: ui-monospace, Menlo, monospace; }
.etiquette.lieu .code svg { height: 12mm; }
/* « MISSIONS — ne pas distribuer » : en blanc sur noir, lisible sans lunettes, pour qu'un sac de
   vêtements ne finisse pas au dépannage. */
.etiquette .bandeau { flex: none; background: #000; color: #fff; font-weight: 900; font-size: 7pt; line-height: 1.25; text-transform: uppercase;
                      letter-spacing: .04em; text-align: center; border-radius: .6mm; white-space: nowrap; overflow: hidden; }
.etiquette.lieu .nom { font-size: 16pt; text-transform: none; }
.etiquette.essai { display: flex; flex-direction: column; gap: 1.5mm; }
.etiquette.essai .nom { font-size: 7.5pt; text-transform: none; flex: none; }
.etiquette.essai .code { flex: 1; min-height: 0; align-items: center; }
.etiquette.essai .code svg { height: 100%; max-height: 20mm; max-width: 56mm; }
.bon { background: #fff; color: #000; padding: 1.5rem; border: 1px solid var(--bord); border-radius: var(--rayon); max-width: 800px; }
.bon table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
.bon td, .bon th { border-bottom: 1px solid #ccc; padding: .35rem; text-align: left; }
.bon .destinataire { display: grid; grid-template-columns: max-content 1fr; gap: .15rem 1rem; margin: .6rem 0; }
.bon .destinataire dt { font-weight: 700; } .bon .destinataire dd { margin: 0; }
.bon .signatures { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; margin-top: 3rem; }
.bon .signatures div { border-top: 1px solid #000; padding-top: .3rem; font-size: .85rem; }

@media print {
  body { background: #fff; }
  .lateral, .barre, .onglets-bas, .messages, .bandeau-bac, .pas-imprime { display: none !important; }
  .coquille { display: block; }
  .contenu { padding: 0; max-width: none; }
  .bon { border: 0; padding: 0; }
  body, .principal, .contenu, .pile { background: #fff !important; }
  /* Rouleau : une étiquette par page, au format de l'étiquette, sans marges. */
  .etiquettes.rouleau { display: block; }
  .etiquettes.rouleau .etiquette { border: 0; border-radius: 0; page-break-after: always; break-after: page; margin: 0; page: etiquette; }
  /* Feuille : toutes à la suite sur du papier ordinaire, trois de front, avec des traits de coupe. */
  .etiquettes.feuille { display: grid; grid-template-columns: repeat(3, 62mm); gap: 3mm; justify-content: center; }
  .etiquettes.feuille .etiquette { border: .2mm dashed #888; border-radius: 0; break-inside: avoid; page-break-inside: avoid; }
  /* Palette : une grande étiquette par page Lettre. */
  .etiquettes.palette { display: block; }
  .etiquettes.palette .etiquette-palette { page: palette; width: auto; height: 250mm; border: .6mm solid #000; border-radius: 0; margin: 0;
                                           page-break-after: always; break-after: page; box-shadow: none; }
  /* Pas de page blanche après la dernière. */
  .etiquettes.palette .etiquette-palette:last-child, .etiquettes.rouleau .etiquette:last-child { page-break-after: auto; break-after: auto; }
}
@page etiquette { size: 62mm 29mm; margin: 0; }
@page palette { size: letter portrait; margin: 12mm; }
@page { margin: 10mm; }

/* ---------------------------------------------------------------- l'iPhone comme caméra du Mac */

.telecommande { background: var(--page); color: var(--encre); }
.telecommande .tete { background: var(--lateral); }
.telecommande .corps-telecommande { flex: 1; display: flex; gap: 2rem; padding: 1.5rem; overflow: auto; align-items: flex-start; }
.appairage { flex: none; width: 300px; text-align: center; }
.appairage .qr { width: 260px; height: 260px; background: #fff; padding: 12px; border-radius: 14px; }
.appairage.replie .qr { width: 110px; height: 110px; padding: 6px; opacity: .6; }
.appairage p { font-size: .9rem; color: var(--encre-2); }
.appairage .petit { font-size: .8rem; color: var(--encre-3); }
.telecommande .colonne { flex: 1; min-width: 0; }
.telecommande .consigne { color: var(--encre-3); }
.fil { list-style: none; margin: 0; padding: 0; }
.fil li { display: flex; gap: 1rem; padding: .6rem .8rem; border-radius: 10px; margin-bottom: .4rem; background: var(--surface); border-left: 4px solid var(--ok); }
.fil li.attention { border-left-color: var(--attention); }
.fil li.erreur { border-left-color: var(--critique); }
.fil li .mono { flex: none; color: var(--encre-3); }
.telecommande .resultat { background: var(--surface-2); color: var(--encre); }
.telecommande .resultat.ok { background: var(--ok-doux); color: var(--ok-encre); }
.telecommande .resultat.attention { background: var(--attention-doux); color: var(--attention-encre); }
.telecommande .resultat.erreur { background: var(--critique-doux); color: var(--critique-encre); }
.telecommande .saisie { background: var(--surface-2); }
.telecommande .saisie input { background: var(--surface); color: var(--encre); border-color: var(--bord-2); }

/* ---------------------------------------------------------------- l'étiquette de palette */

.etiquettes.palette { display: flex; flex-direction: column; gap: 1.5rem; align-items: center; }
.etiquette-palette { width: min(190mm, 100%); aspect-ratio: 190 / 250; background: #fff; color: #000; border: 2px solid #000; border-radius: 4mm;
                     padding: 8mm 10mm; display: flex; flex-direction: column; gap: 5mm; font-family: system-ui, -apple-system, sans-serif;
                     box-shadow: var(--ombre-2); }
.etiquette-palette .tete-palette { display: flex; justify-content: space-between; font-size: 12pt; font-weight: 700; border-bottom: .6mm solid #000; padding-bottom: 2mm; }
.etiquette-palette .denree-palette { font-size: 40pt; font-weight: 900; line-height: 1.02; text-transform: uppercase; letter-spacing: -.01em; }
.etiquette-palette .denree-palette small { display: block; font-size: 16pt; font-weight: 600; text-transform: none; margin-top: 1mm; }
.etiquette-palette .quantite-palette { display: flex; flex-direction: column; border: .8mm solid #000; border-radius: 3mm; padding: 3mm 5mm; }
.etiquette-palette .quantite-palette b { font-size: 60pt; font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
.etiquette-palette .quantite-palette span { font-size: 22pt; font-weight: 700; }
.etiquette-palette .quantite-palette small { font-size: 13pt; }
.etiquette-palette .date-palette { font-size: 44pt; font-weight: 900; line-height: 1.05; }
.etiquette-palette .date-palette small { display: block; font-size: 16pt; font-weight: 800; letter-spacing: .04em; }
.etiquette-palette .code-palette { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 1mm; }
.etiquette-palette .code-palette svg { width: 150mm; max-width: 100%; height: 28mm; }
.etiquette-palette .code-palette .mono { font-size: 20pt; font-weight: 800; }
.etiquette-palette .bandeau-palette { background: #000; color: #fff; font-size: 26pt; font-weight: 900; text-transform: uppercase; text-align: center;
                                      letter-spacing: .03em; padding: 2mm 3mm; border-radius: 2mm; line-height: 1.1; }
.etiquette-palette .pied-palette { font-size: 11pt; text-align: center; border-top: .3mm solid #000; padding-top: 2mm; }
/* Une palette de plusieurs produits : ce qu'elle porte, en tableau ; le titre et la date, moins grands. */
.etiquette-palette.mixte .denree-palette { font-size: 34pt; }
.etiquette-palette.mixte .date-palette { font-size: 26pt; }
.etiquette-palette .contenu-etiquette { width: 100%; border-collapse: collapse; font-size: 14pt; }
.etiquette-palette .contenu-etiquette td { border-bottom: .3mm solid #000; padding: 1.6mm 2mm 1.6mm 0; vertical-align: baseline; }
.etiquette-palette .contenu-etiquette td b { font-size: 16pt; }
.etiquette-palette .contenu-etiquette td.nombre { text-align: right; font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
.etiquette-palette .contenu-etiquette td.mono { font-size: 10pt; white-space: nowrap; }

/* ---------------------------------------------------------------- ranger et sections */

.a-ranger { display: flex; flex-direction: column; gap: .7rem; }
.a-ranger.ok { box-shadow: inset 4px 0 0 var(--ok), var(--ombre-1); }
/* Une palette à ranger : ce qu'elle porte, en petite liste ; ses lignes, sous leur palette, à la réception. */
.contenu-palette { list-style: none; margin: 0; padding: 0 0 0 .8rem; border-left: 3px solid var(--bord-2); display: flex; flex-direction: column; gap: .15rem; font-size: .95rem; }
.titre-palette { margin: .6rem 0 0; font-size: 1.05rem; }
/* La liste du manutentionnaire : la section assignée en gros, à droite ; une case à cocher sur papier. */
.ligne-manut { display: flex; flex-direction: column; gap: .5rem; break-inside: avoid; page-break-inside: avoid; }
.ligne-manut.faite { box-shadow: inset 4px 0 0 var(--ok), var(--ombre-1); opacity: .75; }
.tete-manut { display: flex; gap: .8rem; align-items: flex-start; }
.corps-manut { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .3rem; }
.liste-manutention .titre-imprime { display: none; }
.case-manut { display: none; flex: none; width: 7mm; height: 7mm; border: .5mm solid currentColor; border-radius: 1mm; margin-top: .1rem; }
.section-manut { flex: none; display: flex; flex-direction: column; align-items: flex-end; text-align: right; }
.section-manut small { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--encre-3); }
.section-manut .mono { font-size: 2rem; font-weight: 800; line-height: 1.05; white-space: nowrap; }
.section-manut .sans-place { color: var(--attention-encre); font-weight: 700; max-width: 9rem; }
@media print {
  .liste-manutention .ligne-manut { border: .3mm solid #000; box-shadow: none; opacity: 1; color: #000; background: #fff; }
  .liste-manutention .case-manut, .liste-manutention .titre-imprime { display: block; }
  .liste-manutention .titre-imprime { font-size: 18pt; margin: 0 0 2mm; color: #000; }
  .liste-manutention .discret, .liste-manutention .section-manut small { color: #333; }
}
.suggestion { display: flex; align-items: center; gap: .8rem; background: var(--accent-doux); border-radius: 12px; padding: .7rem .9rem; }
.suggestion .fleche { font-size: 1.6rem; color: var(--accent); font-weight: 800; }
.code-section { font-size: 1.6rem; font-weight: 800; letter-spacing: .02em; white-space: nowrap; flex: none; }
.plan { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .6rem; }
.section-tuile { background: var(--surface); border: 1px solid var(--bord); border-radius: 12px; padding: .7rem; text-align: left; cursor: pointer;
                 display: flex; flex-direction: column; gap: .25rem; min-height: 96px; }
.section-tuile.ok { box-shadow: inset 0 -4px 0 var(--ok); }
.section-tuile.attention { box-shadow: inset 0 -4px 0 var(--attention); }
.section-tuile.critique { box-shadow: inset 0 -4px 0 var(--critique); background: var(--critique-doux); }
.section-tuile .code-section { font-size: 1.3rem; }
.section-tuile .petit { font-size: .8rem; color: var(--encre-2); }
.jauge { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.jauge span { display: block; height: 100%; background: var(--accent); }

/* « À demander » s'imprime seul : la liste du stock reste à l'écran. */
@media print { body.imprimer-demande .liste-stock { display: none; } }

/* ---------------------------------------------------------------- le plan en 3D */

.plan-3d { display: flex; flex-direction: column; gap: .6rem; }
.barre-3d { align-items: center; }
.corps-3d { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: .8rem; align-items: start; }
@media (max-width: 900px) { .corps-3d { grid-template-columns: 1fr; } .scene-3d { height: min(55vh, 640px); height: min(55svh, 640px); } }
.scene-3d { position: relative; height: min(68vh, 640px); min-height: 320px; border-radius: var(--rayon); overflow: hidden;
            border: 1px solid var(--bord); background: var(--page); }
/* Le doigt pilote la vue : la page ne défile ni ne zoome sous lui. */
.toile-3d { display: block; width: 100%; height: 100%; touch-action: none; outline: none; cursor: grab; -webkit-user-select: none; user-select: none; }
.toile-3d:active { cursor: grabbing; }
.toile-3d.a-poser { cursor: crosshair; }
.toile-3d:focus-visible { box-shadow: inset 0 0 0 3px var(--marque-vive); }
.panneau-3d { min-width: 0; }
.scene-3d.sans-3d { height: auto; min-height: 0; display: grid; place-items: center; padding: 1rem; }
.outils-3d { align-items: center; gap: .5rem; }
/* Le plan 3D en plein écran : il couvre la fenêtre (sous les fenêtres de saisie et les messages). */
.plan-3d.plein-ecran-3d { position: fixed; inset: 0; z-index: 50; background: var(--page); overflow: auto; overscroll-behavior: contain;
                          padding: max(.8rem, env(safe-area-inset-top)) max(.8rem, env(safe-area-inset-right)) max(.8rem, env(safe-area-inset-bottom)) max(.8rem, env(safe-area-inset-left)); }
.plan-3d.plein-ecran-3d .scene-3d { height: calc(100vh - 8.5rem); height: calc(100dvh - 8.5rem); max-height: none; min-height: 320px; }
@media (max-width: 900px) { .plan-3d.plein-ecran-3d .scene-3d { height: calc(100svh - 10rem); } }
.page-plein-ecran-3d, .page-plein-ecran-3d body { overflow: hidden; }
.recherche-3d { flex: 1 1 220px; min-width: min(18rem, 100%); border: 1px solid var(--bord-2); border-radius: 99px; padding: .55rem 1rem; font-size: 16px;
                background: var(--surface); color: var(--encre); min-height: 42px; }
.choix-3d { flex: 0 1 15rem; min-width: 0; max-width: 100%; border: 1px solid var(--bord-2); border-radius: 99px; padding: .55rem .9rem; font-size: 16px;
             background: var(--surface); color: var(--encre); min-height: 42px; }
.choix-3d:focus { outline: none; border-color: var(--marque-vive); box-shadow: 0 0 0 3px var(--accent-doux); }
.recherche-3d:focus { outline: none; border-color: var(--marque-vive); box-shadow: 0 0 0 3px var(--accent-doux); }
.modes-3d { flex: 0 1 auto; }
.modes-3d button { min-height: 38px; padding: .35rem .7rem; }
.resultat-3d:empty { display: none; }
.lien-3d { border: 0; background: none; color: var(--accent); font-weight: 700; cursor: pointer; padding: 0; text-decoration: underline; }
/* L'infobulle du survol (Mac) : au-dessus de la toile, sans intercepter la souris. */
.infobulle-3d { position: absolute; z-index: 2; pointer-events: none; display: grid; gap: .1rem; min-width: 150px; max-width: 220px;
                background: var(--surface); color: var(--encre); border: 1px solid var(--bord); border-radius: 10px; padding: .45rem .65rem;
                box-shadow: var(--ombre-2); font-size: .85rem; }
.infobulle-3d b { font-size: 1rem; }
.infobulle-3d small { color: var(--encre-2); }
.etat-3d { font-size: .85rem; }
.legende-3d { display: flex; flex-wrap: wrap; gap: .8rem; font-size: .85rem; color: var(--encre-2); }
.pastille-3d { display: inline-block; width: .8rem; height: .8rem; border-radius: 3px; vertical-align: -1px; margin-right: .3rem; background: #9fb4bd; }
/* Le ton par un attribut : « vide », « ok »… sont déjà des classes de l'application. */
.pastille-3d[data-ton="ok"] { background: #2e9e4f; } .pastille-3d[data-ton="attention"] { background: #e6a100; }
.pastille-3d[data-ton="critique"] { background: #d03b3b; } .pastille-3d[data-ton="marque"] { background: #1A7D92; }

/* L'impression sort toujours en clair, même depuis un écran sombre : pas de texte clair sur papier
   blanc. (html:root… l'emporte sur les règles du thème sombre.) */
@media print {
  html:root:not([data-imprime]), html:root[data-theme="dark"] {
    color-scheme: light;
    --page: #FFFFFF; --surface: #FFFFFF; --surface-2: #F7FAFB; --surface-3: #EDF3F6; --marque-pale: #E8F6FA;
    --encre: #0F1F24; --encre-2: #4A5F67; --encre-3: #5F737B; --bord: #DCE6EA; --bord-2: #C9D7DD;
    --accent: #1A7D92; --accent-encre: #FFFFFF; --accent-doux: #E1F2F6;
    --ok-encre: #0A6B0A; --ok-doux: #E6F6E6; --attention-encre: #7A5300; --attention-doux: #FFF6DD;
    --serieux-encre: #8A3C1A; --serieux-doux: #FDEDE5; --critique-encre: #A21F1F; --critique-doux: #FBE7E7;
    --missions-encre: #1D4F9E; --missions-doux: #E6EEFB;
    --ombre-1: none; --ombre-2: none; --ombre-3: none;
  }
}

/* La fiche d'un produit trouvée dans les bases ouvertes (Open Food Facts…) : une aide, pas une vérité. */
.fiche-dehors { display: grid; gap: .15rem; padding: .6rem .8rem; border-radius: var(--rayon-s); background: var(--accent-doux); border: 1px solid var(--bord); }
