/* ─── Server Controller UI ─────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;600;700&family=Space+Grotesk:wght@300;400;500;600;700&display=swap');

:root {
  --bg-base: #0a0c0f;
  --bg-surface: #111318;
  --bg-card: #161a21;
  --bg-hover: #1c2130;
  --border: #1f2535;
  --border-bright: #2a3550;

  --accent: #00d4ff;
  --accent-dim: rgba(0, 212, 255, 0.12);
  --accent-glow: rgba(0, 212, 255, 0.35);
  --green: #00ff88;
  --green-dim: rgba(0, 255, 136, 0.12);
  --red: #ff4d6a;
  --red-dim: rgba(255, 77, 106, 0.12);
  --yellow: #ffd60a;
  --yellow-dim: rgba(255, 214, 10, 0.12);
  --purple: #9d4edd;

  --text-primary: #e8ecf4;
  --text-secondary: #7a8499;
  --text-dim: #4a5268;
  --text-code: #00ff88;

  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
  --font-sans: 'Space Grotesk', sans-serif;

  --radius: 6px;
  --radius-lg: 10px;
  --transition: 0.18s ease;
  --shadow: 0 4px 20px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 20px var(--accent-glow);
}

/* ─── Reset ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
button { cursor: pointer; font-family: var(--font-sans); }
input, select, textarea { font-family: var(--font-sans); }
code, pre { font-family: var(--font-mono); }

/* ─── Layout ─────────────────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

/* ─── Topbar ─────────────────────────────────────────────────────────── */
.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  height: 56px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.05em;
}
.topbar-logo .logo-icon {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 14px;
}
.topbar-logo span { color: var(--accent); }

.topbar-spacer { flex: 1; }

.topbar-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  cursor: pointer;
  transition: var(--transition);
}
.topbar-user:hover { border-color: var(--border-bright); color: var(--text-primary); }

.btn-logout {
  background: none;
  border: 1px solid var(--red-dim);
  color: var(--red);
  padding: 5px 12px;
  border-radius: var(--radius);
  font-size: 11px;
  font-family: var(--font-mono);
  transition: var(--transition);
}
.btn-logout:hover { background: var(--red-dim); }

/* ─── Sidebar ────────────────────────────────────────────────────────── */
.sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  padding: 16px 0;
  overflow-y: auto;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
}

.sidebar-section {
  padding: 0 12px;
  margin-bottom: 8px;
}
.sidebar-label {
  font-size: 9px;
  font-family: var(--font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 8px 12px 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
  border: 1px solid transparent;
  position: relative;
}
.nav-link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border);
}
.nav-link.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: rgba(0, 212, 255, 0.2);
}
.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 60%;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.nav-icon { font-size: 15px; width: 20px; text-align: center; }

/* ─── Main Content ───────────────────────────────────────────────────── */
.main {
  overflow-y: auto;
  padding: 24px;
}

/* ─── Page Header ────────────────────────────────────────────────────── */
.page-header {
  margin-bottom: 24px;
}
.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.page-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
  font-family: var(--font-mono);
}

/* ─── Cards & Grid ───────────────────────────────────────────────────── */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: var(--transition);
}
.card:hover { border-color: var(--border-bright); }
.card-title {
  font-size: 11px;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 12px;
}

/* ─── Stat Cards ─────────────────────────────────────────────────────── */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  opacity: 0.06;
}
.stat-card.blue::after { background: var(--accent); box-shadow: 0 0 40px var(--accent); }
.stat-card.green::after { background: var(--green); box-shadow: 0 0 40px var(--green); }
.stat-card.red::after { background: var(--red); box-shadow: 0 0 40px var(--red); }
.stat-card.yellow::after { background: var(--yellow); box-shadow: 0 0 40px var(--yellow); }

.stat-label {
  font-size: 10px;
  font-family: var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.stat-value {
  font-size: 28px;
  font-weight: 700;
  font-family: var(--font-mono);
  line-height: 1;
  margin-bottom: 4px;
}
.stat-value.blue { color: var(--accent); }
.stat-value.green { color: var(--green); }
.stat-value.red { color: var(--red); }
.stat-value.yellow { color: var(--yellow); }
.stat-sub {
  font-size: 11px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

/* ─── Progress Bar ───────────────────────────────────────────────────── */
.progress-wrap {
  margin-top: 12px;
}
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.6s ease;
}
.progress-fill.blue { background: var(--accent); }
.progress-fill.green { background: var(--green); }
.progress-fill.red { background: var(--red); }
.progress-fill.yellow { background: var(--yellow); }

/* ─── Buttons ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  border: none;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-sans);
  transition: var(--transition);
  cursor: pointer;
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #000; }
.btn-primary:hover { opacity: 0.85; box-shadow: var(--shadow-glow); }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.btn-ghost:hover { border-color: var(--border-bright); color: var(--text-primary); background: var(--bg-hover); }
.btn-success { background: var(--green-dim); border: 1px solid rgba(0,255,136,0.3); color: var(--green); }
.btn-success:hover { background: rgba(0,255,136,0.2); }
.btn-danger { background: var(--red-dim); border: 1px solid rgba(255,77,106,0.3); color: var(--red); }
.btn-danger:hover { background: rgba(255,77,106,0.2); }
.btn-warning { background: var(--yellow-dim); border: 1px solid rgba(255,214,10,0.3); color: var(--yellow); }
.btn-warning:hover { background: rgba(255,214,10,0.2); }
.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-icon { padding: 7px; width: 32px; height: 32px; justify-content: center; }

/* ─── Badges ─────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0.05em;
}
.badge-green { background: var(--green-dim); color: var(--green); border: 1px solid rgba(0,255,136,0.2); }
.badge-red { background: var(--red-dim); color: var(--red); border: 1px solid rgba(255,77,106,0.2); }
.badge-yellow { background: var(--yellow-dim); color: var(--yellow); border: 1px solid rgba(255,214,10,0.2); }
.badge-gray { background: rgba(122,132,153,0.15); color: var(--text-secondary); border: 1px solid rgba(122,132,153,0.2); }
.badge-blue { background: var(--accent-dim); color: var(--accent); border: 1px solid rgba(0,212,255,0.2); }

/* ─── Tables ─────────────────────────────────────────────────────────── */
.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--bg-surface);
  padding: 10px 16px;
  text-align: left;
  font-size: 10px;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }
td { padding: 10px 16px; font-size: 12px; color: var(--text-secondary); }
td.mono { font-family: var(--font-mono); font-size: 11px; }
td.primary { color: var(--text-primary); font-weight: 500; }

/* ─── Form Elements ──────────────────────────────────────────────────── */
.input {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  width: 100%;
  transition: var(--transition);
  outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.input::placeholder { color: var(--text-dim); }

/* ─── Toast Notifications ────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 12px;
  font-family: var(--font-mono);
  backdrop-filter: blur(8px);
  animation: toast-in 0.2s ease;
  min-width: 280px;
  max-width: 400px;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
.toast-success { background: rgba(0,255,136,0.15); border: 1px solid rgba(0,255,136,0.3); color: var(--green); }
.toast-error { background: rgba(255,77,106,0.15); border: 1px solid rgba(255,77,106,0.3); color: var(--red); }
.toast-info { background: rgba(0,212,255,0.15); border: 1px solid rgba(0,212,255,0.3); color: var(--accent); }

/* ─── Modal ──────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade-in 0.15s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-lg);
  padding: 24px;
  min-width: 340px;
  max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  animation: modal-in 0.2s ease;
}
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.96) translateY(-10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text-primary);
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

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

/* ─── Context Menu ───────────────────────────────────────────────────── */
.ctx-menu {
  position: fixed;
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  padding: 4px;
  z-index: 2000;
  min-width: 160px;
  box-shadow: var(--shadow);
  animation: fade-in 0.1s ease;
}
.ctx-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}
.ctx-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.ctx-item.danger { color: var(--red); }
.ctx-item.danger:hover { background: var(--red-dim); }
.ctx-separator { height: 1px; background: var(--border); margin: 4px 0; }

/* ─── Scrollbar ──────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ─── Login Page ─────────────────────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-base);
  position: relative;
  overflow: hidden;
}
.login-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(0,212,255,0.05) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(157,78,221,0.05) 0%, transparent 60%);
}
.login-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(0,212,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,212,255,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
}
.login-box {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  border-radius: 12px;
  padding: 40px;
  width: 380px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6), 0 0 0 1px rgba(0,212,255,0.05);
}
.login-logo {
  text-align: center;
  margin-bottom: 32px;
}
.login-logo-icon {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 24px;
  margin: 0 auto 12px;
  box-shadow: 0 0 30px var(--accent-glow);
}
.login-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.login-sub {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  margin-top: 4px;
}
.login-form { display: flex; flex-direction: column; gap: 14px; }
.form-label { font-size: 11px; color: var(--text-secondary); font-family: var(--font-mono); margin-bottom: 6px; display: block; letter-spacing: 0.06em; }
.login-error {
  background: var(--red-dim);
  border: 1px solid rgba(255,77,106,0.3);
  color: var(--red);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 12px;
  font-family: var(--font-mono);
  display: none;
}
.login-error.show { display: block; }
.btn-login {
  background: var(--accent);
  color: #000;
  border: none;
  padding: 11px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: var(--transition);
  margin-top: 4px;
}
.btn-login:hover { opacity: 0.85; box-shadow: var(--shadow-glow); }
.btn-login:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
  }
  .sidebar {
    position: fixed;
    left: -220px;
    top: 56px;
    height: calc(100vh - 56px);
    z-index: 200;
    transition: left 0.25s ease;
    width: 220px;
  }
  .sidebar.open { left: 0; }
  .main { padding: 16px; }
  .topbar { padding: 0 16px; }
  .btn-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 34px;
    height: 34px;
    border-radius: var(--radius);
    font-size: 16px;
  }
}
@media (min-width: 769px) {
  .btn-menu-toggle { display: none; }
}

/* ─── Utility ─────────────────────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-mono { font-family: var(--font-mono); }
.text-dim { color: var(--text-dim); }
.text-secondary { color: var(--text-secondary); }
.text-accent { color: var(--accent); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
