:root {
  --fond: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #f0f1f5;
  --bord: #e2e4ea;
  --texte: #161821;
  --doux: #626778;
  --accent: #4f46e5;
  --accent-clair: #4f46e5;
  --accent-texte: #ffffff;
  --ok: #15803d;
  --ok-fond: #dcfce7;
  --attention: #b45309;
  --attention-fond: #fef3c7;
  --panne: #b91c1c;
  --panne-fond: #fee2e2;
  --code-fond: #0f1117;
  --code-texte: #d8dbe5;
  --ombre: 0 1px 2px rgba(16, 18, 27, .06), 0 4px 16px rgba(16, 18, 27, .05);
  --rayon: 12px;
  color-scheme: light;
}
/* Mode sombre : choisi avec le bouton ☾ de la barre (clair par défaut). */
:root[data-theme="dark"] {
    --fond: #0a0c11;
    --surface: #141822;
    --surface-2: #1c2130;
    --bord: #262c3b;
    --texte: #eceef4;
    --doux: #949bb0;
    --accent: #6366f1;
    --accent-clair: #a5b4fc;
    --accent-texte: #ffffff;
    --ok: #4ade80;
    --ok-fond: rgba(74, 222, 128, .12);
    --attention: #fbbf24;
    --attention-fond: rgba(251, 191, 36, .12);
    --panne: #f87171;
    --panne-fond: rgba(248, 113, 113, .14);
    --code-fond: #090b0f;
    --ombre: none;
    color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--fond);
  color: var(--texte);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--accent-clair); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
.doux { color: var(--doux); }
.petit { font-size: 13px; }
code, pre, .mono { font-family: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace; }

/* --- Boutons --- */
.bouton {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--bord); background: var(--surface); color: var(--texte);
  padding: 7px 12px; border-radius: 8px; font: inherit; font-size: 14px; font-weight: 550;
  cursor: pointer; white-space: nowrap; min-height: 36px;
}
.bouton:hover:not(:disabled) { background: var(--surface-2); }
.bouton:disabled { opacity: .5; cursor: not-allowed; }
.bouton.principal { background: var(--accent); border-color: var(--accent); color: var(--accent-texte); }
.bouton.principal:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
.bouton.fantome { background: transparent; border-color: transparent; }
.bouton.fantome:hover { background: var(--surface-2); }
.bouton.large { width: 100%; justify-content: center; min-height: 44px; }
.bouton.danger { color: var(--panne); }
.bouton .roue { width: 14px; height: 14px; border-width: 2px; }

/* --- Authentification --- */
.centre { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.carte-auth {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--bord);
  border-radius: 16px; padding: 28px 24px; box-shadow: var(--ombre); display: grid; gap: 14px;
}
.carte-auth h1 { font-size: 20px; }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 550; color: var(--doux); }
input {
  font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--bord); background: var(--surface-2); color: var(--texte);
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.erreur { color: var(--panne); background: var(--panne-fond); padding: 8px 12px; border-radius: 8px; margin: 0; font-size: 14px; }
.etape { margin: 6px 0 0; }
.qr { justify-self: center; background: #fff; padding: 12px; border-radius: 10px; }
.qr img, .qr canvas { display: block; width: 184px; height: 184px; }
.secret { display: block; margin-top: 8px; word-break: break-all; padding: 8px; background: var(--surface-2); border-radius: 6px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 650; }
.logo img { width: 26px; height: 26px; }

.roue {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--bord); border-top-color: var(--accent);
  animation: tourne .8s linear infinite;
}
@keyframes tourne { to { transform: rotate(360deg); } }

/* --- Barre --- */
.barre {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 24px; background: color-mix(in srgb, var(--fond) 85%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--bord);
}
.barre-droite { display: flex; align-items: center; gap: 4px; }

