:root {
  --fond: #f4f5f7; --carte: #fff; --texte: #1f2430; --doux: #5f6b7a; --ligne: #dde1e7; --primaire: #1d5fbf;
  --primaire-doux: #e6eefb; --urgent: #c62828; --ok: #2e7d32; --attention: #b26a00; --rayon: 8px;
  --faclim-primaire: #1d5fbf;
  color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--texte); background: var(--fond); }
a { color: var(--primaire); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0 0 12px; }
h2 { font-size: 16px; margin: 20px 0 8px; }
h3 { font-size: 14px; margin: 12px 0 6px; }
button, .bouton { font: inherit; border: 1px solid var(--ligne); background: #fff; color: var(--texte); padding: 6px 12px;
  border-radius: 6px; cursor: pointer; }
button:hover { border-color: var(--primaire); }
button.primaire { background: var(--primaire); border-color: var(--primaire); color: #fff; }
button.danger { color: var(--urgent); }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; padding: 6px 8px; border: 1px solid var(--ligne); border-radius: 6px; background: #fff; }
textarea { width: 100%; min-height: 110px; font-family: ui-monospace, Consolas, monospace; }
table { border-collapse: collapse; width: 100%; background: var(--carte); }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--ligne); vertical-align: top; }
th { font-weight: 600; color: var(--doux); font-size: 12px; text-transform: uppercase; letter-spacing: .02em; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
.doux { color: var(--doux); }
.petit { font-size: 12px; }
.ligne { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.espace { flex: 1; }
.bloc { background: var(--carte); border: 1px solid var(--ligne); border-radius: var(--rayon); padding: 14px; margin-bottom: 14px; }
.badge { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 12px; background: var(--primaire-doux); color: var(--primaire); }
.badge.urgent { background: #fdecea; color: var(--urgent); }
.badge.ok { background: #e8f5e9; color: var(--ok); }
.badge.attention { background: #fff4e5; color: var(--attention); }
.badge.panne { background: #fdecea; color: var(--urgent); }

header#barre { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 18px; padding: 0 16px; height: 48px;
  background: #18202c; color: #fff; }
header .marque { color: #fff; font-size: 15px; }
header nav { display: flex; gap: 4px; }
header nav a { color: #cfd6e0; padding: 6px 10px; border-radius: 6px; }
header nav a.actif, header nav a:hover { background: #2a3546; color: #fff; text-decoration: none; }
header .droite { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.moi summary { cursor: pointer; list-style: none; color: #cfd6e0; }
.moi[open] .menu-moi { position: absolute; right: 16px; top: 44px; background: #fff; color: var(--texte); border: 1px solid var(--ligne);
  border-radius: var(--rayon); padding: 6px; display: flex; flex-direction: column; min-width: 180px; box-shadow: 0 4px 16px #0002; }
.menu-moi a, .menu-moi button { padding: 8px 10px; border: 0; text-align: left; background: none; color: var(--texte); }
.menu-moi a:hover, .menu-moi button:hover { background: var(--fond); text-decoration: none; }
main { padding: 16px; max-width: 1700px; margin: 0 auto; }

#connexion { max-width: 360px; margin: 12vh auto; background: #fff; padding: 28px; border-radius: 12px; border: 1px solid var(--ligne); }
#connexion label { display: block; margin: 12px 0 4px; color: var(--doux); }
#connexion input { width: 100%; }
#connexion button { width: 100%; margin-top: 18px; }

.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 8px; }
.colonne { background: #e9ecf1; border-radius: var(--rayon); padding: 8px; min-height: 60vh; }
.colonne.cible { outline: 2px dashed var(--primaire); }
.colonne h2 { margin: 2px 4px 8px; font-size: 13px; display: flex; justify-content: space-between; }
.carte { background: #fff; border-radius: 6px; padding: 8px 10px; margin-bottom: 8px; border: 1px solid var(--ligne); cursor: pointer; }
.carte:hover { border-color: var(--primaire); }
.carte.urgent { border-left: 4px solid var(--urgent); }
.carte .titre { display: flex; justify-content: space-between; font-weight: 600; }
.carte .client { margin-top: 2px; }
.carte .meta { display: flex; gap: 8px; color: var(--doux); font-size: 12px; margin-top: 4px; flex-wrap: wrap; }
.carte[draggable="true"] { cursor: grab; }

.fiche-tete { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.fiche-tete .montants { margin-left: auto; text-align: right; }
.zone-depot { border: 2px dashed var(--ligne); border-radius: var(--rayon); padding: 18px; text-align: center; color: var(--doux); }
.zone-depot.survol { border-color: var(--primaire); background: var(--primaire-doux); }
.onglets { display: flex; gap: 4px; border-bottom: 1px solid var(--ligne); margin: 14px 0; }
.onglets button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; }
.onglets button.actif { border-bottom-color: var(--primaire); color: var(--primaire); }

.grille-saisie { overflow-x: auto; }
.grille-saisie input { width: 70px; padding: 3px 4px; }
.grille-saisie input.large { width: 140px; }
.grille-saisie td, .grille-saisie th { padding: 2px 3px; }
.erreurs { color: var(--urgent); }
.alerte { color: var(--attention); }

.jours { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 10px; }
.bon { background: #fff; border: 1px solid var(--ligne); border-radius: 6px; padding: 8px 10px; margin-bottom: 8px; }
.bon.fait { opacity: .6; }
.bon.fait .titre { text-decoration: line-through; }
.bon.retard { border-left: 4px solid var(--urgent); }
.bandeau-retard { background: #fdecea; color: var(--urgent); padding: 8px 12px; border-radius: var(--rayon); margin-bottom: 10px; cursor: pointer; }

.interrupteur { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--ligne); }
.interrupteur:last-child { border-bottom: 0; }
.interrupteur .texte { flex: 1; }

.modale-fond { position: fixed; inset: 0; background: #0006; display: flex; align-items: center; justify-content: center; z-index: 20; }
.modale { background: #fff; border-radius: 12px; padding: 20px; width: min(560px, 92vw); max-height: 90vh; overflow: auto; }
.modale label { display: block; margin: 10px 0 4px; color: var(--doux); }
.modale input, .modale textarea, .modale select { width: 100%; }
.resultats-client { border: 1px solid var(--ligne); border-radius: 6px; margin-top: 4px; max-height: 220px; overflow: auto; }
.resultats-client div { padding: 6px 8px; cursor: pointer; }
.resultats-client div:hover, .resultats-client div.choisi { background: var(--primaire-doux); }

#toasts { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 30; }
.toast { background: #18202c; color: #fff; padding: 10px 14px; border-radius: 8px; max-width: 420px; box-shadow: 0 4px 16px #0003; }
.toast.erreur { background: var(--urgent); }
faclim-messagerie { display: block; height: 70vh; }

@media (max-width: 700px) {
  header#barre { gap: 8px; padding: 0 8px; }
  header nav a { padding: 6px; }
  main { padding: 10px; }
}
