:root {
  --papier: #F1F2EE;
  --surface: #FFFFFF;
  --encre: #13294B;
  --nuit: #0E1F3A;
  --gris: #5B6577;
  --trait: #D8DCE0;
  --cobalt: #3D5AFE;
  --lavande: #B9C3FF;
  --vert: #12805C;
  --ambre: #F2B43A;
  --ambre-texte: #8A5C00;
  --rouge: #FF5C5F;
  --rouge-texte: #B42328;
  --titre: "Barlow Semi Condensed", "Arial Narrow", sans-serif;
  --texte: "Barlow", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; }
html { scroll-padding-top: 80px; }
body {
  background: var(--papier);
  color: var(--encre);
  font: 16px/1.5 var(--texte);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 2px; border-radius: 4px; }

/* ---------- En-tête sur une ligne ---------- */

.entete {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 32px;
  height: 64px; padding: 0 32px;
  background: var(--encre); color: var(--papier);
}
.marque { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.marque span { font: 700 26px/1 var(--titre); letter-spacing: 0.01em; }
#nav { display: flex; gap: 4px; height: 100%; }
#nav a {
  display: flex; align-items: center; gap: 6px; padding: 0 12px;
  color: rgba(241, 242, 238, 0.68); text-decoration: none; font-weight: 500;
  border-bottom: 3px solid transparent; border-top: 3px solid transparent;
}
#nav a:hover { color: var(--papier); }
#nav a.actif { color: var(--papier); border-bottom-color: var(--cobalt); }
#nav .compte {
  min-width: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--rouge); color: var(--nuit); font-size: 12px; font-weight: 600; text-align: center; line-height: 20px;
}
.societe { margin-left: auto; font-size: 14px; color: rgba(241, 242, 238, 0.68); white-space: nowrap; }
.score { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.score svg { width: 34px; height: 34px; }
.score p { font-size: 13px; line-height: 1.1; color: rgba(241, 242, 238, 0.68); }
.score b { font: 600 20px var(--titre); color: var(--papier); }
.score span { display: block; font-size: 11px; }

.bouton {
  border: 0; border-radius: 8px; padding: 9px 16px;
  background: var(--cobalt); color: #fff; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.bouton:hover { background: #2E48E0; }
.bouton.discret { background: transparent; color: var(--encre); box-shadow: inset 0 0 0 1px var(--trait); }
.bouton.discret:hover { background: var(--papier); }

/* ---------- Page ---------- */

main { max-width: 1280px; margin: 0 auto; padding: 44px 32px 56px; }
h1 { font: 600 clamp(40px, 5.2vw, 64px)/1 var(--titre); letter-spacing: -0.01em; }
.chapo { max-width: 68ch; margin: 14px 0 32px; font-size: 18px; color: var(--gris); }
h2 { font: 600 21px/1.2 var(--titre); padding-top: 12px; border-top: 2px solid var(--encre); margin-bottom: 18px; }
h3 { font: 600 15px var(--titre); color: var(--gris); margin: 20px 0 4px; }
.mention { margin-top: 48px; font-size: 13px; color: var(--gris); }
.vide { color: var(--gris); padding: 8px 0; }

.rangee { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 48px; margin-top: 48px; }
.rangee.haut { margin-top: 0; }
.bloc { margin-top: 48px; }
.rangee + .bloc { margin-top: 48px; }

/* ---------- Flux ---------- */

.flux { margin: 0; padding: 22px 24px 18px; border-radius: 14px; background: var(--nuit); color: var(--papier); }
.defile { overflow-x: auto; }
.flux-svg { display: block; width: 100%; min-width: 760px; height: auto; }
.flux-svg text { font: 500 14px var(--texte); fill: var(--papier); }
.flux-svg text.alerte { fill: #FF9A9C; }
.flux-svg .montant { font-weight: 400; fill: rgba(241, 242, 238, 0.55); }
.lien { fill-opacity: 0.28; transition: fill-opacity 0.2s; }
.lien:hover { fill-opacity: 0.7; }
.jeton { fill: #fff; opacity: 0.75; pointer-events: none; }
.jeton.fuite { fill: var(--rouge); opacity: 1; }
.entree .lien { animation: monter 0.9s ease-out both; animation-delay: calc(var(--i) * 22ms); }
@keyframes monter { from { fill-opacity: 0; } }
.flux figcaption { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 14px; font-size: 13px; color: rgba(241, 242, 238, 0.7); }
.flux figcaption span { display: flex; align-items: center; gap: 7px; }
.flux figcaption .droite { margin-left: auto; }
.cle { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.cle.rond { border-radius: 50%; width: 8px; height: 8px; background: var(--rouge); box-shadow: 0 0 0 3px rgba(255, 92, 95, 0.25); }

/* ---------- À traiter ---------- */

.taches { list-style: none; padding: 0; }
.taches li {
  display: flex; justify-content: space-between; align-items: center; gap: 18px;
  padding: 13px 0 13px 18px; border-bottom: 1px solid var(--trait); position: relative;
}
.taches li::before { content: ""; position: absolute; left: 0; top: 19px; width: 8px; height: 8px; border-radius: 50%; }
.taches li.t-fuite::before { background: var(--rouge); }
.taches li.t-budget::before { background: var(--ambre); }
.taches li.t-demande::before { background: var(--cobalt); }
.taches strong { font-weight: 600; }
.taches p { font-size: 14px; color: var(--gris); }
.lien-action {
  flex: none; border: 0; background: none; padding: 0; cursor: pointer;
  color: var(--cobalt); font-weight: 600; font-size: 14px; text-decoration: none;
}
.lien-action:hover { text-decoration: underline; }

/* ---------- Budgets et barres ---------- */

.budgets, .barres { display: flex; flex-direction: column; gap: 14px; }
.budget, .barre { display: grid; grid-template-columns: 1fr auto auto; gap: 2px 14px; font-size: 14px; }
.barre { grid-template-columns: 1fr auto; }
.budget .nom, .barre span:first-child { font-weight: 500; }
.budget .chiffres, .barre .chiffre { color: var(--gris); }
.budget .taux { font-weight: 600; min-width: 44px; text-align: right; }
.budget.depasse .taux { color: var(--rouge-texte); }
.budget.alerte .taux { color: var(--ambre-texte); }
.piste { grid-column: 1 / -1; position: relative; height: 8px; border-radius: 4px; background: #E3E6E8; }
.piste i { display: block; height: 100%; border-radius: 4px; background: var(--encre); }
.budget.alerte .piste i { background: var(--ambre); }
.budget.depasse .piste i { background: var(--rouge); }
.budget .piste u { position: absolute; left: 76.9%; top: -3px; bottom: -3px; width: 2px; background: var(--encre); }

/* ---------- Colonnes empilées ---------- */

.colonnes { display: flex; align-items: flex-end; gap: 14px; height: calc(var(--h) + 48px); }
.colonne { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.colonne b { font-size: 13px; font-weight: 500; color: var(--gris); }
.colonne.courante b { color: var(--encre); font-weight: 600; }
.pile { width: 100%; display: flex; flex-direction: column; border-radius: 6px 6px 2px 2px; overflow: hidden; }
.pile i { display: block; min-height: 2px; }
.seg-0 { background: var(--encre); }
.seg-1 { background: var(--ambre); }
.seg-2 { background: var(--rouge); }
.colonne:not(.courante) .pile { opacity: 0.55; }
.colonne span { font-size: 13px; color: var(--gris); }
.legende { display: flex; align-items: center; gap: 6px 8px; flex-wrap: wrap; margin-top: 14px; font-size: 13px; color: var(--gris); }
.legende .cle { margin-left: 10px; }
.legende .cle:first-child { margin-left: 0; }

/* ---------- Tables ---------- */

.table { overflow-x: auto; background: var(--surface); border: 1px solid var(--trait); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th { text-align: left; font-size: 13px; font-weight: 600; color: var(--gris); padding: 14px 16px 10px; white-space: nowrap; }
td { padding: 13px 16px; border-top: 1px solid #E7EAEC; vertical-align: top; }
td strong { font-weight: 600; }
td small { display: block; font-size: 13px; color: var(--gris); }
td.num, th.num { text-align: right; }
td.date { white-space: nowrap; color: var(--gris); }
td.besoin { max-width: 32ch; }
td.action { text-align: right; white-space: nowrap; }
tr.risque td:first-child { box-shadow: inset 4px 0 0 var(--rouge); }
tr.risque { background: #FFF5F5; }
tr.nouvelle { background: #EEF1FF; }
tr.cliquable { cursor: pointer; }
tr.cliquable:hover { background: #F4F6FF; }
tr.risque.cliquable:hover { background: #FFECEC; }
.hausse { color: var(--rouge-texte); }
.courbe { width: 90px; height: 24px; }
.courbe polyline { fill: none; stroke: var(--cobalt); stroke-width: 1.6; stroke-linejoin: round; }
.sens.fort, dd.fort { color: var(--rouge-texte); font-weight: 600; }

.pastille { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.pastille.ok { background: #E1F3EA; color: var(--vert); }
.pastille.revue { background: #FCEFD2; color: var(--ambre-texte); }
.pastille.non { background: #FFE3E3; color: var(--rouge-texte); }
.pastille.neutre { background: #E8EBEE; color: var(--gris); }

.petit {
  border: 1px solid var(--cobalt); background: transparent; color: var(--cobalt);
  border-radius: 6px; padding: 4px 10px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.petit:hover { background: var(--cobalt); color: #fff; }
.petit.discret { border-color: var(--trait); color: var(--gris); }
.petit.discret:hover { background: var(--papier); color: var(--encre); }
.petit + .petit { margin-left: 6px; }

.filtres { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: -28px; }
.filtres button {
  border: 1px solid var(--trait); background: var(--surface); border-radius: 99px;
  padding: 6px 14px; font-size: 14px; font-weight: 500; cursor: pointer;
}
.filtres button[aria-pressed="true"] { background: var(--encre); color: var(--papier); border-color: var(--encre); }
.outils-vue { display: flex; justify-content: flex-end; margin-bottom: -28px; }

/* ---------- Fenêtre ---------- */

dialog {
  margin: auto;
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  padding: 0; border: 0; border-radius: 14px; color: var(--encre);
  box-shadow: 0 24px 64px rgba(14, 31, 58, 0.35);
}
dialog::backdrop { background: rgba(14, 31, 58, 0.55); }
dialog[open] { animation: ouvrir 0.18s ease-out; }
@keyframes ouvrir { from { opacity: 0; transform: translateY(8px); } }
.detail { padding: 22px 26px 24px; }
.detail header { display: flex; justify-content: space-between; align-items: center; }
.detail header p { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--gris); }
.fermer { border: 0; background: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--gris); padding: 4px 8px; }
.detail h2 { border: 0; padding: 0; margin: 10px 0 16px; font-size: 28px; }
.detail dl { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; padding: 14px 0; border-top: 1px solid var(--trait); border-bottom: 1px solid var(--trait); }
.detail dt { font-size: 13px; color: var(--gris); }
.detail blockquote { margin-top: 6px; padding: 12px 14px; border-left: 3px solid var(--cobalt); background: var(--papier); font-size: 15px; }
.detail footer { display: flex; gap: 10px; margin-top: 24px; }
.detail label { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; font-size: 14px; font-weight: 600; }
.detail input, .detail select, .detail textarea {
  font: 400 15px var(--texte); color: var(--encre);
  padding: 9px 12px; border: 1px solid var(--trait); border-radius: 8px; background: var(--surface);
}
.detail .deux { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.erreur { margin-top: 12px; color: var(--rouge-texte); font-weight: 500; }

.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 20; transform: translate(-50%, 20px);
  max-width: min(640px, calc(100vw - 32px)); padding: 12px 18px; border-radius: 10px;
  background: var(--encre); color: var(--papier); font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Petits écrans ---------- */

@media (max-width: 1100px) {
  .societe { display: none; }
}
@media (max-width: 900px) {
  .entete { flex-wrap: wrap; height: auto; gap: 10px 16px; padding: 12px 16px 0; position: static; }
  #nav { order: 5; width: 100%; height: 44px; overflow-x: auto; }
  #nav a { white-space: nowrap; }
  .score { margin-left: auto; }
  main { padding: 28px 16px 40px; }
  .rangee { grid-template-columns: minmax(0, 1fr); gap: 40px; }
  .filtres, .outils-vue { margin-bottom: 16px; }
  .flux { padding: 16px 12px; }
  .flux figcaption .droite { margin-left: 0; }
}
@media (max-width: 520px) {
  .bouton#demander { padding: 8px 12px; font-size: 14px; }
  .score span { display: none; }
  .detail dl, .detail .deux { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
