/* ==========================================================================
   NEOX CRM by CodeFier — design system
   Electric blue on charcoal. Dark-first, with a full light theme.
   Tokens → primitives → layout → components → utilities → responsive
   ========================================================================== */

/* ----------------------------------------------------------- 1. Tokens */

:root {
  /* Brand */
  --blue-50:  #eaf1ff;
  --blue-100: #cfe0ff;
  --blue-200: #a3c3ff;
  --blue-300: #6f9cff;
  --blue-400: #4a80ff;
  --blue-500: #2f6bff;   /* primary */
  --blue-600: #1c53e6;
  --blue-700: #1440b4;
  --blue-800: #0f2f82;
  --cyan-400: #22d3ee;
  --cyan-500: #00c2e8;

  /* Semantic */
  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, .14);
  --warning: #f5a524;
  --warning-soft: rgba(245, 165, 36, .14);
  --danger:  #f45b69;
  --danger-soft: rgba(244, 91, 105, .14);
  --info:    #38bdf8;
  --info-soft: rgba(56, 189, 248, .14);
  --purple:  #8b5cf6;
  --purple-soft: rgba(139, 92, 246, .14);
  --teal:    #00c2a8;
  --teal-soft: rgba(0, 194, 168, .14);
  --orange:  #fb923c;
  --orange-soft: rgba(251, 146, 60, .14);
  --primary-soft: rgba(47, 107, 255, .14);
  --muted-soft: rgba(148, 163, 184, .14);

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --fs-xs: .6875rem;   /* 11 */
  --fs-sm: .75rem;     /* 12 */
  --fs-md: .8125rem;   /* 13 */
  --fs-base: .875rem;  /* 14 */
  --fs-lg: 1rem;       /* 16 */
  --fs-xl: 1.125rem;   /* 18 */
  --fs-2xl: 1.375rem;  /* 22 */
  --fs-3xl: 1.75rem;   /* 28 */
  --fs-4xl: 2.25rem;   /* 36 */

  /* Spacing scale (4px rhythm) */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-7: 32px; --sp-8: 40px; --sp-9: 56px;

  /* Radius */
  --r-xs: 6px; --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 22px; --r-full: 999px;

  /* Layout */
  --sidebar-w: 258px;
  --sidebar-w-collapsed: 76px;
  --topbar-h: 64px;
  --bottomnav-h: 62px;
  --content-max: 1600px;

  --transition: 180ms cubic-bezier(.4, 0, .2, 1);
  --transition-slow: 320ms cubic-bezier(.4, 0, .2, 1);
}

/* Dark (default) */
:root,
[data-theme='dark'] {
  --bg:            #0b0e15;
  --bg-grad:       radial-gradient(1200px 620px at 12% -8%, rgba(47,107,255,.16), transparent 62%),
                   radial-gradient(900px 520px at 100% 0%, rgba(0,194,232,.10), transparent 58%);
  --surface:       #12161f;
  --surface-2:     #171c28;
  --surface-3:     #1d2331;
  --surface-hover: #1f2635;
  --border:        #252c3b;
  --border-soft:   #1c2230;
  --border-strong: #333d52;

  --text:      #eef2f9;
  --text-2:    #a8b3c7;
  --text-3:    #6f7c93;
  --text-on-brand: #ffffff;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.36);
  --shadow-md: 0 6px 20px rgba(0,0,0,.40);
  --shadow-lg: 0 20px 48px rgba(0,0,0,.52);
  --glow: 0 0 0 3px rgba(47,107,255,.22);

  --sidebar-bg: #0d111a;
  --topbar-bg: rgba(18,22,31,.86);
  --skeleton: linear-gradient(90deg, #171c28 25%, #202839 37%, #171c28 63%);
  color-scheme: dark;
}

/* Light */
[data-theme='light'] {
  --bg:            #f5f7fc;
  --bg-grad:       radial-gradient(1100px 560px at 10% -10%, rgba(47,107,255,.10), transparent 60%),
                   radial-gradient(800px 420px at 100% 0%, rgba(0,194,232,.08), transparent 56%);
  --surface:       #ffffff;
  --surface-2:     #ffffff;
  --surface-3:     #f2f5fb;
  --surface-hover: #eef2fa;
  --border:        #dfe5f0;
  --border-soft:   #eaeff7;
  --border-strong: #c6d0e2;

  --text:      #0d1220;
  --text-2:    #4a556b;
  --text-3:    #7b869c;
  --text-on-brand: #ffffff;

  --shadow-sm: 0 1px 2px rgba(16,24,40,.06);
  --shadow-md: 0 8px 24px rgba(16,24,40,.09);
  --shadow-lg: 0 24px 56px rgba(16,24,40,.14);
  --glow: 0 0 0 3px rgba(47,107,255,.18);

  --sidebar-bg: #ffffff;
  --topbar-bg: rgba(255,255,255,.88);
  --skeleton: linear-gradient(90deg, #eef1f7 25%, #f7f9fd 37%, #eef1f7 63%);
  color-scheme: light;
}

/* ----------------------------------------------------------- 2. Base */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.55;
  color: var(--text);
  background-color: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 650; letter-spacing: -.015em; color: var(--text); }
h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-xl); }
h4 { font-size: var(--fs-lg); }
p  { margin: 0 0 var(--sp-3); }
p:last-child { margin-bottom: 0; }

a { color: var(--blue-400); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--blue-300); }

hr { border: 0; border-top: 1px solid var(--border); margin: var(--sp-5) 0; opacity: 1; }

::selection { background: var(--blue-500); color: #fff; }

:focus-visible {
  outline: 2px solid var(--blue-400);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--r-full); border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; }

/* ----------------------------------------------------------- 3. Layout */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}
.app-shell.is-collapsed { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }

