:root {
  --bg: #0a1020;
  --bg-soft: #0e1628;
  --panel: #121d33;
  --panel-2: #17243d;
  --border: #25334e;
  --border-soft: #1d2a42;
  --text: #e9eefb;
  --muted: #93a1bb;
  --accent: #6d72ff;
  --accent-strong: #8589ff;
  --accent-soft: rgba(109, 114, 255, 0.16);
  --good: #35d399;
  --bad: #ff6b6b;
  --warn: #f7bf5d;
  --radius: 14px;
  --shadow: 0 18px 48px rgba(2, 6, 23, 0.45);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 620px at 100% -10%, rgba(109, 114, 255, 0.12), transparent 60%),
    var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 26px; letter-spacing: -0.02em; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
.align-right { text-align: right; }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 246px;
  flex: 0 0 246px;
  padding: 22px 16px;
  border-right: 1px solid var(--border-soft);
  background: rgba(9, 15, 28, 0.82);
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -0.01em; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #3b82f6);
  color: white;
  font-size: 12px;
  letter-spacing: 0.04em;
}
.brand-text { font-size: 15px; }

.nav { display: flex; flex-direction: column; gap: 5px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-link:hover { background: var(--panel); color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent-strong); }
.nav-icon { width: 18px; text-align: center; font-size: 16px; }

.sidebar-note {
  margin-top: auto;
  padding: 14px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: rgba(18, 29, 51, 0.7);
}
.note-title { font-weight: 700; font-size: 13px; margin-bottom: 5px; }
.sidebar-note p { color: var(--muted); font-size: 12px; line-height: 1.5; }

.main-column { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 66px;
  flex: 0 0 66px;
  border-bottom: 1px solid var(--border-soft);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(10, 16, 32, 0.72);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-title { font-weight: 700; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.user-badge {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 800;
}
.user-name { font-weight: 600; }

.content { padding: 28px; width: 100%; max-width: 1440px; margin: 0 auto; }

.page-heading, .terminal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 22px;
}
.heading-actions, .terminal-head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.terminal-head h1 { margin-bottom: 4px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: 9px;
  border: 1px solid transparent;
  font-weight: 650;
  font-size: 13px;
  white-space: nowrap;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 7px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-secondary { background: var(--panel-2); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { border-color: #3a4c6e; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--panel-2); color: var(--text); }
.btn-danger-ghost { background: transparent; border-color: transparent; color: var(--bad); }
.btn-danger-ghost:hover { background: rgba(255, 107, 107, 0.12); }
.icon-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: 8px;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card {
  padding: 18px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-label { color: var(--muted); font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 30px; letter-spacing: -0.03em; }
.stat-hint { color: var(--muted); font-size: 12px; }
.stat-good .stat-value { color: var(--good); }
.stat-bad .stat-value { color: var(--bad); }
.stat-warn .stat-value { color: var(--warn); }

.two-column { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr); gap: 18px; }
.settings-layout { grid-template-columns: minmax(320px, 1fr) minmax(320px, 1.1fr); }

.panel {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(2, 6, 23, 0.18);
}
.panel-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.panel-link { color: var(--accent-strong); font-size: 13px; font-weight: 650; }
.panel-empty { padding: 46px 24px; text-align: center; color: var(--muted); }
.panel-empty h3 { color: var(--text); margin: 10px 0 5px; }
.panel-empty .btn { margin-top: 14px; }
.panel-form { padding: 18px; }

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 680px; }
.data-table th {
  padding: 11px 18px;
  text-align: left;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(255, 255, 255, 0.012);
}
.data-table td { padding: 13px 18px; border-top: 1px solid var(--border-soft); vertical-align: middle; }
.data-table tbody tr:hover { background: rgba(255, 255, 255, 0.018); }
.cell-main { font-weight: 650; }
.cell-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.row-actions { display: flex; align-items: center; gap: 3px; }
.align-right .row-actions { justify-content: flex-end; }

.status-pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(147, 161, 187, 0.15);
  color: var(--muted);
}
.status-pill.online { background: rgba(53, 211, 153, 0.14); color: var(--good); }
.status-pill.offline { background: rgba(255, 107, 107, 0.14); color: var(--bad); }
.status-pill.unknown { background: rgba(247, 191, 93, 0.14); color: var(--warn); }
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 700;
}

.activity-list { list-style: none; margin: 0; padding: 8px 0; }
.activity-list li { display: flex; gap: 12px; padding: 11px 18px; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 6px; flex: 0 0 8px; }
.activity-list li > div { flex: 1; min-width: 0; }
.activity-action { font-weight: 650; font-size: 13px; }
.activity-detail { color: var(--muted); font-size: 12px; }
.activity-list time { color: var(--muted); font-size: 11px; white-space: nowrap; }

.form-stack { display: flex; flex-direction: column; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span, .field-label-row span { font-size: 12px; font-weight: 650; color: var(--muted); }
.field small { font-weight: 500; }
.field-label-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.field-narrow { max-width: 150px; }
.field input, .field select, .field textarea, .panel-form input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input:focus, .field select:focus, .field textarea:focus, .panel-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field textarea { resize: vertical; min-height: 70px; }
.hint { color: var(--muted); font-size: 11px; line-height: 1.45; }
.hint a { color: var(--accent-strong); text-decoration: underline; }

.form-error {
  padding: 10px 12px;
  border-radius: 9px;
  background: rgba(255, 107, 107, 0.12);
  border: 1px solid rgba(255, 107, 107, 0.3);
  color: #ffc9c9;
  font-size: 13px;
}

.modal {
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
  overflow-y: auto;
}
.modal::backdrop { background: rgba(3, 7, 18, 0.72); backdrop-filter: blur(3px); }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.modal-head p { font-size: 13px; margin-top: 3px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 6px; }
.result-box {
  padding: 12px;
  border-radius: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
}
.result-box code { word-break: break-all; color: var(--accent-strong); }

.key-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; padding: 18px; }
.key-card { padding: 16px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--border-soft); }
.key-card-head { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.key-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-strong); font-size: 20px; }
.key-fingerprint { font-family: ui-monospace, monospace; font-size: 11px; color: var(--muted); word-break: break-all; padding: 10px; border-radius: 8px; background: var(--bg-soft); }
.key-card-actions { display: flex; justify-content: flex-end; margin-top: 12px; }

