:root {
  --bg: #08060d;
  --surface: #120e1a;
  --surface-2: #191323;
  --border: rgba(139, 92, 246, 0.16);
  --border-strong: rgba(139, 92, 246, 0.32);
  --text: #f5f3fb;
  --muted: #9d97ad;
  --accent: #8b5cf6;
  --accent-2: #ec4899;
  --accent-dim: rgba(139, 92, 246, 0.14);
  --success: #22c55e;
  --danger: #f43f5e;
  --warn: #f59e0b;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
  --font-mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  line-height: 1.5;
}

.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.hidden { display: none !important; }

a { color: var(--accent); }

/* ---- Ambient glow backdrop ---- */

.glow-backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 900px 560px at 50% -8%, rgba(139, 92, 246, 0.30), transparent 65%),
    radial-gradient(ellipse 600px 400px at 85% 0%, rgba(236, 72, 153, 0.14), transparent 60%);
}

/* ---- Brand ---- */

.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { width: 46px; height: auto; flex-shrink: 0; display: block; }
.brand-logo path, .brand-logo polygon { fill: var(--accent); }
.login-card .brand-logo { width: 64px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 13px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(139, 92, 246, 0.06);
}

/* ---- Dashboard / server list ---- */

.back-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 18px;
  line-height: 1;
  margin-right: 4px;
}
.back-link:hover { color: var(--text); }

.list-header { margin-bottom: 20px; }

.server-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.server-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
}
.server-card:hover {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 1px var(--border-strong), 0 8px 24px -8px rgba(139, 92, 246, 0.35);
}
.server-card:active { transform: translateY(1px); }
.server-card-top { margin-bottom: 14px; }
.server-card-name { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.server-card-ip { font-size: 13px; margin-bottom: 2px; overflow-wrap: anywhere; }
.server-card-meta { font-size: 12px; }

/* ---- Console modal ---- */

.console-overlay {
  position: fixed; inset: 0;
  background: rgba(5, 3, 9, 0.88);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 60;
}
.console-box {
  background: #000;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  width: 100%;
  max-width: 960px;
  overflow: hidden;
  box-shadow: 0 20px 60px -20px rgba(139, 92, 246, 0.4);
}
.console-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
#console-screen {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
}
#console-screen canvas { width: 100%; height: 100%; display: block; }
.console-screen-terminal { padding: 8px; overflow: hidden; }
.console-screen-terminal .xterm { height: 100%; }

/* ---- Cards ---- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}

h1, h2, h3 { margin: 0 0 8px; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 23px; }
h2 { font-size: 17px; }

/* ---- Status ---- */

.status-row {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}

.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 13px;
  white-space: nowrap;
}
.led {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--muted);
}
.status-pill[data-state="running"] .led { background: var(--success); box-shadow: 0 0 6px 1px var(--success); }
.status-pill[data-state="stopped"] .led { background: var(--danger); }
.status-pill[data-state="transition"] .led {
  background: var(--warn);
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin: 20px 0;
}
.stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  min-width: 0; /* lets grid children shrink below their content's natural width */
  overflow: hidden;
}
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.stat-value {
  font-size: 15px;
  margin-top: 4px;
  overflow-wrap: anywhere; /* forces long unbroken strings (IPs, MACs) to wrap instead of overflowing */
  word-break: break-word;
}

@media (max-width: 560px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---- Buttons ---- */

.actions { display: flex; flex-wrap: wrap; gap: 10px; }

.btn {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: filter 0.12s ease, transform 0.05s ease, border-color 0.12s ease;
}
.btn:hover { filter: brightness(1.2); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 16px -4px rgba(139, 92, 246, 0.55);
}
.btn-ghost { background: transparent; }
.btn-danger { background: var(--danger); border-color: transparent; color: #fff; }
.btn-danger-outline { background: transparent; border-color: rgba(244, 63, 94, 0.5); color: var(--danger); }
.btn-block { width: 100%; }

/* ---- Forms ---- */

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin: 14px 0 6px;
}
input[type="text"],
input[type="password"],
input[type="file"],
select,
textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
}
textarea { font-family: var(--font-mono); resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

/* ---- Tabs ---- */

.tabs { display: flex; gap: 4px; margin: 18px 0 4px; border-bottom: 1px solid var(--border); }
.tab {
  background: none; border: none; color: var(--muted);
  padding: 10px 4px; margin-right: 20px;
  font-size: 14px; cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-panel { padding-top: 16px; }

/* ---- ISO library ---- */

.iso-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  margin-top: 8px;
  font-size: 13px;
}
.iso-row .iso-name { font-family: var(--font-mono); overflow-wrap: anywhere; }
.iso-row-actions { display: flex; gap: 6px; flex-shrink: 0; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* ---- Messages ---- */

.error-text { color: var(--danger); font-size: 13px; margin-top: 12px; }
.success-text { color: var(--success); font-size: 13px; margin-top: 12px; }

/* ---- Topbar / layout ---- */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
}
.topbar-right { display: flex; align-items: center; gap: 14px; font-size: 14px; }

.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 20px 80px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ---- Login page ---- */

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  box-shadow: 0 24px 70px -24px rgba(139, 92, 246, 0.35);
}
.login-card .brand { margin-bottom: 20px; }
.login-card .badge { margin-bottom: 18px; }
.login-card h1 { font-size: 20px; margin-bottom: 4px; }

/* ---- Confirm dialog ---- */

.confirm-overlay {
  position: fixed; inset: 0;
  background: rgba(5, 3, 9, 0.75);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 50;
}
.confirm-box {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 22px;
  max-width: 380px;
  width: 100%;
  box-shadow: 0 24px 70px -24px rgba(139, 92, 246, 0.4);
}
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
