/* ==========================================================================
   NEXORA — Modern Web App with Supabase
   assets/css/style.css
   Design system: tokens, layout, components, views, responsive.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design tokens
   -------------------------------------------------------------------------- */
:root {
  --font-display: "Sora", "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --radius-pill: 999px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  --sidebar-w: 264px;
  --sidebar-w-collapsed: 78px;
  --topbar-h: 68px;

  --brand-1: #7c5cff;
  --brand-2: #22d3ee;
  --brand-3: #f472b6;
  --grad-brand: linear-gradient(135deg, #7c5cff 0%, #5b8dff 45%, #22d3ee 100%);
  --grad-brand-soft: linear-gradient(135deg, rgba(124, 92, 255, 0.18), rgba(34, 211, 238, 0.14));

  --success: #34d399;
  --warning: #fbbf24;
  --danger: #fb7185;
  --info: #60a5fa;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t-fast: 140ms var(--ease);
  --t: 240ms var(--ease);
}

/* Dark theme (default) */
:root,
[data-theme="dark"] {
  --bg: #06080f;
  --bg-elev: #0a0e1a;
  --surface: rgba(255, 255, 255, 0.035);
  --surface-2: rgba(255, 255, 255, 0.06);
  --surface-solid: #10162a;
  --surface-solid-2: #161d33;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #e9edfb;
  --text-2: #b9c2dd;
  --muted: #8792b2;
  --overlay: rgba(3, 5, 12, 0.72);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.85);
  --shadow-lg: 0 40px 90px -30px rgba(0, 0, 0, 0.9);
  --glow: 0 0 0 1px rgba(124, 92, 255, 0.35), 0 12px 40px -14px rgba(124, 92, 255, 0.55);
  --grid-line: rgba(255, 255, 255, 0.045);
}

/* Light theme */
[data-theme="light"] {
  --bg: #f4f6fb;
  --bg-elev: #ffffff;
  --surface: rgba(16, 24, 40, 0.028);
  --surface-2: rgba(16, 24, 40, 0.055);
  --surface-solid: #ffffff;
  --surface-solid-2: #f7f9fd;
  --border: rgba(16, 24, 40, 0.09);
  --border-strong: rgba(16, 24, 40, 0.16);
  --text: #0d1428;
  --text-2: #2c3757;
  --muted: #66708c;
  --overlay: rgba(16, 24, 40, 0.42);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow: 0 16px 36px -20px rgba(16, 24, 40, 0.35);
  --shadow-lg: 0 40px 80px -32px rgba(16, 24, 40, 0.32);
  --glow: 0 0 0 1px rgba(124, 92, 255, 0.28), 0 14px 36px -16px rgba(124, 92, 255, 0.4);
  --grid-line: rgba(16, 24, 40, 0.05);
}

/* --------------------------------------------------------------------------
   2. Reset & base
   -------------------------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(820px 520px at 12% -8%, rgba(124, 92, 255, 0.20), transparent 62%),
    radial-gradient(760px 520px at 92% 4%, rgba(34, 211, 238, 0.14), transparent 60%),
    radial-gradient(620px 520px at 60% 108%, rgba(244, 114, 182, 0.10), transparent 60%);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(circle at 50% 30%, #000 0%, transparent 78%);
  -webkit-mask-image: radial-gradient(circle at 50% 30%, #000 0%, transparent 78%);
}

h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--text);
  line-height: 1.2;
}

p { margin: 0; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
ul { margin: 0; padding: 0; list-style: none; }

::selection { background: rgba(124, 92, 255, 0.35); color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--surface-2);
  border-radius: var(--radius-pill);
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); background-clip: content-box; }

:focus-visible {
  outline: 2px solid var(--brand-2);
  outline-offset: 2px;
}

.ico {
  width: 16px;
  height: 16px;
  flex: none;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: -999px; top: 12px; z-index: 999;
  background: var(--brand-1); color: #fff; padding: 10px 16px; border-radius: var(--radius-sm);
}
.skip-link:focus { left: 12px; }

/* --------------------------------------------------------------------------
   3. Utilities
   -------------------------------------------------------------------------- */
