:root {
  --bg-dark: #090d16;
  --bg-card: rgba(18, 24, 38, 0.75);
  --bg-card-hover: rgba(26, 34, 52, 0.85);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-active: rgba(99, 102, 241, 0.4);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-emerald: #10b981;
  --accent-cyan: #06b6d4;
  --accent-red: #ef4444;
  --accent-amber: #f59e0b;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ═══════════════════ LAYOUT ═══════════════════ */
.app-layout {
  display: flex;
  width: 100vw;
  min-height: 100vh;
}

.sidebar {
  width: 270px;
  background: rgba(13, 18, 30, 0.96);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(20px);
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 20;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
}

.brand-title {
  display: block;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  background: linear-gradient(to right, #fff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-sub {
  display: block;
  font-size: 11px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.nav-menu {
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-item {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 12px 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.18), rgba(139, 92, 246, 0.06));
  color: #fff;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.pill-badge {
  margin-left: auto;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 8px;
  border-radius: 12px;
  color: #cbd5e1;
}

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 10px var(--accent-emerald);
  transition: all 0.3s ease;
}

.status-indicator.offline {
  background: var(--accent-rose);
  box-shadow: 0 0 10px var(--accent-rose);
}

.status-title {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #e2e8f0;
}

.status-host {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
}

/* ═══════════════════ MAIN CONTENT ═══════════════════ */
.main-content {
  flex: 1;
  padding: 32px 40px;
  overflow-y: auto;
  max-width: 1440px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}

.topbar-left h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.topbar-left p {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}

.topbar-right {
  display: flex;
  gap: 12px;
}

/* ═══════════════════ NOTICES & BANNERS ═══════════════════ */
.banner-notice {
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 13px;
  line-height: 1.5;
  color: #cbd5e1;
  margin-bottom: 24px;
}

.banner-notice.green {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.25);
}

.banner-notice strong {
  color: #fff;
}

/* ═══════════════════ TAB PANES ═══════════════════ */
.tab-pane {
  display: none;
  animation: fadeIn 0.2s ease forwards;
}

.tab-pane.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════ METRICS ═══════════════════ */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 22px;
  backdrop-filter: blur(12px);
  transition: transform 0.2s, border-color 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-active);
}

.stat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.stat-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.stat-icon {
  font-size: 20px;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 6px;
}

.stat-footer {
  font-size: 12px;
}

.text-emerald { color: var(--accent-emerald); }
.text-gray { color: #64748b; }
.text-muted { color: #64748b; }
.text-center { text-align: center; }

/* ═══════════════════ CARDS & SPLITS ═══════════════════ */
.dashboard-split {
  display: flex;
  gap: 24px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  backdrop-filter: blur(14px);
  overflow: hidden;
}

.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.card-body {
  padding: 24px;
}

.card-title-group {
  display: flex;
  align-items: center;
  gap: 14px;
}

.card-icon {
  font-size: 24px;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
}

.card-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ═══════════════════ DATA TABLE ═══════════════════ */
.table-container {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.data-table th {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-muted);
  padding: 14px 18px;
  font-weight: 600;
  border-bottom: 1px solid var(--border-subtle);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
}

.data-table td {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: #cbd5e1;
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* ═══════════════════ TERMINAL CONSOLE ═══════════════════ */
.terminal-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.terminal-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.terminal-dot.red { background: #ef4444; }
.terminal-dot.yellow { background: #f59e0b; }
.terminal-dot.green { background: #10b981; }

.terminal-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: 6px;
}

.terminal-body {
  background: #050811;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 18px 20px;
  height: 290px;
  overflow-y: auto;
  line-height: 1.6;
}

.log-line {
  margin-bottom: 4px;
  word-break: break-all;
}

.log-line.info { color: #94a3b8; }
.log-line.start { color: var(--accent-cyan); font-weight: 600; }
.log-line.success { color: var(--accent-emerald); font-weight: 600; }
.log-line.error { color: var(--accent-red); font-weight: 600; }
.log-line.warn { color: var(--accent-amber); }

/* ═══════════════════ FILTER PILLS & TOOLBAR ═══════════════════ */
.section-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-pills {
  display: flex;
  background: rgba(0, 0, 0, 0.3);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  gap: 4px;
}

.pill-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pill-btn.active {
  background: rgba(99, 102, 241, 0.25);
  color: #fff;
  border: 1px solid rgba(99, 102, 241, 0.4);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 8px 14px;
  flex: 1;
  max-width: 420px;
}

.search-box input {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 13px;
  outline: none;
  width: 100%;
}

/* ═══════════════════ NODES & SERVICES GRID ═══════════════════ */
.nodes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 22px;
}

.node-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 24px;
  backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: transform 0.2s, border-color 0.2s;
}

.node-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-active);
}

.node-card.service-card {
  border-left: 3px solid var(--accent-emerald);
}

.node-card.vps-card {
  border-left: 3px solid var(--accent-blue);
}

.node-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.node-title {
  font-size: 17px;
  font-weight: 700;
}

.node-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  font-family: var(--font-mono);
}

.node-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  background: rgba(0, 0, 0, 0.25);
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 12px;
}

