/* ─── RESET & BASE ───────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ─── ACCESSIBILITY UTILITIES ─────────────────────────────────────────────── */
/* Screen-reader only — visually hidden but available to assistive tech */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip-to-content link (first focusable element on every page) */
.skip-link {
  position: absolute;
  top: -100px;
  left: 8px;
  z-index: 999999;
  background: var(--primary, #25d366);
  color: #000;
  padding: 10px 18px;
  border-radius: 0 0 8px 8px;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition: top 0.15s ease;
}
.skip-link:focus {
  top: 0;
}

/* ─── GLOBAL FOCUS-VISIBLE RING ───────────────────────────────────────────── */
/* Applied to every interactive element — never suppress outline globally */
:focus-visible {
  outline: 3px solid #25d366;
  outline-offset: 2px;
}
/* Remove old browser default ring only where focus-visible takes over */
:focus:not(:focus-visible) {
  outline: none;
}

/* Minimum 44×44px click/touch target (WCAG 2.5.5) */
.btn,
button,
[role="button"] {
  min-height: 36px;
  min-width: 36px;
}
.btn-touch-44,
.icon-btn,
.sidebar-toggle,
.theme-toggle,
.logout-btn,
.alert-close {
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

:root {
  --bg-primary: #0f1117;
  --bg-secondary: #161b27;
  --bg-tertiary: #1e2535;
  --bg-hover: #1a2035;
  --border: #1e2535;
  --border-light: #2d3748;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --primary: #25d366;
  --bg-card: #161b27;
  --green: #25d366;
  --green-dark: #128c7e;
  --green-dim: #0d3a1f;
  --green-border: #166534;
  --blue: #3b82f6;
  --blue-dim: #0c1a3a;
  --red: #ef4444;
  --red-dim: #2d0a0a;
  --yellow: #fbbf24;
  --yellow-dim: #1c1506;
  --purple: #8b5cf6;
  --purple-dim: #150d2e;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow: 0 4px 20px rgba(0, 0, 0, .4);
  --transition: all .15s ease;
  font-family: 'Inter', system-ui, sans-serif;
  --bg-dark: #0b0d14;
  --text-light: #f8fafc;
  --text-dark: #0f172a;
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-hover: #e2e8f0;
  --border: #e2e8f0;
  --border-light: #cbd5e1;
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --bg-card: #ffffff;
  --green: #16a34a;
  --green-dark: #15803d;
  --green-dim: #dcfce7;
  --green-border: #bbf7d0;
  --blue: #2563eb;
  --blue-dim: #dbeafe;
  --red: #dc2626;
  --red-dim: #fee2e2;
  --yellow: #d97706;
  --yellow-dim: #fef3c7;
  --purple: #7c3aed;
  --purple-dim: #f3e8ff;
  --shadow: 0 4px 20px rgba(0, 0, 0, .08);
  --bg-dark: #e2e8f0;
  --text-light: #0f172a;
  --text-dark: #0f172a;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: var(--font-size-base, 14px);
  font-family: var(--font-base, 'Inter', system-ui, sans-serif);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--green);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 2px;
}

/* ─── LAYOUT ─────────────────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ─── SIDEBAR ────────────────────────────────────────────────────────────── */
.sidebar {
  width: 230px;
  min-width: 230px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width .2s ease;
}

.sidebar.collapsed {
  width: 60px;
  min-width: 60px;
}

.sidebar.collapsed .brand-name,
.sidebar.collapsed .brand-sub,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-section-label,
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .user-meta,
.sidebar.collapsed .usage-card {
  display: none;
}

.sidebar.collapsed .sidebar-brand,
.sidebar.collapsed .sidebar-footer {
  padding-left: 0;
  padding-right: 0;
  justify-content: center;
}

.sidebar.collapsed .sidebar-logo-full,
.sidebar.collapsed .sidebar-logo-text {
  display: none !important;
}

.sidebar.collapsed .sidebar-logo-icon {
  display: block !important;
}

.sidebar.collapsed .user-profile {
  justify-content: center;
  flex-direction: column;
  gap: 12px;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 10px;
}

.sidebar.collapsed .sidebar-brand {
  padding: 8px 18px !important;
}

.sidebar-brand {
  padding: 0px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo-full {
  display: block;
  height: 52px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}

.sidebar-logo-icon {
  display: none;
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.brand-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.brand-icon svg {
  width: 28px;
  height: 28px;
}

.brand-name {
  font-size: 19px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
}

.brand-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}

.sidebar-nav {
  padding: 8px 0;
  flex: 1;
}

.nav-section-label {
  padding: 12px 14px 4px;
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  margin: 1px 6px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: var(--transition);
  text-decoration: none !important;
  position: relative;
}

.nav-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid var(--green-border);
}

.nav-item svg,
.nav-item i {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  border-radius: 10px;
  padding: 1px 6px;
  font-weight: 600;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.usage-card {
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  padding: 10px;
  margin-bottom: 10px;
}

.usage-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 2px;
  transition: width .3s;
}

.bg-green {
  background: var(--green);
}

.bg-blue {
  background: var(--blue);
}

.bg-red {
  background: var(--red);
}

.bg-yellow {
  background: var(--yellow);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  color: transparent;
  /* Hides alt text if image breaks */
}

.user-avatar-initials {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
}

.user-meta {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-plan {
  font-size: 10px;
  color: var(--green);
}

.logout-btn {
  color: var(--text-muted);
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: 4px;
  transition: var(--transition);
}

.logout-btn:hover {
  color: var(--red);
  background: var(--red-dim);
  text-decoration: none;
}

.logout-btn i,
.logout-btn svg {
  width: 14px;
  height: 14px;
}

/* ─── MAIN CONTENT ───────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.topbar {
  height: 54px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  flex-shrink: 0;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
}

.sidebar-toggle:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  position: relative;
  display: flex;
  align-items: center;
}

.icon-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.icon-btn i,
.icon-btn svg {
  width: 18px;
  height: 18px;
}

/* ─── TOPBAR USER DROPDOWN ─────────────────────────────────────────── */
.user-dropdown-wrapper {
  position: relative;
  margin-left: 4px;
}

.user-dropdown-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  padding: 4px 10px 4px 4px;
  border-radius: 50px;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-primary);
}

