/* ========================================================
   WA AI Platform - Premium SaaS Theme (StarSender V3 Inspired)
   Curated Slate Navy Dark Mode + High Fidelity Custom Glows
   ======================================================== */

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

/* ---- CSS Variables ---- */
:root {
  --primary: #10b981;          /* Neon Emerald Green */
  --primary-hover: #059669;
  --primary-glow: rgba(16, 185, 129, 0.18);
  
  --accent: #6366f1;           /* Electric Indigo */
  --accent-hover: #4f46e5;
  --accent-glow: rgba(99, 102, 241, 0.18);

  --info: #3b82f6;             /* Ocean Blue */
  --info-glow: rgba(59, 130, 246, 0.15);
  
  --purple: #a855f7;           /* Deep Violet */
  --purple-glow: rgba(168, 85, 247, 0.15);
  
  --danger: #ef4444;           /* Coral Red */
  --warning: #f59e0b;          /* Cyber Yellow */
  --success: #10b981;
  
  --bg-dark: #070a13;          /* Deep Indigo Space-Black */
  --bg-surface: #0e1322;       /* Slate Card Surface */
  --bg-card: rgba(14, 19, 34, 0.6);
  --bg-card-hover: rgba(22, 30, 54, 0.8);
  --bg-input: #131a30;         /* Deep Slate Input */
  
  --border: #1a223d;           /* Low contrast slate boundary */
  --border-hover: #26325c;
  --border-focus: rgba(16, 185, 129, 0.45);
  
  --text-primary: #f3f4f6;     /* Bright Grey */
  --text-secondary: #9ca3af;   /* Muted Grey */
  --text-muted: #525a75;       /* Deep Muted Navy */
  
  --sidebar-w: 260px;
  --topbar-h: 68px;
  --radius: 16px;
  --radius-sm: 10px;
  
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  --glass: rgba(14, 19, 34, 0.4);
  --glass-border: rgba(255, 255, 255, 0.03);
  --transition: all 0.25s cubic-bezier(.4, 0, .2, 1);
}

/* ---- Reset ---- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  font-size: 16px;
  scroll-behavior: smooth;
}
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  letter-spacing: -0.011em;
}
a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition);
}
a:hover {
  color: var(--primary-hover);
}
button {
  cursor: pointer;
  font-family: inherit;
  outline: none;
}
input, textarea, select {
  font-family: inherit;
  outline: none;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 100px;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 100px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary); /* Glow emerald green when hovered */
  box-shadow: 0 0 10px var(--primary);
}

/* ---- Typography Helpers ---- */
h1, h2, h3, h4, .stat-value, .logo-icon {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* ---- Login Page Upgrade ---- */
.login-container {
  display: flex;
  min-height: 100vh;
  background: var(--bg-dark);
}
.login-brand {
  flex: 1.2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 70% 30%, rgba(99, 102, 241, 0.15) 0%, rgba(16, 185, 129, 0.05) 50%, var(--bg-dark) 100%), linear-gradient(135deg, #070a13 0%, #0c1020 100%);
  padding: 4rem;
  position: relative;
  overflow: hidden;
  border-right: 1px solid var(--border);
}
.login-brand::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--primary-glow), transparent 70%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0.7;
}
.login-brand .logo {
  font-family: 'Outfit', sans-serif;
  font-size: 2.8rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 1.25rem;
  z-index: 1;
  letter-spacing: -0.03em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.login-brand .logo span {
  color: var(--primary);
  text-shadow: 0 0 15px var(--primary-glow);
}
.login-brand p {
  color: var(--text-secondary);
  font-size: 1.15rem;
  text-align: center;
  max-width: 440px;
  z-index: 1;
  line-height: 1.5;
  margin-bottom: 3rem;
}
.login-brand .features {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
  z-index: 1;
  max-width: 500px;
}
.login-brand .features li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-primary);
  font-size: 0.95rem;
  list-style: none;
  background: rgba(255, 255, 255, 0.03);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-weight: 500;
}
.login-brand .features li::before {
  content: '✓';
  color: var(--primary);
  font-weight: 800;
  font-size: 1.1rem;
}

