/* ===========================================================================
   GrowKlean Cockpit — feuille de style

   Deux thèmes, une seule définition de couleurs par jeton. La palette claire
   vit sur `:root` nu ; la sombre la redéfinit. Aucun bloc ne définit une
   couleur pour la première fois à l'intérieur d'une media query : sinon un
   navigateur qui n'entre dans aucune des deux conditions afficherait du noir
   sur noir.

   Responsive : le rail latéral devient une barre d'onglets en bas d'écran
   sous 900 px. C'est le seul point de bascule — multiplier les seuils rendrait
   la feuille impossible à tenir.
   =========================================================================== */

:root {
  color-scheme: light dark;

  --fond:            #f6f7f5;
  --fond-2:          #ffffff;
  --fond-3:          #eceee9;
  --bord:            #d8dcd4;
  --bord-net:        #c2c8bc;
  --texte:           #1b1f1a;
  --texte-doux:      #5a6155;
  --texte-faible:    #868d80;

  --accent:          #2f7d4f;
  --accent-doux:     #e3f0e7;
  --accent-texte:    #ffffff;

  --rouge:           #b4342c;
  --rouge-doux:      #fbe8e6;
  --orange:          #a86a12;
  --orange-doux:     #fbf0dd;
  --bleu:            #2a5f9e;
  --bleu-doux:       #e6eef8;

  --rayon:           10px;
  --rayon-s:         6px;
  --ombre:           0 1px 2px rgb(0 0 0 / .06), 0 4px 12px rgb(0 0 0 / .04);
  --rail:            232px;

  --police: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
            "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
}

:root[data-theme="dark"],
:root:not([data-theme="light"]) {
  --fond:            #14171a;
  --fond-2:          #1b1f23;
  --fond-3:          #23282d;
  --bord:            #2c3238;
  --bord-net:        #3d454d;
  --texte:           #e6e9e4;
  --texte-doux:      #a3ab9f;
  --texte-faible:    #757d72;

  --accent:          #5cbf85;
  --accent-doux:     #1c2f24;
  --accent-texte:    #0d1210;

  --rouge:           #e8756c;
  --rouge-doux:      #2e1c1a;
  --orange:          #e0a349;
  --orange-doux:     #2d2418;
  --bleu:            #6fa5e0;
  --bleu-doux:       #1a2431;

  --ombre:           0 1px 2px rgb(0 0 0 / .3), 0 4px 14px rgb(0 0 0 / .22);
}

/* Le navigateur ne stampe rien en mode « système » : c'est la seule
   information disponible pour distinguer clair et sombre. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --fond: #f6f7f5; --fond-2: #ffffff; --fond-3: #eceee9;
    --bord: #d8dcd4; --bord-net: #c2c8bc;
    --texte: #1b1f1a; --texte-doux: #5a6155; --texte-faible: #868d80;
    --accent: #2f7d4f; --accent-doux: #e3f0e7; --accent-texte: #ffffff;
    --rouge: #b4342c; --rouge-doux: #fbe8e6;
    --orange: #a86a12; --orange-doux: #fbf0dd;
    --bleu: #2a5f9e; --bleu-doux: #e6eef8;
    --ombre: 0 1px 2px rgb(0 0 0 / .06), 0 4px 12px rgb(0 0 0 / .04);
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font-family: var(--police);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.saut-contenu {
  position: absolute; left: -9999px;
  background: var(--accent); color: var(--accent-texte);
  padding: .6rem 1rem; border-radius: var(--rayon-s); z-index: 100;
}
.saut-contenu:focus { left: 1rem; top: 1rem; }

/* ---------------------------------------------------------------- ossature */

.app { display: flex; min-height: 100vh; }

