/* P&L (#/pl) : prototype PL.dc.html.
   Styles propres à cet écran (refonte du prototype v73) : un fichier par écran, chargé par index.html après
   shell.css. Téléphone : @media (max-width: 767px), comme la coque ; pas de maquette téléphone : la même page, les
   tableaux défilent à l'horizontale dans leur carte.
   `.pl-file*` (bouton « Fichier des écritures » et son motif) et `.pl-empty*` servent aussi au Journal des ventes
   hebdomadaire (rh.js) ; l'interrupteur est celui de blocs-lignes.js (styles `bl-switch`, css/screens/livraison.css). */

/* En-tête : surtitre, titre, une phrase */
.pl-screen .pl-head { margin-bottom: 24px; }
.pl-screen .pl-head .kicker { margin: 0; font-size: 14px; color: var(--fr-muted); }
.pl-screen .pl-head h1 { margin: 0; letter-spacing: -0.01em; }
.pl-screen .pl-head .lede { margin: 8px 0 0; font-size: 16px; color: var(--app-muted); }

/* Alerte de déséquilibre */
.pl-screen .res-alert { margin: 12px 0; padding: 12px 16px; border-radius: 12px; border: 2px solid #B44836; }
.pl-screen .res-alert ul { margin: 6px 0 0; padding-left: 20px; list-style: disc; }

/* Bloc du total, interrupteur, notes */
.pl-screen .pl-margin { margin-top: 20px; }
.pl-screen .pl-margin .margin__hero { gap: 4px 16px; margin-bottom: 8px; }
.pl-screen .pl-margin .margin__hero h2 { margin: 0 0 4px; font-size: 18px; font-weight: 600; line-height: 1.3; }
.pl-hero__note { margin: 0; font-size: 14px; color: var(--fr-muted); }
.pl-switchbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; }
.pl-note { margin: 8px 0 0; font-size: 14px; color: var(--fr-muted); }

