:root {
  --gold: #C8861A;
  --gold-light: #E09B2A;
  --gold-pale: #FDF4E7;
  --gold-border: #F0C97A;
  --black: #111111;
  --charcoal: #2A2A2A;
  --slate: #5A5A5A;
  --mist: #F8F6F2;
  --white: #FFFFFF;
  --divider: #E8E0D4;
  --serif: 'Playfair Display', Georgia, serif;
  --sans: 'DM Sans', sans-serif;
  --montserrat: 'Montserrat', sans-serif;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --elevation-1: 0 2px 8px rgba(0,0,0,0.12);
  --elevation-2: 0 8px 32px rgba(0,0,0,0.16);
  --elevation-3: 0 16px 48px rgba(0,0,0,0.20);
  --elevation-4: 0 24px 64px rgba(0,0,0,0.28);
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 200ms;
  --duration-slow: 500ms;
  --glass-bg: rgba(22, 22, 22, 0.85);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-blur: 20px;
  --canvas-bg: #0d0d0d;
  --canvas-text: #e0e0e0;
  --canvas-muted: #888;
  --card-bg: rgba(30, 30, 30, 0.7);
  --card-border: rgba(255, 255, 255, 0.06);
  --card-hover-border: rgba(200, 134, 26, 0.3);
  --input-bg: rgba(40, 40, 40, 0.9);
  --input-border: rgba(255, 255, 255, 0.1);
  --input-focus-border: var(--gold);
  --sidebar-bg: rgba(18, 18, 18, 0.95);
  --sidebar-width: 240px;
  --topbar-height: 64px;
}

[data-theme="dark"] {
  --black: #F8F6F2;
  --charcoal: #E8E0D4;
  --slate: #AAAAAA;
  --mist: #1A1A1A;
  --white: #111111;
  --divider: #2A2A2A;
  --gold-pale: #2A241A;
  --canvas-bg: #111111;
  --canvas-text: #e0e0e0;
  --canvas-muted: #888;
  --card-bg: #1A1A1A;
  --card-border: #2A2A2A;
  --card-hover-border: rgba(200, 134, 26, 0.3);
  --input-bg: #1A1A1A;
  --input-border: #2A2A2A;
  --glass-bg: rgba(17, 17, 17, 0.85);
  --glass-border: rgba(255, 255, 255, 0.06);
  --sidebar-bg: #0d0d0d;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--sans);
  background: var(--canvas-bg);
  color: var(--canvas-text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ─── PASSWORD GATE ─── */
.pass-gate {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #1a1a1a 0%, var(--canvas-bg) 70%);
  z-index: 100;
  transition: opacity var(--duration-slow) var(--ease-out-expo);
  flex-direction: column;
}

.pass-gate::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' xmlns='http://www.w3.org/2000/svg'%3E%3Cdefs%3E%3Cpattern id='g' width='60' height='60' patternUnits='userSpaceOnUse'%3E%3Cpath d='M0 30 L30 0 L60 30 L30 60 Z' fill='none' stroke='rgba(200,134,26,0.03)' stroke-width='1'/%3E%3C/pattern%3E%3C/defs%3E%3Crect width='100%25' height='100%25' fill='url(%23g)'/%3E%3C/svg%3E");
  opacity: 0.5;
  pointer-events: none;
}

.pass-gate-card {
  position: relative;
  z-index: 1;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: 56px 48px 48px;
  width: 420px;
  max-width: 90vw;
  text-align: center;
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  box-shadow: var(--elevation-3);
  animation: gateFadeIn 0.8s var(--ease-out-expo) both;
}

@keyframes gateFadeIn {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.pass-gate-emblem {
  width: 48px;
  height: 48px;
  margin: 0 auto 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.pass-gate-emblem svg {
  width: 36px;
  height: 36px;
  color: var(--gold);
}

.pass-gate-emblem::before {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 1px solid rgba(200, 134, 26, 0.2);
  animation: emblemPulse 3s ease-in-out infinite;
}

@keyframes emblemPulse {
  0%, 100% { transform: scale(1); opacity: 0.4; }
  50% { transform: scale(1.08); opacity: 0.8; }
}

.pass-gate-title {
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 700;
  color: #f0f0f0;
  margin-bottom: 8px;
}

.pass-gate-subtitle {
  font-size: 13px;
  color: var(--canvas-muted);
  margin-bottom: 32px;
  letter-spacing: 0.5px;
}

.pass-gate-group {
  position: relative;
  margin-bottom: 20px;
}

.pass-gate-input {
  width: 100%;
  padding: 14px 18px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  color: #f0f0f0;
  font-family: var(--sans);
  font-size: 15px;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
  outline: none;
}

.pass-gate-input::placeholder {
  color: #555;
}

.pass-gate-input:focus {
  border-color: var(--input-focus-border);
  box-shadow: 0 0 0 3px rgba(200, 134, 26, 0.1);
}

.pass-gate-btn {
  width: 100%;
  padding: 14px 24px;
  background: var(--gold);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--montserrat);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform var(--duration-fast), box-shadow var(--duration-fast), background var(--duration-fast);
}

.pass-gate-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(200, 134, 26, 0.3);
}

.pass-gate-btn:active {
  transform: translateY(0);
}

.pass-gate-btn.btn-error {
  animation: btnShake 0.4s ease;
  background: #c0392b;
}

@keyframes btnShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.pass-gate-error {
  display: none;
  color: #e74c3c;
  font-size: 12px;
  margin-top: 12px;
  letter-spacing: 0.3px;
}

.pass-gate-error.shake {
  animation: errorShake 0.5s ease;
}

@keyframes errorShake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
  20%, 40%, 60%, 80% { transform: translateX(4px); }
}

