/* Reprend la charte de l'ERP Equipagro Environnement (theme.css) pour que
   l'intégration ne change rien à l'œil. */
:root {
  --bleu: #1a597b; --turquoise: #3eb5e7; --bleu-pale: #eef4fa; --navy: #13293d; --navy-sombre: #0e2233;
  --brand-soft: #7fb3d5; --rouge: #c0524a; --encre: #16283a; --texte: #3b4c5c; --sourdine: #6b8092;
  --ligne: #e2e9f0; --fond: #f3f6fa; --blanc: #fff; --vert: #1f8a5e; --orange: #c17d24;
  --radius: 14px; --ombre: 0 2px 10px rgba(19, 41, 61, .06), 0 1px 2px rgba(19, 41, 61, .04);
  color-scheme: light;
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--fond); color: var(--texte); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -.02em; margin: 0; color: var(--encre); }
h2 { font-size: 15px; font-weight: 650; margin: 0 0 12px; color: var(--encre); }
h3 { font-size: 13.5px; font-weight: 650; margin: 0 0 8px; color: var(--encre); }
p { margin: 0 0 8px; }
input, select, textarea, button { font-family: inherit; font-size: 14px; }
input:not([type=checkbox]), select, textarea {
  color: var(--encre); background: var(--blanc); border: 1px solid var(--ligne); border-radius: 8px; padding: 8px 10px; outline: none; min-width: 0;
}
input:not([type=checkbox]):focus, select:focus, textarea:focus { border-color: var(--bleu); box-shadow: 0 0 0 3px rgba(26, 89, 123, .13); }
input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--bleu); vertical-align: -3px; }
label { font-size: 12.5px; font-weight: 600; color: var(--sourdine); display: flex; flex-direction: column; gap: 4px; }
label.coche { flex-direction: row; align-items: center; gap: 7px; color: var(--texte); font-weight: 500; font-size: 13.5px; }

