/* ============================================================
   RSE — Design System
   Premium dark glassmorphism theme
   ============================================================ */

/* ---------- CSS Variables ---------- */
:root {
  /* Palette */
  --color-bg-base:       #0f0f23;
  --color-bg-surface:    #1a1a2e;
  --color-bg-elevated:   #16213e;
  --color-bg-card:       rgba(26, 26, 46, 0.65);
  --color-bg-card-hover: rgba(22, 33, 62, 0.80);
  --color-border:        rgba(255, 255, 255, 0.08);
  --color-border-focus:  rgba(124, 58, 237, 0.50);

  --color-primary:       #7c3aed;
  --color-primary-light: #a78bfa;
  --color-secondary:     #2563eb;
  --color-accent:        #06b6d4;

  --gradient-primary:    linear-gradient(135deg, #7c3aed 0%, #2563eb 100%);
  --gradient-primary-h:  linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
  --gradient-shimmer:    linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.04) 50%, transparent 100%);

  --color-text:          #e2e8f0;
  --color-text-muted:    #94a3b8;
  --color-text-dim:      #64748b;
  --color-text-heading:  #f8fafc;

  --color-success:       #22c55e;
  --color-warning:       #f59e0b;
  --color-danger:        #ef4444;
  --color-info:          #3b82f6;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm:   0 1px 2px rgba(0,0,0,0.3);
  --shadow-md:   0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg:   0 8px 30px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 20px rgba(124,58,237,0.25);
  --shadow-glow-blue: 0 0 20px rgba(37,99,235,0.25);

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.3s ease;
  --transition-slow: 0.5s ease;

  /* Layout */
  --sidebar-width: 260px;
  --header-height: 0px;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--color-bg-base);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  overflow: hidden;
}

img, svg { display: block; max-width: 100%; }
a { color: var(--color-primary-light); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { list-style: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ---------- Custom Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(124, 58, 237, 0.3);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: rgba(124, 58, 237, 0.5); }

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(124, 58, 237, 0.3) transparent;
}

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5, h6 {
  color: var(--color-text-heading);
  font-weight: 700;
  line-height: 1.25;
}

h1 { font-size: 2rem; letter-spacing: -0.025em; }
h2 { font-size: 1.5rem; letter-spacing: -0.02em; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }

.text-muted   { color: var(--color-text-muted); }
.text-dim     { color: var(--color-text-dim); }
.text-success { color: var(--color-success); }
.text-danger  { color: var(--color-danger); }
.text-warning { color: var(--color-warning); }
.text-mono    { font-family: var(--font-mono); font-size: 0.875rem; }
.text-sm      { font-size: 0.875rem; }
.text-xs      { font-size: 0.75rem; }
.text-center  { text-align: center; }
.font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; }

/* ---------- Layout ---------- */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  background: rgba(15, 15, 35, 0.85);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  z-index: 100;
}

.sidebar-brand {
  padding: var(--space-lg) var(--space-lg) var(--space-md);
  border-bottom: 1px solid var(--color-border);
}

.sidebar-brand .brand-logo {
  font-size: 1.75rem;
  font-weight: 800;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.05em;
}

.sidebar-brand .brand-subtitle {
  font-size: 0.7rem;
  color: var(--color-text-dim);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-md) var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition-base);
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  user-select: none;
}

.nav-item:hover {
  background: rgba(124, 58, 237, 0.08);
  color: var(--color-text);
  text-decoration: none;
  border-color: rgba(124, 58, 237, 0.12);
}

.nav-item.active {
  background: rgba(124, 58, 237, 0.15);
  color: #fff;
  border-color: rgba(124, 58, 237, 0.25);
  box-shadow: var(--shadow-glow);
}

.nav-item.active .nav-icon {
  filter: drop-shadow(0 0 6px rgba(124,58,237,0.5));
}

.nav-icon {
  font-size: 1.2rem;
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.8rem;
  color: var(--color-text-dim);
}

/* ---------- Main Content ---------- */
.main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--color-bg-base);
  position: relative;
}

.page-wrapper {
  padding: var(--space-xl) var(--space-xl) var(--space-2xl);
  max-width: 1400px;
  margin: 0 auto;
  animation: fadeIn 0.35s ease;
}

