/* ================================================================
   NEXAOTP V2 — main.css  (theme + components + layout, merged)
   Completely rewritten. Old V1 styles preserved in desktop backup zip.
   ================================================================ */

/* ============================================================================
   NEXAOTP V2 — "Midnight Glass" Design System
   theme.css — design tokens + reset + base layer (the foundation)
   Single unified dark theme. Mobile-first. No theme switching.
   ============================================================================ */

/* ─── 1. DESIGN TOKENS ───────────────────────────────────────────────────── */
:root {
  /* ── Brand / accent ──────────────────────────────────────────────────── */
  --c-primary:        #6366f1;   /* indigo — main brand */
  --c-primary-soft:   #818cf8;
  --c-primary-deep:   #4f46e5;
  --c-primary-glow:   rgba(99, 102, 241, 0.45);
  --c-cyan:           #22d3ee;
  --c-cyan-glow:      rgba(34, 211, 238, 0.35);
  --c-violet:         #a78bfa;
  --c-pink:           #f472b6;

  /* ── Semantic ────────────────────────────────────────────────────────── */
  --c-success:        #22c55e;
  --c-success-soft:   rgba(34, 197, 94, 0.14);
  --c-warn:           #f59e0b;
  --c-warn-soft:      rgba(245, 158, 11, 0.14);
  --c-danger:         #ef4444;
  --c-danger-soft:    rgba(239, 68, 68, 0.14);
  --c-info:           #38bdf8;
  --c-info-soft:      rgba(56, 189, 248, 0.14);

  /* ── Surfaces (deep space → glass) ───────────────────────────────────── */
  --bg:               #080c14;   /* page background, deepest */
  --bg-grad-1:        #0a0f1a;
  --bg-grad-2:        #0d1320;
  --surface-1:        rgba(255, 255, 255, 0.035);  /* glass card */
  --surface-2:        rgba(255, 255, 255, 0.055);  /* raised glass / hover */
  --surface-3:        rgba(255, 255, 255, 0.08);   /* input, active */
  --surface-solid:    #11161f;   /* opaque fallback (modals over content) */
  --surface-solid-2:  #161c28;

  /* ── Borders ─────────────────────────────────────────────────────────── */
  --border:           rgba(255, 255, 255, 0.07);
  --border-strong:    rgba(255, 255, 255, 0.12);
  --border-focus:     var(--c-primary);

  /* ── Text ────────────────────────────────────────────────────────────── */
  --text-1:           #f1f5f9;   /* primary */
  --text-2:           rgba(241, 245, 249, 0.62);  /* secondary */
  --text-3:           rgba(241, 245, 249, 0.40);  /* muted / hints */
  --text-on-accent:   #ffffff;

  /* ── Typography ──────────────────────────────────────────────────────── */
  --font-sans: 'Inter', 'Hind Siliguri', 'Noto Sans Bengali', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', ui-monospace, monospace;

  --fs-xs:    0.6875rem;  /* 11px */
  --fs-sm:    0.78rem;    /* ~12.5px */
  --fs-base:  0.875rem;   /* 14px */
  --fs-md:    1rem;       /* 16px */
  --fs-lg:    1.15rem;
  --fs-xl:    1.4rem;
  --fs-2xl:   1.75rem;
  --fs-3xl:   2.25rem;

  --fw-normal:   400;
  --fw-medium:   500;
  --fw-semibold: 600;
  --fw-bold:     700;
  --fw-black:    800;

  --lh-tight:  1.2;
  --lh-base:   1.55;
  --lh-loose:  1.7;

  /* ── Spacing scale (4px base) ────────────────────────────────────────── */
  --sp-1:  4px;
  --sp-2:  8px;
  --sp-3:  12px;
  --sp-4:  16px;
  --sp-5:  20px;
  --sp-6:  24px;
  --sp-8:  32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* ── Radii ───────────────────────────────────────────────────────────── */
  --r-sm:   8px;
  --r-md:   12px;
  --r-lg:   16px;
  --r-xl:   22px;
  --r-2xl:  28px;
  --r-pill: 999px;

  /* ── Shadows / glow ──────────────────────────────────────────────────── */
  --shadow-sm:   0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow:      0 6px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg:   0 16px 48px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 28px var(--c-primary-glow);
  --shadow-glow-cyan: 0 0 24px var(--c-cyan-glow);

  /* ── Glass effect ────────────────────────────────────────────────────── */
  --glass-blur:  blur(16px) saturate(140%);
  --glass-blur-strong: blur(24px) saturate(160%);

  /* ── Motion ──────────────────────────────────────────────────────────── */
  --ease:        cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out:    cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-fast:   0.14s var(--ease);
  --t-base:   0.22s var(--ease);
  --t-slow:   0.4s var(--ease-out);

  /* ── Layout dimensions ───────────────────────────────────────────────── */
  --topbar-h:    58px;
  --bottomnav-h: 64px;
  --sidebar-w:   248px;
  --sidebar-w-collapsed: 72px;
  --content-max: 1240px;

  /* ── Z-index scale ───────────────────────────────────────────────────── */
  --z-base:     1;
  --z-sticky:   100;
  --z-sidebar:  200;
  --z-topbar:   210;
  --z-bottomnav:220;
  --z-overlay:  900;
  --z-modal:    1000;
  --z-toast:    1100;
  --z-tooltip:  1200;

  /* ── Safe-area insets (mobile notch / home bar) ──────────────────────── */
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);

  /* color-scheme tells the browser to render native UI (scrollbars, form
     controls) in dark mode */
  color-scheme: dark;
}

