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

:root {
  --bg-primary: #000000;
  --bg-surface: #18181b;
  --bg-input: #111113;
  --bg-input-alt: #18181b;
  --border-subtle: rgba(255,255,255,0.04);
  --border-input: rgba(255,255,255,0.08);
  --accent: #5865F2;
  --accent-hover: #4752C4;
  --accent-glow: rgba(88,101,242,0.4);
  --green: #519644;
  --green-500: #22c55e;
  --red-400: #f87171;
  --red-300: #fca5a5;
  --red-500: #ef4444;
  --text-primary: #ffffff;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --text-faint: #52525b;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

::selection { background: var(--accent); color: #fff; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

.page-login, .page-callback, .page-auth-check {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
  overflow: hidden;
}

.card-body { padding: 32px; display: flex; flex-direction: column; align-items: center; }

.avatar-lg {
  width: 80px; height: 80px; border-radius: 50%; object-fit: cover;
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.3);
  border: 1px solid var(--border-subtle);
  margin-bottom: 32px;
}

.avatar-md {
  width: 64px; height: 64px; border-radius: 50%; object-fit: cover;
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.3);
  border: 1px solid var(--border-subtle);
  margin-bottom: 16px;
}

.card-title { font-size: 20px; font-weight: 700; color: #fff; margin-bottom: 8px; letter-spacing: -0.025em; text-align: center; }
.card-subtitle { font-size: 12px; font-weight: 500; color: var(--text-secondary); text-align: center; margin-bottom: 32px; }

.btn-discord {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  background: var(--accent); color: #fff; padding: 12px 16px; border-radius: var(--radius-md);
  font-size: 14px; font-weight: 500; border: none; cursor: pointer; text-decoration: none;
  transition: background 0.2s, box-shadow 0.2s, transform 0.1s;
}
.btn-discord:hover { background: var(--accent-hover); box-shadow: 0 4px 24px -4px var(--accent-glow); }
.btn-discord:active { transform: scale(0.98); }
.btn-discord svg { width: 20px; height: 20px; }

.card-footer {
  background: var(--bg-input); padding: 20px; text-align: center;
  border-top: 1px solid var(--border-subtle);
}
.card-footer p { font-size: 12px; font-weight: 500; color: var(--text-muted); cursor: pointer; }
.card-footer p:hover { color: var(--text-secondary); }

.spinner {
  width: 32px; height: 32px; border: 4px solid var(--accent); border-top-color: transparent;
  border-radius: 50%; animation: spin 0.8s linear infinite; margin-bottom: 16px;
}
.spinner-sm { width: 16px; height: 16px; border-width: 3px; }
.spinner-lg { width: 32px; height: 32px; border-width: 4px; }

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

.page-dashboard {
  min-height: 100vh; display: flex; padding: 16px;
}

.sidebar {
  width: 300px; background: var(--bg-surface); padding: 32px; border-radius: var(--radius-xl);
  border: 1px solid var(--border-subtle); box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
  display: flex; flex-direction: column; flex-shrink: 0;
}

.sidebar-header { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 32px; }
.sidebar-title { font-size: 24px; font-weight: 700; color: #fff; letter-spacing: -0.025em; }

.sidebar-nav { display: flex; flex-direction: column; gap: 8px; width: 100%; margin-bottom: auto; }

.nav-link {
  display: flex; align-items: center; gap: 12px; font-size: 14px; font-weight: 500;
  color: var(--text-secondary); padding: 12px 16px; border-radius: var(--radius-md);
  text-decoration: none; transition: background 0.15s, color 0.15s; border: none; background: none; cursor: pointer; width: 100%; text-align: left;
}
.nav-link:hover { background: rgba(255,255,255,0.04); color: #e4e4e7; }
.nav-link.active { background: rgba(255,255,255,0.08); color: #fff; }
.nav-link svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-separator { margin: 4px 8px; border-top: 1px solid var(--border-subtle); }

.sidebar-footer {
  margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--border-subtle); text-align: center;
}
.sidebar-footer p { font-size: 12px; font-weight: 500; color: var(--text-muted); }

.main-content {
  flex: 1; margin-left: 16px; background: var(--bg-surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl); box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
  overflow: hidden; display: flex; flex-direction: column; position: relative;
}

.page { display: none; flex-direction: column; height: 100%; background: var(--bg-surface); overflow: hidden; }
.page.active { display: flex; }
.page-center { flex: 1; display: flex; align-items: center; justify-content: center; text-align: center; padding: 32px; }
.page-center h2 { font-size: 24px; font-weight: 700; color: #fff; margin-bottom: 8px; }
.page-center p { color: var(--text-secondary); }

.page-header {
  display: flex; align-items: center; justify-content: space-between; padding: 24px;
  border-bottom: 1px solid var(--border-subtle);
}
.page-header h2 { font-size: 20px; font-weight: 700; color: #fff; letter-spacing: -0.025em; }
.page-header-actions { display: flex; align-items: center; gap: 12px; }

.page-body { flex: 1; overflow-y: auto; padding: 32px; }

.section-title { font-size: 18px; font-weight: 500; color: #fff; margin-bottom: 16px; }

.card-block {
  background: var(--bg-input); border: 1px solid var(--border-subtle); padding: 24px;
  border-radius: var(--radius-lg);
}

.form-group { margin-bottom: 24px; }
.form-group:last-child { margin-bottom: 0; }
.form-group > label { display: block; font-size: 14px; font-weight: 500; color: #d4d4d8; margin-bottom: 8px; }
.form-label-xs { font-size: 12px; font-weight: 500; color: #a1a1aa; margin-bottom: 6px; display: block; }

.form-input, .form-textarea, .form-select {
  width: 100%; background: var(--bg-input-alt); border: 1px solid var(--border-input);
  border-radius: var(--radius-md); padding: 8px 16px; color: #fff; font-size: 14px;
  font-family: var(--font); outline: none; transition: border-color 0.2s;
}
.form-input:focus, .form-textarea:focus, .form-select:focus { border-color: var(--accent); }
.form-input-lg, .form-select-lg { padding: 12px 16px; }
.form-textarea { resize: none; }
.form-select { appearance: none; cursor: pointer; }
.form-input-inline {
  background: transparent; border: none; color: #fff; font-weight: 500; font-size: 14px;
  outline: none; padding: 4px 8px; border-radius: 4px; flex: 1; font-family: var(--font);
}
.form-input-inline:focus { box-shadow: 0 0 0 1px var(--accent); }

.form-hint { font-size: 12px; color: var(--text-faint); margin-top: 6px; }

.color-row { display: flex; gap: 12px; }
.color-input { width: 40px; height: 40px; border-radius: 4px; cursor: pointer; background: transparent; border: none; padding: 0; }
.color-input + .form-input { flex: 1; }

.toggle-row { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.toggle-row span { font-size: 14px; font-weight: 500; color: #d4d4d8; }

.toggle { position: relative; width: 40px; height: 24px; flex-shrink: 0; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0; background: rgba(255,255,255,0.08); border-radius: 12px;
  transition: background 0.2s; cursor: pointer;
}
.toggle-track::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
  background: #fff; border-radius: 50%; border: 1px solid #d4d4d8; transition: transform 0.2s;
}
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle input:checked + .toggle-track::after { transform: translateX(16px); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 16px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500;
  border: 1px solid var(--border-subtle); cursor: pointer; transition: background 0.15s, color 0.15s;
  font-family: var(--font);
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; min-width: 140px; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary.is-saved { background: var(--green-500); border-color: var(--green-500); }
.btn-primary.is-error { background: var(--red-500); border-color: var(--red-500); }

.btn-ghost { background: rgba(255,255,255,0.04); color: #fff; }
.btn-ghost:hover { background: rgba(255,255,255,0.08); }

.btn-deploy { background: rgba(255,255,255,0.04); color: #fff; }
.btn-deploy:hover { background: rgba(255,255,255,0.08); }
.btn-deploy.is-done { background: rgba(34,197,94,0.2); color: #4ade80; border-color: rgba(34,197,94,0.3); }
.btn-deploy.is-error { background: rgba(239,68,68,0.2); color: #f87171; border-color: rgba(239,68,68,0.3); }

.btn-back { padding: 8px; color: var(--text-secondary); background: none; border: none; cursor: pointer; border-radius: var(--radius-sm); }
.btn-back:hover { color: #fff; background: rgba(255,255,255,0.04); }
.btn-back svg { width: 20px; height: 20px; }

.panel-list { border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); overflow: hidden; background: var(--bg-input); }
.panel-item {
  display: flex; align-items: center; justify-content: space-between; padding: 16px 24px;
  border-bottom: 1px solid var(--border-subtle); cursor: pointer; transition: background 0.15s;
}
.panel-item:last-child { border-bottom: none; }
.panel-item:hover { background: rgba(255,255,255,0.02); }
.panel-item-left { display: flex; align-items: center; gap: 16px; flex: 1; min-width: 0; }
.panel-color-bar { width: 6px; height: 48px; border-radius: 999px; flex-shrink: 0; }
.panel-item-info h3 { font-size: 14px; font-weight: 500; color: #fff; }
.panel-item-info p { font-size: 14px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 400px; }
.panel-item-info .deployed-badge { font-size: 12px; color: #4ade80; margin-top: 4px; }
.panel-item-actions { display: flex; gap: 8px; opacity: 0; transition: opacity 0.15s; }
.panel-item:hover .panel-item-actions { opacity: 1; }
.panel-item-actions button { padding: 8px; background: none; border: none; cursor: pointer; transition: color 0.15s; }
.panel-item-actions .btn-edit { color: var(--text-secondary); }
.panel-item-actions .btn-edit:hover { color: #fff; }
.panel-item-actions .btn-delete { color: var(--red-400); }
.panel-item-actions .btn-delete:hover { color: var(--red-300); }
.panel-item-actions svg { width: 16px; height: 16px; }

.empty-state { padding: 32px; text-align: center; color: var(--text-muted); font-size: 14px; }

.category-card {
  background: var(--bg-input); border: 1px solid var(--border-subtle); padding: 20px;
  border-radius: var(--radius-lg); margin-bottom: 16px; position: relative;
}
.category-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.category-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.category-delete { position: absolute; top: 16px; right: 16px; background: none; border: none; color: var(--red-400); cursor: pointer; opacity: 0; transition: opacity 0.15s; padding: 4px; }
.category-card:hover .category-delete { opacity: 1; }
.category-delete:hover { color: var(--red-300); }
.category-delete svg { width: 16px; height: 16px; }

.team-card {
  background: var(--bg-input); border: 1px solid var(--border-subtle); padding: 20px;
  border-radius: var(--radius-lg); margin-bottom: 16px; position: relative;
}
.team-fields { padding-right: 32px; }
.team-delete { position: absolute; top: 16px; right: 16px; background: none; border: none; color: var(--red-400); cursor: pointer; opacity: 0; transition: opacity 0.15s; padding: 4px; }
.team-card:hover .team-delete { opacity: 1; }
.team-delete:hover { color: var(--red-300); }
.team-delete svg { width: 16px; height: 16px; }

.section-divider { margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--border-subtle); }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-header h3 { font-size: 18px; font-weight: 500; color: #fff; }
.btn-add-category { font-size: 14px; color: var(--accent); background: none; border: none; cursor: pointer; font-weight: 500; font-family: var(--font); display: flex; align-items: center; gap: 4px; }
.btn-add-category:hover { color: var(--accent-hover); }
.btn-add-category svg { width: 16px; height: 16px; }

.hidden { display: none !important; }

.page-header-left { display: flex; align-items: center; gap: 16px; }

@media (max-width: 768px) {
  .page-dashboard { flex-direction: column; }
  .sidebar { width: 100%; }
  .main-content { margin-left: 0; margin-top: 16px; }
  .category-grid { grid-template-columns: 1fr; }
  .panel-item-info p { max-width: 200px; }
}
