/* ═══════════════════════════════════════════════════════════════════
   LMS v7 — PREMIUM DESIGN SYSTEM
   Font: Instrument Sans (display) + DM Sans (body) + JetBrains Mono
   Palette: Rich slate + vivid indigo accent + semantic colors
   Philosophy: Ultra-refined, editorial, production-grade
   ═══════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Instrument+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ─────────────────────────────────────────────────────────────────
   DESIGN TOKENS — Single Source of Truth
   ───────────────────────────────────────────────────────────────── */
:root {
  /* Typography */
  --font-display: 'Instrument Sans', 'DM Sans', system-ui, sans-serif;
  --font-body:    'DM Sans', system-ui, -apple-system, sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', ui-monospace, monospace;

  /* Color scales */
  --slate-50:  #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --slate-950: #020617;

  --indigo-50:  #eef2ff;
  --indigo-100: #e0e7ff;
  --indigo-200: #c7d2fe;
  --indigo-400: #818cf8;
  --indigo-500: #6366f1;
  --indigo-600: #4f46e5;
  --indigo-700: #4338ca;
  --indigo-900: #312e81;

  --violet-500: #8b5cf6;
  --violet-600: #7c3aed;

  --emerald-50:  #ecfdf5;
  --emerald-100: #d1fae5;
  --emerald-500: #10b981;
  --emerald-600: #059669;
  --emerald-700: #047857;

  --rose-50:  #fff1f2;
  --rose-100: #ffe4e6;
  --rose-500: #f43f5e;
  --rose-600: #e11d48;
  --rose-700: #be123c;

  --amber-50:  #fffbeb;
  --amber-100: #fef3c7;
  --amber-500: #f59e0b;
  --amber-600: #d97706;
  --amber-700: #b45309;

  --sky-50:  #f0f9ff;
  --sky-100: #e0f2fe;
  --sky-500: #0ea5e9;
  --sky-600: #0284c7;
  --sky-700: #0369a1;

  /* ── Light mode semantic tokens ── */
  --bg:             var(--slate-50);
  --bg-elevated:    #ffffff;
  --bg-subtle:      var(--slate-100);
  --bg-muted:       var(--slate-200);
  --surface:        #ffffff;
  --surface-raised: #ffffff;
  --surface-overlay:#ffffff;

  --border:         var(--slate-200);
  --border-strong:  var(--slate-300);
  --border-subtle:  var(--slate-100);
  --border-focus:   var(--indigo-500);

  --text-primary:   var(--slate-900);
  --text-secondary: var(--slate-600);
  --text-tertiary:  var(--slate-400);
  --text-inverse:   #ffffff;
  --text-disabled:  var(--slate-300);

  --accent:         var(--indigo-600);
  --accent-hover:   var(--indigo-700);
  --accent-soft:    var(--indigo-50);
  --accent-ring:    rgba(99,102,241,.2);

  --success:        var(--emerald-600);
  --success-bg:     var(--emerald-50);
  --success-border: var(--emerald-100);
  --success-text:   var(--emerald-700);

  --danger:         var(--rose-600);
  --danger-bg:      var(--rose-50);
  --danger-border:  var(--rose-100);
  --danger-text:    var(--rose-700);

  --warning:        var(--amber-600);
  --warning-bg:     var(--amber-50);
  --warning-border: var(--amber-100);
  --warning-text:   var(--amber-700);

  --info:           var(--sky-600);
  --info-bg:        var(--sky-50);
  --info-border:    var(--sky-100);
  --info-text:      var(--sky-700);

  /* Shadows */
  --shadow-xs:  0 1px 2px rgba(15,23,42,.04);
  --shadow-sm:  0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04);
  --shadow:     0 4px 12px rgba(15,23,42,.07), 0 2px 4px rgba(15,23,42,.04);
  --shadow-md:  0 8px 24px rgba(15,23,42,.09), 0 3px 8px rgba(15,23,42,.05);
  --shadow-lg:  0 16px 48px rgba(15,23,42,.12), 0 6px 16px rgba(15,23,42,.07);
  --shadow-xl:  0 32px 64px rgba(15,23,42,.18), 0 12px 24px rgba(15,23,42,.09);
  --shadow-focus: 0 0 0 3px var(--accent-ring);
  --shadow-card: 0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.03);

  /* Radii */
  --r-xs:   4px;
  --r-sm:   6px;
  --r:      8px;
  --r-md:   10px;
  --r-lg:   14px;
  --r-xl:   18px;
  --r-2xl:  24px;
  --r-full: 9999px;

  /* Spacing scale */
  --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;

  /* Motion */
  --ease:          cubic-bezier(.4,0,.2,1);
  --ease-in:       cubic-bezier(.4,0,1,1);
  --ease-out:      cubic-bezier(0,0,.2,1);
  --ease-spring:   cubic-bezier(.34,1.56,.64,1);
  --dur-fast:      .1s;
  --dur-base:      .18s;
  --dur-slow:      .3s;
  --dur-slower:    .5s;
  --transition:    all var(--dur-base) var(--ease);

  /* Layout */
  --sidebar-w:     260px;
  --sidebar-rail:  64px;
  --topbar-h:      58px;
  --container-xl:  1280px;
  --container-lg:  1024px;
}