.rail {
  width: var(--rail);
  flex: 0 0 var(--rail);
  background: var(--fond-2);
  border-right: 1px solid var(--bord);
  display: flex;
  flex-direction: column;
  padding: 1.1rem .75rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.rail__marque {
  display: flex; align-items: center; gap: .55rem;
  padding: 0 .5rem 1.1rem;
  font-size: 1.08rem; font-weight: 650; letter-spacing: -.02em;
}
.rail__logo { font-size: 1.25rem; }
.rail__nom em { font-style: normal; color: var(--accent); }

/* `align-content: start` est indispensable : sans lui, `flex: 1` étire la
   grille sur toute la hauteur du rail et répartit les liens à intervalles
   énormes au lieu de les grouper en haut. */
.rail__liens {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 2px; flex: 1; align-content: start;
}

.rail__liens a {
  display: flex; align-items: center; gap: .65rem;
  padding: .55rem .7rem;
  border-radius: var(--rayon-s);
  color: var(--texte-doux);
  font-weight: 500;
  text-decoration: none;
}
.rail__liens a:hover { background: var(--fond-3); color: var(--texte); }
.rail__liens a[aria-current="page"] {
  background: var(--accent-doux); color: var(--accent); font-weight: 600;
}
.rail__liens span { width: 1.1em; text-align: center; opacity: .75; }

.pastille {
  margin-left: auto;
  background: var(--accent); color: var(--accent-texte);
  font-size: .7rem; font-weight: 700;
  padding: .05rem .4rem; border-radius: 999px; min-width: 1.35em; text-align: center;
}

.rail__pied { display: grid; gap: .5rem; padding-top: .75rem; border-top: 1px solid var(--bord); }

/* Bloc compte : qui est connecté, et de quoi se déconnecter. Masqué quand
   l'authentification n'est pas exigée (cockpit local). */
.compte { display: grid; gap: .35rem; padding: 0 .5rem; }
.compte[hidden] { display: none; }
.compte__nom {
  font-size: .82rem; font-weight: 550; color: var(--texte);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  cursor: pointer;
}
.compte__nom:hover { color: var(--accent); }

.voyant {
  display: flex; align-items: center; gap: .5rem;
  font-size: .8rem; color: var(--texte-doux); padding: 0 .5rem;
}
.voyant__point {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--texte-faible); flex: 0 0 8px;
}
.voyant[data-etat="ok"]     .voyant__point { background: var(--accent); }
.voyant[data-etat="alerte"] .voyant__point { background: var(--orange); }
.voyant[data-etat="ko"]     .voyant__point { background: var(--rouge); }