.node-stat-label {
  color: #64748b;
  display: block;
  font-size: 11px;
}

.node-stat-val {
  font-weight: 600;
  color: #e2e8f0;
}

.node-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  flex-wrap: wrap;
}

/* ═══════════════════ QUOTA BOX ═══════════════════ */
.quota-box {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 10px;
  padding: 16px;
  font-size: 13px;
}

.quota-box.hidden { display: none; }

.quota-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.quota-row {
  display: flex;
  gap: 24px;
}

/* ═══════════════════ PRESETS ═══════════════════ */
.path-presets {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
  font-size: 11px;
  color: #64748b;
}

.preset-tag {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  color: #a5b4fc;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.preset-tag:hover {
  background: rgba(99, 102, 241, 0.2);
  border-color: rgba(99, 102, 241, 0.4);
}

/* ═══════════════════ BUTTONS ═══════════════════ */
.btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.btn-primary {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  border-color: var(--border-subtle);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-outline {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--text-muted);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--accent-blue);
  padding: 6px 12px;
}

.btn-ghost:hover {
  background: rgba(59, 130, 246, 0.1);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

.btn-sm {
  padding: 7px 12px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
}

/* ═══════════════════ FORMS ═══════════════════ */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-row {
  display: flex;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-size: 12px;
  font-weight: 600;
  color: #cbd5e1;
}

.required {
  color: var(--accent-red);
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
textarea,
select {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-subtle);
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.25);
}

.field-hint {
  font-size: 11px;
  color: #64748b;
}

.field-hint code {
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 5px;
  border-radius: 4px;
  color: #a5b4fc;
}

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(0, 0, 0, 0.2);
  padding: 14px 16px;
  border-radius: 8px;
}

.custom-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
  color: #cbd5e1;
}

.button-row {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 10px;
}

/* ═══════════════════ MODALS ═══════════════════ */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.2s ease;
}

.modal-backdrop.hidden { display: none; }

.modal-card {
  background: #0f1626;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  width: 90%;
  max-width: 440px;
  padding: 32px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.modal-lg { max-width: 740px; }

.modal-header h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
}

.modal-header p {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 22px;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #a5b4fc;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  border-radius: 12px;
  margin-bottom: 12px;
}

.brand-dot {
  width: 6px;
  height: 6px;
  background: #6366f1;
  border-radius: 50%;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 18px;
}

.error-msg {
  color: var(--accent-red);
  font-size: 12px;
  margin-top: 4px;
}

.error-msg.hidden { display: none; }

.auth-hint {
  font-size: 11px;
  color: #64748b;
  margin-top: 14px;
  text-align: center;
}

/* ═══════════════════ BADGES ═══════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.badge-success { background: rgba(16, 185, 129, 0.12); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.25); }
.badge-running { background: rgba(59, 130, 246, 0.12); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.25); }
.badge-failed { background: rgba(239, 68, 68, 0.12); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.25); }
.badge-pending { background: rgba(245, 158, 11, 0.12); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.25); }
.badge-raw { background: rgba(99, 102, 241, 0.15); color: #a5b4fc; border: 1px solid rgba(99, 102, 241, 0.3); }
.badge-srv { background: rgba(16, 185, 129, 0.15); color: #6ee7b7; border: 1px solid rgba(16, 185, 129, 0.3); }

/* ═══════════════════ TOASTS ═══════════════════ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
}

.toast {
  background: #1e293b;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.2s ease forwards;
}

.toast.success { border-left: 4px solid var(--accent-emerald); }
.toast.error { border-left: 4px solid var(--accent-red); }
.toast.info { border-left: 4px solid var(--accent-blue); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@media (max-width: 900px) {
  .app-layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .dashboard-split { flex-direction: column; }
  .form-row { flex-direction: column; gap: 12px; }
  .main-content { padding: 20px; }
}