.user-dropdown-btn:hover {
  border-color: var(--green);
  background: var(--bg-hover);
}

.user-avatar-sm {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.user-avatar-initials-sm {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
}

.user-name-top {
  font-size: 13px;
  font-weight: 600;
  max-width: 80px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown-chevron {
  width: 14px !important;
  height: 14px !important;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.user-dropdown-wrapper.show .dropdown-chevron {
  transform: rotate(180deg);
}

.user-dropdown-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 220px;
  background: var(--bg-secondary);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 8px;
  display: none;
  z-index: 1000;
  animation: dropdownFade .2s ease;
}

@keyframes dropdownFade {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.user-dropdown-menu.show {
  display: block;
}

.dropdown-user-info {
  padding: 10px 12px;
}

.dropdown-user-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.dropdown-user-plan {
  font-size: 11px;
  color: var(--green);
  font-weight: 600;
  margin-top: 2px;
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-secondary);
  transition: var(--transition);
  text-decoration: none !important;
}

.dropdown-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.dropdown-item i,
.dropdown-item svg {
  width: 16px;
  height: 16px;
}

.logout-item:hover {
  background: var(--red-dim);
  color: var(--red);
}

/* ─── THEME TOGGLE GLOW ANIMATIONS ────────────────────────────────────────── */
.theme-toggle .light-icon,
.theme-toggle .dark-icon {
  width: 22px;
  height: 22px;
}

.theme-toggle .light-icon {
  color: #f59e0b;
  /* Deep sunset yellow */
  filter: drop-shadow(0 0 6px rgba(245, 158, 11, 0.5));
  animation: sunPulseGlow 3s infinite alternate ease-in-out, sunRotate 12s linear infinite;
  transform-origin: center;
}

.theme-toggle .dark-icon {
  color: #3730a3;
  /* Dark indigo for extreme visibility on light background */
  filter: drop-shadow(0 0 5px rgba(79, 70, 229, 0.4));
  animation: moonPulseGlow 4s infinite ease-in-out, moonFloat 6s infinite ease-in-out;
  transform-origin: center;
}

@keyframes sunPulseGlow {
  0% {
    filter: drop-shadow(0 0 2px rgba(245, 158, 11, 0.4));
  }

  50% {
    filter: drop-shadow(0 0 12px rgba(245, 158, 11, 1));
  }

  100% {
    filter: drop-shadow(0 0 2px rgba(245, 158, 11, 0.4));
  }
}

@keyframes sunRotate {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

@keyframes moonPulseGlow {
  0% {
    filter: drop-shadow(0 0 2px rgba(79, 70, 229, 0.2));
  }

  50% {
    filter: drop-shadow(0 0 8px rgba(79, 70, 229, 0.9));
  }

  100% {
    filter: drop-shadow(0 0 2px rgba(79, 70, 229, 0.2));
  }
}

@keyframes moonFloat {

  0%,
  100% {
    transform: translateY(0) rotate(0);
  }

  50% {
    transform: translateY(-3px) rotate(-8deg);
  }
}

/* Notification */
.notif-wrapper {
  position: relative;
}

.notif-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  background: var(--red);
  border-radius: 50%;
  font-size: 9px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.notif-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 320px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  z-index: 100;
  display: none;
}

.notif-dropdown.show {
  display: block;
}

.notif-header {
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mark-all-read {
  font-size: 11px;
  color: var(--green);
  font-weight: 400;
}

.notif-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}

.notif-item.unread {
  background: var(--blue-dim);
}

.notif-item:hover {
  background: var(--bg-hover);
}

.notif-title {
  font-size: 13px;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.notif-time {
  font-size: 11px;
  color: var(--text-muted);
}

.notif-empty {
  padding: 20px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.notif-all {
  display: block;
  padding: 10px 16px;
  text-align: center;
  font-size: 12px;
  color: var(--green);
  border-top: 1px solid var(--border);
}

.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* ─── ALERTS ─────────────────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin: 0 20px 12px;
  font-size: 13px;
  border: 1px solid;
  animation: slideDown .2s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.alert i,
.alert svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}

.alert-success {
  background: var(--green-dim);
  border-color: var(--green-border);
  color: #4ade80;
}

.alert-error {
  background: var(--red-dim);
  border-color: #7f1d1d;
  color: #f87171;
}

.alert-warning {
  background: var(--yellow-dim);
  border-color: #92400e;
  color: #fbbf24;
}

.alert ul {
  list-style: none;
  padding: 0;
}

.alert-close {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: inherit;
  opacity: .6;
  line-height: 1;
}

/* ─── CARDS ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.card-sm {
  padding: 14px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.stat-label {
  /* WCAG 1.4.4: min 13px; WCAG 1.4.3: meets 4.5:1 on dark bg */
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 600;
  letter-spacing: .3px;
  /* Removed text-transform: uppercase — use sentence case for legibility */
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-value {
  /* WCAG 1.4.4: min 2rem for stat values */
  font-size: clamp(2rem, 4vw, 1.75rem);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.stat-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.stat-change {
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 3px;
}

.stat-change.up {
  color: #4ade80;
}

.stat-change.down {
  color: var(--red);
}

.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;

  /* ADD THIS LINE */
  transition: all 0.3s ease-in-out;
  cursor: pointer;
}

/* --- Green Glow (Total Contacts) --- */
.stat-card:hover {
  border-color: #10B981;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
  transform: translateY(-2px);
  /* Subtle lift effect */
}

/* --- Blue Glow (Messages Today) --- */
.stat-card.blue-hover:hover {
  border-color: #3B82F6;
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.4);
}

/* --- Gold Glow (Campaigns) --- */
.stat-card.gold-hover:hover {
  border-color: #F59E0B;
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.4);
}

/* ─── GRIDS ──────────────────────────────────────────────────────────────── */
.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.grid-2-1 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}

