/* ============================================================
   Corvex Console — Design System
   Inspired by Emil Kowalski's design engineering philosophy:
   compact, fast, purposeful animation, unseen details compound.
   ============================================================ */

/* --- Custom easing curves (Emil Kowalski principle) --- */
:root {
  --ease-out:     cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out:  cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer:  cubic-bezier(0.32, 0.72, 0, 1);

  /* Colors */
  --color-bg:          #0a0a0a;
  --color-surface:     #111111;
  --color-surface-2:   #161616;
  --color-surface-3:   #1c1c1c;
  --color-border:      rgba(255,255,255,0.07);
  --color-border-hover:rgba(255,255,255,0.14);
  --color-text:        #ededed;
  --color-text-muted:  #888;
  --color-text-faint:  #555;
  --color-accent:      #6366f1;
  --color-accent-hover:#818cf8;
  --color-success:     #22c55e;
  --color-warning:     #f59e0b;
  --color-danger:      #ef4444;
  --color-info:        #0ea5e9;

  /* Spacing */
  --sidebar-width: 220px;
  --topbar-height: 48px;

  /* Radius */
  --radius-sm: 4px;
  --radius:    6px;
  --radius-lg: 10px;
  --radius-xl: 14px;
}

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
img, svg { display: block; }

/* ============================================================
   Scrollbar
   ============================================================ */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border-hover); border-radius: 99px; }

/* ============================================================
   Layout
   ============================================================ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 40;
  overflow: visible;
}

.sidebar-nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 4px;
}

.sidebar-logo-mark {
  width: 26px;
  height: 26px;
  background: var(--color-accent);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -0.02em;
}

.sidebar-section {
  padding: 8px 0;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-faint);
  padding: 0 16px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  margin: 0 6px;
  border-radius: var(--radius);
  color: var(--color-text-muted);
  font-size: 13px;
  font-weight: 450;
  cursor: pointer;
  transition: background 150ms var(--ease-out), color 150ms var(--ease-out);
  white-space: nowrap;
}

.nav-item svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity 150ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .nav-item:hover {
    background: var(--color-surface-3);
    color: var(--color-text);
  }
  .nav-item:hover svg { opacity: 1; }
}

.nav-active {
  background: var(--color-surface-3) !important;
  color: var(--color-text) !important;
}
.nav-active svg { opacity: 1 !important; }

.sidebar-bottom {
  flex-shrink: 0;
  padding: 8px 0 12px;
  border-top: 1px solid var(--color-border);
  position: relative;
  z-index: 50;
  background: var(--color-surface);
}

/* Main content */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

/* Topbar */
.topbar {
  height: var(--topbar-height);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  background: var(--color-surface);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
}

.topbar-spacer { flex: 1; }

.page-content {
  padding: 20px;
  flex: 1;
}

/* ============================================================
   Typography
   ============================================================ */
.page-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
}

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-header {
  padding: 14px 16px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-body {
  padding: 14px 16px;
}

.card-footer {
  padding: 0 16px 14px;
  border-top: 1px solid var(--color-border);
  padding-top: 12px;
  margin-top: 2px;
}

/* Stat Cards */
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  transition: border-color 200ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .stat-card:hover { border-color: var(--color-border-hover); }
}

.stat-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-value {
  font-size: 22px;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-top: 4px;
}

.stat-change {
  font-size: 11px;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-change.up   { color: var(--color-success); }
.stat-change.down { color: var(--color-danger); }

/* ============================================================
   Buttons (Emil Kowalski: scale on press, fast feedback)
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  line-height: 1.4;
  transition: background 150ms var(--ease-out), border-color 150ms var(--ease-out),
              color 150ms var(--ease-out), transform 120ms var(--ease-out),
              opacity 120ms var(--ease-out);
  white-space: nowrap;
  position: relative;
  user-select: none;
  text-decoration: none;
}

/* Subtle press feedback — Emil Kowalski: scale(0.97) on :active */
.btn:active { transform: scale(0.97); }

.btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.btn-primary {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { background: var(--color-accent-hover); border-color: var(--color-accent-hover); }
}

.btn-secondary {
  background: var(--color-surface-3);
  color: var(--color-text);
  border-color: var(--color-border);
}
@media (hover: hover) and (pointer: fine) {
  .btn-secondary:hover { background: var(--color-surface-3); border-color: var(--color-border-hover); }
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border-color: transparent;
}
@media (hover: hover) and (pointer: fine) {
  .btn-ghost:hover { background: var(--color-surface-3); color: var(--color-text); }
}

.btn-danger {
  background: rgba(239,68,68,0.12);
  color: var(--color-danger);
  border-color: rgba(239,68,68,0.2);
}
@media (hover: hover) and (pointer: fine) {
  .btn-danger:hover { background: rgba(239,68,68,0.18); border-color: rgba(239,68,68,0.3); }
}

.btn-success {
  background: rgba(34,197,94,0.1);
  color: var(--color-success);
  border-color: rgba(34,197,94,0.2);
}

.btn-sm { padding: 4px 8px; font-size: 12px; }
.btn-lg { padding: 8px 18px; font-size: 14px; }
.btn-xl { padding: 10px 22px; font-size: 14px; }
.btn-icon { padding: 6px; }

.btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }
.btn-loading { pointer-events: none; }
.btn-loading::after {
  content: '';
  width: 12px; height: 12px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: 4px;
}