/* ─── 2. RESET ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Prevent iOS tap-highlight flash */
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--text-1);
  background: var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  /* Layered ambient glow — gives the deep-space backdrop depth */
  background-image:
    radial-gradient(ellipse 80% 50% at 15% 0%,  rgba(99, 102, 241, 0.10), transparent 60%),
    radial-gradient(ellipse 70% 50% at 90% 5%,  rgba(34, 211, 238, 0.07), transparent 55%),
    radial-gradient(ellipse 90% 60% at 50% 100%, rgba(124, 58, 237, 0.06), transparent 60%);
  background-attachment: fixed;
}

img, svg, video, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
table { border-collapse: collapse; width: 100%; }

/* ─── 3. SCROLLBARS ──────────────────────────────────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: var(--r-pill);
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--border-strong); background-clip: padding-box; }

/* ─── 4. SELECTION + FOCUS ───────────────────────────────────────────────── */
::selection { background: var(--c-primary); color: var(--text-on-accent); }

:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
:focus:not(:focus-visible) { outline: none; }

/* ─── 5. TYPOGRAPHY BASE ─────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  color: var(--text-1);
  letter-spacing: -0.01em;
}
h1 { font-size: var(--fs-2xl); font-weight: var(--fw-black); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }

p  { color: var(--text-2); }
small { font-size: var(--fs-sm); color: var(--text-3); }
strong, b { font-weight: var(--fw-semibold); color: var(--text-1); }

code, kbd, pre {
  font-family: var(--font-mono);
  font-size: 0.92em;
}
code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 1px 6px;
  color: var(--c-cyan);
}

/* ─── 6. SMALL UTILITY LAYER ─────────────────────────────────────────────── */
/* Kept intentionally tiny — components.css owns real component styling.
   These are the handful of helpers used everywhere. */
.u-mono     { font-family: var(--font-mono); }
.u-muted    { color: var(--text-2); }
.u-dim      { color: var(--text-3); }
.u-center   { text-align: center; }
.u-right    { text-align: right; }
.u-nowrap   { white-space: nowrap; }
.u-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-hidden   { display: none !important; }
.u-flex     { display: flex; }
.u-flex-col { display: flex; flex-direction: column; }
.u-items-center { align-items: center; }
.u-justify-between { justify-content: space-between; }
.u-gap-1 { gap: var(--sp-1); }
.u-gap-2 { gap: var(--sp-2); }
.u-gap-3 { gap: var(--sp-3); }
.u-gap-4 { gap: var(--sp-4); }
.u-grow  { flex: 1; }
.u-wrap  { flex-wrap: wrap; }

