:root {
  --fond: #f4f6f8; --carte: #fff; --texte: #1b2430; --doux: #5b6675; --ligne: #dde2e8;
  --bleu: #1f4e79; --bleu-clair: #e6eef6; --vert: #1d7a46; --vert-clair: #e3f3ea;
  --orange: #b85c00; --orange-clair: #fdf0e1; --rouge: #b42318; --rouge-clair: #fdecea;
  --rayon: 10px;
  --violet: #6b3fa0; --violet-clair: #f2ebfa; --cyan: #0e6a80; --cyan-clair: #e1f3f7; --gris: #5b6675; --gris-clair: #eef0f3;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--texte); background: var(--fond); }
a { color: var(--bleu); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 14px; }
h2 { font-size: 17px; margin: 22px 0 10px; }
.muted { color: var(--doux); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Barre du haut */
.top { display: flex; align-items: center; gap: 18px; padding: 0 18px; height: 52px; background: var(--bleu); color: #fff; position: sticky; top: 0; z-index: 10; }
.top a { color: #dfe9f3; }
.top a.actif, .top a:hover { color: #fff; text-decoration: none; }
.top .marque { font-weight: 700; color: #fff; white-space: nowrap; }
.tablette .top { font-size: 15px; }
.top nav { scrollbar-width: none; }
.top nav { display: flex; gap: 16px; overflow-x: auto; }
.top .droite { margin-left: auto; display: flex; gap: 12px; align-items: center; white-space: nowrap; }
.top select { background: #2c6295; color: #fff; border: 0; border-radius: 6px; padding: 5px 8px; font: inherit; }
main { max-width: 1280px; margin: 0 auto; padding: 20px 18px 60px; }

/* Cartes et indicateurs */
.cartes { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 18px; }
.carte { background: var(--carte); border: 1px solid var(--ligne); border-radius: var(--rayon); padding: 14px 16px; }
.carte .val { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.carte .lib { color: var(--doux); font-size: 13px; }
.carte.alerte { border-color: #f2c48d; background: var(--orange-clair); }
.bloc { background: var(--carte); border: 1px solid var(--ligne); border-radius: var(--rayon); padding: 14px 16px; margin-bottom: 16px; }

/* Tableaux */
.table-wrap { overflow-x: auto; background: var(--carte); border: 1px solid var(--ligne); border-radius: var(--rayon); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--ligne); text-align: left; vertical-align: top; }
th { background: #f9fafb; font-weight: 600; font-size: 13px; color: var(--doux); position: sticky; top: 0; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f9fbfd; }
tfoot td { font-weight: 700; background: #f9fafb; }

/* Formulaires */
.filtres { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
input[type=text], input[type=search], input[type=number], input[type=date], input[type=password], select, textarea {
  font: inherit; padding: 8px 10px; border: 1px solid #c3cbd5; border-radius: 8px; background: #fff; color: var(--texte); }
input:focus, select:focus { outline: 2px solid #8fb4dc; border-color: var(--bleu); }
.filtres input[type=search] { min-width: 260px; flex: 1; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--bleu); background: var(--bleu); color: #fff; cursor: pointer; text-decoration: none !important; }
.btn.sec { background: #fff; color: var(--bleu); }
.btn.danger { background: var(--rouge); border-color: var(--rouge); }
.btn.petit { padding: 4px 10px; font-size: 13px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--bleu-clair); color: var(--bleu); white-space: nowrap; }
.badge.orange { background: var(--orange-clair); color: var(--orange); }
.badge.rouge { background: var(--rouge-clair); color: var(--rouge); }
.badge.vert { background: var(--vert-clair); color: var(--vert); }
.messages { list-style: none; padding: 0; margin: 0 0 14px; }
.messages li { padding: 10px 14px; border-radius: 8px; margin-bottom: 6px; background: var(--vert-clair); color: var(--vert); font-weight: 600; }
.messages li.error { background: var(--rouge-clair); color: var(--rouge); }
.pagination { display: flex; gap: 10px; align-items: center; margin-top: 10px; }
.entete { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.entete h1 { margin: 0; }
.entete .actions { margin-left: auto; display: flex; gap: 8px; }
.grille2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
dl.fiche { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.fiche dt { color: var(--doux); }
dl.fiche dd { margin: 0; }
.chargement { opacity: .55; transition: opacity .1s; }

/* Tablette : grands boutons, lisibles en plein jour */
body.tablette { font-size: 18px; background: #eef1f4; }
.tablette main { max-width: 900px; }
.tablette h1 { font-size: 26px; }
.tuiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.tuile { display: flex; flex-direction: column; justify-content: center; min-height: 120px; padding: 20px; border-radius: 14px; background: var(--bleu); color: #fff !important; font-size: 26px; font-weight: 700; text-decoration: none !important; box-shadow: 0 2px 0 rgba(0,0,0,.15); }
.tuile small { font-size: 15px; font-weight: 500; opacity: .85; }
.tuile.vert { background: var(--vert); }
.tuile.orange { background: var(--orange); }
.tuile.gris { background: #4a5563; }
.tuile.inactive { background: #9aa4b1; }
.choix { display: flex; flex-direction: column; gap: 10px; }
.choix a, .choix button.ligne { display: flex; align-items: center; gap: 14px; width: 100%; padding: 16px 18px; min-height: 64px; background: #fff; border: 2px solid var(--ligne); border-radius: 12px; color: var(--texte); font: inherit; text-align: left; cursor: pointer; text-decoration: none !important; }
.choix a:active, .choix button.ligne:active { background: var(--bleu-clair); border-color: var(--bleu); }
.choix .code { font-weight: 700; font-size: 20px; min-width: 110px; }
.choix .detail { color: var(--doux); font-size: 15px; }
.choix .droite { margin-left: auto; text-align: right; white-space: nowrap; }
.grande-recherche { width: 100%; font-size: 22px !important; padding: 14px 16px !important; border-radius: 12px !important; border-width: 2px !important; margin-bottom: 14px; }
.tablette .btn { font-size: 20px; padding: 14px 22px; border-radius: 12px; min-height: 58px; }
.gros-champ { font-size: 34px !important; width: 220px; text-align: center; padding: 10px !important; border-width: 2px !important; }
.pastilles { display: flex; flex-wrap: wrap; gap: 10px; }
.pastilles label { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border: 2px solid var(--ligne); border-radius: 12px; background: #fff; cursor: pointer; }
.pastilles input { width: 22px; height: 22px; }
.pastilles label:has(input:checked) { border-color: var(--bleu); background: var(--bleu-clair); }
.confirmation { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-radius: 12px; background: var(--vert-clair); color: var(--vert); font-weight: 700; margin-bottom: 16px; border: 2px solid #9ed3b3; }
.confirmation .alerte { color: var(--orange); font-weight: 600; display: block; }
.confirmation form { margin-left: auto; }
.fil { font-size: 16px; margin-bottom: 10px; }

@media (max-width: 700px) {
  .top { gap: 10px; padding: 0 10px; }
  .top .marque { display: none; }
  main { padding: 14px 12px 50px; }
  .filtres input[type=search] { min-width: 0; width: 100%; }
  .entete .actions { margin-left: 0; }
}
@media print { .top, .filtres, .actions, .pagination { display: none !important; } body { background: #fff; } }
.tablette .top .btn { font-size: 13px; padding: 4px 10px; min-height: 0; border-radius: 8px; }

/* Logos */
.top .marque { display: flex; align-items: center; gap: 10px; }
.top .logo { display: inline-flex; align-items: center; background: #fff; border-radius: 8px; padding: 3px 8px; height: 40px; }
.top .logo img { height: 34px; width: auto; display: block; }
.logo-grand { height: 90px; width: auto; display: block; }
.tuile-societe { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 26px; border-radius: 14px; background: #fff; border: 2px solid var(--ligne); cursor: pointer; font: inherit; font-size: 20px; font-weight: 700; color: var(--texte); }
.tuile-societe:hover, .tuile-societe:focus { border-color: var(--bleu); background: var(--bleu-clair); }
.tuile-societe img { height: 120px; width: auto; }

/* Onglets */
.onglets { display: flex; gap: 4px; border-bottom: 2px solid var(--ligne); margin-bottom: 12px; }
.onglets a { padding: 8px 16px; border-radius: 8px 8px 0 0; color: var(--doux); font-weight: 600; margin-bottom: -2px; border-bottom: 2px solid transparent; }
.onglets a.actif { color: var(--bleu); border-bottom-color: var(--bleu); background: #fff; }
.onglets a:hover { text-decoration: none; color: var(--bleu); }

/* Bon multi-produits */
.bon-tete { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px 18px; align-items: end; }
.bon-tete label { display: block; font-size: 15px; color: var(--doux); margin-bottom: 4px; }
.bon-tete select, .bon-tete input { width: 100%; font-size: 18px; padding: 10px 12px; }
.chantier-choisi { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 2px solid var(--bleu); border-radius: 10px; background: var(--bleu-clair); font-weight: 700; }
.chantier-choisi .detail { font-weight: 400; color: var(--doux); }
table.lignes td { vertical-align: middle; }
table.lignes .qte { width: 110px; font-size: 22px; text-align: center; padding: 8px; }
table.lignes select { font-size: 16px; padding: 8px; max-width: 170px; }
table.lignes input[type=checkbox] { width: 30px; height: 30px; }
table.lignes tr.cochee { background: #eef6ff; }
table.lignes .repere { cursor: pointer; }
.choix-rapide { position: relative; }
.choix-rapide .resultats { position: absolute; z-index: 5; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--ligne); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 360px; overflow-y: auto; }
.choix-rapide .resultats:empty { display: none; }
.choix-rapide .resultats button { display: flex; width: 100%; gap: 12px; text-align: left; border: 0; border-bottom: 1px solid var(--ligne); background: #fff; padding: 12px 14px; font: inherit; cursor: pointer; }
.choix-rapide .resultats button:hover { background: var(--bleu-clair); }
.barre-validation { position: sticky; bottom: 0; background: #eef1f4; padding: 12px 0; display: flex; gap: 12px; align-items: center; border-top: 1px solid var(--ligne); margin-top: 12px; }

/* Impression d'un bon */
.bon-doc { background: #fff; border: 1px solid var(--ligne); border-radius: var(--rayon); padding: 24px; }
.bon-doc header { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 18px; }
.bon-doc .signatures { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 30px; }
.bon-doc .signatures div { border-top: 1px solid #999; padding-top: 6px; min-height: 70px; color: var(--doux); }
@media print { .bon-doc { border: 0; padding: 0; } .no-print { display: none !important; } main { padding: 0; } }
.bon-tete input[type=checkbox] { width: 22px; height: 22px; }
.bandeau-essai { background: #e8590c; color: #fff; text-align: center; font-weight: 700; padding: 6px 10px; letter-spacing: .03em; }
.bon-doc { font-size: 13px; }
.bon-doc th, .bon-doc td { padding: 5px 8px; }

/* Flottant : facturé, pas encore arrivé. Violet tant que le revient manque, bleu-vert une fois le revient saisi. */
.flot { color: var(--violet); font-weight: 600; }
.badge.flot { background: var(--violet-clair); color: var(--violet); }
.badge.flot-rev { background: var(--cyan-clair); color: var(--cyan); }
.badge.cde { background: var(--gris-clair); color: var(--gris); }
tr.flot > td { background: var(--violet-clair); }
tr.flot-rev > td { background: var(--cyan-clair); }
tr.cde > td { color: var(--gris); }
.carte.flot { border-color: #d8c6ef; background: var(--violet-clair); }
.carte.flot .val { color: var(--violet); }
.legende { display: flex; gap: 10px; flex-wrap: wrap; margin: 6px 0 12px; font-size: 13px; }
tr.groupe > th { background: var(--fond); text-align: left; font-size: 14px; padding-top: 14px; border-top: 2px solid var(--ligne); }
button.badge { border: 0; font: inherit; font-size: 12px; cursor: pointer; margin-left: 6px; }
td.nowrap, th.nowrap { white-space: nowrap; }
.muted.petit { font-size: 12px; }
@media (max-width: 900px) { .col-prix { display: none; } }  /* tablette : la valeur suffit */
/* Menu : passe à la ligne plutôt que de couper « Emplacements » ou les suivants sur un écran étroit */
.top { height: auto; min-height: 52px; padding-top: 6px; padding-bottom: 6px; }
.top nav { flex-wrap: wrap; overflow: visible; row-gap: 4px; flex: 1; min-width: 0; }
.top nav a { white-space: nowrap; }
input::placeholder { text-transform: none; }
.serre th, .serre td { padding: 7px 7px; }