/* --- Sidebar --- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 60;
  transition: width var(--transition);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  height: var(--topbar-h);
  padding: 0 var(--sp-5);
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
  overflow: hidden;
}
.brand-mark {
  width: 34px; height: 34px; flex-shrink: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--blue-500), var(--cyan-500));
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: var(--fs-base);
  letter-spacing: -.04em;
  box-shadow: 0 4px 14px rgba(47,107,255,.4);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-name { font-weight: 750; font-size: var(--fs-lg); letter-spacing: -.03em; white-space: nowrap; }
.brand-sub  { font-size: var(--fs-xs); color: var(--text-3); letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }

.sidebar-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: var(--sp-4) var(--sp-3) var(--sp-6); }

.nav-section { margin-bottom: var(--sp-5); }
.nav-label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-3);
  font-weight: 600;
  padding: 0 var(--sp-3);
  margin-bottom: var(--sp-2);
  white-space: nowrap;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 9px var(--sp-3);
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-weight: 500;
  font-size: var(--fs-base);
  margin-bottom: 2px;
  position: relative;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
}
.nav-item i { font-size: 1.05rem; width: 20px; text-align: center; flex-shrink: 0; }
.nav-item span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--blue-300); font-weight: 600; }
[data-theme='light'] .nav-item.active { color: var(--blue-600); }
.nav-item.active::before {
  content: ''; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--blue-500);
}
.nav-item .nav-count {
  margin-left: auto;
  background: var(--danger); color: #fff;
  font-size: var(--fs-xs); font-weight: 700;
  min-width: 19px; height: 19px; padding: 0 5px;
  border-radius: var(--r-full);
  display: grid; place-items: center;
}
.nav-item .nav-count.is-quiet { background: var(--muted-soft); color: var(--text-2); }

.sidebar-footer { padding: var(--sp-3); border-top: 1px solid var(--border-soft); flex-shrink: 0; }

.is-collapsed .sidebar .brand-text,
.is-collapsed .sidebar .nav-label,
.is-collapsed .sidebar .nav-item span,
.is-collapsed .sidebar .nav-count,
.is-collapsed .sidebar .user-mini-text { display: none; }
.is-collapsed .sidebar .nav-item { justify-content: center; padding: 10px; }
.is-collapsed .sidebar-brand { justify-content: center; padding: 0; }

.user-mini {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  transition: background var(--transition);
}
.user-mini:hover { background: var(--surface-hover); }
.user-mini-text { min-width: 0; line-height: 1.25; }
.user-mini-name { font-weight: 600; font-size: var(--fs-md); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-mini-role { font-size: var(--fs-xs); color: var(--text-3); white-space: nowrap; }

/* --- Main column --- */
.main-col { display: flex; flex-direction: column; min-width: 0; min-height: 100vh; min-height: 100dvh; }

.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 0 var(--sp-6);
  background: var(--topbar-bg);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.icon-btn {
  width: 38px; height: 38px; flex-shrink: 0;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--r-sm);
  color: var(--text-2);
  display: grid; place-items: center;
  font-size: 1.05rem;
  cursor: pointer;
  position: relative;
  transition: all var(--transition);
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn.has-dot::after {
  content: ''; position: absolute; top: 7px; right: 8px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger); border: 2px solid var(--surface);
}

.topbar-search { position: relative; flex: 1; max-width: 460px; }
.topbar-search i {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); font-size: .95rem; pointer-events: none;
}
.topbar-search input {
  width: 100%; height: 40px;
  padding: 0 var(--sp-4) 0 38px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: var(--fs-base);
  font-family: inherit;
  transition: all var(--transition);
}
.topbar-search input::placeholder { color: var(--text-3); }
.topbar-search input:focus { outline: none; border-color: var(--blue-500); box-shadow: var(--glow); background: var(--surface); }

.topbar-spacer { flex: 1; }

.page-body {
  flex: 1;
  padding: var(--sp-6);
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  min-width: 0;
}

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--sp-4); flex-wrap: wrap;
  margin-bottom: var(--sp-5);
}
.page-title { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.page-title h1 { font-size: var(--fs-3xl); line-height: 1.2; }
.page-title .sub { color: var(--text-3); font-size: var(--fs-base); }
.page-actions { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }

.breadcrumb-mini { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--text-3); margin-bottom: 2px; }
.breadcrumb-mini a { color: var(--text-3); }
.breadcrumb-mini a:hover { color: var(--blue-400); }

/* ----------------------------------------------------------- 4. Cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card + .card { margin-top: var(--sp-4); }

.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border-soft);
  min-height: 58px;
  flex-wrap: wrap;
}
.card-head h3, .card-head h2 { font-size: var(--fs-lg); font-weight: 650; }
.card-head .sub { font-size: var(--fs-sm); color: var(--text-3); font-weight: 400; }
.card-body { padding: var(--sp-5); }
.card-body.tight { padding: var(--sp-4); }
.card-body.flush { padding: 0; }
.card-foot { padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--border-soft); background: var(--surface-3); }

/* Stat cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.stat-card::after {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, var(--accent, var(--blue-500)), transparent);
  opacity: .9;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.stat-top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.stat-label { font-size: var(--fs-sm); color: var(--text-3); font-weight: 550; text-transform: uppercase; letter-spacing: .06em; }
.stat-icon {
  width: 38px; height: 38px; border-radius: var(--r-sm);
  display: grid; place-items: center; font-size: 1.1rem;
  background: var(--accent-soft, var(--primary-soft)); color: var(--accent, var(--blue-400));
  flex-shrink: 0;
}
.stat-value { font-size: var(--fs-3xl); font-weight: 720; letter-spacing: -.03em; line-height: 1.1; }
.stat-meta { display: flex; align-items: center; gap: 6px; margin-top: var(--sp-2); font-size: var(--fs-sm); color: var(--text-3); flex-wrap: wrap; }
.trend { display: inline-flex; align-items: center; gap: 3px; font-weight: 650; }
.trend.up { color: var(--success); }
.trend.down { color: var(--danger); }
.trend.flat { color: var(--text-3); }

/* Layout grids */
.grid { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main-side { grid-template-columns: minmax(0, 1fr) 360px; }
.grid-side-main { grid-template-columns: 320px minmax(0, 1fr); }

/* ----------------------------------------------------------- 5. Buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 var(--sp-4);
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  font-family: inherit; font-size: var(--fs-base); font-weight: 600;
  line-height: 1; white-space: nowrap;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}
.btn:disabled, .btn.disabled { opacity: .55; pointer-events: none; }
.btn i { font-size: 1rem; }

.btn-primary { background: var(--blue-500); color: #fff; box-shadow: 0 2px 10px rgba(47,107,255,.32); }
.btn-primary:hover { background: var(--blue-600); color: #fff; transform: translateY(-1px); box-shadow: 0 6px 18px rgba(47,107,255,.42); }
.btn-primary:active { transform: translateY(0); }

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

.btn-soft { background: var(--primary-soft); color: var(--blue-400); }
.btn-soft:hover { background: var(--blue-500); color: #fff; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.06); color: #fff; }
.btn-danger-soft { background: var(--danger-soft); color: var(--danger); }
.btn-danger-soft:hover { background: var(--danger); color: #fff; }

.btn-success { background: var(--success); color: #04210f; }
.btn-success:hover { filter: brightness(1.06); color: #04210f; }

.btn-sm { height: 32px; padding: 0 var(--sp-3); font-size: var(--fs-md); }
.btn-xs { height: 27px; padding: 0 10px; font-size: var(--fs-sm); border-radius: var(--r-xs); }
.btn-lg { height: 46px; padding: 0 var(--sp-6); font-size: var(--fs-lg); }
.btn-block { width: 100%; }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn-icon.btn-xs { width: 27px; }

.btn-group { display: inline-flex; border: 1px solid var(--border); border-radius: var(--r-sm); overflow: hidden; }
.btn-group .btn { border-radius: 0; border: 0; border-right: 1px solid var(--border); height: 34px; }
.btn-group .btn:last-child { border-right: 0; }
.btn-group .btn.active { background: var(--primary-soft); color: var(--blue-400); }

/* ----------------------------------------------------------- 6. Forms */

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.full { grid-column: 1 / -1; }

.label {
  font-size: var(--fs-md); font-weight: 600; color: var(--text-2);
  display: flex; align-items: center; gap: 5px;
}
.label .req { color: var(--danger); }
.hint { font-size: var(--fs-sm); color: var(--text-3); }
.err { font-size: var(--fs-sm); color: var(--danger); display: flex; align-items: center; gap: 4px; }

.input, .select, .textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px var(--sp-3);
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: inherit;
  font-size: var(--fs-base);
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  appearance: none;
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.6; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--blue-500); background: var(--surface); box-shadow: var(--glow);
}
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--danger); }
.input:disabled, .select:disabled, .textarea:disabled { opacity: .6; cursor: not-allowed; }