.colonne { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.entete {
  display: flex; align-items: center; gap: .75rem;
  padding: .75rem 1.25rem;
  background: color-mix(in srgb, var(--fond) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--bord);
  position: sticky; top: 0; z-index: 20;
}

.chercher { flex: 1; min-width: 0; }
.chercher input {
  width: 100%; padding: .55rem .85rem;
  background: var(--fond-2); color: var(--texte);
  border: 1px solid var(--bord); border-radius: var(--rayon);
  font: inherit;
}
.chercher input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.contenu { padding: 1.25rem; max-width: 1180px; width: 100%; }
.contenu:focus { outline: none; }

.menu-mobile { display: none; }

/* ---------------------------------------------------------------- éléments */

.btn {
  font: inherit; font-weight: 550;
  padding: .5rem .9rem;
  border-radius: var(--rayon-s);
  border: 1px solid var(--bord-net);
  background: var(--fond-2); color: var(--texte);
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--fond-3); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--primaire { background: var(--accent); color: var(--accent-texte); border-color: transparent; }
.btn--primaire:hover { filter: brightness(1.08); background: var(--accent); }
.btn--fantome { background: transparent; border-color: var(--bord); color: var(--texte-doux); }
.btn--icone { padding: .4rem .6rem; }
.btn--petit { padding: .3rem .6rem; font-size: .82rem; }
.btn--danger { color: var(--rouge); border-color: var(--rouge); }

.carte {
  background: var(--fond-2);
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  padding: 1rem 1.1rem;
  box-shadow: var(--ombre);
}

.grille { display: grid; gap: 1rem; }
.grille--kpi { grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); }
.grille--2   { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.kpi { display: grid; gap: .1rem; }
.kpi__valeur { font-size: 1.75rem; font-weight: 680; letter-spacing: -.03em; line-height: 1.1; }
.kpi__libelle { font-size: .78rem; color: var(--texte-doux); text-transform: uppercase; letter-spacing: .05em; }
.kpi__note { font-size: .78rem; color: var(--texte-faible); }
.kpi--alerte .kpi__valeur { color: var(--orange); }
.kpi--ko .kpi__valeur { color: var(--rouge); }

h1 { font-size: 1.4rem; letter-spacing: -.02em; margin: 0 0 .2rem; }
h2 { font-size: 1.1rem; letter-spacing: -.015em; margin: 0 0 .6rem; }
h3 { font-size: .95rem; margin: 0 0 .4rem; }

.sous-titre { color: var(--texte-doux); margin: 0 0 1.1rem; font-size: .92rem; }

.section { margin-bottom: 1.5rem; }
.section__entete {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; margin-bottom: .7rem; flex-wrap: wrap;
}

.etiquette {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .72rem; font-weight: 600;
  padding: .12rem .5rem; border-radius: 999px;
  background: var(--fond-3); color: var(--texte-doux);
  text-transform: uppercase; letter-spacing: .04em;
}
.etiquette--accent  { background: var(--accent-doux); color: var(--accent); }
.etiquette--rouge   { background: var(--rouge-doux);  color: var(--rouge); }
.etiquette--orange  { background: var(--orange-doux); color: var(--orange); }
.etiquette--bleu    { background: var(--bleu-doux);   color: var(--bleu); }

.liste { display: grid; gap: .6rem; }

.ligne {
  background: var(--fond-2);
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  padding: .8rem .95rem;
  display: grid; gap: .35rem;
}
.ligne:hover { border-color: var(--bord-net); }
.ligne__titre { font-weight: 580; line-height: 1.35; }
.ligne__meta {
  display: flex; flex-wrap: wrap; gap: .45rem; align-items: center;
  font-size: .8rem; color: var(--texte-doux);
}
.ligne__resume { font-size: .88rem; color: var(--texte-doux); }
.ligne__actions { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .2rem; }

.ligne--impact-1 { border-left: 3px solid var(--rouge); }
.ligne--impact-2 { border-left: 3px solid var(--orange); }
.ligne--impact-3 { border-left: 3px solid var(--bord-net); }

.score {
  font-variant-numeric: tabular-nums; font-weight: 680;
  padding: .1rem .45rem; border-radius: var(--rayon-s);
  background: var(--fond-3); font-size: .8rem;
}
.score--fort { background: var(--accent-doux); color: var(--accent); }

.filtres {
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end;
  margin-bottom: 1rem;
}
.champ { display: grid; gap: .2rem; }
.champ > label { font-size: .74rem; color: var(--texte-doux); text-transform: uppercase; letter-spacing: .05em; }
.champ select, .champ input, .champ textarea {
  font: inherit; padding: .4rem .6rem;
  background: var(--fond-2); color: var(--texte);
  border: 1px solid var(--bord); border-radius: var(--rayon-s);
}
.champ textarea { min-height: 84px; resize: vertical; font-family: inherit; }
.champ--large { flex: 1; min-width: 220px; }

.puces { display: flex; flex-wrap: wrap; gap: .35rem; }
.puce {
  font: inherit; font-size: .82rem;
  padding: .3rem .7rem; border-radius: 999px;
  border: 1px solid var(--bord); background: var(--fond-2);
  color: var(--texte-doux); cursor: pointer;
}
.puce[aria-pressed="true"] {
  background: var(--accent-doux); color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent); font-weight: 600;
}

.vide {
  text-align: center; padding: 2.5rem 1rem;
  color: var(--texte-doux); background: var(--fond-2);
  border: 1px dashed var(--bord); border-radius: var(--rayon);
}
.vide strong { display: block; color: var(--texte); margin-bottom: .3rem; }

.chargement { color: var(--texte-doux); padding: 2rem; text-align: center; }

/* Barre de couverture : la comparaison visuelle entre priorité affichée et
   volume réel est l'information — d'où deux barres superposées. */
.barre { display: grid; gap: .25rem; margin-bottom: .55rem; }
.barre__tete { display: flex; justify-content: space-between; font-size: .82rem; }
.barre__piste { height: 7px; background: var(--fond-3); border-radius: 999px; overflow: hidden; position: relative; }
.barre__part { height: 100%; background: var(--accent); border-radius: 999px; }
.barre__cible {
  position: absolute; top: -2px; width: 2px; height: 11px;
  background: var(--texte-faible); border-radius: 1px;
}
.barre--manque .barre__part { background: var(--rouge); }

/* Rendu Markdown des briefs et des sections projet. */
.md { line-height: 1.62; }
.md h1, .md h2, .md h3 { margin: 1.3rem 0 .5rem; }
.md h2 { font-size: 1.05rem; padding-bottom: .3rem; border-bottom: 1px solid var(--bord); }
.md h2:first-child { margin-top: 0; }
.md p { margin: .55rem 0; }
.md ul, .md ol { margin: .5rem 0; padding-left: 1.3rem; }
.md li { margin: .3rem 0; }

