/* ============================================================
   CRM & Email Marketing SaaS — app.css
   Dark theme | Purple/Violet accent | Inter font
   ============================================================ */

/* ── Google Fonts ─────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Variables ────────────────────────────────────────── */
:root {
  /* Brand */
  --primary:          #7c3aed;
  --primary-light:    #8b5cf6;
  --primary-dark:     #6d28d9;
  --primary-glow:     rgba(124, 58, 237, 0.35);
  --primary-subtle:   rgba(124, 58, 237, 0.12);

  /* Sidebar */
  --sidebar-bg:       #1e1b2e;
  --sidebar-border:   #2d2845;
  --sidebar-item-hover: rgba(124, 58, 237, 0.18);
  --sidebar-item-active: rgba(124, 58, 237, 0.30);
  --sidebar-width:    240px;
  --sidebar-collapsed: 0px;

  /* Surface / Background */
  --bg-base:          #0f0d1a;
  --bg-surface:       #16132a;
  --bg-card:          #1c1933;
  --bg-card-hover:    #211e3a;
  --bg-input:         #151227;
  --bg-modal:         #1c1933;
  --bg-overlay:       rgba(10, 8, 20, 0.75);

  /* Text */
  --text-primary:     #f0eeff;
  --text-secondary:   #a09cc0;
  --text-muted:       #6b6688;
  --text-inverse:     #0f0d1a;
  --text-link:        #a78bfa;

  /* Border */
  --border:           #2a2545;
  --border-focus:     #7c3aed;
  --border-hover:     #3d3660;

  /* Status colors */
  --success:          #10b981;
  --success-light:    rgba(16, 185, 129, 0.15);
  --warning:          #f59e0b;
  --warning-light:    rgba(245, 158, 11, 0.15);
  --danger:           #ef4444;
  --danger-light:     rgba(239, 68, 68, 0.15);
  --info:             #3b82f6;
  --info-light:       rgba(59, 130, 246, 0.15);

  /* Gradients */
  --grad-primary:     linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
  --grad-success:     linear-gradient(135deg, #059669 0%, #10b981 100%);
  --grad-danger:      linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
  --grad-warning:     linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
  --grad-info:        linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
  --grad-bg:          linear-gradient(135deg, #0f0d1a 0%, #1a1530 50%, #0f0d1a 100%);

  /* Topbar */
  --topbar-height:    64px;
  --topbar-bg:        rgba(22, 19, 42, 0.90);

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

  /* Shadow */
  --shadow-sm:        0 1px 3px rgba(0,0,0,0.4);
  --shadow:           0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:        0 8px 32px rgba(0,0,0,0.6);
  --shadow-glow:      0 0 24px rgba(124,58,237,0.4);

  /* Transition */
  --transition:       0.2s ease;
  --transition-slow:  0.35s ease;

  /* Z-index layers */
  --z-sidebar:        100;
  --z-topbar:         200;
  --z-dropdown:       300;
  --z-modal:          400;
  --z-toast:          500;
  --z-overlay:        350;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 0.9375rem;
  font-weight: 400;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-base);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--text-link);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--primary-light); }

img, video, svg { max-width: 100%; display: block; }

ul, ol { list-style: none; }

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

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

h1 { font-size: 2rem; }
h2 { font-size: 1.625rem; }
h3 { font-size: 1.375rem; }
h4 { font-size: 1.125rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; }

p { color: var(--text-secondary); margin-bottom: 0.5rem; }

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb {
  background: var(--border-hover);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ── Selection ────────────────────────────────────────────── */
::selection {
  background: var(--primary-glow);
  color: var(--text-primary);
}

/* ── Layout ───────────────────────────────────────────────── */
.app-wrapper {
  display: flex;
  min-height: 100vh;
  position: relative;
}

.main-content {
  flex: 1;
  min-width: 0;
  overflow-x: hidden; /* prevent any child from causing horizontal scroll */
  display: flex;
  flex-direction: column;
  margin-left: var(--sidebar-width);
  transition: margin-left var(--transition-slow);
}

.page-body {
  flex: 1;
  padding: 1.75rem 2rem;
  padding-top: calc(var(--topbar-height) + 1.75rem);
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

.sidebar-collapsed .main-content {
  margin-left: 0;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.col { flex: 1 1 0; min-width: 0; }
.col-auto { flex: 0 0 auto; }
.col-2 { flex: 0 0 calc(16.666% - 1rem); }
.col-3 { flex: 0 0 calc(25% - 1rem); }
.col-4 { flex: 0 0 calc(33.333% - 1rem); }
.col-6 { flex: 0 0 calc(50% - 1rem); }
.col-8 { flex: 0 0 calc(66.666% - 1rem); }
.col-12 { flex: 0 0 100%; }

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sidebar);
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--transition-slow), width var(--transition-slow);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--sidebar-border);
  text-decoration: none;
}

.sidebar-logo-icon {
  width: 38px;
  height: 38px;
  background: var(--grad-primary);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-glow);
}

.sidebar-logo-icon svg {
  width: 22px;
  height: 22px;
  fill: #fff;
}

.sidebar-logo-text {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.sidebar-logo-text span {
  color: var(--primary-light);
}

.sidebar-section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 1.25rem 1.25rem 0.375rem;
}

.sidebar-nav {
  padding: 0.5rem 0.75rem;
  flex: 1;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
  margin-bottom: 2px;
  position: relative;
}

.sidebar-nav-item:hover {
  color: var(--text-primary);
  background: var(--sidebar-item-hover);
}

.sidebar-nav-item.active {
  color: var(--primary-light);
  background: var(--sidebar-item-active);
  font-weight: 600;
}