.grad-text {
  background: var(--grad-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.muted { color: var(--muted); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11.5px; }
.mono { font-family: var(--font-mono); }
.hidden { display: none !important; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-5 { gap: 24px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.center { display: grid; place-items: center; }

/* --------------------------------------------------------------------------
   4. App shell
   -------------------------------------------------------------------------- */
.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  transition: grid-template-columns var(--t);
}

.app-shell.is-collapsed { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-5) var(--space-4);
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-elev) 82%, transparent);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 18px;
  min-height: 46px;
}
.brand__mark {
  width: 38px; height: 38px; flex: none;
  border-radius: 12px;
  background: var(--grad-brand);
  display: grid; place-items: center;
  box-shadow: 0 10px 26px -10px rgba(124, 92, 255, 0.9);
}
.brand__mark svg { width: 21px; height: 21px; }
.brand__name {
  display: block;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.03em;
  white-space: nowrap;
}
.brand__tag {
  display: block;
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  font-family: var(--font-mono);
}

.nav { display: flex; flex-direction: column; gap: 4px; margin-top: var(--space-2); }
.nav__label {
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 14px 12px 6px;
  font-weight: 600;
}
.nav__item {
  display: flex;
  width: 100%;
  border: 0;
  background: transparent;
  font-family: var(--font-body);
  text-align: left;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-weight: 500;
  font-size: 14.5px;
  cursor: pointer;
  position: relative;
  transition: background var(--t-fast), color var(--t-fast);
  white-space: nowrap;
}
.nav__item svg { width: 18px; height: 18px; flex: none; opacity: 0.85; }
.nav__item:hover { background: var(--surface-2); color: var(--text); }
.nav__item.is-active {
  color: var(--text);
  background: var(--grad-brand-soft);
  box-shadow: inset 0 0 0 1px rgba(124, 92, 255, 0.28);
}
.nav__item.is-active svg { opacity: 1; color: var(--brand-2); }
.nav__badge {
  margin-left: auto;
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-2);
}
.nav__item.is-active .nav__badge { background: rgba(124, 92, 255, 0.28); color: #fff; }

.sidebar__footer { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }

.upgrade-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--border);
  background: var(--grad-brand-soft);
}
.upgrade-card h4 { font-size: 14px; margin-bottom: 4px; }
.upgrade-card p { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.upgrade-card::after {
  content: "";
  position: absolute; right: -30px; top: -30px;
  width: 90px; height: 90px; border-radius: 50%;
  background: radial-gradient(circle, rgba(34, 211, 238, 0.35), transparent 70%);
}

.sidebar-collapse {
  display: none;
}

/* collapsed state */
.app-shell.is-collapsed .brand__text,
.app-shell.is-collapsed .nav__label,
.app-shell.is-collapsed .nav__item span,
.app-shell.is-collapsed .nav__badge,
.app-shell.is-collapsed .upgrade-card,
.app-shell.is-collapsed .sidebar__user-meta { display: none; }
.app-shell.is-collapsed .nav__item { justify-content: center; padding: 11px 0; }
.app-shell.is-collapsed .brand { justify-content: center; padding-left: 0; padding-right: 0; }

/* --------------------------------------------------------------------------
   5. Topbar + main
   -------------------------------------------------------------------------- */
.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-5);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.topbar__title { font-size: 17px; font-weight: 600; }
.topbar__sub { font-size: 12px; color: var(--muted); }
.topbar__spacer { flex: 1; }

.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: var(--t-fast);
  position: relative;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn__dot {
  position: absolute; top: 7px; right: 8px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--danger);
  border: 2px solid var(--bg-elev);
}

.content { padding: var(--space-6) var(--space-5) var(--space-7); flex: 1; }
.page { max-width: 1320px; margin: 0 auto; animation: pageIn 420ms var(--ease) both; }
@keyframes pageIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.page__head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-5); }
.page__title { font-size: 26px; }
.page__desc { color: var(--muted); font-size: 14px; margin-top: 4px; }

