:root {
  color-scheme: dark;
  --bg: #0b1017; --bg2: #0f151d; --panel: #131a23; --panel2: #19212c; --panel3: #202a37;
  --line: #222c3a; --line2: #2e3a4b;
  --text: #e9eef5; --text2: #b4bfce; --muted: #7d8aa0;
  --accent: #5b9dff; --accent2: #4585ee; --accent-soft: rgba(91,157,255,.14);
  --ok: #34d399; --warn: #fbbf24; --danger: #fb6f84; --info: #5b9dff;
  --ok-soft: rgba(52,211,153,.13); --warn-soft: rgba(251,191,36,.13); --danger-soft: rgba(251,111,132,.13);
  --radius: 12px; --radius-sm: 8px;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 12px 32px -16px rgba(0,0,0,.6);
  --ease: cubic-bezier(.2,.7,.2,1);
  font-family: Inter, "SF Pro Text", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-feature-settings: "tnum", "cv11", "ss01";
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
body { background: radial-gradient(1100px 520px at 85% -10%, rgba(91,157,255,.07), transparent 60%), var(--bg); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "JetBrains Mono", "Cascadia Code", Consolas, monospace; font-size: 12px; }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -.02em; margin: 0; }
h2 { font-size: 15px; font-weight: 600; letter-spacing: -.01em; margin: 0 0 12px; }
.ico { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Marque */
.brand { display: flex; align-items: center; gap: 11px; font-weight: 700; font-size: 17px; letter-spacing: -.02em; }
.brand.big { font-size: 28px; justify-content: center; margin-bottom: 2px; }
.logo { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; color: #fff;
  background: linear-gradient(145deg, #6aa8ff, #3f6fe0 60%, #5b47d6); box-shadow: 0 6px 16px -6px rgba(91,157,255,.7), 0 1px 0 rgba(255,255,255,.35) inset; }
.logo .ico { width: 18px; height: 18px; stroke-width: 2; }
.brand.big .logo { width: 44px; height: 44px; border-radius: 12px; }
.brand.big .logo .ico { width: 24px; height: 24px; }
.brand small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: 0; margin-top: -2px; }

.card { background: linear-gradient(180deg, var(--panel), var(--bg2)); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }

/* Connexion */
.login { min-height: 100%; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; text-align: center; padding: 30px 28px 26px; }
.login-card .muted { margin: 0 0 6px; }
.login-card input { padding: 11px 13px; text-align: left; }
.login-card .btn { justify-content: center; padding: 11px; font-weight: 600; }
.error { color: var(--danger); min-height: 18px; margin: 0; font-size: 13px; }

/* Structure */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 236px; background: var(--bg2); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { padding: 0 8px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-group { color: var(--muted); font-size: 12px; padding: 14px 10px 6px; }
.nav-group:first-child { padding-top: 0; }
.sidebar nav button { display: flex; align-items: center; gap: 11px; text-align: left; background: none; border: 0; color: var(--text2); padding: 9px 10px; border-radius: var(--radius-sm); cursor: pointer; font: inherit; font-weight: 500; position: relative; transition: background .15s, color .15s; }
.sidebar nav button .ico { color: var(--muted); transition: color .15s; }
.sidebar nav button:hover { background: var(--panel2); color: var(--text); }
.sidebar nav button.active { background: var(--accent-soft); color: #fff; }
.sidebar nav button.active .ico { color: var(--accent); }
.sidebar nav button.active::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.sidebar .btn { justify-content: flex-start; }
main { flex: 1; padding: 28px 36px 48px; min-width: 0; max-width: 1280px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; gap: 12px; }
.live { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 99px; background: var(--ok-soft); color: var(--ok); font-size: 12.5px; font-weight: 600; }
.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 2s ease-out infinite; }
.live.off { background: var(--panel2); color: var(--muted); }
.live.off::before { animation: none; opacity: .6; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(52,211,153,.6); } 80%, 100% { box-shadow: 0 0 0 7px rgba(52,211,153,0); } }

/* Champs et boutons */
input, select, textarea { background: var(--bg2); color: var(--text); border: 1px solid var(--line2); border-radius: var(--radius-sm); padding: 9px 12px; font: inherit; transition: border-color .15s, box-shadow .15s; }
input::placeholder, textarea::placeholder { color: var(--muted); }
input:hover, select:hover, textarea:hover { border-color: #3a485c; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select { cursor: pointer; }
textarea { width: 100%; min-height: 280px; resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; line-height: 1.7; }
input:disabled, select:disabled { opacity: .4; cursor: not-allowed; }
.search { position: relative; flex: 1; min-width: 200px; display: flex; }
.search .ico { position: absolute; left: 12px; top: 50%; margin-top: -9px; color: var(--muted); pointer-events: none; }
.search input { width: 100%; padding-left: 38px; }
.btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line2); background: var(--panel2); color: var(--text); padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer; font: inherit; font-weight: 500; transition: background .15s, border-color .15s, transform .1s; }
.btn:hover { background: var(--panel3); border-color: #40506a; }
.btn:active { transform: translateY(1px); }
.btn .ico { width: 16px; height: 16px; }
.btn.primary { background: linear-gradient(180deg, #6aa8ff, var(--accent2)); border-color: #3f78e0; color: #fff; font-weight: 600; box-shadow: 0 6px 16px -8px rgba(91,157,255,.8), 0 1px 0 rgba(255,255,255,.25) inset; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--danger-soft); color: var(--danger); border-color: rgba(251,111,132,.35); }
.btn.danger:hover { background: var(--danger); border-color: var(--danger); color: #1a0509; }
.btn.warn { background: var(--warn-soft); color: var(--warn); border-color: rgba(251,191,36,.35); }
.btn.warn:hover { background: var(--warn); border-color: var(--warn); color: #1d1500; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--panel2); color: var(--text); }
.btn.small { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row .grow { flex: 1; min-width: 160px; }
.grid { display: grid; gap: 16px; }
.grid.cols2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

/* Tableau de bord */
.hero { display: grid; grid-template-columns: minmax(280px, 1.15fr) 1fr; gap: 16px; margin-bottom: 26px; }
.gauge-card { display: flex; align-items: center; gap: 26px; padding: 24px 28px; position: relative; overflow: hidden; }
.gauge-card::after { content: ""; position: absolute; inset: auto -60px -80px auto; width: 240px; height: 240px; border-radius: 50%; background: radial-gradient(circle, rgba(91,157,255,.14), transparent 70%); pointer-events: none; }
.gauge { position: relative; width: 138px; height: 138px; flex: none; }
.gauge svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge circle { fill: none; stroke-width: 10; stroke-linecap: round; }
.gauge .track { stroke: var(--panel3); }
.gauge .fill { stroke: var(--accent); transition: stroke-dashoffset .8s var(--ease); }
.gauge .center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.gauge .center b { font-size: 34px; font-weight: 700; letter-spacing: -.03em; line-height: 1; }
.gauge .center span { font-size: 12px; color: var(--muted); margin-top: 4px; }
.gauge-meta h2 { font-size: 18px; margin-bottom: 4px; }
.gauge-meta p { margin: 0; color: var(--muted); max-width: 26ch; }
.kpis { display: grid; grid-template-rows: 1fr 1fr; gap: 16px; }
.kpi { display: flex; align-items: center; gap: 16px; padding: 16px 20px; }
.kpi .chip { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.kpi .chip .ico { width: 21px; height: 21px; }
.kpi .chip.warn { background: var(--warn-soft); color: var(--warn); }
.kpi .chip.danger { background: var(--danger-soft); color: var(--danger); }
.kpi .value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.kpi .label { color: var(--muted); font-size: 13px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 2px 12px; }
.section-head h2 { margin: 0; }

/* Fil d'activité */
.feed { padding: 6px 0; }
.feed-item { display: grid; grid-template-columns: 34px 1fr auto; gap: 14px; align-items: center; padding: 11px 18px; border-bottom: 1px solid var(--line); }
.feed-item:last-child { border-bottom: 0; }
.feed-item:hover { background: rgba(255,255,255,.02); }
.feed-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--panel2); color: var(--muted); }
.feed-icon.warn { background: var(--warn-soft); color: var(--warn); }
.feed-icon.danger { background: var(--danger-soft); color: var(--danger); }
.feed-icon.info { background: var(--accent-soft); color: var(--accent); }
.feed-icon.ok { background: var(--ok-soft); color: var(--ok); }
.feed-title { font-weight: 550; }
.feed-sub { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 62ch; }
.feed-time { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* Tableaux */
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 550; font-size: 12.5px; white-space: nowrap; background: var(--bg2); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
td { white-space: nowrap; }
td.wrap, td.muted { white-space: normal; min-width: 180px; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: rgba(91,157,255,.045); }
td.actions { white-space: nowrap; text-align: right; }
td.actions .btn { margin-left: 4px; }
.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.player { display: flex; align-items: center; gap: 11px; font-weight: 550; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 12.5px; font-weight: 700; color: #fff; flex: none; }
.pid { color: var(--muted); font-weight: 400; font-size: 12px; }
.ping { display: inline-flex; align-items: center; gap: 6px; }
.ping::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.ping.mid::before { background: var(--warn); }
.ping.high::before { background: var(--danger); }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--panel2); color: var(--text2); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--accent-soft); color: var(--accent); }

.bar { width: 84px; height: 6px; background: var(--panel3); border-radius: 99px; overflow: hidden; display: inline-block; vertical-align: middle; margin-right: 10px; }
.bar > i { display: block; height: 100%; background: var(--ok); border-radius: 99px; transition: width .4s var(--ease); }
.bar > i.mid { background: var(--warn); }
.bar > i.high { background: var(--danger); }

.note { color: var(--muted); font-size: 12.5px; margin: 8px 0 14px; line-height: 1.6; }
.ids { display: flex; flex-direction: column; gap: 6px; }
.ids code { background: var(--bg2); border: 1px solid var(--line); padding: 7px 10px; border-radius: 7px; word-break: break-all; font-size: 12px; }

/* Modale et toasts */
.modal-bg { position: fixed; inset: 0; background: rgba(5,8,12,.68); backdrop-filter: blur(6px); display: grid; place-items: center; padding: 16px; z-index: 50; animation: fade .15s ease-out; }
.modal { background: var(--panel); border: 1px solid var(--line2); border-radius: 16px; width: 100%; max-width: 470px; padding: 24px; max-height: 90vh; overflow: auto; box-shadow: 0 30px 80px -20px rgba(0,0,0,.8); animation: pop .22s var(--ease); }
.modal h2 { font-size: 17px; }
.modal .body { margin-bottom: 20px; display: flex; flex-direction: column; gap: 12px; }
.modal .body p { margin: 0; }
.modal .body input { width: 100%; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.97); } }
#toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 60; }
.toast { display: flex; align-items: center; gap: 10px; background: var(--panel3); border: 1px solid var(--line2); padding: 11px 16px 11px 13px; border-radius: 11px; max-width: 380px; box-shadow: 0 16px 40px -12px rgba(0,0,0,.7); animation: pop .25s var(--ease); }
.toast .ico { color: var(--ok); }
.toast.err .ico { color: var(--danger); }

@media (max-width: 900px) { .hero { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; flex-wrap: wrap; padding: 12px; gap: 10px; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; flex: 1 1 100%; order: 3; }
  .sidebar nav button.active::before, .nav-group { display: none; }
  .sidebar nav button { padding: 8px 10px; }
  .sidebar nav button span { display: none; }
  .sidebar nav button.active span { display: inline; }
  main { padding: 20px 16px 40px; }
  .gauge-card { flex-direction: column; text-align: center; }
  .gauge-meta p { max-width: none; }
  .feed-item { grid-template-columns: 34px 1fr; }
  .feed-time { grid-column: 2; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Visionnage joueur */
.modal.wide { max-width: min(1100px, 96vw); }
.live-stage { position: relative; background: #05080c; border-radius: 10px; overflow: hidden; aspect-ratio: 16 / 9; display: grid; place-items: center; border: 1px solid var(--line2); }
.live-img { width: 100%; height: 100%; object-fit: contain; display: none; background: #05080c; }
.live-img.on { display: block; }
.live-status { position: absolute; left: 10px; bottom: 8px; font-size: 12px; color: var(--muted); background: rgba(0,0,0,.6); padding: 3px 9px; border-radius: 6px; }
.live-status.err { color: var(--danger); }