.sidebar-nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--primary-light);
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
}

.sidebar-nav-item svg,
.sidebar-nav-item .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.75;
}

.sidebar-nav-item.active svg,
.sidebar-nav-item.active .nav-icon {
  opacity: 1;
}

.sidebar-nav-badge {
  margin-left: auto;
  font-size: 0.6875rem;
  font-weight: 600;
  background: var(--primary);
  color: #fff;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 1rem 0.75rem;
  border-top: 1px solid var(--sidebar-border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
}

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

.sidebar-user-info { flex: 1; min-width: 0; }

.sidebar-user-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role, .sidebar-user-email {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: calc(var(--z-sidebar) - 1);
  backdrop-filter: blur(2px);
}

/* ── Topbar / Navbar ──────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--topbar-height);
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 2rem;
  gap: 1rem;
  z-index: var(--z-topbar);
  transition: left var(--transition-slow);
}

.sidebar-collapsed .topbar {
  left: 0;
}

.topbar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.375rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  line-height: 1;
}

.topbar-toggle:hover {
  color: var(--text-primary);
  background: var(--primary-subtle);
}

.topbar-title {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.topbar-search {
  position: relative;
  width: 280px;
}

.topbar-search input {
  width: 100%;
  height: 38px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 0 1rem 0 2.5rem;
  font-size: 0.875rem;
  color: var(--text-primary);
  transition: all var(--transition);
}

.topbar-search input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-subtle);
}

.topbar-search-icon {
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  width: 16px;
  height: 16px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

.topbar-icon-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-hover);
  background: var(--primary-subtle);
}

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

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition);
}

.card:hover {
  border-color: var(--border-hover);
}

.card-glass {
  background: rgba(28, 25, 51, 0.55);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.07);
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
}

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

.card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.card-body {
  padding: 1.5rem;
}

.card-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,0.15);
}

/* ── Stat Cards ───────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
  transition: all var(--transition);
}

.stat-card::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.06;
  background: var(--grad-primary);
  transition: opacity var(--transition);
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-card:hover::before { opacity: 0.12; }

.stat-card-purple  { --card-accent: var(--grad-primary); }
.stat-card-green   { --card-accent: var(--grad-success); }
.stat-card-red     { --card-accent: var(--grad-danger); }
.stat-card-amber   { --card-accent: var(--grad-warning); }
.stat-card-blue    { --card-accent: var(--grad-info); }

.stat-card-purple::before  { background: var(--grad-primary); }
.stat-card-green::before   { background: var(--grad-success); }
.stat-card-red::before     { background: var(--grad-danger); }
.stat-card-amber::before   { background: var(--grad-warning); }
.stat-card-blue::before    { background: var(--grad-info); }

.stat-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  background: var(--card-accent, var(--grad-primary));
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.stat-card-icon svg { width: 24px; height: 24px; color: #fff; }

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

.stat-card-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 0.625rem;
}

.stat-card-change {
  font-size: 0.8125rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

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

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
  position: relative;
  overflow: hidden;
  user-select: none;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.08);
  opacity: 0;
  transition: opacity var(--transition);
}

.btn:hover::after { opacity: 1; }
.btn:active { transform: translateY(1px); }

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

.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

/* Primary */
.btn-primary {
  background: var(--grad-primary);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 12px var(--primary-glow);
}
.btn-primary:hover {
  box-shadow: 0 4px 20px var(--primary-glow);
  transform: translateY(-1px);
  color: #fff;
}

/* Secondary */
.btn-secondary {
  background: rgba(255,255,255,0.07);
  border-color: var(--border);
  color: var(--text-primary);
}
.btn-secondary:hover {
  background: rgba(255,255,255,0.12);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

/* Danger */
.btn-danger {
  background: var(--grad-danger);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 12px rgba(239,68,68,0.3);
}
.btn-danger:hover {
  box-shadow: 0 4px 20px rgba(239,68,68,0.4);
  transform: translateY(-1px);
  color: #fff;
}

/* Success */
.btn-success {
  background: var(--grad-success);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 12px rgba(16,185,129,0.3);
}
.btn-success:hover {
  box-shadow: 0 4px 20px rgba(16,185,129,0.4);
  transform: translateY(-1px);
  color: #fff;
}

/* Warning */
.btn-warning {
  background: var(--grad-warning);
  color: #fff;
  border-color: transparent;
}
.btn-warning:hover { transform: translateY(-1px); color: #fff; }

/* Info */
.btn-info {
  background: var(--grad-info);
  color: #fff;
  border-color: transparent;
}
.btn-info:hover { transform: translateY(-1px); color: #fff; }

/* Outline variants */
.btn-outline-primary {
  background: transparent;
  border-color: var(--primary);
  color: var(--primary-light);
}
.btn-outline-primary:hover {
  background: var(--primary-subtle);
  color: var(--primary-light);
}

.btn-outline-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}
.btn-outline-danger:hover {
  background: var(--danger-light);
}

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

/* Ghost */
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
}
.btn-ghost::after { display: none; }

/* Sizes */
.btn-xs {
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
}

.btn-sm {
  padding: 0.4375rem 0.875rem;
  font-size: 0.8125rem;
}

.btn-lg {
  padding: 0.75rem 1.75rem;
  font-size: 1rem;
  border-radius: var(--radius-lg);
}

.btn-xl {
  padding: 1rem 2.25rem;
  font-size: 1.0625rem;
  border-radius: var(--radius-lg);
}

.btn-block { width: 100%; }

/* Icon-only */
.btn-icon {
  padding: 0.5rem;
  width: 36px;
  height: 36px;
}
.btn-icon.btn-sm { width: 30px; height: 30px; padding: 0.3125rem; }
.btn-icon.btn-lg { width: 44px; height: 44px; padding: 0.6875rem; }

/* Loading state */
.btn.loading { pointer-events: none; }
.btn.loading::before {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* Button group */
.btn-group {
  display: inline-flex;
}
.btn-group .btn {
  border-radius: 0;
}
.btn-group .btn:first-child {
  border-radius: var(--radius) 0 0 var(--radius);
}
.btn-group .btn:last-child {
  border-radius: 0 var(--radius) var(--radius) 0;
}
.btn-group .btn + .btn {
  border-left-width: 0;
}

/* ── Forms ────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4375rem;
  letter-spacing: 0.015em;
}

.form-label .required {
  color: var(--danger);
  margin-left: 3px;
}

.form-control, .form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5625rem 0.875rem;
  font-size: 0.875rem;
  color: var(--text-primary);
  transition: all var(--transition);
  appearance: none;
  line-height: 1.5;
}

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

.form-control:focus, .form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  background: var(--bg-input);
  box-shadow: 0 0 0 3px var(--primary-subtle);
}

.form-control:disabled, .form-input:disabled, .form-select:disabled, .form-textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: rgba(255,255,255,0.02);
}

.form-control.is-valid, .form-input.is-valid, .form-select.is-valid, .form-textarea.is-valid {
  border-color: var(--success);
  box-shadow: 0 0 0 3px var(--success-light);
}

.form-control.is-invalid, .form-input.is-invalid, .form-select.is-invalid, .form-textarea.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-light);
}

textarea.form-control, textarea.form-input, textarea.form-textarea, .form-textarea {
  resize: vertical;
  min-height: 100px;
}

select.form-control, select.form-select, .form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b6688' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.875rem center;
  padding-right: 2.25rem;
  cursor: pointer;
}

select.form-control option, select.form-select option, .form-select option {
  background: var(--bg-card);
  color: var(--text-primary);
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.375rem;
}

.form-error {
  font-size: 0.75rem;
  color: var(--danger);
  margin-top: 0.375rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

/* Input group */
.input-group {
  display: flex;
  position: relative;
}

.input-group .form-control {
  flex: 1;
}

.input-group-prepend,
.input-group-append {
  display: flex;
  align-items: center;
  padding: 0 0.875rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.875rem;
  white-space: nowrap;
}

.input-group-prepend {
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
}

.input-group-append {
  border-left: none;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.input-group .form-control:not(:first-child) {
  border-radius: 0 var(--radius) var(--radius) 0;
}

.input-group .form-control:not(:last-child) {
  border-radius: var(--radius) 0 0 var(--radius);
}

/* Input with icon */
.input-icon-wrapper {
  position: relative;
}

.input-icon-wrapper .form-control {
  padding-left: 2.5rem;
}

.input-icon-wrapper .input-icon {
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  width: 16px;
  height: 16px;
}

/* Character counter */
.char-counter {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: right;
  margin-top: 0.25rem;
}
.char-counter.warning { color: var(--warning); }
.char-counter.danger  { color: var(--danger); }

/* ── Checkbox & Radio ─────────────────────────────────────── */
.form-check {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  cursor: pointer;
}

.form-check-input {
  width: 17px;
  height: 17px;
  margin-top: 2px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.form-check-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 1.5;
}

/* ── Toggle Switch ────────────────────────────────────────── */
.toggle-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  cursor: pointer;
  user-select: none;
}

.toggle-switch input {
  display: none;
}

.toggle-track {
  width: 44px;
  height: 24px;
  background: var(--border);
  border-radius: var(--radius-full);
  position: relative;
  transition: background var(--transition);
  flex-shrink: 0;
}

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

.toggle-switch input:checked + .toggle-track {
  background: var(--primary);
}

.toggle-switch input:checked + .toggle-track::after {
  transform: translateX(20px);
}

.toggle-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* ── Tables ───────────────────────────────────────────────── */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

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

.table th {
  background: rgba(0,0,0,0.25);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
  user-select: none;
}

.table th.sortable {
  cursor: pointer;
  transition: color var(--transition);
}

.table th.sortable:hover { color: var(--text-primary); }

.table th .sort-icon {
  display: inline-block;
  margin-left: 4px;
  vertical-align: middle;
  opacity: 0.4;
}

.table th.sort-asc .sort-icon,
.table th.sort-desc .sort-icon { opacity: 1; color: var(--primary-light); }

.table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid rgba(42,37,69,0.6);
  color: var(--text-secondary);
  vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }

.table-striped tbody tr:nth-child(even) td {
  background: rgba(0,0,0,0.12);
}

.table-hover tbody tr:hover td {
  background: var(--sidebar-item-hover);
  color: var(--text-primary);
}

.table-checkbox-col {
  width: 40px;
  text-align: center;
}

.table-actions { white-space: nowrap; }

.table-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.table-empty-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.4;
}

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.5;
  white-space: nowrap;
}

