/* Mise en page : barre d'en-tête sombre pleine largeur (charte trans-projet), volet de menu à gauche, liste du jour à droite ; la saisie s'ouvre en fenêtre. */
:root {
  --barre: #262626; --barre-fg: #ffffff; --barre-sub: #bdbdbd; --barre-btn: #3a3a3a;
  --bg: #f2f3f5; --surface: #ffffff; --surface-2: #f7f8fa; --fg: #1f2933; --muted: #5d6874; --line: #dde1e6;
  --accent: #2f7fd6; --accent-bg: #e5f0fc; --orange: #c96d12; --orange-bg: #fbeedd;
  --ok: #2b7a4b; --ok-bg: #e2f3e9; --warn: #9a5800; --warn-bg: #fdf1dc; --err: #b3261e; --err-bg: #fbe5e3;
  --plaque-fond: #ffffff; --plaque-texte: #111111; --plaque-bande: #1d4ea6;
  --ombre: 0 18px 48px rgba(15, 20, 30, .28);
  --f-texte: Calibri, "Carlito", "Segoe UI", Arial, sans-serif;
  --f-code: Consolas, "IBM Plex Mono", "Courier New", monospace;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --barre: #111213; --barre-fg: #f3f4f5; --barre-sub: #9a9fa5; --barre-btn: #2a2c2f;
  --bg: #17191c; --surface: #1f2226; --surface-2: #25292e; --fg: #e5e8eb; --muted: #9ba5af; --line: #343a41;
  --accent: #5ea3ef; --accent-bg: #1c2f45; --orange: #e5913f; --orange-bg: #3a2a18;
  --ok: #67c594; --ok-bg: #1b3326; --warn: #e7b25a; --warn-bg: #382a14; --err: #f08a82; --err-bg: #3d1e1c;
  --ombre: 0 18px 48px rgba(0, 0, 0, .6); color-scheme: dark; } }
:root[data-theme="dark"] {
  --barre: #111213; --barre-fg: #f3f4f5; --barre-sub: #9a9fa5; --barre-btn: #2a2c2f;
  --bg: #17191c; --surface: #1f2226; --surface-2: #25292e; --fg: #e5e8eb; --muted: #9ba5af; --line: #343a41;
  --accent: #5ea3ef; --accent-bg: #1c2f45; --orange: #e5913f; --orange-bg: #3a2a18;
  --ok: #67c594; --ok-bg: #1b3326; --warn: #e7b25a; --warn-bg: #382a14; --err: #f08a82; --err-bg: #3d1e1c;
  --ombre: 0 18px 48px rgba(0, 0, 0, .6); color-scheme: dark; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--fg); font-family: var(--f-texte); font-size: 15px; line-height: 1.4; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--barre); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.barre { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--barre); color: var(--barre-fg);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); padding-block: 10px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.logo { width: 34px; height: 34px; border-radius: 8px; background: var(--barre-btn); display: grid; place-items: center; flex: none; }