.login-form-side {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  background: #090d19;
}
.login-box {
  width: 100%;
  max-width: 400px;
}
.login-box h2 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}
.login-box .subtitle {
  color: var(--text-secondary);
  margin-bottom: 2.25rem;
  font-size: 0.95rem;
}
.login-box .tab-switch {
  display: flex;
  gap: 0;
  margin-bottom: 2.25rem;
  background: var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
}
.login-box .tab-switch button {
  flex: 1;
  padding: 0.7rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  transition: var(--transition);
}
.login-box .tab-switch button.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px var(--primary-glow);
}

/* ---- Forms Styling ---- */
.form-group {
  margin-bottom: 1.5rem;
}
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.form-input {
  width: 100%;
  padding: 0.85rem 1.15rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.95rem;
  transition: var(--transition);
  outline: none;
}
.form-input:hover {
  border-color: var(--border-hover);
}
.form-input:focus {
  border-color: var(--primary);
  background: var(--bg-surface);
  box-shadow: 0 0 0 4px var(--primary-glow);
}
.form-input::placeholder {
  color: var(--text-muted);
}
select.form-input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}
select.form-input option {
  background: var(--bg-surface);
  color: var(--text-primary);
}
textarea.form-input {
  min-height: 120px;
  resize: vertical;
}

/* ---- Buttons Styling ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.8rem 1.6rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  transition: var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 0 25px var(--primary-glow);
  transform: translateY(-1.5px);
}
.btn-secondary {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--bg-surface);
  border-color: var(--border-hover);
}
.btn-danger {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: var(--danger);
}
.btn-sm {
  padding: 0.55rem 1.15rem;
  font-size: 0.85rem;
  border-radius: 8px;
}
.btn-block {
  width: 100%;
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* ---- Dashboard Layout System ---- */
.dashboard {
  display: flex;
  min-height: 100vh;
  background: var(--bg-dark);
}

/* Sidebar Styling */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: var(--transition);
}
.sidebar-logo {
  padding: 1.5rem 1.75rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.85rem;
}
.sidebar-logo h1 {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}
.sidebar-logo h1 span {
  color: var(--primary);
  text-shadow: 0 0 10px var(--primary-glow);
}
.sidebar-logo .logo-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary) 0%, #059669 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 15px var(--primary-glow);
}
.sidebar-nav {
  flex: 1;
  padding: 1.25rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 1.15rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.92rem;
  font-weight: 600;
  transition: var(--transition);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-item:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}
