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

html,
body {
  height: 100%;
}

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

.hidden {
  display: none !important;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input,
textarea,
select {
  font-family: inherit;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease;
}

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

a {
  color: var(--brand-light);
  text-decoration: none;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 8px;
}

/* ---------------- Auth Screen ---------------- */

#auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(124, 92, 255, 0.18), transparent 45%),
    radial-gradient(circle at 80% 80%, rgba(79, 124, 255, 0.15), transparent 45%),
    var(--bg);
  padding: var(--space-5);
}

.auth-box {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-md);
}

.auth-brand {
  text-align: center;
  margin-bottom: var(--space-5);
}

.auth-brand .logo-mark {
  width: 60px;
  height: 60px;
  margin: 0 auto var(--space-3);
  border-radius: 16px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 22px;
  color: #fff;
}

.auth-brand .logo-mark img {
  width: 51px;
  height: 51px;
  object-fit: contain;
}

.auth-brand h1 {
  font-size: 22px;
  font-weight: 700;
}

.auth-brand p {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}

.auth-tabs {
  display: flex;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: var(--space-5);
}

.auth-tab {
  flex: 1;
  padding: 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
}

.auth-tab.active {
  background: var(--brand-gradient);
  color: #fff;
}

.auth-form .form-group {
  margin-bottom: var(--space-4);
}

.auth-form label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.auth-form input {
  width: 100%;
}

.auth-error {
  display: none;
  background: rgba(239, 68, 68, 0.12);
  color: #ff8080;
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: var(--space-4);
}

/* ---------------- App Shell ---------------- */

#app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.2s ease;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar.collapsed {
  width: var(--sidebar-width-collapsed);
}

.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .user-details {
  display: none;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-brand .logo-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-brand .logo-mark img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.sidebar-brand-text strong {
  display: block;
  font-size: 15px;
}

.sidebar-brand-text span {
  font-size: 11px;
  color: var(--text-muted);
}

#sidebar-toggle {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  color: var(--text-muted);
}

#sidebar-toggle:hover {
  background: var(--surface-hover);
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-3);
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 2px;
  position: relative;
}

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

.nav-item.active {
  background: rgba(124, 92, 255, 0.14);
  color: var(--brand-light);
}

.nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--brand-gradient);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
}

.sidebar-bottom {
  padding: var(--space-4);
  border-top: 1px solid var(--border);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: var(--space-3);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--brand-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-details strong {
  display: block;
  font-size: 13px;
}

.user-details span {
  font-size: 11px;
  color: var(--text-muted);
}

.logout-btn {
  width: 100%;
  padding: 9px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.logout-btn:hover {
  color: var(--red);
  border-color: rgba(239, 68, 68, 0.4);
}

#main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.page-loader {
  padding: var(--space-6);
  text-align: center;
  color: var(--text-muted);
}

#page-container {
  flex: 1;
  min-width: 0;
}

.page {
  padding: var(--space-6);
  max-width: 1280px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.page-header h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}

.page-header p {
  color: var(--text-muted);
  font-size: 13.5px;
}

.preview-badge {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--amber);
  background: rgba(245, 158, 11, 0.14);
  padding: 3px 8px;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 8px;
}

.preview-note {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.25);
  color: #a9c8ff;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  margin-bottom: var(--space-5);
  line-height: 1.6;
}

.field-hint {
  font-size: 12.5px;
  color: var(--text-faint);
  margin-top: var(--space-2);
  line-height: 1.6;
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    z-index: 40;
    height: 100vh;
  }
}