.titre-app { display: flex; flex-direction: column; min-width: 0; }
.titre-app b { font-size: 18px; line-height: 1.1; }
.titre-app span { font-size: 12.5px; color: var(--barre-sub); }
.barre .espace { flex: 1; }
.etat-reseau { display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 999px; padding: 6px 12px; background: var(--barre-btn); color: var(--barre-fg); font-size: 13.5px; }
.etat-reseau i { width: 9px; height: 9px; border-radius: 50%; background: #4cc27f; }
.etat-reseau.hors i { background: #e8a33c; }
.etat-reseau small { color: var(--barre-sub); }
.poste { font-size: 13px; color: var(--barre-sub); }

.coquille { display: grid; grid-template-columns: 210px minmax(0, 1fr); min-height: calc(100% - 56px); }
.volet { background: var(--surface); border-right: 1px solid var(--line); padding-block: 14px; display: flex; flex-direction: column; gap: 2px; }
.volet button { display: flex; align-items: center; gap: 10px; border: 0; background: none; text-align: left; padding: 9px 16px 9px 18px; border-left: 3px solid transparent; color: var(--muted); font-size: 15px; }
.volet button:hover { color: var(--orange); }
.volet button[aria-current="page"] { color: var(--accent); border-left-color: var(--accent); background: var(--accent-bg); font-weight: 700; }
.volet .compte { margin-left: auto; font-size: 12px; background: var(--warn-bg); color: var(--warn); border-radius: 999px; padding: 0 7px; font-weight: 700; }
.volet .pied-volet { margin-top: auto; padding: 12px 18px 0; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); }

main { min-width: 0; padding-block: 18px 40px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: flex; flex-direction: column; gap: 14px; }
.avis { font-size: 13px; color: var(--muted); background: var(--surface-2); border: 1px dashed var(--line); border-radius: 6px; padding: 7px 12px; }
.tete { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.tete h1 { margin: 0; font-size: 22px; text-wrap: balance; }
.tete p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.tete .espace { flex: 1; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 7px 14px; }
.btn:hover { border-color: var(--muted); }
.btn.principal { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.btn.principal:hover { filter: brightness(1.08); }
.btn kbd { font-family: var(--f-code); font-size: 11px; opacity: .8; margin-left: 6px; }

.resume { display: flex; flex-wrap: wrap; gap: 8px 22px; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.resume b { color: var(--fg); }

.filtres { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; position: sticky; top: calc(env(safe-area-inset-top, 0px) + 54px); z-index: 3; background: var(--bg); padding-block: 6px; }
.segment { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--surface); }
.segment button { border: 0; background: none; padding: 5px 12px; font-size: 13.5px; color: var(--muted); }
.segment button[aria-pressed="true"] { background: var(--fg); color: var(--surface); }
.puce { position: relative; }
.puce > button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 13.5px; display: inline-flex; gap: 6px; align-items: center; }
.puce > button .v { color: var(--muted); }
.puce.active > button { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }
.puce.active > button .v { color: var(--accent); font-weight: 700; }
.puce .x { margin-left: 2px; font-weight: 700; }
.choix { position: absolute; top: calc(100% + 6px); left: 0; z-index: 6; min-width: 210px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--ombre); padding: 6px; }
.choix button { display: flex; width: 100%; justify-content: space-between; gap: 16px; border: 0; background: none; padding: 6px 10px; border-radius: 5px; text-align: left; }
.choix button:hover:not(:disabled) { background: var(--surface-2); }
.choix button:disabled { opacity: .4; cursor: default; }
.choix button span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.recherche { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 14px; min-width: 0; width: 220px; max-width: 100%; }
.effacer { border: 0; background: none; color: var(--accent); font-size: 13.5px; text-decoration: underline; }

.cadre-table { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; font-variant-numeric: tabular-nums; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: 9px 10px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.nouvelle td { animation: lueur 1.6s ease-out; }
@keyframes lueur { from { background: var(--accent-bg); } to { background: transparent; } }
td.num { text-align: right; }
.client-nom { font-weight: 700; }
.client-code { color: var(--muted); font-size: 12.5px; }
.vide { padding: 28px; text-align: center; color: var(--muted); }

.plaque { display: inline-flex; align-items: stretch; border: 1.5px solid #222; border-radius: 3px; background: var(--plaque-fond); color: var(--plaque-texte); font-family: var(--f-code); font-weight: 600; font-size: 12.5px; letter-spacing: .03em; line-height: 1; overflow: hidden; }
.plaque::before { content: "F"; background: var(--plaque-bande); color: #fff; font-size: 9px; padding: 4px 3px 0; }
.plaque span { padding: 4px 6px; }
.plaque.nc { opacity: .55; }
.etiq { display: inline-block; border-radius: 999px; padding: 2px 9px; font-size: 12.5px; font-weight: 700; }
.etiq.ok { background: var(--ok-bg); color: var(--ok); }
.etiq.serveur { background: var(--accent-bg); color: var(--accent); }
.etiq.attente { background: var(--warn-bg); color: var(--warn); }
.etiq.qualif { background: var(--orange-bg); color: var(--orange); }
.fact { font-size: 13px; color: var(--muted); }

/* Fenêtre de saisie */
.voile { position: fixed; inset: 0; z-index: 20; background: rgba(10, 14, 20, .45); display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; align-items: center; padding: 16px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.fenetre { width: min(760px, 100%); max-height: calc(100% - 8px); display: flex; flex-direction: column; background: var(--surface); border-radius: 10px; box-shadow: var(--ombre); overflow: hidden; border: 1px solid var(--line); }
.fenetre-titre { display: flex; align-items: center; gap: 10px; background: var(--barre); color: var(--barre-fg); padding: 10px 14px; }
.fenetre-titre b { font-size: 15.5px; }
.fenetre-titre span { color: var(--barre-sub); font-size: 13px; }
.fenetre-titre .fermer { margin-left: auto; border: 0; background: none; color: var(--barre-fg); font-size: 20px; line-height: 1; padding: 2px 6px; border-radius: 4px; }
.fenetre-titre .fermer:hover { background: var(--barre-btn); }
.fenetre-corps { padding: 16px 18px; overflow: auto; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px 14px; }
.champ { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.champ label { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.champ input, .champ select, .champ textarea { border: 1px solid var(--line); background: var(--surface); border-radius: 5px; padding: 7px 9px; width: 100%; }
.champ input:disabled { background: var(--surface-2); color: var(--muted); }
.champ input.immat { font-family: var(--f-code); text-transform: uppercase; letter-spacing: .03em; }
.champ.erreur input, .champ.erreur select { border-color: var(--err); }
.champ .aide { font-size: 12.5px; color: var(--muted); min-height: 1em; }
.champ.erreur .aide { color: var(--err); font-weight: 700; }
.c2 { grid-column: span 2; } .c3 { grid-column: span 3; } .c4 { grid-column: span 4; } .c6 { grid-column: span 6; }
.separ { grid-column: span 6; border-top: 1px solid var(--line); padding-top: 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.encart { grid-column: span 6; border-radius: 6px; padding: 9px 12px; font-size: 13.5px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.encart.info { background: var(--accent-bg); color: var(--fg); }
.encart.alerte { background: var(--warn-bg); color: var(--fg); }
.encart.alerte b { color: var(--warn); }
.puces-immat { display: flex; flex-wrap: wrap; gap: 6px; }
.puces-immat button { border: 0; background: none; padding: 0; }
.total { grid-column: span 6; display: flex; justify-content: flex-end; gap: 18px; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.total b { color: var(--fg); font-size: 17px; }
.fenetre-pied { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; }
.fenetre-pied .note-pied { font-size: 12.5px; color: var(--muted); margin-right: auto; }

.carte { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; }
.grille-synchro { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.carte h2 { margin: 0 0 6px; font-size: 15px; }
.carte .gros { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.carte p { margin: 0; color: var(--muted); font-size: 13.5px; }
.journal { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.journal li { display: flex; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.journal li:last-child { border-bottom: 0; }
.journal time { font-family: var(--f-code); font-size: 12.5px; color: var(--muted); flex: none; padding-top: 2px; }

.toast { position: fixed; z-index: 30; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); background: var(--fg); color: var(--surface); border-radius: 8px; padding: 10px 16px; font-size: 14px; box-shadow: var(--ombre); }

@media (max-width: 760px) {
  .coquille { grid-template-columns: minmax(0, 1fr); }
  .volet { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 0; }
  .volet button { border-left: 0; border-bottom: 3px solid transparent; white-space: nowrap; padding: 10px 14px; }
  .volet button[aria-current="page"] { border-bottom-color: var(--accent); }
  .volet .pied-volet { display: none; }
  .fenetre-corps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .c2, .c3 { grid-column: span 1; } .c4, .c6, .separ, .encart, .total { grid-column: span 2; }
  .filtres { top: calc(env(safe-area-inset-top, 0px) + 100px); }
  .poste { display: none; }
}
@media (prefers-reduced-motion: reduce) { tr.nouvelle td { animation: none; } }

/* ---- Ajouts de la PWA (v1) ---- */
body { margin: 0; }
tbody tr.cliquable { cursor: pointer; }
tbody tr.cliquable:hover td { background: var(--surface-2); }
.etiq.refus { background: var(--err-bg); color: var(--err); }
.etiq.annulee { background: var(--surface-2); color: var(--muted); text-decoration: line-through; }
.btn.danger { color: var(--err); border-color: var(--err); background: var(--surface); }
.btn:disabled { opacity: .5; cursor: default; }
.auto { position: relative; }
.suggestions { position: absolute; z-index: 25; left: 0; right: 0; top: 100%; margin-top: 2px; max-height: 300px; overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--ombre); padding: 4px; }
.suggestions button { display: flex; width: 100%; gap: 10px; justify-content: space-between; border: 0; background: none; text-align: left; padding: 6px 9px; border-radius: 4px; }
.suggestions button span:last-child { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.suggestions button.actif, .suggestions button:hover { background: var(--accent-bg); }
.suggestions .vide-sugg { padding: 6px 9px; color: var(--muted); font-size: 13px; }
.encart.consigne { background: var(--warn-bg); }
.encart.consigne ul { margin: 0; padding-left: 18px; }
.encart .champ { flex: 1 1 200px; }
details.complements { grid-column: span 6; border-top: 1px solid var(--line); padding-top: 6px; }
details.complements summary { cursor: pointer; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
details.complements .grille { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px 14px; margin-top: 10px; }
.champ.alerte .aide { color: var(--warn); font-weight: 700; }
.champ.ok .aide { color: var(--ok); }
.ecran-poste { max-width: 520px; margin: 40px auto; }
.ecran-poste .carte { display: flex; flex-direction: column; gap: 12px; }
.ecran-poste .champ input, .ecran-poste .champ select { border: 1px solid var(--line); background: var(--surface); border-radius: 5px; padding: 7px 9px; }
.bandeau-hors { background: var(--warn-bg); color: var(--fg); border-radius: 6px; padding: 8px 12px; font-size: 14px; }
@media (max-width: 760px) { details.complements { grid-column: span 2; } details.complements .grille { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.suggestions { min-width: min(440px, calc(100vw - 48px)); }
