:root {
  --color-primary-50: 239 246 255;
  --color-primary-100: 219 234 254;
  --color-primary-200: 191 219 254;
  --color-primary-300: 147 197 253;
  --color-primary-400: 96 165 250;
  --color-primary-500: 59 130 246;
  --color-primary-600: 37 99 235;
  --color-primary-700: 29 78 216;
  --color-primary-800: 30 64 175;
  --color-primary-900: 30 58 138;
  --color-primary-950: 23 37 84;
  --bs-primary: rgb(var(--color-primary-600));
  --bs-primary-rgb: var(--color-primary-600);
  --bs-link-color-rgb: var(--color-primary-600);
  --bs-link-hover-color-rgb: var(--color-primary-700);
  --ma-border: rgba(15, 23, 42, 0.08);
  --ma-surface-sidebar: #16181d;
  --ma-surface-base: #1d2026;
  --ma-surface-1: #22262d;
  --ma-surface-2: #272c34;
  --ma-surface-3: #2d333c;
  --ma-surface-overlay: #343b45;
}

body.theme-dark,
body.theme-light,
body.theme-blue {
  --color-primary-50: 239 246 255;
  --color-primary-100: 219 234 254;
  --color-primary-200: 191 219 254;
  --color-primary-300: 147 197 253;
  --color-primary-400: 96 165 250;
  --color-primary-500: 59 130 246;
  --color-primary-600: 37 99 235;
  --color-primary-700: 29 78 216;
  --color-primary-800: 30 64 175;
  --color-primary-900: 30 58 138;
  --color-primary-950: 23 37 84;
}

body.theme-green {
  --color-primary-50: 236 253 245;
  --color-primary-100: 209 250 229;
  --color-primary-200: 167 243 208;
  --color-primary-300: 110 231 183;
  --color-primary-400: 52 211 153;
  --color-primary-500: 16 185 129;
  --color-primary-600: 5 150 105;
  --color-primary-700: 4 120 87;
  --color-primary-800: 6 95 70;
  --color-primary-900: 6 78 59;
  --color-primary-950: 2 44 34;
}

body.theme-red {
  --color-primary-50: 254 242 242;
  --color-primary-100: 254 226 226;
  --color-primary-200: 254 202 202;
  --color-primary-300: 252 165 165;
  --color-primary-400: 248 113 113;
  --color-primary-500: 239 68 68;
  --color-primary-600: 220 38 38;
  --color-primary-700: 185 28 28;
  --color-primary-800: 153 27 27;
  --color-primary-900: 127 29 29;
  --color-primary-950: 69 10 10;
}

body.theme-blue,
body.theme-green,
body.theme-red,
body.theme-dark,
body.theme-light {
  --bs-primary: rgb(var(--color-primary-600));
  --bs-primary-rgb: var(--color-primary-600);
  --bs-link-color-rgb: var(--color-primary-600);
  --bs-link-hover-color-rgb: var(--color-primary-700);
}

body {
  font-family: "Inter", system-ui, sans-serif;
  overflow: hidden;
}

html,
body {
  height: 100%;
}