/* --- Tuiles --- */
.tuiles {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px;
  padding: 20px 24px 0; max-width: 1400px; margin: 0 auto;
}
.tuile { background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); padding: 14px 16px; box-shadow: var(--ombre); }
.tuile .etiquette { font-size: 12px; color: var(--doux); font-weight: 550; text-transform: uppercase; letter-spacing: .04em; }
.tuile .valeur { font-size: 22px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tuile .detail { font-size: 12.5px; color: var(--doux); margin-top: 2px; }
.jauge { height: 5px; background: var(--surface-2); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.jauge > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.jauge.haute > i { background: var(--attention); }
.jauge.critique > i { background: var(--panne); }

/* --- Alertes --- */
#alertes { max-width: 1400px; margin: 0 auto; padding: 0 24px; }
.alerte {
  margin-top: 12px; padding: 10px 14px; border-radius: 10px; font-size: 14px;
  background: var(--attention-fond); color: var(--texte); border: 1px solid color-mix(in srgb, var(--attention) 35%, transparent);
}
.alerte.panne { background: var(--panne-fond); border-color: color-mix(in srgb, var(--panne) 35%, transparent); }
.alerte ul { margin: 4px 0 0; padding-left: 18px; }

/* --- Onglets --- */
.onglets {
  display: flex; gap: 4px; max-width: 1400px; margin: 20px auto 0; padding: 0 24px;
  border-bottom: 1px solid var(--bord); overflow-x: auto; scrollbar-width: none;
}
.onglets button {
  border: 0; background: none; font: inherit; font-weight: 550; color: var(--doux);
  padding: 10px 12px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.onglets button.actif { color: var(--texte); border-bottom-color: var(--accent-clair); }
.onglets .compteur { font-size: 12px; background: var(--surface-2); border-radius: 10px; padding: 1px 7px; margin-left: 4px; }

.contenu { max-width: 1400px; margin: 0 auto; padding: 20px 24px 48px; }

/* --- Cartes d'applications --- */
.grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 14px; }
.carte {
  --etat: var(--ok);
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon);
  box-shadow: var(--ombre); padding: 14px 16px 14px 20px; display: flex; flex-direction: column; gap: 10px; min-width: 0;
}
/* Liseré d'état : une panne se repère sans lire les cartes. */
.carte::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--etat); }
.carte.attention { --etat: var(--attention); }
.carte.panne { --etat: var(--panne); border-color: color-mix(in srgb, var(--panne) 45%, var(--bord)); }
.carte-tete { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.carte-tete .titre { min-width: 0; }
.carte-tete h3 { font-size: 16px; }
.carte-tete a.url { font-size: 13px; display: inline-flex; align-items: center; gap: 4px; margin-top: 2px; word-break: break-all; }
.carte-tete a.url svg { width: 12px; height: 12px; flex: none; opacity: .7; }
.etat-tete { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; text-align: right; }
.pastille { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 20px; white-space: nowrap; }
.pastille::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pastille.ok { color: var(--ok); background: var(--ok-fond); }
.pastille.attention { color: var(--attention); background: var(--attention-fond); }
.pastille.panne { color: var(--panne); background: var(--panne-fond); }
.pastille.neutre { color: var(--doux); background: var(--surface-2); }
.bandeau { background: var(--panne-fond); padding: 6px 10px; border-radius: 8px; }
.carte.attention .bandeau { background: var(--attention-fond); color: var(--attention); }

.lignes { display: grid; gap: 5px; font-size: 13.5px; }
.ligne { display: grid; grid-template-columns: 96px 1fr; gap: 8px; align-items: baseline; }
.ligne > span:first-child { color: var(--doux); font-size: 12.5px; }
.ligne .valeur { min-width: 0; overflow-wrap: anywhere; }
/* Commit sur une seule ligne : le message complet reste au survol. */
.commit-ligne { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.commit-ligne .sujet { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.commit-ligne .quand { flex: none; font-size: 12.5px; }
.commit { flex: none; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; background: var(--surface-2); padding: 1px 6px; border-radius: 5px; }
.en-attente { flex: none; color: var(--attention); background: var(--attention-fond); font-size: 12px; font-weight: 600; padding: 0 7px; border-radius: 10px; }
.probleme { color: var(--panne); font-size: 13px; }

.conteneurs { display: grid; gap: 8px; }
.resume-conteneurs {
  display: flex; align-items: center; gap: 6px; width: 100%; text-align: left;
  font: inherit; font-size: 13px; color: var(--texte); background: var(--surface-2);
  border: 1px solid transparent; border-radius: 8px; padding: 6px 10px; cursor: pointer;
}
.resume-conteneurs:hover { border-color: var(--bord); }
.resume-conteneurs code { font-size: 12px; }
.resume-conteneurs .texte { flex: 1; min-width: 0; }
.resume-conteneurs .point { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; }
.resume-conteneurs.ko { color: var(--panne); background: var(--panne-fond); }
.resume-conteneurs.ko .point { background: var(--panne); }
.resume-conteneurs .chevron { margin-left: auto; display: inline-flex; color: var(--doux); transition: transform .15s; }
.resume-conteneurs .chevron svg { width: 14px; height: 14px; }
.resume-conteneurs[aria-expanded="true"] .chevron { transform: rotate(90deg); }
.puces { display: flex; flex-wrap: wrap; gap: 6px; }
.puce {
  font-size: 12px; padding: 3px 8px; border-radius: 6px; background: var(--surface-2);
  border: 1px solid var(--bord); display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--texte);
}
.puce:hover { border-color: var(--accent-clair); }
.puce .point { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.puce.arrete .point { background: var(--panne); }
.puce.malade .point { background: var(--attention); }
.puce .mem { color: var(--doux); }

.actions { margin-top: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; border-top: 1px solid var(--bord); padding-top: 12px; }
.actions .espace { flex: 1; }
.bouton.icone { color: var(--doux); border-color: var(--bord); background: transparent; padding: 0; width: 36px; justify-content: center; }
.bouton.icone:hover { color: var(--texte); background: var(--surface-2); }
.bouton.icone svg { width: 16px; height: 16px; }
.bouton.principal { box-shadow: 0 1px 0 rgba(255, 255, 255, .12) inset, 0 4px 14px color-mix(in srgb, var(--accent) 35%, transparent); }

/* --- Tableaux --- */
.bloc { background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); box-shadow: var(--ombre); overflow: hidden; margin-bottom: 20px; }
.bloc > h2 { font-size: 15px; padding: 14px 16px; border-bottom: 1px solid var(--bord); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.defile { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--doux); text-transform: uppercase; letter-spacing: .04em; padding: 10px 16px; background: var(--surface-2); white-space: nowrap; }
td { padding: 10px 16px; border-top: 1px solid var(--bord); vertical-align: middle; }
td.nombre { font-variant-numeric: tabular-nums; white-space: nowrap; }
td.fin { text-align: right; white-space: nowrap; }
td code { font-size: 12.5px; }
.vide { padding: 24px 16px; color: var(--doux); text-align: center; }

/* --- Tiroir --- */
#voile { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 20; }
#tiroir {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(920px, 100vw); z-index: 21;
  background: var(--surface); border-left: 1px solid var(--bord); display: flex; flex-direction: column;
  box-shadow: -8px 0 32px rgba(0, 0, 0, .18);
}
#tiroir > header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--bord); }
#tiroir h2 { font-size: 16px; }
#tiroir-outils { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 20px; border-bottom: 1px solid var(--bord); }
#tiroir-outils:empty { display: none; }
#tiroir-outils .bouton.actif { border-color: var(--accent); color: var(--accent); }
#tiroir-texte {
  flex: 1; margin: 0; overflow: auto; padding: 14px 20px; background: var(--code-fond); color: var(--code-texte);
  font-size: 12.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word;
}

