:root {
  --bg: #0b1017;
  --panel: #121a24;
  --panel2: #17212e;
  --line: #233041;
  --text: #e6edf5;
  --muted: #8a9bb0;
  --accent: #38bdf8;
  --accent2: #a78bfa;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 12px;
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f3f5f9; --panel: #ffffff; --panel2: #f6f8fb; --line: #dfe5ee; --text: #142033; --muted: #5d6b80;
    --accent: #0284c7; --accent2: #7c3aed; --ok: #059669; --warn: #b45309; --bad: #dc2626; color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--bad); min-height: 1.2em; margin: 8px 0 0; }
code { font-family: var(--mono); background: var(--panel2); padding: 1px 5px; border-radius: 5px; word-break: break-all; }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); border-color: var(--accent); }
label { display: block; margin: 10px 0; color: var(--muted); font-size: 13px; }
label input { display: block; width: 100%; margin-top: 4px; color: var(--text); font-size: 15px; }
label.check { display: inline-flex; align-items: center; gap: 6px; margin: 0; color: var(--text); }
label.check input { width: auto; margin: 0; }

.btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #04121c; font-weight: 600; }
.btn.danger { color: var(--bad); }
.btn.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { border-color: var(--line); }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn.icon { padding: 5px 9px; }
.btn.wide { width: 100%; padding: 10px; margin-top: 6px; }
.btn:disabled { opacity: .5; cursor: default; }

/* Connexion */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; }
.qr { display: block; margin: 10px auto; border-radius: 8px; background: #fff; padding: 6px; }

/* Barre du haut */
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; }
.brand.big { font-size: 22px; margin-bottom: 10px; }
.logo { width: 22px; height: 22px; border-radius: 6px; background: linear-gradient(135deg, var(--accent), var(--accent2)); position: relative; }
.logo::after { content: ""; position: absolute; inset: 6px 5px; border-top: 2px solid rgba(255,255,255,.9); border-bottom: 2px solid rgba(255,255,255,.9); }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 18px; padding: 10px 20px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 4px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.tabs button { background: none; border: 0; padding: 7px 12px; border-radius: 8px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button.active { background: var(--panel2); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.user { display: flex; gap: 4px; }
/* toute la largeur de l'écran, quelle qu'elle soit */
main { padding: 20px clamp(16px, 1.6vw, 40px); }
@media (min-width: 2200px) { html, body { font-size: 15px; } }
.view { animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } }

.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.toolbar.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.spacer { flex: 1; }
.seg { display: inline-flex; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 2px; flex-wrap: wrap; }
.seg button { background: none; border: 0; padding: 5px 10px; border-radius: 6px; cursor: pointer; color: var(--muted); }
.seg button.active { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.25); }

