/* ================================================================
   CONVERSIONPAGE — Complete Design System
   Premium admin panel. Emerald accent, slate foundation.
   Light + Dark themes. Fully responsive.
   ================================================================ */

/* ----------------------------------------------------------------
   0. Reset & Base
   ---------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  transition: background 0.3s ease, color 0.3s ease;
}

/* ----------------------------------------------------------------
   1. CSS Custom Properties — Light Theme (default)
   ---------------------------------------------------------------- */
:root {
  --emerald-50:  #ecfdf5;
  --emerald-100: #d1fae5;
  --emerald-200: #a7f3d0;
  --emerald-300: #6ee7b7;
  --emerald-400: #34d399;
  --emerald-500: #10b981;
  --emerald-600: #059669;
  --emerald-700: #047857;
  --emerald-800: #065f46;
  --emerald-900: #064e3b;

  --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;

  --primary:       var(--emerald-500);
  --primary-hover:  var(--emerald-600);
  --primary-soft:  var(--emerald-50);
  --primary-muted: var(--emerald-100);
  --primary-glow:  rgba(16, 185, 129, 0.15);

  --success:       #10b981;
  --success-soft:  #ecfdf5;
  --warning:       #f59e0b;
  --warning-soft:  #fffbeb;
  --error:         #ef4444;
  --error-soft:    #fef2f2;
  --info:          #3b82f6;
  --info-soft:     #eff6ff;
  --pending:       #8b5cf6;
  --pending-soft:  #f5f3ff;

  --bg-body:       #f6f8fb;
  --bg-surface:    #ffffff;
  --bg-surface-hover: #f8fafc;
  --bg-elevated:   #ffffff;
  --bg-inset:      #f1f5f9;

  --sidebar-bg:    var(--slate-900);
  --sidebar-bg-hover: rgba(255, 255, 255, 0.06);
  --sidebar-bg-active: rgba(16, 185, 129, 0.12);
  --sidebar-text:  var(--slate-400);
  --sidebar-text-active: #ffffff;
  --sidebar-accent: var(--emerald-400);
  --sidebar-width: 260px;
  --sidebar-width-collapsed: 72px;
  --sidebar-border: rgba(255, 255, 255, 0.06);

  --topbar-height: 64px;
  --topbar-bg:     rgba(255, 255, 255, 0.8);
  --topbar-border: var(--slate-200);

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

  --border:        var(--slate-200);
  --border-light:  var(--slate-100);
  --border-focus:  var(--emerald-500);

  --shadow-xs:     0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm:     0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md:     0 4px 6px -1px rgba(0, 0, 0, 0.06), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg:     0 10px 15px -3px rgba(0, 0, 0, 0.06), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl:     0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  --shadow-glow:   0 0 20px rgba(16, 185, 129, 0.15);

  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  14px;
  --radius-xl:  20px;
  --radius-full: 9999px;

  --transition-fast:   150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow:   350ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ----------------------------------------------------------------
   1b. Dark Theme
   ---------------------------------------------------------------- */
[data-theme="dark"] {
  --bg-body:       #0c0f16;
  --bg-surface:    #141820;
  --bg-surface-hover: #1a1f2b;
  --bg-elevated:   #1a1f2b;
  --bg-inset:      #0f1219;

  --sidebar-bg:    #0a0d14;
  --sidebar-bg-hover: rgba(255, 255, 255, 0.05);
  --sidebar-border: rgba(255, 255, 255, 0.04);

  --topbar-bg:     rgba(20, 24, 32, 0.85);
  --topbar-border: rgba(255, 255, 255, 0.06);

  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-tertiary:  #64748b;

  --border:        rgba(255, 255, 255, 0.08);
  --border-light:  rgba(255, 255, 255, 0.04);

  --primary-soft:  rgba(16, 185, 129, 0.1);
  --primary-muted: rgba(16, 185, 129, 0.15);

  --success-soft:  rgba(16, 185, 129, 0.12);
  --warning-soft:  rgba(245, 158, 11, 0.12);
  --error-soft:    rgba(239, 68, 68, 0.12);
  --info-soft:     rgba(59, 130, 246, 0.12);
  --pending-soft:  rgba(139, 92, 246, 0.12);

  --shadow-xs:     0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-sm:     0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md:     0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
  --shadow-lg:     0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.2);
  --shadow-xl:     0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .badge-success { color: #6ee7b7; }
[data-theme="dark"] .badge-warning { color: #fbbf24; }
[data-theme="dark"] .badge-error { color: #fca5a5; }
[data-theme="dark"] .badge-info { color: #93c5fd; }
[data-theme="dark"] .badge-pending { color: #c4b5fd; }
[data-theme="dark"] .badge-neutral { color: var(--slate-300); }
[data-theme="dark"] .sidebar-link.active { color: #fff; }
[data-theme="dark"] .code-block { background: #0a0d14; border-color: rgba(255,255,255,0.06); }
[data-theme="dark"] .kpi-card::before { opacity: 0.8; }
[data-theme="dark"] tbody tr:hover { background: rgba(16,185,129,0.06); }
[data-theme="dark"] .chart-container line { stroke: rgba(255,255,255,0.06) !important; }
[data-theme="dark"] .chart-container text { fill: var(--slate-500) !important; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }
[data-theme="dark"] .login-right { background: linear-gradient(135deg, #060810, #0a0d14); }
[data-theme="dark"] .form-input { background: var(--bg-inset); }
[data-theme="dark"] .modal-content { background: var(--bg-elevated); }

/* ----------------------------------------------------------------
   2. Typography
   ---------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.text-sm { font-size: 0.8667rem; }
.text-xs { font-size: 0.8rem; }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-primary-color { color: var(--primary); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-mono {
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;
  font-size: 0.9em;
}

/* ----------------------------------------------------------------
   3. Layout — App Shell
   ---------------------------------------------------------------- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width var(--transition-normal);
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-width-collapsed);
}

.sidebar-header {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-logo:hover { text-decoration: none; }

.sidebar-logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--emerald-400), var(--emerald-600));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo-icon svg {
  width: 18px;
  height: 18px;
  color: #fff;
}

.sidebar-logo-text {
  font-size: 1.067rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  opacity: 1;
  transition: opacity var(--transition-fast);
}

.sidebar.collapsed .sidebar-logo-text {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--sidebar-bg-hover) transparent;
}

.sidebar-section {
  margin-bottom: 8px;
}

.sidebar-section-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--slate-500);
  padding: 8px 12px 6px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--transition-fast);
}

.sidebar.collapsed .sidebar-section-title {
  opacity: 0;
  height: 0;
  padding: 0;
  margin: 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 450;
  white-space: nowrap;
  transition: all var(--transition-fast);
  position: relative;
  cursor: pointer;
}

.sidebar-link:hover {
  background: var(--sidebar-bg-hover);
  color: var(--slate-200);
  text-decoration: none;
}

.sidebar-link.active {
  background: var(--sidebar-bg-active);
  color: var(--sidebar-text-active);
}

.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--sidebar-accent);
  border-radius: 0 3px 3px 0;
}

.sidebar-link svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar-link.active svg {
  opacity: 1;
  color: var(--sidebar-accent);
}

.sidebar-link-text {
  opacity: 1;
  transition: opacity var(--transition-fast);
}

.sidebar.collapsed .sidebar-link-text {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.sidebar-link .badge-count {
  margin-left: auto;
  background: var(--emerald-500);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  min-width: 20px;
  text-align: center;
}

.sidebar.collapsed .badge-count {
  display: none;
}

/* Sidebar collapse: hide text elements */
.sidebar.collapsed .sidebar-link > span:not([class]) {
  opacity: 0; width: 0; overflow: hidden;
}
.sidebar.collapsed .user-menu-info {
  opacity: 0; width: 0; overflow: hidden; position: absolute;
}
.sidebar.collapsed .sidebar-link {
  justify-content: center;
  padding: 9px 0;
}
.sidebar.collapsed .sidebar-link svg { margin: 0; }
.sidebar.collapsed .user-menu {
  justify-content: center;
  padding: 12px 8px;
}
.sidebar.collapsed .sidebar-header {
  justify-content: center;
  padding: 0;
}
.sidebar.collapsed .sidebar-nav {
  padding: 12px 6px;
}
.sidebar.collapsed .sidebar-link.active::before {
  left: 0;
}

/* Sidebar toggle button */
.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  margin: 8px 10px;
  border: 1px solid var(--sidebar-border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--sidebar-text);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.sidebar-toggle:hover {
  background: var(--sidebar-bg-hover);
  color: #fff;
}

.sidebar-toggle svg {
  width: 18px;
  height: 18px;
  transition: transform var(--transition-normal);
}

.sidebar.collapsed .sidebar-toggle svg {
  transform: rotate(180deg);
}

/* User menu in sidebar */
.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  margin: 8px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--sidebar-border);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.user-menu:hover {
  background: var(--sidebar-bg-hover);
}

.user-menu-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--emerald-400), var(--emerald-600));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
}

.user-menu-name {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--slate-200);
  white-space: nowrap;
}

.user-menu-role {
  font-size: 0.7rem;
  color: var(--slate-500);
}

/* --- Main content area --- */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  transition: margin-left var(--transition-normal);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.sidebar.collapsed ~ .main-wrapper {
  margin-left: var(--sidebar-width-collapsed);
}

/* --- Topbar --- */
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-height);
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--topbar-border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-burger {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
}

.topbar-burger:hover { color: var(--text-primary); }
.topbar-burger svg { width: 22px; height: 22px; }

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8667rem;
  color: var(--text-tertiary);
}

.breadcrumb a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.breadcrumb a:hover { color: var(--primary); text-decoration: none; }

.breadcrumb-sep {
  color: var(--text-tertiary);
  font-size: 0.75rem;
}

.breadcrumb-current {
  color: var(--text-primary);
  font-weight: 500;
}

.topbar-spacer { flex: 1; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.topbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.topbar-btn:hover {
  background: var(--bg-inset);
  color: var(--text-primary);
}

.topbar-btn svg { width: 20px; height: 20px; }

.topbar-btn .notification-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: var(--error);
  border-radius: 50%;
  border: 2px solid var(--topbar-bg);
}

.topbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-inset);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text-tertiary);
  font-size: 0.8667rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  min-width: 220px;
}