.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236f7c93' d='M6 8 0 1.4 1.4 0 6 4.8 10.6 0 12 1.4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 34px;
  cursor: pointer;
}

.input-group { display: flex; align-items: stretch; }
.input-group .input { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.input-group .addon {
  display: grid; place-items: center; padding: 0 var(--sp-3);
  background: var(--surface-hover); border: 1px solid var(--border); border-left: 0;
  border-radius: 0 var(--r-sm) var(--r-sm) 0; color: var(--text-3); font-size: var(--fs-md); font-weight: 600;
  white-space: nowrap;
}

.check { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; font-size: var(--fs-base); color: var(--text-2); }
.check input[type='checkbox'], .check input[type='radio'] {
  width: 17px; height: 17px; margin: 1px 0 0; flex-shrink: 0;
  accent-color: var(--blue-500); cursor: pointer;
}

.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--border-strong); border-radius: var(--r-full);
  transition: var(--transition);
}
.switch .slider::before {
  content: ''; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%; transition: var(--transition);
}
.switch input:checked + .slider { background: var(--blue-500); }
.switch input:checked + .slider::before { transform: translateX(18px); }

.file-drop {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-md);
  padding: var(--sp-6);
  text-align: center;
  color: var(--text-3);
  cursor: pointer;
  transition: all var(--transition);
  background: var(--surface-3);
}
.file-drop:hover, .file-drop.dragover { border-color: var(--blue-500); background: var(--primary-soft); color: var(--blue-300); }
.file-drop i { font-size: 1.7rem; display: block; margin-bottom: var(--sp-2); }

/* ----------------------------------------------------------- 7. Chips & badges */

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border-radius: var(--r-full);
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}
.chip i { font-size: .8rem; }
.chip-primary { background: var(--primary-soft); color: var(--blue-400); }
.chip-success { background: var(--success-soft); color: var(--success); }
.chip-warning { background: var(--warning-soft); color: var(--warning); }
.chip-danger  { background: var(--danger-soft);  color: var(--danger); }
.chip-info    { background: var(--info-soft);    color: var(--info); }
.chip-purple  { background: var(--purple-soft);  color: var(--purple); }
.chip-teal    { background: var(--teal-soft);    color: var(--teal); }
.chip-orange  { background: var(--orange-soft);  color: var(--orange); }
.chip-muted   { background: var(--muted-soft);   color: var(--text-3); }
[data-theme='light'] .chip-primary { color: var(--blue-600); }

.pill-tabs { display: flex; gap: 4px; background: var(--surface-3); padding: 4px; border-radius: var(--r-md); overflow-x: auto; }
.pill-tabs a, .pill-tabs button {
  padding: 7px var(--sp-4); border-radius: var(--r-sm);
  font-size: var(--fs-md); font-weight: 600; color: var(--text-2);
  border: 0; background: transparent; cursor: pointer; white-space: nowrap;
  transition: all var(--transition);
}
.pill-tabs a:hover, .pill-tabs button:hover { color: var(--text); background: var(--surface-hover); }
.pill-tabs a.active, .pill-tabs button.active { background: var(--surface); color: var(--blue-400); box-shadow: var(--shadow-sm); }

