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

:root {
  --bg:       #080808;
  --bg2:      #0e0e0e;
  --bg3:      #141414;
  --bg4:      #1a1a1a;
  --border:   rgba(255,255,255,0.06);
  --border2:  rgba(255,165,60,0.18);
  --text:     #f0ede8;
  --muted:    #504840;
  --muted2:   #9a8878;
  --accent:   #d4621a;
  --accent-g: linear-gradient(135deg, #e8721a, #a84010);
  --success:  #4aff8a;
  --error:    #ff4a4a;
  --warning:  #ffaa4a;
}

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ============================================================
   VIEWS — only one visible at a time
   ============================================================ */
.view { display: none; }
.view.active { display: block; }

/* ============================================================
   AUTH PAGES (login + register)
   ============================================================ */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.auth-page::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 50% 0%, rgba(212,98,26,0.08), transparent),
    radial-gradient(ellipse 40% 40% at 80% 80%, rgba(212,98,26,0.04), transparent);
  pointer-events: none;
}

.auth-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, black, transparent);
  pointer-events: none;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 16px;
  padding: 44px;
  position: relative;
  animation: fadeUp 0.4s ease both;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
  text-decoration: none;
}

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

.auth-logo-text {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 18px;
  color: var(--text);
  letter-spacing: -0.5px;
}

.auth-title {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 24px;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}

.auth-sub {
  color: var(--muted2);
  font-size: 13px;
  margin-bottom: 32px;
  font-weight: 300;
}

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted2);
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(212,98,26,0.1);
}

.form-input::placeholder { color: var(--muted); }

.btn {
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  padding: 12px 24px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  letter-spacing: 0.3px;
  font-weight: 500;
}

.btn-primary {
  background: var(--accent-g);
  color: #fff;
  width: 100%;
  box-shadow: 0 4px 20px rgba(212,98,26,0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 28px rgba(212,98,26,0.45);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--muted2);
}

.btn-ghost:hover {
  border-color: rgba(255,255,255,0.2);
  color: var(--text);
}

.btn-danger {
  background: rgba(255,74,74,0.1);
  border: 1px solid rgba(255,74,74,0.3);
  color: var(--error);
}

.btn-danger:hover {
  background: rgba(255,74,74,0.2);
}

.auth-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 12px;
  color: var(--muted2);
}

.auth-footer a {
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
}

.auth-footer a:hover { text-decoration: underline; }

/* Alert messages */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 12px;
  margin-bottom: 20px;
  display: none;
}

.alert.show { display: block; }

.alert-error {
  background: rgba(255,74,74,0.1);
  border: 1px solid rgba(255,74,74,0.3);
  color: var(--error);
}

.alert-success {
  background: rgba(74,255,138,0.1);
  border: 1px solid rgba(74,255,138,0.3);
  color: var(--success);
}

/* ============================================================
   DASHBOARD LAYOUT
   ============================================================ */
.dashboard {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 240px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 10;
}

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

.sidebar-logo-icon {
  width: 28px; height: 28px;
  background: var(--accent-g);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.3px;
}

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

.nav-section-label {
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 20px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--muted2);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 13px;
  border-left: 2px solid transparent;
  user-select: none;
}

.nav-item:hover {
  color: var(--text);
  background: rgba(255,255,255,0.03);
}

.nav-item.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(212,98,26,0.06);
}

.nav-icon { font-size: 15px; width: 18px; text-align: center; }

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

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