.page-header {
  margin-bottom: var(--space-xl);
}

.page-header h1 {
  margin-bottom: var(--space-xs);
}

.page-header p {
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

.demo-access-card {
  display: grid;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  padding: var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: rgba(22, 33, 62, 0.56);
}

.demo-access-card strong {
  display: block;
  color: var(--color-text-heading);
  font-size: 0.95rem;
  margin-bottom: 2px;
}

.demo-access-card span {
  color: var(--color-text-muted);
  font-size: 0.82rem;
}

.demo-access-card code {
  display: block;
  color: var(--color-primary-light);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

/* ---------- Cards ---------- */
.card {
  background: var(--color-bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.06), transparent);
}

.card:hover {
  background: var(--color-bg-card-hover);
  border-color: rgba(124, 58, 237, 0.15);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-heading);
  margin-bottom: var(--space-md);
}

.card-flat {
  border-radius: var(--radius-lg);
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  padding: var(--space-lg);
}

.card-flat:hover {
  transform: none;
  box-shadow: none;
}

/* ---------- Stats / KPI Grid ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.stat-card {
  background: var(--color-bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  position: relative;
  overflow: hidden;
  transition: all var(--transition-base);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--gradient-primary);
  opacity: 0;
  transition: opacity var(--transition-base);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
  border-color: rgba(124,58,237,0.2);
}

.stat-card:hover::before { opacity: 1; }

.stat-icon {
  font-size: 1.5rem;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: rgba(124, 58, 237, 0.12);
}

.stat-value {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--color-text-heading);
  letter-spacing: -0.02em;
  line-height: 1;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-trend {
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.stat-trend.up   { color: var(--color-success); }
.stat-trend.down { color: var(--color-danger); }

/* ---------- Data Tables ---------- */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  background: var(--color-bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.data-table th {
  background: rgba(15, 15, 35, 0.9);
  backdrop-filter: blur(8px);
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
  user-select: none;
}

.data-table td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid rgba(255,255,255,0.03);
  color: var(--color-text);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background var(--transition-fast);
}

.data-table tbody tr:nth-child(even) {
  background: rgba(255,255,255,0.015);
}

.data-table tbody tr:hover {
  background: rgba(124, 58, 237, 0.06);
}

.data-table tbody tr.selected {
  background: rgba(124, 58, 237, 0.12);
}

.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  border-top: 1px solid var(--color-border);
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 10px 20px;
  font-size: 0.875rem;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
  line-height: 1.2;
  outline: none;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--gradient-primary);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.3);
}

.btn-primary:hover {
  background: var(--gradient-primary-h);
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.45);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255,255,255,0.05);
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn-secondary:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.15);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.12);
  color: var(--color-danger);
  border-color: rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.22);
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.2);
}

.btn-success {
  background: rgba(34, 197, 94, 0.12);
  color: var(--color-success);
  border-color: rgba(34, 197, 94, 0.2);
}

.btn-success:hover {
  background: rgba(34, 197, 94, 0.22);
  box-shadow: 0 0 16px rgba(34, 197, 94, 0.2);
}

.btn-warning {
  background: rgba(245, 158, 11, 0.12);
  color: var(--color-warning);
  border-color: rgba(245, 158, 11, 0.2);
}

.btn-warning:hover {
  background: rgba(245, 158, 11, 0.22);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
  font-size: 1rem;
}

.btn-icon.btn-sm {
  width: 30px;
  height: 30px;
  font-size: 0.85rem;
}