/* Avatars */
.avatar {
  width: 36px; height: 36px; flex-shrink: 0;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: var(--fs-md); font-weight: 700; color: #fff;
  object-fit: cover;
  letter-spacing: -.02em;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-xs { width: 24px; height: 24px; font-size: var(--fs-xs); }
.avatar-sm { width: 30px; height: 30px; font-size: var(--fs-xs); }
.avatar-lg { width: 52px; height: 52px; font-size: var(--fs-lg); }
.avatar-xl { width: 84px; height: 84px; font-size: var(--fs-2xl); }
.avatar-stack { display: flex; }
.avatar-stack .avatar { margin-left: -9px; border: 2px solid var(--surface); }
.avatar-stack .avatar:first-child { margin-left: 0; }

.user-cell { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.user-cell-text { min-width: 0; line-height: 1.3; }
.user-cell-name { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-cell-sub { font-size: var(--fs-sm); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ----------------------------------------------------------- 8. Tables */

.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-base); }
.table th {
  text-align: left;
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-sm);
  font-weight: 650;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .06em;
  background: var(--surface-3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky; top: 0; z-index: 2;
}
.table th a { color: inherit; display: inline-flex; align-items: center; gap: 4px; }
.table th a:hover { color: var(--blue-400); }
.table td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
  color: var(--text-2);
}
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: var(--surface-hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td strong, .table td .strong { color: var(--text); font-weight: 600; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .btn { margin-left: 4px; }
.table-fixed { table-layout: fixed; }
.table tr.is-clickable { cursor: pointer; }

.table-compact td, .table-compact th { padding: 9px var(--sp-3); }

/* ----------------------------------------------------------- 9. Filters */

.filter-bar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin-bottom: var(--sp-4);
}
.filter-item { display: flex; flex-direction: column; gap: 4px; min-width: 140px; flex: 1 1 150px; }
.filter-item.grow { flex: 2 1 220px; }
.filter-item .label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }
.filter-item .input, .filter-item .select { height: 36px; min-height: 36px; font-size: var(--fs-md); }
.filter-actions { display: flex; gap: var(--sp-2); align-items: center; flex-shrink: 0; }

.active-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--sp-4); }
.active-filters .chip a { color: inherit; opacity: .7; display: inline-flex; }
.active-filters .chip a:hover { opacity: 1; }

/* ----------------------------------------------------------- 10. Kanban */

.kanban {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(288px, 1fr);
  gap: var(--sp-4);
  overflow-x: auto;
  padding-bottom: var(--sp-4);
  align-items: start;
}
.kanban-col {
  background: var(--surface-3);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  display: flex; flex-direction: column;
  max-height: calc(100vh - 260px);
  min-height: 200px;
}
.kanban-col-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-soft);
  position: sticky; top: 0; background: var(--surface-3); z-index: 2;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.kanban-col-title { display: flex; align-items: center; gap: 7px; font-weight: 650; font-size: var(--fs-md); }
.kanban-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.kanban-count { background: var(--surface); color: var(--text-3); font-size: var(--fs-xs); font-weight: 700; padding: 2px 7px; border-radius: var(--r-full); }
.kanban-total { font-size: var(--fs-sm); color: var(--text-3); font-weight: 600; }
.kanban-body { padding: var(--sp-3); overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: var(--sp-3); }
.kanban-body.is-over { background: var(--primary-soft); border-radius: var(--r-md); }

.kanban-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  cursor: grab;
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
}
.kanban-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); transform: translateY(-1px); }
.kanban-card:active { cursor: grabbing; }
.kanban-card.dragging { opacity: .45; transform: rotate(1.5deg) scale(.98); }
.kanban-card-title { font-weight: 600; color: var(--text); margin-bottom: 5px; line-height: 1.35; }
.kanban-card-meta { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); margin-top: var(--sp-3); }
.kanban-value { font-weight: 700; color: var(--success); font-variant-numeric: tabular-nums; }

/* ----------------------------------------------------------- 11. Timeline */

.timeline { position: relative; padding-left: 30px; }
.timeline::before { content: ''; position: absolute; left: 11px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: var(--sp-5); }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot {
  position: absolute; left: -30px; top: 0;
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); border: 2px solid var(--border);
  font-size: .68rem; color: var(--text-3);
  z-index: 1;
}
.tl-dot.is-primary { border-color: var(--blue-500); color: var(--blue-400); background: var(--primary-soft); }
.tl-dot.is-success { border-color: var(--success); color: var(--success); background: var(--success-soft); }
.tl-dot.is-danger  { border-color: var(--danger);  color: var(--danger);  background: var(--danger-soft); }
.tl-dot.is-warning { border-color: var(--warning); color: var(--warning); background: var(--warning-soft); }
.tl-head { display: flex; align-items: baseline; gap: var(--sp-2); flex-wrap: wrap; }
.tl-title { font-weight: 600; color: var(--text); }
.tl-time { font-size: var(--fs-sm); color: var(--text-3); }
.tl-body { font-size: var(--fs-md); color: var(--text-2); margin-top: 3px; white-space: pre-wrap; word-break: break-word; }

/* ----------------------------------------------------------- 12. Progress */

