:root {
  --pri: #008486; --pri-dark: #006a6b; --sec: #8FE9D2;
  --bord: #e6e8eb; --fond: #f0f0f0; --texte: #333; --muted: #828d99;
  --c-fusionner: #1f9d55; --c-traiter: #008486; --c-relancer: #e8870e; --c-bloque: #d64545; --c-tickets: #6f5bd3; --c-encours: #9aa5b1;
}
body { background: var(--fond); color: var(--texte); font-size: 14px; }
a { color: var(--pri-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
.text-muted-e { color: var(--muted); }
.nowrap { white-space: nowrap; }
.b-fusionner { --c: var(--c-fusionner); } .b-traiter { --c: var(--c-traiter); } .b-relancer { --c: var(--c-relancer); }
 .b-dormant { --c: #b0a58f; }

.entete { background: #fff; border-bottom: 1px solid var(--bord); padding: 14px 24px; display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; position: sticky; top: 0; z-index: 10; }
.entete h1 { font-size: 18px; margin: 0; font-weight: 600; }
.entete h1 i { color: var(--pri); margin-right: 6px; }
.entete .sous { color: var(--muted); font-size: 12px; }
.entete .droite { margin-left: auto; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.pipe { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pipe-ok { background: #e3f5ea; color: #16733d; } .pipe-ko { background: #fde8e8; color: #a82828; } .pipe-wait { background: #eef1f4; color: var(--muted); }
.stat { font-size: 12px; color: var(--muted); } .stat strong { color: var(--texte); }
.filtre { width: 220px; border-radius: 8px; font-size: 13px; }
.filtre:focus { border-color: var(--pri); box-shadow: 0 0 0 .2rem rgba(0,132,134,.15); }

main { padding: 20px 24px 40px; }
.tuiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.tuile { background: #fff; border: 1px solid var(--bord); border-radius: 14px; padding: 12px 16px; display: flex; gap: 12px; align-items: center; box-shadow: 0 1px 3px rgba(0,0,0,.04); border-left: 4px solid var(--c); }
.tuile i { color: var(--c); font-size: 20px; width: 24px; text-align: center; }
.t-n { font-size: 24px; font-weight: 700; line-height: 1; } .t-l { color: var(--muted); font-size: 12px; margin-top: 2px; }

.onglets { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--bord); }
.onglet { background: none; border: 0; padding: 8px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.onglet.actif { color: var(--pri-dark); border-bottom-color: var(--pri); }
.panneau { display: none; } .panneau.actif { display: block; }

.colonnes { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; align-items: start; }
.col-b { background: #f7f8f9; border: 1px solid var(--bord); border-radius: 14px; overflow: hidden; }
.col-h { background: #fff; padding: 10px 12px; border-bottom: 1px solid var(--bord); border-top: 3px solid var(--c); display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.col-h i { color: var(--c); } .col-h h2 { font-size: 14px; font-weight: 600; margin: 0; }
.compte { margin-left: auto; background: var(--c); color: #fff; border-radius: 999px; padding: 0 8px; font-size: 12px; font-weight: 700; }
.col-aide { width: 100%; color: var(--muted); font-size: 11px; }
.col-corps { padding: 8px; display: flex; flex-direction: column; gap: 8px; max-height: calc(100vh - 290px); overflow-y: auto; }

.item { background: #fff; border: 1px solid var(--bord); border-left: 3px solid var(--c); border-radius: 10px; padding: 8px 10px; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.item-top { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.num { display: inline-block; min-width: 22px; text-align: center; background: #eef1f4; color: var(--muted); border-radius: 6px; font-size: 11px; font-weight: 700; padding: 0 4px; }
.ref { font-weight: 700; } .age { margin-left: auto; color: var(--muted); font-size: 11px; white-space: nowrap; }
.titre { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--texte); font-weight: 500; margin: 4px 0 2px; line-height: 1.3; }
.raison { color: var(--c); font-weight: 600; font-size: 12px; }
.reserve { color: #a0620a; font-size: 11px; margin-top: 2px; }
.meta { display: flex; align-items: center; gap: 4px; margin-top: 6px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.ext { margin: 6px 0 0; padding: 4px 8px; border-left: 2px solid var(--bord); color: #555; font-size: 12px; font-style: italic; background: #fafbfb; border-radius: 0 6px 6px 0; }
.ext-aut { font-style: normal; color: var(--muted); }
.bds { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; } .bds:empty { display: none; }
.bd { font-size: 10.5px; padding: 1px 7px; border-radius: 999px; background: #eef1f4; color: #55606b; font-weight: 600; white-space: nowrap; }
.bd-new { background: var(--sec); color: #064d4e; } .bd-relance { background: #fdefd9; color: #9a5a05; }
.bd-urgent { background: #fde8e8; color: #a82828; } .bd-prio { background: #eef1f4; color: #55606b; } .bd-test { background: #e8f3f3; color: var(--pri-dark); }

.av { --h: 180; display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; background: hsl(var(--h) 45% 88%); color: hsl(var(--h) 45% 30%); font-size: 9px; font-weight: 700; flex: none; }
.av.lg { width: 36px; height: 36px; font-size: 13px; }

.bas { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; margin-top: 18px; }
.bloc { background: #fff; border: 1px solid var(--bord); border-radius: 14px; padding: 12px 16px; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.bloc h2 { font-size: 14px; font-weight: 600; margin: 0 0 8px; } .bloc h2 i { color: var(--pri); margin-right: 6px; }
.table-e { width: 100%; font-size: 13px; } .table-e td { padding: 5px 6px; border-top: 1px solid var(--bord); vertical-align: top; }
.table-e tr:first-child td { border-top: 0; } .num-cell { width: 30px; }
.lien-titre { color: var(--texte); }
.pastille { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c); margin-right: 6px; }
.venir { list-style: none; padding: 0; margin: 0; font-size: 13px; } .venir li { padding: 4px 0; border-top: 1px solid var(--bord); }
.venir li:first-child { border-top: 0; } .quand { font-weight: 700; color: var(--pri-dark); margin-right: 8px; }
.p-titre-inline { color: #555; }
.vide { color: var(--muted); font-size: 12px; margin: 4px 2px; font-style: italic; }

.personnes { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; align-items: start; }
.personne { background: #fff; border: 1px solid var(--bord); border-radius: 14px; padding: 12px 14px; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.personne header { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.p-nom { font-weight: 600; } .p-user { color: var(--muted); font-size: 12px; }
.chips { margin-left: auto; display: flex; gap: 4px; }
.chip { background: var(--c); color: #fff; border-radius: 999px; padding: 0 8px; font-size: 12px; font-weight: 700; }
.p-groupe { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--c); font-weight: 700; margin: 10px 0 4px; }
.p-liste { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.p-liste li { padding: 4px 0; border-top: 1px solid var(--bord); display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.p-replie summary { cursor: pointer; } .p-liste li:first-child { border-top: 0; } .p-liste a { font-weight: 700; }
.p-raison { color: #444; } .p-titre { width: 100%; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pied { margin-top: 18px; color: var(--muted); font-size: 12px; }
.pied code { background: #fff; border: 1px solid var(--bord); border-radius: 6px; padding: 1px 6px; color: var(--pri-dark); }
.avert { background: #fff6e5; border: 1px solid #f3d9a4; border-radius: 10px; padding: 8px 12px; margin-top: 12px; font-size: 12px; }
.cache { display: none !important; }

@media (max-width: 1400px) { .colonnes { grid-template-columns: repeat(3, minmax(0, 1fr)); } .col-corps { max-height: none; } }
@media (max-width: 900px) {
  .colonnes, .tuiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bas { grid-template-columns: 1fr; } main, .entete { padding-left: 16px; padding-right: 16px; }
  .entete { position: static; } .filtre { width: 100%; } .entete .droite { margin-left: 0; width: 100%; }
}
@media (max-width: 560px) {
  .colonnes, .personnes { grid-template-columns: 1fr; }
  .tuiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .tuile { padding: 8px 10px; border-left-width: 3px; } .tuile i { display: none; }
  .t-n { font-size: 20px; } .t-l { font-size: 11px; }
  .entete { gap: 8px 12px; } .entete .droite { gap: 8px; }
}

/* --- Base (sans Bootstrap) --- */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; line-height: 1.45; }
h1, h2, h3 { line-height: 1.2; }
.me-1 { margin-right: 4px; } .mx-1 { margin: 0 4px; }
.champ, .filtre { font: inherit; font-size: 13px; padding: 5px 10px; border: 1px solid var(--bord); border-radius: 8px; background: #fff; color: var(--texte); }
.champ:focus, .filtre:focus { outline: 0; border-color: var(--pri); box-shadow: 0 0 0 .2rem rgba(0,132,134,.15); }
.btn { font: inherit; font-size: 13px; font-weight: 600; border-radius: 8px; padding: 6px 12px; border: 1px solid transparent; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.btn:hover { text-decoration: none; }
.btn-pri { background: var(--pri); color: #fff; } .btn-pri:hover { background: var(--pri-dark); }
.btn-sec { background: #eef1f4; color: var(--texte); } .btn-sec:hover { background: #e2e6ea; }
.btn[disabled] { opacity: .6; cursor: default; }
.maj { font-size: 12px; color: var(--muted); }

/* --- Actions sur les éléments --- */
.actions { display: flex; gap: 2px; margin-top: 6px; justify-content: flex-end; }
.act { background: none; border: 0; color: var(--muted); padding: 2px 6px; border-radius: 6px; cursor: pointer; font-size: 12px; }
.act:hover { background: #eef1f4; color: var(--pri-dark); }
.act-relancer { color: var(--c-relancer); }
.p-liste .actions, .table-e .actions { margin: 0 0 0 auto; }
.table-e .actions { justify-content: flex-end; }

/* --- Fenêtres --- */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: 0 10px 40px rgba(0,0,0,.2); color: var(--texte); }
dialog::backdrop { background: rgba(20,30,40,.35); }
.dlg-h { padding: 14px 18px 0; } .dlg-h h2 { font-size: 16px; margin: 0; } .dlg-h .sous { color: var(--muted); font-size: 12px; margin-top: 4px; }
.dlg-c { padding: 12px 18px; display: flex; flex-direction: column; gap: 10px; }
.dlg-p { padding: 12px 18px 16px; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; border-top: 1px solid var(--bord); }
.choix { display: flex; flex-wrap: wrap; gap: 6px; }
.choix .btn.actif { background: var(--sec); color: #064d4e; }
textarea.champ { min-height: 140px; resize: vertical; width: 100%; line-height: 1.45; }
.aide { font-size: 12px; color: var(--muted); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #22313f; color: #fff; padding: 8px 16px; border-radius: 8px; font-size: 13px; z-index: 50; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.visible { opacity: 1; }
.tourne { animation: tourne 1s linear infinite; } @keyframes tourne { to { transform: rotate(360deg); } }

/* --- Masqués --- */
.masques .table-e td { vertical-align: middle; }
.mode { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--muted); }

/* --- Connexion --- */
.connexion { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.connexion form { background: #fff; border: 1px solid var(--bord); border-radius: 14px; padding: 24px; width: min(360px, 100%); box-shadow: 0 1px 3px rgba(0,0,0,.04); display: flex; flex-direction: column; gap: 12px; }
.connexion h1 { font-size: 18px; margin: 0; } .connexion h1 i { color: var(--pri); margin-right: 6px; }
.erreur { color: #a82828; font-size: 13px; }
.attente { text-align: center; padding: 80px 16px; color: var(--muted); }
.attente i { color: var(--pri); font-size: 28px; margin-bottom: 12px; }

/* --- Statistiques --- */
.tuiles-stats { grid-template-columns: repeat(8, minmax(0, 1fr)); }
.tuile-stat { --c: var(--pri); }
.tuile-stat .t-n { font-size: 20px; white-space: nowrap; }
.graph { margin-bottom: 18px; }
.legende { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.leg { display: inline-flex; align-items: center; gap: 6px; }
.leg-p { width: 10px; height: 10px; border-radius: 3px; background: var(--s); }
.s-creees { --s: #eb6834; } .s-fusionnees { --s: #008486; }
.mensuel { width: 100%; max-width: 720px; height: auto; display: block; }
.mensuel rect { fill: var(--s); } .mensuel g:hover rect { opacity: .8; }
.g-val { font-size: 10px; fill: var(--texte); text-anchor: middle; }
.g-axe { font-size: 11px; fill: var(--muted); text-anchor: middle; }
.g-base { stroke: var(--bord); stroke-width: 1; }
.table-defile { overflow-x: auto; }
.table-stats th { font-size: 11px; font-weight: 600; color: var(--muted); text-align: right; padding: 4px 8px 6px; border-bottom: 1px solid var(--bord); cursor: pointer; user-select: none; white-space: nowrap; vertical-align: bottom; }
.table-stats th:hover { color: var(--pri-dark); }
.table-stats th[aria-sort] { color: var(--pri-dark); }
.table-stats th[aria-sort=descending]::after { content: " ↓"; } .table-stats th[aria-sort=ascending]::after { content: " ↑"; }
.table-stats td { vertical-align: middle; padding: 5px 8px; }
.table-stats .personne-col { text-align: left; white-space: nowrap; position: sticky; left: 0; background: #fff; }
.table-stats td.personne-col { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.num-col { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.num-col.zero { color: #c3c9cf; }
.num-col.barre { background: linear-gradient(to left, rgba(0,132,134,.13) var(--p), transparent var(--p)) no-repeat; background-size: 100% 70%; background-position: center; }
.spark-col { text-align: right; } .spark rect { fill: var(--pri); } .spark rect:hover { fill: var(--pri-dark); }
.sr summary { cursor: pointer; color: var(--c-relancer); font-weight: 700; list-style: none; }
.sr summary::-webkit-details-marker { display: none; }
.sr[open] summary { margin-bottom: 4px; }
.sr ul { list-style: none; padding: 0; margin: 0; text-align: left; white-space: normal; font-size: 12px; width: 360px; max-height: 240px; overflow-y: auto; }
.sr li { padding: 3px 0; border-top: 1px solid var(--bord); } .sr li a { font-weight: 700; }
.methode { margin-top: 18px; font-size: 12px; color: #555; background: #fff; border: 1px solid var(--bord); border-radius: 14px; padding: 10px 16px; }
.methode summary { cursor: pointer; font-weight: 600; color: var(--texte); } .methode summary i { color: var(--pri); margin-right: 4px; }
.methode ul { margin: 8px 0 0; padding-left: 18px; } .methode li { margin: 4px 0; }
.methode code { background: #f3f5f6; border-radius: 4px; padding: 0 4px; color: var(--pri-dark); }
@media (max-width: 1400px) { .tuiles-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 560px) { .tuiles-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } .sr ul { width: 260px; } }
.mensuel .partiel rect { opacity: .4; }

/* --- Navigation commune, période, mobile --- */
.nav-app { display: inline-flex; background: #eef1f4; border-radius: 10px; padding: 3px; gap: 2px; }
.nav-app a { padding: 5px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; color: #55606b; white-space: nowrap; }
.nav-app a:hover { text-decoration: none; color: var(--pri-dark); }
.nav-app a.actif { background: #fff; color: var(--pri-dark); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.nav-app a i { margin-right: 4px; }
.periode { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.presets .btn { padding: 5px 11px; }
.perso { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
.perso label { display: inline-flex; align-items: center; gap: 6px; }
.t-ecart { font-size: 11px; color: var(--muted); margin-top: 3px; white-space: nowrap; }
.t-ecart i { font-size: 10px; width: auto; color: var(--muted); }
.graph-defile { overflow-x: auto; }
@media (max-width: 900px) {
  .nav-app { order: -1; width: 100%; } .nav-app a { flex: 1; text-align: center; }
  .periode { flex-direction: column; align-items: stretch; }
  .perso input[type=date] { flex: 1; min-width: 0; }
  .perso label { flex: 1; }
}
@media (max-width: 560px) {
  .hide-mobile { display: none; }
  .presets .btn { flex: 1 1 auto; justify-content: center; }
  .onglet { padding: 8px 8px; font-size: 13px; }
  .table-stats td, .table-stats th { padding: 4px 6px; }
}

/* --- Réglages --- */
.reglages { max-width: 760px; display: flex; flex-direction: column; gap: 16px; }
.reglage form { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.reglage form > .btn { align-self: flex-start; }
.ch { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }
.ch .champ { font-weight: 400; width: 100%; }
.ligne { display: flex; gap: 8px; } .ligne .champ { flex: 1; min-width: 0; }
.etat { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0; font-size: 13px; }
.etat dt { color: var(--muted); } .etat dd { margin: 0; overflow-wrap: anywhere; }
.alerte-r { color: #a0620a; font-size: 13px; margin: 8px 0 0; }
.genere { background: #f3f5f6; border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.genere code { font-size: 15px; font-weight: 700; color: var(--pri-dark); letter-spacing: .02em; }
.nav-app a { position: relative; }
.pastille-alerte { position: absolute; top: 3px; right: 4px; width: 8px; height: 8px; border-radius: 50%; background: #d64545; }
@media (max-width: 560px) { .nav-app .lib-nav { font-size: 12px; } .etat { grid-template-columns: 1fr; } .etat dd { margin-bottom: 4px; } }