.grid-1-2 {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 16px;
}

@media (max-width: 1200px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {

  .grid-4,
  .grid-3,
  .grid-2,
  .grid-2-1,
  .grid-1-2 {
    grid-template-columns: 1fr;
  }
}

/* ─── TABLES ─────────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  padding: 10px 14px;
  text-align: left;
  /* WCAG 1.4.4: 13px minimum, sufficient contrast */
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 600;
  letter-spacing: .3px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--bg-primary);
  color: var(--text-secondary);
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover td {
  background: var(--bg-hover);
}

.table-check {
  width: 14px;
  height: 14px;
  cursor: pointer;
  accent-color: var(--green);
}

/* ─── BADGES ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 12px;   /* WCAG 1.4.4: improved from 11px */
  font-weight: 600;
  border: 1px solid;
  white-space: nowrap;
}

/* Badge icon sizing */
.badge svg,
.badge i {
  width: 11px;
  height: 11px;
  flex-shrink: 0;
}

.badge-green {
  background: #052e16;
  color: #4ade80;
  border-color: #166534;
}

.badge-blue {
  background: #0c1a3a;
  color: #60a5fa;
  border-color: #1d4ed8;
}

.badge-yellow {
  background: #1c1506;
  color: #fbbf24;
  border-color: #92400e;
}