/* Semantic text colors */
.t-primary { color: var(--c-primary-soft); }
.t-cyan    { color: var(--c-cyan); }
.t-success { color: var(--c-success); }
.t-warn    { color: var(--c-warn); }
.t-danger  { color: var(--c-danger); }

/* ─── 7. GLOBAL KEYFRAMES ────────────────────────────────────────────────── */
@keyframes nx-spin   { to { transform: rotate(360deg); } }
@keyframes nx-pulse  { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
@keyframes nx-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes nx-slide-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes nx-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ─── 8. REDUCED MOTION ──────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================================
   NEXAOTP V2 — components.css
   Reusable UI primitives. Depends on theme.css tokens.
   ============================================================================ */

/* ─── BUTTONS ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: 11px 18px; border-radius: var(--r-pill);
  font-weight: var(--fw-semibold); font-size: var(--fs-base); line-height: 1;
  white-space: nowrap; user-select: none; transition: var(--t-base);
  border: 1px solid transparent;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn i { font-size: 0.95em; }

.btn-primary { background: linear-gradient(135deg, var(--c-primary), var(--c-primary-deep)); color: #fff; box-shadow: var(--shadow-glow); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-glass   { background: var(--surface-2); border-color: var(--border-strong); color: var(--text-1); }
.btn-glass:hover { background: var(--surface-3); }
.btn-ghost   { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text-1); }
.btn-outline { background: transparent; border-color: var(--c-primary); color: var(--c-primary-soft); }
.btn-danger  { background: linear-gradient(135deg, var(--c-danger), #c0392b); color: #fff; }
.btn-success { background: linear-gradient(135deg, var(--c-success), #15803d); color: #fff; }
.btn-block   { width: 100%; }
.btn-xs      { padding: 4px 10px; font-size: var(--fs-xs); }
.btn-sm      { padding: 7px 13px; font-size: var(--fs-sm); }
.btn-lg      { padding: 14px 24px; font-size: var(--fs-md); }
.btn-icon    { padding: 0; width: 38px; height: 38px; border-radius: var(--r-md); }

.btn-loading { color: transparent !important; pointer-events: none; position: relative; }
.btn-loading::after {
  content: ''; position: absolute; width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.35); border-top-color: #fff;
  border-radius: 50%; animation: nx-spin 0.6s linear infinite;
}

/* ─── CARDS ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--sp-5);
  backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
}
.card + .card { margin-top: var(--sp-4); }
.card-hdr {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--sp-4); gap: var(--sp-3); flex-wrap: wrap;
}
.card-title {
  font-size: var(--fs-md); font-weight: var(--fw-bold); color: var(--text-1);
  display: flex; align-items: center; gap: var(--sp-2);
}
.card-title i { color: var(--c-primary-soft); }

/* ─── STAT CARDS ─────────────────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-3); }
.stat {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--sp-4);
  backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
  position: relative; overflow: hidden;
}
.stat-ico {
  width: 34px; height: 34px; border-radius: var(--r-md); display: flex;
  align-items: center; justify-content: center; font-size: 16px; margin-bottom: var(--sp-3);
  background: var(--surface-3); color: var(--c-primary-soft);
}
.stat-val {
  font-size: var(--fs-2xl); font-weight: var(--fw-black); line-height: 1;
  font-feature-settings: 'tnum'; letter-spacing: -0.02em;
}
.stat-val.grad {
  background: linear-gradient(135deg, var(--c-cyan), var(--c-primary-soft));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.stat-lbl { font-size: var(--fs-sm); color: var(--text-2); margin-top: var(--sp-1); }

/* ─── INPUTS / FIELDS ────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-2); }
.inp {
  width: 100%; padding: 12px 14px; border-radius: var(--r-md);
  background: var(--surface-3); border: 1px solid var(--border);
  color: var(--text-1); font-size: var(--fs-base); transition: var(--t-fast);
}
.inp::placeholder { color: var(--text-3); }
.inp:focus { border-color: var(--c-primary); background: var(--surface-2); outline: none;
             box-shadow: 0 0 0 3px var(--c-primary-glow); }
.inp:disabled { opacity: 0.5; }
select.inp { appearance: none; cursor: pointer;
  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='%2394a3b8' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
/* v78 FIX: native <option> popup had no explicit colors -> Chrome/Windows rendered
   white text on its default LIGHT popup bg = invisible until hover (white-on-white).
   Option popups need an OPAQUE bg (translucent rgba is ignored by the OS popup). */
select.inp option, .inp option {
  background-color: var(--surface-solid);
  color: var(--text-1);
}
select.inp option:checked, select.inp option:hover {
  background-color: var(--c-primary);
  color: var(--text-on-accent, #fff);
}

.inp-group { position: relative; }
.inp-group .inp-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.inp-group .inp { padding-left: 40px; }

/* ─── CHIPS / BADGES ─────────────────────────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px;
  border-radius: var(--r-pill); font-size: var(--fs-sm); font-weight: var(--fw-semibold);
  white-space: nowrap;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.chip-success { background: var(--c-success-soft); color: var(--c-success); }
.chip-warn    { background: var(--c-warn-soft);    color: var(--c-warn); }
.chip-danger  { background: var(--c-danger-soft);  color: var(--c-danger); }
.chip-info    { background: var(--c-info-soft);    color: var(--c-info); }
.chip-primary { background: rgba(99,102,241,0.14); color: var(--c-primary-soft); }
.chip-warn .dot { animation: nx-pulse 1.4s ease-in-out infinite; }

/* ─── AVATAR ─────────────────────────────────────────────────────────────── */
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: var(--fw-bold); font-size: var(--fs-base); color: #fff;
  background: linear-gradient(135deg, var(--c-primary), var(--c-cyan));
}
.avatar-sm { width: 30px; height: 30px; font-size: var(--fs-sm); }
.avatar-lg { width: 56px; height: 56px; font-size: var(--fs-lg); }

/* ─── SPINNER ────────────────────────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px; border: 2px solid var(--surface-3);
  border-top-color: var(--c-primary); border-radius: 50%;
  animation: nx-spin 0.7s linear infinite; display: inline-block;
}
.spinner-lg { width: 34px; height: 34px; border-width: 3px; }

/* ─── SKELETON ───────────────────────────────────────────────────────────── */
.skel {
  background: linear-gradient(90deg, var(--surface-1) 25%, var(--surface-2) 50%, var(--surface-1) 75%);
  background-size: 200% 100%; animation: nx-shimmer 1.4s linear infinite;
  border-radius: var(--r-md);
}
.skel-line { height: 14px; margin-bottom: 8px; }
.skel-card { height: 80px; margin-bottom: var(--sp-3); }

/* ─── SEGMENTED TABS / PILL TABS ─────────────────────────────────────────── */
.seg {
  display: inline-flex; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--r-pill); padding: 4px; gap: 2px;
}
.seg-btn {
  padding: 7px 16px; border-radius: var(--r-pill); font-size: var(--fs-sm);
  font-weight: var(--fw-semibold); color: var(--text-2); transition: var(--t-fast);
}
.seg-btn.active { background: var(--c-primary); color: #fff; box-shadow: var(--shadow-sm); }

/* ─── TABLE ──────────────────────────────────────────────────────────────── */
.tbl { width: 100%; font-size: var(--fs-sm); }
.tbl th { text-align: left; color: var(--text-3); font-weight: var(--fw-semibold);
          font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.05em;
          padding: 0 var(--sp-3) var(--sp-2); }
.tbl td { padding: var(--sp-3); border-top: 1px solid var(--border); color: var(--text-1); vertical-align: middle; }
.tbl tr:hover td { background: var(--surface-1); }
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--r-md); }