.nav-item.active {
  background: var(--primary-glow);
  color: var(--primary);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding-left: calc(1.15rem - 3px);
}
.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  transition: var(--transition);
}
.nav-item.active .nav-icon {
  color: var(--primary);
  filter: drop-shadow(0 0 5px var(--primary));
}
.nav-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 1.8px;
  color: var(--text-muted);
  padding: 1.75rem 1.15rem 0.6rem;
  font-weight: 700;
}
.sidebar-footer {
  padding: 1.15rem 1rem;
  border-top: 1px solid var(--border);
  background: rgba(7, 10, 19, 0.4);
}
.user-info {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.5rem;
}
.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--primary) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.95rem;
  color: #fff;
  box-shadow: 0 4px 10px rgba(99, 102, 241, 0.2);
}
.user-details .user-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
}
.user-details .user-email {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Main Content Styling */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Topbar Styling */
.topbar {
  height: var(--topbar-h);
  background: rgba(14, 19, 34, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2.25rem;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.topbar-title p {
  font-size: 0.82rem;
  color: var(--text-secondary);
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

/* Content Area */
.content {
  padding: 2.25rem;
  flex: 1;
}

/* Page Section Display */
.page-section {
  display: none;
}
.page-section.active {
  display: block;
}

/* ---- Stat Cards (Luxury SaaS Redesign) ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2.25rem;
}
.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.6rem 1.8rem;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 145px;
}
.stat-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}
.stat-card::after {
  content: '';
  position: absolute;
  top: -20px;
  right: -20px;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  filter: blur(45px);
  opacity: 0.12;
  pointer-events: none;
}
.stat-card:nth-child(1)::after { background: var(--primary); }
.stat-card:nth-child(2)::after { background: var(--accent); }
.stat-card:nth-child(3)::after { background: var(--info); }
.stat-card:nth-child(4)::after { background: var(--purple); }

.stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.15rem;
}
.stat-icon-wrapper {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-icon-wrapper.sent {
  background: rgba(16, 185, 129, 0.1);
  color: var(--primary);
}
.stat-icon-wrapper.received {
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent);
}
.stat-icon-wrapper.devices {
  background: rgba(59, 130, 246, 0.1);
  color: var(--info);
}
.stat-icon-wrapper.contacts {
  background: rgba(168, 85, 247, 0.1);
  color: var(--purple);
}

.stat-card .stat-value {
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-primary);
  margin-bottom: 0.15rem;
}
.stat-card .stat-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.stat-card .stat-change {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.25rem 0.55rem;
  border-radius: 6px;
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

/* ---- Glass Card Styling ---- */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  margin-bottom: 1.75rem;
}
.glass-card h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-primary);
}

/* ---- Message Chart Card ---- */
.chart-container-card {
  padding: 1.8rem;
  margin-bottom: 2rem;
  border-color: rgba(99, 102, 241, 0.15); /* Sleek Indigo glow highlight */
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}
.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
}
.chart-actions {
  display: flex;
  gap: 0.75rem;
}
.chart-badge {
  background: rgba(16, 185, 129, 0.12);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.chart-badge::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--primary);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--primary);
  animation: statusPulse 1.5s infinite;
}
.chart-wrapper {
  position: relative;
  width: 100%;
  height: 300px;
}

/* ---- WA Accounts Devices Section ---- */
.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}
.device-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 220px;
  box-shadow: var(--shadow);
}
.device-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.5);
}
.device-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.device-header strong {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.device-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: rgba(255, 255, 255, 0.03);
  padding: 0.3rem 0.65rem;
  border-radius: 20px;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.status-dot.connected {
  background: var(--success);
  box-shadow: 0 0 10px var(--primary);
}
.status-dot.disconnected {
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
}
.status-dot.connecting {
  background: var(--warning);
  box-shadow: 0 0 8px var(--warning);
  animation: statusPulse 1.5s infinite;
}
@keyframes statusPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(0.9); }
}
.qr-container {
  display: flex;
  justify-content: center;
  padding: 1.25rem;
  background: white;
  border-radius: var(--radius-sm);
  margin: 1.25rem 0;
  box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.1);
}
.qr-container img {
  width: 180px;
  height: 180px;
}
.device-card p {
  font-size: 0.88rem;
  font-weight: 500;
  margin-bottom: 1rem;
}

/* ---- Inbox Upgrade (StarSender Web WhatsApp style) ---- */
.inbox-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 0;
  height: calc(100vh - var(--topbar-h) - 4.5rem);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.chat-list {
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.chat-list-header {
  padding: 1.25rem;
  border-bottom: 1px solid var(--border);
}
.chat-list-header input {
  width: 100%;
  padding: 0.75rem 1.25rem 0.75rem 2.5rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 30px;
  color: var(--text-primary);
  font-size: 0.88rem;
  outline: none;
  transition: var(--transition);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23525a75' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 1rem center;
}
.chat-list-header input:focus {
  border-color: var(--primary);
  background-color: var(--bg-surface);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
.chat-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid rgba(26, 34, 61, 0.3);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}
.chat-item:hover {
  background: rgba(22, 30, 54, 0.4);
}
.chat-item.active {
  background: rgba(16, 185, 129, 0.08);
}
.chat-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3.5px;
  background: var(--primary);
}
.chat-item .chat-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  font-size: 1rem;
  flex-shrink: 0;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}
