:root {
  --accent: #4fa3ff;
  --accent-doux: rgba(79, 163, 255, .14);
  --fond: #0f1217;
  --panneau: #161a21;
  --carte: #1c212a;
  --carte-2: #222834;
  --ligne: #2a313d;
  --texte: #e8ecf2;
  --texte-2: #9aa5b5;
  --texte-3: #6b7686;
  --vert: #3ecf8e;
  --jaune: #f5b942;
  --rouge: #f0555a;
  --violet: #a78bfa;
  --rayon: 10px;
  --echelle: 1;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: transparent; }
body {
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--texte);
  user-select: none;
}
body.apercu { background: #2b3440 url() center/cover; }
input, select, textarea, button { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.cache { display: none !important; }

/* ------------------------------------------------------------------ menu */
#menu {
  position: absolute; top: 50%; left: 50%;
  width: 1220px; height: 760px;
  transform: translate(-50%, -50%) scale(var(--echelle));
  display: flex;
  background: var(--fond);
  border: 1px solid var(--ligne);
  border-radius: 14px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
  overflow: hidden;
  animation: entree .18s ease-out;
}
#menu.gauche { left: 24px; transform-origin: left center; transform: translateY(-50%) scale(var(--echelle)); }
#menu.droite { left: auto; right: 24px; transform-origin: right center; transform: translateY(-50%) scale(var(--echelle)); }
@keyframes entree { from { opacity: 0; margin-top: 12px; } to { opacity: 1; margin-top: 0; } }

#barre {
  width: 222px; flex: none;
  background: var(--panneau);
  border-right: 1px solid var(--ligne);
  display: flex; flex-direction: column;
}
.logo { display: flex; gap: 10px; align-items: center; padding: 18px 16px 14px; }
.logo-carre {
  width: 36px; height: 36px; border-radius: 9px;
  background: var(--accent); color: #0b0e13;
  display: grid; place-items: center; font-weight: 800; font-size: 18px;
}
.logo-titre { font-weight: 700; font-size: 15px; }
.logo-sous { color: var(--texte-3); font-size: 12px; max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#onglets { flex: 1; overflow-y: auto; padding: 4px 10px; }
#onglets .groupe { color: var(--texte-3); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; margin: 12px 8px 4px; }
.onglet {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 10px; margin: 1px 0;
  border: 0; border-radius: 8px; background: none;
  color: var(--texte-2); cursor: pointer; text-align: left;
}
.onglet:hover { background: var(--carte); color: var(--texte); }
.onglet.actif { background: var(--accent-doux); color: var(--accent); font-weight: 600; }
.onglet .pastille { margin-left: auto; }

.moi { border-top: 1px solid var(--ligne); padding: 12px 14px; font-size: 12px; color: var(--texte-2); }
.moi b { color: var(--texte); display: block; font-size: 13px; }

main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#entete {
  height: 62px; flex: none;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; border-bottom: 1px solid var(--ligne);
}
#entete h1 { font-size: 18px; font-weight: 650; }
.entete-droite { display: flex; gap: 10px; align-items: center; }
.recherche-globale { position: relative; }
.recherche-globale input { width: 300px; }
#resultats-rapides {
  position: absolute; top: 40px; right: 0; width: 300px; z-index: 20;
  background: var(--carte-2); border: 1px solid var(--ligne); border-radius: 8px; overflow: hidden;
  box-shadow: 0 12px 30px rgba(0,0,0,.4);
}
#resultats-rapides div { padding: 8px 12px; cursor: pointer; }
#resultats-rapides div:hover { background: var(--accent-doux); }

#contenu { flex: 1; overflow-y: auto; padding: 18px 20px 24px; }
#contenu::-webkit-scrollbar, #onglets::-webkit-scrollbar, .defile::-webkit-scrollbar { width: 8px; }
#contenu::-webkit-scrollbar-thumb, #onglets::-webkit-scrollbar-thumb, .defile::-webkit-scrollbar-thumb { background: var(--ligne); border-radius: 4px; }

/* -------------------------------------------------------------- éléments */
input, select, textarea {
  background: var(--carte); border: 1px solid var(--ligne); border-radius: 8px;
  padding: 8px 11px; outline: none; user-select: text;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 70px; }
