/* SYNERGIE SECTEURS — feuille de style
   Design institutionnel : bleu nuit, vert sarcelle, or. Aucune police externe (connexions lentes). */
:root {
  --nuit: #12304a;
  --nuit-2: #1b4466;
  --sarcelle: #0e6b6b;
  --sarcelle-clair: #e3f1f0;
  --or: #b8862f;
  --or-clair: #f7efdf;
  --fond: #f3f5f7;
  --carte: #ffffff;
  --texte: #1d2733;
  --texte-2: #55616e;
  --bord: #dde3e9;
  --bord-2: #eef1f4;
  --danger: #b3261e;
  --danger-clair: #fbe9e7;
  --succes: #1e7a3c;
  --succes-clair: #e6f4ea;
  --alerte: #9a6400;
  --alerte-clair: #fff4dc;
  --rayon: 10px;
  --ombre: 0 1px 2px rgba(18, 48, 74, .06), 0 2px 8px rgba(18, 48, 74, .05);
  --titre: Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --menu: 248px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--sans); font-size: 15px; line-height: 1.45; color: var(--texte); background: var(--fond); }
a { color: var(--sarcelle); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--titre); font-weight: 600; color: var(--nuit); margin: 0 0 .5em; line-height: 1.2; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; font-family: var(--sans); font-weight: 650; }
img { max-width: 100%; }
.ic { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: -3px; }
.muted { color: var(--texte-2); }
.small { font-size: .86rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.hidden { display: none !important; }
.mt { margin-top: 16px; } .mb { margin-bottom: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.pre { white-space: pre-wrap; }

/* ───── Structure générale ───── */
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--menu); background: var(--nuit); color: #dce6ef; display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 40; transition: transform .2s; }
.brand { padding: 18px 18px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand .logo { display: flex; gap: 10px; align-items: center; }
.brand .mark { width: 36px; height: 36px; border-radius: 9px; background: linear-gradient(135deg, var(--or), #e0b65e); display: grid; place-items: center; color: var(--nuit); font-family: var(--titre); font-weight: 700; font-size: 18px; flex: none; }
.brand .nom { font-family: var(--titre); font-weight: 700; letter-spacing: .04em; color: #fff; font-size: 1.02rem; line-height: 1.1; }
.brand .sous { font-size: .72rem; color: #9fb4c6; margin-top: 3px; }
.nav { flex: 1; overflow-y: auto; padding: 10px 8px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 8px; color: #cfdbe6; font-size: .94rem; margin-bottom: 2px; }
.nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.nav a.actif { background: rgba(255,255,255,.11); color: #fff; box-shadow: inset 3px 0 0 var(--or); }
.nav .sep { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #7f98ad; padding: 14px 12px 6px; }
.nav .badge { margin-left: auto; }
.concepteur { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.08); display: flex; gap: 10px; align-items: center; font-size: .75rem; color: #9fb4c6; }
.concepteur img, .concepteur .ph { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex: none; border: 2px solid var(--or); }
.concepteur .ph { background: var(--nuit-2); display: grid; place-items: center; color: var(--or); font-weight: 700; }
.concepteur b { color: #fff; display: block; font-size: .82rem; }
.main { flex: 1; margin-left: var(--menu); min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; background: rgba(255,255,255,.96); backdrop-filter: blur(6px); border-bottom: 1px solid var(--bord); display: flex; align-items: center; gap: 10px; padding: 10px 22px; }
.topbar .burger { display: none; }
.search { flex: 1; max-width: 460px; position: relative; }
.search input { width: 100%; padding-left: 36px; background: var(--fond); border-color: transparent; }
.search .ic { position: absolute; left: 11px; top: 11px; color: var(--texte-2); }
.topbar .user { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.topbar .user .qui { text-align: right; line-height: 1.15; }
.topbar .user .qui b { display: block; font-size: .9rem; }
.topbar .user .qui span { font-size: .74rem; color: var(--texte-2); }
.iconbtn { position: relative; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--bord); background: #fff; color: var(--nuit); cursor: pointer; }
.iconbtn:hover { background: var(--fond); }
.iconbtn .pastille { position: absolute; top: -3px; right: -3px; }
.contenu { padding: 22px; max-width: 1240px; width: 100%; margin: 0 auto; }
.entete { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.entete p { margin: 2px 0 0; color: var(--texte-2); }
.voile { display: none; }
.horsligne { background: var(--alerte); color: #fff; text-align: center; padding: 6px; font-size: .88rem; }

/* ───── Composants ───── */
.carte { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 18px; }
.carte + .carte { margin-top: 16px; }
.carte > h2:first-child, .carte > h3:first-child { margin-top: 0; }
.carte .titre-carte { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.carte .titre-carte h2, .carte .titre-carte h3 { margin: 0; }
.grille { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { padding: 16px 18px; }
.kpi .lib { font-size: .8rem; color: var(--texte-2); text-transform: uppercase; letter-spacing: .05em; }
.kpi .val { font-size: 1.7rem; font-weight: 700; color: var(--nuit); margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: .82rem; color: var(--texte-2); }
.kpi.or { border-top: 3px solid var(--or); } .kpi.sar { border-top: 3px solid var(--sarcelle); } .kpi.nuit { border-top: 3px solid var(--nuit); } .kpi.rouge { border-top: 3px solid var(--danger); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 15px; border-radius: 8px; border: 1px solid var(--bord); background: #fff; color: var(--nuit); font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; white-space: nowrap; min-height: 38px; }
.btn:hover { background: var(--fond); text-decoration: none; }
.btn.prim { background: var(--sarcelle); border-color: var(--sarcelle); color: #fff; }
.btn.prim:hover { background: #0b5a5a; }
.btn.nuit { background: var(--nuit); border-color: var(--nuit); color: #fff; }
.btn.danger { color: var(--danger); border-color: #efc2bd; }
.btn.danger:hover { background: var(--danger-clair); }
.btn.lien { border: 0; background: none; padding: 6px 8px; color: var(--sarcelle); min-height: 0; }
.btn.petit { padding: 5px 10px; font-size: .82rem; min-height: 30px; }
.btn:disabled { opacity: .55; cursor: wait; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .74rem; font-weight: 650; background: var(--bord-2); color: var(--texte-2); white-space: nowrap; }
.badge.vert { background: var(--succes-clair); color: var(--succes); }
.badge.rouge { background: var(--danger-clair); color: var(--danger); }
.badge.or { background: var(--or-clair); color: #7d5a14; }
.badge.sar { background: var(--sarcelle-clair); color: var(--sarcelle); }
.badge.nuit { background: #e4ebf2; color: var(--nuit); }
.badge.demo { background: #f1e6fb; color: #6a2f9a; }
.pastille { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: .7rem; font-weight: 700; display: inline-grid; place-items: center; }

label { display: block; font-size: .84rem; font-weight: 600; color: var(--texte-2); margin-bottom: 5px; }
input, select, textarea { width: 100%; font: inherit; font-size: 16px; color: var(--texte); background: #fff; border: 1px solid var(--bord); border-radius: 8px; padding: 9px 11px; min-height: 40px; }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--sarcelle); outline-offset: 1px; border-color: var(--sarcelle); }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; }
.champs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.champs .plein { grid-column: 1 / -1; }
.champ .aide { font-size: .78rem; color: var(--texte-2); margin-top: 4px; }
.req::after { content: " *"; color: var(--danger); }
.coche { display: flex; gap: 8px; align-items: center; font-weight: 500; color: var(--texte); }
fieldset { border: 1px solid var(--bord); border-radius: var(--rayon); padding: 14px; margin: 0; }
legend { font-weight: 700; color: var(--nuit); padding: 0 6px; }
.filtres { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filtres > * { flex: 1 1 150px; }
.filtres .q { flex: 2 1 220px; }

.tablewrap { overflow-x: auto; border: 1px solid var(--bord); border-radius: var(--rayon); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--texte-2); background: #f8fafb; padding: 10px 12px; border-bottom: 1px solid var(--bord); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--bord-2); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.clic { cursor: pointer; }
tbody tr.clic:hover { background: #f6f9fb; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.annule td { color: #9aa4ae; text-decoration: line-through; }
.vide { padding: 28px; text-align: center; color: var(--texte-2); }

.avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; background: var(--sarcelle-clair); color: var(--sarcelle); display: inline-grid; place-items: center; font-weight: 700; font-size: .85rem; flex: none; }
.avatar.grand { width: 112px; height: 112px; font-size: 2rem; border-radius: 12px; }
.ident { display: flex; align-items: center; gap: 10px; }
.ident b { display: block; }

.liste { list-style: none; margin: 0; padding: 0; }
.liste li { padding: 10px 0; border-bottom: 1px solid var(--bord-2); display: flex; gap: 10px; align-items: flex-start; }
.liste li:last-child { border-bottom: 0; }
.liste .date { min-width: 52px; text-align: center; background: var(--sarcelle-clair); color: var(--sarcelle); border-radius: 8px; padding: 4px 6px; font-weight: 700; line-height: 1.1; font-size: .78rem; }
.liste .date b { display: block; font-size: 1.15rem; }

.barres { display: grid; gap: 8px; }
.barre { display: grid; grid-template-columns: minmax(90px, 38%) 1fr 48px; gap: 10px; align-items: center; font-size: .86rem; }
.barre .piste { background: var(--bord-2); border-radius: 6px; height: 12px; overflow: hidden; }
.barre .rempli { height: 100%; background: var(--sarcelle); border-radius: 6px; }
.colonnes { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 10px; }
.colonnes .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: .7rem; color: var(--texte-2); }
.colonnes .col .b { width: 100%; max-width: 34px; background: var(--nuit-2); border-radius: 4px 4px 0 0; min-height: 2px; }
.jauge { height: 10px; background: var(--bord-2); border-radius: 6px; overflow: hidden; }
.jauge > div { height: 100%; background: var(--or); }

.onglets { display: flex; gap: 4px; border-bottom: 1px solid var(--bord); margin-bottom: 16px; overflow-x: auto; }
.onglets a { padding: 10px 14px; color: var(--texte-2); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.onglets a.actif { color: var(--nuit); border-bottom-color: var(--or); }
.onglets a:hover { text-decoration: none; color: var(--nuit); }

.pub { border-left: 4px solid var(--bord); }
.pub.annonce { border-left-color: var(--sarcelle); }
.pub.communique { border-left-color: var(--or); }
.pub.important { background: linear-gradient(90deg, #fffaf0, #fff 40%); }
.pub .meta { font-size: .8rem; color: var(--texte-2); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.pub .corps { white-space: pre-wrap; }
.pub .corps.coupe { max-height: 6.2em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 60%, transparent); mask-image: linear-gradient(#000 60%, transparent); }
.commentaire { padding: 10px 12px; border-radius: 8px; background: var(--fond); margin-bottom: 8px; }
.commentaire.masque { opacity: .6; border: 1px dashed var(--danger); }

.chat { display: grid; grid-template-columns: 300px 1fr; gap: 0; height: calc(100vh - 170px); min-height: 420px; border: 1px solid var(--bord); border-radius: var(--rayon); background: #fff; overflow: hidden; }
.chat .convs { border-right: 1px solid var(--bord); overflow-y: auto; }
.chat .conv { display: block; padding: 12px 14px; border-bottom: 1px solid var(--bord-2); color: var(--texte); }
.chat .conv:hover, .chat .conv.actif { background: #f3f8f8; text-decoration: none; }
.chat .conv .ap { font-size: .82rem; color: var(--texte-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat .fil { display: flex; flex-direction: column; min-width: 0; }
.chat .msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; background: #f7f9fa; }
.bulle { max-width: 78%; padding: 8px 12px; border-radius: 12px; background: #fff; border: 1px solid var(--bord); white-space: pre-wrap; word-wrap: break-word; }
.bulle.moi { align-self: flex-end; background: var(--sarcelle); color: #fff; border-color: var(--sarcelle); }
.bulle .h { font-size: .7rem; opacity: .7; margin-top: 3px; text-align: right; }
.chat form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--bord); }
.chat form textarea { min-height: 42px; height: 42px; }

/* Modale */
.modal-fond { position: fixed; inset: 0; background: rgba(13, 30, 46, .5); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 40px 14px; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 680px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.large { max-width: 920px; }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--bord); }
.modal header h2 { margin: 0; }
.modal .corps { padding: 20px; }
.modal footer { padding: 14px 20px; border-top: 1px solid var(--bord); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.toasts { position: fixed; bottom: 18px; right: 18px; z-index: 200; display: grid; gap: 8px; }
.toast { background: var(--nuit); color: #fff; padding: 11px 16px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.2); max-width: 360px; font-size: .9rem; }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--succes); }
.alerte { padding: 11px 14px; border-radius: 8px; background: var(--alerte-clair); color: #6b4700; border: 1px solid #f1dca8; margin-bottom: 14px; }
.alerte.info { background: var(--sarcelle-clair); color: #0b4f4f; border-color: #bfe0de; }
.alerte.err { background: var(--danger-clair); color: var(--danger); border-color: #f2c3be; }
.secret { font-family: ui-monospace, Consolas, monospace; font-size: 1.15rem; background: var(--or-clair); padding: 6px 10px; border-radius: 6px; letter-spacing: .05em; user-select: all; }

.fiche-tete { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.dl { display: grid; grid-template-columns: 170px 1fr; gap: 8px 14px; margin: 0; font-size: .92rem; }
.dl dt { color: var(--texte-2); }
.dl dd { margin: 0; font-weight: 500; }
.chrono { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 2px solid var(--bord); }
.chrono li { position: relative; padding: 0 0 14px 12px; font-size: .88rem; }
.chrono li::before { content: ""; position: absolute; left: -22px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--or); border: 2px solid #fff; }
.chrono .diff { color: var(--texte-2); font-size: .82rem; }

/* Connexion */
.ecran-connexion { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.ecran-connexion .vitrine { background: radial-gradient(1200px 500px at 20% 0%, #1f527a, var(--nuit)); color: #e6eef5; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.ecran-connexion .vitrine h1 { color: #fff; font-size: 2.1rem; letter-spacing: .03em; }
.ecran-connexion .vitrine .devise { font-family: var(--titre); font-size: 1.15rem; color: #f0d9a8; max-width: 440px; }
.ecran-connexion .vitrine ul { padding-left: 18px; color: #b8cad9; }
.ecran-connexion .formulaire { display: flex; align-items: center; justify-content: center; padding: 30px 20px; }
.ecran-connexion form { width: 100%; max-width: 380px; display: grid; gap: 14px; }
.structs { display: flex; gap: 8px; flex-wrap: wrap; }
.structs span { border: 1px solid rgba(255,255,255,.25); border-radius: 6px; padding: 4px 10px; font-weight: 700; letter-spacing: .06em; font-size: .85rem; }
.chargement { display: grid; place-items: center; min-height: 50vh; color: var(--texte-2); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--bord); border-top-color: var(--sarcelle); border-radius: 50%; animation: tourne .8s linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }

/* ───── Mobile et tablette ───── */
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); }
  body.menu-ouvert .sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.35); }
  body.menu-ouvert .voile { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 35; }
  .main { margin-left: 0; }
  .topbar { padding: 8px 12px; }
  .topbar .burger { display: grid; }
  .topbar .user .qui { display: none; }
  .contenu { padding: 14px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .champs { grid-template-columns: 1fr; }
  .chat { grid-template-columns: 1fr; height: calc(100vh - 140px); }
  .chat.dans-fil .convs { display: none; }
  .chat:not(.dans-fil) .fil { display: none; }
  .ecran-connexion { grid-template-columns: 1fr; }
  .ecran-connexion .vitrine { padding: 28px 22px; }
  .ecran-connexion .vitrine ul, .ecran-connexion .vitrine .bas { display: none; }
  .dl { grid-template-columns: 1fr; gap: 2px; }
  .dl dd { margin-bottom: 8px; }
  .masque-mobile { display: none; }
  .modal-fond { padding: 0; }
  .modal { border-radius: 0; min-height: 100vh; }
  h1 { font-size: 1.3rem; }
}
@media (max-width: 520px) { .g4 { grid-template-columns: 1fr 1fr; } .kpi .val { font-size: 1.35rem; } .search { max-width: none; } }

/* ───── Impression / PDF ───── */
#impression { display: none; }
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; font-size: 11pt; }
  body.imprime > *:not(#impression) { display: none !important; }
  body.imprime #impression { display: block; }
  #impression table { font-size: 9.5pt; }
  #impression th { background: #eef2f5 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #impression td, #impression th { padding: 5px 7px; border: 1px solid #ccd3da; }
  .doc-tete { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid var(--nuit); padding-bottom: 8px; margin-bottom: 14px; }
  .doc-tete .nom { font-family: var(--titre); font-weight: 700; font-size: 15pt; color: var(--nuit); }
  .doc-pied { margin-top: 18px; padding-top: 6px; border-top: 1px solid #ccd3da; font-size: 8pt; color: #666; display: flex; justify-content: space-between; }
  .saut { page-break-before: always; }
  .signatures { display: flex; justify-content: space-between; margin-top: 40px; }
  .signatures div { width: 40%; border-top: 1px solid #999; padding-top: 4px; text-align: center; font-size: 9pt; }
  .recu { border: 1px solid #999; padding: 14px; margin-bottom: 14px; }
  a { color: inherit; }
}