.chat-item .chat-info {
  flex: 1;
  min-width: 0;
}
.chat-item .chat-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.2rem;
}
.chat-item .chat-preview {
  font-size: 0.82rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}
.chat-item .chat-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-shrink: 0;
  font-weight: 600;
  align-self: flex-start;
  margin-top: 0.25rem;
}

.chat-view {
  display: flex;
  flex-direction: column;
  background: #090d16;
}
.chat-view-header {
  padding: 1.1rem 1.75rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
}
.chat-view-header strong {
  font-family: 'Outfit', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  background-image: radial-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px);
  background-size: 16px 16px;
}
.msg-bubble {
  max-width: 65%;
  padding: 0.8rem 1.25rem;
  border-radius: 14px;
  font-size: 0.92rem;
  line-height: 1.55;
  position: relative;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  animation: bubbleFade 0.2s ease-out;
}
@keyframes bubbleFade {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg-bubble.incoming {
  background: var(--bg-surface);
  align-self: flex-start;
  border-bottom-left-radius: 3px;
  border: 1px solid var(--border);
  color: var(--text-primary);
}
.msg-bubble.outgoing {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.22) 0%, rgba(16, 185, 129, 0.15) 100%);
  align-self: flex-end;
  border-bottom-right-radius: 3px;
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--text-primary);
}
.msg-time {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
  text-align: right;
  font-weight: 600;
}
.chat-input-area {
  padding: 1.25rem 1.75rem;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.85rem;
  align-items: center;
}
.chat-input-area input {
  flex: 1;
  padding: 0.9rem 1.4rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 30px;
  color: var(--text-primary);
  outline: none;
  font-size: 0.95rem;
  transition: var(--transition);
}
.chat-input-area input:focus {
  border-color: var(--primary);
  background: var(--bg-surface);
}
.chat-input-area button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  border: none;
  color: #fff;
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  box-shadow: 0 4px 15px var(--primary-glow);
}
.chat-input-area button:hover {
  background: var(--primary-hover);
  box-shadow: 0 0 20px var(--primary-glow);
  transform: scale(1.03);
}
.chat-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 1.15rem;
  flex-direction: column;
  gap: 1.25rem;
}
.chat-empty span {
  font-size: 3.5rem;
}

/* ---- Contacts & Campaigns Tables ---- */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-sm);
}
table {
  width: 100%;
  border-collapse: collapse;
}
th {
  text-align: left;
  padding: 1rem 1.25rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  border-bottom: 1.5px solid var(--border);
  font-weight: 700;
  background: rgba(14, 19, 34, 0.4);
}
td {
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--text-primary);
  font-weight: 500;
  transition: var(--transition);
}
tr:hover td {
  background: rgba(255, 255, 255, 0.015);
}
.tag {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: rgba(16, 185, 129, 0.1);
  color: var(--primary);
  border-radius: 30px;
  font-size: 0.75rem;
  font-weight: 700;
  margin-right: 0.35rem;
  border: 1px solid rgba(16, 185, 129, 0.15);
}

/* ---- Sender Page Design ---- */
.sender-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 1.75rem;
}
.number-list {
  max-height: 220px;
  overflow-y: auto;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  border: 1px solid var(--border);
}
.number-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  font-weight: 600;
}
.number-item button {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition);
}
.number-item button:hover {
  transform: scale(1.15);
}
.progress-bar {
  height: 10px;
  background: var(--bg-input);
  border-radius: 5px;
  overflow: hidden;
  margin-top: 1rem;
  border: 1px solid var(--border);
}
.progress-bar .progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
  border-radius: 5px;
  transition: width 0.5s cubic-bezier(.4,0,.2,1);
}

