/* Management — feuille de style unique.
   Thème sombre par défaut, clair au choix (data-theme sur <html>) ou selon l'OS. */

:root {
  color-scheme: dark;
  --fond: #111214;
  --surface-1: #191919;
  --surface-2: #212224;
  --surface-3: #2a2b2e;
  --bordure: #2f3034;
  --bordure-forte: #44464b;
  --texte: #efefef;
  --texte-2: #a3a3a3;
  --texte-3: #7a7a7a;
  --accent: #338ced;
  --accent-fond: rgba(51, 140, 237, .14);
  --serie-1: #338ced;
  --serie-2: #e76624;
  --serie-3: #00a888;
  --bon: #0aac23;
  --attention: #fbb315;
  --serieux: #f18a59;
  --critique: #dc3c3d;
  --critique-texte: #ff7b7c;
  --bon-texte: #3fd157;
  --attention-texte: #fbb315;
  --grille: #2a2b2e;
  --ombre: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.25);
  --rayon: 10px;
  --police: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: light) {
  :root:where(:not([data-theme="dark"])) {
    color-scheme: light;
    --fond: #f4f4f5; --surface-1: #ffffff; --surface-2: #f7f7f8; --surface-3: #ececee;
    --bordure: #e3e3e6; --bordure-forte: #c9c9ce;
    --texte: #191919; --texte-2: #5c5c5c; --texte-3: #8a8a8a;
    --accent: #257de0; --accent-fond: rgba(37,125,224,.10);
    --serie-1: #257de0; --serie-2: #f47230; --serie-3: #00b894;
    --critique-texte: #c42b2c; --bon-texte: #006c10; --attention-texte: #8a5d00;
    --grille: #ececee; --ombre: 0 1px 2px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.06);
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --fond: #f4f4f5; --surface-1: #ffffff; --surface-2: #f7f7f8; --surface-3: #ececee;
  --bordure: #e3e3e6; --bordure-forte: #c9c9ce;
  --texte: #191919; --texte-2: #5c5c5c; --texte-3: #8a8a8a;
  --accent: #257de0; --accent-fond: rgba(37,125,224,.10);
  --serie-1: #257de0; --serie-2: #f47230; --serie-3: #00b894;
  --critique-texte: #c42b2c; --bon-texte: #006c10; --attention-texte: #8a5d00;
  --grille: #ececee; --ombre: 0 1px 2px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--police); font-size: 14px; line-height: 1.45;
  background: var(--fond); color: var(--texte);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.discret { color: var(--texte-2); }
.tres-discret { color: var(--texte-3); }
.nombre { font-variant-numeric: tabular-nums; }
.cache { display: none !important; }

.chargement-initial { padding: 40px; color: var(--texte-2); }

/* ------------------------------------------------------------ structure */

.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.app.sans-menu { display: block; }

.menu {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--surface-1); border-right: 1px solid var(--bordure);
  display: flex; flex-direction: column;
}
.menu-tete { display: flex; align-items: center; gap: 10px; padding: 16px 16px 12px; }
.menu-tete img { width: 26px; height: 26px; }
.menu-tete strong { font-size: 15px; }
.menu-recherche { padding: 0 12px 8px; }
.menu-recherche input { width: 100%; }
.menu nav { padding: 4px 8px 16px; flex: 1; }
.menu-groupe { margin-top: 14px; }
.menu-groupe-titre { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--texte-3); padding: 4px 8px; }
.menu-lien {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 7px;
  color: var(--texte); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.menu-lien:hover { background: var(--surface-2); text-decoration: none; }
.menu-lien.actif { background: var(--accent-fond); color: var(--accent); }
.menu-lien .nom { overflow: hidden; text-overflow: ellipsis; flex: 1; }
.menu-pied { padding: 12px; border-top: 1px solid var(--bordure); display: flex; gap: 6px; flex-wrap: wrap; }

.contenu { min-width: 0; padding: 22px 28px 60px; max-width: 1500px; }
.entete-page { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.entete-page .titre { display: flex; flex-direction: column; gap: 4px; }
.entete-page .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.bouton-menu { display: none; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .menu { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 50; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--ombre); }
  .menu.ouvert { transform: none; }
  .contenu { padding: 14px 14px 60px; }
  .bouton-menu { display: inline-flex; }
}

/* ------------------------------------------------------------ éléments */

.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 7px 12px; border-radius: 8px; border: 1px solid var(--bordure-forte);
  background: var(--surface-2); cursor: pointer; white-space: nowrap; font-size: 13px;
}
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primaire { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primaire:hover { filter: brightness(1.08); }
.btn.danger { color: var(--critique-texte); border-color: color-mix(in srgb, var(--critique) 45%, transparent); }
.btn.danger:hover { background: color-mix(in srgb, var(--critique) 12%, transparent); }
.btn.petit { padding: 4px 9px; font-size: 12px; border-radius: 7px; }
.btn.fantome { background: transparent; border-color: transparent; }
.btn.fantome:hover { background: var(--surface-2); }

input[type=text], input[type=password], input[type=email], input[type=number], input[type=search], input[type=date], input[type=datetime-local], input[type=url], select, textarea {
  background: var(--surface-2); border: 1px solid var(--bordure-forte); border-radius: 8px;
  padding: 7px 10px; min-width: 0;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { width: 100%; min-height: 90px; resize: vertical; }
label.champ { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--texte-2); }
label.case { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }

.carte {
  background: var(--surface-1); border: 1px solid var(--bordure); border-radius: var(--rayon);
  padding: 16px;
}
.carte + .carte { margin-top: 14px; }
.carte-titre { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.grille { display: grid; gap: 14px; }
.grille.g2 { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.grille.g3 { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.pile > * + * { margin-top: 14px; }

.pastille { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--texte-3); }
.pastille.bon { background: var(--bon); }
.pastille.attention { background: var(--attention); }
.pastille.critique { background: var(--critique); }

.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 500;
  padding: 2px 8px; border-radius: 99px; border: 1px solid var(--bordure-forte); color: var(--texte-2); white-space: nowrap;
}
.badge.bon { color: var(--bon-texte); border-color: color-mix(in srgb, var(--bon) 45%, transparent); }
.badge.attention { color: var(--attention-texte); border-color: color-mix(in srgb, var(--attention) 50%, transparent); }
.badge.critique { color: var(--critique-texte); border-color: color-mix(in srgb, var(--critique) 50%, transparent); }
.badge.info { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }

/* ------------------------------------------------------------ dashboard */

.serveurs { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; margin-bottom: 18px; }
.serveur .ligne { display: grid; grid-template-columns: 70px 1fr 92px; gap: 10px; align-items: center; margin-top: 8px; font-size: 13px; }
.jauge { height: 8px; border-radius: 99px; background: color-mix(in srgb, var(--accent) 18%, transparent); overflow: hidden; }
.jauge > span { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.jauge.attention { background: color-mix(in srgb, var(--attention) 20%, transparent); }
.jauge.attention > span { background: var(--attention); }
.jauge.critique { background: color-mix(in srgb, var(--critique) 20%, transparent); }
.jauge.critique > span { background: var(--critique); }

.alertes { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.alerte {
  display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-radius: 8px;
  background: var(--surface-1); border: 1px solid var(--bordure); border-left: 3px solid var(--attention);
}
.alerte.critique { border-left-color: var(--critique); }
.alerte .quoi { flex: 1; }

.section-titre { display: flex; align-items: baseline; gap: 10px; margin: 22px 0 10px; }
.section-titre h2 { font-size: 15px; }

.carte-site { display: flex; flex-direction: column; gap: 12px; cursor: pointer; transition: border-color .12s; position: relative; }
.carte-site:hover { border-color: var(--bordure-forte); }
.carte-site .tete { display: flex; align-items: center; gap: 10px; }
.carte-site .tete .nom { font-weight: 600; font-size: 15px; }
.carte-site .tete .domaine { font-size: 12px; color: var(--texte-2); }
.carte-site .tete .droite { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.monogramme {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex: none;
  font-weight: 700; font-size: 14px; color: #fff; background: var(--surface-3);
}
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.kpi { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kpi .libelle { font-size: 12px; color: var(--texte-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .valeur { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi .sous { font-size: 11.5px; color: var(--texte-3); }
.kpis.grands .kpi .valeur { font-size: 26px; }
.carte-site .kpis .kpi .valeur { font-size: 18px; }
.carte-site .pied { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; font-size: 12px; color: var(--texte-2); }
.carte-site .erreur { font-size: 12px; color: var(--critique-texte); }

/* tableau des autres sites */
.table-wrap { overflow-x: auto; border: 1px solid var(--bordure); border-radius: var(--rayon); background: var(--surface-1); }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; font-weight: 500; color: var(--texte-2); font-size: 12px; padding: 9px 12px; border-bottom: 1px solid var(--bordure); white-space: nowrap; background: var(--surface-1); position: sticky; top: 0; }
table.t td { padding: 8px 12px; border-bottom: 1px solid var(--bordure); vertical-align: middle; }
table.t td.date { white-space: nowrap; }
table.t tr:last-child td { border-bottom: none; }
table.t tr.cliquable { cursor: pointer; }
table.t tr.cliquable:hover td { background: var(--surface-2); }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.t td.actions { white-space: nowrap; text-align: right; }
table.t td.actions .btn + .btn { margin-left: 4px; }
.table-outils { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.table-outils input[type=search] { min-width: 220px; }
.vide { padding: 24px; text-align: center; color: var(--texte-2); }

/* ------------------------------------------------------------ page site */

.onglets { display: flex; gap: 2px; border-bottom: 1px solid var(--bordure); margin-bottom: 18px; overflow-x: auto; scrollbar-width: thin; }
.onglet {
  padding: 9px 14px; border: none; background: none; cursor: pointer; color: var(--texte-2);
  border-bottom: 2px solid transparent; white-space: nowrap; margin-bottom: -1px;
}
.onglet:hover { color: var(--texte); }
.onglet.actif { color: var(--texte); border-bottom-color: var(--accent); font-weight: 500; }
.parametres { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }

dl.infos { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: 13px; }
dl.infos dt { color: var(--texte-2); }
dl.infos dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

pre.journal {
  background: var(--surface-2); border: 1px solid var(--bordure); border-radius: 8px; padding: 12px;
  font-family: var(--mono); font-size: 12px; line-height: 1.5; overflow: auto; max-height: 70vh; margin: 0;
  white-space: pre-wrap; word-break: break-all;
}
pre.journal .err { color: var(--critique-texte); }
pre.journal .warn { color: var(--attention-texte); }

.formulaire { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; align-items: end; }
.formulaire .plein { grid-column: 1 / -1; }
.formulaire .boutons { grid-column: 1 / -1; display: flex; gap: 8px; }

.message { padding: 10px 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--bordure); }
.message.erreur { border-color: color-mix(in srgb, var(--critique) 45%, transparent); color: var(--critique-texte); }
.message.info { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }

/* ------------------------------------------------------------ graphiques */

.graphique { position: relative; width: 100%; }
.graphique svg { display: block; width: 100%; overflow: visible; }
.graphique .axe text { fill: var(--texte-3); font-size: 11px; }
.graphique .grille-ligne { stroke: var(--grille); stroke-width: 1; }
.graphique .legende { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--texte-2); margin-bottom: 6px; }
.graphique .legende i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.infobulle {
  position: absolute; pointer-events: none; z-index: 5; background: var(--surface-3); color: var(--texte);
  border: 1px solid var(--bordure-forte); border-radius: 8px; padding: 7px 9px; font-size: 12px; box-shadow: var(--ombre);
  white-space: nowrap; transform: translate(-50%, calc(-100% - 10px));
}
.infobulle b { font-variant-numeric: tabular-nums; }
.infobulle i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }
.etincelle { width: 100%; height: 36px; }

/* ------------------------------------------------------------ connexion */

.ecran-connexion { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.boite-connexion { width: 100%; max-width: 380px; }
.boite-connexion .carte { padding: 26px; }
.boite-connexion h1 { margin-bottom: 4px; }
.boite-connexion form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.boite-connexion input { width: 100%; }
.code-totp { letter-spacing: .3em; font-size: 20px; text-align: center; font-family: var(--mono); }
.qr { display: block; margin: 8px auto; border-radius: 8px; background: #fff; padding: 6px; }

/* ------------------------------------------------------------ modale & toasts */

.voile { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modale { width: 100%; max-width: 480px; background: var(--surface-1); border: 1px solid var(--bordure-forte); border-radius: 12px; padding: 20px; box-shadow: var(--ombre); }
.modale h3 { margin-bottom: 10px; font-size: 16px; }
.modale .corps { display: flex; flex-direction: column; gap: 12px; }
.modale .boutons { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

.toasts { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--surface-3); border: 1px solid var(--bordure-forte); padding: 10px 14px; border-radius: 9px; box-shadow: var(--ombre); max-width: 420px; }
.toast.erreur { border-color: var(--critique); }
.toast.bon { border-color: var(--bon); }

.chargement { color: var(--texte-2); padding: 18px 0; }
.chargement::before { content: ''; display: inline-block; width: 12px; height: 12px; border: 2px solid var(--texte-3); border-top-color: transparent; border-radius: 50%; margin-right: 8px; vertical-align: -1px; animation: tourne .8s linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .chargement::before { animation: none; } }
