/* ── APP SHELL ──────────────────────────────────────────────────*/
.app-shell { display: flex; min-height: 100vh; background: var(--bg-base); }

/* ── SIDEBAR ────────────────────────────────────────────────────*/
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  background: rgba(9, 13, 22, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  transition: transform 250ms cubic-bezier(0.4, 0, 0.2, 1), width 250ms cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar.collapsed { width: 64px; }

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  height: var(--topbar-h);
  flex-shrink: 0;
}
.logo-mark { width: 32px; height: 32px; flex-shrink: 0; }
.logo-text {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 800;
  white-space: nowrap;
  transition: opacity 200ms ease;
  color: var(--text-primary);
}
.logo-text strong { color: var(--accent-orange); }
.sidebar.collapsed .logo-text { opacity: 0; width: 0; overflow: hidden; }

.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; min-height: 0; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.05); }

.nav-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 10px 12px 4px;
  white-space: nowrap;
  transition: opacity 200ms;
}
.sidebar.collapsed .nav-section-label { opacity: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  min-height: 42px;
  position: relative;
  border: 1px solid transparent;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item span { font-size: 0.875rem; font-weight: 550; transition: opacity 200ms; }
.sidebar.collapsed .nav-item span { opacity: 0; width: 0; }

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.02);
}
.nav-item.active {
  background: rgba(168, 85, 247, 0.12);
  color: #c084fc;
  border-left: 3px solid #a855f7;
  padding-left: 9px;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
.nav-item.active svg { color: #c084fc; }
.nav-item.danger { color: var(--danger); }
.nav-item.danger:hover { background: var(--danger-dim); }
.nav-divider { height: 1px; background: var(--border); margin: 8px 10px; }

.sidebar-footer { padding: 12px 8px; border-top: 1px solid var(--border); flex-shrink: 0; }
.sidebar-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
  background: rgba(255, 255, 255, 0.02);
}
.sidebar-collapse-btn:hover { background: rgba(255, 255, 255, 0.06); color: var(--text-primary); }
.sidebar-collapse-btn svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ── TOPBAR ─────────────────────────────────────────────────────*/
.topbar {
  height: var(--topbar-h);
  background: rgba(6, 8, 20, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.hamburger {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
}
.hamburger:hover { background: rgba(255, 255, 255, 0.06); color: var(--text-primary); }
.topbar-title { font-family: var(--font-display); font-size: 1rem; font-weight: 700; color: var(--text-primary); }
.topbar-right { display: flex; align-items: center; gap: 12px; }

/* ── Balance chip ── */
.balance-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px 5px 8px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.18) 0%, rgba(5, 150, 105, 0.08) 100%);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 999px;
  cursor: pointer;
  transition: all 180ms ease;
  position: relative;
  overflow: hidden;
}
.balance-chip::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(16, 185, 129, 0.1) 100%);
  opacity: 0;
  transition: opacity 200ms;
}
.balance-chip:hover::before { opacity: 1; }
.balance-chip:hover {
  border-color: rgba(16, 185, 129, 0.6);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.25);
}
.balance-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
  flex-shrink: 0;
}
.balance-icon svg { width: 13px; height: 13px; color: #040815; }
.balance-text { display: flex; flex-direction: column; line-height: 1; }
.balance-label { font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.07em; color: rgba(16, 185, 129, 0.85); font-weight: 700; }
.balance-amount { font-size: 0.83rem; font-weight: 800; color: #10b981; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }

/* ── User menu ── */
.user-menu {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  transition: all 180ms ease;
  position: relative;
  border: 1px solid transparent;
}
.user-menu:hover { background: rgba(255, 255, 255, 0.05); border-color: var(--border); }
.user-menu > svg { width: 14px; height: 14px; color: var(--text-muted); transition: transform 200ms; }
.user-menu:hover > svg { transform: translateY(1px); }

/* ── Avatar ── */
.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  position: relative;
  overflow: hidden;
}
.user-avatar:not(.is-admin) {
  background: var(--grad-amber);
  color: #fff;
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.4);
}
.user-avatar.is-admin {
  background: var(--grad-accent);
  color: #fff;
  box-shadow: 0 2px 10px rgba(139, 92, 246, 0.45);
}
.user-avatar::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.18) 0%, transparent 60%);
  pointer-events: none;
}
.user-name { font-size: 0.83rem; font-weight: 600; color: var(--text-primary); }
.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: all 150ms ease;
  z-index: 200;
}
.user-dropdown.open { opacity: 1; pointer-events: all; transform: translateY(0); }
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: 0.875rem;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-primary);
}
.dropdown-item:hover { background: rgba(255, 255, 255, 0.05); }
.dropdown-item svg { width: 16px; height: 16px; color: var(--text-muted); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-divider { height: 1px; background: var(--border); }

.avatar-letter { position: relative; z-index: 1; }
.avatar-badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fcd34d, #f59e0b);
  border: 2px solid var(--bg-surface);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

/* ── MAIN CONTENT ───────────────────────────────────────────────*/
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: margin-left 250ms cubic-bezier(0.4, 0, 0.2, 1);
}
.main-wrapper.collapsed { margin-left: 64px; }
.main-content { flex: 1; padding: 28px; max-width: 1400px; width: 100%; }
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.03em; color: var(--text-primary); }
.page-header p { color: var(--text-muted); font-size: 0.9rem; margin-top: 4px; }