/* ── Dark mode ── */
[data-theme="dark"] {
  --bg:             #090e1a;
  --bg-elevated:    #0f1629;
  --bg-subtle:      #141d2e;
  --bg-muted:       #1a2540;
  --surface:        #0f1629;
  --surface-raised: #141d2e;
  --surface-overlay:#192135;

  --border:         rgba(255,255,255,.08);
  --border-strong:  rgba(255,255,255,.14);
  --border-subtle:  rgba(255,255,255,.04);
  --border-focus:   var(--indigo-400);

  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-tertiary:  #475569;
  --text-disabled:  #334155;

  --accent:         var(--indigo-400);
  --accent-hover:   #a5b4fc;
  --accent-soft:    rgba(99,102,241,.12);
  --accent-ring:    rgba(129,140,248,.25);

  --success-bg:     rgba(16,185,129,.08);
  --success-border: rgba(16,185,129,.18);
  --success-text:   #6ee7b7;

  --danger-bg:      rgba(244,63,94,.08);
  --danger-border:  rgba(244,63,94,.18);
  --danger-text:    #fda4af;

  --warning-bg:     rgba(245,158,11,.08);
  --warning-border: rgba(245,158,11,.18);
  --warning-text:   #fcd34d;

  --info-bg:        rgba(14,165,233,.08);
  --info-border:    rgba(14,165,233,.18);
  --info-text:      #7dd3fc;

  --shadow-xs:  0 1px 2px rgba(0,0,0,.2);
  --shadow-sm:  0 1px 3px rgba(0,0,0,.3), 0 1px 2px rgba(0,0,0,.2);
  --shadow:     0 4px 12px rgba(0,0,0,.35), 0 2px 4px rgba(0,0,0,.2);
  --shadow-md:  0 8px 24px rgba(0,0,0,.4), 0 3px 8px rgba(0,0,0,.25);
  --shadow-lg:  0 16px 48px rgba(0,0,0,.5), 0 6px 16px rgba(0,0,0,.3);
  --shadow-xl:  0 32px 64px rgba(0,0,0,.6), 0 12px 24px rgba(0,0,0,.4);
  --shadow-card: 0 1px 3px rgba(0,0,0,.3), inset 0 1px 0 rgba(255,255,255,.04);
}

/* ─────────────────────────────────────────────────────────────────
   RESET & BASE
   ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; font-size: 16px; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  transition: background var(--dur-slow) var(--ease), color var(--dur-slow) var(--ease);
}
a { color: var(--accent); text-decoration: none; transition: color var(--dur-base) var(--ease); }
a:hover { color: var(--accent-hover); }
img, video { max-width: 100%; height: auto; display: block; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--sp-4) 0; }
::selection { background: var(--accent); color: #fff; }
h1,h2,h3,h4,h5,h6 {
  font-family: var(--font-display);
  color: var(--text-primary);
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.25;
}
:focus-visible { outline: none; box-shadow: var(--shadow-focus); border-radius: var(--r-sm); }
input, textarea, select, button { font-family: var(--font-body); }

/* ─────────────────────────────────────────────────────────────────
   APP SHELL LAYOUT
   ───────────────────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}
.main-area {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--dur-slow) var(--ease);
}
.main-area.rail-mode { margin-left: var(--sidebar-rail); }

main.content {
  flex: 1;
  padding: var(--sp-6) var(--sp-8);
  max-width: var(--container-xl);
  width: 100%;
  margin: 0 auto;
}

@media (max-width: 1024px) {
  main.content { padding: var(--sp-4) var(--sp-5); }
}
@media (max-width: 768px) {
  .main-area { margin-left: 0; }
  main.content { padding: var(--sp-4); }
}

/* ─────────────────────────────────────────────────────────────────
   SIDEBAR
   ───────────────────────────────────────────────────────────────── */
#app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 400;
  transition: width var(--dur-slow) var(--ease), transform var(--dur-slow) var(--ease);
  overflow: hidden;
  will-change: width;
}
#app-sidebar.collapsed {
  width: var(--sidebar-rail);
}
#app-sidebar .sb-header {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow: hidden;
}
#app-sidebar .sb-logo-mark {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: var(--r);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: white;
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font-display);
  letter-spacing: -.03em;
}
#app-sidebar .sb-brand {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.02em;
  white-space: nowrap;
  opacity: 1;
  transition: opacity var(--dur-base) var(--ease);
}
#app-sidebar.collapsed .sb-brand { opacity: 0; pointer-events: none; }

#app-sidebar .sb-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
#app-sidebar .sb-body::-webkit-scrollbar { width: 4px; }
#app-sidebar .sb-body::-webkit-scrollbar-track { background: transparent; }
#app-sidebar .sb-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--r-full); }

.sb-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-tertiary);
  padding: 14px 20px 6px;
  white-space: nowrap;
  transition: opacity var(--dur-base) var(--ease);
}
#app-sidebar.collapsed .sb-section-label { opacity: 0; }

