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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #232637;
  --border: #2d3148;
  --accent: #4f8ef7;
  --accent2: #7c6af7;
  --green: #4ade80;
  --yellow: #facc15;
  --red: #f87171;
  --amber: #f59e0b;
  --text: #e2e8f0;
  --text2: #94a3b8;
  --text3: #475569;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

body {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Scrollbar ─────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
}
.btn:hover { opacity: .88; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-danger  { background: var(--red); color: #fff; }
.btn-ghost   { background: var(--surface2); color: var(--text); }
.btn-sm      { padding: 6px 12px; font-size: 12px; }

/* ── Input ─────────────────────────────────────────────────────────────── */
.input-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.input-group label { font-size: 13px; color: var(--text2); font-weight: 500; }
input, select, textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  width: 100%;
  transition: border-color .15s;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }

/* ── Card ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

/* ── Badge ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}
.badge-superadmin { background: rgba(124,106,247,.2); color: #a78bfa; }
.badge-operator   { background: rgba(79,142,247,.2);  color: #60a5fa; }
.badge-viewer     { background: rgba(148,163,184,.15); color: #94a3b8; }
.badge-online     { background: rgba(74,222,128,.15);  color: var(--green); }

/* ── Toast ─────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 9999;
}
.toast {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text);
  box-shadow: var(--shadow);
  animation: slideIn .2s ease;
  min-width: 260px;
  max-width: 360px;
}
.toast.success { border-color: var(--green); }
.toast.error   { border-color: var(--red); }
.toast.info    { border-color: var(--accent); }
@keyframes slideIn { from { opacity:0; transform: translateX(20px); } to { opacity:1; transform:none; } }

/* ── Modal ─────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  display: none;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  width: min(90vw, 440px);
  box-shadow: var(--shadow);
}
.modal-title {
  font-size: 16px; font-weight: 600;
  margin-bottom: 18px;
  display: flex; justify-content: space-between; align-items: center;
}
.modal-close {
  background: none; border: none; color: var(--text2);
  cursor: pointer; font-size: 20px; line-height: 1;
}

/* ── Topbar ────────────────────────────────────────────────────────────── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: 54px;
  background: rgba(15,17,23,.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 20px;
  gap: 12px;
  z-index: 100;
}
.topbar-logo {
  font-size: 15px; font-weight: 700;
  color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.topbar-logo i { color: var(--amber); font-size: 20px; }
.topbar-spacer { flex: 1; }
.topbar-user {
  font-size: 13px; color: var(--text2);
  display: flex; align-items: center; gap: 8px;
}
.topbar-user strong { color: var(--text); }

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