input[type=color] { padding: 2px; height: 36px; width: 56px; }
input[type=range] { padding: 0; accent-color: var(--accent); background: none; border: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 13px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--ligne); background: var(--carte-2); color: var(--texte);
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn svg { width: 16px; height: 16px; }
.btn.principal { background: var(--accent); border-color: var(--accent); color: #0b0e13; font-weight: 600; }
.btn.danger { color: var(--rouge); }
.btn.danger:hover { border-color: var(--rouge); background: rgba(240,85,90,.1); }
.btn.plein-danger { background: var(--rouge); border-color: var(--rouge); color: #fff; font-weight: 600; }
.btn.petit { padding: 5px 9px; font-size: 12px; }
.btn.actif { background: var(--accent-doux); border-color: var(--accent); color: var(--accent); }
.btn-icone { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--ligne); background: var(--carte); color: var(--texte-2); cursor: pointer; display: grid; place-items: center; }
.btn-icone:hover { color: var(--texte); border-color: var(--accent); }

.carte { background: var(--carte); border: 1px solid var(--ligne); border-radius: var(--rayon); padding: 16px; }
.carte h2 { font-size: 14px; font-weight: 650; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.carte h2 .droite { margin-left: auto; }
.grille { display: grid; gap: 14px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g5 { grid-template-columns: repeat(5, 1fr); }
.ligne { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ligne.etire > * { flex: 1; }
.espace { height: 14px; }
.muted { color: var(--texte-2); }
.petit-texte { font-size: 12px; color: var(--texte-3); }
.vide { color: var(--texte-3); text-align: center; padding: 30px 10px; }

.pastille { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--carte-2); color: var(--texte-2); }
.pastille.vert { background: rgba(62,207,142,.14); color: var(--vert); }
.pastille.jaune { background: rgba(245,185,66,.14); color: var(--jaune); }
.pastille.rouge { background: rgba(240,85,90,.15); color: var(--rouge); }
.pastille.bleu { background: var(--accent-doux); color: var(--accent); }
.pastille.violet { background: rgba(167,139,250,.15); color: var(--violet); }

/* tuiles de stats */
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .valeur { font-size: 26px; font-weight: 700; }
.stat .nom { color: var(--texte-2); font-size: 12px; }
.barre-prog { height: 6px; border-radius: 3px; background: var(--carte-2); overflow: hidden; margin-top: 4px; }
.barre-prog i { display: block; height: 100%; background: var(--accent); }

/* tableaux et listes */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--texte-3); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--ligne); position: sticky; top: 0; background: var(--carte); }
td { padding: 9px 10px; border-bottom: 1px solid var(--ligne); vertical-align: middle; }
tr.clic { cursor: pointer; }
tr.clic:hover td { background: var(--carte-2); }
tr.choisi td { background: var(--accent-doux); }

.liste-ev { display: flex; flex-direction: column; gap: 2px; }
.ev { display: flex; gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--ligne); font-size: 13px; }
.ev:last-child { border: 0; }
.ev .h { color: var(--texte-3); width: 46px; flex: none; }

/* page joueurs */
.joueurs-page { display: grid; grid-template-columns: 1fr 470px; gap: 14px; height: 100%; }
.joueurs-liste { display: flex; flex-direction: column; min-height: 0; }
.joueurs-liste .defile { flex: 1; overflow-y: auto; margin-top: 10px; }
.fiche { overflow-y: auto; }
.fiche-tete { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.avatar { width: 46px; height: 46px; border-radius: 12px; background: var(--accent-doux); color: var(--accent); display: grid; place-items: center; font-weight: 800; font-size: 18px; flex: none; }
.fiche-tete .nom { font-size: 16px; font-weight: 700; }
.infos { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; font-size: 13px; margin-bottom: 12px; }
.infos div span { color: var(--texte-3); display: block; font-size: 11px; }
.jauges { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 12px; }
.jauge { font-size: 11px; color: var(--texte-2); }
.jauge b { display: block; font-size: 14px; color: var(--texte); }
.section-actions { margin-top: 12px; }
.section-actions h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--texte-3); margin-bottom: 6px; }
.section-actions .ligne .btn { flex: 1 1 calc(33% - 8px); }
.note { background: var(--carte-2); border-radius: 8px; padding: 8px 10px; margin-top: 6px; font-size: 13px; position: relative; }
.note .meta { font-size: 11px; color: var(--texte-3); margin-top: 3px; }
.note.avertissement { border-left: 3px solid var(--jaune); }
.note .x { position: absolute; top: 6px; right: 8px; cursor: pointer; color: var(--texte-3); }
.note .x:hover { color: var(--rouge); }