/* --------------------------------------------------------------------------
   6. Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  white-space: nowrap;
  transition: transform var(--t-fast), box-shadow var(--t-fast), background var(--t-fast), border-color var(--t-fast), opacity var(--t-fast);
}
.btn svg { width: 17px; height: 17px; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn--primary {
  background: var(--grad-brand);
  color: #fff;
  box-shadow: 0 12px 28px -12px rgba(124, 92, 255, 0.85);
}
.btn--primary:hover { box-shadow: 0 16px 34px -12px rgba(124, 92, 255, 1); }

.btn--ghost { background: transparent; border-color: var(--border); color: var(--text-2); }
.btn--ghost:hover { border-color: var(--border-strong); color: var(--text); background: var(--surface); }

.btn--soft { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn--soft:hover { background: var(--surface-2); }

.btn--danger { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 34%, transparent); }
.btn--danger:hover { background: color-mix(in srgb, var(--danger) 26%, transparent); }

.btn--sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: var(--radius-xs); }
.btn--sm svg { width: 15px; height: 15px; }
.btn--lg { height: 50px; padding: 0 26px; font-size: 15px; }
.btn--block { width: 100%; }
.btn--icon { width: 34px; padding: 0; }

.btn--loading { position: relative; color: transparent !important; pointer-events: none; }
.btn--loading::after {
  content: "";
  position: absolute;
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------------------
   7. Cards & surfaces
   -------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-5);
  position: relative;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.card--solid { background: var(--surface-solid); backdrop-filter: none; -webkit-backdrop-filter: none; }
.card--flush { padding: 0; overflow: hidden; }
.card--hover { transition: transform var(--t), border-color var(--t), box-shadow var(--t); }
.card--hover:hover { transform: translateY(-3px); border-color: var(--border-strong); box-shadow: var(--shadow); }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: var(--space-4); }
.card__title { font-size: 15.5px; font-weight: 600; }
.card__hint { font-size: 12.5px; color: var(--muted); }

/* --------------------------------------------------------------------------
   8. Forms
   -------------------------------------------------------------------------- */
.field { margin-bottom: var(--space-4); }
.field__label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 7px; color: var(--text-2); }
.field__hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.field__error { font-size: 12px; color: var(--danger); margin-top: 6px; display: none; }
.field.has-error .input { border-color: color-mix(in srgb, var(--danger) 60%, transparent); }
.field.has-error .field__error { display: block; }

.input, .select, .textarea {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14.5px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  outline: none;
}
.textarea { height: auto; padding: 12px 14px; resize: vertical; min-height: 120px; line-height: 1.6; }
.input::placeholder, .textarea::placeholder { color: color-mix(in srgb, var(--muted) 80%, transparent); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand-1);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.18);
  background: var(--surface-solid);
}
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238792b2' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
.select option { background: var(--surface-solid); color: var(--text); }

.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { padding-left: 42px; }
.input-group__icon { position: absolute; left: 14px; color: var(--muted); display: grid; place-items: center; pointer-events: none; }
.input-group__icon svg { width: 17px; height: 17px; }
.input-group__action {
  position: absolute; right: 6px;
  width: 32px; height: 32px; display: grid; place-items: center;
  border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: var(--radius-xs);
}
.input-group__action:hover { color: var(--text); background: var(--surface-2); }
.input-group__action svg { width: 17px; height: 17px; }