.sb-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px 9px 16px;
  margin: 1px 8px;
  border-radius: var(--r);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid transparent;
  position: relative;
}
.sb-nav-item:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}
.sb-nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
  font-weight: 600;
}
.sb-nav-item .sb-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sb-nav-item .sb-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity var(--dur-base) var(--ease), max-width var(--dur-base) var(--ease);
}
#app-sidebar.collapsed .sb-label { opacity: 0; max-width: 0; }
.sb-badge {
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--r-full);
  line-height: 1.4;
  flex-shrink: 0;
  transition: opacity var(--dur-base) var(--ease);
}
#app-sidebar.collapsed .sb-badge { opacity: 0; }

#app-sidebar .sb-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.sb-collapse-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 8px 16px;
  border-radius: var(--r);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background var(--dur-fast);
  white-space: nowrap;
  font-family: var(--font-body);
}
.sb-collapse-btn:hover { background: var(--bg-subtle); color: var(--text-primary); }
.sb-collapse-btn .sb-icon { flex-shrink: 0; }

/* Mobile sidebar */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(9,14,26,.5);
  z-index: 399;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }
@media (max-width: 768px) {
  #app-sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w) !important;
  }
  #app-sidebar.mobile-open { transform: translateX(0); }
  .sb-label, .sb-section-label, .sb-brand, .sb-badge { opacity: 1 !important; max-width: none !important; }
}

/* ─────────────────────────────────────────────────────────────────
   TOPBAR
   ───────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 var(--sp-6);
  position: sticky;
  top: 0;
  z-index: 200;
  flex-shrink: 0;
  backdrop-filter: blur(12px);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
}
.topbar-mobile-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--dur-fast);
}
.topbar-mobile-toggle:hover { background: var(--bg-subtle); color: var(--text-primary); }
@media (max-width: 768px) { .topbar-mobile-toggle { display: flex; } }

.topbar-search {
  flex: 1;
  max-width: 420px;
  position: relative;
}
.topbar-search input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 38px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text-primary);
  font-size: 13.5px;
  font-family: var(--font-body);
  transition: border-color var(--dur-base), box-shadow var(--dur-base), background var(--dur-base);
}
.topbar-search input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
  background: var(--surface);
}
.topbar-search input::placeholder { color: var(--text-tertiary); }
.topbar-search .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
}

.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: var(--sp-2); }

.topbar-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
  position: relative;
  flex-shrink: 0;
}
.topbar-btn:hover { background: var(--bg-subtle); color: var(--text-primary); }
.topbar-btn .badge-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--surface);
}

.topbar-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--r-full);
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-display);
  cursor: pointer;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid transparent;
  transition: border-color var(--dur-base), box-shadow var(--dur-base);
}
.topbar-avatar:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.topbar-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ─────────────────────────────────────────────────────────────────
   DROPDOWN MENUS
   ───────────────────────────────────────────────────────────────── */
.dropdown-wrapper { position: relative; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 220px;
  background: var(--surface-overlay);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 999;
  opacity: 0;
  transform: translateY(-8px) scale(.97);
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease), transform var(--dur-base) var(--ease);
  transform-origin: top right;
}
.dropdown-menu.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-body);
}
.dropdown-item:hover { background: var(--bg-subtle); color: var(--text-primary); }
.dropdown-item.danger:hover { background: var(--danger-bg); color: var(--danger-text); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }
.dropdown-header {
  padding: 8px 10px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-tertiary);
}

/* ─────────────────────────────────────────────────────────────────
   BUTTONS — Complete set
   ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--r);
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 600;
  font-family: var(--font-body);
  letter-spacing: -.01em;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  transition: all var(--dur-base) var(--ease);
  position: relative;
  overflow: hidden;
}
.btn:focus-visible { box-shadow: var(--shadow-focus); outline: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 1px 2px rgba(79,70,229,.2);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(79,70,229,.25); color: white; }
.btn-primary:active { transform: translateY(0); box-shadow: 0 1px 2px rgba(79,70,229,.2); }

.btn-secondary {
  background: var(--bg-subtle);
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--bg-muted); border-color: var(--border-strong); color: var(--text-primary); }

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.btn-outline:hover { background: var(--bg-subtle); border-color: var(--text-primary); color: var(--text-primary); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-subtle); color: var(--text-primary); }

.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}
.btn-danger:hover { background: var(--rose-700); color: white; transform: translateY(-1px); }

.btn-success {
  background: var(--success);
  color: white;
  border-color: var(--success);
}
.btn-success:hover { background: var(--emerald-700); color: white; }

.btn-warning {
  background: var(--warning);
  color: white;
  border-color: var(--warning);
}

.btn-sm { padding: 5px 12px; font-size: 12.5px; gap: 5px; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }
.btn-xl { padding: 14px 28px; font-size: 16px; border-radius: var(--r-md); }
.btn-icon { padding: 0; width: 36px; height: 36px; border-radius: var(--r); }
.btn-icon-sm { padding: 0; width: 30px; height: 30px; border-radius: var(--r-sm); }
.btn-block { display: flex; width: 100%; }
.btn-loading { pointer-events: none; }
.btn-loading::after {
  content: '';
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin-left: 4px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─────────────────────────────────────────────────────────────────
   CARDS & SURFACES
   ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 16px;
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-size: 14.5px;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--text-primary);
  letter-spacing: -.015em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title svg { width: 17px; height: 17px; color: var(--text-tertiary); }
.card-body { padding: 22px; }
.card-body-sm { padding: 16px; }
.card-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  border-radius: 0 0 calc(var(--r-lg) - 1px) calc(var(--r-lg) - 1px);
}

/* Stat cards */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--dur-base), border-color var(--dur-base), transform var(--dur-base);
  text-decoration: none;
  display: block;
}
.stat-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); transform: translateY(-2px); }
.stat-card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; }
.stat-icon {
  width: 40px; height: 40px;
  border-radius: var(--r);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 20px; height: 20px; }