.btn:disabled, .btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-group {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

/* ---------- Forms ---------- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--space-md);
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.input, .select, .textarea {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 0.9rem;
  color: var(--color-text);
  transition: all var(--transition-base);
  outline: none;
  width: 100%;
}

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15), var(--shadow-glow);
  background: rgba(255,255,255,0.06);
}

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

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

.select option {
  background: var(--color-bg-surface);
  color: var(--color-text);
}

.textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.5;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.form-inline {
  display: flex;
  gap: var(--space-sm);
  align-items: flex-end;
}

.input-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: var(--radius-full);
  background: rgba(255,255,255,0.08);
  outline: none;
  transition: background var(--transition-base);
}

.input-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--gradient-primary);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(124,58,237,0.4);
  transition: transform var(--transition-fast);
}

.input-range::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* ---------- Badges / Tags ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.badge-success {
  background: rgba(34, 197, 94, 0.12);
  color: var(--color-success);
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.12);
  color: var(--color-warning);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.12);
  color: var(--color-danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-info {
  background: rgba(59, 130, 246, 0.12);
  color: var(--color-info);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.badge-neutral {
  background: rgba(255,255,255,0.06);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

/* ---------- Progress Bar ---------- */
.progress-bar {
  width: 100%;
  height: 8px;
  background: rgba(255,255,255,0.06);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--gradient-primary);
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
}

.progress-bar-fill::after {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0; right: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  animation: shimmer 2s infinite;
}

.progress-bar-lg { height: 12px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg), 0 0 60px rgba(124,58,237,0.1);
  animation: slideUp 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

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

.modal-header h3 {
  font-size: 1.15rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.modal-close:hover {
  color: var(--color-text);
  background: rgba(255,255,255,0.06);
}

.modal-body {
  padding: var(--space-lg);
}

.modal-footer {
  padding: var(--space-md) var(--space-lg) var(--space-lg);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  border-top: 1px solid var(--color-border);
}

/* ---------- Toast Notifications ---------- */
.toast-container {
  position: fixed;
  top: var(--space-lg);
  right: var(--space-lg);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
}

.toast {
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  min-width: 300px;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  pointer-events: auto;
  animation: slideRight 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  font-size: 0.875rem;
  font-weight: 500;
}

.toast-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.toast-message {
  flex: 1;
  color: var(--color-text);
}

.toast.toast-success { border-left: 3px solid var(--color-success); }
.toast.toast-error   { border-left: 3px solid var(--color-danger); }
.toast.toast-info    { border-left: 3px solid var(--color-info); }
.toast.toast-warning { border-left: 3px solid var(--color-warning); }

.toast.toast-exit {
  animation: slideOutRight 0.3s ease forwards;
}

/* ---------- Spinner ---------- */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255,255,255,0.08);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-sm { width: 18px; height: 18px; border-width: 2px; }
.spinner-lg { width: 48px; height: 48px; border-width: 4px; }

.loading-center {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: var(--space-2xl);
}