.checkbox { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 13.5px; color: var(--text-2); }
.checkbox input { position: absolute; opacity: 0; pointer-events: none; }
.checkbox__box {
  width: 19px; height: 19px; flex: none; margin-top: 1px;
  border-radius: 6px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  display: grid; place-items: center;
  transition: var(--t-fast);
}
.checkbox__box svg { width: 13px; height: 13px; opacity: 0; transform: scale(0.6); transition: var(--t-fast); color: #fff; }
.checkbox input:checked + .checkbox__box { background: var(--grad-brand); border-color: transparent; }
.checkbox input:checked + .checkbox__box svg { opacity: 1; transform: scale(1); }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.switch:last-child { border-bottom: 0; }
.switch__text strong { display: block; font-size: 14px; font-weight: 600; }
.switch__text span { font-size: 12.5px; color: var(--muted); }
.switch__control {
  width: 46px; height: 26px; flex: none;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  position: relative; cursor: pointer;
  transition: var(--t);
}
.switch__control::after {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--muted);
  transition: var(--t);
}
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch input:checked + .switch__control { background: var(--grad-brand); border-color: transparent; }
.switch input:checked + .switch__control::after { transform: translateX(20px); background: #fff; }

/* --------------------------------------------------------------------------
   9. Badges, chips, avatars
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.badge--success { background: color-mix(in srgb, var(--success) 16%, transparent); color: var(--success); border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.badge--warning { background: color-mix(in srgb, var(--warning) 16%, transparent); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }
.badge--danger { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.badge--info { background: color-mix(in srgb, var(--info) 16%, transparent); color: var(--info); border-color: color-mix(in srgb, var(--info) 30%, transparent); }
.badge--brand { background: var(--grad-brand-soft); color: var(--brand-2); border-color: rgba(124, 92, 255, 0.3); }
.badge__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 12.5px;
  cursor: pointer;
  transition: var(--t-fast);
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.is-active { background: var(--grad-brand-soft); border-color: rgba(124, 92, 255, 0.4); color: var(--text); }

.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
  background: var(--grad-brand);
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 14px;
  font-family: var(--font-display);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
.avatar--xs { width: 26px; height: 26px; font-size: 10.5px; }
.avatar--sm { width: 32px; height: 32px; font-size: 12px; }
.avatar--lg { width: 56px; height: 56px; font-size: 19px; }
.avatar--xl { width: 96px; height: 96px; font-size: 32px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* --------------------------------------------------------------------------
   10. Stats & charts
   -------------------------------------------------------------------------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-4); }
.stat {
  position: relative;
  overflow: hidden;
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}
.stat::after {
  content: "";
  position: absolute; inset: 0;
  background: var(--grad-brand-soft);
  opacity: 0;
  transition: opacity var(--t);
}
.stat:hover::after { opacity: 1; }
.stat > * { position: relative; z-index: 1; }
.stat__top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.stat__icon {
  width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center;
  background: var(--grad-brand-soft);
  border: 1px solid var(--border);
  color: var(--brand-2);
}
.stat__icon svg { width: 18px; height: 18px; }
.stat__value { font-family: var(--font-display); font-size: 28px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; }
.stat__label { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.stat__delta { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; }
.stat__delta svg { width: 13px; height: 13px; }
.stat__delta.up { color: var(--success); }
.stat__delta.down { color: var(--danger); }

.chart { width: 100%; height: auto; overflow: visible; }
.chart__grid line { stroke: var(--border); stroke-dasharray: 3 5; }
.chart__label { fill: var(--muted); font-size: 10.5px; font-family: var(--font-mono); }
.chart__area { fill: url(#nexoraGrad); opacity: 0.28; }
.chart__line { fill: none; stroke: url(#nexoraStroke); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.chart__dot { fill: var(--bg-elev); stroke: var(--brand-2); stroke-width: 2.4; }
.chart__bar { fill: url(#nexoraStroke); opacity: 0.85; rx: 4; }
.chart-wrap { position: relative; }

.donut { display: grid; place-items: center; position: relative; }
.donut__center { position: absolute; text-align: center; }
.donut__value { font-family: var(--font-display); font-size: 26px; font-weight: 700; }
.donut__label { font-size: 11.5px; color: var(--muted); }

.progress { height: 8px; border-radius: var(--radius-pill); background: var(--surface-2); overflow: hidden; }
.progress__bar { height: 100%; border-radius: var(--radius-pill); background: var(--grad-brand); transition: width 700ms var(--ease); }

/* --------------------------------------------------------------------------
   11. Tables, lists, timeline
   -------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 14px 18px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background var(--t-fast); }
.table tbody tr:hover { background: var(--surface); }
.table tbody tr:last-child td { border-bottom: 0; }

.list { display: flex; flex-direction: column; }
.list__item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  transition: background var(--t-fast);
}
.list__item:last-child { border-bottom: 0; }
.list__item:hover { background: var(--surface); }
.list__title { font-size: 14px; font-weight: 600; }
.list__meta { font-size: 12px; color: var(--muted); }

.timeline { position: relative; padding-left: 26px; }
.timeline::before {
  content: "";
  position: absolute; left: 7px; top: 6px; bottom: 6px;
  width: 1px; background: var(--border);
}
.timeline__item { position: relative; padding-bottom: 20px; }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__dot {
  position: absolute; left: -26px; top: 5px;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--surface-solid);
  border: 2px solid var(--brand-1);
  box-shadow: 0 0 0 3px var(--bg);
}
.timeline__dot.is-success { border-color: var(--success); }
.timeline__dot.is-info { border-color: var(--info); }
.timeline__dot.is-warning { border-color: var(--warning); }
.timeline__dot.is-danger { border-color: var(--danger); }
.timeline__title { font-size: 13.5px; font-weight: 600; }
.timeline__time { font-size: 11.5px; color: var(--muted); font-family: var(--font-mono); }

/* --------------------------------------------------------------------------
   12. Empty state & skeletons
   -------------------------------------------------------------------------- */
.empty { text-align: center; padding: 46px 24px; }
.empty__art { width: 92px; height: 92px; margin: 0 auto 18px; border-radius: 26px; display: grid; place-items: center; background: var(--grad-brand-soft); border: 1px solid var(--border); color: var(--brand-2); }
.empty__art svg { width: 40px; height: 40px; }
.empty h3 { font-size: 16px; margin-bottom: 6px; }
.empty p { color: var(--muted); font-size: 13.5px; max-width: 380px; margin: 0 auto 18px; }

.skeleton {
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 37%, var(--surface) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.sk-line { height: 12px; margin-bottom: 10px; }
.sk-circle { border-radius: 50%; width: 40px; height: 40px; }

/* --------------------------------------------------------------------------
   13. Modal, toast, drawer
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: var(--overlay);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: grid; place-items: center;
  padding: 20px;
  animation: fadeIn 200ms var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%;
  max-width: 540px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: modalIn 280ms var(--ease);
}
.modal--lg { max-width: 720px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(18px) scale(0.97); } to { opacity: 1; transform: none; } }
.modal__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 22px 24px 0; }
.modal__title { font-size: 18px; }
.modal__desc { font-size: 13px; color: var(--muted); margin-top: 5px; }
.modal__body { padding: 20px 24px; }
.modal__foot { display: flex; justify-content: flex-end; gap: 10px; padding: 0 24px 22px; flex-wrap: wrap; }
.modal__close {
  width: 32px; height: 32px; border-radius: var(--radius-xs);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); cursor: pointer; display: grid; place-items: center;
}
.modal__close:hover { color: var(--text); background: var(--surface-2); }
.modal__close svg { width: 16px; height: 16px; }

.toast-wrap {
  position: fixed;
  right: 20px; bottom: 20px;
  z-index: 300;
  display: flex; flex-direction: column; gap: 10px;
  max-width: min(380px, calc(100vw - 40px));
}
.toast {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface-solid);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  animation: toastIn 300ms var(--ease);
}
.toast.is-out { animation: toastOut 220ms var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(24px); } }
.toast__icon { width: 22px; height: 22px; flex: none; border-radius: 50%; display: grid; place-items: center; }
.toast__icon svg { width: 14px; height: 14px; }
.toast--success .toast__icon { background: color-mix(in srgb, var(--success) 20%, transparent); color: var(--success); }
.toast--error .toast__icon { background: color-mix(in srgb, var(--danger) 20%, transparent); color: var(--danger); }
.toast--info .toast__icon { background: color-mix(in srgb, var(--info) 20%, transparent); color: var(--info); }
.toast--warning .toast__icon { background: color-mix(in srgb, var(--warning) 20%, transparent); color: var.warning); }
.toast__title { font-size: 13.5px; font-weight: 600; }
.toast__msg { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.drawer-backdrop { position: fixed; inset: 0; z-index: 190; background: var(--overlay); animation: fadeIn 180ms var(--ease); }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 195;
  width: min(400px, 92vw);
  background: var(--surface-solid);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  animation: drawerIn 280ms var(--ease);
  display: flex; flex-direction: column;
}
@keyframes drawerIn { from { transform: translateX(100%); } to { transform: none; } }
.drawer__head { padding: 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.drawer__body { padding: 16px 20px; overflow-y: auto; flex: 1; }

/* --------------------------------------------------------------------------
   14. Auth pages
   -------------------------------------------------------------------------- */
.auth {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
}
.auth__aside {
  position: relative;
  overflow: hidden;
  padding: 48px;
  display: flex; flex-direction: column; justify-content: space-between;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
}
.auth__aside-bg {
  position: absolute; inset: 0;
  background: url("../images/hero-aurora.jpg") center / cover no-repeat;
  opacity: 0.62;
  filter: saturate(1.15) contrast(1.05);
}
.auth__aside::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(6,8,15,0.30) 0%, rgba(6,8,15,0.72) 55%, rgba(6,8,15,0.95) 100%);
}
.auth__aside > *:not(.auth__aside-bg) { position: relative; z-index: 2; }
.auth__quote { max-width: 460px; }
.auth__quote h2 { font-size: 32px; line-height: 1.25; margin-bottom: 14px; }
.auth__quote p { color: var(--text-2); font-size: 15px; }
.auth__stats { display: flex; gap: 32px; flex-wrap: wrap; margin-top: 34px; }
.auth__stat strong { display: block; font-family: var(--font-display); font-size: 24px; }
.auth__stat span { font-size: 12.5px; color: var(--muted); }