.stat-icon-indigo { background: var(--indigo-50); color: var(--indigo-600); }
.stat-icon-emerald { background: var(--emerald-50); color: var(--emerald-600); }
.stat-icon-rose { background: var(--rose-50); color: var(--rose-600); }
.stat-icon-amber { background: var(--amber-50); color: var(--amber-600); }
.stat-icon-sky { background: var(--sky-50); color: var(--sky-600); }
.stat-icon-violet { background: rgba(139,92,246,.1); color: var(--violet-600); }
[data-theme="dark"] .stat-icon-indigo { background: rgba(99,102,241,.12); color: var(--indigo-400); }
[data-theme="dark"] .stat-icon-emerald { background: rgba(16,185,129,.1); color: #6ee7b7; }
[data-theme="dark"] .stat-icon-rose { background: rgba(244,63,94,.1); color: #fda4af; }
[data-theme="dark"] .stat-icon-amber { background: rgba(245,158,11,.1); color: #fcd34d; }
[data-theme="dark"] .stat-icon-sky { background: rgba(14,165,233,.1); color: #7dd3fc; }

.stat-value {
  font-size: 26px;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--text-primary);
  letter-spacing: -.03em;
  line-height: 1;
  margin-bottom: 6px;
}
.stat-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: -.01em;
}
.stat-trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--r-full);
  margin-top: 8px;
}
.stat-trend-up { color: var(--success-text); background: var(--success-bg); }
.stat-trend-down { color: var(--danger-text); background: var(--danger-bg); }
.stat-trend svg { width: 12px; height: 12px; }

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

/* ─────────────────────────────────────────────────────────────────
   BADGES & PILLS
   ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--r-full);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: -.01em;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge svg { width: 11px; height: 11px; }
.badge-default { background: var(--bg-subtle); color: var(--text-secondary); border-color: var(--border); }
.badge-indigo { background: var(--indigo-50); color: var(--indigo-600); border-color: var(--indigo-100); }
.badge-emerald { background: var(--emerald-50); color: var(--emerald-700); border-color: var(--emerald-100); }
.badge-rose { background: var(--rose-50); color: var(--rose-700); border-color: var(--rose-100); }
.badge-amber { background: var(--amber-50); color: var(--amber-700); border-color: var(--amber-100); }
.badge-sky { background: var(--sky-50); color: var(--sky-700); border-color: var(--sky-100); }
.badge-success { background: var(--success-bg); color: var(--success-text); border-color: var(--success-border); }
.badge-danger { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-border); }
.badge-warning { background: var(--warning-bg); color: var(--warning-text); border-color: var(--warning-border); }
.badge-info { background: var(--info-bg); color: var(--info-text); border-color: var(--info-border); }

/* Status dots */
.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
}
.status-dot::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot-active::before { background: var(--success); box-shadow: 0 0 0 2px var(--success-bg); }
.status-dot-inactive::before { background: var(--text-tertiary); }
.status-dot-pending::before { background: var(--warning); box-shadow: 0 0 0 2px var(--warning-bg); animation: pulse 2s infinite; }
.status-dot-danger::before { background: var(--danger); box-shadow: 0 0 0 2px var(--danger-bg); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }

/* ─────────────────────────────────────────────────────────────────
   FORMS & INPUTS
   ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 7px;
  letter-spacing: -.01em;
}
.form-label-optional::after { content: ' (optional)'; font-weight: 400; color: var(--text-tertiary); }
.form-hint { font-size: 12px; color: var(--text-tertiary); margin-top: 5px; }
.form-error { font-size: 12px; color: var(--danger-text); margin-top: 5px; display: flex; align-items: center; gap: 4px; }
.form-error svg { width: 12px; height: 12px; flex-shrink: 0; }

.input, .select, .textarea {
  display: block;
  width: 100%;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r);
  color: var(--text-primary);
  font-size: 13.5px;
  font-family: var(--font-body);
  line-height: 1.5;
  transition: border-color var(--dur-base), box-shadow var(--dur-base), background var(--dur-base);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
  background: var(--surface);
}
.input::placeholder, .textarea::placeholder { color: var(--text-tertiary); }
.input-sm { padding: 6px 10px; font-size: 13px; }
.input-lg { padding: 11px 14px; font-size: 15px; }
.input-error { border-color: var(--danger); }
.input-error:focus { box-shadow: 0 0 0 3px rgba(244,63,94,.15); }
.input-icon-wrapper { position: relative; }
.input-icon-wrapper .input { padding-left: 38px; }
.input-icon-wrapper .input-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
}
.input-icon-wrapper .input-icon svg { width: 16px; height: 16px; }

.textarea { resize: vertical; min-height: 100px; }
.select { 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='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.checkbox-wrapper, .radio-wrapper { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.checkbox-wrapper input, .radio-wrapper input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.checkbox-wrapper span, .radio-wrapper span { font-size: 13.5px; color: var(--text-primary); }

/* Input group */
.input-group { display: flex; }
.input-group .input { border-radius: 0; border-right: none; flex: 1; }
.input-group .input:first-child { border-radius: var(--r) 0 0 var(--r); }
.input-group .input:last-child { border-radius: 0 var(--r) var(--r) 0; border-right: 1px solid var(--border-strong); }
.input-group .btn { border-radius: 0 var(--r) var(--r) 0; }
.input-addon {
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  border-right: none;
  border-radius: var(--r) 0 0 var(--r);
  color: var(--text-tertiary);
  font-size: 13px;
  white-space: nowrap;
}

/* ─────────────────────────────────────────────────────────────────
   TABLES
   ───────────────────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.data-table thead {
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
}
.data-table thead th {
  padding: 11px 16px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-tertiary);
  text-align: left;
  white-space: nowrap;
}
.data-table thead th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color var(--dur-fast);
}
.data-table thead th.sortable:hover { color: var(--text-primary); }
.data-table tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--dur-fast);
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-subtle); }
.data-table td {
  padding: 13px 16px;
  color: var(--text-primary);
  vertical-align: middle;
}
.data-table td.muted { color: var(--text-secondary); }
.table-actions { display: flex; align-items: center; gap: 6px; }
.table-avatar {
  width: 32px; height: 32px;
  border-radius: var(--r-full);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
}
.table-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ─────────────────────────────────────────────────────────────────
   MODALS
   ───────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(9,14,26,.5);
  backdrop-filter: blur(4px);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease);
}
.modal-backdrop.show { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  transform: scale(.95) translateY(10px);
  transition: transform var(--dur-base) var(--ease-spring);
  overflow: hidden;
}
.modal-backdrop.show .modal { transform: scale(1) translateY(0); }
.modal-lg { max-width: 720px; }
.modal-xl { max-width: 960px; }
.modal-sm { max-width: 380px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title {
  font-size: 16px;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--text-primary);
  letter-spacing: -.02em;
}
.modal-close {
  width: 32px; height: 32px;
  border-radius: var(--r);
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.modal-close:hover { background: var(--bg-subtle); color: var(--text-primary); }
.modal-body {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
  background: var(--bg-subtle);
}

/* ─────────────────────────────────────────────────────────────────
   ALERTS & TOASTS
   ───────────────────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--r);
  border: 1px solid;
  font-size: 13.5px;
  line-height: 1.5;
}
.alert svg { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; }
.alert-title { font-weight: 600; margin-bottom: 2px; font-size: 14px; }
.alert-success { background: var(--success-bg); border-color: var(--success-border); color: var(--success-text); }
.alert-danger  { background: var(--danger-bg);  border-color: var(--danger-border);  color: var(--danger-text); }
.alert-warning { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning-text); }
.alert-info    { background: var(--info-bg);    border-color: var(--info-border);    color: var(--info-text); }

/* Toast container */
.toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
  width: calc(100vw - 48px);
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  animation: toastIn .3s var(--ease-spring) forwards;
  position: relative;
  overflow: hidden;
}
.toast.leaving { animation: toastOut .25s var(--ease) forwards; }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px) scale(.95); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); max-height: 120px; margin-bottom: 0; }
  to   { opacity: 0; transform: translateX(40px); max-height: 0; margin-bottom: -10px; }
}
.toast-icon { width: 20px; height: 20px; flex-shrink: 0; }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-size: 13.5px; font-weight: 700; color: var(--text-primary); margin-bottom: 1px; }
.toast-msg { font-size: 13px; color: var(--text-secondary); }
.toast-close { background: none; border: none; cursor: pointer; color: var(--text-tertiary); padding: 0; line-height: 1; }
.toast-close:hover { color: var(--text-primary); }
.toast-progress {
  position: absolute;
  bottom: 0; left: 0;
  height: 2px;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  animation: toastProgress linear forwards;
}
@keyframes toastProgress { from { width: 100%; } to { width: 0%; } }
.toast-success .toast-icon { color: var(--success); }
.toast-success .toast-progress { background: var(--success); }
.toast-danger .toast-icon { color: var(--danger); }
.toast-danger .toast-progress { background: var(--danger); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-warning .toast-progress { background: var(--warning); }
.toast-info .toast-icon { color: var(--info); }
.toast-info .toast-progress { background: var(--info); }

/* ─────────────────────────────────────────────────────────────────
   SKELETON LOADERS
   ───────────────────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-subtle) 25%, var(--bg-muted) 50%, var(--bg-subtle) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.6s infinite;
  border-radius: var(--r);
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skel-line { height: 14px; border-radius: var(--r-sm); }
.skel-circle { border-radius: 50%; }
.skel-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 20px; }
.skel-avatar { width: 40px; height: 40px; }
.skel-title { height: 20px; width: 60%; }
.skel-text  { height: 13px; }
.skel-btn   { height: 36px; width: 100px; }

/* ─────────────────────────────────────────────────────────────────
   PAGE HEADER & BREADCRUMB
   ───────────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}
.page-header-left { min-width: 0; }
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 12.5px;
  color: var(--text-tertiary);
  flex-wrap: wrap;
}
.breadcrumb a { color: var(--text-secondary); font-weight: 500; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb-sep { color: var(--text-tertiary); user-select: none; }
.page-title {
  font-size: 22px;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--text-primary);
  letter-spacing: -.025em;
  line-height: 1.2;
}
.page-subtitle {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.5;
}
.page-header-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ─────────────────────────────────────────────────────────────────
   TABS
   ───────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color var(--dur-fast), border-color var(--dur-fast);
  text-decoration: none;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: var(--font-body);
  margin-bottom: -1px;
}
.tab-item:hover { color: var(--text-primary); }
.tab-item.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-item svg { width: 15px; height: 15px; }
.tab-count {
  background: var(--bg-subtle);
  color: var(--text-tertiary);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: var(--r-full);
  font-weight: 700;
}
.tab-item.active .tab-count { background: var(--accent-soft); color: var(--accent); }

/* Tab pills variant */
.tabs-pills {
  display: flex;
  gap: 6px;
  background: var(--bg-subtle);
  padding: 4px;
  border-radius: var(--r-lg);
  border-bottom: none;
  margin-bottom: 20px;
}
.tabs-pills .tab-item {
  border-radius: var(--r);
  border-bottom: none;
  margin-bottom: 0;
  padding: 7px 14px;
  font-size: 13px;
}
.tabs-pills .tab-item.active {
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  border-color: transparent;
}

/* ─────────────────────────────────────────────────────────────────
   LOADING BAR
   ───────────────────────────────────────────────────────────────── */
.loading-bar {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--violet-500));
  z-index: 9999;
  transition: width .3s var(--ease-out);
  box-shadow: 0 0 8px rgba(99,102,241,.5);
}
.loading-bar.loading { width: 70%; }
.loading-bar.done { width: 100%; transition: width .2s var(--ease-out), opacity .4s .1s; opacity: 0; }