/* ============================================================
   Forms
   ============================================================ */
.form-group { margin-bottom: 14px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: 5px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 7px 10px;
  color: var(--color-text);
  font-size: 13px;
  transition: border-color 150ms var(--ease-out), box-shadow 150ms var(--ease-out);
  outline: none;
  appearance: none;
}

.form-input::placeholder, .form-textarea::placeholder { color: var(--color-text-faint); }

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(99,102,241,0.2);
}

.form-input.error, .form-select.error { border-color: var(--color-danger); }

.form-error {
  font-size: 11px;
  color: var(--color-danger);
  margin-top: 4px;
}

.form-hint {
  font-size: 11px;
  color: var(--color-text-faint);
  margin-top: 4px;
}

.form-select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ============================================================
   Tables
   ============================================================ */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table thead th {
  background: var(--color-surface-2);
  padding: 8px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.table tbody tr {
  border-bottom: 1px solid var(--color-border);
  transition: background 100ms var(--ease-out);
}

.table tbody tr:last-child { border-bottom: none; }

@media (hover: hover) and (pointer: fine) {
  .table tbody tr:hover { background: var(--color-surface-2); }
}

.table td {
  padding: 9px 14px;
  font-size: 13px;
  color: var(--color-text);
  vertical-align: middle;
}

.table td.muted { color: var(--color-text-muted); font-size: 12px; }

/* ============================================================
   Badges
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-success  { background: rgba(34,197,94,0.12);  color: #4ade80; }
.badge-warning  { background: rgba(245,158,11,0.12); color: #fbbf24; }
.badge-danger   { background: rgba(239,68,68,0.12);  color: #f87171; }
.badge-info     { background: rgba(14,165,233,0.12); color: #38bdf8; }
.badge-neutral  { background: rgba(255,255,255,0.06); color: var(--color-text-muted); }
.badge-accent   { background: rgba(99,102,241,0.15); color: #818cf8; }

/* ============================================================
   Avatar
   ============================================================ */
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: 0.04em;
}
.avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.avatar-lg { width: 36px; height: 36px; font-size: 13px; }

/* ============================================================
   Toast Notifications (Sonner-inspired)
   ============================================================ */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: all;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--color-surface-3);
  border: 1px solid var(--color-border-hover);
  border-radius: var(--radius-lg);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--color-text);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5), 0 2px 6px rgba(0,0,0,0.3);
  min-width: 260px;
  max-width: 360px;
  opacity: 0;
  transform: translateY(8px) scale(0.97);
  transition: opacity 250ms var(--ease-out), transform 250ms var(--ease-out);
  cursor: pointer;

  @starting-style {
    opacity: 0;
    transform: translateY(8px) scale(0.97);
  }
}

.toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast.hide {
  opacity: 0;
  transform: translateY(4px) scale(0.98);
  transition: opacity 200ms ease-out, transform 200ms ease-out;
}

.toast-icon { width: 16px; height: 16px; flex-shrink: 0; }
.toast-success .toast-icon { color: var(--color-success); }
.toast-error   .toast-icon { color: var(--color-danger); }
.toast-info    .toast-icon { color: var(--color-info); }
.toast-warning .toast-icon { color: var(--color-warning); }

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 200ms var(--ease-out);
}

.modal-overlay.show { opacity: 1; }

.modal {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 480px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.6);
  transform: scale(0.96) translateY(8px);
  transition: transform 220ms var(--ease-out);
}