.badge-primary  { background: var(--primary-subtle);  color: var(--primary-light); }
.badge-success  { background: var(--success-light);   color: var(--success); }
.badge-danger   { background: var(--danger-light);    color: var(--danger); }
.badge-warning  { background: var(--warning-light);   color: var(--warning); }
.badge-info     { background: var(--info-light);      color: var(--info); }
.badge-muted    { background: rgba(255,255,255,0.07); color: var(--text-muted); }

.badge-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.badge-lg {
  padding: 0.3rem 0.875rem;
  font-size: 0.8125rem;
  border-radius: var(--radius);
}

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 0.875rem;
  animation: slideInDown 0.3s ease forwards;
}

.alert-icon { flex-shrink: 0; margin-top: 1px; width: 18px; height: 18px; }
.alert-content { flex: 1; }
.alert-title { font-weight: 600; margin-bottom: 2px; color: inherit; }
.alert-message { opacity: 0.85; }

.alert-close {
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.6;
  padding: 0;
  color: inherit;
  line-height: 1;
  transition: opacity var(--transition);
  margin-left: auto;
  flex-shrink: 0;
}
.alert-close:hover { opacity: 1; }

.alert-success {
  background: var(--success-light);
  border-color: rgba(16,185,129,0.3);
  color: var(--success);
}