.auth__panel {
  display: flex; align-items: center; justify-content: center;
  padding: 40px 32px;
  overflow-y: auto;
}
.auth__form { width: 100%; max-width: 420px; }
.auth__mobile-brand { display: none; align-items: center; gap: 12px; margin-bottom: 28px; }
.auth__mobile-brand .brand__name { font-size: 18px; }

.auth__head { margin-bottom: 26px; }
.auth__head h1 { font-size: 27px; margin-bottom: 6px; }
.auth__head p { color: var(--muted); font-size: 14px; }

.tabs { display: inline-flex; padding: 4px; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 24px; width: 100%; }
.tab {
  flex: 1; height: 36px;
  border: 0; background: transparent; color: var(--muted);
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  border-radius: var(--radius-xs);
  transition: var(--t-fast);
}
.tab.is-active { background: var(--surface-solid); color: var(--text); box-shadow: var(--shadow-sm); }

.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; margin: 20px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.alert {
  display: flex; gap: 11px;
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.5;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
}
.alert svg { width: 17px; height: 17px; flex: none; margin-top: 1px; }
.alert--info { border-color: color-mix(in srgb, var(--info) 30%, transparent); background: color-mix(in srgb, var(--info) 10%, transparent); color: var(--text-2); }
.alert--info svg { color: var(--info); }
.alert--success { border-color: color-mix(in srgb, var(--success) 30%, transparent); background: color-mix(in srgb, var(--success) 10%, transparent); }
.alert--success svg { color: var(--success); }
.alert--warning { border-color: color-mix(in srgb, var(--warning) 30%, transparent); background: color-mix(in srgb, var(--warning) 10%, transparent); }
.alert--warning svg { color: var(--warning); }
.alert--danger { border-color: color-mix(in srgb, var(--danger) 30%, transparent); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.alert--danger svg { color: var(--danger); }
.alert--brand { border-color: rgba(124, 92, 255, 0.32); background: var(--grad-brand-soft); }

/* --------------------------------------------------------------------------
   15. Profile grid + detail
   -------------------------------------------------------------------------- */
.profile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--space-4); }
.profile-card { text-align: left; cursor: pointer; }
.profile-card__top { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.profile-card__name { font-size: 15.5px; font-weight: 600; }
.profile-card__role { font-size: 12.5px; color: var(--muted); }
.profile-card__foot { display: flex; gap: 16px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted); }
.profile-card__foot span { display: inline-flex; align-items: center; gap: 5px; }
.profile-card__foot svg { width: 14px; height: 14px; }

