@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.8);
  --bg-glass: rgba(255, 255, 255, 0.03);
  --border: rgba(255, 255, 255, 0.08);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #6366f1;
  --accent-glow: rgba(99, 102, 241, 0.3);
  --green: #10b981;
  --green-glow: rgba(16, 185, 129, 0.3);
  --red: #ef4444;
  --red-glow: rgba(239, 68, 68, 0.3);
  --yellow: #f59e0b;
  --yellow-glow: rgba(245, 158, 11, 0.3);
  --cyan: #06b6d4;
  --radius: 16px;
  --radius-sm: 10px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
              radial-gradient(ellipse at 80% 20%, rgba(6, 182, 212, 0.06) 0%, transparent 50%),
              radial-gradient(ellipse at 50% 80%, rgba(16, 185, 129, 0.04) 0%, transparent 50%);
  z-index: 0;
  pointer-events: none;
}

/* ── Header ────────────────────────────────────────── */
.header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 16px 32px;
  display: flex; align-items: center; justify-content: space-between;
}

.header-left { display: flex; align-items: center; gap: 14px; }

.logo {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; color: white;
  box-shadow: 0 0 20px var(--accent-glow);
}

.header h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.5px; }
.header p { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.conn-badge {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px;
  border-radius: 100px;
  font-size: 13px; font-weight: 500;
  border: 1px solid var(--border);
  background: var(--bg-glass);
  transition: var(--transition);
}
.conn-badge .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: var(--transition);
}
.conn-badge.online .dot { background: var(--green); box-shadow: 0 0 8px var(--green-glow); }
.conn-badge.offline .dot { background: var(--red); box-shadow: 0 0 8px var(--red-glow); }

/* ── Layout ────────────────────────────────────────── */
.container {
  position: relative; z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 32px;
}

/* ── Nav Tabs ──────────────────────────────────────── */
.nav-tabs {
  display: flex; gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 5px;
  margin-bottom: 28px;
  backdrop-filter: blur(12px);
  width: fit-content;
}

.nav-tab {
  padding: 10px 22px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: flex; align-items: center; gap: 8px;
}
.nav-tab:hover { color: var(--text-primary); background: var(--bg-glass); }
.nav-tab.active {
  color: white;
  background: linear-gradient(135deg, var(--accent), #818cf8);
  box-shadow: 0 4px 15px var(--accent-glow);
}
.nav-tab svg { width: 16px; height: 16px; }

/* ── Tab Content ───────────────────────────────────── */
.tab-content { display: none; animation: fadeIn 0.4s ease; }
.tab-content.active { display: block; }

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

/* ── Stats Grid ────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  backdrop-filter: blur(12px);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: var(--radius) var(--radius) 0 0;
}
.stat-card:hover { border-color: rgba(255,255,255,0.15); transform: translateY(-2px); }
.stat-card.purple::before { background: linear-gradient(90deg, var(--accent), #818cf8); }
.stat-card.green::before { background: linear-gradient(90deg, var(--green), #34d399); }
.stat-card.cyan::before { background: linear-gradient(90deg, var(--cyan), #22d3ee); }
.stat-card.yellow::before { background: linear-gradient(90deg, var(--yellow), #fbbf24); }

.stat-card .label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px; }
.stat-card .value { font-size: 28px; font-weight: 700; letter-spacing: -1px; }
.stat-card .sub { font-size: 12px; color: var(--text-secondary); margin-top: 6px; }

/* ── Card / Panel ──────────────────────────────────── */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  margin-bottom: 24px;
  overflow: hidden;
}

.panel-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.panel-header h3 { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.panel-body { padding: 24px; }

/* ── Table ─────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  color: var(--text-secondary);
}
tbody tr { transition: var(--transition); }
tbody tr:hover { background: rgba(255,255,255,0.02); }
tbody tr:last-child td { border-bottom: none; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge.online { background: rgba(16,185,129,0.12); color: var(--green); }
.badge.offline { background: rgba(239,68,68,0.12); color: var(--red); }

.badge .dot-sm {
  width: 6px; height: 6px;
  border-radius: 50%;
}
.badge.online .dot-sm { background: var(--green); }
.badge.offline .dot-sm { background: var(--red); }

/* ── Forms ─────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  transition: var(--transition);
  outline: none;
}
.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-input::placeholder { color: var(--text-muted); }

select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

/* ── Buttons ───────────────────────────────────────── */
.btn {
  padding: 11px 24px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex; align-items: center; gap: 8px;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #818cf8);
  color: white;
  box-shadow: 0 4px 15px var(--accent-glow);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 25px var(--accent-glow); }

.btn-danger {
  background: rgba(239,68,68,0.12);
  color: var(--red);
  border: 1px solid rgba(239,68,68,0.2);
}
.btn-danger:hover { background: rgba(239,68,68,0.2); }

.btn-ghost {
  background: var(--bg-glass);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text-primary); border-color: rgba(255,255,255,0.15); }

.btn-sm { padding: 7px 14px; font-size: 12px; border-radius: 8px; }

.btn-icon {
  width: 36px; height: 36px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
}

/* ── CLI Terminal ──────────────────────────────────── */
.cli-output {
  background: #050810;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px;
  font-family: 'Fira Code', 'Cascadia Code', monospace;
  font-size: 12px;
  line-height: 1.7;
  color: var(--green);
  max-height: 400px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.cli-input-wrap {
  display: flex; gap: 10px;
  margin-top: 14px;
}

.cli-input {
  flex: 1;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #050810;
  color: var(--green);
  font-family: 'Fira Code', 'Cascadia Code', monospace;
  font-size: 13px;
  outline: none;
  transition: var(--transition);
}
.cli-input:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-glow); }

/* ── Toast ─────────────────────────────────────────── */
.toast-container { position: fixed; top: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }

.toast {
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  animation: slideIn 0.4s ease, fadeOut 0.4s ease 3.6s forwards;
  display: flex; align-items: center; gap: 10px;
  min-width: 280px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}
.toast.success { background: rgba(16,185,129,0.15); color: var(--green); border-color: rgba(16,185,129,0.3); }
.toast.error { background: rgba(239,68,68,0.15); color: var(--red); border-color: rgba(239,68,68,0.3); }
.toast.info { background: rgba(99,102,241,0.15); color: #818cf8; border-color: rgba(99,102,241,0.3); }

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

/* ── Spinner ───────────────────────────────────────── */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  display: flex; align-items: center; justify-content: center;
  padding: 60px 0;
  color: var(--text-muted);
  font-size: 14px;
  gap: 12px;
}

/* ── Empty State ───────────────────────────────────── */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: 16px; opacity: 0.3; }
.empty-state p { font-size: 14px; }

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 768px) {
  .header { padding: 14px 18px; }
  .container { padding: 18px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .nav-tabs { width: 100%; overflow-x: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .stat-card .value { font-size: 22px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* ── Scrollbar ─────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ── Version Info Panel ────────────────────────────── */
.version-box {
  background: rgba(99,102,241,0.06);
  border: 1px solid rgba(99,102,241,0.15);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.6;
  font-family: 'Fira Code', monospace;
}

/* ── Progress Bar ──────────────────────────────────── */
.progress-bar {
  height: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 8px;
}
.progress-bar .fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease;
}
.progress-bar .fill.green { background: linear-gradient(90deg, var(--green), #34d399); }
.progress-bar .fill.yellow { background: linear-gradient(90deg, var(--yellow), #fbbf24); }
.progress-bar .fill.red { background: linear-gradient(90deg, var(--red), #f87171); }
