:root {
  --bg: #0b0f17;
  --card: #121826;
  --card-2: #182032;
  --border: #24304a;
  --text: #e7ecf5;
  --muted: #8fa0bf;
  --accent: #4f8cff;
  --accent-2: #6aa6ff;
  --ok: #37d67a;
  --warn: #f5b83d;
  --down: #ff5c5c;
  --unknown: #8fa0bf;
  --radius: 12px;
  --shadow: 0 8px 30px rgba(0, 0, 0, .35);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(79,140,255,.14), transparent 60%),
    radial-gradient(900px 420px at -10% 110%, rgba(55,214,122,.08), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
}
.hidden { display: none !important; }
button { font-family: inherit; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 32px; box-shadow: var(--shadow); text-align: center;
}
.login-logo {
  width: 54px; height: 54px; margin: 0 auto 14px; border-radius: 14px; display: flex;
  align-items: center; justify-content: center; font-weight: 800; font-size: 17px; letter-spacing: .05em;
  background: linear-gradient(135deg, var(--accent), #7c5cff); color: #fff;
}
.login-card h1 { font-size: 19px; margin: 0 0 6px; }
.login-sub { color: var(--muted); font-size: 12.5px; margin: 0 0 22px; }
.login-card label { display: block; text-align: left; font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.login-card input {
  width: 100%; margin-top: 6px; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 14px; outline: none;
}
.login-card input:focus { border-color: var(--accent); }
.login-error { color: var(--down); font-size: 13px; margin-bottom: 12px; text-align: center; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid var(--border); background: var(--card-2); color: var(--text);
  border-radius: 9px; padding: 7px 13px; font-size: 13px; cursor: pointer;
  transition: filter .12s, background .12s;
}
.btn:hover { filter: brightness(1.12); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #6c55ff); border-color: transparent; color: #fff; font-weight: 600;
}
.btn-ghost { background: transparent; }
.btn-block { width: 100%; padding: 11px; }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 7px; }

/* ---------- Header ---------- */
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 26px 6px; gap: 12px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo-sm {
  width: 40px; height: 40px; border-radius: 11px; display: flex; align-items: center; justify-content: center;
  font-weight: 800; background: linear-gradient(135deg, var(--accent), #7c5cff); color: #fff; font-size: 13px;
}
.title { font-size: 17px; font-weight: 700; letter-spacing: .01em; }
.subtitle { color: var(--muted); font-size: 12px; }
.header-right { display: flex; align-items: center; gap: 12px; }
.user-label { color: var(--muted); font-size: 13px; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; padding: 14px 26px 6px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.stat .n { font-size: 26px; font-weight: 800; line-height: 1.05; }
.stat .l { color: var(--muted); font-size: 11.5px; margin-top: 3px; text-transform: uppercase; letter-spacing: .05em; }
.c-ok { color: var(--ok); } .c-warn { color: var(--warn); } .c-down { color: var(--down); } .c-total { color: var(--accent-2); }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; gap: 8px; padding: 12px 26px 6px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select {
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  border-radius: 9px; padding: 8px 10px; font-size: 14px; outline: none;
}
.toolbar input:focus, .toolbar select:focus { border-color: var(--accent); }
.search { flex: 1; min-width: 200px; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); gap: 14px; padding: 12px 26px 26px; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

/* ---------- Table ---------- */
.table-wrap { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  padding: 10px 14px; border-bottom: 1px solid var(--border); background: rgba(255,255,255,.015);
}
tbody td { padding: 9px 14px; border-bottom: 1px solid rgba(36,48,74,.5); vertical-align: middle; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: rgba(79,140,255,.06); }
tbody tr.sel { background: rgba(79,140,255,.14); box-shadow: inset 3px 0 0 var(--accent); }
tbody tr:last-child td { border-bottom: none; }
.cell-name { font-weight: 650; font-size: 14.5px; }
.cell-sub { color: var(--muted); font-size: 11.5px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; margin-top: 2px; }
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700;
  padding: 3px 10px; border-radius: 99px; white-space: nowrap;
}
.badge.ok { background: rgba(55,214,122,.13); color: var(--ok); }
.badge.warn { background: rgba(245,184,61,.13); color: var(--warn); }
.badge.down { background: rgba(255,92,92,.13); color: var(--down); }
.badge.unknown { background: rgba(143,160,191,.13); color: var(--unknown); }
.pill-type {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700;
  padding: 3px 11px; border-radius: 99px; white-space: nowrap; letter-spacing: .01em;
}
.pill-type.proxmox { background: rgba(245,184,61,.16); color: #fbbf24; }
.pill-type.vm-windows { background: rgba(79,140,255,.16); color: var(--accent-2); }
.pill-type.vm-linux { background: rgba(55,214,122,.16); color: var(--ok); }
.pill-type.docker-host { background: rgba(38,198,218,.16); color: #26c6da; }
.pill-type.nas { background: rgba(167,139,250,.16); color: #c4b5fd; }
.pill-type.service { background: rgba(244,114,182,.16); color: #f472b6; }
.pill-type.other { background: rgba(143,160,191,.16); color: var(--muted); }
.chip-vm {
  display: inline-block; background: rgba(79,140,255,.15); color: var(--accent-2);
  border-radius: 99px; padding: 1px 9px; font-size: 11.5px; font-weight: 700; margin: 1px 3px 1px 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.chip-kw {
  display: inline-block; background: rgba(245,184,61,.15); color: var(--warn);
  border-radius: 7px; padding: 1px 7px; font-size: 11.5px; font-weight: 700; margin-right: 3px;
}
.tip { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--card-2); border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

/* ---------- Detail ---------- */
.detail {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; position: sticky; top: 12px;
}
.detail-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 30px 8px; }
.detail h2 { margin: 0 0 4px; font-size: 21px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.detail .d-alias { color: var(--muted); font-size: 12px; margin-bottom: 10px; font-family: ui-monospace, Menlo, Consolas, monospace; }
.drow { display: flex; justify-content: space-between; gap: 14px; padding: 7px 0; border-bottom: 1px dashed rgba(36,48,74,.7); font-size: 13.5px; align-items: baseline; }
.drow:last-child { border-bottom: none; }
.drow .k { color: var(--muted); font-size: 12.5px; flex-shrink: 0; }
.drow .v { text-align: right; word-break: break-word; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.drow .v.plain { font-family: inherit; }
.d-note { color: var(--muted); font-size: 13px; line-height: 1.55; margin: 10px 0 0; }
.d-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.d-actions .spacer { flex: 1; }
.btn-link { color: var(--accent-2); border-color: rgba(79,140,255,.4); text-decoration: none; display: inline-flex; align-items: center; gap: 5px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(4,7,13,.72); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.modal-card {
  width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; background: var(--card);
  border: 1px solid var(--border); border-radius: 16px; padding: 24px; box-shadow: var(--shadow);
}
.modal-card h2 { margin: 0 0 18px; font-size: 17px; }
.modal-card label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.modal-card input, .modal-card select, .modal-card textarea {
  width: 100%; margin-top: 5px; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 13.5px; outline: none; resize: vertical;
}
.modal-card input:focus, .modal-card select:focus, .modal-card textarea:focus { border-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