.user-avatar {
  width: 32px; height: 32px;
  background: var(--accent-g);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.user-plan {
  font-size: 10px;
  color: var(--accent);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.btn-logout {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted2);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-logout:hover {
  border-color: var(--error);
  color: var(--error);
}

/* Main content */
.main {
  margin-left: 240px;
  flex: 1;
  padding: 32px 40px;
  max-width: calc(100vw - 240px);
}

.page-header {
  margin-bottom: 32px;
}

.page-title {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 24px;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.page-sub {
  color: var(--muted2);
  font-size: 13px;
  font-weight: 300;
}

/* Cards */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
}

.card-title {
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title-icon {
  font-size: 16px;
}

/* Stats row */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}

.stat-label {
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted2);
  margin-bottom: 8px;
}

.stat-value {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.5px;
}

.stat-value.online { color: var(--success); }
.stat-value.accent { color: var(--accent); }

/* Status badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11px;
  letter-spacing: 0.5px;
}

.badge-active {
  background: rgba(74,255,138,0.1);
  border: 1px solid rgba(74,255,138,0.3);
  color: var(--success);
}

.badge-inactive {
  background: rgba(255,74,74,0.1);
  border: 1px solid rgba(255,74,74,0.3);
  color: var(--error);
}

.badge-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* Config grid */
.config-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.config-section {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}

.config-section-title {
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 16px;
}

.config-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.config-row:last-child { border-bottom: none; }

.config-key {
  font-size: 12px;
  color: var(--muted2);
  font-weight: 300;
}

.config-input {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  width: 100px;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}

.config-input:focus { border-color: var(--accent); }

/* Toggle switch */
.toggle {
  position: relative;
  width: 40px;
  height: 22px;
  cursor: pointer;
}

.toggle input { display: none; }

.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--bg4);
  border: 1px solid var(--border);
  border-radius: 100px;
  transition: background 0.2s, border-color 0.2s;
}

.toggle input:checked + .toggle-track {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle-knob {
  position: absolute;
  top: 3px; left: 3px;
  width: 14px; height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle input:checked ~ .toggle-knob { transform: translateX(18px); }

/* Profiles */
.profiles-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.profile-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.profile-card:hover {
  border-color: var(--border2);
  transform: translateY(-2px);
}

.profile-card.selected {
  border-color: var(--accent);
  background: rgba(212,98,26,0.05);
}

.profile-name {
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}

.profile-vocation {
  font-size: 11px;
  color: var(--muted2);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.profile-delete {
  position: absolute;
  top: 8px; right: 8px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
}

.profile-delete:hover {
  color: var(--error);
  background: rgba(255,74,74,0.1);
}

/* Create profile form */
.create-profile-form {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  display: none;
}

.create-profile-form.show { display: block; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

/* Select input */
.form-select {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
  appearance: none;
  cursor: pointer;
}

.form-select:focus { border-color: var(--accent); }

.form-select option {
  background: var(--bg2);
  color: var(--text);
}

/* Divider */
.divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

/* Save bar */
.save-bar {
  position: fixed;
  bottom: 0; left: 240px; right: 0;
  background: var(--bg2);
  border-top: 1px solid var(--border2);
  padding: 16px 40px;
  display: none;
  align-items: center;
  justify-content: space-between;
  z-index: 50;
}

.save-bar.show { display: flex; }

.save-bar-text {
  font-size: 13px;
  color: var(--muted2);
}

.save-bar-text span { color: var(--accent); }

.save-actions { display: flex; gap: 12px; }

.btn-save {
  background: var(--accent-g);
  color: #fff;
  box-shadow: 0 4px 16px rgba(212,98,26,0.3);
  padding: 10px 24px;
}

.btn-save:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(212,98,26,0.45);
}

.btn-discard {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted2);
  padding: 10px 24px;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.tab {
  padding: 10px 20px;
  font-size: 13px;
  color: var(--muted2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  margin-bottom: -1px;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Tab content */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Animations */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.panel-section {
  animation: fadeUp 0.3s ease both;
}

/* Loading spinner */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: none;
}

.spinner.show { display: inline-block; }

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

/* Responsive */
@media (max-width: 900px) {
  .sidebar { width: 200px; }
  .main { margin-left: 200px; padding: 24px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .config-grid { grid-template-columns: 1fr; }
  .profiles-grid { grid-template-columns: repeat(2, 1fr); }
  .save-bar { left: 200px; }
}
</style>