body[data-bs-theme="dark"] {
  --ma-border: rgba(255, 255, 255, 0.06);
  --ma-surface-sidebar: #191b20;
  --ma-surface-base: #21252b;
  --ma-surface-1: #242930;
  --ma-surface-2: #282e36;
  --ma-surface-3: #2c333c;
  --ma-surface-overlay: #313944;
  background:
    radial-gradient(circle at top left, rgba(var(--color-primary-700), 0.28), transparent 28%),
    linear-gradient(180deg, #171a1f 0%, #1b1f26 55%, #20252c 100%);
  color: #e5eefb;
}

body[data-bs-theme="light"] {
  --ma-border: rgba(15, 23, 42, 0.08);
  --ma-surface-sidebar: #e2e5ea;
  --ma-surface-base: #eceff3;
  --ma-surface-1: #e9ecf0;
  --ma-surface-2: #e6e9ee;
  --ma-surface-3: #e3e7ec;
  --ma-surface-overlay: #dde2e8;
  background:
    radial-gradient(circle at top left, rgba(var(--color-primary-200), 0.55), transparent 28%),
    linear-gradient(180deg, #f7f9fc 0%, #f0f3f7 55%, #eaedf2 100%);
  color: #0f172a;
}

a {
  text-decoration: none;
}

.auth-card,
.node-chip,
.sidebar-status,
.hero-stat,
.stat-card,
.preview-card,
.console-output {
  border-radius: 1.25rem;
}

.auth-card {
  background: color-mix(in srgb, var(--ma-surface-overlay) 92%, transparent);
  backdrop-filter: blur(14px);
}

body[data-bs-theme="light"] .auth-card {
  background: color-mix(in srgb, white 58%, var(--ma-surface-base));
}

.auth-brand {
  background:
    radial-gradient(circle at top, rgba(var(--color-primary-600), 0.32), transparent 35%),
    linear-gradient(155deg, #111827 0%, #0f172a 70%, #172554 100%);
}

body[data-bs-theme="light"] .auth-brand {
  background:
    radial-gradient(circle at top, rgba(var(--color-primary-200), 0.55), transparent 35%),
    linear-gradient(155deg, #ffffff 0%, #eef5ff 70%, #e4ecff 100%);
}

.auth-feature {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0.85rem 1rem;
  border-radius: 1rem;
  background: color-mix(in srgb, var(--ma-surface-2) 88%, transparent);
  border: 1px solid rgba(var(--color-primary-500), 0.35);
  font-weight: 500;
}

body[data-bs-theme="light"] .auth-feature {
  background: color-mix(in srgb, white 55%, var(--ma-surface-1));
  border: 1px solid rgba(var(--color-primary-200), 0.7);
}

.brand-mark,
.brand-mark-lg,
.stat-icon,
.chip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 1rem;
  background: linear-gradient(135deg, rgb(var(--color-primary-500)), rgb(var(--color-primary-700)));
  color: #fff;
  box-shadow: 0 0.75rem 2rem rgba(var(--color-primary-700), 0.18);
}

.brand-mark {
  width: 3rem;
  height: 3rem;
  font-size: 1.3rem;
}

.brand-mark-lg {
  width: 4rem;
  height: 4rem;
  font-size: 1.75rem;
}

.stat-icon,
.chip-icon {
  width: 3.25rem;
  height: 3.25rem;
  font-size: 1.4rem;
}

.content {
  min-width: 0;
  min-height: 0;
  background: color-mix(in srgb, var(--ma-surface-base) 96%, transparent);
  overflow: hidden;
}

.app-header,
.app-footer {
  background: color-mix(in srgb, var(--ma-surface-2) 94%, transparent);
  backdrop-filter: blur(14px);
}

body[data-bs-theme="light"] .app-header,
body[data-bs-theme="light"] .app-footer {
  background: color-mix(in srgb, white 42%, var(--ma-surface-2));
}

.app-sidebar {
  width: 280px;
  background: color-mix(in srgb, var(--ma-surface-sidebar) 97%, transparent);
  backdrop-filter: blur(14px);
  overflow: auto;
}

body[data-bs-theme="light"] .app-sidebar {
  background: color-mix(in srgb, white 22%, var(--ma-surface-sidebar));
}

.app-sidebar-nav .btn {
  justify-content: flex-start;
  align-items: center;
  gap: 0.4rem;
}

.sidebar-logo {
  width: 3rem;
  height: 3rem;
  object-fit: cover;
  border-radius: 0.95rem;
  box-shadow: 0 0.75rem 2rem rgba(var(--color-primary-700), 0.18);
}

.min-w-0 {
  min-width: 0;
}

.app-shell {
  height: 100vh;
  overflow: hidden;
}

.container-fluid {
  min-height: 0;
}

.content > .container-fluid {
  height: 100%;
  overflow: auto;
}

.header-search {
  position: relative;
  width: min(22rem, 42vw);
}

.header-search .form-control {
  padding-left: 2.35rem;
}

.header-search-icon {
  position: absolute;
  top: 50%;
  left: 0.85rem;
  transform: translateY(-50%);
  color: var(--bs-secondary-color);
  pointer-events: none;
}

.btn-icon {
  width: 2.6rem;
  height: 2.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.node-chip {
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.node-chip:hover {
  transform: translateY(-3px);
  box-shadow: 0 1rem 2rem rgba(2, 6, 23, 0.35);
}

.dashboard-loader {
  min-height: 220px;
}

.dashboard-spinner {
  display: grid;
  place-items: center;
  min-height: 160px;
}

.kpi-card {
  overflow: hidden;
  position: relative;
}

.kpi-graph {
  position: absolute;
  inset: 0;
  opacity: 0.55;
  pointer-events: none;
}

.kpi-graph svg {
  width: 100%;
  height: 100%;
}

.node-tile {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  min-height: 118px;
}

.node-tile-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem;
  border-right: 1px solid var(--ma-border);
}

.node-tile-main {
  padding: 0.7rem 0.8rem 0.7rem 0.75rem;
  min-width: 0;
  position: relative;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  align-items: start;
}

.node-tile-heading {
  min-width: 0;
}

.node-tile-metrics {
  display: grid;
  gap: 0.45rem;
  align-self: start;
}

.node-tile-meta {
  align-self: end;
  margin-top: 0.55rem;
}

.node-metric {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) 2.4rem;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
}

.node-metric .progress {
  --bs-progress-height: 0.35rem;
  display: flex;
  align-items: center;
  margin: 0;
}

.node-tile .chip-icon {
  width: 2.35rem;
  height: 2.35rem;
  font-size: 1rem;
}

.node-loading-icon {
  animation: node-icon-spin 1s linear infinite;
}

@keyframes node-icon-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.node-tile-main .badge {
  font-size: 0.65rem;
  padding: 0.35rem 0.45rem;
}

.node-tile-main h3 {
  font-size: 0.95rem;
}

.node-tile-main .small {
  font-size: 0.74rem;
}

.node-status {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  display: inline-block;
  position: absolute;
  top: 0.75rem;
  right: 0.8rem;
}

.node-status.is-online {
  background: #22c55e;
  box-shadow: 0 0 0 0.2rem rgba(34, 197, 94, 0.15);
}

.node-status.is-offline {
  background: #64748b;
  box-shadow: 0 0 0 0.2rem rgba(100, 116, 139, 0.12);
}

.node-metric-label,
.node-metric-value {
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1;
}

.node-metric-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  justify-self: end;
}

.system-summary-item {
  display: grid;
  grid-template-columns: 3.25rem minmax(0, 1fr);
  gap: 0.9rem;
  align-items: center;
}

.system-summary-icon {
  width: 3rem;
  height: 3rem;
  font-size: 1.2rem;
}

.system-summary-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--bs-secondary-color);
  margin-bottom: 0.15rem;
}