/* interrupteurs */
.interrupteurs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.inter { background: var(--carte-2); border: 1px solid var(--ligne); border-radius: 10px; padding: 12px; cursor: pointer; display: flex; flex-direction: column; gap: 8px; }
.inter:hover { border-color: var(--accent); }
.inter .tete { display: flex; justify-content: space-between; align-items: center; }
.inter .nom { font-weight: 600; font-size: 13px; }
.inter .desc { font-size: 11px; color: var(--texte-3); }
.bascule { width: 32px; height: 18px; border-radius: 9px; background: var(--ligne); position: relative; transition: background .15s; flex: none; }
.bascule::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: left .15s; }
.inter.on { border-color: var(--accent); background: var(--accent-doux); }
.inter.on .bascule { background: var(--accent); }
.inter.on .bascule::after { left: 16px; }

/* catalogues */
.filtres { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.puce { padding: 5px 11px; border-radius: 999px; border: 1px solid var(--ligne); background: var(--carte); color: var(--texte-2); cursor: pointer; font-size: 12px; }
.puce.actif { background: var(--accent); border-color: var(--accent); color: #0b0e13; font-weight: 600; }
.catalogue { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 10px; }
.article { background: var(--carte); border: 1px solid var(--ligne); border-radius: 10px; overflow: hidden; position: relative; }
.article:hover { border-color: var(--accent); }
.article .image { height: 92px; background: var(--carte-2); display: grid; place-items: center; overflow: hidden; }
.article .image img { max-width: 100%; max-height: 100%; object-fit: contain; }
.article.objet .image { height: 72px; }
.article.objet .image img { max-height: 58px; }
.article .txt { padding: 8px 10px; }
.article .t1 { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.article .t2 { font-size: 11px; color: var(--texte-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.article .boutons { display: flex; gap: 4px; padding: 0 8px 8px; }
.article .boutons .btn { flex: 1; padding: 5px 4px; font-size: 12px; }

/* météo */
.meteos { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.meteo { padding: 10px 6px; border-radius: 9px; border: 1px solid var(--ligne); background: var(--carte-2); cursor: pointer; text-align: center; font-size: 12px; }
.meteo:hover { border-color: var(--accent); }
.meteo.actif { background: var(--accent-doux); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.horloge { font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* signalements */
.sig-page { display: grid; grid-template-columns: 330px 1fr; gap: 14px; height: 100%; }
.sig-liste { overflow-y: auto; }
.sig { padding: 10px 12px; border-radius: 9px; border: 1px solid var(--ligne); background: var(--carte-2); margin-bottom: 8px; cursor: pointer; }
.sig.actif { border-color: var(--accent); }
.sig .haut { display: flex; justify-content: space-between; font-size: 12px; color: var(--texte-3); }
.sig .msg { margin-top: 4px; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conversation { display: flex; flex-direction: column; height: 100%; }
.bulles { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 6px 2px; }
.bulle { max-width: 78%; padding: 8px 12px; border-radius: 12px; background: var(--carte-2); font-size: 13px; user-select: text; }
.bulle.moi { align-self: flex-end; background: var(--accent-doux); }
.bulle .de { font-size: 11px; color: var(--texte-3); margin-bottom: 2px; }
.saisie { display: flex; gap: 8px; margin-top: 10px; }
.saisie input { flex: 1; }

/* carte du monde */
.carte-monde { position: relative; height: 610px; background: #10161f; border-radius: 10px; overflow: hidden; border: 1px solid var(--ligne); }
.carte-monde canvas { width: 100%; height: 100%; display: block; }
.infobulle { position: absolute; pointer-events: none; background: var(--carte-2); border: 1px solid var(--ligne); border-radius: 7px; padding: 5px 9px; font-size: 12px; white-space: nowrap; }

/* dialogue */
#fond-dialogue { position: fixed; inset: 0; background: rgba(5,7,10,.55); display: grid; place-items: center; z-index: 50; }
#dialogue { width: 440px; background: var(--panneau); border: 1px solid var(--ligne); border-radius: 12px; padding: 20px; box-shadow: 0 24px 60px rgba(0,0,0,.6); animation: entree .15s ease-out; }
#dialogue h3 { font-size: 16px; margin-bottom: 4px; }
#dialogue .sous { color: var(--texte-2); font-size: 13px; margin-bottom: 14px; }
#dialogue label { display: block; font-size: 12px; color: var(--texte-2); margin: 10px 0 5px; }
#dialogue input, #dialogue select, #dialogue textarea { width: 100%; }
#dialogue .case { display: flex; gap: 8px; align-items: center; margin-top: 12px; font-size: 13px; color: var(--texte); }
#dialogue .case input { width: auto; }
#dialogue .boutons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* visionneuse d'écran */
#visionneuse { position: fixed; inset: 0; background: rgba(5,7,10,.75); display: grid; place-items: center; z-index: 60; }
.visionneuse-cadre { background: var(--panneau); border: 1px solid var(--ligne); border-radius: 12px; padding: 12px; max-width: 86vw; }
.visionneuse-haut { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-weight: 600; }
#visionneuse-image { max-width: 84vw; max-height: 78vh; border-radius: 8px; display: block; }

/* ------------------------------------------------------- couche visible en jeu */
#couche-overlay { position: fixed; inset: 0; pointer-events: none; z-index: 40; }
#annonces { position: absolute; top: 4vh; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 10px; align-items: center; width: 620px; }
.annonce {
  width: 100%; background: rgba(15,18,23,.94); border: 1px solid var(--ligne); border-left: 4px solid var(--accent);
  border-radius: 10px; padding: 14px 18px; box-shadow: 0 16px 40px rgba(0,0,0,.45);
  animation: descend .3s ease-out;
}
.annonce.attention { border-left-color: var(--jaune); }
.annonce.alerte { border-left-color: var(--rouge); }
.annonce .titre { font-weight: 700; font-size: 15px; margin-bottom: 3px; }
.annonce .texte { color: var(--texte); font-size: 14px; line-height: 1.4; }
.annonce .de { color: var(--texte-3); font-size: 11px; margin-top: 6px; }
.annonce .temps { height: 3px; background: var(--ligne); border-radius: 2px; margin-top: 10px; overflow: hidden; }
.annonce .temps i { display: block; height: 100%; background: currentColor; color: var(--accent); animation: vide linear forwards; }
.annonce.attention .temps i { color: var(--jaune); }
.annonce.alerte .temps i { color: var(--rouge); }
.annonce.avertissement { width: 520px; margin-top: 20vh; border: 2px solid var(--jaune); text-align: center; padding: 22px; }
.annonce.avertissement .titre { color: var(--jaune); font-size: 22px; }
@keyframes descend { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: none; } }
@keyframes vide { from { width: 100%; } to { width: 0; } }
.sortie { animation: sort .3s ease-in forwards; }
@keyframes sort { to { opacity: 0; transform: translateY(-10px); } }

#toasts { position: absolute; right: 22px; bottom: 22px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast {
  min-width: 240px; max-width: 380px; background: rgba(22,26,33,.97); border: 1px solid var(--ligne);
  border-left: 3px solid var(--accent); border-radius: 9px; padding: 10px 14px; font-size: 13px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: descend .2s ease-out;
}
.toast.ok { border-left-color: var(--vert); }
.toast.erreur { border-left-color: var(--rouge); }
.toast b { display: block; margin-bottom: 2px; }

/* carte détaillée */
.carte-page { display: grid; grid-template-columns: 1fr 230px; gap: 14px; }
.carte-page .carte-monde { height: 640px; cursor: grab; }
.carte-boutons { position: absolute; top: 12px; right: 12px; display: flex; flex-direction: column; gap: 6px; }
.carte-boutons .btn-icone { background: rgba(22,26,33,.92); font-size: 18px; font-weight: 700; }
.carte-coord { position: absolute; left: 12px; bottom: 10px; font-size: 11px; color: var(--texte-2); background: rgba(12,23,36,.8); padding: 3px 8px; border-radius: 6px; pointer-events: none; }
.liste-carte { height: 640px; display: flex; flex-direction: column; padding: 12px; }
.liste-carte .defile { overflow-y: auto; flex: 1; }
.ev.clic { cursor: pointer; border-radius: 6px; }
.ev.clic:hover { background: var(--carte-2); }
