/* Briques communes des écrans rangés en blocs (static/js/blocs-lignes.js, préfixe `bl-`) : interrupteur « Seulement les
   lignes à traiter », en-tête de bloc, choix des pièces d'origine, tableau en grille qui devient une liste sur téléphone,
   détail déplié, boutons de pièces. Même rendu sur Livraison, Titres-restaurant, P&L et Journal des ventes hebdomadaire
   (prototype v73). Chargée par index.html après shell.css et avant les feuilles d'écran, qui peuvent la compléter.
   Téléphone : @media (max-width: 767px), comme la coque. */

:root {
  --bl-soft: color-mix(in srgb, var(--app-bg) 64%, transparent);                /* sur la carte blanche : #F8FAF5, ligne ouverte, détail */
  --bl-divider: color-mix(in srgb, var(--app-line) 50%, var(--app-surface));    /* #EEF2EA : lignes de la liste */
  --bl-off-ink: color-mix(in srgb, var(--app-muted) 66%, var(--app-surface));   /* #8A958D : choix bloqué */
  --bl-track-off: color-mix(in srgb, var(--app-muted) 50%, var(--app-surface)); /* #A6B0A9 */
  --bl-track-on: color-mix(in srgb, var(--app-primary) 88%, #000);              /* #1A5C32 */
}

.bl-desk-only, .bl-phone-only { min-width: 0; }
@media (min-width: 768px) { .bl-phone-only { display: none !important; } }
@media (max-width: 767px) { .bl-desk-only { display: none !important; } }

/* Interrupteur « Seulement les lignes à traiter » */
.bl-switch { display: inline-flex; align-items: center; gap: 10px; min-height: 40px; padding: 0; border: 0; background: none;
  color: var(--app-ink); font: inherit; font-size: 15px; font-weight: 600; line-height: 1.4; text-align: left; cursor: pointer; }
.bl-switch__track { flex: none; position: relative; width: 44px; height: 24px; border-radius: 999px; background: var(--bl-track-off); }
.bl-switch__knob { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #FFFFFF; transition: left .15s ease; }
.bl-switch[aria-checked="true"] .bl-switch__track { background: var(--bl-track-on); }
.bl-switch[aria-checked="true"] .bl-switch__knob { left: 22px; }
.bl-switch__label { min-width: 0; }
.bl-switch__count { margin-left: 10px; vertical-align: middle; display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 24px;
  padding: 0 7px; box-sizing: border-box; border-radius: 999px; background: var(--app-warn-bg); color: var(--app-warn-ink);
  font-size: 13px; font-weight: 800; }
@media (prefers-reduced-motion: reduce) { .bl-switch__knob { transition: none; } }

/* Blocs, en-tête de bloc */
.bl-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin: 0 0 12px; }
.bl-head__lead { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; min-width: 0; }
.bl-title { display: flex; align-items: center; gap: 12px; margin: 0; font-size: 20px; font-weight: 700; line-height: 1.25; }
.bl-title__logo { flex: none; display: block; width: 72px; height: 32px; box-sizing: border-box; padding: 4px 8px;
  border: 1px solid var(--app-line); border-radius: 8px; background: #FFFFFF; object-fit: contain; }
.bl-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.bl-all { display: flex; align-items: center; gap: 10px; color: var(--app-ink); cursor: pointer; }
.bl-all.is-off { color: var(--bl-off-ink); cursor: default; }
.bl-box { width: 18px; height: 18px; margin: 0; flex: none; accent-color: var(--app-primary); }
.bl-lock { font-size: 14px; color: var(--app-muted); }
.bl-go { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 16px; border: 0;
  border-radius: 12px; background: var(--app-primary); color: var(--app-on-primary); font: inherit; font-size: 14px; font-weight: 700;
  line-height: 1.2; cursor: pointer; }
.bl-go:disabled { opacity: .5; cursor: default; }
.bl-go__icon { display: inline-flex; }
.bl-none { margin: 0; padding: 16px 20px; background: var(--app-surface); border: 1px solid var(--app-line); border-radius: 16px;
  font-size: 15px; color: var(--app-muted); }

/* Tableau en grille (rôles table / row / cell) dans sa carte ; défile dans la carte sous sa largeur. */
/* `position: relative` : le titre caché de la dernière colonne (« Pièces et détail », pour les lecteurs d'écran) reste
   dans ce cadre qui défile ; sans lui, il sortait de la page, qui glissait de côté sur tablette (audit EC-19). */
.bl-tablewrap { position: relative; background: var(--app-surface); border: 1px solid var(--app-line); border-radius: 16px; overflow-x: auto; }
.bl-table { min-width: 1060px; font-size: 14px; }
.bl-row { display: grid; align-items: center; border-top: 1px solid var(--app-line); }
.bl-row.is-open { background: var(--bl-soft); }
.bl-row--head { align-items: end; border-top: 0; border-bottom: 1px solid var(--app-line); font-size: 12px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--app-muted); }
.bl-row--head > .bl-c { padding: 18px 16px 14px; }
.bl-row--head > .bl-c:last-child { padding: 18px 0 14px; }
.bl-row:not(.bl-row--head) { cursor: pointer; }
.bl-c { min-width: 0; padding: 16px; }
.bl-num { text-align: right; font-weight: 500; }
.bl-strong { font-weight: 700; }
.bl-neg { color: var(--app-bad-ink); }
.bl-c--name { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: 10px; font-weight: 700; }
.bl-c--name > .bl-alert { grid-column: 1 / -1; }
.bl-check { display: inline-flex; align-items: center; cursor: pointer; }
.bl-check.is-off { cursor: default; }
.bl-namebox { min-width: 0; display: flex; flex-direction: column; }
.bl-alert { display: block; font-size: 13px; font-weight: 600; color: var(--app-warn-ink); }
.bl-c--act { padding: 0 10px 0 0; display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.bl-rowpieces { display: inline-flex; align-items: center; min-height: 34px; padding: 0 10px; border: 1px solid var(--app-line);
  border-radius: 999px; background: var(--app-surface); color: var(--app-primary); font: inherit; font-size: 13px; font-weight: 700;
  white-space: nowrap; cursor: pointer; }
.bl-chev { flex: none; display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 1px solid var(--app-line);
  border-radius: 999px; background: var(--app-surface); color: var(--app-ink); cursor: pointer; }
.bl-chev__icon { width: 8px; height: 8px; box-sizing: border-box; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg); }
.bl-chev[aria-expanded="true"] .bl-chev__icon { transform: translateY(2px) rotate(-135deg); }
.bl-row--total { border-top: 2px solid var(--app-ink); font-weight: 700; cursor: pointer; }
.bl-row--total > .bl-c--name { display: block; }
.bl-row--total > .bl-num { font-weight: 700; }
.bl-excl { display: block; font-size: 12px; font-weight: 600; color: var(--app-muted); }

/* Détail déplié d'une ligne (et du total) */
.bl-detail { display: block; padding: 14px 20px 18px; border-top: 1px dashed var(--app-line); background: var(--bl-soft); }
.bl-detail__body { display: flex; flex-direction: column; gap: 10px; }
.bl-detail__alert { margin: 0; font-size: 13px; }
.bl-fields { margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 24px; }
.bl-field { min-width: 0; }
.bl-field dt { font-size: 12px; color: var(--app-muted); }
.bl-field dd { margin: 2px 0 0; font-size: 14px; font-weight: 600; }
.bl-origs { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px 12px; margin-top: 8px; }
.bl-orig { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border: 1px solid var(--app-primary);
  border-radius: 12px; background: var(--app-surface); color: var(--app-primary); font: inherit; font-size: 14px; font-weight: 700;
  line-height: 1.2; cursor: pointer; }
.bl-orig:disabled { opacity: .5; cursor: default; }
.bl-missing { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; box-sizing: border-box; border-radius: 12px;
  background: var(--app-warn-bg); color: var(--app-warn-ink); font-size: 14px; font-weight: 600; }
.bl-note { margin: 0; font-size: 13px; color: var(--app-muted); }
.bl-note:empty { display: none; }

/* Chiffre douteux (médecin v2) : « en vérification » sous le nom du restaurant ou sur un virement, au calme : texte gris
   foncé dans un contour en pointillés (jamais une couleur seule), qui passe à la ligne plutôt que de déborder ; et la
   phrase qui l'explique sous le titre de la page. */
.bl-verif { display: inline-block; align-self: flex-start; max-width: 100%; box-sizing: border-box; margin-top: 4px;
  padding: 0 8px; border: 1px dashed currentColor; border-radius: 999px; color: var(--app-muted); font-size: 12px;
  font-weight: 600; line-height: 1.5; white-space: normal; overflow-wrap: anywhere; }
.bl-verif-note { margin: 0 0 16px; max-width: 80ch; font-size: 14px; line-height: 1.45; color: var(--app-muted); }

/* Focus clavier : l'anneau vert de la coque autour de chaque brique, ses coins arrondis gardés (le :focus-visible
   commun d'app.css les ramènerait à 2 px). */
.bl-switch:focus-visible, .bl-go:focus-visible, .bl-rowpieces:focus-visible, .bl-chev:focus-visible, .bl-orig:focus-visible,
.bl-tot:focus-visible, .bl-box:focus-visible { outline: 2px solid var(--app-primary); outline-offset: 2px; }
.bl-switch:focus-visible { border-radius: 8px; }
.bl-go:focus-visible, .bl-orig:focus-visible { border-radius: 12px; }
.bl-rowpieces:focus-visible, .bl-chev:focus-visible { border-radius: 999px; }
.bl-tot:focus-visible { border-radius: 10px; }
.bl-box:focus-visible { border-radius: 4px; }

@media (max-width: 767px) {
  /* Un bloc = une carte blanche : en-tête (logo, interrupteur, total, choix), puis la liste des lignes. */
  .bl-block { background: var(--app-surface); border: 1px solid var(--app-line); border-radius: 16px; overflow: hidden; }
  .bl-block--empty { display: none; }        /* avec l'interrupteur, un bloc sans ligne à traiter disparaît */
  .bl-head { justify-content: flex-start; gap: 4px 8px; margin: 0; padding: 8px 8px 8px 12px; }
  .bl-head__lead { flex: 1 1 auto; flex-wrap: nowrap; gap: 4px 8px; }
  .bl-head__lead .bl-switch { flex: 0 1 auto; margin-left: auto; }
  .bl-title__logo { width: 56px; height: 32px; padding: 3px 5px; }
  /* Interrupteur au téléphone (LivraisonMobile, TitresMobile), le même sur les quatre écrans : le texte et sa pastille
     d'abord, le rail 46 × 26 au bout ; sur la ligne du logo dans Livraison et Titres (le texte passe à la ligne). */
  .bl-switch { min-height: 44px; font-size: 14px; }
  .bl-switch__track { order: 2; width: 46px; height: 26px; }
  .bl-switch__knob { top: 3px; left: 3px; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); }
  .bl-switch[aria-checked="true"] .bl-switch__knob { left: 23px; }
  .bl-switch__label { display: flex; align-items: center; gap: 8px; }     /* le texte passe à la ligne, la pastille reste à côté */
  .bl-switch__count { flex: none; margin-left: 0; min-width: 22px; height: 22px; padding: 0 6px; }
  .bl-tot { flex: none; margin-left: auto; display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 10px;
    border: 0; border-radius: 10px; background: none; color: var(--app-ink); font: inherit; text-align: right; }
  span.bl-tot { padding-right: 28px; }
  button.bl-tot { cursor: pointer; }
  .bl-tot__text { display: flex; flex-direction: column; align-items: flex-end; }
  .bl-tot__label { font-size: 12px; font-weight: 600; color: var(--app-muted); }
  .bl-tot__value { font-size: 17px; font-weight: 800; line-height: 1.25; }
  .bl-tot__chev { flex: none; width: 8px; height: 8px; box-sizing: border-box; border-right: 2px solid var(--app-muted);
    border-bottom: 2px solid var(--app-muted); transform: translateY(-2px) rotate(45deg); }
  .bl-tot[aria-expanded="true"] .bl-tot__chev { transform: translateY(2px) rotate(-135deg); }
  .bl-pick { display: contents; }
  .bl-all { gap: 8px; min-width: 44px; min-height: 44px; font-size: 14px; font-weight: 600; }
  /* Cibles de 44 px au doigt, même dessin (fos-slow-9) : la zone touchée dépasse le bouton de 6 px en haut et en bas. */
  .bl-rowpieces { position: relative; }
  .bl-rowpieces::before { content: ""; position: absolute; inset: -6px 0; }
  .bl-all.is-off { color: var(--app-ink); opacity: .4; }
  .bl-pick .bl-box, .bl-check .bl-box { width: 22px; height: 22px; }
  .bl-lock { margin-left: auto; font-size: 13px; text-align: right; }
  .bl-go { flex: none; margin-left: auto; min-height: 44px; padding: 0 14px; }
  .bl-go.is-empty { display: none; }
  .bl-none { margin: 0; border: 0; border-top: 1px solid var(--bl-divider); border-radius: 0; padding: 14px 16px; }
  .bl-totdetail { padding: 14px 16px 16px; border-top: 1px dashed var(--app-line); background: var(--bl-soft); display: flex;
    flex-direction: column; gap: 12px; }

  /* Le tableau devient une liste : case, nom et montant, état et bouton des pièces, flèche. */
  .bl-tablewrap { background: none; border: 0; border-radius: 0; overflow: visible; }
  .bl-table { min-width: 0; }
  .bl-row--head, .bl-row--total, .bl-row--total + .bl-detail { display: none; }
  .bl-row { grid-template-columns: 44px minmax(0, 1fr) auto auto 20px !important; grid-template-areas:
    "check name name value chev" "check badge pieces pieces chev"; column-gap: 8px; row-gap: 4px; align-items: center;
    min-height: 64px; box-sizing: border-box; padding: 12px 14px 12px 0; border-top: 1px solid var(--bl-divider); background: var(--app-surface); }
  .bl-row > .bl-c { padding: 0; }
  .bl-row > .bl-c--name, .bl-row > .bl-c--act { display: contents; }
  .bl-row .bl-check { grid-area: check; align-self: stretch; justify-content: center; }
  .bl-row .bl-namebox { grid-area: name; font-size: 15px; font-weight: 700; overflow-wrap: anywhere; }
  .bl-row .bl-alert { display: none; }
  .bl-row > .bl-num { display: none; }
  .bl-row > .bl-key { display: block; grid-area: value; justify-self: end; font-size: 15px; font-weight: 700; white-space: nowrap; }
  .bl-row > .bl-c--state { grid-area: badge; justify-self: end; }
  .bl-row .bl-rowpieces { grid-area: pieces; justify-self: end; }
  .bl-row .bl-chev { grid-area: chev; justify-self: end; position: relative; width: 20px; height: 44px; border: 0; border-radius: 0;
    background: none; color: var(--app-muted); }
  /* doigt : 40 × 44 autour de la flèche de 20 px (audit EC-13), dans l'espace entre les pièces et le bord de la carte */
  .bl-row .bl-chev::before { content: ""; position: absolute; inset: 0 -12px 0 -8px; }
  .bl-row.is-open, .bl-row.is-open + .bl-detail { background: var(--bl-soft); }
  .bl-detail { padding: 12px 16px 16px; }
  .bl-detail__body { gap: 12px; }
  .bl-detail__alert { padding: 8px 12px; border-radius: 10px; background: var(--app-warn-bg); color: var(--app-warn-ink); font-weight: 600; }
  .bl-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; }
  .bl-field { overflow-wrap: anywhere; }
  .bl-field--wide { grid-column: span 2; }
  .bl-origs { flex-direction: column; align-items: flex-end; gap: 8px; margin-top: 6px; }
  .bl-orig { justify-content: center; min-height: 44px; padding: 0 12px; font-size: 15px; }
  .bl-missing { justify-content: center; min-height: 44px; padding: 0 12px; text-align: center; }
  .bl-note--warn { color: var(--app-warn-ink); }
}

/* Tablette (768 à 1 199 px, le doigt ; audit EC-13) : bouton des pièces et flèche de la ligne à 40 px. */
@media (min-width: 768px) and (max-width: 1199px) {
  .bl-rowpieces { min-height: 40px; }
  .bl-chev { width: 40px; height: 40px; }
}