/* Le tableau de marge : colonnes du prototype (177 / 151 / 224 / 232 / 135 / 176 / 44), défile sous 900 px */
.pl-table > .table--res { min-width: 900px; table-layout: fixed; font-size: 14px; }
.pl-table > .table--res > thead > tr > th { box-sizing: border-box; }
.pl-table > .table--res > thead > tr > th:nth-child(1) { width: 15.5%; }
.pl-table > .table--res > thead > tr > th:nth-child(2) { width: 13.3%; }
.pl-table > .table--res > thead > tr > th:nth-child(3) { width: 19.7%; }
.pl-table > .table--res > thead > tr > th:nth-child(4) { width: 20.4%; }
.pl-table > .table--res > thead > tr > th:nth-child(5) { width: 11.8%; }
.pl-table > .table--res > thead > tr > th:nth-child(6) { width: 15.4%; }
.pl-table > .table--res > thead > tr > th.res-toggle-cell { width: 3.9%; }
.pl-table > .table--res > * > tr > th, .pl-table > .table--res > * > tr > td { white-space: nowrap; }
.pl-table > .table--res > tbody > tr.row-h > th, .pl-table > .table--res > tbody > tr.row-h > td,
.pl-table > .table--res > tfoot > tr > th, .pl-table > .table--res > tfoot > tr > td { padding: 6px 16px; }
.pl-table > .table--res > thead > tr > th { padding: 18px 16px 14px; }
.pl-table > .table--res > * > tr > th.res-toggle-cell, .pl-table > .table--res > * > tr.row-h > td.res-toggle-cell { padding: 0 10px 0 0; }
.pl-table > .table--res > tbody > tr > td.num { font-weight: 500; }
.pl-table > .table--res > tbody > tr > td.key { font-weight: 700; }
.pl-table .bar { width: 200px; max-width: 100%; margin: 4px 0 0 auto; }
/* Total : un trait fin, comme le prototype */
.pl-table > .table--res > tfoot > tr > th, .pl-table > .table--res > tfoot > tr > td { border-top: 1px solid var(--app-line); height: 56px; }
.pl-table > .table--res > tbody > tr.row-x.is-open > th, .pl-table > .table--res > tbody > tr.row-x.is-open > td { background: var(--bl-soft, #F8FAF5); }

/* Détail déplié : les écritures du restaurant */
.pl-table > .table--res > tbody > tr.res-detail > td { padding: 14px 20px 18px; border-top: 1px dashed var(--app-line); background: var(--bl-soft, #F8FAF5); }
.pl-table .res-detail__body { gap: 10px; left: 20px; min-width: min(100%, calc(100cqw - 40px)); }
.pl-gap { margin: 0; font-size: 15px; font-weight: 700; color: var(--app-bad-ink); }
.pl-rounding { margin: 0; font-size: 14px; color: var(--app-muted); }
.pl-lines { max-width: 820px; margin: 0 !important; border-radius: 12px; }
.pl-lines > .table--res { min-width: 0; table-layout: auto; font-size: 14px; }
.pl-lines > .table--res > thead > tr > th { padding: 12px 14px 8px; }
.pl-lines > .table--res > * > tr.row-h { height: auto; }
.pl-lines > .table--res > * > tr > th, .pl-lines > .table--res > * > tr > td { padding: 8px 14px; white-space: nowrap; }
.pl-lines > .table--res > thead > tr > th:nth-child(1) { width: 17.2%; }
.pl-lines > .table--res > thead > tr > th:nth-child(2) { width: 41.4%; }
.pl-lines > .table--res > tbody > tr > th { font-weight: 600; }
.pl-lines > .table--res > tbody > tr > td, .pl-lines > .table--res > tbody > tr > td.num:nth-child(n) { font-weight: 400; }
.pl-lines > .table--res > tbody > tr > td:nth-child(2) { white-space: normal; }
.pl-lines > .table--res > tfoot > tr > th, .pl-lines > .table--res > tfoot > tr > td { border-top: 2px solid var(--app-ink); padding: 8px 14px; font-weight: 700; }
.pl-lines > .table--res > tbody > tr:hover { background: none; }

/* Fichier des écritures (P&L et Journal des ventes hebdomadaire) */
.pl-file { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.pl-file__btn { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 16px; box-sizing: border-box;
  border: 1px solid var(--app-line); border-radius: 12px; background: var(--app-surface); color: var(--fr-ink); font: inherit;
  font-size: 14px; font-weight: 700; line-height: 1.2; text-decoration: none; cursor: pointer; }
.pl-file__btn:hover { border-color: var(--app-line-strong); color: var(--fr-ink); }
.pl-file__btn:focus-visible { outline: 2px solid var(--app-primary); outline-offset: 2px; }
.pl-file__reason { margin: 0; font-size: 14px; font-weight: 600; color: var(--app-bad-ink); }
.pl-file__draft { font-size: 13px; color: var(--app-muted); }

/* Carte vide : mois sans chiffres, ou rien à traiter (P&L et Journal des ventes hebdomadaire) */
.pl-empty { margin-top: 16px; padding: 36px 24px; background: var(--app-surface); border: 1px solid var(--app-line); border-radius: 16px;
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.pl-empty h2 { margin: 0; font-size: 20px; font-weight: 700; }
.pl-empty p { margin: 0; max-width: 56ch; font-size: 15px; color: var(--app-muted); }
.pl-empty__reset { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px; box-sizing: border-box;
  border: 1px solid var(--app-line); border-radius: 12px; background: var(--app-surface); color: var(--fr-ink); font: inherit;
  font-size: 15px; font-weight: 700; text-decoration: none; cursor: pointer; }
.pl-empty__reset:hover { border-color: var(--app-line-strong); color: var(--fr-ink); }
.pl-empty__reset:focus-visible { outline: 2px solid var(--app-primary); outline-offset: 2px; }

/* Classeur du mois */
.pl-screen .pl-depot { margin-top: 20px; }
.pl-screen .pl-depot h2 { margin: 0 0 4px; font-size: 18px; font-weight: 600; line-height: 1.3; }
.pl-screen .pl-depot > p.small { margin: 0; font-size: 14px; color: var(--fr-muted); }
.pl-screen .pl-depot .res-more { margin-top: 6px; font-size: 14px; color: var(--fr-muted); }
.pl-screen .pl-depot__bar { justify-content: flex-start; gap: 12px; margin: 12px 0; }
.pl-screen .pl-depot__pick { min-height: 40px; padding: 0 16px; border-radius: 12px; font-size: 14px; font-weight: 700; line-height: 1.2; color: var(--fr-ink); }
.pl-screen .pl-depot__msg { margin: 0 0 8px; font-size: 14px; font-weight: 600; color: var(--app-bad-ink); }
.pl-screen .pl-depot__msg:empty { display: none; }
.pl-screen .pl-depot > p.muted:last-child { font-size: 14px; color: var(--fr-muted); }
.pl-screen .depots { margin: 0; gap: 8px; }
.pl-screen .depot { gap: 6px 12px; padding: 12px 14px; }
.pl-screen .depot__name { font-weight: 700; }
.pl-screen .depot .small.muted { font-size: 14px; color: var(--fr-muted); }

@media (max-width: 767px) {
  .pl-screen .pl-head { margin-bottom: 20px; }
  .pl-empty { padding: 28px 16px; }
  .pl-empty h2 { font-size: 17px; }
  /* les tableaux gardent leurs colonnes et défilent dans leur carte (pas de colonnes repliées) */
  .pl-table > .table--res > * > tr > th, .pl-table > .table--res > * > tr > td { white-space: nowrap; }
  .pl-table > .table--res > tbody > tr.row-h > th, .pl-table > .table--res > tbody > tr.row-h > td,
  .pl-table > .table--res > tfoot > tr > th, .pl-table > .table--res > tfoot > tr > td { padding: 6px 16px; }
  .pl-table > .table--res > thead > tr > th { padding: 18px 16px 14px; white-space: nowrap; }
  .pl-table > .table--res > * > tr > th.res-toggle-cell, .pl-table > .table--res > * > tr.row-h > td.res-toggle-cell { width: 3.9%; padding: 0 10px 0 0; }
  .pl-table .res-toggle { width: 34px; height: 34px; border: 1px solid var(--app-line); background: var(--app-surface); }
  .pl-table > .table--res .badge { white-space: nowrap; }
  .pl-table > .table--res > tbody > tr.res-detail > td { padding: 14px 16px 18px; }
  .pl-table .res-detail__body { left: 16px; min-width: min(100%, calc(100cqw - 32px)); }
  .pl-lines > .table--res > * > tr > th, .pl-lines > .table--res > * > tr > td { padding: 8px 10px; }
}

/* Le bouton du fichier dans un tableau : la règle des liens de tableau au doigt (app.css, passe UX T11) ne s'y applique pas */
.table--res .pl-file a.pl-file__btn { display: inline-flex; padding: 0 16px; margin: 0; }
