/* Bureau de validation des ordres : clair, lisible sur téléphone, sans décor. */
:root {
  --fond: #e6ebea;
  --surface: #fbfcfc;
  --encre: #16262b;
  --encre-douce: #52646a;
  --ligne: #c9d3d2;
  --achat: #0b6e4f;
  --vente: #9f2a2a;
  --pause: #7a5200;
  --pause-fond: #f3e6c8;
  --arret-fond: #9f2a2a;
  --actif-fond: #0b6e4f;
  --sur-couleur: #ffffff;
  --focus: #1d5fd1;
  --rayon: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #121a1c;
    --surface: #1b2629;
    --encre: #e4eceb;
    --encre-douce: #9db0b3;
    --ligne: #2e3d40;
    --achat: #4cc29a;
    --vente: #f08a80;
    --pause: #e3b25b;
    --pause-fond: #3a2f17;
    --arret-fond: #7d1f1f;
    --actif-fond: #0f5a41;
    --focus: #7fb0ff;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--fond);
  color: var(--encre);
  font-family: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
a { color: var(--focus); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.barre {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + .75rem) 1rem .75rem;
  border-bottom: 1px solid var(--ligne);
  background: var(--surface);
}
.marque { font-weight: 700; font-size: 1.125rem; }
.deconnexion { margin: 0; }

.page { max-width: 46rem; margin: 0 auto; padding: 1rem; }
.corps-etroit .page { max-width: 26rem; padding-top: 3rem; }

h1 { font-size: 1.75rem; line-height: 1.2; margin: 0 0 1rem; }
h2 { font-size: 1.25rem; margin: 2.25rem 0 .75rem; display: flex; align-items: center; gap: .5rem; }
.compteur {
  font-size: .9375rem; min-width: 1.75rem; text-align: center;
  padding: 0 .5rem; border-radius: 999px;
  background: var(--encre); color: var(--surface);
}
.note, .discret { color: var(--encre-douce); font-size: .9375rem; }
.vide { color: var(--encre-douce); padding: 1rem; border: 1px dashed var(--ligne); border-radius: var(--rayon); }
.visuellement-cache { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Messages */
.flash { padding: .75rem 1rem; border-radius: var(--rayon); margin: 0 0 1rem; border-left: 4px solid; background: var(--surface); }
.flash-succes { border-color: var(--achat); }
.flash-erreur { border-color: var(--vente); }
.bandeau-reel {
  margin: 0 0 1rem; padding: .75rem 1rem; border-radius: var(--rayon);
  background: var(--arret-fond); color: var(--sur-couleur); font-weight: 700;
}

/* Bande d'état : la première chose à lire */
.etat { border-radius: var(--rayon); padding: 1rem 1.125rem; }
.etat-titre { margin: 0; font-size: 1.25rem; font-weight: 700; line-height: 1.3; }
.etat-detail { margin: .375rem 0 0; font-size: .9375rem; }
.etat-arret { background: var(--arret-fond); color: var(--sur-couleur); }
.etat-actif { background: var(--actif-fond); color: var(--sur-couleur); }
.etat-pause { background: var(--pause-fond); color: var(--encre); }
.moteur { display: block; }
.moteur-silencieux { font-weight: 700; }

/* Ticket d'ordre : la phrase de l'ordre est l'élément central */
.ticket {
  background: var(--surface);
  border: 1px solid var(--ligne);
  border-left: 8px solid var(--encre-douce);
  border-radius: var(--rayon);
  padding: 1rem 1.125rem;
  margin-bottom: 1rem;
}
.ticket-achat { border-left-color: var(--achat); }
.ticket-vente { border-left-color: var(--vente); }
.ticket-phrase { margin: 0; font-size: 1.5rem; font-weight: 700; line-height: 1.25; }
.ticket-achat .ticket-phrase { color: var(--achat); }
.ticket-vente .ticket-phrase { color: var(--vente); }
.ticket-sous { margin: .25rem 0 0; color: var(--encre-douce); font-size: .9375rem; }

.chiffres {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: .75rem; margin: 1rem 0; padding: .75rem 0;
  border-top: 1px solid var(--ligne); border-bottom: 1px solid var(--ligne);
}
.chiffres dt { font-size: .875rem; color: var(--encre-douce); }
.chiffres dd { margin: 0; font-weight: 700; }

.ia { margin: 0 0 1rem; padding-left: .75rem; border-left: 3px solid var(--ligne); }
.ia p { margin: .25rem 0; }
.ia-avis { font-weight: 700; }
.ia-favorable { border-left-color: var(--achat); }
.ia-defavorable { border-left-color: var(--vente); }
.ia-defavorable .ia-avis { color: var(--vente); }
.ia-absente { color: var(--encre-douce); font-style: italic; }
.ia-risques { color: var(--encre-douce); }

/* Formulaires et boutons */
.formulaire { display: grid; gap: 1rem; }
label { display: grid; gap: .375rem; font-weight: 700; font-size: .9375rem; }
input, textarea {
  font: inherit; font-weight: 400; color: var(--encre);
  background: var(--fond); border: 1px solid var(--ligne); border-radius: 4px;
  padding: .625rem .75rem; width: 100%;
}
textarea { resize: vertical; }
.champ-code { font-size: 1.5rem; letter-spacing: .3em; text-align: center; }
.decision { display: grid; gap: .75rem; }
.boutons { display: grid; grid-template-columns: 1fr 2fr; gap: .75rem; }

.btn {
  font: inherit; font-weight: 700; cursor: pointer;
  min-height: 3rem; padding: .625rem 1rem;
  border-radius: 4px; border: 2px solid transparent;
}
.btn-principal { background: var(--encre); color: var(--surface); }
.btn-secondaire { background: transparent; color: var(--encre); border-color: var(--encre); }
.btn-danger { background: var(--vente); color: var(--sur-couleur); }
@media (prefers-color-scheme: dark) { .btn-danger { color: #1b0b0b; } }
.lien { font: inherit; background: none; border: 0; color: var(--focus); cursor: pointer; padding: .25rem; text-decoration: underline; }

/* Sécurité */
.securite { margin-top: 2.25rem; }
.commande {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem;
  padding: .875rem 0; border-bottom: 1px solid var(--ligne);
}
.commande form { margin: 0; }
.commande-nom { margin: 0; font-weight: 700; }
.commande-etat { margin: 0; color: var(--encre-douce); font-size: .9375rem; }
.form-code { display: flex; gap: .5rem; }
.form-code input { width: 9.5rem; text-align: center; letter-spacing: .15em; }

/* Tableaux */
.defile { overflow-x: auto; background: var(--surface); border: 1px solid var(--ligne); border-radius: var(--rayon); }
table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
th, td { padding: .625rem .75rem; text-align: left; border-bottom: 1px solid var(--ligne); vertical-align: top; }
th { font-weight: 700; color: var(--encre-douce); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; white-space: nowrap; }
.positif { color: var(--achat); }
.negatif { color: var(--vente); }
.statut { font-weight: 700; white-space: nowrap; }
.statut-executee, .statut-approuvee, .statut-transmise { color: var(--achat); }
.statut-rejetee, .statut-refusee_risque, .statut-erreur { color: var(--vente); }
.statut-expiree, .statut-annulee { color: var(--encre-douce); }

/* Première configuration */
.panneau { background: var(--surface); border: 1px solid var(--ligne); border-radius: var(--rayon); padding: 1.5rem; }
.qr { display: flex; justify-content: center; padding: 1rem; background: #ffffff; border-radius: var(--rayon); margin: 1rem 0; }
.cle { text-align: center; font-size: 1.125rem; letter-spacing: .05em; word-spacing: .3em; user-select: all; }

@media (max-width: 30rem) {
  .boutons { grid-template-columns: 1fr; }
  .boutons .btn-principal { order: -1; }
  .form-code { width: 100%; }
  .form-code input { flex: 1; width: auto; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
