:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f2f1ed;
  --texte: #0b0b0b;
  --texte-2: #52514e;
  --discret: #6f6d68;
  --trait: #e1e0d9;
  --axe: #c3c2b7;
  --bord: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-texte: #ffffff;
  --succes-texte: #006300;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300;
  --bon: #0ca30c; --attention: #fab219; --serieux: #ec835a; --critique: #d03b3b;
  --ombre: 0 1px 2px rgba(0, 0, 0, 0.05), 0 4px 16px rgba(0, 0, 0, 0.04);
  --rayon: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321;
    --texte: #f0efec; --texte-2: #c3c2b7; --discret: #9a988f;
    --trait: #2c2c2a; --axe: #383835; --bord: rgba(255, 255, 255, 0.10);
    --accent: #3987e5; --succes-texte: #0ca30c;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300;
    --ombre: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #232321;
  --texte: #f0efec; --texte-2: #c3c2b7; --discret: #9a988f;
  --trait: #2c2c2a; --axe: #383835; --bord: rgba(255, 255, 255, 0.10);
  --accent: #3987e5; --succes-texte: #0ca30c;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300;
  --ombre: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--page); color: var(--texte);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.15rem; }
h2 { font-size: 1.05rem; margin-bottom: 12px; }
h3 { font-size: 0.95rem; margin-bottom: 8px; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
.chiffres { font-variant-numeric: tabular-nums; }
.discret { color: var(--discret); }
.secondaire { color: var(--texte-2); }
.petit { font-size: 0.85rem; }
.cache { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* En-tête et navigation */
.entete {
  position: sticky; top: 0; z-index: 10; background: var(--page);
  border-bottom: 1px solid var(--trait);
}
.entete-haut {
  max-width: 1180px; margin: 0 auto; padding: 12px 16px 0;
  display: flex; align-items: center; gap: 12px;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo img { width: 28px; height: 28px; }
.entete-haut .espace { flex: 1; }
.onglets {
  max-width: 1180px; margin: 0 auto; padding: 0 16px;
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
}
.onglets a {
  padding: 10px 12px; color: var(--texte-2); text-decoration: none; white-space: nowrap;
  border-bottom: 2px solid transparent; font-weight: 500;
}
.onglets a[aria-current="page"] { color: var(--texte); border-bottom-color: var(--accent); }
.onglets a:hover { color: var(--texte); }
.pastille {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px;
  background: var(--critique); color: #fff; font-size: 0.75rem; text-align: center; line-height: 18px;
}

main { max-width: 1180px; margin: 0 auto; padding: 20px 16px 48px; }
section { margin-bottom: 28px; }
.titre-section { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.titre-section h2 { margin: 0; }
.titre-section .espace { flex: 1; }

/* Boutons */
.bouton {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; min-height: 36px;
  border-radius: 8px; border: 1px solid var(--bord); background: var(--surface); cursor: pointer;
  font-weight: 500; text-decoration: none; color: var(--texte);
}
.bouton:hover { background: var(--surface-2); }
.bouton.principal { background: var(--accent); border-color: var(--accent); color: var(--accent-texte); }
.bouton.principal:hover { filter: brightness(1.08); }
.bouton.danger { color: var(--critique); }
.bouton.discret { border-color: transparent; background: transparent; }
.bouton:disabled { opacity: 0.55; cursor: not-allowed; }
.bouton svg { width: 16px; height: 16px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Cartes et tuiles */
.carte {
  background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon);
  padding: 16px; box-shadow: var(--ombre);
}
.grille-tuiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.grille-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; }
.tuile .libelle { color: var(--texte-2); font-size: 0.85rem; font-weight: 500; }
.tuile .valeur { font-size: 1.6rem; font-weight: 600; margin: 4px 0 2px; }
.tuile .valeur small { font-size: 0.9rem; font-weight: 500; color: var(--texte-2); }
.tuile button.tuile-lien { all: unset; cursor: pointer; display: block; }

/* Jauges */
.jauge { position: relative; height: 8px; border-radius: 4px; background: var(--surface-2); margin: 10px 0 6px; overflow: visible; }
.jauge > .rempli { height: 100%; border-radius: 4px; background: var(--accent); max-width: 100%; }
.jauge > .rempli.attention { background: var(--attention); }
.jauge > .rempli.critique { background: var(--critique); }
.jauge > .repere { position: absolute; top: -4px; width: 2px; height: 16px; background: var(--texte-2); border-radius: 1px; }

/* Barre empilée */
.empile { display: flex; gap: 2px; height: 10px; border-radius: 5px; overflow: hidden; background: var(--surface-2); }
.empile > span { display: block; height: 100%; min-width: 2px; }
.empile.grande { height: 18px; border-radius: 6px; }
.c-code, .p-code { background: var(--s1); }
.c-git, .p-git { background: var(--s2); }
.c-dependances, .p-dependances { background: var(--s3); }
.c-caches, .p-caches { background: var(--s4); }
.c-generes, .p-generes { background: var(--s5); }
.c-donnees, .p-donnees { background: var(--s6); }
.legende { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 0.85rem; color: var(--texte-2); }
.pastille-couleur { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; vertical-align: -1px; }
.succes-texte { color: var(--succes-texte); font-weight: 500; }

/* Liste des projets */
.projets { display: grid; gap: 10px; }
.projet {
  display: grid;
  gap: 16px; align-items: center; cursor: pointer; text-align: left; width: 100%;
  grid-template-columns: minmax(150px, 1.3fr) minmax(170px, 2fr) 150px minmax(150px, 1.2fr);
  font: inherit; color: inherit;
}
.projet:hover { border-color: var(--axe); }
.projet .nom { font-weight: 600; font-size: 1rem; }
.projet .taille { font-weight: 600; }
.projet .nombre { text-align: right; white-space: nowrap; }
.etiquettes { display: flex; flex-wrap: wrap; gap: 6px; }
.etiquette {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px;
  font-size: 0.8rem; background: var(--surface-2); color: var(--texte-2); white-space: nowrap;
}
.etiquette::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--discret); }
.etiquette.bon::before { background: var(--bon); }
.etiquette.attention::before { background: var(--attention); }
.etiquette.critique::before { background: var(--critique); }
.etiquette.neutre::before { display: none; }
.tendance { display: flex; justify-content: flex-end; margin: 2px 0; }
.tendance svg { width: 70px; height: 24px; flex: none; }
.tendance svg path { fill: none; stroke: var(--s1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
@media (max-width: 760px) {
  .projet { grid-template-columns: 1fr auto; gap: 8px 12px; }
  .projet .col-barre { grid-column: 1 / -1; }
  .projet .col-etat { grid-column: 1 / -1; }
  .projet .nombre { grid-row: 1; grid-column: 2; }
  .projet .nombre .tendance { display: none; }
  .prefixe { display: none; }
  .entete-haut { gap: 4px; }
  .entete-haut .bouton { padding: 6px 8px; }
}
.logo h1 { white-space: nowrap; }
.entete-haut .bouton { white-space: nowrap; }

/* Tableaux */
.tableau-defilant { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th { text-align: left; color: var(--texte-2); font-weight: 500; font-size: 0.8rem; padding: 6px 10px; border-bottom: 1px solid var(--trait); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid var(--trait); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td.nombre, th.nombre { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Barres horizontales (plus gros dossiers) */
.barres { display: grid; gap: 6px; }
.barre-ligne { display: grid; grid-template-columns: minmax(90px, 180px) 1fr 80px; gap: 10px; align-items: center; font-size: 0.88rem; }
.barre-ligne .nom-barre { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barre-ligne .piste { height: 10px; }
.barre-ligne .piste span { display: block; height: 100%; background: var(--s1); border-radius: 0 4px 4px 0; min-width: 2px; }

/* Graphique */
.graphique { position: relative; }
.graphique { min-height: 220px; }
.graphique svg { display: block; overflow: visible; }
.graphique .grille line { stroke: var(--trait); stroke-width: 1; }
.graphique .axe text { fill: var(--discret); font-size: 11px; font-variant-numeric: tabular-nums; }
.graphique .courbe { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.graphique .aire { opacity: 0.12; }
.graphique .curseur { stroke: var(--axe); stroke-width: 1; }
.graphique .point { stroke: var(--surface); stroke-width: 2; }
.infobulle {
  position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--bord);
  border-radius: 8px; padding: 6px 10px; font-size: 0.82rem; box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  white-space: nowrap; z-index: 5;
}

/* Formulaires */
.champ { display: grid; gap: 4px; margin-bottom: 14px; }
.champ label { font-weight: 500; font-size: 0.9rem; }
.champ .aide { font-size: 0.82rem; color: var(--discret); }
input[type="text"], input[type="password"], input[type="number"], textarea {
  width: 100%; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--axe); background: var(--surface);
}
input:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
textarea { min-height: 70px; resize: vertical; }
.case { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 10px; cursor: pointer; }
.case input { margin-top: 4px; width: 17px; height: 17px; accent-color: var(--accent); }
.case .aide { display: block; font-size: 0.82rem; color: var(--discret); }
.ligne-champs { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.ligne-champs .champ { flex: 1; min-width: 140px; margin-bottom: 0; }

/* Messages */
.message { padding: 10px 14px; border-radius: 8px; margin: 10px 0; font-size: 0.9rem; border: 1px solid var(--bord); background: var(--surface-2); }
.message.erreur { border-color: color-mix(in srgb, var(--critique) 50%, transparent); background: color-mix(in srgb, var(--critique) 10%, var(--surface)); }
.message.succes { border-color: color-mix(in srgb, var(--bon) 50%, transparent); background: color-mix(in srgb, var(--bon) 10%, var(--surface)); }
.message.alerte { border-color: color-mix(in srgb, var(--attention) 60%, transparent); background: color-mix(in srgb, var(--attention) 12%, var(--surface)); }
.etapes { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 6px; }
.etapes li { display: flex; gap: 8px; align-items: baseline; }
.etapes .ok { color: var(--succes-texte); font-weight: 700; }
.etapes .ko { color: var(--critique); font-weight: 700; }
pre.journal {
  background: var(--surface-2); padding: 12px; border-radius: 8px; overflow: auto; max-height: 50vh;
  font-size: 0.78rem; line-height: 1.45; white-space: pre-wrap; word-break: break-word;
}

/* Boîte de dialogue */
dialog {
  border: 1px solid var(--bord); border-radius: 14px; background: var(--surface); color: var(--texte);
  padding: 20px; width: min(480px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
dialog.large { width: min(820px, calc(100vw - 32px)); }
dialog h2 { margin-bottom: 8px; }
dialog .actions { justify-content: flex-end; margin-top: 16px; }
input.code { font-size: 1.4rem; letter-spacing: 0.3em; text-align: center; font-variant-numeric: tabular-nums; }

/* Fil d'Ariane */
.retour { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 12px; color: var(--texte-2); text-decoration: none; }
.retour:hover { color: var(--texte); }
.entete-projet { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 18px; }
.entete-projet h1 { font-size: 1.4rem; }
.liste-def { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 0.9rem; margin: 0; }
.liste-def dt { color: var(--texte-2); }
.liste-def dd { margin: 0; overflow-wrap: anywhere; }

/* Page de connexion */
.page-connexion { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.boite-connexion { width: min(380px, 100%); }
.boite-connexion .logo { justify-content: center; margin-bottom: 18px; }
.boite-connexion .logo img { width: 40px; height: 40px; }
.boite-connexion button { width: 100%; justify-content: center; margin-top: 6px; }

.vide { padding: 24px; text-align: center; color: var(--discret); }
.chargement { color: var(--discret); padding: 24px 0; }
@media (prefers-reduced-motion: no-preference) {
  .jauge > .rempli { transition: width 0.4s ease; }
}
@media (forced-colors: active) {
  .empile > span, .jauge > .rempli { forced-color-adjust: none; }
}