.alert-danger {
  background: var(--danger-light);
  border-color: rgba(239,68,68,0.3);
  color: var(--danger);
}

.alert-warning {
  background: var(--warning-light);
  border-color: rgba(245,158,11,0.3);
  color: var(--warning);
}

.alert-info {
  background: var(--info-light);
  border-color: rgba(59,130,246,0.3);
  color: var(--info);
}

.alert-primary {
  background: var(--primary-subtle);
  border-color: rgba(124,58,237,0.3);
  color: var(--primary-light);
}

.flash-messages {
  position: fixed;
  top: calc(var(--topbar-height) + 1rem);
  right: 1.5rem;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 380px;
  width: 100%;
}

/* ── Modals ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: var(--z-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-slow);
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-modal);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(24px) scale(0.97);
  transition: transform var(--transition-slow);
}

.modal-overlay.open .modal {
  transform: translateY(0) scale(1);
}

.modal-sm  { max-width: 380px; }
.modal-lg  { max-width: 720px; }
.modal-xl  { max-width: 1000px; }

.modal-header {
  display: flex;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}

.modal-title {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
}

.modal-close {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}
.modal-close:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text-primary);
}

.modal-body { padding: 1.5rem; }

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border);
}

/* ── Dropdown ─────────────────────────────────────────────── */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all var(--transition);
}

.dropdown-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-menu-left { right: auto; left: 0; }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 1rem;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.dropdown-item:hover {
  background: var(--sidebar-item-hover);
  color: var(--text-primary);
}

.dropdown-item.danger:hover {
  background: var(--danger-light);
  color: var(--danger);
}

.dropdown-item svg { width: 15px; height: 15px; flex-shrink: 0; }

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 0.375rem 0;
}