/* ---------- Skeleton ---------- */
.skeleton {
  background: linear-gradient(90deg,
    rgba(255,255,255,0.04) 25%,
    rgba(255,255,255,0.08) 50%,
    rgba(255,255,255,0.04) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.8s infinite;
  border-radius: var(--radius-sm);
}

.skeleton-text { height: 14px; margin-bottom: 8px; }
.skeleton-text:last-child { width: 60%; }
.skeleton-title { height: 24px; width: 40%; margin-bottom: 16px; }
.skeleton-avatar { width: 44px; height: 44px; border-radius: 50%; }
.skeleton-card { height: 120px; border-radius: var(--radius-lg); }

/* ---------- Custom Checkbox ---------- */
.checkbox-wrapper {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  gap: var(--space-sm);
  user-select: none;
}

.checkbox-wrapper input[type="checkbox"] {
  display: none;
}

.checkmark {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.checkbox-wrapper input:checked + .checkmark {
  background: var(--gradient-primary);
  border-color: var(--color-primary);
}

.checkbox-wrapper input:checked + .checkmark::after {
  content: '✓';
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.checkbox-wrapper:hover .checkmark {
  border-color: var(--color-primary-light);
}

/* ---------- Search Bar ---------- */
.search-bar {
  position: relative;
  width: 100%;
  max-width: 400px;
}

.search-bar .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9rem;
  color: var(--color-text-dim);
  pointer-events: none;
}

.search-bar .input {
  padding-left: 40px;
  border-radius: var(--radius-full);
  background: rgba(255,255,255,0.04);
}

.search-bar .input:focus {
  box-shadow: 0 0 0 3px rgba(124,58,237,0.12), var(--shadow-glow);
}

/* ---------- Filter Pills ---------- */
.filter-pills {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.filter-pill {
  padding: 6px 16px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-muted);
  transition: all var(--transition-base);
  user-select: none;
}

.filter-pill:hover {
  border-color: rgba(124,58,237,0.3);
  color: var(--color-text);
}

.filter-pill.active {
  background: var(--gradient-primary);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(124,58,237,0.3);
}

/* ---------- Empty State ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl) var(--space-lg);
  text-align: center;
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
  opacity: 0.4;
}

.empty-state .empty-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: var(--space-xs);
}

.empty-state .empty-message {
  font-size: 0.875rem;
  color: var(--color-text-dim);
  max-width: 320px;
}

/* ---------- Status Dots ---------- */
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.status-dot.green {
  background: var(--color-success);
  box-shadow: 0 0 8px rgba(34,197,94,0.5);
  animation: pulse 2s infinite;
}

.status-dot.yellow {
  background: var(--color-warning);
  box-shadow: 0 0 8px rgba(245,158,11,0.5);
  animation: pulse 1.5s infinite;
}

.status-dot.red {
  background: var(--color-danger);
  box-shadow: 0 0 8px rgba(239,68,68,0.5);
  animation: pulse 2s infinite;
}

.status-dot.gray {
  background: var(--color-text-dim);
}

/* ---------- QR Code Area ---------- */
.qr-container {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  border: 2px dashed rgba(124, 58, 237, 0.3);
  border-radius: var(--radius-xl);
  background: rgba(124, 58, 237, 0.04);
  min-height: 280px;
  transition: all var(--transition-base);
  position: relative;
}

.qr-container:hover {
  border-color: rgba(124, 58, 237, 0.5);
  box-shadow: 0 0 30px rgba(124, 58, 237, 0.08);
}

.qr-container img, .qr-container canvas {
  border-radius: var(--radius-md);
  max-width: 256px;
}

.qr-placeholder {
  text-align: center;
  color: var(--color-text-dim);
}

.qr-placeholder .empty-icon { font-size: 2.5rem; margin-bottom: var(--space-sm); }

/* ---------- Dispatch Controls ---------- */
.dispatch-controls {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

.dispatch-controls .btn { min-width: 100px; }

/* ---------- Activity Feed ---------- */
.activity-feed {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}

.activity-item:hover {
  background: rgba(255,255,255,0.02);
}

.activity-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
  background: rgba(124,58,237,0.1);
}

.activity-text {
  flex: 1;
  font-size: 0.875rem;
}

.activity-time {
  font-size: 0.75rem;
  color: var(--color-text-dim);
  white-space: nowrap;
}

/* ---------- Bulk Actions Toolbar ---------- */
.bulk-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: rgba(124, 58, 237, 0.08);
  border: 1px solid rgba(124, 58, 237, 0.2);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-md);
  animation: slideUp 0.3s ease;
}

.bulk-toolbar .bulk-count {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-primary-light);
  white-space: nowrap;
}

/* ---------- Message Card ---------- */
.message-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: all var(--transition-base);
}

.message-card:hover {
  border-color: rgba(124,58,237,0.2);
  box-shadow: var(--shadow-md);
}

.message-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.message-card-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-text-heading);
}

.message-card-body {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  line-height: 1.6;
  white-space: pre-wrap;
  background: rgba(0,0,0,0.2);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255,255,255,0.03);
}

.message-preview {
  background: rgba(34, 197, 94, 0.06);
  border: 1px solid rgba(34, 197, 94, 0.15);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}

.message-preview-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-success);
  margin-bottom: var(--space-sm);
}

/* ---------- Variable Helper Buttons ---------- */
.var-buttons {
  display: flex;
  gap: var(--space-xs);
  margin-top: var(--space-sm);
  flex-wrap: wrap;
}

.var-btn {
  padding: 4px 10px;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  background: rgba(124,58,237,0.1);
  border: 1px solid rgba(124,58,237,0.2);
  border-radius: var(--radius-sm);
  color: var(--color-primary-light);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.var-btn:hover {
  background: rgba(124,58,237,0.2);
}

/* ---------- Campaign Card ---------- */
.campaign-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: all var(--transition-base);
}

