* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg-primary: #36393f;
  --bg-secondary: #2f3136;
  --bg-tertiary: #202225;
  --bg-card: #292b2f;
  --text-primary: #dcddde;
  --text-secondary: #8e9297;
  --text-muted: #72767d;
  --blurple: #5865f2;
  --blurple-hover: #4752c4;
  --green: #3ba55d;
  --red: #ed4245;
  --yellow: #faa81a;
  --border: #3e4147;
  --input-bg: #40444b;
  --scrollbar: #202225;
  --scrollbar-thumb: #4f545c;
  --sidebar-width: 240px;
}

body {
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
}

a { color: var(--blurple); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--scrollbar); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 4px; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  height: 100vh;
  position: fixed;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--bg-tertiary);
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--bg-tertiary);
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-header img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.sidebar-nav { flex: 1; padding: 8px; overflow-y: auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin: 2px 0;
  border-radius: 4px;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
}

.nav-item:hover { background: rgba(79,84,92,0.3); color: var(--text-primary); text-decoration: none; }
.nav-item.active { background: rgba(88,101,242,0.2); color: #fff; }
.nav-item .icon { font-size: 18px; width: 24px; text-align: center; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
}

.sidebar-footer .user-info { display: flex; align-items: center; gap: 8px; }
.sidebar-footer img { width: 24px; height: 24px; border-radius: 50%; }

/* Main Content */
.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 24px 32px;
  min-height: 100vh;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-header h1 { font-size: 24px; font-weight: 700; color: #fff; }

/* Cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.card {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 20px;
  border: 1px solid var(--border);
}

.card-label { font-size: 12px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 6px; font-weight: 700; }
.card-value { font-size: 28px; font-weight: 700; color: #fff; }
.card-value.online { color: var(--green); }
.card-value.offline { color: var(--red); }

/* Tables */
.table-wrap {
  background: var(--bg-card);
  border-radius: 8px;
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 24px;
}

table { width: 100%; border-collapse: collapse; }

th {
  text-align: left;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
}

td {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 14px;
}

tr:hover { background: rgba(79,84,92,0.16); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 4px;
  border: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  color: #fff;
}

.btn-primary { background: var(--blurple); }
.btn-primary:hover { background: var(--blurple-hover); }
.btn-danger { background: var(--red); }
.btn-danger:hover { background: #c03537; }
.btn-success { background: var(--green); }
.btn-success:hover { background: #2d8049; }
.btn-secondary { background: var(--input-bg); color: var(--text-primary); }
.btn-secondary:hover { background: #4f545c; }
.btn-sm { padding: 4px 10px; font-size: 13px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 6px; font-weight: 700; }

input[type="text"], input[type="number"], input[type="search"], textarea, select {
  width: 100%;
  padding: 10px 12px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}

input:focus, textarea:focus, select:focus { border-color: var(--blurple); }
textarea { resize: vertical; min-height: 80px; }

/* Tags/Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
}

.badge-green { background: rgba(59,165,93,0.2); color: var(--green); }
.badge-red { background: rgba(237,66,69,0.2); color: var(--red); }
.badge-blurple { background: rgba(88,101,242,0.2); color: var(--blurple); }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  justify-content: center;
  align-items: center;
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 24px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal h2 { margin-bottom: 16px; font-size: 20px; color: #fff; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* Tabs */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 2px solid var(--border); }
.tab {
  padding: 10px 16px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
}

.tab:hover { color: var(--text-primary); }
.tab.active { color: #fff; border-bottom-color: var(--blurple); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Toggle switch */
.toggle { position: relative; display: inline-block; width: 40px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--input-bg);
  border-radius: 11px;
  transition: 0.2s;
}

.toggle-slider:before {
  content: '';
  position: absolute;
  height: 16px; width: 16px;
  left: 3px; bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
}

.toggle input:checked + .toggle-slider { background: var(--green); }
.toggle input:checked + .toggle-slider:before { transform: translateX(18px); }

/* Log viewer */
.log-viewer {
  background: var(--bg-tertiary);
  border-radius: 8px;
  padding: 16px;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 13px;
  line-height: 1.6;
  max-height: 600px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.log-line { padding: 2px 0; border-bottom: 1px solid rgba(255,255,255,0.04); }
.log-error { color: var(--red); }
.log-info { color: var(--text-secondary); }

/* Login page */
.login-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  width: 100%;
  background: var(--bg-tertiary);
}

.login-box {
  background: var(--bg-secondary);
  padding: 32px;
  border-radius: 8px;
  text-align: center;
  width: 400px;
}

.login-box h1 { margin-bottom: 8px; font-size: 24px; color: #fff; }
.login-box p { color: var(--text-secondary); margin-bottom: 24px; font-size: 14px; }
.login-box .btn { width: 100%; justify-content: center; padding: 12px; font-size: 16px; }

/* Status indicator */
.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
}

.status-dot.online { background: var(--green); }
.status-dot.offline { background: var(--red); }

/* JSON viewer */
.json-tree { font-family: monospace; font-size: 13px; }
.json-key { color: var(--blurple); }
.json-string { color: var(--green); }
.json-number { color: var(--yellow); }

/* Actions list */
.action-item {
  background: var(--bg-tertiary);
  border-radius: 4px;
  padding: 10px 14px;
  margin: 6px 0;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.action-item .action-type {
  background: var(--blurple);
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: 6px;
  color: #fff;
  font-size: 14px;
  z-index: 200;
  animation: slideIn 0.3s ease;
}

.toast-success { background: var(--green); }
.toast-error { background: var(--red); }

@keyframes slideIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar .nav-label, .sidebar-header span, .sidebar-footer .user-info span { display: none; }
  .main { margin-left: 60px; padding: 16px; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