.badge-red {
  background: #2d0a0a;
  color: #f87171;
  border-color: #7f1d1d;
}

.badge-gray {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border-color: var(--border-light);
}

.badge-purple {
  background: #150d2e;
  color: #a78bfa;
  border-color: #5b21b6;
}

/* ─── BUTTONS ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  text-decoration: none !important;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--green);
  color: #fff;
  border-color: var(--green-dark);
}

.btn-primary:hover {
  background: #22c55e;
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border-color: var(--border-light);
}

.btn-secondary:hover {
  background: var(--border-light);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--red);
  color: #fff;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-light);
}

.btn-outline:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-xs {
  padding: 3px 8px;
  font-size: 11px;
}

.btn-lg {
  padding: 11px 22px;
  font-size: 14px;
}

.btn svg,
.btn i {
  width: 15px;
  height: 15px;
}

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

/* ─── FORMS ──────────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 6px;
}

.form-label .required {
  color: var(--red);
  margin-left: 2px;
}

.form-control,
.form-select,
textarea.form-control {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  padding: 9px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  /* outline managed by :focus-visible global rule — do not set to none */
  transition: var(--transition);
  font-family: inherit;
}

.form-control:focus,
.form-select:focus,
textarea.form-control:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(37, 211, 102, .1);
}

.form-control::placeholder {
  color: var(--text-muted);
}

.form-control.is-invalid {
  border-color: var(--red);
}

.form-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-text {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* WCAG 3.3.2: Hint text below inputs */
.form-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 5px;
  line-height: 1.45;
}

/* WCAG 1.3.1: Visible form labels — sentence case, sufficient contrast */
.form-label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 6px;
}

.form-label .required {
  color: var(--red);
  margin-left: 2px;
}

.invalid-feedback {
  font-size: 11px;
  color: var(--red);
  margin-top: 4px;
}

.input-group {
  display: flex;
}