/* ── GRID LAYOUTS ───────────────────────────────────────────────*/
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.content-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.content-grid.thirds { display: grid; grid-template-columns: 1fr 1fr 1fr; }
.full-width { grid-column: 1/-1; }

/* ── SIDEBAR OVERLAY (mobile) ───────────────────────────────────*/
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.8); backdrop-filter: blur(4px); z-index: 99; }

/* ── AUTH PAGE ──────────────────────────────────────────────────*/
.auth-page { height: 100vh; display: grid; grid-template-columns: 1.1fr 0.9fr; overflow: hidden; background: #060814; }

.auth-brand {
  background-color: #060814;
  background-image: 
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 32px 32px;
  background-position: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px;
  position: relative;
  border-right: 1px solid rgba(255, 255, 255, 0.03);
}
.auth-brand::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.1) 0%, transparent 70%);
  top: -200px;
  left: -200px;
  animation: pulse-glow 6s ease-in-out infinite;
}
.auth-brand::after {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(244, 63, 94, 0.08) 0%, transparent 70%);
  bottom: -100px;
  right: -100px;
  animation: pulse-glow 8s ease-in-out infinite reverse;
}
.auth-brand-content { position: relative; z-index: 1; text-align: center; }
.auth-brand-logo { display: flex; align-items: center; gap: 12px; justify-content: center; margin-bottom: 32px; }
.auth-brand-logo .logo-text { font-family: var(--font-display); font-size: 1.8rem; font-weight: 800; letter-spacing: -0.03em; }
.auth-brand h2 { font-size: 2.2rem; font-weight: 800; margin-bottom: 14px; letter-spacing: -0.04em; line-height: 1.15; color: var(--text-primary); }
.auth-brand p { color: var(--text-muted); font-size: 1.05rem; max-width: 380px; margin: 0 auto 36px; line-height: 1.6; }

.trust-badges { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.trust-badge {
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-bright);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}
.trust-badge strong { color: var(--accent-green); }

.auth-form-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: #03050a;
  overflow-y: auto;
}
.auth-form-card {
  width: 100%;
  max-width: 420px;
  padding: 38px 34px;
  background: rgba(11, 15, 25, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-xl);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7), 0 0 40px rgba(168, 85, 247, 0.1);
}
.auth-form-card h1 { font-size: 1.45rem; font-weight: 800; margin-bottom: 4px; letter-spacing: -0.02em; color: var(--text-primary); }
.auth-form-card .subtitle { color: var(--text-muted); font-size: 0.875rem; margin-bottom: 20px; }
.auth-tabs { display: flex; gap: 0; margin-bottom: 18px; border-bottom: 1px solid var(--border); }
.auth-tab {
  padding: 10px 20px;
  font-weight: 700;
  cursor: pointer;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: var(--transition);
  font-size: 0.9rem;
}
.auth-tab.active { color: #f43f5e; border-bottom-color: #f43f5e; }

/* ── RESPONSIVE ─────────────────────────────────────────────────*/
@media (max-width: 1024px) {
  .content-grid, .content-grid.thirds { grid-template-columns: 1fr; }
  .auth-page { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-w) !important; }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar-overlay { display: block; opacity: 0; pointer-events: none; transition: opacity 250ms; }
  .sidebar-overlay.visible { opacity: 1; pointer-events: all; }
  .main-wrapper, .main-wrapper.collapsed { margin-left: 0; }
  .hamburger { display: flex; }
  .sidebar-collapse-btn { display: none; }

  .main-content { padding: 16px; }
  .page-header { margin-bottom: 16px; }
  .page-header h1 { font-size: 1.25rem; }
  .page-header p { font-size: 0.82rem; }

  .topbar { padding: 0 16px; }
  .user-name { display: none; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 1.35rem; }

  .card { padding: 16px; }
  .card-title { font-size: 0.95rem; }

  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table { min-width: 500px; font-size: 0.82rem; }
  .table th, .table td { padding: 8px 10px; }
  .table .btn-sm { padding: 4px 10px; font-size: 0.75rem; }

  .content-grid,
  .content-grid.thirds,
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr"] { grid-template-columns: 1fr !important; }

  .modal { padding: 18px; width: calc(100vw - 28px) !important; max-width: 100% !important; }
  .input, .btn { min-height: 44px; }
  .btn-sm { min-height: 36px; }

  .price-display { padding: 12px 14px; }
  .price-value { font-size: 1.2rem; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 12px; }
  .stat-value { font-size: 1.15rem; }
  .stat-label { font-size: 0.72rem; }

  .main-content { padding: 12px; }
  .card { padding: 14px; }
  .modal { padding: 14px; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .amount-pill { padding: 6px 12px; font-size: 0.78rem; }
}