.modal-overlay.show .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  padding: 16px 18px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.modal-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -0.02em;
}

.modal-body { padding: 14px 18px; }

.modal-footer {
  padding: 0 18px 16px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* ============================================================
   Dropdown
   ============================================================ */
.dropdown {
  position: relative;
  display: inline-flex;
}

.table td .dropdown-menu {
  z-index: 200;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  min-width: 160px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 100;
  opacity: 0;
  transform: scale(0.96) translateY(-4px);
  transform-origin: top right;
  transition: opacity 150ms var(--ease-out), transform 150ms var(--ease-out);
  pointer-events: none;
  overflow: hidden;
}

.dropdown-menu.open {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: all;
}

.dropdown-menu-up {
  top: auto;
  bottom: calc(100% + 6px);
  transform-origin: bottom right;
}

.dropdown-menu-up.open {
  transform: scale(1) translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  font-size: 13px;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 100ms, color 100ms;
}

@media (hover: hover) and (pointer: fine) {
  .dropdown-item:hover { background: var(--color-surface-3); color: var(--color-text); }
}

.dropdown-item.danger { color: var(--color-danger); }
.dropdown-item svg { width: 14px; height: 14px; }
.dropdown-divider { height: 1px; background: var(--color-border); margin: 4px 0; }

/* ============================================================
   Product Cards
   ============================================================ */
.product-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 200ms var(--ease-out), transform 200ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .product-card:hover {
    border-color: var(--color-border-hover);
    transform: translateY(-1px);
  }
}

.product-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.product-icon svg { width: 18px; height: 18px; color: #fff; }

/* Plan Cards */
.plan-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  position: relative;
  transition: border-color 200ms var(--ease-out);
}

.plan-card.popular {
  border-color: var(--color-accent);
  background: rgba(99,102,241,0.04);
}

.plan-popular-badge {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-accent);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  letter-spacing: 0.04em;
}

/* ============================================================
   Page Header
   ============================================================ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.page-header-left { display: flex; flex-direction: column; gap: 2px; }

/* ============================================================
   Search / Filter Bar
   ============================================================ */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.search-input {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 6px 10px;
  flex: 1;
  max-width: 280px;
  transition: border-color 150ms var(--ease-out);
}

.search-input:focus-within { border-color: var(--color-accent); }
.search-input svg { width: 14px; height: 14px; color: var(--color-text-muted); flex-shrink: 0; }
.search-input input {
  background: none;
  border: none;
  outline: none;
  color: var(--color-text);
  font-size: 13px;
  width: 100%;
}
.search-input input::placeholder { color: var(--color-text-faint); }

/* ============================================================
   Tabs
   ============================================================ */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  gap: 0;
  margin-bottom: 16px;
}

.tab {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 450;
  color: var(--color-text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 150ms, border-color 150ms;
}

.tab.active {
  color: var(--color-text);
  border-bottom-color: var(--color-accent);
}

@media (hover: hover) and (pointer: fine) {
  .tab:hover { color: var(--color-text); }
}

/* ============================================================
   Empty State
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.empty-state-icon {
  width: 44px;
  height: 44px;
  background: var(--color-surface-3);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.empty-state-icon svg { width: 22px; height: 22px; color: var(--color-text-faint); }

.empty-state-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 4px;
}

.empty-state-desc {
  font-size: 12px;
  color: var(--color-text-muted);
  max-width: 260px;
  line-height: 1.6;
  margin-bottom: 16px;
}

/* ============================================================
   Alert Banner
   ============================================================ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  border: 1px solid transparent;
  margin-bottom: 14px;
}

.alert svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: rgba(34,197,94,0.08);  color: #4ade80; border-color: rgba(34,197,94,0.2); }
.alert-error   { background: rgba(239,68,68,0.08);  color: #f87171; border-color: rgba(239,68,68,0.2); }
.alert-warning { background: rgba(245,158,11,0.08); color: #fbbf24; border-color: rgba(245,158,11,0.2); }
.alert-info    { background: rgba(14,165,233,0.08); color: #38bdf8; border-color: rgba(14,165,233,0.2); }

/* ============================================================
   Loading Skeleton
   ============================================================ */
@keyframes shimmer {
  from { background-position: -400px 0; }
  to   { background-position: 400px 0; }
}

.skeleton {
  background: linear-gradient(90deg, var(--color-surface-2) 25%, var(--color-surface-3) 50%, var(--color-surface-2) 75%);
  background-size: 400px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius);
}