.input-group .form-control {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.input-group .btn {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.input-addon {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  padding: 9px 12px;
  font-size: 12px;
  color: var(--text-muted);
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  border-right: none;
  white-space: nowrap;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  accent-color: var(--green);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* ─── SEARCH BAR ─────────────────────────────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 0 12px;
}

.search-bar i,
.search-bar svg {
  color: var(--text-muted);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.search-bar input {
  background: none;
  border: none;
  color: var(--text-primary);
  padding: 9px 0;
  font-size: 13px;
  outline: none;
  flex: 1;
}

/* ─── TABS ───────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  padding: 3px;
  margin-bottom: 16px;
}

.tab {
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
  border: none;
  background: transparent;
}

.tab.active {
  background: var(--bg-secondary);
  color: var(--green);
  border: 1px solid var(--border);
}

.tab:hover:not(.active) {
  color: var(--text-secondary);
}

/* ─── TOGGLE SWITCH ──────────────────────────────────────────────────────── */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggle {
  position: relative;
  width: 40px;
  height: 22px;
  cursor: pointer;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border-light);
  border-radius: 22px;
  transition: .2s;
}

.toggle-slider:before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: .2s;
}

.toggle input:checked~.toggle-slider {
  background: var(--green);
}

.toggle input:checked~.toggle-slider:before {
  transform: translateX(18px);
}

/* ─── MODAL ──────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: 24px;
  width: 500px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-sm {
  width: 380px;
}

.modal-lg {
  width: 700px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
}

.modal-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ─── EMPTY STATE ────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state svg,
.empty-state i {
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  opacity: .4;
}

.empty-state h3 {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 13px;
}

/* ─── PAGINATION ─────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 20px;
}

.page-btn {
  padding: 6px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
}

.page-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.page-btn.active {
  background: var(--green-dim);
  color: var(--green);
  border-color: var(--green-border);
}

/* ─── CHAT UI ────────────────────────────────────────────────────────────── */
.chat-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: calc(100vh - 96px);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--bg-secondary);
}

.chat-sidebar {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.chat-list {
  overflow-y: auto;
  flex: 1;
}

.chat-item {
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}

.chat-item:hover {
  background: var(--bg-hover);
}

.chat-item.active {
  background: var(--green-dim);
  border-left: 3px solid var(--green);
}

.chat-item-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.chat-item-preview {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-time {
  font-size: 10px;
  color: var(--text-muted);
}

.chat-main {
  display: flex;
  flex-direction: column;
}

.chat-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-primary);
}

.msg {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
}

.msg.received {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  align-self: flex-start;
  border-radius: 2px 10px 10px 10px;
}

.msg.sent {
  background: var(--green-dim);
  color: #a7f3d0;
  align-self: flex-end;
  border-radius: 10px 2px 10px 10px;
  border: 1px solid var(--green-border);
}

.msg-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
}

.chat-input {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}

.chat-input .form-control {
  flex: 1;
}

/* ─── CAMPAIGN ANALYTICS ─────────────────────────────────────────────────── */
.metric-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.metric-label {
  font-size: 12px;
  color: var(--text-muted);
  width: 80px;
}

.metric-bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.metric-bar {
  height: 100%;
  border-radius: 3px;
  transition: width .3s;
}

.metric-pct {
  font-size: 12px;
  color: var(--text-secondary);
  width: 40px;
  text-align: right;
}

/* ─── BILLING ────────────────────────────────────────────────────────────── */
.plan-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: 24px;
  transition: var(--transition);
}

.plan-card:hover {
  border-color: var(--green);
}

.plan-card.featured {
  border-color: var(--green);
  background: var(--green-dim);
}