.btn { border: 1px solid var(--ligne); background: var(--blanc); color: var(--encre); border-radius: 9px; padding: 8px 14px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--brand-soft); }
.btn.principal { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.principal:hover { background: var(--navy-sombre); }
.btn.danger { color: var(--rouge); }
.btn.petit { padding: 5px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.entete { background: linear-gradient(180deg, var(--navy), var(--navy-sombre)); color: #d7e3ec; padding: 0 22px; display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.marque { padding: 14px 0; }
.marque .titre { color: #fff; font-weight: 700; font-size: 16px; letter-spacing: -.015em; }
.marque .sous-titre { color: var(--brand-soft); font-size: 12px; }
.onglets { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.onglet { background: none; border: none; color: #c3d3e0; padding: 20px 13px; font-weight: 600; cursor: pointer; border-bottom: 3px solid transparent; }
.onglet:hover { color: #fff; }
.onglet.actif { color: #fff; border-bottom-color: var(--turquoise); }
.qui { font-size: 12.5px; display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.qui .role { background: rgba(62, 181, 231, .18); color: #bfe6f8; border-radius: 99px; padding: 2px 10px; font-weight: 600; }
.qui button { background: none; border: 1px solid rgba(255, 255, 255, .25); color: #fff; border-radius: 8px; padding: 5px 10px; cursor: pointer; }

main { max-width: 1180px; margin: 0 auto; padding: 24px 22px 60px; }
.titre-page { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.carte { background: var(--blanc); border: 1px solid var(--ligne); border-radius: var(--radius); box-shadow: var(--ombre); padding: 18px; margin-bottom: 16px; }
.sourdine { color: var(--sourdine); }
.petit-texte { font-size: 12.5px; }
.vide { color: var(--sourdine); padding: 14px 0; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--sourdine); font-weight: 650; padding: 8px 10px; border-bottom: 1px solid var(--ligne); }
td { padding: 10px; border-bottom: 1px solid var(--ligne); vertical-align: top; }
tr:last-child td { border-bottom: none; }
td.nombre, th.nombre { text-align: right; font-variant-numeric: tabular-nums; }
.defile { overflow-x: auto; }

.lien { white-space: nowrap; background: none; border: none; padding: 0; font: inherit; font-weight: 650; color: var(--bleu); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.lien:hover { color: var(--navy); }
.bulle { display: inline-block; min-width: 19px; padding: 0 6px; border-radius: 99px; background: var(--turquoise); color: var(--navy); font-size: 11.5px; font-weight: 700; line-height: 19px; text-align: center; margin-left: 4px; }
form.palette { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
form.palette input { width: 92px; padding: 6px 8px; }
.manquant { margin-top: 8px; }
.manquant input { width: 150px; padding: 6px 8px; }
tr.ecartee td:not(:first-child) { opacity: .45; }
.pastille { display: inline-block; border-radius: 99px; padding: 2px 9px; font-size: 12px; font-weight: 600; background: var(--bleu-pale); color: var(--bleu); }
.pastille.vert { background: #e6f4ee; color: var(--vert); }
.pastille.orange { background: #fbf1e1; color: var(--orange); }
.pastille.rouge { background: #f9e9e7; color: var(--rouge); }
.pastille.gris { background: #eef1f4; color: var(--sourdine); }

.message { border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; font-weight: 500; }
.message.erreur { background: #f9e9e7; color: #8e2f28; }
.message.alerte { background: #fbf1e1; color: #7d5010; }
.message.ok { background: #e6f4ee; color: #17694a; }
.message ul { margin: 4px 0 0; padding-left: 18px; }

.grille { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.ligne-saisie { border: 1px solid var(--ligne); border-radius: 12px; padding: 14px; margin-bottom: 10px; background: #fafcfe; }
.ligne-saisie .grille { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); align-items: end; }
.calcul { margin-top: 10px; font-size: 13px; color: var(--encre); }
.calcul.erreur { color: var(--rouge); }

.chiffres { display: flex; gap: 22px; flex-wrap: wrap; margin-bottom: 14px; }
.chiffre .valeur { font-size: 21px; font-weight: 700; color: var(--encre); letter-spacing: -.02em; }
.chiffre .legende { font-size: 12px; color: var(--sourdine); }

/* Dessin d'une barre : les coupes à l'échelle, le reste en bout. */
.barre { margin-bottom: 12px; }
.barre .nom { font-size: 12.5px; font-weight: 600; color: var(--encre); margin-bottom: 4px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.barre .trace { display: flex; height: 34px; border-radius: 6px; overflow: hidden; border: 1px solid #b9c9d6; background: #fff; }
.barre .coupe { background: #cfe3f1; border-right: 2px solid var(--navy); display: flex; align-items: center; justify-content: center; font-size: 11.5px; font-weight: 650; color: var(--navy); overflow: hidden; white-space: nowrap; }
/* Une teinte par commande (assez claires pour rester lisibles à l'impression). */
.t0 { background: #cfe3f1 !important; } .t1 { background: #fbe3b8 !important; } .t2 { background: #cdebd6 !important; } .t3 { background: #f3cfd8 !important; }
.t4 { background: #ddd3f2 !important; } .t5 { background: #c9ecec !important; } .t6 { background: #f1e9b4 !important; } .t7 { background: #e2e2e2 !important; }
.repere { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(19, 41, 61, .35); margin-right: 7px; vertical-align: -1px; background: #fff; }
.pastille.fois { background: var(--navy); color: #fff; }
.gain { flex-basis: 100%; background: var(--bleu-pale); color: var(--encre); border-radius: 10px; padding: 9px 13px; }
.barre .reste { flex: 1; background: repeating-linear-gradient(135deg, #f1f4f7, #f1f4f7 6px, #e3e9ee 6px, #e3e9ee 12px); display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--sourdine); white-space: nowrap; overflow: hidden; }
.barre .reste.gardee { background: #e6f4ee; color: var(--vert); font-weight: 650; }
.barre ul { list-style: none; margin: 5px 0 0; padding: 0; font-size: 12.5px; columns: 2; column-gap: 28px; }
.barre ol { margin: 5px 0 0; padding-left: 20px; font-size: 12.5px; columns: 2; column-gap: 28px; }

.connexion { max-width: 360px; margin: 9vh auto; }
.connexion .carte { padding: 26px; }
.connexion form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }

.etiquettes { display: none; }
.etiquette { border: 1px solid #000; border-radius: 4px; padding: 8px 10px; break-inside: avoid; font-size: 12px; color: #000; }
.etiquette .long { font-size: 20px; font-weight: 800; }
.etiquette .client { font-weight: 700; }

@media (max-width: 640px) {
  main { padding: 16px 12px 50px; }
  .entete { padding: 0 12px; gap: 6px; }
  .onglet { padding: 11px 9px; }
  .barre ul { list-style: none; margin: 5px 0 0; padding: 0; font-size: 12.5px; columns: 2; column-gap: 28px; }
.barre ol { columns: 1; }
}

@media print {
  .entete, .actions, .sans-impression { display: none !important; }
  html, body { background: #fff; font-size: 12px; }
  main { max-width: none; padding: 0; }
  .carte { box-shadow: none; border: none; padding: 0 0 10px; break-inside: auto; }
  .barre { break-inside: avoid; }
  .barre .coupe, .barre .reste, .repere, .pastille.fois { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body.imprime-etiquettes main > *:not(.etiquettes) { display: none !important; }
  body.imprime-etiquettes .etiquettes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
}

/* ── Écran télé « À faire » : lu de loin, debout. Tout est en em, la taille de
   base suit la largeur de l'écran (≈ 22 px sur une télé 1920 px). */
main:has(> .tele) { max-width: none; padding: 20px 28px 50px; }
.tele { font-size: clamp(15px, 1.15vw, 26px); color: var(--encre); }
.tele .carte { padding: 1em 1.2em; margin-bottom: .9em; }
.tele h2 { font-size: 1.15em; margin-bottom: .7em; }
.tele .btn { font-size: .9em; padding: .55em 1em; }
.tele .btn.gros { font-size: 1.15em; padding: .7em 1.6em; }
.tele .btn.petit { font-size: .75em; }
.tele .message { font-size: .9em; padding: .6em 1em; }
.tele .lien { font-size: inherit; }
.tele-vide { font-size: 1.4em; text-align: center; padding: 2.5em 0; }

.tele-commande { display: flex; align-items: baseline; gap: .4em 1.2em; flex-wrap: wrap; margin-bottom: .7em; }
.tele-commande .rang { flex-basis: 100%; font-size: .85em; font-weight: 650; color: var(--sourdine); text-transform: uppercase; letter-spacing: .06em; }
.tele-commande .titre { display: flex; align-items: baseline; gap: .6em; flex-wrap: wrap; flex: 1; }
.tele-commande .num { font-size: 2.3em; font-weight: 800; letter-spacing: -.02em; }
.tele-commande .client { font-size: 1.6em; font-weight: 600; color: var(--texte); }
.tele-commande .nav { align-self: center; }
.tele-note { font-size: 1.05em !important; }

.tele-grille { display: grid; grid-template-columns: minmax(16em, 1fr) 2.6fr; gap: 0 .9em; align-items: start; }
.batardeau-tele { display: flex; gap: .7em; align-items: flex-start; padding: .55em 0; border-bottom: 1px solid var(--ligne); }
.batardeau-tele:last-child { border-bottom: none; }
.batardeau-tele .repere { width: 1.1em; height: 1.1em; margin: .45em 0 0; flex: none; }
.batardeau-tele .dims { font-size: 1.6em; font-weight: 750; line-height: 1.2; font-variant-numeric: tabular-nums; }
.batardeau-tele .qte { color: var(--bleu); }
.batardeau-tele .detail { font-size: .85em; color: var(--sourdine); }
.tele .orange { color: var(--orange); }
.tele .vert { color: var(--vert); }

.barre-tele { margin-bottom: .9em; }
.barre-tele:last-child { margin-bottom: 0; }
.barre-tele .tete { display: flex; gap: .3em .8em; align-items: baseline; flex-wrap: wrap; margin-bottom: .3em; }
.barre-tele .numero { font-weight: 700; }
.barre-tele .fois { background: var(--navy); color: #fff; border-radius: 99px; padding: .05em .65em; font-weight: 700; }
.barre-tele .source { font-size: .85em; color: var(--sourdine); }
.barre-tele .trace { display: flex; height: 2.6em; border-radius: 8px; overflow: hidden; border: 2px solid #9fb3c3; background: #fff; }
.barre-tele .coupe { border-right: 3px solid var(--navy); display: flex; align-items: center; justify-content: center; gap: .25em; font-size: 1.25em; font-weight: 800; color: var(--navy); overflow: hidden; white-space: nowrap; font-variant-numeric: tabular-nums; }
.barre-tele .coupe small { font-size: .6em; font-weight: 700; opacity: .75; }
.barre-tele .reste { flex: 1; background: repeating-linear-gradient(135deg, #f1f4f7, #f1f4f7 6px, #e3e9ee 6px, #e3e9ee 12px); display: flex; align-items: center; justify-content: center; font-size: .8em; color: var(--sourdine); white-space: nowrap; overflow: hidden; }
.barre-tele .reste.gardee { background: #e6f4ee; color: var(--vert); font-weight: 650; }

.tele-autres { font-size: .9em; color: var(--texte); margin: .2em 0 .9em; }
.tele-actions { justify-content: flex-end; margin-bottom: .9em; }
.tele-ensuite { font-size: .9em; display: flex; flex-wrap: wrap; gap: .3em .5em; align-items: baseline; color: var(--texte); padding-top: .7em; border-top: 1px solid var(--ligne); }
.tele-ensuite > span:first-child { font-weight: 700; color: var(--sourdine); }
.tele-ensuite .sep { color: var(--sourdine); margin: 0 .2em; }
.tele-palettes { border-color: #bfe0cf; background: #f4fbf7; }
.tele-palettes .ligne-palette { display: flex; justify-content: space-between; align-items: center; gap: .6em 1em; flex-wrap: wrap; padding: .3em 0; }
.tele form.palette input { width: 6.5em; font-size: .85em; }
.tele #manque { margin-top: 1em; }
.tele .manquant input { font-size: .85em; }

@media (max-width: 900px) { .tele-grille { grid-template-columns: 1fr; } }
@media print {
  .tele { font-size: 12px; }
  body.imprime-etiquettes .tele > *:not(.etiquettes) { display: none !important; }
  body.imprime-etiquettes .tele .etiquettes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; font-size: 12px; }
  .barre-tele .coupe, .barre-tele .reste, .batardeau-tele .repere { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.poids-calcule { display: inline-block; font-weight: 700; color: var(--encre); background: #eef1f4; border-radius: 8px; padding: 6px 10px; white-space: nowrap; }

/* ── Factures de l'atelier ── */
.table-grille input, .table-grille select { width: 100%; min-width: 70px; }
.table-grille td:first-child input { min-width: 210px; }
.table-grille select { min-width: 135px; }
.table-grille td.paire { white-space: nowrap; }
.table-grille td.paire input { width: 72px; min-width: 0; }
.table-grille td.paire input + input { margin-left: 4px; }
.facture-doc { max-width: 900px; }
.facture-tete { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 22px; line-height: 1.5; }
.facture-societe { font-size: 18px; font-weight: 750; color: var(--encre); }
.facture-ref { text-align: right; }
.facture-titre { font-size: 22px; font-weight: 800; letter-spacing: .08em; color: var(--encre); }
.facture-auto { font-weight: 700; text-transform: uppercase; letter-spacing: .06em; font-size: 12px; color: var(--sourdine); margin-bottom: 6px; }
.facture-client { border: 1px solid var(--ligne); border-radius: 10px; padding: 12px 14px; margin: 0 0 18px auto; max-width: 340px; line-height: 1.5; }
.facture-totaux { margin: 14px 0 0 auto; max-width: 300px; }
.facture-totaux div { display: flex; justify-content: space-between; padding: 4px 0; }
.facture-totaux .ttc { border-top: 2px solid var(--encre); margin-top: 4px; padding-top: 8px; font-size: 17px; }
.facture-mentions { margin-top: 22px; color: var(--sourdine); }
@media print {
  body.imprime-facture main > *:not(.facture-doc) { display: none !important; }
  body.imprime-facture .facture-doc { max-width: none; font-size: 12px; }
}

/* ── Chrono des 48 h ── */
.chrono { display: inline-block; font-variant-numeric: tabular-nums; font-weight: 700; color: var(--encre); background: #eef1f4; border-radius: 8px; padding: 2px 8px; white-space: nowrap; font-size: .92em; }
.chrono small { font-weight: 500; color: var(--sourdine); margin-left: 4px; }
.chrono.bientot { background: #fbf1e2; color: var(--orange); }
.chrono.retard { background: #f9e9e7; color: var(--rouge); }
.chrono.fini { background: #e6f4ee; color: var(--vert); }
.tele-chrono { flex-basis: 100%; }
.tele-chrono .chrono { font-size: 1.5em; padding: .15em .5em; }
.valeur.rouge { color: var(--rouge); }

/* ── Contrôle avant palette ── */
.modale { position: fixed; inset: 0; background: rgba(22, 40, 58, .55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modale-carte { width: 100%; max-width: 620px; max-height: calc(100vh - 32px); overflow-y: auto; font-size: 18px; margin: 0; }
.modale-carte h2 { font-size: 1.5em; margin-bottom: .6em; }
.modale-etape { font-size: .78em; font-weight: 650; color: var(--sourdine); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.modale-liste { list-style: none; padding: 0; margin: 0 0 18px; }
.modale-liste li { padding: 10px 0; border-bottom: 1px solid var(--ligne); font-size: 1.15em; }
.modale-liste li:last-child { border-bottom: none; }
.modale-actions { justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.modale-carte .btn.gros { font-size: 1.05em; padding: 12px 20px; }
.modale-carte textarea { width: 100%; font: inherit; padding: 8px 10px; border: 1px solid var(--ligne); border-radius: 8px; margin-top: 6px; }
.modale-carte .case { display: flex; align-items: center; gap: 10px; margin: 14px 0 8px; font-weight: 600; }
.modale-carte .case input { width: 22px; height: 22px; }

/* ── Feuilles de coupe du jour : une par page, seulement à l'impression ── */
.feuilles-jour { display: none; }
.feuille-tete { font-size: .85em; font-weight: 650; color: var(--sourdine); text-transform: uppercase; letter-spacing: .05em; margin-bottom: .5em; }
@media print {
  body.imprime-jour .tele > *:not(.feuilles-jour) { display: none !important; }
  body.imprime-jour .feuilles-jour { display: block; }
  .feuille { break-after: page; }
  .feuille:last-child { break-after: auto; }
  .modale { display: none !important; }
}
[hidden] { display: none !important; }
.modale-carte label { font-size: 15px; }
.modale-carte .case { flex-direction: row; color: var(--texte); }
.modale-carte input:not([type=checkbox]) { font-size: 17px; padding: 10px 12px; }
.tele-chrono > .sourdine { font-size: .85em; font-weight: 600; margin-right: .4em; }
.btn.principal.danger { background: var(--rouge); border-color: var(--rouge); color: #fff; }
.btn.principal.danger:hover { background: #a8443d; }
.modale-carte > p { font-size: 1.05em; }
.modale-carte label input { margin-top: 6px; }
/* Grandes fenêtres, lisibles debout devant l'écran de l'atelier (23/10). */
.modale-carte { max-width: 880px; font-size: 22px; padding: 34px 38px; }
.modale-carte h2 { font-size: 1.6em; }
.modale-carte p { font-size: .9em; }
.modale-liste li { font-size: 1.2em; padding: 14px 0; }
.modale-carte .btn { font-size: .85em; padding: 14px 22px; }
.modale-carte .btn.gros { font-size: 1em; padding: 18px 30px; }
.modale-carte label { font-size: .8em; }
.modale-carte input:not([type=checkbox]) { font-size: 1em; padding: 14px 16px; }
.modale-carte .case { font-size: .85em; }
.modale-carte .case input { width: 28px; height: 28px; }
.modale-carte textarea { font-size: .9em; }
