:root {
  color-scheme: dark;
  --fond: #0f1218;
  --surface: #171b23;
  --surface-2: #1f2430;
  --trait: #2c3340;
  --texte: #e6e9ef;
  --discret: #98a2b3;
  --accent: #d9502e;
  --accent-clair: #f0704c;
  --ok: #3fb97c;
  --attente: #e2a93b;
  --ko: #ef5a5a;
  --rayon: 8px;
  --mono: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }
body {
  background: var(--fond);
  color: var(--texte);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

h1 { font-size: 1.5rem; margin: 0 0 1rem; font-weight: 650; }
h2 { font-size: 1.05rem; margin: 1.75rem 0 .6rem; font-weight: 600; }
p { margin: 0 0 .75rem; }
a { color: var(--accent-clair); }
code { font-family: var(--mono); }
:focus-visible { outline: 2px solid var(--accent-clair); outline-offset: 2px; }

.marque { font-weight: 700; font-size: 1.15rem; letter-spacing: .01em; }
.marque span { color: var(--accent-clair); }

/* Structure */
.app { display: grid; grid-template-columns: 210px minmax(0, 1fr); min-height: 100%; }
.menu {
  background: var(--surface);
  border-right: 1px solid var(--trait);
  padding: 1.1rem .75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
}
.menu .marque { padding: 0 .55rem; }
#navigation { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.lien-menu {
  background: none;
  border: 0;
  border-radius: 6px;
  color: var(--discret);
  cursor: pointer;
  font: inherit;
  padding: .5rem .6rem;
  text-align: left;
  min-height: 40px;
}
.lien-menu:hover { background: var(--surface-2); color: var(--texte); }
.lien-menu.actif { background: var(--surface-2); color: var(--texte); font-weight: 600; box-shadow: inset 2px 0 0 var(--accent); }
.pied-menu { display: flex; flex-direction: column; gap: .4rem; padding: 0 .3rem; }
.nom-compte { color: var(--discret); font-size: .85rem; overflow-wrap: anywhere; padding: 0 .25rem; }
.contenu { padding: 1.5rem 2rem 3rem; max-width: 1200px; width: 100%; }

