:root {
  --bg: #0f1218; --bg2: #171b23; --bg3: #1f2530; --line: #2a313e;
  --fg: #e6e9ef; --muted: #8a93a3; --accent: #e57000;
  --green: #3fb950; --red: #f85149; --yellow: #d29922; --blue: #58a6ff;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--red); min-height: 1.2em; margin: 0; }
input, select { background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; font: inherit; }
input:focus, select:focus { outline: none; border-color: var(--accent); }
label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; }
label.inline { flex-direction: row; align-items: center; gap: 6px; }

.btn { background: var(--bg3); color: var(--fg); border: 1px solid var(--line); border-radius: 6px; padding: 7px 12px; cursor: pointer; font: inherit; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.green { color: var(--green); } .btn.red { color: var(--red); } .btn.yellow { color: var(--yellow); }

/* Connexion */
#login-view { min-height: 100vh; display: grid; place-items: center; }
.login-card { width: 320px; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.logo { font-weight: 700; font-size: 17px; color: var(--accent); }

/* Barre du haut */
.topbar { display: flex; align-items: center; gap: 24px; padding: 10px 20px; background: var(--bg2); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.tab { background: none; border: none; color: var(--muted); padding: 8px 12px; border-radius: 6px; cursor: pointer; font: inherit; }
.tab.active, .tab:hover { color: var(--fg); background: var(--bg3); }
.who { display: flex; align-items: center; gap: 10px; color: var(--muted); }
main { padding: 20px; max-width: 1500px; margin: 0 auto; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar #search { flex: 1; min-width: 200px; }

/* Noeuds */
.nodes { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.node { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; min-width: 220px; }
.node b { display: block; margin-bottom: 6px; }

/* Cartes VM */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.card { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.card-head { display: flex; align-items: center; gap: 10px; }
.card-head .name { font-weight: 600; font-size: 15px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.running { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot.stopped { background: var(--red); }
.dot.paused, .dot.suspended { background: var(--yellow); }
.badge { font-size: 11px; padding: 2px 7px; border-radius: 10px; background: var(--bg3); color: var(--muted); border: 1px solid var(--line); }
.badge.qemu { color: var(--blue); } .badge.lxc { color: var(--accent); }
.meta { color: var(--muted); font-size: 12px; display: flex; gap: 12px; flex-wrap: wrap; }
.tags span { font-size: 11px; background: var(--bg3); padding: 1px 6px; border-radius: 4px; margin-right: 4px; }
.bars { display: grid; gap: 5px; }
.bar { display: grid; grid-template-columns: 38px 1fr 92px; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.bar .track { height: 6px; background: var(--bg3); border-radius: 3px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--green); transition: width .4s; }
.bar .fill.warn { background: var(--yellow); } .bar .fill.crit { background: var(--red); }
.bar .val { text-align: right; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.actions .spacer { flex: 1; }

/* Panneaux & tableaux */
.panel { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.panel.narrow { max-width: 420px; }
.panel h2 { margin: 0 0 12px; font-size: 16px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 10px; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-weight: 500; font-size: 12px; }
.table td.center, .table th.center { text-align: center; }

/* Modale */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 20; padding: 20px; }
.modal-box { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; width: min(960px, 100%); max-height: 90vh; overflow: auto; padding: 18px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h3 { margin: 0; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 14px; }
.chart { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.chart h4 { margin: 0 0 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
.chart canvas { width: 100%; height: 160px; display: block; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 4px 12px; font-size: 13px; margin-bottom: 14px; }
.kv div:nth-child(odd) { color: var(--muted); }
.perm-table td { padding: 5px 6px; }
.perm-table tr:hover td { background: var(--bg3); }
.sticky-actions { position: sticky; bottom: -18px; background: var(--bg2); padding: 12px 0 2px; display: flex; gap: 8px; justify-content: flex-end; }

/* Toasts */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 30; }
.toast { background: var(--bg3); border: 1px solid var(--line); border-left: 4px solid var(--blue); padding: 10px 14px; border-radius: 6px; max-width: 380px; }
.toast.ok { border-left-color: var(--green); } .toast.err { border-left-color: var(--red); }

@media (max-width: 600px) {
  .grid { grid-template-columns: 1fr; }
  .charts { grid-template-columns: 1fr; }
  main { padding: 12px; }
}