/* ─── LIST ROW ───────────────────────────────────────────────────────────── */
.lrow {
  display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border);
}
.lrow:last-child { border-bottom: none; }

/* ─── TOGGLE SWITCH ──────────────────────────────────────────────────────── */
.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; background: var(--surface-3); border: 1px solid var(--border);
  border-radius: var(--r-pill); transition: var(--t-base); cursor: pointer;
}
.switch .track::before {
  content: ''; position: absolute; height: 18px; width: 18px; left: 3px; top: 50%;
  transform: translateY(-50%); background: var(--text-2); border-radius: 50%; transition: var(--t-base);
}
.switch input:checked + .track { background: var(--c-primary); border-color: var(--c-primary); }
.switch input:checked + .track::before { transform: translateY(-50%) translateX(18px); background: #fff; }

/* ─── PROGRESS ───────────────────────────────────────────────────────────── */
.progress { height: 6px; background: var(--surface-3); border-radius: var(--r-pill); overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--c-primary), var(--c-cyan));
                 border-radius: var(--r-pill); transition: width var(--t-slow); }

/* ─── ALERT ──────────────────────────────────────────────────────────────── */
.alert {
  display: flex; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md);
  font-size: var(--fs-sm); line-height: var(--lh-base); border: 1px solid var(--border);
  background: var(--surface-1); color: var(--text-2);
}
.alert i { flex-shrink: 0; margin-top: 2px; }
.alert-info   { background: var(--c-info-soft);    border-color: rgba(56,189,248,0.25); }
.alert-warn   { background: var(--c-warn-soft);    border-color: rgba(245,158,11,0.25); }
.alert-danger { background: var(--c-danger-soft);  border-color: rgba(239,68,68,0.25); }
.alert-success{ background: var(--c-success-soft); border-color: rgba(34,197,94,0.25); }