/* HTMX loading indicator */
.htmx-indicator {
  opacity: 0;
  transition: opacity var(--dur-base);
}
.htmx-request .htmx-indicator { opacity: 1; }
.htmx-request.htmx-indicator { opacity: 1; }

/* ─────────────────────────────────────────────────────────────────
   EMPTY STATE
   ───────────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  gap: 16px;
}
.empty-state-icon {
  width: 64px; height: 64px;
  background: var(--bg-subtle);
  border-radius: var(--r-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
}
.empty-state-icon svg { width: 28px; height: 28px; }
.empty-state h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.015em;
}
.empty-state p {
  font-size: 13.5px;
  color: var(--text-secondary);
  max-width: 320px;
  line-height: 1.6;
}

/* ─────────────────────────────────────────────────────────────────
   PROGRESS BARS
   ───────────────────────────────────────────────────────────────── */
.progress {
  height: 6px;
  background: var(--bg-subtle);
  border-radius: var(--r-full);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  border-radius: var(--r-full);
  background: var(--accent);
  transition: width .5s var(--ease);
}
.progress-bar-success { background: var(--success); }
.progress-bar-danger  { background: var(--danger); }
.progress-bar-warning { background: var(--warning); }
.progress-sm { height: 4px; }
.progress-lg { height: 10px; }

/* ─────────────────────────────────────────────────────────────────
   SEARCH RESULTS DROPDOWN
   ───────────────────────────────────────────────────────────────── */
.search-results-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 100%;
  min-width: 360px;
  background: var(--surface-overlay);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl);
  z-index: 999;
  overflow: hidden;
  display: none;
}
.search-results-panel.show { display: block; }
.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  transition: background var(--dur-fast);
  cursor: pointer;
  text-decoration: none;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg-subtle); }
.search-result-icon { width: 36px; height: 36px; background: var(--bg-subtle); border-radius: var(--r); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.search-result-icon svg { width: 17px; height: 17px; color: var(--text-secondary); }
.search-result-title { font-size: 13.5px; font-weight: 600; color: var(--text-primary); }
.search-result-meta { font-size: 12px; color: var(--text-tertiary); margin-top: 1px; }
.search-results-header { padding: 8px 14px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--text-tertiary); background: var(--bg-subtle); }