.dropdown-header {
  padding: 0.5rem 1rem 0.25rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

/* ── Tabs ─────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
  overflow-x: auto;
}

.tab-item {
  padding: 0.75rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: all var(--transition);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tab-item:hover { color: var(--text-secondary); }

.tab-item.active {
  color: var(--primary-light);
  border-bottom-color: var(--primary-light);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Pagination ───────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-wrap: wrap;
}

.page-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 0.625rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition);
  cursor: pointer;
}

.page-link:hover {
  background: var(--primary-subtle);
  border-color: var(--primary);
  color: var(--primary-light);
}

.page-link.active {
  background: var(--grad-primary);
  border-color: transparent;
  color: #fff;
  font-weight: 700;
}

.page-link.disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Avatar / Initials ────────────────────────────────────── */
.avatar {
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
}

.avatar-xs { width: 24px; height: 24px; }
.avatar-sm { width: 32px; height: 32px; }
.avatar-md { width: 40px; height: 40px; }
.avatar-lg { width: 52px; height: 52px; }
.avatar-xl { width: 72px; height: 72px; }

.avatar-initials {
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
  text-transform: uppercase;
  background: var(--grad-primary);
  color: #fff;
  letter-spacing: 0.04em;
}

.avatar-initials.xs { width: 24px; height: 24px; font-size: 0.625rem; }
.avatar-initials.sm { width: 32px; height: 32px; font-size: 0.75rem;  }
.avatar-initials.md { width: 40px; height: 40px; font-size: 0.9375rem; }
.avatar-initials.lg { width: 52px; height: 52px; font-size: 1.125rem; }
.avatar-initials.xl { width: 72px; height: 72px; font-size: 1.5rem;   }

.avatar-group {
  display: flex;
}

.avatar-group .avatar-initials,
.avatar-group .avatar {
  border: 2px solid var(--bg-card);
}

.avatar-group .avatar-initials + .avatar-initials,
.avatar-group .avatar + .avatar {
  margin-left: -10px;
}

/* Color variants for avatars */
.avatar-initials.purple  { background: var(--grad-primary); }
.avatar-initials.green   { background: var(--grad-success); }
.avatar-initials.red     { background: var(--grad-danger);  }
.avatar-initials.amber   { background: var(--grad-warning); }
.avatar-initials.blue    { background: var(--grad-info);    }

/* ── Toast Notifications ──────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  max-width: 380px;
  pointer-events: all;
  animation: slideInRight 0.3s ease forwards;
  position: relative;
  overflow: hidden;
}

.toast::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  border-radius: var(--radius-full);
}

.toast-success::before { background: var(--success); }
.toast-danger::before  { background: var(--danger);  }
.toast-warning::before { background: var(--warning); }
.toast-info::before    { background: var(--info);    }
.toast-primary::before { background: var(--primary); }

.toast-icon { flex-shrink: 0; width: 20px; height: 20px; margin-top: 1px; }
.toast-success .toast-icon { color: var(--success); }
.toast-danger  .toast-icon { color: var(--danger);  }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info    .toast-icon { color: var(--info);    }
.toast-primary .toast-icon { color: var(--primary-light); }

.toast-content { flex: 1; }

.toast-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.toast-message {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  transition: color var(--transition);
  margin-left: auto;
  flex-shrink: 0;
}

.toast-close:hover { color: var(--text-primary); }

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: rgba(255,255,255,0.15);
  border-radius: var(--radius-full);
  transform-origin: left;
  animation: toastProgress var(--toast-duration, 4s) linear forwards;
}

.toast.dismissing { animation: slideOutRight 0.25s ease forwards; }

/* ── Page Header ──────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
}

.page-header-left { flex: 1; min-width: 0; }

.page-header-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

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

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

/* ── Breadcrumb ───────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

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

.breadcrumb-item a:hover { color: var(--primary-light); }

.breadcrumb-item.active { color: var(--text-secondary); }

.breadcrumb-separator {
  color: var(--text-muted);
  opacity: 0.5;
}

/* ── Charts Placeholder ───────────────────────────────────── */
.chart-container {
  position: relative;
  width: 100%;
}

.chart-area {
  width: 100%;
  display: block;
  border-radius: var(--radius);
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1rem;
  justify-content: center;
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.chart-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Loading Spinner ──────────────────────────────────────── */
.spinner {
  display: inline-block;
  border: 2px solid rgba(255,255,255,0.15);
  border-top-color: var(--primary-light);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.spinner-xs { width: 14px; height: 14px; }
.spinner-sm { width: 20px; height: 20px; }
.spinner-md { width: 28px; height: 28px; }
.spinner-lg { width: 40px; height: 40px; border-width: 3px; }
.spinner-xl { width: 56px; height: 56px; border-width: 3px; }

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15,13,26,0.65);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  border-radius: inherit;
  z-index: 10;
}

.loading-overlay-text {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ── Progress Bar ─────────────────────────────────────────── */
.progress {
  height: 8px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--grad-primary);
  border-radius: var(--radius-full);
  transition: width 0.6s ease;
}

.progress-bar-success { background: var(--grad-success); }
.progress-bar-danger  { background: var(--grad-danger);  }
.progress-bar-warning { background: var(--grad-warning); }
.progress-bar-info    { background: var(--grad-info);    }

.progress-sm { height: 4px; }
.progress-lg { height: 12px; }

.progress-striped .progress-bar {
  background-image: linear-gradient(
    45deg,
    rgba(255,255,255,0.12) 25%,
    transparent 25%,
    transparent 50%,
    rgba(255,255,255,0.12) 50%,
    rgba(255,255,255,0.12) 75%,
    transparent 75%,
    transparent
  );
  background-size: 16px 16px;
  animation: stripeMove 1s linear infinite;
}

/* ── Empty State ──────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
}

.empty-state-icon {
  width: 72px;
  height: 72px;
  background: var(--primary-subtle);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.empty-state-icon svg { width: 36px; height: 36px; color: var(--primary-light); }
.empty-state-title { font-size: 1.125rem; font-weight: 700; margin-bottom: 0.5rem; }
.empty-state-desc  { font-size: 0.875rem; color: var(--text-muted); max-width: 340px; margin-bottom: 1.5rem; }

/* ── Tooltip ──────────────────────────────────────────────── */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.85);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.3125rem 0.625rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition);
  z-index: var(--z-dropdown);
}

[data-tooltip]:hover::before { opacity: 1; }

/* ── Login Page ───────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: var(--grad-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}

.login-page::before,
.login-page::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
}

.login-page::before {
  width: 600px;
  height: 600px;
  background: rgba(124,58,237,0.2);
  top: -200px;
  right: -200px;
}

.login-page::after {
  width: 400px;
  height: 400px;
  background: rgba(168,85,247,0.12);
  bottom: -150px;
  left: -100px;
}

.login-card {
  background: rgba(28,25,51,0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
  position: relative;
  z-index: 1;
  animation: fadeInUp 0.5s ease forwards;
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
  text-decoration: none;
}

.login-logo-icon {
  width: 48px;
  height: 48px;
  background: var(--grad-primary);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow);
}

.login-logo-text {
  font-size: 1.375rem;
  font-weight: 800;
  color: var(--text-primary);
}

.login-logo-text span { color: var(--primary-light); }

.login-title {
  font-size: 1.5rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 0.375rem;
}

.login-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 2rem;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  margin: 1.25rem 0;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.login-footer-text {
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 1.5rem;
}

/* ── Utility Classes ──────────────────────────────────────── */
.d-flex          { display: flex; }
.d-inline-flex   { display: inline-flex; }
.d-block         { display: block; }
.d-inline-block  { display: inline-block; }
.d-none          { display: none; }
.d-grid          { display: grid; }

.align-items-center  { align-items: center; }
.align-items-start   { align-items: flex-start; }
.align-items-end     { align-items: flex-end; }
.justify-content-center  { justify-content: center; }
.justify-content-between { justify-content: space-between; }
.justify-content-end     { justify-content: flex-end; }

.flex-column { flex-direction: column; }
.flex-wrap   { flex-wrap: wrap; }
.flex-1      { flex: 1; }
.gap-1  { gap: 0.25rem; }
.gap-2  { gap: 0.5rem; }
.gap-3  { gap: 0.75rem; }
.gap-4  { gap: 1rem; }
.gap-5  { gap: 1.25rem; }
.gap-6  { gap: 1.5rem; }

.text-left    { text-align: left; }
.text-center  { text-align: center; }
.text-right   { text-align: right; }