.topbar-search:hover {
  border-color: var(--border);
  color: var(--text-secondary);
}

.topbar-search svg { width: 16px; height: 16px; }

.topbar-search kbd {
  margin-left: auto;
  font-size: 0.7rem;
  font-family: inherit;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--text-tertiary);
}

.topbar-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--emerald-400), var(--emerald-600));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: box-shadow var(--transition-fast);
  margin-left: 4px;
}

.topbar-avatar:hover {
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* --- Content area --- */
.content {
  flex: 1;
  padding: 28px;
  animation: fadeSlideIn 0.35s ease forwards;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.page-subtitle {
  font-size: 0.8667rem;
  color: var(--text-secondary);
}

.page-header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* Mobile overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
  backdrop-filter: blur(2px);
}

.sidebar-overlay.active { display: block; }

/* ----------------------------------------------------------------
   4. Cards
   ---------------------------------------------------------------- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-light);
}

.card-title {
  font-size: 0.9333rem;
  font-weight: 600;
}

.card-body {
  padding: 22px;
}

.card-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border-light);
}

/* ----------------------------------------------------------------
   5. KPI Cards
   ---------------------------------------------------------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.kpi-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border);
}

/* Colored top border */
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.kpi-card:nth-child(1)::before { background: linear-gradient(90deg, var(--emerald-400), var(--emerald-500)); }
.kpi-card:nth-child(2)::before { background: linear-gradient(90deg, #3b82f6, #6366f1); }
.kpi-card:nth-child(3)::before { background: linear-gradient(90deg, #8b5cf6, #a78bfa); }
.kpi-card:nth-child(4)::before { background: linear-gradient(90deg, #f59e0b, #f97316); }

.kpi-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kpi-card-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-card-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-card-icon svg { width: 18px; height: 18px; }

.kpi-card-icon.emerald { background: var(--primary-soft); color: var(--emerald-600); }
.kpi-card-icon.blue { background: var(--info-soft); color: var(--info); }
.kpi-card-icon.amber { background: var(--warning-soft); color: var(--warning); }
.kpi-card-icon.violet { background: var(--pending-soft); color: var(--pending); }

.kpi-card-value {
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
}

.kpi-card-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
}

.kpi-trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: 600;
  font-size: 0.8rem;
}

.kpi-trend.up { color: var(--success); }
.kpi-trend.down { color: var(--error); }
.kpi-trend svg { width: 14px; height: 14px; }

/* ----------------------------------------------------------------
   6. Dashboard
   ---------------------------------------------------------------- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
  position: relative;
}

.stat-row:last-child { border-bottom: none; }

.stat-row-label {
  font-size: 0.8667rem;
  color: var(--text-secondary);
}

.stat-row-value {
  font-size: 0.9333rem;
  font-weight: 600;
}

.stat-row-bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: var(--primary-soft);
  border-radius: var(--radius-sm);
  transition: width 0.6s ease;
  z-index: 0;
}

.stat-row > * { position: relative; z-index: 1; }

/* Chart */
.chart-container {
  position: relative;
  width: 100%;
  height: 280px;
  border-radius: var(--radius-md);
  overflow: hidden;
}

/* ----------------------------------------------------------------
   7. Tables
   ---------------------------------------------------------------- */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

thead th {
  font-size: 0.7667rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  background: var(--bg-inset);
  padding: 11px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

thead th:first-child { padding-left: 22px; }
thead th:last-child { padding-right: 22px; }

tbody tr {
  transition: all var(--transition-fast);
  border-left: 3px solid transparent;
}

tbody tr:hover {
  background: var(--primary-soft);
  border-left-color: var(--primary);
}

tbody tr:hover td:first-child {
  padding-left: 19px;
}

tbody tr[data-href] { cursor: pointer; }

tbody td {
  padding: 13px 16px;
  font-size: 0.8667rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  vertical-align: middle;
}

tbody td:first-child { padding-left: 22px; }
tbody td:last-child { padding-right: 22px; }

.table-wrapper { overflow-x: auto; }

/* Table ID cells */
.cell-id {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--primary);
  cursor: pointer;
}

.cell-id:hover { text-decoration: underline; }

/* ----------------------------------------------------------------
   8. Badges
   ---------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.7333rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  animation: badgePop 0.3s ease forwards;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge-success { background: var(--success-soft); color: var(--emerald-700); }
.badge-success .badge-dot { background: var(--success); }

.badge-warning { background: var(--warning-soft); color: #92400e; }
.badge-warning .badge-dot { background: var(--warning); }

.badge-error { background: var(--error-soft); color: #991b1b; }
.badge-error .badge-dot { background: var(--error); }

.badge-info { background: var(--info-soft); color: #1e40af; }
.badge-info .badge-dot { background: var(--info); }

.badge-pending { background: var(--pending-soft); color: #5b21b6; }
.badge-pending .badge-dot { background: var(--pending); }

.badge-neutral { background: var(--bg-inset); color: var(--text-secondary); }
.badge-neutral .badge-dot { background: var(--slate-400); }

/* ----------------------------------------------------------------
   9. Buttons
   ---------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  font-family: inherit;
  font-size: 0.8667rem;
  font-weight: 500;
  line-height: 1.4;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
}

.btn:hover { text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 1px 3px rgba(16, 185, 129, 0.3);
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--bg-surface-hover);
  border-color: var(--slate-300);
}

.btn-danger {
  background: var(--error);
  color: #fff;
  border-color: var(--error);
}

.btn-danger:hover {
  background: #dc2626;
  border-color: #dc2626;
}

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

.btn-ghost:hover {
  background: var(--bg-inset);
  color: var(--text-primary);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-xs {
  padding: 4px 8px;
  font-size: 0.7333rem;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 0.9333rem;
  font-weight: 600;
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: var(--radius-md);
}

.btn-icon.btn-sm {
  width: 28px;
  height: 28px;
}

/* ----------------------------------------------------------------
   10. Forms
   ---------------------------------------------------------------- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
}

.form-label {
  font-size: 0.8667rem;
  font-weight: 500;
  color: var(--text-primary);
}

.form-input,
.form-select,
.form-textarea {
  padding: 9px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.8667rem;
  color: var(--text-primary);
  outline: none;
  transition: all var(--transition-fast);
  width: 100%;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-tertiary);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%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;
}

.form-textarea {
  min-height: 80px;
  resize: vertical;
}

.form-help {
  font-size: 0.8rem;
  color: var(--text-tertiary);
}

.form-error {
  font-size: 0.8rem;
  color: var(--error);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.8667rem;
  color: var(--text-secondary);
}

.checkbox-box {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.checkbox-box.checked {
  background: var(--primary);
  border-color: var(--primary);
}

.checkbox-box.checked svg { display: block; color: #fff; }

/* Toggle switch */
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--border);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.toggle.active { background: var(--primary); }

.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.toggle.active::after { transform: translateX(20px); }

/* ----------------------------------------------------------------
   11. Modals
   ---------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease forwards;
}

.modal-content {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalSlideIn 0.3s ease forwards;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--bg-inset);
  color: var(--text-primary);
}

.modal-close svg { width: 18px; height: 18px; }

.modal-body {
  padding: 24px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
}

/* ----------------------------------------------------------------
   12. Filter Chips / Tabs
   ---------------------------------------------------------------- */
.filter-chips {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-chip:hover {
  border-color: var(--border);
  color: var(--text-primary);
}

.filter-chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.filter-chip .chip-count {
  font-size: 0.7rem;
  background: rgba(255, 255, 255, 0.2);
  padding: 1px 6px;
  border-radius: var(--radius-full);
}

.filter-chip:not(.active) .chip-count {
  background: var(--bg-inset);
  color: var(--text-tertiary);
}

/* ----------------------------------------------------------------
   13. Pagination
   ---------------------------------------------------------------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-top: 1px solid var(--border-light);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.pagination-info { }

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pagination-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.pagination-btn:hover {
  border-color: var(--border);
  color: var(--text-primary);
}

.pagination-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination-btn svg { width: 16px; height: 16px; }

/* ----------------------------------------------------------------
   14. Toast Notifications
   ---------------------------------------------------------------- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-size: 0.8667rem;
  pointer-events: auto;
  animation: toastIn 0.35s ease forwards;
  max-width: 380px;
}

.toast.removing {
  animation: toastOut 0.3s ease forwards;
}

.toast svg { width: 18px; height: 18px; flex-shrink: 0; }

.toast-success { border-left: 3px solid var(--success); }
.toast-success svg { color: var(--success); }

.toast-error { border-left: 3px solid var(--error); }
.toast-error svg { color: var(--error); }

.toast-info { border-left: 3px solid var(--info); }
.toast-info svg { color: var(--info); }

.toast-warning { border-left: 3px solid var(--warning); }
.toast-warning svg { color: var(--warning); }

/* ----------------------------------------------------------------
   15. Login Page
   ---------------------------------------------------------------- */
.login-page {
  min-height: 100vh;
  display: flex;
  background: var(--bg-body);
}

.login-left {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  animation: fadeIn 0.5s ease-out forwards;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 40px;
}

.login-logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--emerald-400), var(--emerald-600));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-logo-icon svg { width: 22px; height: 22px; color: #fff; }

.login-logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}

.login-heading {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -0.03em;
}

.login-subheading {
  color: var(--text-secondary);
  font-size: 0.9333rem;
  margin-bottom: 32px;
}

.login-remember-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  font-size: 0.8667rem;
}

.login-remember-row a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.login-remember-row a:hover { text-decoration: underline; }

.login-right {
  flex: 1;
  background: linear-gradient(135deg, var(--slate-900) 0%, var(--slate-800) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  position: relative;
  overflow: hidden;
}

.login-right::before {
  content: '';
  position: absolute;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.15), transparent 70%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.login-right-content {
  position: relative;
  text-align: center;
  color: #fff;
  max-width: 380px;
}

.login-right-content h2 {
  font-size: 1.5rem;
  color: #fff;
  margin-bottom: 12px;
}

.login-right-content p {
  color: var(--slate-300);
  font-size: 0.9333rem;
  line-height: 1.7;
}

.login-right .decorative-grid {
  position: absolute;
  width: 300px;
  height: 300px;
  opacity: 0.08;
}

.login-right .decorative-grid circle { fill: #fff; }

.login-error {
  background: var(--error-soft);
  color: var(--error);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.8667rem;
  margin-bottom: 16px;
  display: none;
}

.login-error.visible { display: block; }

.login-btn-primary {
  width: 100%;
  padding: 12px;
  font-size: 0.9333rem;
  font-weight: 600;
}

/* ----------------------------------------------------------------
   16. Journey / Timeline View
   ---------------------------------------------------------------- */
.journey-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
}

.journey-timeline {
  position: relative;
  padding-left: 40px;
}

.journey-timeline::before {
  content: '';
  position: absolute;
  left: 18px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border-light);
}

.journey-node {
  position: relative;
  margin-bottom: 24px;
  animation: fadeIn 0.35s ease-out forwards;
}

.journey-node-dot {
  position: absolute;
  left: -30px;
  top: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.journey-node-dot.emerald { background: var(--primary-soft); border: 2px solid var(--primary); }
.journey-node-dot.blue { background: var(--info-soft); border: 2px solid var(--info); }
.journey-node-dot.amber { background: var(--warning-soft); border: 2px solid var(--warning); }
.journey-node-dot.green { background: var(--success-soft); border: 2px solid var(--success); }
.journey-node-dot.red { background: var(--error-soft); border: 2px solid var(--error); }
.journey-node-dot.gray { background: var(--bg-inset); border: 2px solid var(--slate-300); }

.journey-node-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
}

.journey-node-title {
  font-size: 0.9333rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.journey-node-time {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  margin-bottom: 12px;
}

.journey-node-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 0.8rem;
}

.journey-node-grid dt {
  color: var(--text-tertiary);
}

.journey-node-grid dd {
  font-weight: 500;
  color: var(--text-primary);
  word-break: break-all;
}

.journey-detail-card {
  position: sticky;
  top: calc(var(--topbar-height) + 28px);
}

/* ----------------------------------------------------------------
   17. Settings Page
   ---------------------------------------------------------------- */
.settings-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
}

.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.settings-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: var(--radius-md);
  font-size: 0.8667rem;
  font-weight: 450;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.settings-nav-link:hover {
  background: var(--bg-inset);
  color: var(--text-primary);
  text-decoration: none;
}

.settings-nav-link.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 500;
}

