:root {
  --fond: #f4f5f2;
  --surface: #ffffff;
  --surface-2: #f8f9f6;
  --bordure: #dfe2dc;
  --bordure-forte: #c4c9c0;
  --texte: #1d2321;
  --texte-2: #5b6460;
  --texte-3: #858d89;
  --accent: #1f6f78;
  --accent-fond: #e2f1f0;
  --accent-texte: #11484e;
  --succes: #2f7a3a;
  --succes-fond: #e5f2e3;
  --alerte: #9a5b06;
  --alerte-fond: #fbefd9;
  --danger: #a3302d;
  --danger-fond: #fbe7e6;
  --rayon: 8px;
  --ombre: 0 1px 2px rgb(20 30 25 / 6%);
  --police: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fond: #141817;
    --surface: #1b201f;
    --surface-2: #212726;
    --bordure: #2e3533;
    --bordure-forte: #414a47;
    --texte: #e6ebe8;
    --texte-2: #a7b0ac;
    --texte-3: #7c8582;
    --accent: #5dbdc4;
    --accent-fond: #173638;
    --accent-texte: #bfe9ec;
    --succes: #7cc488;
    --succes-fond: #1b3220;
    --alerte: #e5b15d;
    --alerte-fond: #3a2c12;
    --danger: #f08b86;
    --danger-fond: #3d1c1b;
    --ombre: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--fond); color: var(--texte); font: 14px/1.5 var(--police); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; font-weight: 600; margin: 0; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 13px; font-weight: 600; margin: 0 0 8px; color: var(--texte-2); text-transform: uppercase; letter-spacing: .04em; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
pre { background: var(--surface-2); border: 1px solid var(--bordure); border-radius: var(--rayon); padding: 10px 12px; overflow: auto; max-height: 420px; white-space: pre-wrap; word-break: break-word; margin: 0; }
.chargement { display: grid; place-items: center; height: 100%; color: var(--texte-3); }

/* Mise en page */
.cadre { display: grid; grid-template-columns: 232px 1fr; min-height: 100%; }
.menu { background: var(--surface); border-right: 1px solid var(--bordure); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.marque { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; font-weight: 600; }
.marque img { width: 28px; height: 28px; }
.marque small { display: block; font-weight: 400; color: var(--texte-3); font-size: 12px; }
.menu a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--rayon); color: var(--texte-2); }
.menu a:hover { background: var(--surface-2); text-decoration: none; color: var(--texte); }
.menu a.actif { background: var(--accent-fond); color: var(--accent-texte); font-weight: 600; }
.menu .pied { margin-top: auto; padding: 10px; border-top: 1px solid var(--bordure); font-size: 12.5px; color: var(--texte-2); }
.menu .pied button { margin-top: 8px; width: 100%; }
.pastille-direct { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--texte-3); }
.pastille-direct::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--texte-3); }
.pastille-direct.ok::before { background: var(--succes); }
.contenu { padding: 24px 28px 48px; min-width: 0; }
.entete { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.entete p { margin: 2px 0 0; color: var(--texte-2); }
.grille { display: grid; gap: 16px; }
.grille.deux { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.grille.stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 16px; }
.carte { background: var(--surface); border: 1px solid var(--bordure); border-radius: 12px; padding: 16px 18px; box-shadow: var(--ombre); min-width: 0; }
.stat .valeur { font-size: 26px; font-weight: 600; line-height: 1.2; }
.stat .libelle { color: var(--texte-2); font-size: 13px; }
.vide { color: var(--texte-3); padding: 18px 0; text-align: center; }
.ligne { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ligne.espace { justify-content: space-between; }
.discret { color: var(--texte-3); font-size: 12.5px; }

/* Contrôles */
button, .bouton { font: inherit; font-size: 13.5px; border: 1px solid var(--bordure-forte); background: var(--surface); color: var(--texte); padding: 6px 12px; border-radius: var(--rayon); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
button:hover, .bouton:hover { background: var(--surface-2); text-decoration: none; }
button.principal { background: var(--accent); border-color: var(--accent); color: #fff; }
button.principal:hover { filter: brightness(1.08); background: var(--accent); }
button.danger { color: var(--danger); }
button:disabled { opacity: .5; cursor: default; }
button.petit { padding: 3px 8px; font-size: 12.5px; }
input, select, textarea { font: inherit; color: var(--texte); background: var(--surface); border: 1px solid var(--bordure-forte); border-radius: var(--rayon); padding: 7px 10px; width: 100%; }
textarea { font-family: var(--mono); font-size: 12.5px; min-height: 160px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--texte-2); }
form.pile, .pile { display: grid; gap: 12px; }
.erreur { color: var(--danger); font-size: 13px; }

/* Tableaux */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 600; font-size: 12px; color: var(--texte-3); text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--bordure); }
td { padding: 9px 10px; border-bottom: 1px solid var(--bordure); vertical-align: middle; }
tr.cliquable { cursor: pointer; }
tr.cliquable:hover td { background: var(--surface-2); }
tr.selection td { background: var(--accent-fond); }
.defile { overflow-x: auto; }

/* Étiquettes */
.etiquette { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--texte-2); border: 1px solid var(--bordure); white-space: nowrap; }
.etiquette.termine, .etiquette.pret, .etiquette.connecte { background: var(--succes-fond); color: var(--succes); border-color: transparent; }
.etiquette.en_cours, .etiquette.en_attente { background: var(--accent-fond); color: var(--accent-texte); border-color: transparent; }
.etiquette.echec, .etiquette.indisponible, .etiquette.revoque { background: var(--danger-fond); color: var(--danger); border-color: transparent; }
.etiquette.annule, .etiquette.verrou { background: var(--alerte-fond); color: var(--alerte); border-color: transparent; }

