:root {
  --fond: #f3f5f9;
  --carte: #ffffff;
  --texte: #1b2433;
  --doux: #5d6b80;
  --bord: #dde3ec;
  --marine: #1d3557;
  --accent: #e07a1f;
  --ok: #1f7a4d;
  --ok-fond: #e3f4ea;
  --attention: #8a5a00;
  --attention-fond: #fff4dc;
  --erreur: #b3261e;
  --erreur-fond: #fde8e6;
  --rayon: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #0f1520;
    --carte: #182131;
    --texte: #e6ebf3;
    --doux: #9aa7bb;
    --bord: #2a3548;
    --marine: #8fb3e8;
    --ok: #6fd3a0;
    --ok-fond: #143325;
    --attention: #f0c36a;
    --attention-fond: #3a2e12;
    --erreur: #ff8a80;
    --erreur-fond: #3d1714;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--fond); color: var(--texte); }
a { color: var(--marine); }
h1 { font-size: 1.45rem; margin: 0; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; }

.entete { background: #1d3557; color: #fff; padding: .6rem 1rem; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem; position: sticky; top: 0; z-index: 5; padding-top: max(.6rem, env(safe-area-inset-top)); }
.marque { display: flex; align-items: center; gap: .5rem; color: #fff; text-decoration: none; font-weight: 700; }
.marque img { width: 32px; height: 32px; }
.menu { display: flex; gap: .25rem; overflow-x: auto; flex: 1; scrollbar-width: none; }
.menu a { color: #dbe6f7; text-decoration: none; padding: .45rem .7rem; border-radius: 8px; white-space: nowrap; font-size: .95rem; }
.menu a.actif, .menu a:hover { background: rgba(255,255,255,.14); color: #fff; }
.menu .sortie { margin-left: auto; }

.contenu { max-width: 1200px; margin: 0 auto; padding: 1rem 1rem 3rem; }
.titre-page { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin: .5rem 0 1rem; }
.carte { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.carte.etroite { max-width: 420px; margin: 2rem auto; }
.titre-carte { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; }
.vide { color: var(--doux); }
.aide { color: var(--doux); font-size: .92rem; margin: .25rem 0 .75rem; }
.petit { font-size: .85rem; color: var(--doux); }
.pastille { background: var(--carte); border: 1px solid var(--bord); border-radius: 999px; padding: .35rem .9rem; }

.flash { padding: .7rem 1rem; border-radius: 10px; margin-bottom: 1rem; background: var(--ok-fond); color: var(--ok); }
.flash.erreur { background: var(--erreur-fond); color: var(--erreur); }
.flash.attention { background: var(--attention-fond); color: var(--attention); }

.champ { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .85rem; }
.champ > span { font-size: .9rem; font-weight: 600; }
input, select, textarea { font: inherit; color: var(--texte); background: var(--carte); border: 1px solid var(--bord); border-radius: 8px; padding: .6rem .7rem; width: 100%; min-height: 44px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--marine); outline-offset: 1px; }
input:disabled, textarea:disabled { opacity: .7; }
.invalide input, .invalide textarea { border-color: var(--erreur); }
.erreur { color: var(--erreur); font-size: .85rem; }
fieldset { border: 1px solid var(--bord); border-radius: 10px; padding: .75rem .9rem .1rem; margin: 0 0 .9rem; }
legend { font-weight: 700; padding: 0 .35rem; }
.grille { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 1rem; }
.grille.trois { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.case { display: flex; align-items: center; gap: .5rem; margin: .4rem 0; }
.case input { width: auto; min-height: 0; }

.bouton { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: .55rem 1rem; border-radius: 9px; border: 1px solid var(--bord); background: var(--carte); color: var(--texte); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.bouton.principal { background: var(--accent); border-color: var(--accent); color: #fff; }
.bouton.danger { background: var(--erreur-fond); border-color: var(--erreur); color: var(--erreur); }
.bouton.discret { border-color: transparent; background: none; }
.bouton.large { width: 100%; }
.bouton.petit { min-height: 36px; padding: .3rem .7rem; font-size: .9rem; }
.bouton.wa { background: #25d366; border-color: #25d366; color: #fff; white-space: nowrap; }
.lien { background: none; border: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font: inherit; }
.lien.petit { font-size: .85rem; }
.boutons { display: flex; flex-wrap: wrap; gap: .5rem; }
.zone-danger { margin-top: 1rem; text-align: right; }

.table-defile { overflow-x: auto; }
table.liste { border-collapse: collapse; width: 100%; font-size: .94rem; }
.liste th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--doux); border-bottom: 2px solid var(--bord); padding: .5rem; white-space: nowrap; }
.liste td { border-bottom: 1px solid var(--bord); padding: .55rem .5rem; vertical-align: top; }
.liste .actions { white-space: nowrap; text-align: right; }

.badge { display: inline-block; font-size: .78rem; font-weight: 700; padding: .12rem .55rem; border-radius: 999px; background: var(--bord); }
.badge.envoye { background: var(--ok-fond); color: var(--ok); }
.badge.simule, .badge.en_attente { background: var(--attention-fond); color: var(--attention); }
.badge.echec { background: var(--erreur-fond); color: var(--erreur); }

.infos { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .75rem; margin: 0; }
.infos dt { font-size: .8rem; color: var(--doux); }
.infos dd { margin: 0; font-weight: 600; }
.observation { margin: .75rem 0 0; padding: .6rem .8rem; background: var(--fond); border-radius: 8px; }
.lots-recents { margin: 0; padding-left: 1.1rem; }
.lots-recents li { margin: .3rem 0; }
.transmission { border: 2px solid var(--accent); }

.filtres { display: flex; flex-wrap: wrap; gap: 0 1rem; align-items: flex-end; }
.filtres .champ { flex: 1 1 160px; }
.filtres .boutons { margin-bottom: .85rem; }
.recherche { display: flex; gap: .5rem; }
.ligne-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .5rem 0; border-bottom: 1px solid var(--bord); }
.ligne-form input:not([type=checkbox]), .ligne-form select { width: auto; flex: 1 1 160px; }
.ligne-form .nom { flex: 1 1 180px; }
.ligne-form.test { border: 0; margin-top: .5rem; }
.etat { margin: 0 0 .5rem; padding-left: 1.1rem; }
.journal { list-style: none; margin: 0; padding: 0; font-size: .9rem; max-height: 360px; overflow-y: auto; }
.journal li { padding: .35rem 0; border-bottom: 1px solid var(--bord); }
.journal time { color: var(--doux); margin-right: .4rem; }

#hors-ligne { position: fixed; left: 1rem; right: 1rem; bottom: max(1rem, env(safe-area-inset-bottom)); background: #3a2e12; color: #ffe2a6; padding: .7rem 1rem; border-radius: 10px; text-align: center; z-index: 10; }

/* Téléphone : tableaux en fiches */
@media (max-width: 720px) {
  .liste thead { display: none; }
  .liste tr { display: block; border: 1px solid var(--bord); border-radius: 10px; margin-bottom: .6rem; padding: .35rem .6rem; }
  .liste td { display: flex; justify-content: space-between; gap: 1rem; border: 0; padding: .25rem 0; text-align: right; }
  .liste td::before { content: attr(data-l); color: var(--doux); font-size: .82rem; text-align: left; }
  .liste .actions { justify-content: flex-end; }
  .menu { flex-basis: 100%; margin: 0 -.5rem; }
  .menu .sortie { margin-left: 0; }
}

/* Bordereau imprimable */
body.bordereau { background: #fff; color: #000; padding: 1.5rem; font-size: 13px; }
.bordereau header { display: flex; justify-content: space-between; margin-bottom: 1rem; }
.bordereau h1 { font-size: 1.3rem; margin: .5rem 0; }
.bordereau table { border-collapse: collapse; width: 100%; }
.bordereau th, .bordereau td { border: 1px solid #555; padding: 4px 6px; text-align: left; vertical-align: top; }
.bordereau th { background: #e9edf3; }
.signatures { display: flex; justify-content: space-between; margin-top: 2.5rem; }
.signatures div { width: 40%; min-height: 90px; border-top: 1px solid #555; padding-top: .4rem; }
.ne-pas-imprimer { margin-bottom: 1rem; }
@media print {
  .ne-pas-imprimer { display: none; }
  body.bordereau { padding: 0; }
  @page { size: A4 landscape; margin: 12mm; }
}