/* Cartes serveurs */
.server-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(440px, 1fr)); gap: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card.offline { border-color: color-mix(in srgb, var(--bad) 50%, var(--line)); }
/* sections de la carte (GPU, stockage, conteneurs) : côte à côte quand la carte est large, empilées sinon */
.card-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 0 32px; align-items: start; }
.card-cols > div > .section-title:first-child { margin-top: 4px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head h2 { margin: 0; font-size: 19px; display: flex; align-items: center; gap: 9px; }
.card-head .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 20%, transparent); flex: none; }
.dot.off { background: var(--bad); box-shadow: 0 0 0 4px color-mix(in srgb, var(--bad) 20%, transparent); }
.gauges { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 10px; margin-bottom: 14px; }
.gauge { background: var(--panel2); border-radius: 10px; padding: 10px; text-align: center; }
.gauge svg { width: 74px; height: 74px; display: block; margin: 0 auto 4px; }
.gauge .lbl { color: var(--muted); font-size: 12px; }
.gauge .val { font-size: 12px; color: var(--muted); }
.ring-bg { stroke: var(--line); }
.ring-txt { fill: var(--text); font: 600 17px system-ui, sans-serif; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.chart { background: var(--panel2); border-radius: 10px; padding: 8px 10px 4px; }
.chart .top { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.chart .top b { color: var(--text); font-weight: 600; }
.chart svg { width: 100%; height: clamp(46px, 4.5vw, 90px); display: block; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 0 8px; }
.disk { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; margin-bottom: 9px; font-size: 13px; }
.disk .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.disk .name small { color: var(--muted); margin-left: 6px; }
.disk .nums { color: var(--muted); font-size: 12px; }
.bar { grid-column: 1 / -1; height: 6px; background: var(--line); border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.bar > i.warn { background: var(--warn); }
.bar > i.bad { background: var(--bad); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 12.5px; cursor: pointer; }
.chip b { font-weight: 700; }
.chip.ok b { color: var(--ok); } .chip.bad b { color: var(--bad); } .chip.warn b { color: var(--warn); }
.top-list { margin-top: 10px; font-size: 13px; }
.top-list div { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px dashed var(--line); }
.top-list div:last-child { border-bottom: 0; }
.top-list span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.card-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 14px; }

/* Tableaux */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; position: relative; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th { position: sticky; top: 0; background: var(--panel2); font-weight: 600; font-size: 12.5px; color: var(--muted); z-index: 1; }
.table th[data-sort] { cursor: pointer; user-select: none; }
.table th.sorted::after { content: " ▾"; } .table th.sorted.asc::after { content: " ▴"; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--panel2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.actions { text-align: right; }
.table td.actions .btn { margin-left: 4px; }
.table td.wrap { white-space: normal; word-break: break-word; }
.table .cb { width: 34px; }
.cname { font-weight: 600; }
.cname small { display: block; font-weight: 400; color: var(--muted); }
.image { color: var(--muted); max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.badge.running::before { background: var(--ok); } .badge.unhealthy::before { background: var(--bad); }
.badge.starting::before { background: var(--warn); } .badge.exited::before, .badge.dead::before { background: var(--bad); opacity: .6; }
.srv-tag { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.srv-tag.alt { background: color-mix(in srgb, var(--accent2) 16%, transparent); color: var(--accent2); }

/* Processus */
.ps-summary { display: flex; gap: 18px; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin: -2px 0 10px; }
.ps-summary b { color: var(--text); font-variant-numeric: tabular-nums; }
.ps-name { font-weight: 600; }
.ps-cmd { display: block; color: var(--muted); font: 12px var(--mono); max-width: max(260px, calc(100vw - 1180px)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#psTable td.pname { cursor: pointer; white-space: normal; }
.meter { display: inline-flex; align-items: center; gap: 8px; justify-content: flex-end; }
.meter i { display: inline-block; width: 52px; height: 6px; background: var(--line); border-radius: 4px; overflow: hidden; position: relative; }
.meter i::after { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--w); background: var(--accent); border-radius: 4px; }
.meter.warn i::after { background: var(--warn); } .meter.bad i::after { background: var(--bad); }
.ps-hot td { background: color-mix(in srgb, var(--bad) 7%, transparent); }
.net-card { padding: 12px 16px; margin-bottom: 12px; }
.net-card .head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.net-card .head b { font-size: 14px; }
.net-row .v { white-space: nowrap; }
.net-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 2fr) 210px; gap: 10px; align-items: center; padding: 4px 0; font-size: 13px; border-bottom: 1px dashed var(--line); }
.net-row:last-child { border-bottom: 0; }
.net-row .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.net-row .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.net-row .v b { color: var(--text); font-weight: 600; }
.net-bars { display: grid; gap: 3px; }
.net-bars i { display: block; height: 5px; border-radius: 3px; min-width: 2px; }
.net-bars i.rx { background: var(--ok); } .net-bars i.tx { background: var(--accent2); }
.net-cell { font-variant-numeric: tabular-nums; font-size: 12.5px; }
.net-cell .rx { color: var(--ok); } .net-cell .tx { color: var(--accent2); }
.net-cell small { display: block; color: var(--muted); font-size: 11px; }
@media (max-width: 640px) {
  .net-row { grid-template-columns: minmax(0, 1fr) auto; font-size: 12px; }
  .net-row .net-bars { display: none; }
  #psSearch { order: 5; flex-basis: 100%; }
}
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-all; }
.kv dd code { white-space: pre-wrap; }

/* Mises à jour */
.upd-status { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.upd-big { font-size: 26px; font-weight: 700; line-height: 1; }
.upd-big.ok { color: var(--ok); }
.banner { border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 13.5px; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.banner.warn { background: color-mix(in srgb, var(--warn) 14%, transparent); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); }
.banner.bad { background: color-mix(in srgb, var(--bad) 12%, transparent); border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent); }
.banner.ok { background: color-mix(in srgb, var(--ok) 12%, transparent); border: 1px solid color-mix(in srgb, var(--ok) 40%, transparent); }
.pkg-list { max-height: max(360px, calc(100vh - 520px)); overflow: auto; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 12px; }
.pkg-list .table td { padding: 5px 10px; font-size: 13px; }
.pkg-ver { font: 12px var(--mono); color: var(--muted); white-space: normal !important; word-break: break-all; }
.pkg-ver b { color: var(--text); font-weight: 500; }
.tag-sec { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); margin-left: 6px; }
.upd-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.upd-actions .btn.primary { padding: 9px 16px; }
.job { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 12px; background: var(--panel2); }
.job-head { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; margin-bottom: 8px; flex-wrap: wrap; }
.job-step { font-weight: 600; }
.job .bar { height: 8px; margin-bottom: 8px; }
.job .bar > i { transition: width .4s ease; }
.job-sub { color: var(--muted); font-size: 12.5px; margin-bottom: 8px; min-height: 1.3em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-log { height: 280px; margin: 0; }
.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -1px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Fichiers */
.crumbs { display: flex; align-items: center; gap: 2px; overflow-x: auto; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 3px 6px; min-height: 34px; scrollbar-width: thin; }
.crumbs button { background: none; border: 0; padding: 3px 6px; border-radius: 5px; cursor: pointer; white-space: nowrap; color: var(--text); }
.crumbs button:hover { background: var(--panel); }
.crumbs span { color: var(--muted); }
.crumbs input { border: 0; background: transparent; width: 100%; padding: 3px; font-family: var(--mono); }
.files td.name { cursor: pointer; }
.files td.name:hover .fname { color: var(--accent); }
.ficon { display: inline-block; width: 22px; text-align: center; margin-right: 6px; }
.fname { font-weight: 500; }
.link-target { color: var(--muted); font-size: 12px; margin-left: 6px; }
.drop.over { outline: 2px dashed var(--accent); outline-offset: -6px; }
.drop-hint { display: none; position: absolute; inset: 0; place-items: center; background: color-mix(in srgb, var(--bg) 70%, transparent); font-size: 16px; color: var(--accent); pointer-events: none; }
.drop.over .drop-hint { display: grid; }
.uploads { display: grid; gap: 6px; margin-bottom: 10px; }
.upload { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 13px; }
.upload .bar { margin-top: 4px; }

/* Console */
.term-tabs { display: flex; gap: 4px; overflow-x: auto; max-width: 60%; }
.term-tab { display: inline-flex; align-items: center; gap: 6px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px 5px 10px; cursor: pointer; white-space: nowrap; font-size: 13px; }
.term-tab.active { border-color: var(--accent); }
.term-tab.dead { opacity: .55; }
.term-tab .x { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0 2px; }
.term-area { background: #0a0e14; border: 1px solid var(--line); border-radius: var(--radius); height: calc(100vh - 150px); min-height: 360px; position: relative; overflow: hidden; }
.term-pane { position: absolute; inset: 8px; }
.term-area .empty { color: var(--muted); display: grid; place-items: center; height: 100%; padding: 20px; text-align: center; }

/* Fenêtres */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal-box { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; width: 100%; max-width: 460px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.modal-box.wide { max-width: min(1700px, 94vw); height: calc(100vh - 32px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; gap: 10px; }
.modal-head h3 { margin: 0; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { padding: 6px 16px; overflow: auto; flex: 1; display: flex; flex-direction: column; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px 16px; align-items: center; }
.modal-foot .left { margin-right: auto; color: var(--muted); font-size: 12.5px; }
.modal-body input { width: 100%; }
.editor, .logs { flex: 1; width: 100%; min-height: 300px; font: 13px/1.5 var(--mono); resize: none; white-space: pre; tab-size: 4; }
.logs { background: #0a0e14; color: #d1dae6; border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow: auto; margin: 0; }
.toasts { position: fixed; bottom: 16px; right: 16px; display: grid; gap: 8px; z-index: 60; max-width: calc(100vw - 32px); }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; padding: 10px 14px; box-shadow: 0 8px 24px rgba(0,0,0,.3); animation: fade .2s; }
.toast.bad { border-left-color: var(--bad); }
.toast.ok { border-left-color: var(--ok); }
.empty-row td { text-align: center; color: var(--muted); padding: 30px; }

@media (max-width: 900px) {
  .server-grid { grid-template-columns: 1fr; }
  .charts { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  main { padding: 12px 16px; }
  .topbar { flex-wrap: wrap; padding: 8px 16px; gap: 8px; }
  .tabs { order: 3; flex-basis: 100%; }
  .user { margin-left: auto; }
  .gauges { grid-template-columns: repeat(2, 1fr); }
  .charts { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  .toolbar { flex-wrap: wrap; }
  .term-tabs { max-width: 100%; flex-basis: 100%; }
  .term-area { height: calc(100vh - 220px); }
  .card { padding: 14px; }
}

/* Stockage réseau : une carte sur toute la largeur, volumes côte à côte */
.storage-card { margin-bottom: 18px; }
.storage-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 4px 32px; }
.disk .nums b { color: var(--text); font-weight: 600; }

.disk .name { white-space: normal; overflow: visible; }