.system-summary-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--bs-emphasis-color);
}

.system-summary-stats {
  display: grid;
  gap: 0.75rem;
  padding-top: 0.25rem;
}

.system-summary-stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.92rem;
}

.progress {
  --bs-progress-height: 0.6rem;
  background: color-mix(in srgb, black 18%, var(--ma-surface-1));
}

.card,
.list-group-item,
.form-control,
.form-select,
.btn,
.table,
.alert,
.badge,
.modal-content,
.dropdown-menu {
  border-color: var(--ma-border);
}

.card,
.list-group-item,
.table,
.modal-content,
.dropdown-menu,
.sidebar-status,
.theme-card,
.add-vm-panel,
.auth-toggle-option,
.option-check {
  background: var(--ma-surface-1);
}

.stat-card,
.node-chip,
.dashboard-loader > .card,
.preview-card.dim {
  background: var(--ma-surface-2);
}

.modal-content {
  background: var(--ma-surface-overlay);
}

body[data-bs-theme="light"] .card,
body[data-bs-theme="light"] .list-group-item,
body[data-bs-theme="light"] .table,
body[data-bs-theme="light"] .modal-content,
body[data-bs-theme="light"] .dropdown-menu,
body[data-bs-theme="light"] .sidebar-status,
body[data-bs-theme="light"] .theme-card,
body[data-bs-theme="light"] .add-vm-panel,
body[data-bs-theme="light"] .auth-toggle-option,
body[data-bs-theme="light"] .option-check {
  background: var(--ma-surface-1);
}

.add-vm-form {
  display: grid;
  gap: 1rem;
}

.add-vm-panel {
  border: 1px solid var(--ma-border);
  border-radius: 1.1rem;
  padding: 1rem;
}

body[data-bs-theme="light"] .add-vm-panel {
  background: var(--ma-surface-1);
}