.text-color-primary   { color: var(--text-primary); }
.text-color-secondary { color: var(--text-secondary); }
.text-muted           { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-info    { color: var(--info); }
.text-purple  { color: var(--primary-light); }

.font-xs    { font-size: 0.75rem; }
.font-sm    { font-size: 0.875rem; }
.font-base  { font-size: 1rem; }
.font-lg    { font-size: 1.125rem; }
.font-xl    { font-size: 1.25rem; }
.fw-400 { font-weight: 400; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-5 { margin-top: 1.5rem; }
.mt-6 { margin-top: 2rem; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-5 { margin-bottom: 1.5rem; }
.mb-6 { margin-bottom: 2rem; }

.ms-auto { margin-left: auto; }
.me-auto  { margin-right: auto; }
.mx-auto  { margin-left: auto; margin-right: auto; }

.p-0 { padding: 0; }
.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-5 { padding: 1.5rem; }
.p-6 { padding: 2rem; }

.w-full  { width: 100%; }
.h-full  { height: 100%; }
.w-auto  { width: auto; }
.h-auto  { height: auto; }

.rounded        { border-radius: var(--radius); }
.rounded-sm     { border-radius: var(--radius-sm); }
.rounded-lg     { border-radius: var(--radius-lg); }
.rounded-full   { border-radius: var(--radius-full); }

.overflow-hidden { overflow: hidden; }
.overflow-auto   { overflow: auto; }
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pointer   { cursor: pointer; }
.no-select { user-select: none; }

.opacity-0   { opacity: 0; }
.opacity-50  { opacity: 0.5; }
.opacity-75  { opacity: 0.75; }
.opacity-100 { opacity: 1; }

.border        { border: 1px solid var(--border); }
.border-top    { border-top: 1px solid var(--border); }
.border-bottom { border-bottom: 1px solid var(--border); }
.no-border     { border: none !important; }

.bg-card    { background: var(--bg-card); }
.bg-surface { background: var(--bg-surface); }
.bg-primary-subtle { background: var(--primary-subtle); }

.shadow    { box-shadow: var(--shadow); }
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.shadow-glow { box-shadow: var(--shadow-glow); }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ── Animations ───────────────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideInDown {
  from { opacity: 0; transform: translateY(-16px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

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

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-32px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}

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

@keyframes pulseDot {
  0%   { transform: scale(1); box-shadow: 0 0 0 0 rgba(124,58,237,0.5); }
  70%  { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(124,58,237,0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(124,58,237,0); }
}

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

@keyframes stripeMove {
  from { background-position: 0 0; }
  to   { background-position: 32px 0; }
}

@keyframes toastProgress {
  from { width: 100%; }
  to   { width: 0%; }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}

/* Utility animation classes */
.animate-fade-in        { animation: fadeIn 0.3s ease forwards; }
.animate-fade-in-up     { animation: fadeInUp 0.4s ease forwards; }
.animate-fade-in-down   { animation: fadeInDown 0.3s ease forwards; }
.animate-slide-in-right { animation: slideInRight 0.3s ease forwards; }
.animate-slide-in-left  { animation: slideInLeft 0.3s ease forwards; }
.animate-scale-in       { animation: scaleIn 0.25s ease forwards; }
.animate-pulse          { animation: pulse 2s ease-in-out infinite; }
.animate-spin           { animation: spin 1s linear infinite; }
.animate-bounce         { animation: bounce 1s ease-in-out infinite; }

/* Stagger animation helpers */
.stagger-1 { animation-delay: 0.05s; }
.stagger-2 { animation-delay: 0.10s; }
.stagger-3 { animation-delay: 0.15s; }
.stagger-4 { animation-delay: 0.20s; }
.stagger-5 { animation-delay: 0.25s; }
.stagger-6 { animation-delay: 0.30s; }

/* Skeleton / shimmer */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-card) 0px,
    rgba(255,255,255,0.06) 200px,
    var(--bg-card) 400px
  );
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: var(--radius-sm);
}

.skeleton-text {
  height: 14px;
  border-radius: var(--radius-full);
  margin-bottom: 0.5rem;
}

.skeleton-text.short  { width: 40%; }
.skeleton-text.medium { width: 65%; }
.skeleton-text.long   { width: 90%; }

.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

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

/* ── Responsive ───────────────────────────────────────────── */

/* Medium desktop/tablet: <1024px */
@media (max-width: 1023px) {
  .page-body { padding: 1.25rem 1.5rem; padding-top: calc(var(--topbar-height) + 1.25rem); }
  .topbar-search { width: 220px; }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
}

/* Tablet: <768px */
@media (max-width: 767px) {
  :root { --topbar-height: 58px; }

  /* Sidebar becomes a drawer */
  .sidebar {
    transform: translateX(-100%);
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

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

  .main-content { margin-left: 0; }
  .topbar { left: 0; padding: 0 1rem; }
  .topbar-toggle { display: flex; }
  .topbar-search { display: none; }

  .page-body { padding: 1rem; padding-top: calc(var(--topbar-height) + 1rem); }

  .page-header { flex-direction: column; gap: 0.875rem; }
  .page-header-actions { width: 100%; }

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

  .col-3, .col-4 { flex: 0 0 100%; }
  .col-6  { flex: 0 0 100%; }

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

  .modal { border-radius: var(--radius-lg); }

  .table th, .table td { padding: 0.625rem 0.75rem; }

  .flash-messages { right: 1rem; left: 1rem; max-width: none; }

  .login-card { padding: 1.75rem 1.5rem; }
}

/* Mobile: <480px */
@media (max-width: 479px) {
  .stat-grid { grid-template-columns: 1fr; }

  .tabs { overflow-x: auto; }

  .btn-group { flex-wrap: wrap; }
  .btn-group .btn {
    border-radius: var(--radius) !important;
    border-left-width: 1px !important;
  }

  .pagination { justify-content: center; }

  .toast-container { bottom: 1rem; right: 1rem; left: 1rem; }
  .toast { min-width: auto; max-width: none; width: 100%; }

  .modal-footer { flex-direction: column-reverse; }
  .modal-footer .btn { width: 100%; }
}

/* ── Print styles ─────────────────────────────────────────── */
@media print {
  .sidebar,
  .topbar,
  .topbar-toggle,
  .toast-container,
  .flash-messages { display: none !important; }
  .main-content   { margin-left: 0 !important; }
  .page-body      { padding: 0 !important; }
  body            { background: #fff; color: #000; }
  .card           { border: 1px solid #ddd; }
}

/* ============================================================
   UI Revamp - Glassmorphism & Animations
   ============================================================ */

.glass-card {
  background: rgba(28, 25, 51, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-lg);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.glass-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px 0 rgba(124, 58, 237, 0.15);
  border-color: rgba(124, 58, 237, 0.2);
}

.stat-card {
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: -100%; width: 50%; height: 100%;
  background: linear-gradient(to right, transparent, rgba(255,255,255,0.03), transparent);
  transform: skewX(-20deg);
  animation: shine 6s infinite;
}
@keyframes shine {
  0% { left: -100%; }
  20% { left: 200%; }
  100% { left: 200%; }
}

.quick-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  text-decoration: none;
  transition: all var(--transition);
  gap: 0.75rem;
}
.quick-action-btn:hover {
  background: var(--sidebar-item-hover);
  border-color: var(--primary);
  color: var(--primary-light);
  transform: translateY(-2px);
}
.quick-action-btn svg {
  width: 28px; height: 28px;
  stroke: var(--primary);
}

.activity-item {
  display: flex;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.activity-icon.open { background: var(--info-light); color: var(--info); }
.activity-icon.click { background: var(--warning-light); color: var(--warning); }
.activity-icon.sent { background: var(--success-light); color: var(--success); }
.activity-details { flex-grow: 1; font-size: 0.875rem; }
.activity-time { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; }

.integration-card {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.5rem; background: var(--bg-card); border-radius: var(--radius);
  border: 1px solid var(--border); transition: var(--transition);
}
.integration-card:hover { border-color: var(--primary); }


/* ============================================================
   Dashboard — Scoped Styles
   ============================================================ */

/* ── Page header actions ──────────────────────────────────── */
.db-header-actions {
  display: flex;
  gap: 0.625rem;
  flex-wrap: wrap;
}

/* ── Stats grid ───────────────────────────────────────────── */
.db-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

/* ── Quick-action shortcuts row ───────────────────────────── */
.db-quick-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.db-quick-grid .quick-action-btn span {
  font-weight: 600;
  font-size: 0.875rem;
}

/* ── Charts row ───────────────────────────────────────────── */
.db-charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.db-chart-wrap {
  position: relative;
  height: 210px;
  width: 100%;
}

.db-doughnut-body {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  flex-wrap: wrap;
}

.db-doughnut-legend {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.db-legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.db-legend-dot {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  display: inline-block;
  flex-shrink: 0;
}

.db-label-muted {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Table cards ──────────────────────────────────────────── */
.db-table-card .table-responsive {
  border-radius: 0;
  border: none;
}

.db-contact-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.db-contact-info {
  min-width: 0;
}

.db-contact-name {
  font-weight: 500;
  color: var(--text-primary);
  font-size: 0.8125rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 110px;
}

.db-contact-email {
  color: var(--text-muted);
  font-size: 0.7rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 110px;
}

.db-campaign-name {
  font-weight: 500;
  color: var(--text-primary);
  font-size: 0.8125rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

.db-campaign-sub {
  color: var(--text-muted);
  font-size: 0.7rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

.db-text-sm { font-size: 0.8125rem; color: var(--text-secondary); }

/* ── Email Performance card ───────────────────────────────── */
.db-perf-body {
  padding-top: 0.75rem;
}

.db-perf-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.db-perf-divider {
  height: 1px;
  background: rgba(255,255,255,0.06);
  margin: 0.75rem 0;
}

.db-perf-item {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.db-perf-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.125rem;
}

.db-perf-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
  flex-shrink: 1;
}

.db-perf-count {
  font-size: 0.7rem;
  color: var(--text-muted);
  flex-shrink: 0;
  white-space: nowrap;
}

.db-bar-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.db-bar-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  width: 32px;
  flex-shrink: 0;
}

.db-bar-track {
  flex: 1;
  height: 5px;
  background: rgba(255,255,255,0.07);
  border-radius: 99px;
  overflow: hidden;
}

.db-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.7s ease;
}

.db-bar-purple { background: linear-gradient(90deg, #7c3aed, #a78bfa); }
.db-bar-blue   { background: linear-gradient(90deg, #0ea5e9, #38bdf8); }

.db-bar-pct {
  font-size: 0.75rem;
  font-weight: 700;
  width: 36px;
  text-align: right;
  flex-shrink: 0;
}

.db-pct-purple { color: #a78bfa; }
.db-pct-blue   { color: #38bdf8; }

.db-perf-summary {
  display: flex;
  gap: 0.625rem;
  margin-top: 0.875rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255,255,255,0.07);
}

.db-perf-stat {
  flex: 1;
  border-radius: 10px;
  padding: 0.5rem 0.625rem;
  text-align: center;
}

.db-perf-stat-purple {
  background: rgba(124,58,237,0.08);
  border: 1px solid rgba(124,58,237,0.18);
}

.db-perf-stat-blue {
  background: rgba(14,165,233,0.08);
  border: 1px solid rgba(14,165,233,0.18);
}

.db-perf-stat-val {
  font-size: 1.1rem;
  font-weight: 700;
  color: #a78bfa;
  line-height: 1.2;
}

.db-perf-stat-blue .db-perf-stat-val { color: #38bdf8; }

.db-perf-stat-lbl {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.db-perf-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  opacity: 0.5;
  text-align: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

/* ── Side column (Quick Actions + Live Activity) ──────────── */
.db-side-col {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Quick Actions items */
.db-qa-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-top: 0.5rem;
}

.db-qa-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  border-radius: 10px;
  text-decoration: none;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.db-qa-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.db-qa-title {
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--text-primary);
}

.db-qa-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.db-qa-purple { background: rgba(124,58,237,0.07); border-color: rgba(124,58,237,0.14); }
.db-qa-purple:hover { background: rgba(124,58,237,0.14); }
.db-qa-purple .db-qa-icon { background: rgba(124,58,237,0.15); }

.db-qa-green  { background: rgba(16,185,129,0.05); border-color: rgba(16,185,129,0.12); }
.db-qa-green:hover  { background: rgba(16,185,129,0.12); }
.db-qa-green .db-qa-icon  { background: rgba(16,185,129,0.12); }

.db-qa-amber  { background: rgba(245,158,11,0.05); border-color: rgba(245,158,11,0.12); }
.db-qa-amber:hover  { background: rgba(245,158,11,0.12); }
.db-qa-amber .db-qa-icon  { background: rgba(245,158,11,0.10); }

.db-qa-blue   { background: rgba(59,130,246,0.05); border-color: rgba(59,130,246,0.12); }
.db-qa-blue:hover   { background: rgba(59,130,246,0.12); }
.db-qa-blue .db-qa-icon   { background: rgba(59,130,246,0.10); }

/* Live Activity */
.db-activity-card { flex: 1; }

.db-activity-body {
  padding: 0 1.25rem;
  max-height: 260px;
  overflow-y: auto;
}

.db-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  display: inline-block;
}

.db-no-activity {
  padding: 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ============================================================
   Dashboard Responsive
   ============================================================ */

/*
  Desktop layout (bottom grid):
  | Recent Contacts | Recent Campaigns | Email Performance | [Quick Actions ]  |
  |                 |                  |                   | [Live Activity  ]  |

  Grid: 3 equal columns + 1 narrower side column
  db-side-col is always flex-column (stacked), never row.
*/

/* Base bottom grid — 3 content cols + 1 side col */
.db-bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 280px;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
  align-items: start;
}

/* ── ≤ 1280px: tighten side col a bit ────────────────────── */
@media (max-width: 1280px) {
  .db-bottom-grid {
    grid-template-columns: 1fr 1fr 1fr 240px;
  }
}

/* ── ≤ 1100px: 2+2 layout ────────────────────────────────── */
@media (max-width: 1100px) {
  /* 2 cols: left pair | right pair */
  .db-bottom-grid {
    grid-template-columns: 1fr 1fr;
  }
  /* Email Performance takes col 1, side col takes col 2 — both on row 2 */
  /* No span needed, natural flow works */
  .db-side-col {
    flex-direction: column; /* keep stacked */
  }
}

/* ── ≤ 1023px: stats/quick 2-col, charts 1-col ───────────── */
@media (max-width: 1023px) {
  .db-stats-grid  { grid-template-columns: repeat(2, 1fr); }
  .db-quick-grid  { grid-template-columns: repeat(2, 1fr); }
  .db-charts-grid { grid-template-columns: 1fr; }
}

/* ── Mobile ≤ 767px: everything single column ────────────── */
@media (max-width: 767px) {
  .db-stats-grid    { grid-template-columns: repeat(2, 1fr); gap: 0.875rem; }
  .db-quick-grid    { grid-template-columns: repeat(2, 1fr); gap: 0.875rem; }
  .db-charts-grid   { grid-template-columns: 1fr; gap: 0.875rem; }

  .db-bottom-grid {
    grid-template-columns: 1fr;
    gap: 0.875rem;
  }

  /* On mobile, side col's two cards sit side by side (Quick Actions + Live Activity) */
  .db-side-col {
    flex-direction: row;
    align-items: flex-start;
    gap: 0.875rem;
  }
  .db-side-col > .card {
    flex: 1;
    min-width: 0;
  }

  .db-doughnut-body { flex-direction: column; gap: 1rem; }
  .db-hide-xs       { display: none; }

  .db-perf-name,
  .db-campaign-name,
  .db-contact-name,
  .db-contact-email,
  .db-campaign-sub  { max-width: 100%; }

  .db-header-actions .btn { font-size: 0.75rem; padding: 0.375rem 0.75rem; }
}

/* ── Small mobile ≤ 540px: side col back to stacked ─────── */
@media (max-width: 540px) {
  .db-side-col {
    flex-direction: column;
  }
  .db-side-col > .card {
    flex: none;
    width: 100%;
  }
}

/* ── Extra small ≤ 479px ─────────────────────────────────── */
@media (max-width: 479px) {
  .db-stats-grid   { grid-template-columns: 1fr 1fr; gap: 0.75rem; }
  .db-quick-grid   { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
  .db-bottom-grid  { gap: 0.75rem; }
  .stat-card-value { font-size: 1.5rem; }
  .db-chart-wrap   { height: 180px; }
  .db-quick-grid .quick-action-btn { padding: 1rem 0.75rem; }
  .db-quick-grid .quick-action-btn span { font-size: 0.75rem; }
}
