:root {
  --fond: #f4f6fb; --carte: #ffffff; --texte: #141a2b; --doux: #5d6680; --ligne: #dde2ee;
  --vert: #1e3a8a; --vert2: #2563eb; --rouge: #b3261e; --orange: #b85c00; --bleu: #1d5fa8;
  --ombre: 0 1px 3px rgba(0,0,0,.08);
}
@media (prefers-color-scheme: dark) {
  :root { --fond: #0d1220; --carte: #161d2e; --texte: #e8ecf6; --doux: #9aa4bd; --ligne: #283449;
    --vert: #4f7fe8; --vert2: #7aa2f2; --rouge: #ff7b72; --orange: #f0a04b; --bleu: #79b0f0; --ombre: none; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--fond); color: var(--texte);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; }
body { padding-bottom: calc(150px + env(safe-area-inset-bottom)); }
button, input, select, textarea { font: inherit; color: inherit; }

.entete { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--vert); color: #fff; }
.titre { display: flex; flex-direction: column; }
.titre strong { font-size: 19px; }
.maj { font-size: 12px; opacity: .85; }
.badge { border: 0; border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; cursor: pointer; }
.badge.lecture { background: rgba(255,255,255,.18); color: #fff; }
.badge.admin { background: #ffd24d; color: #3a2a00; }

.bandeau { margin: 10px 16px 0; padding: 10px 12px; border-radius: 10px; font-size: 14px;
  background: #fff4d6; color: #5a4100; border: 1px solid #f1d58a; }
@media (prefers-color-scheme: dark) { .bandeau { background: #3a2f12; color: #ffe3a1; border-color: #6b5522; } }

main { padding: 12px 16px; max-width: 760px; margin: 0 auto; }
h2 { font-size: 18px; margin: 18px 0 8px; }
.chiffres { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.chiffre { background: var(--carte); border: 1px solid var(--ligne); border-radius: 12px; padding: 12px; box-shadow: var(--ombre); }
.chiffre b { display: block; font-size: 24px; }
.chiffre.cliquable { cursor: pointer; }
.chiffre span { color: var(--doux); font-size: 13px; }

.recherche { width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--ligne); background: var(--carte); margin: 4px 0 10px; }
.liste { list-style: none; margin: 0; padding: 0; background: var(--carte); border: 1px solid var(--ligne); border-radius: 12px; overflow: hidden; box-shadow: var(--ombre); }
.liste li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px; border-top: 1px solid var(--ligne); cursor: pointer; }
.liste li:first-child { border-top: 0; }
.liste li .g { min-width: 0; }
.liste li .g small { display: block; color: var(--doux); font-size: 13px; }
.liste li .d { text-align: right; white-space: nowrap; font-weight: 700; }
.vide { color: var(--doux); padding: 14px; text-align: center; }
.neg { color: var(--rouge); } .pos { color: var(--vert2); } .attn { color: var(--orange); }
.annulee { opacity: .45; text-decoration: line-through; }
.etiquette { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--ligne); }
.etiquette.en_route { background: #dbe8f8; color: #1d4f8a; } .etiquette.au_port { background: #fde9cf; color: #7a4300; }
.etiquette.arrive { background: #d7f0e2; color: #145c3c; } .etiquette.decharge { background: #e6e6e6; color: #333; }

.micro { position: fixed; right: 18px; bottom: calc(78px + env(safe-area-inset-bottom)); width: 72px; height: 72px; border-radius: 50%;
  border: 0; background: var(--vert2); color: #fff; box-shadow: 0 6px 18px rgba(0,0,0,.25); cursor: pointer; z-index: 6; }
.micro.ecoute { background: var(--rouge); animation: pulse 1.1s infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }

.onglets { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--carte); border-top: 1px solid var(--ligne); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.onglets button { border: 0; background: none; padding: 14px 2px; font-size: 13px; color: var(--doux); cursor: pointer; }
.onglets button.actif { color: var(--vert2); font-weight: 700; box-shadow: inset 0 3px 0 var(--vert2); }

dialog { width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 40px); overflow-y: auto; border: 0; border-radius: 16px; padding: 0; background: var(--carte); color: var(--texte); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog form { padding: 16px; }
dialog h3 { margin: 0 0 6px; font-size: 18px; }
.dicte { background: var(--fond); border-radius: 10px; padding: 8px 10px; font-style: italic; color: var(--doux); margin-bottom: 10px; }
.champ { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.champ label { font-size: 13px; color: var(--doux); }
.champ input, .champ select, .champ textarea { padding: 10px; border-radius: 9px; border: 1px solid var(--ligne); background: var(--carte); width: 100%; }
.rangee { display: grid; grid-template-columns: 90px 110px 1fr; gap: 6px; margin: 6px 0; }
.rangee input, .rangee select { padding: 9px; border-radius: 9px; border: 1px solid var(--ligne); background: var(--carte); width: 100%; min-width: 0; }
.boutons { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.btn { border: 0; border-radius: 10px; padding: 11px 16px; font-weight: 700; cursor: pointer; background: var(--ligne); }
.btn.principal { background: var(--vert2); color: #fff; }
.btn.danger { background: transparent; color: var(--rouge); }
.lien { background: none; border: 0; color: var(--bleu); padding: 0; cursor: pointer; text-decoration: underline; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 4px; }
.actions .btn { font-size: 14px; padding: 9px 12px; }
.ecoute-txt { min-height: 24px; font-size: 17px; }
.petit { font-size: 13px; color: var(--doux); }
@media (min-width: 700px) { .chiffres { grid-template-columns: repeat(4, 1fr); } }

a.btn { text-decoration: none; display: inline-block; color: inherit; }
a.btn.principal { color: #fff; }
.recu { background: #fff; color: #111; border-radius: 10px; padding: 12px; }
.recu table { font-size: 14px; } .recu th { border-bottom: 1px solid #999; } .recu td { border-bottom: 1px solid #eee; }

.barre-recherche { position: sticky; top: 58px; z-index: 4; padding: 8px 16px; background: var(--fond); max-width: 760px; margin: 0 auto; }
.barre-recherche input { width: 100%; padding: 11px 14px; border-radius: 999px; border: 1px solid var(--ligne); background: var(--carte); }
.ligne { border: 1px solid var(--ligne); border-radius: 12px; padding: 8px; margin: 8px 0; background: var(--fond); }
.ligne > input { width: 100%; padding: 9px; border-radius: 9px; border: 1px solid var(--ligne); background: var(--carte); margin: 3px 0; }
details.groupe { background: var(--carte); border: 1px solid var(--ligne); border-radius: 12px; padding: 4px 10px 10px; margin: 10px 0; box-shadow: var(--ombre); }
details.groupe > summary { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; cursor: pointer; font-size: 17px; }
details.groupe > summary span { color: var(--doux); font-size: 14px; text-align: right; }
details.groupe .liste { box-shadow: none; }
h4 { margin: 12px 0 6px; font-size: 15px; }
details > summary.petit { cursor: pointer; margin: 10px 0 6px; }
.carte-cat { border: 1px solid var(--ligne); border-radius: 12px; padding: 8px; margin: 8px 0; background: var(--carte); }
.carte-cat > input { width: 100%; padding: 9px; border-radius: 9px; border: 1px solid var(--ligne); background: var(--carte); margin: 3px 0; }
.fiche { background: var(--carte); border: 1px solid var(--ligne); border-radius: 12px; padding: 4px 12px 10px; margin: 10px 0; }
.cliquable { cursor: pointer; }
.etiquette.inconnu { background: #eee; color: #555; }
.liste li .g { flex: 1 1 auto; }
.liste li .d { white-space: normal; max-width: 58%; overflow-wrap: anywhere; }

.as-ligne { display: flex; gap: 6px; align-items: flex-end; background: var(--carte); border: 1px solid var(--ligne); border-radius: 22px; padding: 5px; }
.as-ligne textarea { flex: 1; border: 0; background: transparent; resize: none; padding: 8px 6px; min-height: 36px; max-height: 140px; outline: none; }
.as-bt { border: 0; border-radius: 50%; width: 38px; height: 38px; flex: 0 0 38px; background: var(--fond); cursor: pointer; font-size: 17px; }
.as-envoyer { background: var(--vert2); color: #fff; }
.bt-micro.ecoute { background: var(--rouge); color: #fff; animation: pulse 1.1s infinite; }
#asAide, #asEtat { margin: 6px 8px 0; }

/* Écran d'accueil (avant connexion) : tout le reste est caché */
body.verrouille > :not(#verrou):not(dialog):not(#langue) { display: none !important; }
body.verrouille { padding-bottom: 0; }
.verrou { display: none; }
body.verrouille .verrou { display: flex; flex-direction: column; justify-content: space-between; min-height: 100vh; min-height: 100dvh;
  box-sizing: border-box; padding: calc(40px + env(safe-area-inset-top)) 24px calc(28px + env(safe-area-inset-bottom));
  background: linear-gradient(170deg, #1e3a8a 0%, #2563eb 100%); color: #fff; }
.v-haut { text-align: center; margin-top: 8vh; }
.v-logo { width: 96px; height: 96px; border-radius: 22px; box-shadow: 0 8px 24px rgba(0,0,0,.3); }
.v-haut h1 { font-size: 28px; line-height: 1.25; margin: 22px 0 8px; }
.v-etat { opacity: .85; font-size: 15px; min-height: 1.2em; }
.v-bas { display: flex; flex-direction: column; gap: 6px; width: 100%; max-width: 420px; margin: 0 auto; }
.v-bas label { font-size: 14px; font-weight: 600; opacity: .9; margin-top: 6px; }
.v-bas input { font-size: 17px; padding: 13px 14px; border-radius: 12px; border: 0; background: #fff; color: #111; }
.v-err { color: #ffd2cc; font-size: 14px; min-height: 1.2em; margin: 4px 0; }
.v-ok { font-size: 17px; padding: 14px; background: #fff; color: #1e3a8a; }
.v-oubli { background: none; border: 0; color: #fff; text-decoration: underline; font-size: 15px; padding: 12px; cursor: pointer; }

/* liste à cocher (supprimer plusieurs opérations) */
.liste-coches { max-height: 55vh; overflow-y: auto; margin: 8px 0; border: 1px solid var(--ligne); border-radius: 10px; }
.coche { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-bottom: 1px solid var(--ligne); cursor: pointer; }
.coche:last-child { border-bottom: 0; }
.coche input { margin-top: 3px; width: 20px; height: 20px; flex: none; }
.coche small { display: block; opacity: .7; font-size: 12px; }
.btn.danger { border: 1px solid var(--rouge); }

/* un élément marqué "hidden" reste caché même s'il a un display (ex. .rangee) */
[hidden] { display: none !important; }

/* « Prix et stock minimum » : la quantité et l'unité de la ligne ne servent pas, on les cache */
.sans-qte .ligne > .rangee:first-child, .sans-qte .l_pco, .sans-qte .l_pco_lab, .sans-qte .l_pco_tot { display: none !important; }
.etiquette.en_attente { background: #fde9cf; color: #7a4300; } .etiquette.preparee { background: #dbe8f8; color: #1d4f8a; }
.etiquette.livree { background: #d7f0e2; color: #145c3c; } .etiquette.annulee { background: #eee; color: #777; text-decoration: line-through; }

/* licence : bandeaux d'échéance, de retard et de suspension */
.bandeau.licence-info { background: #e8f0fb; color: #1d4f8a; }
.bandeau.licence-alerte { background: #fde9cf; color: #7a4300; font-weight: 600; }
.bandeau.licence-bloque { background: #f9d6d5; color: #8a1c17; font-weight: 600; }

/* premier lancement : choix de la langue */
.langue-ecran { display: none; }
body.choix-langue > *:not(.langue-ecran) { display: none !important; }
body.choix-langue .langue-ecran { display: flex !important; flex-direction: column; align-items: center; justify-content: center; gap: 14px; min-height: 100vh; min-height: 100dvh;
  padding: 24px; text-align: center; background: linear-gradient(170deg, #1e3a8a 0%, #2563eb 100%); color: #fff; }
.langue-ecran h1 { margin: 0; font-size: 32px; }
.langue-ecran .petit { color: rgba(255,255,255,.8); }
.langue-choix { display: grid; gap: 12px; width: min(320px, 100%); }
.langue-choix .btn { font-size: 18px; padding: 14px; background: #fff; color: #1e3a8a; border: 0; }