.campaign-card:hover {
  border-color: rgba(124,58,237,0.15);
}

.campaign-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.campaign-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: var(--space-md);
  margin: var(--space-md) 0;
}

.campaign-stat-item {
  text-align: center;
}

.campaign-stat-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-text-heading);
}

.campaign-stat-label {
  font-size: 0.7rem;
  color: var(--color-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---------- Section Divider ---------- */
.section {
  margin-bottom: var(--space-xl);
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-heading);
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.section-divider {
  height: 1px;
  background: var(--color-border);
  margin: var(--space-xl) 0;
}

/* ---------- Collapsible / Expandable ---------- */
.collapsible-trigger {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  padding: var(--space-sm) 0;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-muted);
  transition: color var(--transition-fast);
  user-select: none;
}

.collapsible-trigger:hover { color: var(--color-text); }

.collapsible-trigger .arrow {
  transition: transform var(--transition-base);
  font-size: 0.7rem;
}

.collapsible-trigger.open .arrow {
  transform: rotate(90deg);
}

.collapsible-body {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.4s ease;
}

.collapsible-body.open {
  max-height: 2000px;
}

/* ---------- Settings Sections ---------- */
.settings-section {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.settings-section-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* ---------- Grid helpers ---------- */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-lg);
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }

/* ---------- Messages grid ---------- */
.messages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: var(--space-lg);
}

/* ---------- Campaigns grid ---------- */
.campaigns-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-lg);
}

/* ---------- Quick Actions ---------- */
.quick-actions {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.quick-action-btn {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  color: var(--color-text);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition-base);
}

.quick-action-btn:hover {
  border-color: rgba(124,58,237,0.3);
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}

.quick-action-btn .qa-icon {
  font-size: 1.3rem;
}

/* ---------- Animations ---------- */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

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

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

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

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

@keyframes glow {
  0%, 100% { box-shadow: 0 0 8px rgba(124,58,237,0.3); }
  50%      { box-shadow: 0 0 20px rgba(124,58,237,0.6); }
}

/* ---------- Responsive — Tablet ---------- */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 220px;
  }

  .page-wrapper {
    padding: var(--space-lg);
  }

  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .grid-3 {
    grid-template-columns: 1fr 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .messages-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -100%;
    z-index: 200;
    transition: left var(--transition-base);
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    left: 0;
  }

  .main-content {
    width: 100%;
  }

  .page-wrapper {
    padding: var(--space-md);
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
  }

  .grid-3 {
    grid-template-columns: 1fr;
  }

  .modal {
    max-width: 95vw;
    margin: var(--space-md);
  }

  .toast {
    min-width: unset;
    max-width: calc(100vw - 32px);
  }
}

/* ---------- Utility: visually-hidden ---------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

/* ---------- Log / Dispatch Log ---------- */
.dispatch-log {
  max-height: 200px;
  overflow-y: auto;
  background: rgba(0,0,0,0.25);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-text-muted);
  line-height: 1.8;
}

.dispatch-log .log-entry {
  display: flex;
  gap: var(--space-sm);
}

.dispatch-log .log-time {
  color: var(--color-text-dim);
  flex-shrink: 0;
}

.dispatch-log .log-success { color: var(--color-success); }
.dispatch-log .log-error   { color: var(--color-danger); }

/* ---------- CRM Kanban ---------- */
.kanban-board {
  display: flex;
  gap: var(--space-md);
  overflow-x: auto;
  padding-bottom: var(--space-md);
  min-height: calc(100vh - 200px);
}

.kanban-column {
  flex: 0 0 300px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
}

.kanban-column-header {
  padding: var(--space-md);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.kanban-column-header h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
  flex: 1;
}

.kanban-column-body {
  padding: var(--space-md);
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  min-height: 100px;
}

.kanban-card {
  background: var(--color-surface-hover);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  cursor: grab;
  position: relative;
  transition: transform 0.2s, box-shadow 0.2s;
}

.kanban-card:active {
  cursor: grabbing;
}

.kanban-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  border-color: rgba(255,255,255,0.15);
}

.kanban-card h4 {
  margin: 0 0 4px 0;
  font-size: 0.85rem;
  color: var(--color-text);
}