/* ---- Modal System ---- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 13, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.active {
  display: flex;
}
.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.25rem;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.9) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal h3 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  color: var(--text-primary);
}
.modal p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.modal-actions {
  display: flex;
  gap: 0.85rem;
  margin-top: 2rem;
  justify-content: flex-end;
}

/* ---- Toast Notifications ---- */
.toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.toast {
  padding: 0.95rem 1.4rem;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: slideIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  min-width: 300px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  border-left: 4px solid transparent;
}
.toast.success {
  background: #072214;
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-left: 4px solid var(--primary);
  color: #a7f3d0;
}
.toast.error {
  background: #2d0e0e;
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-left: 4px solid var(--danger);
  color: #fca5a5;
}
.toast.info {
  background: #0a1b3a;
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-left: 4px solid var(--info);
  color: #bfdbfe;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(60px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ---- Responsive System ---- */
@media(max-width: 1200px) {
  .sender-grid {
    grid-template-columns: 1fr;
  }
}
@media(max-width: 1024px) {
  .inbox-layout {
    grid-template-columns: 280px 1fr;
  }
}
@media(max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .login-container {
    flex-direction: column;
  }
  .login-brand {
    display: none;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
  .inbox-layout {
    grid-template-columns: 1fr;
  }
  .chat-view {
    display: none;
  }
  .content {
    padding: 1.5rem;
  }
  .topbar {
    padding: 0 1.5rem;
  }
}
@media(max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
}

/* ---- CRM Kanban Pipeline Board ---- */
.contacts-view-toggle {
  display: flex;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-right: auto;
}
.contacts-view-toggle button {
  padding: 0.45rem 1rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.85rem;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.contacts-view-toggle button.active {
  background: var(--primary-glow);
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.1);
}

.kanban-board {
  display: flex;
  gap: 1.25rem;
  overflow-x: auto;
  padding: 0.5rem 0 1.5rem 0;
  align-items: flex-start;
  min-height: 550px;
}
.kanban-column {
  flex: 1;
  min-width: 260px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 700px;
  overflow-y: auto;
  transition: var(--transition);
}
.kanban-column.dragover {
  border-color: var(--primary);
  box-shadow: 0 0 20px var(--primary-glow);
  background: rgba(16, 185, 129, 0.03);
}
.kanban-column-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.75rem;
  border-bottom: 2.5px solid var(--border);
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.75px;
}
.kanban-column[data-status="new"] .kanban-column-header { border-bottom-color: var(--info); }
.kanban-column[data-status="interested"] .kanban-column-header { border-bottom-color: var(--accent); }
.kanban-column[data-status="follow_up"] .kanban-column-header { border-bottom-color: var(--warning); }
.kanban-column[data-status="closing"] .kanban-column-header { border-bottom-color: var(--primary); }
.kanban-column[data-status="repeat_order"] .kanban-column-header { border-bottom-color: var(--purple); }

.kanban-column-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.kanban-column-count {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.2rem 0.65rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-primary);
}

.kanban-cards-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 150px;
}

.kanban-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.95rem;
  cursor: grab;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  user-select: none;
}
.kanban-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  transform: translateY(-2.5px);
  box-shadow: var(--shadow);
}
.kanban-card:active {
  cursor: grabbing;
}
.kanban-card.dragging {
  opacity: 0.4;
  border-style: dashed;
  border-color: var(--text-muted);
}
.kanban-card-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'Outfit', sans-serif;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kanban-card-phone {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-family: monospace;
}
.kanban-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.15rem;
}
.kanban-card-tag {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.kanban-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
  margin-top: 0.5rem;
  border-top: 1px solid var(--border);
  padding-top: 0.5rem;
}
.kanban-card-btn {
  background: none;
  border: none;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.3rem;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--text-secondary);
}
.kanban-card-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}
.kanban-card-btn.chat-btn:hover {
  color: var(--primary);
  background: var(--primary-glow);
}
.kanban-card-btn.edit-btn:hover {
  color: var(--info);
  background: var(--info-glow);
}
.kanban-card-btn.delete-btn:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}