/* Ligne indentée prolongeant un point de liste : les briefs y rattachent le
   résumé et l'URL de l'item cité. */
.md-suite {
  margin: .1rem 0 .45rem 1.3rem;
  color: var(--texte-doux); font-size: .93em;
}
.md code {
  font-family: var(--mono); font-size: .87em;
  background: var(--fond-3); padding: .1rem .35rem; border-radius: 4px;
}
.md pre {
  background: var(--fond-3); padding: .8rem 1rem;
  border-radius: var(--rayon-s); overflow-x: auto;
}
.md pre code { background: none; padding: 0; }
.md blockquote {
  margin: .7rem 0; padding: .3rem 0 .3rem .9rem;
  border-left: 3px solid var(--bord-net); color: var(--texte-doux);
}
.md table { border-collapse: collapse; width: 100%; margin: .7rem 0; font-size: .9rem; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--bord); padding: .4rem .6rem; text-align: left; }
.md th { background: var(--fond-3); font-weight: 620; }
.md hr { border: none; border-top: 1px solid var(--bord); margin: 1.2rem 0; }

.texte-source {
  font-family: var(--mono); font-size: .82rem; line-height: 1.6;
  white-space: pre-wrap; word-break: break-word;
  background: var(--fond-3); padding: 1rem; border-radius: var(--rayon-s);
  max-height: 62vh; overflow: auto;
}

/* --------------------------------------------------------------- modale */

.modale {
  border: 1px solid var(--bord); border-radius: var(--rayon);
  background: var(--fond-2); color: var(--texte);
  padding: 0; width: min(880px, 94vw); max-height: 88vh;
  box-shadow: 0 20px 60px rgb(0 0 0 / .35);
}
.modale::backdrop { background: rgb(0 0 0 / .55); }
.modale__entete {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .9rem 1.1rem; border-bottom: 1px solid var(--bord);
  position: sticky; top: 0; background: var(--fond-2);
}
.modale__entete h2 { margin: 0; font-size: 1rem; }
.modale__corps { padding: 1.1rem; overflow: auto; max-height: calc(88vh - 60px); }

/* --------------------------------------------------------------- notes */

.notes {
  position: fixed; bottom: 1rem; right: 1rem; z-index: 60;
  display: grid; gap: .5rem; max-width: min(380px, 88vw);
}
.note {
  background: var(--fond-2); border: 1px solid var(--bord-net);
  border-left: 3px solid var(--accent);
  border-radius: var(--rayon-s); padding: .65rem .85rem;
  box-shadow: var(--ombre); font-size: .88rem;
  animation: entree .18s ease-out;
}
.note--erreur { border-left-color: var(--rouge); }
.note--alerte { border-left-color: var(--orange); }

@keyframes entree {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* --------------------------------------------------------------- mobile */

@media (max-width: 900px) {
  .app { flex-direction: column; }

  .rail {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto;
    width: 100%; flex: none; height: auto;
    flex-direction: row; align-items: center;
    border-right: none; border-top: 1px solid var(--bord);
    padding: .35rem .5rem calc(.35rem + env(safe-area-inset-bottom));
    z-index: 30;
  }
  .rail__marque, .rail__pied { display: none; }

  .rail__liens {
    grid-auto-flow: column; grid-auto-columns: 1fr;
    width: 100%; gap: 0;
  }
  .rail__liens a {
    flex-direction: column; gap: .12rem;
    padding: .4rem .2rem; font-size: .66rem; text-align: center;
  }
  .rail__liens a span { font-size: 1.1rem; width: auto; }
  .pastille { position: absolute; transform: translate(1.1rem, -.55rem); font-size: .62rem; }

  .contenu { padding: 1rem .85rem 5.2rem; }
  .entete { padding: .6rem .85rem; }
  .grille--kpi { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
  .kpi__valeur { font-size: 1.4rem; }
  .btn--primaire .btn__texte { display: none; }
  .btn--primaire::after { content: "⟳"; font-size: 1.05rem; }
}

@media (max-width: 560px) {
  .filtres { gap: .4rem; }
  .champ select, .champ input { font-size: .88rem; }
}