.profile-hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 28px;
  margin-bottom: var(--space-5);
}
.profile-hero::before {
  content: "";
  position: absolute; inset: 0;
  background: var(--grad-brand-soft);
  opacity: 0.9;
}
.profile-hero__inner { position: relative; display: flex; gap: 22px; align-items: center; flex-wrap: wrap; }
.profile-hero__meta { flex: 1; min-width: 220px; }
.profile-hero__name { font-size: 23px; }
.profile-hero__role { color: var(--text-2); font-size: 14px; margin-top: 3px; }

/* --------------------------------------------------------------------------
   16. Posts
   -------------------------------------------------------------------------- */
.post-card { display: flex; flex-direction: column; gap: 12px; }
.post-card__title { font-size: 16px; font-weight: 600; }
.post-card__body { color: var(--text-2); font-size: 14px; line-height: 1.65; }
.post-card__foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.post-card__stats { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); }
.post-card__stats span { display: inline-flex; align-items: center; gap: 5px; }
.post-card__stats svg { width: 15px; height: 15px; }
.post-card__actions { display: flex; gap: 6px; }

.tag { display: inline-block; padding: 2px 9px; border-radius: var(--radius-pill); font-size: 11.5px; background: var(--surface-2); color: var(--text-2); }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: var(--space-4); }
.toolbar .input-group { flex: 1; min-width: 200px; }