.settings-nav-link svg { width: 18px; height: 18px; }

.settings-section {
  max-width: 640px;
}

.settings-section-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.settings-section-desc {
  font-size: 0.8667rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.param-grid {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 10px;
  align-items: center;
}

.param-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ----------------------------------------------------------------
   18. Integration Cards
   ---------------------------------------------------------------- */
.integration-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.integration-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all var(--transition-fast);
}

.integration-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow), var(--shadow-md);
}

.integration-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.integration-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-inset);
}

.integration-icon svg { width: 24px; height: 24px; }

.integration-name {
  font-weight: 600;
  font-size: 0.9333rem;
}

.integration-status {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ----------------------------------------------------------------
   19. Code Blocks
   ---------------------------------------------------------------- */
.code-block {
  background: var(--bg-inset);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  line-height: 1.7;
  overflow-x: auto;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-all;
}

.code-editor {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  line-height: 1.7;
  min-height: 200px;
  resize: vertical;
  width: 100%;
  color: var(--text-primary);
  outline: none;
}

.code-editor:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* ----------------------------------------------------------------
   20. Empty & Loading States
   ---------------------------------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.empty-state svg {
  width: 48px;
  height: 48px;
  color: var(--text-tertiary);
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.empty-state-text {
  font-size: 0.8667rem;
  color: var(--text-secondary);
  max-width: 360px;
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner-lg {
  width: 36px;
  height: 36px;
  border-width: 3px;
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 12px;
}

.loading-state .spinner { width: 32px; height: 32px; border-width: 3px; }

/* Skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--bg-inset) 25%, var(--bg-surface-hover) 50%, var(--bg-inset) 75%);
  background-size: 200% 100%;
  animation: skeleton 1.5s ease infinite;
  border-radius: var(--radius-sm);
}

.skeleton-line {
  height: 14px;
  margin-bottom: 8px;
}

.skeleton-line:last-child { width: 60%; }

.skeleton-card {
  height: 100px;
  border-radius: var(--radius-lg);
}

/* ----------------------------------------------------------------
   21. Utility Classes
   ---------------------------------------------------------------- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-5 { margin-top: 20px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.p-3 { padding: 12px; }
.p-4 { padding: 16px; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* ----------------------------------------------------------------
   22. Animations & Keyframes
   ---------------------------------------------------------------- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes badgePop {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.animate-fade-in {
  animation: fadeIn 0.35s ease-out forwards;
}

.stagger-children > * {
  animation: fadeIn 0.35s ease-out forwards;
  opacity: 0;
}

.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 50ms; }
.stagger-children > *:nth-child(3) { animation-delay: 100ms; }
.stagger-children > *:nth-child(4) { animation-delay: 150ms; }
.stagger-children > *:nth-child(5) { animation-delay: 200ms; }
.stagger-children > *:nth-child(6) { animation-delay: 250ms; }

/* ----------------------------------------------------------------
   23. Scrollbar
   ---------------------------------------------------------------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--slate-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--slate-400); }

/* ----------------------------------------------------------------
   24. Confirm Dialog
   ---------------------------------------------------------------- */
.confirm-dialog {
  text-align: center;
  padding: 32px 24px;
}

.confirm-dialog svg {
  width: 48px;
  height: 48px;
  color: var(--error);
  margin-bottom: 16px;
}

.confirm-dialog-title {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.confirm-dialog-text {
  font-size: 0.8667rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.confirm-dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* ----------------------------------------------------------------
   25. Toolbar
   ---------------------------------------------------------------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  min-width: 240px;
  transition: all var(--transition-fast);
}

.toolbar-search:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.toolbar-search svg { width: 16px; height: 16px; color: var(--text-tertiary); flex-shrink: 0; }

.toolbar-search input {
  border: none;
  background: transparent;
  outline: none;
  font-family: inherit;
  font-size: 0.8667rem;
  color: var(--text-primary);
  width: 100%;
}

.toolbar-search input::placeholder { color: var(--text-tertiary); }

.toolbar-spacer { flex: 1; }

/* ----------------------------------------------------------------
   26. Period Selector
   ---------------------------------------------------------------- */
.period-selector {
  display: flex;
  gap: 4px;
  background: var(--bg-inset);
  border-radius: var(--radius-md);
  padding: 3px;
}

.period-btn {
  padding: 4px 12px;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
}

.period-btn:hover { color: var(--text-primary); }

.period-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

/* ----------------------------------------------------------------
   27. Macros Reference
   ---------------------------------------------------------------- */
.macros-list {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 6px 16px;
  font-size: 0.8rem;
}

.macro-name {
  font-family: 'JetBrains Mono', monospace;
  color: var(--primary);
  font-weight: 500;
}

.macro-desc { color: var(--text-secondary); }

/* ----------------------------------------------------------------
   28. Responsive
   ---------------------------------------------------------------- */
@media (max-width: 1024px) {
  .sidebar,
  .sidebar.collapsed {
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
    width: var(--sidebar-width) !important;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.3);
  }

  /* Restore all text when mobile-open */
  .sidebar.mobile-open .sidebar-logo-text,
  .sidebar.mobile-open .sidebar-link-text,
  .sidebar.mobile-open .sidebar-link > span:not([class]),
  .sidebar.mobile-open .badge-count,
  .sidebar.mobile-open .user-menu-info,
  .sidebar.mobile-open .sidebar-section-title {
    opacity: 1 !important;
    width: auto !important;
    height: auto !important;
    overflow: visible !important;
    position: static !important;
    display: inline !important;
  }

  .sidebar.mobile-open .sidebar-link {
    justify-content: flex-start;
    padding: 9px 12px;
  }

  .sidebar.mobile-open .sidebar-header {
    justify-content: flex-start;
    padding: 0 20px;
  }

  .sidebar.mobile-open .sidebar-nav { padding: 12px 10px; }
  .sidebar.mobile-open .user-menu { justify-content: flex-start; padding: 12px 14px; }

  .main-wrapper,
  .sidebar.collapsed ~ .main-wrapper {
    margin-left: 0 !important;
  }

  .topbar-burger { display: flex; }
  .sidebar-toggle { display: none; }

  .dashboard-grid { grid-template-columns: 1fr; }
  .journey-layout { grid-template-columns: 1fr; }
  .settings-layout { grid-template-columns: 1fr; }
  .login-right { display: none; }
}

@media (max-width: 640px) {
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .topbar-search { display: none; }
  .kpi-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .page-header-actions { width: 100%; }
  .form-row { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-search { min-width: 0; width: 100%; }
  .pagination { flex-direction: column; gap: 12px; }
  .modal-content { margin: 16px; max-width: calc(100% - 32px); }
}

/* ----------------------------------------------------------------
   29. Print
   ---------------------------------------------------------------- */
@media print {
  .sidebar,
  .topbar,
  .sidebar-overlay,
  .toast-container { display: none !important; }
  .main-wrapper { margin-left: 0 !important; }
  .content { padding: 0; }
}
