@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&family=Syne:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #0a0a0f;
  --bg-2: #111118;
  --bg-3: #18181f;
  --border: #2a2a38;
  --border-2: #3a3a50;
  --text: #e8e8f0;
  --text-muted: #8888a8;
  --text-faint: #444460;
  --accent: #7c6af7;
  --accent-2: #5b4de0;
  --accent-glow: rgba(124, 106, 247, 0.15);
  --green: #3ecf8e;
  --green-bg: rgba(62, 207, 142, 0.08);
  --red: #f96464;
  --red-bg: rgba(249, 100, 100, 0.08);
  --yellow: #f5c542;
  --yellow-bg: rgba(245, 197, 66, 0.08);
  --radius: 10px;
  --radius-sm: 6px;
  --font-display: 'Syne', sans-serif;
  --font-mono: 'Space Mono', monospace;
}

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

html { font-size: 14px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-display);
  min-height: 100vh;
  line-height: 1.5;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-2); }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* Layout */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  min-height: 100vh;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

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

.sidebar-logo .logo-mark {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo .logo-icon {
  width: 34px;
  height: 34px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.sidebar-logo .logo-text {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.3px;
}

.sidebar-logo .logo-sub {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-top: 2px;
  letter-spacing: 0.5px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-label {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-faint);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 10px 8px 6px;
  font-family: var(--font-mono);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-link:hover { background: var(--bg-3); color: var(--text); }
.nav-link.active { background: var(--accent-glow); color: var(--accent); }
.nav-link .nav-icon { font-size: 15px; width: 18px; text-align: center; }

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border);
}

.main {
  margin-left: 220px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: 56px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}

.topbar-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--accent-glow);
  color: var(--accent);
  font-family: var(--font-mono);
  font-weight: 700;
}

.content { padding: 28px; flex: 1; }

/* Cards */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

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

.card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body { padding: 20px; }

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
}

.stat-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-family: var(--font-mono);
}

.stat-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
  margin-top: 6px;
}

.stat-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-display);
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); transform: translateY(-1px); }
.btn-secondary { background: var(--bg-3); color: var(--text); border: 1px solid var(--border-2); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-success { background: var(--green-bg); color: var(--green); border: 1px solid rgba(62,207,142,0.2); }
.btn-success:hover { background: rgba(62,207,142,0.15); }
.btn-danger { background: var(--red-bg); color: var(--red); border: 1px solid rgba(249,100,100,0.2); }
.btn-danger:hover { background: rgba(249,100,100,0.15); }
.btn-warning { background: var(--yellow-bg); color: var(--yellow); border: 1px solid rgba(245,197,66,0.2); }
.btn-warning:hover { background: rgba(245,197,66,0.15); }
.btn-sm { padding: 5px 10px; font-size: 11px; }
.btn-icon { padding: 7px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-active, .badge-online { background: var(--green-bg); color: var(--green); }
.badge-inactive, .badge-stopped { background: var(--bg-3); color: var(--text-muted); border: 1px solid var(--border); }
.badge-expired, .badge-errored { background: var(--red-bg); color: var(--red); }

.badge-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.badge-active .badge-dot, .badge-online .badge-dot { animation: pulse 2s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-faint);
  letter-spacing: 1px;
  text-transform: uppercase;
  font-family: var(--font-mono);
  border-bottom: 1px solid var(--border);
  background: var(--bg-3);
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-3); }

tbody td {
  padding: 12px 16px;
  color: var(--text);
  vertical-align: middle;
}

.mono { font-family: var(--font-mono); }

/* Forms */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 6px;
  font-family: var(--font-mono);
}

.form-input, .form-select {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font-display);
  outline: none;
  transition: border-color 0.15s;
}

.form-input:focus, .form-select:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--text-faint); }
.form-select option { background: var(--bg-3); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}

.modal-overlay.open { opacity: 1; visibility: visible; }

.modal {
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: 14px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: transform 0.2s;
}

.modal-overlay.open .modal { transform: scale(1) translateY(0); }

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

.modal-title { font-size: 15px; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 20px;
  padding: 0;
  line-height: 1;
  transition: color 0.15s;
}

.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* Toast */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  max-width: 300px;
  animation: slideIn 0.2s ease;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast-success { background: var(--green-bg); border: 1px solid rgba(62,207,142,0.3); color: var(--green); }
.toast-error { background: var(--red-bg); border: 1px solid rgba(249,100,100,0.3); color: var(--red); }
.toast-info { background: var(--accent-glow); border: 1px solid rgba(124,106,247,0.3); color: var(--accent); }

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

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.4; }
.empty-title { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.empty-sub { font-size: 12px; }

/* Loading */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 12px;
  gap: 8px;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Code block for credentials */
.cred-box {
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--green);
}

.cred-row { display: flex; justify-content: space-between; margin-bottom: 6px; }
.cred-row:last-child { margin-bottom: 0; }
.cred-key { color: var(--text-muted); }

/* Action group */
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Page header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-title { font-size: 20px; font-weight: 800; color: var(--text); }
.page-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