.plan-name {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.plan-price {
  font-size: 36px;
  font-weight: 800;
  color: var(--green);
  margin: 12px 0 4px;
}

.plan-period {
  font-size: 12px;
  color: var(--text-muted);
}

.plan-features {
  margin-top: 16px;
}

.plan-feature {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

.plan-feature:last-child {
  border-bottom: none;
}

.plan-feature i,
.plan-feature svg {
  width: 14px;
  height: 14px;
  color: var(--green);
  flex-shrink: 0;
}

/* ─── CHATBOT BUILDER ────────────────────────────────────────────────────── */
.builder-canvas {
  min-height: 400px;
  background: var(--bg-primary);
  border: 2px dashed var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
}

.flow-node {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 8px;
  cursor: grab;
}

.flow-node:hover {
  border-color: var(--green);
}

.flow-node-type {
  font-size: 10px;
  color: var(--green);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 4px;
}

.flow-arrow {
  display: flex;
  justify-content: center;
  color: var(--text-muted);
  margin: 4px 0;
}

/* ─── SETTINGS ───────────────────────────────────────────────────────────── */
.setting-section {
  margin-bottom: 28px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.setting-row:last-child {
  border-bottom: none;
}

.setting-label {
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
}

.setting-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ─── AVATAR ─────────────────────────────────────────────────────────────── */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.avatar-sm {
  width: 28px;
  height: 28px;
  font-size: 11px;
}

.avatar-lg {
  width: 48px;
  height: 48px;
  font-size: 16px;
}

.avatar-green {
  background: var(--green-dim);
  color: var(--green);
}

.avatar-blue {
  background: var(--blue-dim);
  color: var(--blue);
}

.avatar-purple {
  background: var(--purple-dim);
  color: var(--purple);
}

/* ─── UTILITIES ──────────────────────────────────────────────────────────── */
.d-flex {
  display: flex;
}

.align-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-1 {
  gap: 4px;
}

.gap-2 {
  gap: 8px;
}

.gap-3 {
  gap: 12px;
}

.gap-4 {
  gap: 16px;
}

.mt-1 {
  margin-top: 4px;
}

.mt-2 {
  margin-top: 8px;
}

.mt-3 {
  margin-top: 16px;
}

.mt-4 {
  margin-top: 24px;
}

.mb-1 {
  margin-bottom: 4px;
}

.mb-2 {
  margin-bottom: 8px;
}

.mb-3 {
  margin-bottom: 16px;
}

.mb-4 {
  margin-bottom: 24px;
}

.text-muted {
  color: var(--text-muted);
}

.text-secondary {
  color: var(--text-secondary);
}

.text-green {
  color: var(--green);
}

.text-red {
  color: var(--red);
}

.text-sm {
  font-size: 12px;
}

.text-xs {
  font-size: 11px;
}

.font-semibold {
  font-weight: 600;
}

.font-bold {
  font-weight: 700;
}

.text-center {
  text-align: center;
}

.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.w-full {
  width: 100%;
}

@media (max-width: 480px) {
  .login-card {
    padding: 24px;
  }

  .login-title {
    font-size: 20px;
  }
}

/* ─── LIGHT THEME OVERRIDES ─────────────────────────────────────────────────────────────── */
[data-theme="light"] .alert-success {
  background: #dcfce7;
  border-color: #bbf7d0;
  color: #166534;
}

[data-theme="light"] .alert-error {
  background: #fee2e2;
  border-color: #fecaca;
  color: #991b1b;
}

[data-theme="light"] .alert-warning {
  background: #fef3c7;
  border-color: #fde68a;
  color: #92400e;
}

[data-theme="light"] .badge-green {
  background: #dcfce7;
  color: #166534;
  border-color: #bbf7d0;
}

[data-theme="light"] .badge-blue {
  background: #dbeafe;
  color: #1e40af;
  border-color: #bfdbfe;
}

[data-theme="light"] .badge-yellow {
  background: #fef3c7;
  color: #92400e;
  border-color: #fde68a;
}

[data-theme="light"] .badge-red {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fecaca;
}

[data-theme="light"] .badge-gray {
  background: #f1f5f9;
  color: #475569;
  border-color: #cbd5e1;
}

[data-theme="light"] .badge-purple {
  background: #f3e8ff;
  color: #5b21b6;
  border-color: #e9d5ff;
}

.hidden {
  display: none;
}

.section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* ─── SELECT DROPDOWN OPTIONS ────────────────────────────────────────────── */
select option {
  background: #1e2535;
  color: #fffcfc;
}

select option:hover,
select option:focus,
select option:checked {
  background: #25d366;
  color: #fff;
}