:root {
  --bg-primary: #0a0d14;
  --bg-secondary: #111622;
  --bg-card: #161c2c;
  --bg-card-hover: #1c2438;
  --bg-glass: rgba(22, 28, 44, 0.75);
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #3b82f6;
  
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-glow: rgba(59, 130, 246, 0.35);
  
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.35);
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.35);
  --warning: #f59e0b;
  --warning-glow: rgba(245, 158, 11, 0.35);
  --purple: #8b5cf6;
  
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-main: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-family);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover {
  color: #60a5fa;
}

/* Navbar */
.navbar {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 1000;
  padding: 0.75rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.02em;
}

.nav-logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px var(--primary-glow);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.nav-link {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}
.nav-link:hover, .nav-link.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.05);
}

.badge-admin {
  background: linear-gradient(135deg, #ec4899, #8b5cf6);
  color: #ffffff;
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: 9999px;
  font-weight: 700;
  text-transform: uppercase;
}

/* Layout */
.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem;
  flex: 1;
}

/* Flash Messages */
.flash-container {
  margin-bottom: 1.5rem;
}
.alert {
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid transparent;
  animation: slideDown 0.25s ease-out;
}
.alert-success {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.3);
  color: #34d399;
}
.alert-danger {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.3);
  color: #f87171;
}
.alert-info {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.3);
  color: #60a5fa;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Cards & Grid */
.grid {
  display: grid;
  gap: 1.5rem;
}
.grid-cols-4 {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.grid-cols-2 {
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.card:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.stat-title {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 0.05em;
}
.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: #ffffff;
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.badge-running {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.badge-running .badge-dot {
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: pulseGlow 1.5s infinite;
}
.badge-stopped, .badge-uploaded {
  background: rgba(148, 163, 184, 0.12);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.2);
}
.badge-stopped .badge-dot, .badge-uploaded .badge-dot {
  background: #94a3b8;
}
.badge-failed, .badge-crashed {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.badge-failed .badge-dot, .badge-crashed .badge-dot {
  background: #ef4444;
  box-shadow: 0 0 8px #ef4444;
}
.badge-restarting, .badge-starting, .badge-installing, .badge-validating {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.badge-restarting .badge-dot, .badge-starting .badge-dot {
  background: #f59e0b;
  animation: pulseGlow 1s infinite;
}

@keyframes pulseGlow {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.3); }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.55rem 1.1rem;
  font-size: 0.88rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}
.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 10px var(--primary-glow);
}
.btn-primary:hover {
  background: var(--primary-hover);
  color: #ffffff;
  transform: translateY(-1px);
}
.btn-secondary {
  background: var(--bg-card);
  border-color: var(--border-color);
  color: var(--text-main);
}
.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.2);
}
.btn-success {
  background: var(--success);
  color: #ffffff;
  box-shadow: 0 2px 10px var(--success-glow);
}
.btn-success:hover {
  background: #059669;
}
.btn-danger {
  background: var(--danger);
  color: #ffffff;
  box-shadow: 0 2px 10px var(--danger-glow);
}
.btn-danger:hover {
  background: #dc2626;
}
.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}
.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}
.form-control {
  width: 100%;
  padding: 0.65rem 0.9rem;
  background: #0d121c;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: #ffffff;
  font-size: 0.92rem;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}
.form-text {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 0.35rem;
}

/* Tables */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
}
.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}
.table th {
  background: #111726;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
}
.table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  background: var(--bg-card);
}
.table tr:last-child td {
  border-bottom: none;
}
.table tr:hover td {
  background: var(--bg-card-hover);
}

/* Bot Tabs */
.tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
  overflow-x: auto;
}
.tab-link {
  padding: 0.75rem 1.25rem;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
}
.tab-link:hover {
  color: #ffffff;
}
.tab-link.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* Terminal & Logs */
.terminal-window {
  background: #050811;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: 'JetBrains Mono', Consolas, Monaco, monospace;
  font-size: 0.85rem;
  overflow: hidden;
}
.terminal-header {
  background: #0d121c;
  padding: 0.5rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}
.terminal-body {
  padding: 1rem;
  height: 480px;
  overflow-y: auto;
  line-height: 1.6;
}
.log-line {
  white-space: pre-wrap;
  word-break: break-all;
}
.log-stdout {
  color: #e2e8f0;
}
.log-stderr {
  color: #f87171;
}
.log-system {
  color: #60a5fa;
  font-weight: 600;
}

/* Code Editor */
.editor-textarea {
  width: 100%;
  height: 420px;
  background: #050811;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: #f1f5f9;
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 0.9rem;
  padding: 1rem;
  line-height: 1.5;
  resize: vertical;
}
.editor-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.active {
  display: flex;
}
.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  padding: 1.75rem;
  box-shadow: var(--shadow-main);
  animation: zoomIn 0.2s ease-out;
}
@keyframes zoomIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* Footer */
.footer {
  border-top: 1px solid var(--border-color);
  padding: 1.25rem 2rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-dim);
}