.pass-gate-hint {
  margin-top: 16px;
  font-size: 11px;
  color: #444;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* ─── DASHBOARD ─── */
.app-dashboard {
  display: none;
  height: 100vh;
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.app-dashboard.visible {
  opacity: 1;
}

/* ─── TOP BAR ─── */
.topbar {
  height: var(--topbar-height);
  background: rgba(15, 15, 15, 0.95);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 50;
  flex-shrink: 0;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-brand-icon {
  width: 28px;
  height: 28px;
  color: var(--gold);
}

.topbar-brand h1 {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 700;
  color: #f0f0f0;
  letter-spacing: 0.3px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-logout {
  padding: 8px 20px;
  background: transparent;
  color: var(--canvas-muted);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  font-family: var(--montserrat);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all var(--duration-fast);
}

.topbar-logout:hover {
  color: #f0f0f0;
  border-color: rgba(200, 134, 26, 0.4);
  background: rgba(200, 134, 26, 0.06);
}

/* ─── BODY LAYOUT ─── */
.hub-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ─── SIDEBAR ─── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid rgba(255,255,255,0.05);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  flex-shrink: 0;
  overflow-y: auto;
}

.sidebar-section-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #555;
  padding: 8px 24px;
  margin-bottom: 4px;
}

.sidebar-nav {
  list-style: none;
  padding: 0 12px;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-radius: var(--radius-md);
  font-family: var(--montserrat);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #777;
  cursor: pointer;
  transition: all var(--duration-fast);
  margin-bottom: 2px;
  position: relative;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.sidebar-nav-item:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.sidebar-nav-item:hover {
  color: #bbb;
  background: rgba(255,255,255,0.03);
}

.sidebar-nav-item.active {
  color: #f0f0f0;
  background: rgba(200, 134, 26, 0.1);
}

.sidebar-nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  border-radius: 0 3px 3px 0;
  background: var(--gold);
}

.sidebar-nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity var(--duration-fast);
}

.sidebar-nav-item.active .sidebar-nav-icon,
.sidebar-nav-item:hover .sidebar-nav-icon {
  opacity: 1;
}

/* ─── MAIN CONTENT ─── */
.main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 40px;
  background: var(--canvas-bg);
}

.tab-panel {
  display: none;
  animation: panelFadeIn 0.4s var(--ease-out-expo);
}

.tab-panel.active {
  display: block;
}

@keyframes panelFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── RESPONSIVE ─── */
@media (max-width: 1024px) {
  .main-content { padding: 28px 24px; }
  .sidebar { width: 200px; }
}

@media (max-width: 768px) {
  .hub-body { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    padding: 0;
    border-right: none;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    flex-shrink: 0;
  }
  .sidebar-section-label { display: none; }
  .sidebar-nav {
    display: flex;
    padding: 8px 12px;
    gap: 4px;
  }
  .sidebar-nav-item {
    font-size: 11px;
    padding: 10px 14px;
    white-space: nowrap;
    border-radius: var(--radius-sm);
  }
  .sidebar-nav-item.active::before { display: none; }
  .sidebar-nav-item.active { border-bottom: 2px solid var(--gold); background: transparent; border-radius: 0; }
  .main-content { padding: 20px 16px; }
  .topbar { padding: 0 16px; }
  .topbar-brand h1 { font-size: 15px; }
  .pass-gate-card { padding: 40px 28px 36px; }
}

@media (max-width: 480px) {
  .main-content { padding: 16px 12px; }
  .topbar { padding: 0 12px; }
  .topbar-brand h1 { font-size: 14px; }
  .topbar-logout { padding: 6px 12px; font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