dialog {
  border: 1px solid var(--bord); border-radius: 14px; padding: 22px; width: min(440px, calc(100vw - 32px));
  background: var(--surface); color: var(--texte); box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}
dialog::backdrop { background: rgba(0, 0, 0, .35); }
dialog h2 { font-size: 17px; margin-bottom: 8px; }
.boutons-fin { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* --- Téléphone --- */
@media (max-width: 640px) {
  .barre { padding: 10px 16px; }
  .sur-large, #date-releve { display: none; }
  .tuiles { padding: 16px 16px 0; grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .tuile .valeur { font-size: 19px; }
  #alertes, .onglets { padding-left: 16px; padding-right: 16px; }
  .contenu { padding: 16px 16px 40px; }
  .grille { grid-template-columns: 1fr; }
  .ligne { grid-template-columns: 82px 1fr; }
  .commit-ligne .quand { display: none; }
  th, td { padding: 9px 12px; }
  .cacher-mobile { display: none; }
}

/* Sous-titre gris collé au titre de bloc, le bouton éventuel reste à droite. */
.bloc > h2 { justify-content: flex-start; flex-wrap: wrap; }
.bloc > h2 > .doux { font-weight: 450; }
.bloc > h2 > .bouton { margin-left: auto; }

.bouton.theme { width: 36px; padding: 0; justify-content: center; font-size: 16px; }