.feature-list { list-style: none; margin: 0; padding: 8px 18px; }
.feature-list li { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border-soft); }
.feature-list li:last-child { border-bottom: 0; }
.feature-check { width: 22px; height: 22px; flex: 0 0 22px; border-radius: 50%; display: grid; place-items: center; background: rgba(53, 211, 153, 0.14); color: var(--good); font-weight: 800; }
.feature-list p { color: var(--muted); font-size: 12px; margin-top: 2px; }
.settings-meta { padding: 14px 18px; border-top: 1px solid var(--border-soft); display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; }
.settings-meta strong { color: var(--text); }

.terminal-shell { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #070b14; box-shadow: var(--shadow); }
.terminal-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border-soft); background: var(--panel); }
.terminal-title { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 650; }
.terminal-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px rgba(53, 211, 153, 0.12); }
.terminal-actions { display: flex; gap: 3px; flex-wrap: wrap; }
.terminal-host { height: min(70vh, 680px); min-height: 360px; padding: 12px; }
.terminal-host .xterm { height: 100%; }
.terminal-commandbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--panel); border-top: 1px solid var(--border-soft); }
.command-prompt { color: var(--good); font-weight: 800; font-size: 15px; }
.terminal-commandbar input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  outline: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.terminal-commandbar input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.terminal-commandbar input:disabled { opacity: 0.55; cursor: not-allowed; }
.terminal-footer { display: flex; justify-content: space-between; gap: 12px; padding: 9px 14px; border-top: 1px solid var(--border-soft); background: var(--panel); color: var(--muted); font-size: 12px; }

.flash-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.flash { padding: 11px 14px; border-radius: 9px; border: 1px solid var(--border); background: var(--panel); }
.flash.error { border-color: rgba(255, 107, 107, 0.35); background: rgba(255, 107, 107, 0.12); color: #ffc9c9; }
.flash.success { border-color: rgba(53, 211, 153, 0.35); background: rgba(53, 211, 153, 0.12); color: #bdf7df; }
.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: 360px;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 100;
}
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { border-color: rgba(255, 107, 107, 0.4); color: #ffc9c9; }
.toast.success { border-color: rgba(53, 211, 153, 0.4); color: #bdf7df; }

.empty-state { max-width: 460px; margin: 80px auto; text-align: center; }
.empty-icon { width: 58px; height: 58px; margin: 0 auto 14px; border-radius: 16px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-strong); font-size: 26px; font-weight: 800; }
.empty-state h2 { font-size: 21px; margin-bottom: 6px; }
.empty-state .btn { margin-top: 18px; }

.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.auth-layout { width: min(980px, 100%); display: grid; grid-template-columns: 1.1fr 0.9fr; border-radius: 20px; overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow); }
.auth-panel { padding: 46px; }
.auth-hero { background: linear-gradient(155deg, rgba(109, 114, 255, 0.24), rgba(14, 22, 40, 0.9) 55%); display: flex; flex-direction: column; gap: 20px; }
.auth-hero h1 { font-size: 34px; max-width: 420px; }
.auth-hero p { color: #c6d0e5; max-width: 420px; }
.brand-light { color: white; }
.hero-list { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 10px; color: #c6d0e5; font-size: 13px; }
.hero-list li::before { content: "✓"; color: var(--good); margin-right: 9px; font-weight: 800; }
.auth-card { background: var(--panel); }
.auth-card-inner { max-width: 360px; margin: 0 auto; width: 100%; }
.auth-card-inner h2 { font-size: 24px; }
.auth-card-inner > p { margin: 6px 0 24px; }
.auth-footer { margin-top: 18px !important; font-size: 11px; text-align: center; }

@media (max-width: 1050px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-column, .settings-layout { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; flex-direction: row; align-items: center; padding: 12px 16px; gap: 12px; overflow-x: auto; }
  .sidebar .nav { flex-direction: row; }
  .sidebar-note { display: none; }
  .topbar { position: static; padding: 0 16px; }
  .content { padding: 18px 14px; }
  .page-heading, .terminal-head { flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .field-narrow { max-width: none; }
  .auth-layout { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .auth-panel { padding: 32px 24px; }
  .terminal-toolbar { flex-direction: column; align-items: flex-start; }
}
