:root {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --surface-muted: #f8f9fa;
  --text: #2c3e50;
  --text-muted: #6c757d;
  --border: #e9ecef;
  --shadow: rgba(0,0,0,0.05);
  --accent: #667eea;
  --accent-soft: #f0f2ff;
  --danger: #dc3545;
  --danger-hover: #c82333;
}

:root[data-theme="dark"] {
  --bg: #111827;
  --surface: #182233;
  --surface-muted: #223047;
  --text: #e5edf7;
  --text-muted: #9aa9bc;
  --border: #2c3b52;
  --shadow: rgba(0,0,0,0.28);
  --accent: #8ea0ff;
  --accent-soft: #263155;
  --danger: #e23d4f;
  --danger-hover: #f05262;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.18s ease, color 0.18s ease;
}
.navbar {
  background: var(--surface);
  box-shadow: 0 1px 8px var(--shadow);
  height: 64px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-brand { font-size: 20px; font-weight: 700; }
.nav-user { display: flex; align-items: center; gap: 16px; }
.user-level { background: var(--border); color: var(--text); padding: 4px 12px; border-radius: 20px; font-size: 12px; }
.logout-btn { background: var(--danger); color: white; text-decoration: none; padding: 6px 16px; border-radius: 8px; transition: 0.2s; }
.logout-btn:hover { background: var(--danger-hover); }

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text);
  border-radius: 999px;
  min-height: 34px;
  padding: 4px 10px 4px 5px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.theme-toggle-track {
  width: 36px;
  height: 22px;
  border-radius: 999px;
  background: #cfd7e3;
  padding: 2px;
  display: block;
  transition: background 0.18s ease;
}

.theme-toggle-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  display: block;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  transition: transform 0.18s ease;
}

:root[data-theme="dark"] .theme-toggle-track {
  background: var(--accent);
}

:root[data-theme="dark"] .theme-toggle-thumb {
  transform: translateX(14px);
}

.app-container { display: flex; min-height: calc(100vh - 64px); background: var(--bg); }
.sidebar { width: 260px; background: var(--surface); border-right: 1px solid var(--border); padding: 24px 0; }
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item { padding: 10px 24px; color: var(--text); text-decoration: none; display: flex; align-items: center; gap: 12px; transition: 0.2s; }
.nav-item:hover:not(.disabled) { background: var(--surface-muted); color: var(--accent); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); border-right: 3px solid var(--accent); }
.nav-item.disabled { opacity: 0.5; cursor: not-allowed; }
.nav-badge { background: var(--border); color: var(--text-muted); font-size: 10px; padding: 2px 6px; border-radius: 20px; margin-left: auto; }

.main-content { flex: 1; padding: 32px; background: var(--bg); }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.page-header h1 { font-size: 28px; font-weight: 600; }

.users-table-container { background: var(--surface); border-radius: 12px; overflow-x: auto; }
.users-table { width: 100%; border-collapse: collapse; }
.users-table th, .users-table td { padding: 14px 20px; text-align: left; border-bottom: 1px solid var(--border); }
.users-table th { background: var(--surface-muted); font-weight: 600; }
.user-id { font-family: monospace; color: var(--text-muted); }
.vk-link { color: #2787f5; text-decoration: none; }
.level-badge { display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: 12px; }
.level-1 { background: #e9ecef; }
.level-2 { background: #d4edda; color: #155724; }
.level-3 { background: #cce5ff; color: #004085; }
.level-4 { background: #fff3cd; color: #856404; }
.level-5 { background: #f8d7da; color: #721c24; }

.login-container { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.login-card { background: white; border-radius: 24px; padding: 40px; width: 100%; max-width: 400px; text-align: center; }
.login-icon { font-size: 48px; margin-bottom: 16px; }
.login-header h1 { font-size: 28px; margin-bottom: 8px; }
.error-message { background: #fee; border-radius: 8px; padding: 10px; margin-bottom: 20px; color: #c33; }
.vk-id-loading { color: #6c757d; padding: 20px; }

@media (max-width: 768px) {
  .sidebar { width: 72px; }
  .nav-item span:not(.nav-icon) { display: none; }
  .main-content { padding: 20px; }
  .theme-toggle [data-theme-label] { display: none; }
  .nav-user { gap: 8px; }
}
