:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2e3350;
  --primary: #3b6ff5;
  --primary-hover: #2d5ce8;
  --danger: #e05252;
  --danger-hover: #c83c3c;
  --text: #e8eaf6;
  --text-muted: #8b90b0;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

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

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

/* ── Login ── */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0f1117 60%, #1a1f3a);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 40px;
  width: 380px;
  box-shadow: var(--shadow);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.login-logo p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 4px;
}

/* ── Layout ── */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ── */
.sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo span {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
}

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

.sidebar-nav { padding: 12px 0; flex: 1; }

.nav-section {
  padding: 8px 16px 4px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  border-left: 3px solid transparent;
  transition: all 0.15s;
  user-select: none;
}

.nav-item:hover { background: var(--surface2); color: var(--text); }

.nav-item.active {
  background: rgba(59,111,245,0.12);
  color: var(--primary);
  border-left-color: var(--primary);
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

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

.user-info { display: flex; align-items: center; gap: 10px; }

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.user-name { font-size: 0.85rem; font-weight: 600; }
.user-email { font-size: 0.72rem; color: var(--text-muted); }

.btn-logout {
  margin-top: 10px;
  width: 100%;
  padding: 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.15s;
}

.btn-logout:hover { background: var(--danger); border-color: var(--danger); color: #fff; }

/* ── Main content ── */
.main { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }

.topbar {
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h2 { font-size: 1.1rem; font-weight: 600; }
.topbar p { font-size: 0.82rem; color: var(--text-muted); margin-top: 2px; }

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

/* ── Cards grid ── */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow); }

.card-icon {
  width: 40px;
  height: 40px;
  background: rgba(59,111,245,0.15);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.card-icon svg { width: 22px; height: 22px; color: var(--primary); }

.card-title { font-weight: 600; font-size: 0.95rem; }
.card-meta { font-size: 0.78rem; color: var(--text-muted); }

/* ── Table ── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

table { width: 100%; border-collapse: collapse; }

th {
  background: var(--surface2);
  padding: 12px 16px;
  text-align: left;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

td { padding: 12px 16px; font-size: 0.88rem; border-top: 1px solid var(--border); }

tr:hover td { background: var(--surface2); }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
}

.badge-admin { background: rgba(59,111,245,0.2); color: #7a9ef8; }
.badge-user { background: rgba(139,144,176,0.15); color: var(--text-muted); }
.badge-active { background: rgba(52,199,89,0.15); color: #34c759; }
.badge-inactive { background: rgba(224,82,82,0.15); color: #e05252; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  border: none;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.btn-ghost:hover { border-color: var(--text-muted); color: var(--text); }

.btn-sm { padding: 5px 10px; font-size: 0.78rem; }

/* ── Forms ── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }

label { font-size: 0.82rem; color: var(--text-muted); }

input, select, textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
  font-family: inherit;
}

input:focus, select:focus, textarea:focus { border-color: var(--primary); }

select option { background: var(--surface2); }

textarea { resize: vertical; min-height: 80px; }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow);
  max-height: 90vh;
  overflow-y: auto;
}

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

.modal-header h3 { font-size: 1rem; }

.modal-body { padding: 24px; }

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

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

.btn-close:hover { color: var(--text); }

/* ── Panel view (iframe) ── */
.panel-view {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 200;
  display: flex;
  flex-direction: column;
}

.panel-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-topbar h3 { font-size: 0.95rem; font-weight: 600; flex: 1; }

.panel-iframe-wrap { flex: 1; position: relative; overflow: hidden; }

.panel-iframe-wrap iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* ── Checkbox list ── */
.check-list {
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
}

.check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}

.check-item:last-child { border-bottom: none; }
.check-item:hover { background: var(--surface); }

.check-item input[type=checkbox] { accent-color: var(--primary); width: 15px; height: 15px; }

.check-workspace-label {
  padding: 6px 14px 4px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

/* ── Stats ── */
.stats { display: flex; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 24px;
  flex: 1;
  min-width: 140px;
}

.stat-value { font-size: 1.8rem; font-weight: 700; }
.stat-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }

/* ── Alerts ── */
.alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.alert-error { background: rgba(224,82,82,0.1); border: 1px solid rgba(224,82,82,0.3); color: #f08080; }
.alert-success { background: rgba(52,199,89,0.1); border: 1px solid rgba(52,199,89,0.3); color: #52d97a; }

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

.empty svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty p { font-size: 0.9rem; }

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

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { width: 60px; min-width: 60px; }
  .sidebar-logo span, .nav-item span, .user-name, .user-email, .btn-logout, .nav-section { display: none; }
  .nav-item { padding: 12px; justify-content: center; }
  .content { padding: 16px; }
  .topbar { padding: 14px 16px; }
}