.add-vm-panel-title {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--bs-secondary-color);
  margin-bottom: 0.9rem;
}

.auth-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.auth-toggle-option {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--ma-border);
  border-radius: 0.95rem;
  cursor: pointer;
  transition: border-color 0.18s ease, background-color 0.18s ease, transform 0.18s ease;
}

body[data-bs-theme="light"] .auth-toggle-option {
  background: var(--ma-surface-1);
}

.auth-toggle-label {
  font-weight: 600;
  color: var(--bs-emphasis-color);
}

.btn-check:checked + .auth-toggle-option {
  border-color: rgba(var(--color-primary-500), 0.7);
  background: rgba(var(--color-primary-500), 0.12);
  transform: translateY(-1px);
}

.auth-mode-panel {
  min-height: 74px;
}

.option-check {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-height: calc(1.5em + 0.75rem + 2px);
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--ma-border);
  border-radius: 0.95rem;
}

body[data-bs-theme="light"] .option-check {
  background: var(--ma-surface-1);
}

.run-pre,
.code-block,
.console-output {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.9rem;
}

.run-pre,
.code-block {
  background: #13161b;
  color: #dbeafe;
  padding: 1rem;
  border-radius: 1rem;
}

.console-output {
  min-height: 420px;
  max-height: 60vh;
  overflow: auto;
  background: #0b1220;
  color: #dbeafe;
  padding: 0;
}

.console-shell {
  position: relative;
}

.console-terminal {
  min-height: 420px;
  height: 60vh;
  overflow: hidden;
}

.console-panel {
  min-height: 100vh;
}

.console-panel .console-terminal {
  height: 100vh;
}

.console-fullscreen-shell {
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

.console-terminal .xterm {
  height: 100%;
  background: #0b1220;
  padding: 0.9rem 1rem;
}

.console-terminal .xterm-viewport {
  background: #0b1220;
  border-radius: 1.25rem;
}

.preview-card {
  min-height: 120px;
  border: 1px solid rgba(var(--color-primary-700), 0.55);
  background: linear-gradient(135deg, rgba(var(--color-primary-900), 0.95), rgba(var(--color-primary-700), 0.8));
}

.preview-card.accent {
  background: linear-gradient(135deg, rgba(var(--color-primary-500), 0.92), rgba(var(--color-primary-700), 0.92));
}

.preview-card.dim {
  background: linear-gradient(135deg, #0f172a, #1e293b);
}

body[data-bs-theme="light"] .preview-card {
  background: linear-gradient(135deg, rgba(var(--color-primary-100), 0.9), rgba(var(--color-primary-300), 0.9));
  border: 1px solid rgba(var(--color-primary-200), 0.9);
}

body[data-bs-theme="light"] .preview-card.dim {
  background: linear-gradient(135deg, #ffffff, #e2e8f0);
}

.qr-panel img {
  width: 100%;
  height: auto;
}

.theme-card {
  padding: 1rem;
  border: 1px solid var(--ma-border);
  border-radius: 1rem;
  cursor: pointer;
}

body[data-bs-theme="light"] .theme-card {
  background: var(--ma-surface-1);
}

.theme-card strong,
.theme-card small {
  display: block;
}

.theme-card small {
  color: var(--bs-secondary-color);
}

.theme-swatch {
  display: block;
  height: 88px;
  border-radius: 0.85rem;
  margin-bottom: 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.swatch-dark {
  background: linear-gradient(135deg, #0f172a, #1e293b);
}

.swatch-light {
  background: linear-gradient(135deg, #ffffff, #e2e8f0);
}

.swatch-green {
  background: linear-gradient(135deg, rgb(16 185 129), rgb(4 120 87));
}

.swatch-red {
  background: linear-gradient(135deg, rgb(239 68 68), rgb(185 28 28));
}

.swatch-blue {
  background: linear-gradient(135deg, rgb(59 130 246), rgb(29 78 216));
}

.btn-check:checked + .theme-card {
  border-color: rgb(var(--color-primary-500));
  box-shadow: 0 0 0 0.2rem rgba(var(--color-primary-500), 0.2);
}

@media (max-width: 991.98px) {
  .app-shell {
    flex-direction: column;
  }

  .app-sidebar {
    width: 100%;
  }

  .auth-toggle {
    grid-template-columns: 1fr;
  }
}