.progress-track { height: 7px; background: var(--surface-3); border-radius: var(--r-full); overflow: hidden; }
.progress-fill {
  height: 100%; border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--blue-500), var(--cyan-500));
  transition: width var(--transition-slow);
}
.progress-fill.is-success { background: linear-gradient(90deg, var(--success), #4ade80); }
.progress-fill.is-warning { background: linear-gradient(90deg, var(--warning), #fbbf24); }
.progress-fill.is-danger  { background: linear-gradient(90deg, var(--danger), #fb7185); }
.progress-lg { height: 11px; }
.progress-xs { height: 4px; }

.ring { --p: 0; --size: 96px; --thick: 9px; width: var(--size); height: var(--size); position: relative; flex-shrink: 0; }
.ring::before {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(var(--ring-color, var(--blue-500)) calc(var(--p) * 1%), var(--surface-3) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - var(--thick)), #000 calc(100% - var(--thick) + 1px));
  mask: radial-gradient(farthest-side, transparent calc(100% - var(--thick)), #000 calc(100% - var(--thick) + 1px));
}
.ring-label {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-weight: 720; font-size: var(--fs-lg); letter-spacing: -.02em;
}

/* ----------------------------------------------------------- 13. Empty & skeleton */

.empty { text-align: center; padding: var(--sp-9) var(--sp-5); color: var(--text-3); }
.empty-icon {
  width: 64px; height: 64px; margin: 0 auto var(--sp-4);
  border-radius: var(--r-lg);
  background: var(--surface-3); border: 1px solid var(--border);
  display: grid; place-items: center; font-size: 1.6rem; color: var(--text-3);
}
.empty h4 { color: var(--text-2); margin-bottom: 5px; font-size: var(--fs-lg); }
.empty p { font-size: var(--fs-base); max-width: 380px; margin: 0 auto var(--sp-4); }

.skeleton { background: var(--skeleton); background-size: 400% 100%; animation: shimmer 1.3s ease-in-out infinite; border-radius: var(--r-xs); }
.sk-line { height: 12px; margin-bottom: 9px; }
.sk-line.short { width: 55%; }
.sk-card { height: 108px; border-radius: var(--r-lg); }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* Global route loading bar */
#neox-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0;
  background: linear-gradient(90deg, var(--blue-500), var(--cyan-400));
  z-index: 9999; opacity: 0; transition: width 220ms ease, opacity 220ms ease;
  box-shadow: 0 0 12px rgba(47,107,255,.7);
}
#neox-progress.active { opacity: 1; }

.spinner {
  width: 17px; height: 17px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  display: inline-block; animation: spin .7s linear infinite;
}
.spinner-lg { width: 34px; height: 34px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

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

/* ----------------------------------------------------------- 14. Toasts */

.toast-stack {
  position: fixed; bottom: var(--sp-5); right: var(--sp-5);
  z-index: 1200; display: flex; flex-direction: column; gap: var(--sp-2);
  max-width: min(380px, calc(100vw - 32px));
}
.toast-item {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--blue-500);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  animation: toastIn .3s cubic-bezier(.2,.9,.3,1.2);
  font-size: var(--fs-base);
}
.toast-item.is-success { border-left-color: var(--success); }
.toast-item.is-danger  { border-left-color: var(--danger); }
.toast-item.is-warning { border-left-color: var(--warning); }
.toast-item .ti-icon { font-size: 1.05rem; margin-top: 1px; }
.toast-item.is-success .ti-icon { color: var(--success); }
.toast-item.is-danger  .ti-icon { color: var(--danger); }
.toast-item.is-warning .ti-icon { color: var(--warning); }
.toast-item.is-info    .ti-icon { color: var(--info); }
.toast-item .ti-body { flex: 1; min-width: 0; color: var(--text); word-break: break-word; }
.toast-item .ti-close { background: none; border: 0; color: var(--text-3); cursor: pointer; padding: 0; font-size: 1rem; line-height: 1; }
.toast-item.leaving { animation: toastOut .22s ease forwards; }
@keyframes toastIn  { from { opacity: 0; transform: translateX(28px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(28px) scale(.96); } }

/* ----------------------------------------------------------- 15. Dropdowns & modals */

.dropdown { position: relative; }
.dropdown-menu-neox {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 230px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 200;
  display: none;
  animation: ddIn .16s ease;
}
.dropdown-menu-neox.show { display: block; }
.dropdown-menu-neox.left { right: auto; left: 0; }
@keyframes ddIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.dd-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 8px 10px; border-radius: var(--r-xs);
  color: var(--text-2); font-size: var(--fs-base); width: 100%;
  background: none; border: 0; text-align: left; cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.dd-item:hover { background: var(--surface-hover); color: var(--text); }
.dd-item.is-danger { color: var(--danger); }
.dd-item.is-danger:hover { background: var(--danger-soft); }
.dd-divider { height: 1px; background: var(--border-soft); margin: 5px 0; }
.dd-head { padding: 8px 10px 6px; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); font-weight: 650; }

.modal-backdrop-neox {
  position: fixed; inset: 0; background: rgba(4, 7, 14, .68);
  backdrop-filter: blur(3px); z-index: 1000;
  display: none; align-items: center; justify-content: center;
  padding: var(--sp-4);
  overflow-y: auto;
}
.modal-backdrop-neox.show { display: flex; animation: fadeIn .18s ease; }
.modal-neox {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px;
  max-height: calc(100vh - 48px);
  display: flex; flex-direction: column;
  animation: modalIn .24s cubic-bezier(.2,.9,.3,1.05);
  margin: auto;
}
.modal-neox.wide { max-width: 860px; }
.modal-neox.narrow { max-width: 420px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border-soft); flex-shrink: 0;
}
.modal-body { padding: var(--sp-5); overflow-y: auto; flex: 1; }
.modal-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--border-soft); flex-shrink: 0;
  flex-wrap: wrap;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }

/* ----------------------------------------------------------- 16. Chat */

.chat-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  height: calc(100vh - var(--topbar-h) - var(--sp-6) * 2);
  min-height: 460px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.chat-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.chat-list-head { padding: var(--sp-4); border-bottom: 1px solid var(--border-soft); flex-shrink: 0; }
.chat-list-scroll { overflow-y: auto; flex: 1; }
.chat-person {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer; transition: background var(--transition);
}
.chat-person:hover { background: var(--surface-hover); }
.chat-person.active { background: var(--primary-soft); border-left: 3px solid var(--blue-500); padding-left: calc(var(--sp-4) - 3px); }
.chat-person-text { flex: 1; min-width: 0; }
.chat-person-name { font-weight: 600; font-size: var(--fs-base); color: var(--text); display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.chat-person-last { font-size: var(--fs-sm); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-unread { background: var(--blue-500); color: #fff; font-size: var(--fs-xs); font-weight: 700; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-full); display: grid; place-items: center; }

.chat-panel { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.chat-head { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border-soft); flex-shrink: 0; }
.chat-messages { flex: 1; overflow-y: auto; padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-3); }
.msg-row { display: flex; gap: var(--sp-2); max-width: 74%; }
.msg-row.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg-bubble {
  padding: 9px var(--sp-3);
  border-radius: 14px 14px 14px 4px;
  background: var(--surface-3);
  border: 1px solid var(--border-soft);
  font-size: var(--fs-base);
  color: var(--text);
  word-break: break-word;
  white-space: pre-wrap;
  line-height: 1.5;
}
.msg-row.mine .msg-bubble {
  background: var(--blue-500); border-color: var(--blue-500); color: #fff;
  border-radius: 14px 14px 4px 14px;
}
.msg-time { font-size: var(--fs-xs); color: var(--text-3); margin-top: 3px; display: block; }
.msg-row.mine .msg-time { text-align: right; }
.msg-day { text-align: center; font-size: var(--fs-xs); color: var(--text-3); margin: var(--sp-2) 0; text-transform: uppercase; letter-spacing: .07em; }
.chat-compose { display: flex; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--border-soft); flex-shrink: 0; }
.chat-compose .textarea { min-height: 42px; max-height: 130px; resize: none; }

/* ----------------------------------------------------------- 17. Video player */

.video-shell { background: #000; border-radius: var(--r-lg); overflow: hidden; position: relative; }
.video-frame { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-shield { position: absolute; inset: 0; cursor: pointer; }

.vp-controls {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: linear-gradient(180deg, #0f131c, #0a0d14);
  color: #e9eefb;
  flex-wrap: wrap;
}
.vp-btn {
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(255,255,255,.08); border: 0; color: #fff;
  display: grid; place-items: center; cursor: pointer; font-size: 1.05rem;
  transition: background var(--transition), transform var(--transition);
  flex-shrink: 0;
}
.vp-btn:hover { background: var(--blue-500); transform: scale(1.06); }
.vp-btn.primary { width: 46px; height: 46px; background: var(--blue-500); font-size: 1.2rem; }
.vp-bar { flex: 1; min-width: 140px; height: 6px; background: rgba(255,255,255,.16); border-radius: var(--r-full); cursor: pointer; position: relative; }
.vp-bar-fill { height: 100%; border-radius: var(--r-full); background: linear-gradient(90deg, var(--blue-500), var(--cyan-400)); width: 0; transition: width .25s linear; }
.vp-bar-knob {
  position: absolute; top: 50%; transform: translate(-50%, -50%); left: 0;
  width: 13px; height: 13px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 5px rgba(0,0,0,.5); opacity: 0; transition: opacity var(--transition);
}
.vp-bar:hover .vp-bar-knob { opacity: 1; }
.vp-time { font-size: var(--fs-sm); font-variant-numeric: tabular-nums; color: #b9c4da; white-space: nowrap; }
.vp-spacer { flex: 1; }
.vp-rate { background: rgba(255,255,255,.08); border: 0; color: #fff; border-radius: var(--r-xs); padding: 5px 9px; font-size: var(--fs-sm); cursor: pointer; font-weight: 600; }

.lesson-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-soft);
  transition: background var(--transition);
}
.lesson-item:hover { background: var(--surface-hover); }
.lesson-item.active { background: var(--primary-soft); }
.lesson-num {
  width: 27px; height: 27px; border-radius: 50%; flex-shrink: 0;
  background: var(--surface-3); border: 1px solid var(--border);
  display: grid; place-items: center; font-size: var(--fs-sm); font-weight: 700; color: var(--text-3);
}
.lesson-item.done .lesson-num { background: var(--success-soft); border-color: var(--success); color: var(--success); }

/* ----------------------------------------------------------- 18. Reward card */

.reward-backdrop {
  position: fixed; inset: 0; z-index: 1300;
  background: rgba(3, 6, 12, .8); backdrop-filter: blur(6px);
  display: none; align-items: center; justify-content: center; padding: var(--sp-4);
}
.reward-backdrop.show { display: flex; animation: fadeIn .25s ease; }
.reward-card {
  position: relative;
  width: 100%; max-width: 380px;
  background: linear-gradient(165deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  padding: var(--sp-8) var(--sp-6) var(--sp-6);
  text-align: center;
  box-shadow: var(--shadow-lg), 0 0 70px rgba(47,107,255,.28);
  animation: rewardPop .55s cubic-bezier(.18,.9,.3,1.3);
  overflow: hidden;
}
.reward-card::before {
  content: ''; position: absolute; top: -55%; left: -55%; width: 210%; height: 210%;
  background: conic-gradient(from 0deg, transparent, rgba(47,107,255,.18), transparent 30%);
  animation: rewardSpin 5s linear infinite;
}
.reward-inner { position: relative; z-index: 1; }
@keyframes rewardSpin { to { transform: rotate(360deg); } }
@keyframes rewardPop { 0% { opacity: 0; transform: scale(.7) translateY(28px); } 100% { opacity: 1; transform: none; } }

.reward-medal {
  width: 104px; height: 104px; margin: 0 auto var(--sp-4);
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 2.6rem; color: #fff;
  background: linear-gradient(140deg, var(--blue-500), var(--cyan-500));
  box-shadow: 0 12px 38px rgba(47,107,255,.5);
  animation: medalFloat 2.6s ease-in-out infinite;
}
@keyframes medalFloat { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
.reward-kicker { font-size: var(--fs-sm); letter-spacing: .16em; text-transform: uppercase; color: var(--blue-400); font-weight: 700; }
.reward-title { font-size: var(--fs-2xl); margin: var(--sp-2) 0 var(--sp-1); }
.reward-desc { color: var(--text-2); font-size: var(--fs-base); margin-bottom: var(--sp-4); }
.reward-points {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--success-soft); color: var(--success);
  padding: 6px var(--sp-4); border-radius: var(--r-full);
  font-weight: 700; margin-bottom: var(--sp-5);
}

.confetti-piece {
  position: fixed; width: 9px; height: 15px; top: -20px;
  z-index: 1299; pointer-events: none; opacity: .95;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  to { transform: translateY(105vh) rotate(760deg); opacity: 0; }
}

/* Badge tiles */
.badge-tile {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: var(--sp-4) var(--sp-3);
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  text-align: center;
  transition: transform var(--transition), border-color var(--transition);
}
.badge-tile:hover { transform: translateY(-3px); border-color: var(--border-strong); }
.badge-tile.locked { opacity: .42; filter: grayscale(1); }
.badge-medal {
  width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.4rem; color: #fff;
  flex-shrink: 0;
}
.badge-tile-name { font-size: var(--fs-md); font-weight: 650; color: var(--text); line-height: 1.3; }
.badge-tile-desc { font-size: var(--fs-xs); color: var(--text-3); line-height: 1.4; }

/* Leaderboard */
.lb-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-soft);
  transition: background var(--transition);
}
.lb-row:hover { background: var(--surface-hover); }
.lb-row.is-me { background: var(--primary-soft); }
.lb-rank {
  width: 30px; height: 30px; border-radius: var(--r-sm); flex-shrink: 0;
  display: grid; place-items: center; font-weight: 750; font-size: var(--fs-md);
  background: var(--surface-3); color: var(--text-3);
}
.lb-rank.gold   { background: linear-gradient(135deg, #f5c451, #e0a020); color: #3a2600; }
.lb-rank.silver { background: linear-gradient(135deg, #dfe6ef, #b3bfd0); color: #2b3340; }
.lb-rank.bronze { background: linear-gradient(135deg, #e0a274, #bd7c48); color: #3a2003; }

/* ----------------------------------------------------------- 19. Auth page */

.auth-page {
  min-height: 100vh; min-height: 100dvh;
  display: grid; grid-template-columns: 1fr 1fr;
}
.auth-aside {
  position: relative; overflow: hidden;
  background: linear-gradient(150deg, #0a1330 0%, #0b1b4d 42%, #061024 100%);
  color: #fff;
  padding: var(--sp-9) var(--sp-8);
  display: flex; flex-direction: column; justify-content: space-between;
}
.auth-aside::before {
  content: ''; position: absolute; width: 620px; height: 620px; border-radius: 50%;
  background: radial-gradient(circle, rgba(47,107,255,.42), transparent 68%);
  top: -180px; right: -200px;
}
.auth-aside::after {
  content: ''; position: absolute; width: 460px; height: 460px; border-radius: 50%;
  background: radial-gradient(circle, rgba(0,194,232,.28), transparent 68%);
  bottom: -170px; left: -140px;
}
.auth-aside > * { position: relative; z-index: 1; }
.auth-headline { font-size: clamp(1.9rem, 3vw, 2.7rem); line-height: 1.16; font-weight: 750; letter-spacing: -.03em; color: #fff; }
.auth-sub { color: rgba(226,235,255,.78); font-size: var(--fs-lg); margin-top: var(--sp-4); max-width: 430px; }
.auth-points { display: flex; flex-direction: column; gap: var(--sp-3); margin-top: var(--sp-7); }
.auth-point { display: flex; align-items: flex-start; gap: var(--sp-3); color: rgba(226,235,255,.9); font-size: var(--fs-base); }
.auth-point i { color: var(--cyan-400); font-size: 1.05rem; margin-top: 1px; }

.auth-main { display: grid; place-items: center; padding: var(--sp-6); background: var(--bg); }
.auth-card { width: 100%; max-width: 400px; }
.auth-logo { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-7); }

.demo-accounts { margin-top: var(--sp-5); border-top: 1px solid var(--border); padding-top: var(--sp-4); }
.demo-account {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%;
  padding: 9px var(--sp-3); border-radius: var(--r-sm);
  background: var(--surface-3); border: 1px solid var(--border);
  cursor: pointer; margin-bottom: 6px; text-align: left;
  transition: all var(--transition); color: var(--text-2); font-family: inherit;
}
.demo-account:hover { border-color: var(--blue-500); background: var(--primary-soft); color: var(--text); }
.demo-account-text { flex: 1; min-width: 0; }
.demo-account-role { font-weight: 650; font-size: var(--fs-md); color: var(--text); }
.demo-account-mail { font-size: var(--fs-xs); color: var(--text-3); }

/* ----------------------------------------------------------- 20. Misc components */

.kv { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 9px var(--sp-3); font-size: var(--fs-base); }
.kv dt { color: var(--text-3); font-weight: 500; }
.kv dd { margin: 0; color: var(--text); font-weight: 550; word-break: break-word; }

.section-title {
  display: flex; align-items: center; gap: var(--sp-2);
  font-size: var(--fs-sm); font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-3); margin-bottom: var(--sp-3);
}
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.alert {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-3);
  font-size: var(--fs-base);
  color: var(--text-2);
}
.alert i { font-size: 1.05rem; margin-top: 1px; flex-shrink: 0; }
.alert-info    { background: var(--info-soft);    border-color: transparent; color: var(--info); }
.alert-success { background: var(--success-soft); border-color: transparent; color: var(--success); }
.alert-warning { background: var(--warning-soft); border-color: transparent; color: var(--warning); }
.alert-danger  { background: var(--danger-soft);  border-color: transparent; color: var(--danger); }

.pagination-neox { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; padding: var(--sp-3) var(--sp-4); }
.pagination-info { font-size: var(--fs-md); color: var(--text-3); }
.pagination-links { display: flex; gap: 4px; flex-wrap: wrap; }
.pagination-links a, .pagination-links span {
  min-width: 33px; height: 33px; padding: 0 9px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-xs); border: 1px solid var(--border);
  font-size: var(--fs-md); font-weight: 600; color: var(--text-2);
  transition: all var(--transition);
}
.pagination-links a:hover { border-color: var(--blue-500); color: var(--blue-400); background: var(--primary-soft); }
.pagination-links .current { background: var(--blue-500); border-color: var(--blue-500); color: #fff; }
.pagination-links .disabled { opacity: .4; pointer-events: none; }

.tooltip-host { position: relative; }
.tooltip-host[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 7px); left: 50%; transform: translateX(-50%);
  background: var(--surface-3); color: var(--text); border: 1px solid var(--border);
  padding: 5px 9px; border-radius: var(--r-xs); font-size: var(--fs-sm); white-space: nowrap;
  box-shadow: var(--shadow-md); z-index: 300; pointer-events: none;
}

.stat-line { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: 9px 0; border-bottom: 1px solid var(--border-soft); }
.stat-line:last-child { border-bottom: 0; }
.stat-line-label { color: var(--text-2); font-size: var(--fs-base); display: flex; align-items: center; gap: 7px; min-width: 0; }
.stat-line-value { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }

.chart-box { position: relative; width: 100%; }
.chart-box canvas { max-width: 100%; }

.mono { font-family: var(--font-mono); font-size: .92em; }
.ref-tag {
  font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--text-3);
  background: var(--surface-3); padding: 2px 7px; border-radius: var(--r-xs); border: 1px solid var(--border-soft);
  white-space: nowrap;
}

/* Mobile bottom navigation */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 70;
  height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--topbar-bg);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--border);
}
.bottom-nav-inner { display: grid; grid-template-columns: repeat(5, 1fr); height: var(--bottomnav-h); }
.bn-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--text-3); font-size: var(--fs-xs); font-weight: 600; position: relative;
}
.bn-item i { font-size: 1.24rem; }
.bn-item.active { color: var(--blue-400); }
.bn-item .bn-dot { position: absolute; top: 9px; right: 50%; margin-right: -14px; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); }

.sidebar-scrim {
  position: fixed; inset: 0; background: rgba(4,7,14,.6); z-index: 55;
  display: none; backdrop-filter: blur(2px);
}
.sidebar-scrim.show { display: block; animation: fadeIn .18s ease; }

/* PWA install prompt */
.install-banner {
  position: fixed; left: var(--sp-4); right: var(--sp-4); bottom: calc(var(--bottomnav-h) + 12px);
  z-index: 900; display: none;
  align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: var(--r-md); box-shadow: var(--shadow-lg);
  max-width: 460px; margin: 0 auto;
}
.install-banner.show { display: flex; animation: toastIn .3s ease; }

/* ----------------------------------------------------------- 21. Utilities */

.flex { display: flex; }
.inline-flex { display: inline-flex; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; min-width: 0; }
.gap-1 { gap: var(--sp-1); } .gap-2 { gap: var(--sp-2); } .gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); } .gap-5 { gap: var(--sp-5); } .gap-6 { gap: var(--sp-6); }

.mt-0 { margin-top: 0; } .mt-1 { margin-top: var(--sp-1); } .mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); } .mt-4 { margin-top: var(--sp-4); } .mt-5 { margin-top: var(--sp-5); }
.mt-6 { margin-top: var(--sp-6); } .mt-7 { margin-top: var(--sp-7); }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: var(--sp-1); } .mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); } .mb-4 { margin-bottom: var(--sp-4); } .mb-5 { margin-bottom: var(--sp-5); }
.mb-6 { margin-bottom: var(--sp-6); }
.ml-auto { margin-left: auto; }
.p-0 { padding: 0; } .p-3 { padding: var(--sp-3); } .p-4 { padding: var(--sp-4); } .p-5 { padding: var(--sp-5); }

