:root {
  --violet: #3B2A7A;
  --violet-clair: #EEEAF8;
  --or: #E0A030;
  --vert: #2E7D4F;
  --rouge: #C0392B;
  --orange: #D9822B;
  --texte: #1E1B2E;
  --gris: #6B6880;
  --bord: #E2DFEC;
  --fond: #F6F5FA;
  --carte: #FFFFFF;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --violet: #B9A8FF;
    --violet-clair: #2A2442;
    --texte: #ECEAF5;
    --gris: #A19DB8;
    --bord: #34304A;
    --fond: #15131F;
    --carte: #1E1B2C;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fond);
  color: var(--texte);
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.2; }
h1 { font-size: 1.4rem; color: var(--violet); }
h2 { font-size: 1.15rem; color: var(--violet); }
h3 { font-size: .95rem; margin-top: 1.2em; }
.discret { color: var(--gris); font-size: .85rem; }
.erreur { color: var(--rouge); font-size: .9rem; }
button { font: inherit; cursor: pointer; }
input, select, textarea {
  font: inherit; width: 100%; padding: .55em .7em; margin-top: .25em;
  border: 1px solid var(--bord); border-radius: 8px; background: var(--carte); color: var(--texte);
}
label { display: block; font-size: .85rem; color: var(--gris); margin-bottom: .7em; }
.principal, .secondaire, .danger {
  border: 0; border-radius: 8px; padding: .6em 1.1em; font-weight: 600;
}
.principal { background: var(--violet); color: #fff; }
@media (prefers-color-scheme: dark) { .principal { color: #15131F; } }
.secondaire { background: var(--violet-clair); color: var(--violet); }
.danger { background: transparent; color: var(--rouge); border: 1px solid var(--rouge); }
.lien { background: none; border: 0; color: var(--violet); padding: .4em .5em; font-weight: 600; }

/* Connexion */
.connexion { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.connexion .carte { width: 100%; max-width: 360px; text-align: center; }
.connexion label { text-align: left; }
.connexion .principal { width: 100%; margin-top: .4em; }
.logo {
  width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 18px; background: #3B2A7A; color: var(--or);
  display: grid; place-items: center; font-weight: 800; letter-spacing: .5px;
}
.carte { background: var(--carte); border: 1px solid var(--bord); border-radius: 14px; padding: 20px; }

/* Barre */
.barre {
  position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 10px 16px; background: var(--carte); border-bottom: 3px solid var(--or);
}
.barre strong { color: var(--violet); margin-right: 8px; }
.actions-barre { display: flex; gap: 2px; flex-shrink: 0; }
.contenu { max-width: 1100px; margin: 0 auto; padding: 16px; }

/* Totaux */
.totaux { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.tuile { background: var(--carte); border: 1px solid var(--bord); border-radius: 12px; padding: 12px 14px; }
.tuile .valeur { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tuile .libelle { color: var(--gris); font-size: .8rem; }
.alerte { background: var(--violet-clair); border-radius: 8px; padding: 8px 12px; font-size: .85rem; }
.filtres { margin-bottom: 12px; }

/* Liste */
.liste { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.atelier {
  text-align: left; width: 100%; background: var(--carte); border: 1px solid var(--bord); border-radius: 14px;
  padding: 14px; color: inherit; transition: border-color .15s;
  display: flex; flex-direction: column; justify-content: flex-start;
}
.atelier:hover { border-color: var(--violet); }
.atelier.suspendu { border-left: 5px solid var(--rouge); }
.entete-atelier { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.entete-atelier .nom { font-weight: 700; font-size: 1.02rem; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.badge { font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--violet-clair); color: var(--violet); white-space: nowrap; }
.badge.ok { background: #E3F3EA; color: var(--vert); }
.badge.alerte-b { background: #FBE7E4; color: var(--rouge); }
.badge.attention { background: #FCEFDD; color: var(--orange); }
@media (prefers-color-scheme: dark) {
  .badge.ok { background: #1D3A2A; color: #7FD6A2; }
  .badge.alerte-b { background: #4A2420; color: #FF9C8F; }
  .badge.attention { background: #4A3520; color: #F5B970; }
}
.jauge { margin: 6px 0; font-size: .8rem; }
.jauge .ligne { display: flex; justify-content: space-between; color: var(--gris); }
.jauge .ligne b { color: var(--texte); font-variant-numeric: tabular-nums; }
.barre-jauge { height: 6px; border-radius: 3px; background: var(--bord); overflow: hidden; margin-top: 3px; }
.barre-jauge span { display: block; height: 100%; background: var(--violet); border-radius: 3px; }
.barre-jauge span.haut { background: var(--orange); }
.barre-jauge span.plein { background: var(--rouge); }
.pied-atelier { margin-top: auto !important; display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; font-size: .78rem; color: var(--gris); }

/* Fiche */
dialog {
  width: min(640px, calc(100vw - 16px)); max-height: calc(100vh - 32px); border: 0; border-radius: 16px; padding: 20px;
  background: var(--carte); color: var(--texte);
}
dialog::backdrop { background: rgba(20, 16, 40, .55); }
.fermer { position: sticky; top: 0; float: right; margin: -8px -8px 0 0; }
.fermer button { background: var(--violet-clair); color: var(--violet); border: 0; border-radius: 99px; width: 34px; height: 34px; }
.grille2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 480px) { .grille2 { grid-template-columns: 1fr; } }
.chiffres { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin: 10px 0; }
.chiffres div { background: var(--fond); border-radius: 10px; padding: 8px 10px; }
.chiffres b { display: block; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.chiffres span { font-size: .75rem; color: var(--gris); }
.rangee { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.bloc { border-top: 1px solid var(--bord); margin-top: 16px; padding-top: 12px; }
.admin { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; }
.secret {
  font-family: ui-monospace, monospace; font-size: 1.1rem; background: var(--fond); border: 1px dashed var(--violet);
  border-radius: 8px; padding: 8px 12px; user-select: all; word-break: break-all;
}
.journal-ligne { border-bottom: 1px solid var(--bord); padding: 8px 0; font-size: .85rem; }
.journal-ligne .quand { color: var(--gris); font-size: .78rem; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); max-width: calc(100vw - 32px);
  background: #1E1B2E; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: .9rem; z-index: 10;
}
.toast.erreur-t { background: var(--rouge); }
