:root {
  --fond: #0e1116;
  --fond-carte: #161b22;
  --fond-carte-survol: #1c232d;
  --bordure: #262d38;
  --texte: #e6edf3;
  --texte-doux: #8b949e;
  --accent: #2f81f7;
  --vert: #3fb950;
  --orange: #d29922;
  --rouge: #f85149;
  --violet: #a371f7;
  --rayon: 10px;
  --ombre: 0 1px 3px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--fond);
  color: var(--texte);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  min-height: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Structure ----------------------------------------------------------- */

.entete {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--fond-carte);
  border-bottom: 1px solid var(--bordure);
  position: sticky;
  top: 0;
  z-index: 50;
}

.entete .marque {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 1.05em;
}

.entete .marque img { height: 26px; width: auto; }

.entete nav { display: flex; gap: 4px; margin-left: 12px; }

.entete nav a {
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--texte-doux);
  font-size: .92em;
}
.entete nav a:hover { background: var(--fond-carte-survol); color: var(--texte); text-decoration: none; }
.entete nav a.actif { background: var(--accent); color: #fff; }

.entete .droite { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: .85em; color: var(--texte-doux); }

main { padding: 20px; max-width: 1400px; margin: 0 auto; }

h1 { font-size: 1.4em; margin: 0 0 4px; }
h2 { font-size: 1.1em; margin: 24px 0 12px; color: var(--texte); }
.sous-titre { color: var(--texte-doux); font-size: .9em; margin: 0 0 20px; }

/* --- Bandeau d'information ------------------------------------------------ */

.bandeau {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  background: var(--fond-carte);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: .9em;
}
.bandeau .element { display: flex; align-items: center; gap: 7px; }
.bandeau .etiquette { color: var(--texte-doux); }

/* --- Pastilles d'etat ----------------------------------------------------- */

.pastille {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--texte-doux);
}
.pastille.vert { background: var(--vert); box-shadow: 0 0 6px rgba(63, 185, 80, .6); }
.pastille.orange { background: var(--orange); }
.pastille.rouge { background: var(--rouge); }
.pastille.violet { background: var(--violet); }
.pastille.gris { background: #484f58; }
.pastille.pulse { animation: pulse 1.4s ease-in-out infinite; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* --- Grille de bornes ----------------------------------------------------- */

.grille {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.carte {
  background: var(--fond-carte);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  padding: 14px 16px;
  box-shadow: var(--ombre);
  transition: border-color .15s;
}
.carte:hover { border-color: #35404e; }
.carte.occupee { border-color: var(--accent); }
.carte.alerte { border-color: var(--rouge); }

.carte .titre {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  margin-bottom: 10px;
}
.carte .titre .nom { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.carte .titre .ip { font-size: .78em; color: var(--texte-doux); font-weight: 400; font-family: ui-monospace, Consolas, monospace; }

.lignes { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-size: .88em; }
.ligne { display: flex; align-items: center; gap: 8px; }
.ligne .etiquette { color: var(--texte-doux); width: 58px; flex: 0 0 auto; }
.ligne .valeur { display: flex; align-items: center; gap: 7px; }
.ligne .detail { color: var(--texte-doux); font-size: .9em; margin-left: auto; font-family: ui-monospace, Consolas, monospace; }

.actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* --- Barre de recherche et de filtre des sites ---------------------------- */
/* Elle vit en dehors de la liste rafraichie toutes les 4 s : ce qu'on tape et
   le filtre choisi survivent donc au rafraichissement, et le curseur ne saute
   pas au milieu d'une saisie. */
.barre-filtres {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.barre-filtres .recherche {
  flex: 1 1 240px;
  max-width: 340px;
}

.barre-filtres .groupe {
  display: flex;
  gap: 4px;
}

.barre-filtres .compte {
  color: var(--texte-doux);
  font-size: .84em;
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 575.98px) {
  .barre-filtres .recherche { max-width: none; flex-basis: 100%; }
  .barre-filtres .compte { margin-left: 0; }
}

/* --- Boutons -------------------------------------------------------------- */

/* Un .btn est en display:inline-flex, ce qui ecrase le display:none que le
   navigateur applique a l'attribut hidden : sans cette regle, un bouton masque
   par hidden reste visible, et vide quand il n'a pas de libelle. */
[hidden] { display: none !important; }

.btn {
  border: 1px solid var(--bordure);
  background: #21262d;
  color: var(--texte);
  padding: 7px 13px;
  border-radius: 6px;
  font-size: .87em;
  font-family: inherit;
  cursor: pointer;
  transition: background .12s, border-color .12s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:hover:not(:disabled) { background: #30363d; border-color: #3d4552; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.principal { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.principal:hover:not(:disabled) { background: #4a92f8; }
.btn.vert { background: #1f6f31; border-color: #2a8a3f; color: #fff; }
.btn.vert:hover:not(:disabled) { background: #278240; }
.btn.rouge { background: #8b2721; border-color: #a3312a; color: #fff; }
.btn.rouge:hover:not(:disabled) { background: #a12f28; }
.btn.discret { background: transparent; }
.btn.petit { padding: 4px 9px; font-size: .8em; }

.barre-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; align-items: center; }

/* --- Formulaires ---------------------------------------------------------- */

input[type=text], input[type=password], input[type=time], input[type=number], input[type=search], select, textarea {
  background: #0d1117;
  border: 1px solid var(--bordure);
  color: var(--texte);
  padding: 7px 10px;
  border-radius: 6px;
  font-family: inherit;
  font-size: .9em;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
label { display: block; font-size: .85em; color: var(--texte-doux); margin-bottom: 4px; }
.champ { margin-bottom: 12px; }
.champs-ligne { display: flex; gap: 12px; flex-wrap: wrap; }
.champs-ligne > .champ { flex: 1 1 180px; }

/* --- Tableaux ------------------------------------------------------------- */

table { width: 100%; border-collapse: collapse; font-size: .88em; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--bordure); }
th { color: var(--texte-doux); font-weight: 500; font-size: .88em; }
tbody tr:hover { background: var(--fond-carte-survol); }

/* --- Fenetres modales ----------------------------------------------------- */

.voile {
  position: fixed; inset: 0;
  background: rgba(1, 4, 9, .8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.voile.visible { display: flex; }
.modale {
  background: var(--fond-carte);
  border: 1px solid var(--bordure);
  border-radius: 12px;
  padding: 20px 22px;
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .6);
}
.modale h3 { margin: 0 0 16px; font-size: 1.1em; }
.modale .pied { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

/* --- Journal -------------------------------------------------------------- */

.journal {
  background: #0d1117;
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  font-family: ui-monospace, Consolas, monospace;
  font-size: .8em;
  line-height: 1.6;
  max-height: 320px;
  overflow-y: auto;
  padding: 10px 12px;
}
.journal .evt { display: flex; gap: 10px; padding: 1px 0; }
.journal .heure { color: #6e7681; flex: 0 0 auto; }
.journal .cible { color: var(--violet); flex: 0 0 auto; }
.journal .evt.succes .msg { color: var(--vert); }
.journal .evt.alerte .msg { color: var(--orange); }
.journal .evt.erreur .msg { color: var(--rouge); }

/* --- Notifications -------------------------------------------------------- */

#notifications { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.notification {
  background: var(--fond-carte);
  border: 1px solid var(--bordure);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: .88em;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .5);
  max-width: 380px;
  animation: entree .2s ease;
}
.notification.succes { border-left-color: var(--vert); }
.notification.erreur { border-left-color: var(--rouge); }
.notification.alerte { border-left-color: var(--orange); }
@keyframes entree { from { opacity: 0; transform: translateX(20px); } }

/* --- Divers --------------------------------------------------------------- */

.vide { color: var(--texte-doux); text-align: center; padding: 40px 20px; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: .9em; }
.secret { font-family: ui-monospace, Consolas, monospace; background: #0d1117; padding: 6px 10px; border-radius: 6px; word-break: break-all; font-size: .82em; border: 1px solid var(--bordure); }
.avertissement { background: rgba(210, 153, 34, .1); border: 1px solid rgba(210, 153, 34, .35); border-radius: 8px; padding: 10px 14px; font-size: .88em; margin-bottom: 16px; }
.info-bloc { background: rgba(47, 129, 247, .08); border: 1px solid rgba(47, 129, 247, .3); border-radius: 8px; padding: 10px 14px; font-size: .88em; margin-bottom: 16px; }

@media (max-width: 640px) {
  .entete { flex-wrap: wrap; gap: 8px; padding: 10px 14px; }
  .entete nav { margin-left: 0; width: 100%; overflow-x: auto; }
  .entete .droite { margin-left: 0; }
  main { padding: 14px; }
  .grille { grid-template-columns: 1fr; }
}

/* --- Tableau des horaires ------------------------------------------------- */

table.horaires { max-width: 460px; }
table.horaires td, table.horaires th { padding: 7px 14px; }
table.horaires td:first-child { width: 46%; }