/* Boutons */
.bouton {
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--trait);
  border-radius: 6px;
  color: var(--texte);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: .9rem;
  justify-content: center;
  min-height: 36px;
  padding: .35rem .8rem;
  text-decoration: none;
  white-space: nowrap;
}
.bouton:hover:not(:disabled) { border-color: #475063; background: #272d3a; }
.bouton:disabled { opacity: .5; cursor: not-allowed; }
.bouton.principal { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.bouton.principal:hover:not(:disabled) { background: var(--accent-clair); border-color: var(--accent-clair); }
.bouton.danger { color: var(--ko); border-color: #5a3036; }
.bouton.danger:hover:not(:disabled) { background: #3a2226; border-color: var(--ko); }
.bouton.discret { background: none; color: var(--discret); }
.bouton.discret:hover:not(:disabled) { color: var(--texte); }
.bouton.large { width: 100%; min-height: 44px; }
.actions { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; justify-content: flex-end; }

/* Connexion */
.connexion { display: grid; place-items: center; min-height: 100%; padding: 1.5rem; }
.carte-connexion {
  background: var(--surface);
  border: 1px solid var(--trait);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: .9rem;
  max-width: 420px;
  padding: 1.75rem;
  width: 100%;
}
.carte-connexion h2 { margin: 0; }
.carte-connexion p { margin: 0; }
.formulaire-code { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .5rem; }
.formulaire-code .erreur-texte { grid-column: 1 / -1; margin: 0; }
.etapes { margin: 0; padding-left: 1.2rem; color: var(--discret); }
.qr { align-self: center; border-radius: 6px; max-width: 100%; height: auto; image-rendering: pixelated; }
.secret { display: block; margin-top: .4rem; overflow-wrap: anywhere; color: var(--discret); }
.codes { list-style: none; margin: 0; padding: .75rem; display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; background: var(--surface-2); border-radius: 6px; }
.erreur-texte { color: var(--ko); }

input[type="text"], input[type="search"] {
  background: var(--fond);
  border: 1px solid var(--trait);
  border-radius: 6px;
  color: var(--texte);
  font: inherit;
  min-height: 38px;
  padding: .4rem .65rem;
  width: 100%;
}
input:focus { border-color: var(--accent-clair); outline: none; }

/* Tuiles */
.bandeau { border-radius: var(--rayon); margin-bottom: 1rem; padding: .65rem .9rem; border: 1px solid; }
.bandeau.ok { background: #14261e; border-color: #24513c; color: #a5e4c6; }
.bandeau.ko { background: #2a191c; border-color: #5a3036; }
.bandeau ul { margin: .25rem 0 0; padding-left: 1.2rem; }
.tuiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .75rem; }
.tuile { background: var(--surface); border: 1px solid var(--trait); border-radius: var(--rayon); padding: .85rem 1rem; }
.tuile-libelle { color: var(--discret); font-size: .85rem; }
.tuile-valeur { font-size: 1.6rem; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.3; }
.tuile-detail { color: var(--discret); font-size: .82rem; margin-top: .25rem; }
progress { appearance: none; background: var(--surface-2); border: 0; border-radius: 3px; display: block; height: 6px; margin-top: .4rem; overflow: hidden; width: 100%; }
progress::-webkit-progress-bar { background: var(--surface-2); }
progress::-webkit-progress-value { background: var(--accent-clair); }
progress::-moz-progress-bar { background: var(--accent-clair); }
progress.haut::-webkit-progress-value { background: var(--ko); }
progress.haut::-moz-progress-bar { background: var(--ko); }

/* Tableaux */
.tableau-zone { background: var(--surface); border: 1px solid var(--trait); border-radius: var(--rayon); overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { border-bottom: 1px solid var(--trait); padding: .6rem .85rem; text-align: left; vertical-align: middle; }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
thead th { color: var(--discret); font-size: .8rem; font-weight: 500; white-space: nowrap; }
tbody th { font-weight: 550; }
table.dense th, table.dense td { font-size: .84rem; padding: .35rem .6rem; vertical-align: top; }
.nombre { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.droite { text-align: right; }
.adresse, .note, .mise-a-jour, .vide { color: var(--discret); font-size: .82rem; font-weight: 400; }
.cellule { max-width: 360px; overflow-wrap: anywhere; }
.horodatage { white-space: nowrap; font-variant-numeric: tabular-nums; }
.lecteur { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.mise-a-jour { margin-top: .75rem; }

.pastille { align-items: center; display: inline-flex; gap: .4rem; white-space: nowrap; }
.pastille i { border-radius: 50%; display: block; height: 8px; width: 8px; background: var(--discret); }
.pastille.ok i { background: var(--ok); }
.pastille.attente i { background: var(--attente); }
.pastille.ko i { background: var(--ko); }
.pastille.ko { color: var(--ko); }

/* Onglets */
.onglets { border-bottom: 1px solid var(--trait); display: flex; flex-wrap: wrap; gap: 2px; margin-bottom: 1rem; }
.onglet { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--discret); cursor: pointer; font: inherit; margin-bottom: -1px; min-height: 40px; padding: .45rem .85rem; }
.onglet:hover { color: var(--texte); }
.onglet.actif { border-bottom-color: var(--accent-clair); color: var(--texte); font-weight: 600; }

/* Consoles */
.barre-serveur { align-items: center; display: flex; flex-wrap: wrap; gap: .75rem; justify-content: space-between; margin-bottom: .75rem; }
.infos-serveur { align-items: center; display: flex; flex-wrap: wrap; gap: .85rem; }
.sortie {
  background: #0a0c10;
  border: 1px solid var(--trait);
  border-radius: var(--rayon);
  color: #c6ccd6;
  font: .78rem/1.45 var(--mono);
  height: min(58vh, 620px);
  min-height: 260px;
  overflow: auto;
  padding: .6rem .75rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.ligne-erreur { color: #ff8f8f; }
.ligne-alerte { color: #e9c46a; }
.ligne-commande { color: var(--accent-clair); font-weight: 600; }
.ligne-reponse { color: #9fe0c0; }
.systeme { color: #8ab4f8; }
.ligne-commande-form { display: grid; gap: .5rem; grid-template-columns: minmax(0, 1fr) auto; margin-top: .6rem; }
.ligne-commande-form input { font-family: var(--mono); font-size: .88rem; }
.raccourcis { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }

/* Données */
.explorateur { display: grid; gap: 1rem; grid-template-columns: 230px minmax(0, 1fr); }
.liste-donnees { background: var(--surface); border: 1px solid var(--trait); border-radius: var(--rayon); max-height: 70vh; overflow-y: auto; padding: .3rem; }
.element-liste { align-items: center; background: none; border: 0; border-radius: 5px; color: var(--texte); cursor: pointer; display: flex; font: inherit; font-size: .88rem; gap: .5rem; justify-content: space-between; min-height: 34px; padding: .25rem .5rem; text-align: left; width: 100%; }
.element-liste:hover { background: var(--surface-2); }
.element-liste.actif { background: var(--surface-2); box-shadow: inset 2px 0 0 var(--accent); }
.detail-donnees h2 { margin-top: 0; }
.barre-donnees { align-items: center; display: flex; gap: .75rem; margin-bottom: .5rem; }
.barre-donnees input { max-width: 260px; }
.bloc-texte { background: var(--surface); border: 1px solid var(--trait); border-radius: var(--rayon); font: .84rem var(--mono); margin: 0; overflow: auto; padding: .75rem; }

/* Dialogue et message */
.dialogue { background: var(--surface); border: 1px solid var(--trait); border-radius: 10px; color: var(--texte); max-width: 420px; padding: 1.25rem; width: calc(100% - 2rem); }
.dialogue::backdrop { background: rgb(0 0 0 / .6); }
.dialogue h2 { margin: 0 0 .5rem; }
.message { background: var(--surface-2); border: 1px solid var(--trait); border-radius: var(--rayon); bottom: 1rem; box-shadow: 0 6px 24px rgb(0 0 0 / .4); left: 50%; max-width: calc(100% - 2rem); padding: .55rem .9rem; position: fixed; transform: translateX(-50%); z-index: 10; }
.message.erreur { border-color: var(--ko); color: var(--ko); }

/* Téléphone */
@media (max-width: 760px) {
  .app { display: block; }
  .menu {
    border-bottom: 1px solid var(--trait);
    border-right: 0;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: .25rem .6rem;
    height: auto;
    padding: .5rem .6rem;
    z-index: 5;
  }
  .menu .marque { padding: 0 .2rem; }
  .pied-menu { flex-direction: row; align-items: center; margin-left: auto; padding: 0; }
  .nom-compte { display: none; }
  #navigation { flex: 1 0 100%; flex-direction: row; overflow-x: auto; order: 3; scrollbar-width: none; }
  .lien-menu { white-space: nowrap; }
  .lien-menu.actif { box-shadow: inset 0 -2px 0 var(--accent); }
  .contenu { padding: 1rem .85rem 2.5rem; }
  .masque-mobile { display: none; }
  .explorateur { grid-template-columns: minmax(0, 1fr); }
  .liste-donnees { max-height: 200px; }
  .sortie { height: 50vh; }
  .barre-serveur .actions { justify-content: flex-start; }
  th, td { padding: .5rem .55rem; }
}