/* ─── EMPTY STATE ────────────────────────────────────────────────────────── */
.empty { text-align: center; padding: var(--sp-12) var(--sp-4); color: var(--text-3); }
.empty i { font-size: 2.4rem; opacity: 0.3; display: block; margin-bottom: var(--sp-3); }
.empty-title { font-size: var(--fs-md); color: var(--text-2); font-weight: var(--fw-semibold); }
.empty-sub { font-size: var(--fs-sm); margin-top: 4px; }

/* ─── MODAL ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: var(--z-modal);
  background: rgba(4, 7, 12, 0.7); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: flex-end; justify-content: center;
  padding: var(--sp-4); animation: nx-fade-in 0.2s var(--ease);
}
@media (min-width: 640px) { .modal-overlay { align-items: center; } }
.modal-card {
  background: var(--surface-solid); border: 1px solid var(--border-strong);
  border-radius: var(--r-xl); width: 100%; max-width: 460px; max-height: 88vh;
  overflow-y: auto; box-shadow: var(--shadow-lg);
  animation: nx-slide-up 0.3s var(--ease-out);
  padding-bottom: calc(var(--sp-5) + var(--safe-bottom));
}
.modal-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-5) var(--sp-5) var(--sp-3); position: sticky; top: 0;
  background: var(--surface-solid); z-index: 1;
}
.modal-hdr h3 { font-size: var(--fs-lg); }
.modal-close { width: 34px; height: 34px; border-radius: var(--r-md); color: var(--text-2);
               display: flex; align-items: center; justify-content: center; transition: var(--t-fast); }
.modal-close:hover { background: var(--surface-2); color: var(--text-1); }
.modal-body { padding: 0 var(--sp-5) var(--sp-5); }

/* ─── TOAST ──────────────────────────────────────────────────────────────── */
#toastHost {
  position: fixed; left: 50%; transform: translateX(-50%);
  top: calc(var(--safe-top) + var(--sp-3)); z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: var(--sp-2); width: calc(100% - var(--sp-8)); max-width: 420px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md); font-size: var(--fs-sm); font-weight: var(--fw-medium);
  background: var(--surface-solid-2); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg); color: var(--text-1); pointer-events: auto;
  animation: nx-slide-up 0.3s var(--ease-out); backdrop-filter: var(--glass-blur-strong);
}
.toast i { flex-shrink: 0; font-size: 1.05rem; }
.toast.success i { color: var(--c-success); }
.toast.error i   { color: var(--c-danger); }
.toast.warn i    { color: var(--c-warn); }
.toast.info i    { color: var(--c-info); }
.toast.hide { animation: nx-fade-in 0.2s var(--ease) reverse forwards; }

