/* ─── Reset & Base ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-primary: #0f1117;
  --bg-secondary: #161822;
  --bg-card: #1c1e2e;
  --bg-card-hover: #232540;
  --bg-input: #12131d;
  --border: #2a2d42;
  --border-hover: #3d4163;
  --text-primary: #e8eaf0;
  --text-secondary: #8b8fa7;
  --text-muted: #5c6080;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-glow: rgba(99,102,241,.15);
  --green: #22c55e;
  --green-bg: rgba(34,197,94,.12);
  --blue: #3b82f6;
  --blue-bg: rgba(59,130,246,.12);
  --purple: #a855f7;
  --purple-bg: rgba(168,85,247,.12);
  --orange: #f59e0b;
  --orange-bg: rgba(245,158,11,.12);
  --red: #ef4444;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,.25);
  --transition: .2s ease;
  --sidebar-w: 260px;
  --font: 'Inter', -apple-system, sans-serif;
  --mono: 'JetBrains Mono', monospace;
}

html { font-size: 14px; }
body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
code { font-family: var(--mono); font-size: .85em; background: var(--bg-input); padding: 2px 6px; border-radius: 4px; }

/* ─── Sidebar ──────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
}
.brand-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}
.sidebar-brand h1 { font-size: 1.1rem; font-weight: 700; letter-spacing: -.02em; }
.brand-sub { font-size: .75rem; color: var(--text-muted); }

.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
  transition: all var(--transition);
}
.nav-item:hover { background: var(--bg-card); color: var(--text-primary); }
.nav-item.active { background: var(--accent-glow); color: var(--accent-hover); }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}
.status-indicator { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--text-secondary); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.status-dot.online { background: var(--green); box-shadow: 0 0 8px var(--green); }
.status-dot.offline { background: var(--red); box-shadow: 0 0 8px var(--red); }

/* ─── Main Content ─────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 32px;
  max-width: 1200px;
}

.view { display: none; animation: fadeIn .3s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}
.view-header h2 { font-size: 1.6rem; font-weight: 800; letter-spacing: -.03em; }
.view-subtitle { color: var(--text-muted); margin-top: 4px; }

.header-actions { display: flex; gap: 10px; align-items: center; }

/* ─── Buttons ──────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: .85rem;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  font-family: var(--font);
}
.btn-outline {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent-hover); background: var(--accent-glow); }
.link-btn { font-size: .85rem; font-weight: 600; color: var(--accent); }
.link-btn:hover { color: var(--accent-hover); }

/* ─── Stats Grid ───────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all var(--transition);
}
.stat-card:hover { border-color: var(--border-hover); transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-icon.blue { background: var(--blue-bg); color: var(--blue); }
.stat-icon.green { background: var(--green-bg); color: var(--green); }
.stat-icon.purple { background: var(--purple-bg); color: var(--purple); }
.stat-icon.orange { background: var(--orange-bg); color: var(--orange); }
.stat-value { font-size: 1.8rem; font-weight: 800; display: block; letter-spacing: -.03em; }
.stat-label { font-size: .8rem; color: var(--text-muted); font-weight: 500; }

/* ─── Cards ────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 1rem; font-weight: 700; }
.card-body { padding: 22px; }

/* ─── Empty State ──────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  color: var(--text-muted);
  text-align: center;
  gap: 8px;
}
.empty-state.small { padding: 32px; }
.empty-state p { font-weight: 600; font-size: .95rem; }
.empty-state span { font-size: .8rem; }

/* ─── Table ────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 12px 16px;
  font-size: .85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.data-table tbody tr { transition: background var(--transition); cursor: pointer; }
.data-table tbody tr:hover { background: var(--bg-card-hover); }
.empty-cell { cursor: default !important; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .02em;
}
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-purple { background: var(--purple-bg); color: var(--purple); }
.badge-orange { background: var(--orange-bg); color: var(--orange); }

.table-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
}
.table-info { font-size: .8rem; color: var(--text-muted); }
.pagination { display: flex; gap: 6px; }
.page-btn {
  width: 34px; height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
}
.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ─── Search ───────────────────────────────────────── */
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  transition: border-color var(--transition);
}
.search-box:focus-within { border-color: var(--accent); }
.search-box input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: .85rem;
  width: 200px;
}
.search-box svg { color: var(--text-muted); flex-shrink: 0; }

/* ─── Settings ─────────────────────────────────────── */
.settings-grid { display: flex; flex-direction: column; gap: 20px; }
.settings-desc { color: var(--text-secondary); margin-bottom: 14px; line-height: 1.6; }

.code-block {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font-family: var(--mono);
  font-size: .85rem;
  color: var(--accent-hover);
  word-break: break-all;
}
.code-block.dark { flex-direction: column; align-items: flex-start; }
.code-block.dark pre { white-space: pre-wrap; line-height: 1.6; color: var(--text-secondary); }
.code-block.dark code { background: none; padding: 0; }
.copy-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  padding: 6px 8px;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.copy-btn:hover { color: var(--accent); border-color: var(--accent); }

.setup-steps { display: flex; flex-direction: column; gap: 20px; }
.step { display: flex; gap: 16px; }
.step-num {
  width: 32px; height: 32px;
  background: var(--accent-glow);
  color: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .85rem;
  flex-shrink: 0;
}
.step strong { display: block; margin-bottom: 4px; }
.step p { color: var(--text-secondary); line-height: 1.5; font-size: .85rem; }

.info-grid { display: flex; flex-direction: column; gap: 12px; }
.info-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.info-row:last-child { border-bottom: none; }
.info-label { color: var(--text-muted); font-weight: 500; }
.info-value { font-weight: 600; }

/* ─── Modal ────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 640px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
  animation: modalIn .25s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all var(--transition);
}
.modal-close:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.modal-body { padding: 24px; overflow-y: auto; }

.detail-grid { display: flex; flex-direction: column; gap: 14px; }
.detail-row { display: flex; gap: 12px; }
.detail-label { min-width: 100px; color: var(--text-muted); font-weight: 500; font-size: .85rem; }
.detail-value { color: var(--text-primary); font-size: .85rem; word-break: break-all; }
.detail-json {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-family: var(--mono);
  font-size: .78rem;
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 300px;
  overflow-y: auto;
  margin-top: 12px;
}

/* ─── Responsive ───────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 20px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .view-header { flex-direction: column; align-items: flex-start; gap: 12px; }
}
