/* Espace de travail des campagnes.
   Reprend les composants existants (.panel, .tbl, .chip, .btn) et ajoute ce que
   le traitement en volume demande : progression, filtres, panneau lateral,
   messages. Aucune couleur en dur : tout vient de tokens.css. */

/* Les ecrans de lecture gardent leur colonne de 900 px ; un tableau de deux
   cents contrats, lui, prend la largeur disponible. */
.content.large { max-width: 1280px; }

.ws { display: grid; gap: 18px; }

.ws-tete { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.ws-tete h2 { font-size: 20px; font-weight: 800; letter-spacing: -.01em; margin-top: 4px; }
.ws-tete .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ws-2col { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }

/* --- Formulaire de selection --- */
.champ { display: grid; gap: 6px; margin-bottom: 12px; }
.champ > span { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.champ select, .champ input {
  font-family: var(--sans); font-size: 14.5px; color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 9px 11px; background: var(--surface);
}
.aide { font-size: 12.5px; color: var(--muted); margin: 6px 0 12px; }
.compte-selection { font-size: 16px; margin-bottom: 10px; }
.puces { display: flex; flex-wrap: wrap; gap: 6px; max-height: 190px; overflow-y: auto; }
.puce {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px;
  background: var(--surface2); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 3px 6px 3px 10px;
}
.puce button { border: 0; background: none; color: var(--muted); font-size: 15px; line-height: 1; padding: 0 3px; }
.puce button:hover { color: var(--ko); }
.puce.muet { color: var(--muted); padding-right: 10px; }
.reduire { display: flex; align-items: center; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.reduire > span:first-child { font-size: 13px; }
.reduire .aide { margin: 0; }

/* --- Devis --- */
.devis { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.devis > div { display: grid; gap: 3px; }
.devis b { font-size: 24px; font-weight: 800; letter-spacing: -.02em; color: var(--blue-d); }
.etq { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.jauge { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; margin-top: 6px; }
.jauge i { display: block; height: 100%; background: var(--blue); }
.avert { font-size: 13px; color: var(--gold); background: var(--warnb); border-radius: var(--r-sm); padding: 9px 12px; margin-top: 10px; }
.refus { font-size: 13.5px; background: var(--kob); color: var(--red-ink); border-radius: var(--r-sm); padding: 12px 14px; margin-top: 10px; }
.refus ul { margin: 6px 0 0 18px; }

/* --- Progression : une barre empilee par statut --- */
.progression { display: grid; gap: 6px; }
.barre { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--line); }
.barre .seg { display: block; height: 100%; }
.barre .seg.ok { background: var(--ok); }
.barre .seg.warn { background: var(--warn); }
.barre .seg.ko { background: var(--ko); }
.barre .seg.ro { background: var(--ro); }
.sous { font-size: 12.5px; color: var(--muted); }
.bandeau-pause {
  font-size: 13.5px; background: var(--warnb); color: var(--gold);
  border-radius: var(--r-sm); padding: 11px 14px;
}

/* --- Filtres --- */
.filtres { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* --- Tables --- */
.tbl tr.cliquable { cursor: pointer; }
.tbl tr.cliquable:hover { background: var(--blue-l); }
.tbl .sous { display: block; }

/* --- Etats vides et chargement --- */
.etat-vide { text-align: center; padding: 38px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.ev-titre { font-size: 15.5px; font-weight: 700; }
.ev-detail { font-size: 13.5px; color: var(--muted); max-width: 52ch; margin: 8px auto 14px; }
.fantomes { display: grid; gap: 8px; }
.fantome { height: 38px; border-radius: var(--r-sm); background: linear-gradient(90deg, var(--surface2), var(--line), var(--surface2)); background-size: 200% 100%; animation: glisse 1.4s infinite; }
@keyframes glisse { to { background-position: -200% 0; } }

/* --- Panneau lateral : le rapport sans quitter la liste --- */
.panneau {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 94vw); z-index: 70;
  background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--sh-3);
  transform: translateX(105%); transition: transform .25s var(--ease); overflow-y: auto;
}
.panneau.on { transform: none; }
.panneau-tete {
  position: sticky; top: 0; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px;
}
.panneau-tete h3 { font-family: var(--mono); font-size: 15px; }
.panneau-fermer { border: 1px solid var(--line); background: var(--surface2); border-radius: var(--r-sm); padding: 6px 11px; font-size: 12px; }
.panneau-corps { padding: 18px 20px 40px; }

/* --- Rapport --- */
.rapport { display: grid; gap: 14px; }
.rapport-tete { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.encart { background: var(--warnb); border-radius: var(--r-sm); padding: 12px 14px; font-size: 13.5px; }
.encart.ko { background: var(--kob); color: var(--red-ink); }
.encart p { margin-top: 4px; }
.couverture { background: var(--surface2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 11px 14px; }
.couverture .aide { margin: 4px 0 0; }
.groupe { display: grid; gap: 10px; }
.groupe h4 { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
details.groupe > summary { cursor: pointer; font-size: 13px; color: var(--blue-3); padding: 8px 0; }
.ctl { border-left: 3px solid var(--line); padding: 2px 0 2px 12px; display: grid; gap: 5px; font-size: 13.5px; }
.ctl header { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.ctl .ecart { color: var(--ko); }
.ctl .manque { color: var(--ro); }
.ctl .action { color: var(--blue-3); }
.liste-simple { margin-left: 18px; font-size: 13px; display: grid; gap: 4px; }

/* --- Tri par famille : l'inattendu d'abord --- */
.panel.alerte { border-color: var(--ko); }
.panel.alerte .hd h3 { color: var(--red-ink); }
.panel.replie > summary {
  cursor: pointer; padding: 14px 18px; font-size: 13.5px; color: var(--ink2);
  background: var(--surface2); border-radius: var(--r);
}
.panel.replie[open] > summary { border-radius: var(--r) var(--r) 0 0; border-bottom: 1px solid var(--line); }

.famille { border-top: 1px solid var(--line); padding: 14px 0; display: grid; gap: 6px; }
.famille:first-of-type { border-top: 0; }
.famille-tete { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.famille-tete b { font-size: 14.5px; }
.famille-ecart { font-size: 13.5px; color: var(--ink2); }
.famille-actions { display: flex; gap: 8px; margin-top: 4px; flex-wrap: wrap; }

/* Matrice point x statut : la densite est le sujet, pas la decoration. */
.tbl td.cell-ko { background: var(--kob); color: var(--ko); font-weight: 600; }
.tbl td.cell-warn { background: var(--warnb); color: var(--gold); font-weight: 600; }
.tbl td.cell-ro { background: var(--rob); color: var(--ro); }
.tbl td.cell-ok { color: var(--ok); }

/* --- Messages --- */
.messages { position: fixed; bottom: 20px; left: calc(50% + (var(--sbw) / 2)); transform: translateX(-50%); z-index: 90; display: grid; gap: 8px; }
.msg {
  display: flex; align-items: center; gap: 12px; background: var(--ink); color: #fff;
  border-radius: var(--r-sm); padding: 10px 14px; font-size: 13.5px; box-shadow: var(--sh-2);
}
.msg-erreur { background: var(--red-ink); }
.msg-action { border: 1px solid rgba(255,255,255,.4); background: none; color: inherit; border-radius: 7px; padding: 3px 9px; font-size: 12px; }

@media (max-width: 860px) {
  .messages { left: 50%; }
}
@media (prefers-reduced-motion: reduce) {
  .panneau { transition: none; }
  .fantome { animation: none; }
}