/* ─── DIVIDER ────────────────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: var(--sp-4) 0; border: none; }

/* ============================================================================
   NEXAOTP V2 — layout.css
   App shell. Mobile-first: top bar + bottom nav. Desktop (>=900px): sidebar.
   ============================================================================ */

/* ─── APP SHELL ──────────────────────────────────────────────────────────── */
#app { display: none; }
#app.show { display: block; }

.app-shell { min-height: 100vh; min-height: 100dvh; }
.main-col { min-width: 0; overflow-x: hidden; }

/* ─── TOP BAR ────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: var(--z-topbar);
  height: calc(var(--topbar-h) + var(--safe-top)); padding-top: var(--safe-top);
  display: flex; align-items: center; gap: var(--sp-3);
  padding-left: var(--sp-4); padding-right: var(--sp-4);
  background: rgba(8, 12, 20, 0.72); backdrop-filter: var(--glass-blur-strong);
  -webkit-backdrop-filter: var(--glass-blur-strong); border-bottom: 1px solid var(--border);
}
.topbar-brand { display: flex; align-items: center; gap: var(--sp-2); font-weight: var(--fw-black); font-size: var(--fs-md); }
.topbar-logo {
  width: 32px; height: 32px; border-radius: var(--r-md); display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--c-primary), var(--c-cyan)); box-shadow: var(--shadow-glow); font-size: 16px;
}
.topbar-title { font-size: var(--fs-md); font-weight: var(--fw-bold); }
.topbar-spacer { flex: 1; }

.bal-pill {
  display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: var(--r-pill);
  background: var(--surface-2); border: 1px solid var(--border); font-weight: var(--fw-bold);
  font-size: var(--fs-sm); color: var(--c-cyan); font-feature-settings: 'tnum';
}
.topbar-icon-btn {
  width: 38px; height: 38px; border-radius: var(--r-md); position: relative;
  display: flex; align-items: center; justify-content: center; color: var(--text-2); transition: var(--t-fast);
}
.topbar-icon-btn:hover { background: var(--surface-2); color: var(--text-1); }
.notif-badge {
  position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: var(--r-pill); background: var(--c-danger); color: #fff;
  font-size: 9px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}

/* ─── PAGE CONTENT ───────────────────────────────────────────────────────── */
.page {
  max-width: var(--content-max); margin: 0 auto;
  padding: var(--sp-5) var(--sp-4);
  padding-bottom: calc(var(--bottomnav-h) + var(--safe-bottom) + var(--sp-6));
  animation: nx-fade-in 0.3s var(--ease);
}
.pg-hdr { margin-bottom: var(--sp-5); }
.pg-hdr h1 { font-size: var(--fs-xl); display: flex; align-items: center; gap: var(--sp-2); }
.pg-hdr h1 i { color: var(--c-primary-soft); }
.pg-sub { font-size: var(--fs-sm); color: var(--text-2); margin-top: 4px; }
.pg-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

/* ─── BOTTOM NAV (mobile) ────────────────────────────────────────────────── */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-bottomnav);
  height: calc(var(--bottomnav-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
  display: flex; align-items: stretch;
  background: rgba(8, 12, 20, 0.82); backdrop-filter: var(--glass-blur-strong);
  -webkit-backdrop-filter: var(--glass-blur-strong); border-top: 1px solid var(--border);
}
.bn-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-3); font-size: 10px; font-weight: var(--fw-semibold); transition: var(--t-fast);
  position: relative; padding-top: 4px;
}
.bn-item i { font-size: 19px; transition: var(--t-fast); }
.bn-item.active { color: var(--c-primary-soft); }
.bn-item.active i { transform: translateY(-1px); filter: drop-shadow(0 0 8px var(--c-primary-glow)); }
.bn-item.active::before {
  content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 28px; height: 3px; border-radius: var(--r-pill); background: var(--c-primary);
}
.bn-fab {
  flex: 0 0 auto; margin: 0 var(--sp-1);
}
.bn-fab-btn {
  width: 52px; height: 52px; border-radius: 50%; margin-top: -16px;
  background: linear-gradient(135deg, var(--c-primary), var(--c-primary-deep));
  box-shadow: var(--shadow-glow); display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 22px; border: 3px solid var(--bg); transition: var(--t-base);
}
.bn-fab-btn:active { transform: scale(0.92); }