/* --------------------------------------------------------------------------
   17. Misc components
   -------------------------------------------------------------------------- */
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background var(--t-fast);
}
.user-chip:hover { background: var(--surface); }
.sidebar__user { border-top: 1px solid var(--border); padding-top: 12px; }
.sidebar__user-meta { min-width: 0; }
.sidebar__user-name { font-size: 13.5px; font-weight: 600; }
.sidebar__user-mail { font-size: 11.5px; color: var(--muted); }

.dropdown { position: relative; }
.dropdown__menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 210px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 60;
  animation: modalIn 180ms var(--ease);
}
.dropdown__item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 9px 11px;
  border: 0; background: transparent; color: var(--text-2);
  font-size: 13.5px; text-align: left; cursor: pointer;
  border-radius: var(--radius-xs);
}
.dropdown__item:hover { background: var(--surface-2); color: var(--text); }
.dropdown__item svg { width: 16px; height: 16px; }
.dropdown__item--danger { color: var(--danger); }
.dropdown__sep { height: 1px; background: var(--border); margin: 6px 4px; }

.notif-item { display: flex; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--border); }
.notif-item:last-child { border-bottom: 0; }
.notif-item.is-unread .notif-item__title { color: var(--text); font-weight: 600; }
.notif-item__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand-1); margin-top: 7px; flex: none; }
.notif-item__title { font-size: 13.5px; }
.notif-item__body { font-size: 12.5px; color: var(--muted); }
.notif-item__time { font-size: 11px; color: var(--muted); font-family: var(--font-mono); margin-top: 3px; }

.kbd { font-family: var(--font-mono); font-size: 11px; padding: 2px 6px; border-radius: 5px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); }

.segmented { display: inline-flex; padding: 3px; gap: 3px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.segmented__btn { height: 30px; padding: 0 12px; border: 0; background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 600; cursor: pointer; border-radius: var(--radius-xs); }
.segmented__btn.is-active { background: var(--surface-solid); color: var(--text); }

.banner {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  border: 1px dashed rgba(124, 92, 255, 0.4);
  background: var(--grad-brand-soft);
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: var(--space-4);
}
.banner svg { width: 17px; height: 17px; color: var(--brand-2); flex: none; }
.banner strong { color: var(--text); }

/* --------------------------------------------------------------------------
   17b. Layout helpers
   -------------------------------------------------------------------------- */
.grid-dash {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
  gap: var(--space-4);
  margin-top: var(--space-4);
}
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-4);
}
.grid-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(330px, 100%), 1fr));
  gap: var(--space-4);
}
.grid-settings {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: var(--space-4);
}

/* --------------------------------------------------------------------------
   18. Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1100px) {
  .auth { grid-template-columns: 1fr; }
  .auth__aside { display: none; }
  .auth__mobile-brand { display: flex; }
  .grid-dash { grid-template-columns: minmax(0, 1fr); }
  .grid-settings { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    z-index: 195;
    transform: translateX(-100%);
    transition: transform var(--t);
    background: var(--bg-elev);
  }
  .app-shell.is-mobile-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .app-shell.is-collapsed .brand__text,
  .app-shell.is-collapsed .nav__label,
  .app-shell.is-collapsed .nav__item span,
  .app-shell.is-collapsed .nav__badge,
  .app-shell.is-collapsed .upgrade-card,
  .app-shell.is-collapsed .sidebar__user-meta { display: revert; }
  .app-shell.is-collapsed .nav__item { justify-content: flex-start; padding: 10px 12px; }
  .app-shell.is-collapsed .brand { justify-content: flex-start; }
  .sidebar-collapse { display: grid; }
  .content { padding: var(--space-5) var(--space-4) var(--space-6); }
  .topbar { padding: 0 var(--space-4); }
  .page__title { font-size: 22px; }
}

@media (max-width: 760px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .grid-form { grid-template-columns: minmax(0, 1fr); }
  .card__head { flex-wrap: wrap; }
}

@media (max-width: 640px) {
  .auth__panel { padding: 28px 18px; }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .stat__value { font-size: 24px; }
  .card { padding: var(--space-4); }
  .topbar__sub { display: none; }
  .modal__foot { flex-direction: column-reverse; }
  .modal__foot .btn { width: 100%; }
  .profile-hero { padding: 20px; }
}

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

@media print {
  .sidebar, .topbar, .toast-wrap { display: none !important; }
  .app-shell { grid-template-columns: 1fr; }
}