/* ============================================================
   Stagger animation (Emil Kowalski: 30-80ms between items)
   ============================================================ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.stagger-item {
  opacity: 0;
  animation: fadeUp 280ms var(--ease-out) forwards;
}

.stagger-item:nth-child(1)  { animation-delay: 0ms; }
.stagger-item:nth-child(2)  { animation-delay: 40ms; }
.stagger-item:nth-child(3)  { animation-delay: 80ms; }
.stagger-item:nth-child(4)  { animation-delay: 120ms; }
.stagger-item:nth-child(5)  { animation-delay: 160ms; }
.stagger-item:nth-child(6)  { animation-delay: 200ms; }
.stagger-item:nth-child(7)  { animation-delay: 240ms; }
.stagger-item:nth-child(8)  { animation-delay: 280ms; }

/* ============================================================
   Auth Layout
   ============================================================ */
.auth-layout {
  min-height: 100vh;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.4);
  animation: fadeUp 320ms var(--ease-out) both;
}

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 24px;
}

.auth-logo-mark {
  width: 34px;
  height: 34px;
  background: var(--color-accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text);
  text-align: center;
  margin-bottom: 4px;
  letter-spacing: -0.03em;
}

.auth-subtitle {
  font-size: 13px;
  color: var(--color-text-muted);
  text-align: center;
  margin-bottom: 22px;
}

/* ============================================================
   Impersonation Banner
   ============================================================ */
.impersonate-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: linear-gradient(90deg, rgba(245,158,11,0.14) 0%, rgba(245,158,11,0.06) 100%);
  border-bottom: 1px solid rgba(245,158,11,0.22);
  box-shadow: inset 3px 0 0 var(--color-warning);
  position: sticky;
  top: 0;
  z-index: 35;
}

.impersonate-banner-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(245,158,11,0.16);
  border: 1px solid rgba(245,158,11,0.28);
  color: #fbbf24;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.impersonate-banner-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.impersonate-banner-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #fbbf24;
}

.impersonate-banner-detail {
  font-size: 12px;
  color: var(--color-text-muted);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.impersonate-banner-detail strong {
  color: var(--color-text);
  font-weight: 600;
}

.impersonate-banner-sep {
  margin: 0 4px;
  color: var(--color-text-faint);
}

.impersonate-banner-exit {
  flex-shrink: 0;
  background: rgba(245,158,11,0.14) !important;
  border: 1px solid rgba(245,158,11,0.3) !important;
  color: #fde68a !important;
  font-weight: 500;
  gap: 6px;
}

@media (hover: hover) and (pointer: fine) {
  .impersonate-banner-exit:hover {
    background: rgba(245,158,11,0.22) !important;
    border-color: rgba(245,158,11,0.45) !important;
    color: #fff !important;
  }
}

.is-impersonating {
  --impersonate-banner-height: 53px;
}

.is-impersonating .topbar {
  top: var(--impersonate-banner-height);
}

@media (max-width: 768px) {
  .impersonate-banner {
    flex-wrap: wrap;
    padding: 12px 16px;
    gap: 10px;
  }

  .impersonate-banner-detail {
    white-space: normal;
  }

  .impersonate-banner-exit {
    width: 100%;
    justify-content: center;
  }
}

/* ============================================================
   Grid helpers
   ============================================================ */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }

@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .sidebar { transform: translateX(-100%); transition: transform 250ms var(--ease-drawer); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
}

/* ============================================================
   Misc
   ============================================================ */
.divider { height: 1px; background: var(--color-border); margin: 16px 0; }

.text-muted   { color: var(--color-text-muted) !important; }
.text-faint   { color: var(--color-text-faint) !important; }
.text-success { color: var(--color-success) !important; }
.text-danger  { color: var(--color-danger) !important; }
.text-warning { color: var(--color-warning) !important; }
.text-accent  { color: var(--color-accent) !important; }

.flex   { display: flex; }
.items-center { align-items: center; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.mt-auto { margin-top: auto; }
.ml-auto { margin-left: auto; }
.w-full  { width: 100%; }

.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Spinner */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* Admin sidebar accent */
.sidebar-admin .sidebar-logo-mark { background: #f59e0b; }

/* Impersonating chip */
.impersonating-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(245,158,11,0.1);
  color: #fbbf24;
  border: 1px solid rgba(245,158,11,0.2);
  border-radius: 99px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
}

/* Prefers reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