.text-xs { font-size: var(--fs-xs); } .text-sm { font-size: var(--fs-sm); } .text-md { font-size: var(--fs-md); }
.text-lg { font-size: var(--fs-lg); } .text-xl { font-size: var(--fs-xl); } .text-2xl { font-size: var(--fs-2xl); }
.text-muted { color: var(--text-3); }
.text-dim { color: var(--text-2); }
.text-success { color: var(--success); } .text-danger { color: var(--danger); }
.text-warning { color: var(--warning); } .text-primary { color: var(--blue-400); }
.text-center { text-align: center; } .text-right { text-align: right; }
.fw-600 { font-weight: 600; } .fw-700 { font-weight: 700; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.nowrap { white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.relative { position: relative; }
.pointer { cursor: pointer; }
.divider { height: 1px; background: var(--border-soft); margin: var(--sp-4) 0; }
.scroll-y { overflow-y: auto; }
.no-print { }

/* ----------------------------------------------------------- 22. Responsive */

@media (max-width: 1400px) {
  .grid-main-side { grid-template-columns: minmax(0, 1fr) 320px; }
}

@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main-side, .grid-side-main { grid-template-columns: minmax(0, 1fr); }
  .chat-shell { grid-template-columns: 260px minmax(0, 1fr); }
}

@media (max-width: 992px) {
  :root { --sidebar-w: 262px; }
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .app-shell.is-collapsed { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; top: 0; left: 0; width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform var(--transition-slow);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .is-collapsed .sidebar .brand-text,
  .is-collapsed .sidebar .nav-label,
  .is-collapsed .sidebar .nav-item span,
  .is-collapsed .sidebar .nav-count,
  .is-collapsed .sidebar .user-mini-text { display: revert; }
  .is-collapsed .sidebar .nav-item { justify-content: flex-start; padding: 9px var(--sp-3); }
  .is-collapsed .sidebar-brand { justify-content: flex-start; padding: 0 var(--sp-5); }

  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .page-body { padding: var(--sp-4) var(--sp-4) calc(var(--bottomnav-h) + var(--sp-6)); }
  .bottom-nav { display: block; }
  .toast-stack { bottom: calc(var(--bottomnav-h) + var(--sp-3)); right: var(--sp-3); left: var(--sp-3); }
  .chat-shell { grid-template-columns: minmax(0, 1fr); height: calc(100vh - var(--topbar-h) - var(--bottomnav-h) - var(--sp-6)); }
  .chat-shell .chat-list { display: none; }
  .chat-shell.show-list .chat-list { display: flex; }
  .chat-shell.show-list .chat-panel { display: none; }
}

@media (max-width: 768px) {
  :root { --topbar-h: 58px; }
  .topbar { padding: 0 var(--sp-3); gap: var(--sp-2); }
  .topbar-search { max-width: none; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  .page-title h1 { font-size: var(--fs-2xl); }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--sp-3); }
  .stat-card { padding: var(--sp-4); }
  .stat-value { font-size: var(--fs-2xl); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .card-body { padding: var(--sp-4); }
  .card-head { padding: var(--sp-3) var(--sp-4); }
  .modal-neox { max-height: calc(100dvh - 24px); }
  .modal-foot { flex-direction: column-reverse; }
  .modal-foot .btn { width: 100%; }
  .msg-row { max-width: 88%; }
  .kanban { grid-auto-columns: 84vw; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px var(--sp-2); }
  .kv dt { margin-top: var(--sp-2); }
  .filter-item { flex: 1 1 100%; min-width: 0; }
  .filter-actions { width: 100%; }
  .filter-actions .btn { flex: 1; }
}

@media (max-width: 576px) {
  .auth-page { grid-template-columns: minmax(0, 1fr); }
  .auth-aside { display: none; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-body { padding: var(--sp-3) var(--sp-3) calc(var(--bottomnav-h) + var(--sp-6)); }
  .table th, .table td { padding: 10px var(--sp-3); }
  .ring { --size: 78px; --thick: 8px; }
}

@media (max-width: 400px) {
  .stat-grid, .grid-4 { grid-template-columns: minmax(0, 1fr); }
}

/* Wide screens keep content from stretching uncomfortably */
@media (min-width: 1900px) {
  .page-body { padding: var(--sp-7) var(--sp-8); }
}

/* ----------------------------------------------------------- 23. Motion & print */

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

@media print {
  .sidebar, .topbar, .bottom-nav, .page-actions, .toast-stack, .no-print, .install-banner { display: none !important; }
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  body { background: #fff; color: #000; }
  .card { border-color: #ddd; box-shadow: none; break-inside: avoid; }
  .page-body { padding: 0; max-width: none; }
  a { color: #000; text-decoration: none; }
}