/* ─────────────────────────────────────────────────────────────────
   NOTIFICATION PANEL
   ───────────────────────────────────────────────────────────────── */
.notif-panel {
  min-width: 340px;
  max-width: 380px;
}
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--dur-fast);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg-subtle); }
.notif-item.unread { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.notif-item.unread .notif-title { font-weight: 700; }
.notif-icon { width: 36px; height: 36px; border-radius: var(--r-full); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.notif-icon svg { width: 16px; height: 16px; }
.notif-title { font-size: 13px; color: var(--text-primary); line-height: 1.4; }
.notif-time { font-size: 11.5px; color: var(--text-tertiary); margin-top: 2px; }
.notif-unread-dot { width: 7px; height: 7px; background: var(--accent); border-radius: 50%; flex-shrink: 0; margin-top: 5px; }

/* ─────────────────────────────────────────────────────────────────
   AVATAR
   ───────────────────────────────────────────────────────────────── */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-full);
  font-family: var(--font-display);
  font-weight: 700;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--accent-soft);
  color: var(--accent);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-md { width: 36px; height: 36px; font-size: 14px; }
.avatar-lg { width: 48px; height: 48px; font-size: 18px; }
.avatar-xl { width: 64px; height: 64px; font-size: 24px; }
.avatar-group { display: flex; }
.avatar-group .avatar { border: 2px solid var(--surface); margin-left: -8px; }
.avatar-group .avatar:first-child { margin-left: 0; }

/* ─────────────────────────────────────────────────────────────────
   SWITCH / TOGGLE
   ───────────────────────────────────────────────────────────────── */
.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track {
  position: absolute;
  inset: 0;
  background: var(--border-strong);
  border-radius: var(--r-full);
  cursor: pointer;
  transition: background var(--dur-base);
}
.switch-track::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform var(--dur-base) var(--ease-spring);
  box-shadow: var(--shadow-sm);
}
.switch input:checked ~ .switch-track { background: var(--accent); }
.switch input:checked ~ .switch-track::before { transform: translateX(18px); }
.switch input:focus ~ .switch-track { box-shadow: var(--shadow-focus); }

/* ─────────────────────────────────────────────────────────────────
   FILTER BAR
   ───────────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 13px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--dur-fast);
  text-decoration: none;
  background: var(--surface);
}
.filter-pill:hover { border-color: var(--border-strong); color: var(--text-primary); }
.filter-pill.active { background: var(--accent-soft); color: var(--accent); border-color: var(--indigo-200); font-weight: 600; }
.filter-pill svg { width: 13px; height: 13px; }
.filter-pill .pill-count { font-size: 11px; font-weight: 700; background: currentColor; color: var(--surface); padding: 0 5px; border-radius: var(--r-full); opacity: .7; }

/* ─────────────────────────────────────────────────────────────────
   NOTE CARD
   ───────────────────────────────────────────────────────────────── */
.note-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
  transition: all var(--dur-base);
  text-decoration: none;
  display: block;
  cursor: pointer;
}
.note-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); transform: translateY(-2px); }
.note-card-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.note-card-title { font-size: 14.5px; font-weight: 700; color: var(--text-primary); letter-spacing: -.015em; margin-bottom: 6px; line-height: 1.35; font-family: var(--font-display); }
.note-card-excerpt { font-size: 13px; color: var(--text-secondary); line-height: 1.55; margin-bottom: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.note-card-footer { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.note-card-stat { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-tertiary); }
.note-card-stat svg { width: 13px; height: 13px; }
.notes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }

/* Progress ring (reading progress) */
.progress-ring-wrap { position: relative; width: 32px; height: 32px; flex-shrink: 0; }
.progress-ring { transform: rotate(-90deg); }
.progress-ring-track { fill: none; stroke: var(--bg-muted); stroke-width: 3; }
.progress-ring-fill { fill: none; stroke: var(--success); stroke-width: 3; stroke-linecap: round; transition: stroke-dashoffset .4s var(--ease); }

/* ─────────────────────────────────────────────────────────────────
   GLOBAL SEARCH COMMAND PALETTE
   ───────────────────────────────────────────────────────────────── */
