:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel-2: #1c232c;
  --line: #2a323d;
  --text: #e6edf3;
  --muted: #8b96a5;
  --accent: #4f8cff;
  --ok: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --cpu: #4f8cff;
  --mem: #b07cff;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
h2 { font-size: 15px; margin: 0; font-weight: 600; }

/* Connexion */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; display: grid; gap: 14px; }
.login-card label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
input, select { background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 9px 11px; font: inherit; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.error { color: var(--bad); min-height: 1em; margin: 0; }

.brand { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }

.btn { border: 1px solid var(--line); background: var(--panel-2); color: var(--text); border-radius: 8px; padding: 8px 14px; font: inherit; cursor: pointer; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.danger:hover { border-color: var(--bad); color: var(--bad); }
.btn:disabled { opacity: .5; cursor: wait; }

/* Mise en page */
main { max-width: 1200px; margin: 0 auto; padding: 20px 16px 60px; display: grid; gap: 18px; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.top-actions { display: flex; align-items: center; gap: 12px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 6px; }
.card .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.card .value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.card .sub { color: var(--muted); font-size: 12px; }
.bar { height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--ok); border-radius: 3px; transition: width .4s; }
.bar > i.warn { background: var(--warn); }
.bar > i.bad { background: var(--bad); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.legend { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 3px; display: inline-block; border-radius: 2px; margin-left: 8px; }
.sw.cpu { background: var(--cpu); }
.sw.mem { background: var(--mem); }
canvas { width: 100%; display: block; }
.filter { width: 200px; max-width: 100%; padding: 6px 10px; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table a { color: var(--accent); text-decoration: none; }
.table a:hover { text-decoration: underline; }
.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12px; }
.nowrap { white-space: nowrap; }
.actions { display: flex; gap: 6px; justify-content: flex-end; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); font-size: 12px; white-space: nowrap; }

.project { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.project + .project { margin-top: 10px; }
.project-head { background: var(--panel-2); padding: 10px 12px; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; }
.project-head strong { display: flex; align-items: center; gap: 8px; }

/* Logs */
dialog { width: min(1100px, calc(100vw - 32px)); height: min(80vh, 800px); padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text); }
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.dialog-head select { padding: 4px 8px; font-size: 12px; }
#logs-body { margin: 0; padding: 12px 14px; overflow: auto; flex: 1; font: 12px/1.5 ui-monospace, "Cascadia Code", Consolas, monospace; white-space: pre-wrap; word-break: break-all; color: #c9d1d9; }

dialog.small-dialog { width: min(520px, calc(100vw - 32px)); height: auto; }
.route-form { display: flex; flex-direction: column; width: 100%; }
.route-body { padding: 16px; display: grid; gap: 14px; }
.route-body label { display: grid; gap: 6px; font-size: 13px; }
.route-body p { margin: 0; }
.host-input { display: flex; align-items: center; gap: 6px; }
.host-input input { flex: 1; min-width: 0; }
.banner { border: 1px solid var(--line); background: var(--panel-2); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.banner.warn { border-color: var(--warn); }
.banner.ok { border-color: var(--ok); }
.banner code, .route-body code { font-family: ui-monospace, Consolas, monospace; background: var(--bg); padding: 1px 5px; border-radius: 4px; }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: rgba(79, 140, 255, .15); color: var(--accent); margin-left: 6px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--panel-2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 8px; opacity: 0; pointer-events: none; transition: .25s; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.bad { border-color: var(--bad); }

@media (max-width: 640px) {
  .hide-sm { display: none; }
  .card .value { font-size: 22px; }
}