.barre { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; min-width: 90px; border: 1px solid var(--bordure); }
.barre > span { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.barre.indetermine > span { width: 35% !important; animation: va-et-vient 1.4s ease-in-out infinite; }
@keyframes va-et-vient { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }
@media (prefers-reduced-motion: reduce) { .barre.indetermine > span { animation: none; } }

/* Postes */
.poste { border: 1px solid var(--bordure); border-radius: var(--rayon); padding: 12px; display: grid; gap: 8px; }
.poste + .poste { margin-top: 10px; }
.logiciels { display: flex; gap: 6px; flex-wrap: wrap; }

/* Explorateur de projet */
.explorateur { display: grid; grid-template-columns: minmax(320px, 1fr) minmax(360px, 1.1fr); gap: 16px; align-items: start; }
.fil { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; font-size: 13px; margin-bottom: 10px; }
.fil a { cursor: pointer; }
.fil span.sep { color: var(--texte-3); }
.element-nom { display: flex; align-items: center; gap: 8px; min-width: 0; }
.element-nom span.nom { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icone-type { width: 18px; text-align: center; color: var(--texte-3); flex: none; }
.depot { border: 1.5px dashed var(--bordure-forte); border-radius: var(--rayon); padding: 14px; text-align: center; color: var(--texte-3); font-size: 13px; }
.depot.survol { border-color: var(--accent); background: var(--accent-fond); color: var(--accent-texte); }
.visionneuse { background: var(--surface-2); border: 1px solid var(--bordure); border-radius: var(--rayon); min-height: 260px; display: grid; place-items: center; overflow: hidden; }
.visionneuse img { max-width: 100%; max-height: 70vh; display: block; cursor: zoom-in; }
.visionneuse.agrandie img { max-height: none; cursor: zoom-out; }
.medias { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.medias img { width: 100%; border-radius: var(--rayon); border: 1px solid var(--bordure); cursor: zoom-in; background: var(--surface-2); }

/* Pilotage */
.lot { display: grid; gap: 8px; }
.lot .appel { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; border: 1px solid var(--bordure); border-radius: var(--rayon); padding: 8px 10px; }
.outil-aide { font-size: 12.5px; color: var(--texte-2); white-space: pre-wrap; max-height: 140px; overflow: auto; }

/* Fenêtre modale */
.voile { position: fixed; inset: 0; background: rgb(10 15 12 / 55%); display: grid; place-items: center; padding: 20px; z-index: 10; }
.modale { background: var(--surface); border-radius: 12px; border: 1px solid var(--bordure); padding: 20px; width: min(620px, 100%); max-height: 90vh; overflow: auto; }
.modale.large { width: min(1200px, 100%); }
.modale img { max-width: 100%; }

/* Connexion */
.connexion { min-height: 100%; display: grid; place-items: center; padding: 20px; }
.connexion .carte { width: min(400px, 100%); padding: 28px; }
.connexion .marque { padding: 0 0 20px; }

/* Notifications */
.notifications { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 20; }
.notification { background: var(--texte); color: var(--fond); padding: 10px 14px; border-radius: var(--rayon); font-size: 13px; max-width: 360px; box-shadow: 0 4px 16px rgb(0 0 0 / 18%); }
.notification.erreur { background: var(--danger); color: #fff; }

@media (max-width: 900px) {
  .cadre { grid-template-columns: 1fr; }
  .menu { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px 16px; }
  .menu .marque { padding: 0 8px 0 0; }
  .menu .pied { display: none; }
  .contenu { padding: 16px; }
  .explorateur, .grille.deux { grid-template-columns: 1fr; }
}