/* ─── SIDEBAR (desktop) ──────────────────────────────────────────────────── */
.sidebar { display: none; }
.side-overlay { display: none; }

/* ─── USER DROPDOWN MENU ─────────────────────────────────────────────────── */
.menu-sheet {
  position: fixed; inset: 0; z-index: var(--z-overlay); display: none;
  background: rgba(4,7,12,0.6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.menu-sheet.show { display: block; animation: nx-fade-in 0.2s var(--ease); }
.menu-panel {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: var(--surface-solid); border-top-left-radius: var(--r-2xl); border-top-right-radius: var(--r-2xl);
  border-top: 1px solid var(--border-strong); padding: var(--sp-3) var(--sp-3) calc(var(--sp-5) + var(--safe-bottom));
  animation: nx-slide-up 0.3s var(--ease-out); box-shadow: var(--shadow-lg);
  /* Scroll when menu has many items — never overflow the viewport */
  max-height: 85vh; max-height: 85dvh; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.menu-grab { width: 40px; height: 4px; border-radius: var(--r-pill); background: var(--border-strong); margin: 6px auto var(--sp-4); }
.menu-item {
  display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md); color: var(--text-1); font-weight: var(--fw-medium); transition: var(--t-fast);
}
.menu-item:hover { background: var(--surface-2); }
.menu-item i { width: 22px; text-align: center; color: var(--text-2); }
.menu-item.danger { color: var(--c-danger); } .menu-item.danger i { color: var(--c-danger); }

/* ════════════════════════════════════════════════════════════════════════
   DESKTOP — sidebar layout kicks in at 900px
   ════════════════════════════════════════════════════════════════════════ */
@media (min-width: 900px) {
  .bottom-nav { display: none; }

  .app-shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; }

  .sidebar {
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; height: 100dvh;
    width: var(--sidebar-w); background: rgba(10, 14, 24, 0.6); backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur); border-right: 1px solid var(--border);
    padding: var(--sp-4) var(--sp-3); z-index: var(--z-sidebar); overflow-y: auto;
  }
  .side-brand { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3) var(--sp-5); }
  .side-brand .topbar-logo { width: 38px; height: 38px; }
  .side-brand b { font-size: var(--fs-lg); font-weight: var(--fw-black); }

  .side-sec { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-3);
              font-weight: var(--fw-bold); padding: var(--sp-4) var(--sp-3) var(--sp-2); }
  .side-link {
    display: flex; align-items: center; gap: var(--sp-3); padding: 10px var(--sp-3); border-radius: var(--r-md);
    color: var(--text-2); font-weight: var(--fw-medium); font-size: var(--fs-base); transition: var(--t-fast);
    margin-bottom: 2px;
  }
  .side-link i { width: 20px; text-align: center; font-size: 16px; }
  .side-link:hover { background: var(--surface-2); color: var(--text-1); }
  .side-link.active { background: rgba(99,102,241,0.14); color: var(--c-primary-soft); }
  .side-link.active i { color: var(--c-primary-soft); }

  .side-foot { margin-top: auto; padding-top: var(--sp-4); }

  /* Topbar loses brand on desktop (sidebar has it); content area gets the topbar */
  .topbar { position: sticky; }
  .topbar-brand-mobile { display: none; }

  .page { padding: var(--sp-6) var(--sp-8); padding-bottom: var(--sp-10); }

  /* menu-sheet becomes a dropdown anchored top-right on desktop */
  .menu-sheet.show { background: transparent; }
  .menu-panel {
    position: absolute; top: calc(var(--topbar-h) + 6px); right: var(--sp-6); left: auto; bottom: auto;
    width: 240px; border-radius: var(--r-lg); border: 1px solid var(--border-strong);
    animation: nx-slide-up 0.2s var(--ease-out);
  }
  .menu-grab { display: none; }
}

@media (min-width: 1200px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}