.command-palette-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(9,14,26,.6);
  backdrop-filter: blur(6px);
  z-index: 9000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 120px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base);
}
.command-palette-backdrop.show { opacity: 1; pointer-events: auto; }
.command-palette {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 580px;
  overflow: hidden;
  transform: translateY(-20px) scale(.97);
  transition: transform var(--dur-base) var(--ease-spring);
}
.command-palette-backdrop.show .command-palette { transform: translateY(0) scale(1); }
.command-palette-input-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.command-palette-input-wrap svg { color: var(--text-tertiary); flex-shrink: 0; width: 20px; height: 20px; }
.command-palette-input {
  flex: 1;
  font-size: 16px;
  color: var(--text-primary);
  background: none;
  border: none;
  outline: none;
  font-family: var(--font-body);
}
.command-palette-input::placeholder { color: var(--text-tertiary); }
.command-palette-results { max-height: 400px; overflow-y: auto; padding: 6px; }
.command-result-group-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-tertiary);
  padding: 8px 10px 4px;
}
.command-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: var(--r);
  cursor: pointer;
  transition: background var(--dur-fast);
  text-decoration: none;
  color: var(--text-primary);
}
.command-result-item:hover, .command-result-item.selected {
  background: var(--accent-soft);
}
.command-result-item-icon { width: 32px; height: 32px; border-radius: var(--r); background: var(--bg-subtle); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.command-result-item-icon svg { width: 16px; height: 16px; color: var(--text-secondary); }
.command-result-title { font-size: 14px; font-weight: 500; }
.command-result-meta { font-size: 12px; color: var(--text-tertiary); }
.command-palette-footer { padding: 10px 16px; border-top: 1px solid var(--border); background: var(--bg-subtle); display: flex; gap: 16px; }
.command-hint { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-tertiary); }
.command-hint kbd { background: var(--bg-muted); border: 1px solid var(--border-strong); border-radius: 4px; padding: 1px 5px; font-size: 11px; font-family: var(--font-mono); color: var(--text-secondary); }

/* ─────────────────────────────────────────────────────────────────
   UTILITIES
   ───────────────────────────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.flex-1 { flex: 1; }
.min-w-0 { min-width: 0; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid { display: grid; }
.grid-2 { grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4,1fr); gap: 16px; }
.mt-1 { margin-top: 4px; }  .mt-2 { margin-top: 8px; }  .mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; } .mt-8 { margin-top: 32px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; } .mb-8 { margin-bottom: 32px; }
.text-xs  { font-size: 12px; }
.text-sm  { font-size: 13px; }
.text-base{ font-size: 14px; }
.text-lg  { font-size: 16px; }
.text-xl  { font-size: 18px; }
.text-2xl { font-size: 22px; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-center { text-align: center; }
.hidden { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border-width: 0; }

/* Divider */
.divider { border: none; border-top: 1px solid var(--border); margin: var(--sp-4) 0; }

/* Code */
code, .code { font-family: var(--font-mono); font-size: 12.5px; background: var(--bg-subtle); color: var(--accent); padding: 1px 6px; border-radius: var(--r-sm); border: 1px solid var(--border); }
pre { background: var(--slate-900); color: var(--slate-100); padding: 18px; border-radius: var(--r-lg); overflow-x: auto; font-family: var(--font-mono); font-size: 13px; line-height: 1.6; }
[data-theme="dark"] pre { background: var(--bg-elevated); border: 1px solid var(--border); }

/* Scroll fade */
.scroll-fade-bottom {
  -webkit-mask-image: linear-gradient(to bottom, black 80%, transparent 100%);
  mask-image: linear-gradient(to bottom, black 80%, transparent 100%);
}

/* Responsive grid breakpoints */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2,1fr); }
  .grid-3 { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2,1fr); }
  .page-header { flex-direction: column; align-items: flex-start; }
  .page-header-right { width: 100%; }
  .notes-grid { grid-template-columns: 1fr; }
}

/* ─────────────────────────────────────────────────────────────────
   HTMX-SPECIFIC TRANSITIONS & OPTIMISTIC UI
   ───────────────────────────────────────────────────────────────── */
.htmx-swapping { opacity: 0; transition: opacity var(--dur-base); }
.htmx-settling  { opacity: 0; }
.htmx-settling.htmx-added { opacity: 1; transition: opacity var(--dur-slow); }

/* Fade swap */
[hx-swap*="transition:true"] { transition: opacity var(--dur-base); }

/* Staggered list items */
.stagger-children > * { opacity: 0; animation: fadeUp .35s var(--ease-out) forwards; }
.stagger-children > *:nth-child(1) { animation-delay: .05s; }
.stagger-children > *:nth-child(2) { animation-delay: .1s; }
.stagger-children > *:nth-child(3) { animation-delay: .15s; }
.stagger-children > *:nth-child(4) { animation-delay: .2s; }
.stagger-children > *:nth-child(5) { animation-delay: .25s; }
.stagger-children > *:nth-child(n+6) { animation-delay: .3s; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Bottom navigation (mobile) */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 60px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 300;
  padding: 0 12px;
  align-items: center;
  justify-content: space-around;
  backdrop-filter: blur(12px);
}
@media (max-width: 768px) { .bottom-nav { display: flex; } main.content { padding-bottom: 76px; } }
.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 12px;
  border-radius: var(--r);
  color: var(--text-tertiary);
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
  transition: color var(--dur-fast);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
}
.bottom-nav-item svg { width: 22px; height: 22px; }
.bottom-nav-item.active { color: var(--accent); }
.bottom-nav-item .nav-dot {
  position: absolute;
  top: 6px;
  right: 10px;
  width: 6px; height: 6px;
  background: var(--danger);
  border-radius: 50%;
  border: 1.5px solid var(--surface);
}

/* ─────────────────────────────────────────────────────────────────
   SCROLLBAR GLOBAL
   ───────────────────────────────────────────────────────────────── */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--r-full); }
*::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }
