:root, [data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-card: #ffffff;
  --border-color: #e2e8f0;
  --border-focus: #10b981;
  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.16);
  --accent-emerald-light: #ecfdf5;
  --accent-emerald-dark: #059669;
  --accent-cyan: #06b6d4;
  --accent-purple: #8b5cf6;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 4px 20px -2px rgba(15, 23, 42, 0.05), 0 2px 6px -1px rgba(15, 23, 42, 0.02);
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-heading: 'Plus Jakarta Sans', var(--font-family);
  --font-mono: 'Fira Code', 'Consolas', monospace;
  --sidebar-width: 250px;
}

[data-theme="dark"] {
  --bg-primary: #07090e;
  --bg-secondary: #0c101a;
  --bg-tertiary: #121829;
  --bg-card: rgba(15, 20, 34, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #10b981;
  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.25);
  --accent-emerald-light: rgba(16, 185, 129, 0.12);
  --accent-emerald-dark: #059669;
  --accent-cyan: #06b6d4;
  --accent-purple: #8b5cf6;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --danger: #ef4444;
  --warning: #f59e0b;
  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-heading: 'Plus Jakarta Sans', var(--font-family);
  --font-mono: 'Fira Code', 'Consolas', monospace;
}


* {
  box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   Mobile Touch Target Enhancements
   Ensure all interactive elements are ≥44px for proper touch accessibility
-------------------------------------------------------------------------- */

/* Minimum touch target size */
button,
input[type="button"],
input[type="submit"],
.input-group-append button,
.btn {
  min-height: 44px;
  min-width: 44px;
}

/* Ensure proper padding on mobile buttons */
@media (max-width: 768px) {
  .btn {
    padding: 12px 16px !important;
    font-size: 1rem !important;
  }

  .nav-tab {
    min-height: 48px !important;
    padding: 8px 16px !important;
  }

  .nav-link {
    padding: 14px !important;
    min-height: 48px !important;
  }

  .card button {
    min-height: 48px !important;
    padding: 12px 16px !important;
  }

  .sidebar-close-btn,
  .portal-sidebar-toggle-btn {
    width: 48px !important;
    height: 48px !important;
    padding: 10px !important;
  }

  /* Form inputs - larger touch targets */
  .form-control,
  input,
  textarea,
  select {
    min-height: 44px;
    font-size: 1rem;
    padding: 10px 12px;
  }

  /* Large mobile-friendly buttons */
  .btn-lg,
  button.btn-lg {
    min-height: 56px !important;
    padding: 14px 20px !important;
    font-size: 1.1rem !important;
  }
}

/* Prevent zoom on form fields (mobile) */
@media (max-width: 768px) {
  input,
  textarea,
  select {
    font-size: 16px !important; /* Prevents iOS Safari auto-zoom */
  }
}

html {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
}


/* Background ambient glow */
body::before {
  content: '';
  position: fixed;
  top: -150px;
  right: -150px;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.12) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  bottom: -200px;
  left: -200px;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.1) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

@media (max-width: 768px) {
  body::before,
  body::after {
    display: none !important;
  }
}

/* Header */
.app-header {
  height: 70px;
  background: var(--bg-secondary);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.logo-badge {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-emerald), var(--accent-cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  color: #fff;
  box-shadow: 0 0 15px var(--accent-emerald-glow);
}

.brand-name {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.connection-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.status-dot.connected,
.status-dot.green {
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
}

.status-dot.disconnected {
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
}

.status-dot.pairing {
  background: var(--warning);
  box-shadow: 0 0 8px var(--warning);
}

.btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-emerald), #059669);
  color: #fff;
  box-shadow: 0 4px 15px var(--accent-emerald-glow);
}

.btn-primary:hover {
  opacity: 0.95;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

/* Nav Tabs */
.portal-nav {
  display: flex;
  gap: 8px;
  padding: 16px 32px 0 32px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.nav-tab {
  padding: 10px 20px;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.92rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  border-bottom: 2px solid transparent;
}

.nav-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

.nav-tab.active {
  color: #fff;
  background: var(--bg-tertiary);
  border-bottom: 2px solid var(--accent-emerald);
}

/* Main Content Area */
.portal-main {
  flex: 1;
  padding: 32px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tab-pane.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Glass Cards */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
  margin-bottom: 24px;
}

.card-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-subtitle {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

/* Forms */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 8px;
  display: block;
  line-height: 1.4;
}

[data-theme="dark"] .form-label {
  color: #f1f5f9;
}

.form-control {
  width: 100%;
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #0f172a;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus {
  border-color: var(--accent-emerald) !important;
  box-shadow: 0 0 0 3px var(--accent-emerald-glow) !important;
}

.form-control::placeholder {
  color: #94a3b8;
  opacity: 1;
}

/* Browser autofill styling to ensure typed/saved text is always high-contrast dark */
.form-control:-webkit-autofill,
.form-control:-webkit-autofill:hover,
.form-control:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0px 1000px #ffffff inset !important;
  -webkit-text-fill-color: #0f172a !important;
  transition: background-color 5000s ease-in-out 0s;
}

[data-theme="dark"] .form-control {
  background: rgba(16, 21, 34, 0.85);
  border-color: rgba(255, 255, 255, 0.12);
  color: #f1f5f9;
}

[data-theme="dark"] .form-control:-webkit-autofill,
[data-theme="dark"] .form-control:-webkit-autofill:hover,
[data-theme="dark"] .form-control:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0px 1000px #161d30 inset !important;
  -webkit-text-fill-color: #f1f5f9 !important;
}

textarea.form-control {
  resize: vertical;
  min-height: 90px;
}

/* Switch toggle */
.switch-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.switch-input {
  display: none;
}

.switch-slider {
  width: 44px;
  height: 24px;
  background: var(--bg-tertiary);
  border-radius: 20px;
  position: relative;
  transition: 0.3s;
  border: 1px solid var(--border-color);
}

.switch-slider::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-secondary);
  transition: 0.3s;
}

.switch-input:checked + .switch-slider {
  background: var(--accent-emerald);
}

.switch-input:checked + .switch-slider::before {
  transform: translateX(19px);
  background: #fff;
}

/* QR Code Box */
.qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: rgba(10, 13, 20, 0.5);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-color);
  margin-top: 16px;
  min-height: 280px;
}

.qr-image {
  width: 240px;
  height: 240px;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  background: #fff;
  padding: 10px;
}

/* =========================================================
   MODERN CRM INBOX & WORKSPACE (LIGHT THEME + EMERALD ACCENT)
   ========================================================= */

.crm-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 0;
  height: clamp(620px, calc(100vh - 130px), 920px);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  position: relative;
}

.crm-sidebar {
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  height: 100%;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}

.crm-sidebar-header {
  padding: 14px 16px 10px 16px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.crm-tab-switcher {
  display: flex;
  gap: 6px;
  background: var(--bg-tertiary);
  padding: 3px;
  border-radius: 10px;
}

.crm-tab-switcher button {
  flex: 1;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.crm-tab-switcher button.active {
  background: #ffffff;
  color: var(--accent-emerald-dark);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .crm-tab-switcher button.active {
  background: var(--bg-card);
  color: var(--accent-emerald);
}

/* CRM Search Box */
.crm-search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.crm-search-box .search-icon {
  position: absolute;
  left: 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
  pointer-events: none;
}

.crm-search-box input {
  width: 100%;
  padding: 7px 10px 7px 32px;
  font-size: 0.82rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-primary);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s ease;
}

.crm-search-box input:focus {
  border-color: var(--accent-emerald);
  background: #ffffff;
}

/* Filter Chips */
.crm-filter-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.crm-filter-chips::-webkit-scrollbar {
  display: none;
}

.crm-filter-chip {
  padding: 3px 9px;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.crm-filter-chip:hover {
  color: var(--text-primary);
  border-color: #cbd5e1;
}

.crm-filter-chip.active {
  background: var(--accent-emerald-light);
  border-color: var(--accent-emerald);
  color: var(--accent-emerald-dark);
  font-weight: 700;
}

.customer-list {
  flex: 1 1 0%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg-secondary);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.customer-list::-webkit-scrollbar {
  width: 6px;
}
.customer-list::-webkit-scrollbar-track {
  background: transparent;
}
.customer-list::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
}
.customer-list::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.28);
}
[data-theme="dark"] .customer-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
}
[data-theme="dark"] .customer-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.28);
}

.customer-item {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

.customer-item:hover {
  background: #f8fafc;
}

.customer-item.active {
  background: #ecfdf5;
  border-left: 3px solid var(--accent-emerald);
}

[data-theme="dark"] .customer-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

[data-theme="dark"] .customer-item.active {
  background: rgba(16, 185, 129, 0.1);
  border-left: 3px solid var(--accent-emerald);
}

.customer-avatar {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10b981 0%, #06b6d4 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.25);
  flex-shrink: 0;
}

.customer-info {
  flex: 1;
  min-width: 0;
}

.customer-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3px;
}

.customer-phone {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.customer-preview {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.customer-item-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.badge-ai-active {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}

.badge-takeover {
  background: #fef3c7;
  color: #d97706;
  border: 1px solid #fde68a;
}

/* CRM Chat Workspace */
.crm-chat {
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  height: 100%;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}

.crm-chat-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
  gap: 12px;
}

.crm-mobile-back-btn {
  display: none;
  align-items: center;
  gap: 4px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 5px 9px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.crm-header-customer-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.crm-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.crm-status-pill.online {
  background: #ecfdf5;
  color: #059669;
  border-color: #a7f3d0;
}

.crm-status-pill.takeover {
  background: #fef3c7;
  color: #b45309;
  border-color: #fde68a;
}

.status-indicator-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 6px var(--accent-emerald);
}

.crm-status-pill.takeover .status-indicator-dot {
  background: #f59e0b;
  box-shadow: 0 0 6px #f59e0b;
}

/* Takeover Banner inside Chat */
.crm-takeover-alert {
  background: #fffbeb;
  border-bottom: 1px solid #fef3c7;
  color: #92400e;
  padding: 10px 18px;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* Chat Messages Canvas */
.chat-messages {
  flex: 1 1 0%;
  min-height: 0;
  padding: 20px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8fafc;
  background-image: radial-gradient(#e2e8f0 1px, transparent 1px);
  background-size: 20px 20px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}
.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
}
.chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.28);
}
[data-theme="dark"] .chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
}
[data-theme="dark"] .chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.28);
}

[data-theme="dark"] .chat-messages {
  background: #0d111d;
  background-image: radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 20px 20px;
}

.chat-bubble {
  max-width: 72%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.5;
  word-break: break-word;
  position: relative;
}

.chat-bubble.customer {
  align-self: flex-start;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  color: #0f172a;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.04);
}

[data-theme="dark"] .chat-bubble.customer {
  background: #161d30;
  border-color: rgba(255, 255, 255, 0.1);
  color: #f1f5f9;
}

.chat-bubble.bot {
  align-self: flex-end;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #064e3b;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.08);
}

[data-theme="dark"] .chat-bubble.bot {
  background: #064e3b;
  border-color: #059669;
  color: #ffffff;
}

.chat-bubble.agent {
  align-self: flex-end;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e3a8a;
  border-bottom-right-radius: 4px;
}

.chat-bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-size: 0.68rem;
  color: #64748b;
  margin-top: 4px;
}

.chat-bubble.bot .chat-bubble-meta {
  color: #059669;
}

.chat-read-ticks {
  font-weight: 700;
  color: var(--accent-emerald);
}

/* Quick Macros Tray */
.crm-quick-macros {
  padding: 8px 16px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.crm-quick-macros::-webkit-scrollbar {
  display: none;
}

.crm-macro-chip {
  padding: 5px 11px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 16px;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.crm-macro-chip:hover {
  background: var(--accent-emerald-light);
  border-color: var(--accent-emerald);
  color: var(--accent-emerald-dark);
}

/* CRM Chat Input Bar */
.crm-chat-input {
  padding: 12px 18px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 10px;
  background: var(--bg-secondary);
  align-items: center;
}

.crm-chat-input input {
  font-size: 0.92rem;
  padding: 10px 14px;
  border-radius: 20px;
}

/* =========================================================
   AUTH MODAL (UNIFIED WITH LANDING PAGE THEME)
   ========================================================= */

.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(248, 250, 252, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.auth-overlay.show,
.auth-overlay[style*="display: flex"],
.auth-overlay[style*="display:flex"],
.modal-backdrop.show,
.modal-backdrop[style*="display: flex"],
.modal-backdrop[style*="display:flex"] {
  opacity: 1 !important;
  visibility: visible !important;
}

/* Persona Catalog Item Checklist */
.persona-catalog-checklist {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
  padding: 8px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.persona-catalog-item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: background 0.15s ease;
}

.persona-catalog-item-row:hover {
  background: rgba(16, 185, 129, 0.08);
}

.persona-catalog-item-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-emerald);
  cursor: pointer;
}

.persona-catalog-item-info {
  display: flex;
  flex: 1;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.persona-catalog-item-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
}

.persona-catalog-item-price {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

/* Light theme default - matches landing page */
.auth-card {
  width: 100%;
  max-width: 460px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 28px;
  padding: 40px 36px;
  box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 0.08), 0 8px 32px rgba(16, 185, 129, 0.15);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* Dark theme support */
[data-theme="dark"] .auth-overlay {
  background: rgba(10, 15, 22, 0.88);
}

[data-theme="dark"] .auth-card {
  background: #101522;
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 0.75);
}

.auth-brand-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
}

.auth-brand-title {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.2;
  margin: 0;
  letter-spacing: -0.01em;
}

.auth-brand-title,
[data-theme="dark"] .auth-brand-title {
  color: #0f172a;
}

[data-theme="dark"] .auth-brand-title {
  color: #f1f5f9;
}

.auth-brand-title span {
  color: #10b981;
}

.auth-brand-subtitle {
  font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: #334155;
  font-size: 0.9rem;
  font-weight: 500;
  margin-top: 4px;
  line-height: 1.4;
}

[data-theme="dark"] .auth-brand-subtitle {
  color: #94a3b8;
}

.auth-segmented-tabs {
  display: flex;
  background: #f1f5f9;
  border-radius: 9999px;
  padding: 4px;
  margin-bottom: 28px;
  border: 1px solid #e2e8f0;
  gap: 4px;
}

[data-theme="dark"] .auth-segmented-tabs {
  background: #161d30;
  border-color: rgba(255, 255, 255, 0.08);
}

.auth-segmented-tab {
  flex: 1;
  padding: 10px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #64748b;
  background: transparent;
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: center;
  font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.auth-segmented-tab:hover {
  background: rgba(16, 185, 129, 0.08);
  color: #10b981;
}

.auth-segmented-tab.active {
  background: #ffffff;
  color: #10b981;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
}

[data-theme="dark"] .auth-segmented-tab.active {
  background: #101522;
  color: #10b981;
}

.input-icon-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon-prefix {
  position: absolute;
  left: 12px;
  font-size: 1rem;
  color: #64748b;
  pointer-events: none;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.input-icon-wrapper .form-control {
  padding-left: 42px;
  padding-right: 44px;
  border-radius: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.25);
}

[data-theme="dark"] .form-control:focus {
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.35);
}

[data-theme="dark"] .input-icon-prefix {
  color: #94a3b8;
}

.btn-toggle-password {
  position: absolute;
  right: 14px;
  background: transparent;
  border: none;
  color: #64748b;
  cursor: pointer;
  padding: 4px;
  font-size: 1.1rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 2;
  width: 28px;
  height: 28px;
}

.btn-toggle-password:hover {
  color: #10b981;
  background: rgba(16, 185, 129, 0.08);
  transform: scale(1.08);
}

.auth-submit-btn {
  width: 100%;
  justify-content: center;
  padding: 14px 24px;
  margin-top: 6px;
  font-size: 1rem;
  font-weight: 700;
  border-radius: 14px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.35);
  color: #ffffff;
  border: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.auth-submit-btn:hover {
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45);
  transform: translateY(-2px);
  background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
}

[data-theme="dark"] .auth-submit-btn {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

/* ===== In-Card Language Switcher & RTL Styling ===== */
.auth-lang-switcher {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}

.auth-lang-btn {
  border: 1px solid var(--border-color, #e2e8f0);
  background: var(--bg-surface-elevated, #f8fafc);
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--text-muted, #64748b);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
}

.auth-lang-btn:hover {
  color: var(--text-primary, #0f172a);
  border-color: #10b981;
}

.auth-lang-btn.active {
  background: rgba(16, 185, 129, 0.12) !important;
  border-color: #10b981 !important;
  color: #10b981 !important;
}

[data-theme="dark"] .auth-lang-btn {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  color: #94a3b8;
}

[data-theme="dark"] .auth-lang-btn.active {
  background: rgba(16, 185, 129, 0.2) !important;
  color: #34d399 !important;
}

/* RTL Layout Rules for Auth Modal */
[dir="rtl"] .auth-card {
  text-align: right;
}

[dir="rtl"] .auth-lang-switcher {
  justify-content: flex-start;
}

[dir="rtl"] .auth-brand-header {
  text-align: right;
  flex-direction: row;
}

[dir="rtl"] .form-label {
  text-align: right;
}

[dir="rtl"] .input-icon-prefix {
  left: auto;
  right: 14px;
}

[dir="rtl"] .btn-toggle-password {
  right: auto;
  left: 14px;
}

[dir="rtl"] .input-icon-wrapper .form-control {
  padding-left: 44px;
  padding-right: 42px;
  text-align: right;
  direction: rtl;
}

[dir="rtl"] .input-icon-wrapper input[type="email"],
[dir="rtl"] .input-icon-wrapper input[type="password"],
[dir="rtl"] #etsyOrderId {
  direction: ltr;
  text-align: left;
}

[dir="rtl"] .auth-terms-note {
  text-align: center;
}


/* ===== Google 1-Click Sign-In Container & Button ===== */
#googleSignInBtnWrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-height: 44px;
  position: relative;
}

#googleSignInBtnWrapper iframe {
  margin: 0 auto !important;
}

.google-sign-in-native-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  max-width: 320px;
  height: 44px;
  padding: 0 16px;
  border-radius: 9999px;
  background: #ffffff;
  color: #3c4043;
  border: 1px solid #dadce0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(60, 64, 67, 0.08);
  transition: all 0.2s ease;
  user-select: none;
}

.google-sign-in-native-btn:hover {
  background-color: #f8fafd;
  border-color: #c6c9ce;
  box-shadow: 0 2px 8px rgba(60, 64, 67, 0.16);
  transform: translateY(-1px);
}

.google-sign-in-native-btn:active {
  background-color: #f1f3f4;
  transform: translateY(0);
}

[data-theme="dark"] .google-sign-in-native-btn {
  background: #1e293b;
  color: #f1f5f9;
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .google-sign-in-native-btn:hover {
  background: #273549;
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

/* Hide fallback if Google official iframe is present */
#googleSignInBtnWrapper:has(iframe) .google-sign-in-native-btn {
  display: none !important;
}

/* ===== Welcome Overlay ===== */
.auth-welcome-overlay {
  position: fixed;
  inset: 0;
  background: rgba(248, 250, 252, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.auth-welcome-overlay.show {
  opacity: 1;
  visibility: visible;
}

.auth-welcome-card {
  background: #ffffff;
  border-radius: 28px;
  padding: 48px 40px;
  max-width: 420px;
  text-align: center;
  box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 0.08), 0 8px 32px rgba(16, 185, 129, 0.15);
  border: 1px solid #e2e8f0;
  position: relative;
  overflow: hidden;
}

[data-theme="dark"] .auth-welcome-card {
  background: #101522;
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 0.75);
}

.auth-welcome-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 24px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  color: #ffffff;
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.35);
  flex-shrink: 0;
}

.auth-welcome-title {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 1.65rem;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 12px 0;
  letter-spacing: -0.01em;
}

[data-theme="dark"] .auth-welcome-title {
  color: #f1f5f9;
}

.auth-welcome-desc {
  font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: #334155;
  font-size: 0.95rem;
  line-height: 1.5;
  margin: 0 0 24px 0;
}

[data-theme="dark"] .auth-welcome-desc {
  color: #94a3b8;
}

.auth-welcome-btn {
  padding: 14px 32px;
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-block;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.35);
  font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.auth-welcome-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45);
}


/* Toast Notifications - High-Contrast Executive Dark Glassmorphism */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  padding: 14px 22px;
  background: #090d16 !important;
  color: #ffffff !important;
  border: 1px solid rgba(16, 185, 129, 0.6) !important;
  border-radius: 12px !important;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.65), 0 0 20px rgba(16, 185, 129, 0.25) !important;
  font-family: var(--font-family);
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: -0.01em;
  z-index: 9999999 !important;
  display: none;
  align-items: center;
  gap: 12px;
  max-width: 440px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  animation: toastSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes toastSlideUp {
  0% { opacity: 0; transform: translateY(16px) scale(0.96); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* Super Admin Styling */
.admin-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.admin-kpi-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
}

.admin-kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #8b5cf6, #06b6d4);
}

.admin-kpi-card.kpi-error::before {
  background: linear-gradient(90deg, #ef4444, #f59e0b);
}

.kpi-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.kpi-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.admin-table-container {
  overflow-x: auto;
  margin-top: 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.admin-table th {
  background: var(--bg-tertiary);
  padding: 12px 16px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-color);
}

.admin-table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  vertical-align: middle;
}

.admin-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-active { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-trial { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-expired { background: rgba(239, 68, 68, 0.15); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-admin { background: rgba(139, 92, 246, 0.15); color: #c084fc; border: 1px solid rgba(139, 92, 246, 0.3); }
.badge-error { background: rgba(239, 68, 68, 0.2); color: #fca5a5; font-family: monospace; font-size: 0.7rem; }
.badge-warn { background: rgba(245, 158, 11, 0.2); color: #fde68a; font-family: monospace; font-size: 0.7rem; }
.badge-info { background: rgba(6, 182, 212, 0.2); color: #a5f3fc; font-family: monospace; font-size: 0.7rem; }

.btn-xs {
  padding: 4px 8px;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  transition: all 0.15s ease;
}

.btn-xs:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-xs.btn-success {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.4);
  color: #34d399;
}

.btn-xs.btn-success:hover {
  background: rgba(16, 185, 129, 0.3);
}

.btn-xs.btn-vip {
  background: rgba(139, 92, 246, 0.15);
  border-color: rgba(139, 92, 246, 0.4);
  color: #c084fc;
}

.btn-xs.btn-vip:hover {
  background: rgba(139, 92, 246, 0.3);
}

.admin-log-console {
  background: #06080e;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  height: 380px;
  overflow-y: auto;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.log-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 6px 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.015);
  border-left: 3px solid transparent;
}

.log-row.ERROR { border-left-color: #ef4444; }
.log-row.WARN { border-left-color: #f59e0b; }
.log-row.INFO { border-left-color: #06b6d4; }

.log-time {
  color: var(--text-muted);
  white-space: nowrap;
  font-size: 0.75rem;
}

.log-content {
  flex: 1;
  word-break: break-word;
}

.log-details {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 4px;
}

/* ==========================================
   AI Persona Sandbox Styles
   ========================================== */

.persona-selector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.persona-select-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  text-align: left;
}

.persona-select-card:hover {
  transform: translateY(-2px);
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.04);
}

.persona-select-card.active {
  border-color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.08);
  box-shadow: 0 0 15px -3px rgba(16, 185, 129, 0.25);
}

.persona-select-card .card-icon {
  font-size: 1.8rem;
  margin-bottom: 8px;
}

.persona-select-card .card-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.persona-select-card .card-tagline {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.sandbox-container {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 440px;
  gap: 28px;
  align-items: start;
}

/* Left: Persona Blueprint Details */
.sandbox-details-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.catalog-pill-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}

.catalog-pill-item {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.catalog-pill-item .item-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
}

.catalog-pill-item .item-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.catalog-pill-item .item-price {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-emerald);
  white-space: nowrap;
  background: rgba(16, 185, 129, 0.1);
  padding: 3px 8px;
  border-radius: 4px;
}

/* Right: WhatsApp Simulator Phone Frame (Desktop & Tablet) */
.whatsapp-sim-frame {
  background: #0b141a;
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 28px;
  overflow: hidden;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  height: clamp(580px, 82vh, 730px);
  position: sticky;
  top: 86px;
  z-index: 10;
  transition: all 0.3s ease;
}

/* Smartphone Status Bar (Top Bezel) */
.sim-phone-bar {
  background: #202c33;
  padding: 8px 18px 4px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #8696a0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  user-select: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.sim-phone-notch {
  width: 68px;
  height: 10px;
  background: #000;
  border-radius: 6px;
  opacity: 0.85;
}

.sim-phone-icons {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
}

.phone-icon-net {
  font-size: 0.65rem;
  font-weight: 700;
  color: #aebac1;
}

.whatsapp-sim-header {
  background: #202c33;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sim-avatar-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sim-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  border: 1px solid var(--border-color);
}

.sim-title-group h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: #e9edef;
}

.sim-title-group p {
  font-size: 0.72rem;
  color: #8696a0;
  display: flex;
  align-items: center;
  gap: 5px;
}

.sim-title-group p .online-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #00a884;
}

.whatsapp-sim-messages {
  flex: 1;
  background-color: #0b141a;
  background-image: radial-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 0);
  background-size: 20px 20px;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sim-bubble {
  max-width: 80%;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  line-height: 1.4;
  position: relative;
  word-break: break-word;
}

.sim-bubble.agent {
  align-self: flex-start;
  background: #202c33;
  color: #e9edef;
  border-top-left-radius: 2px;
}

.sim-bubble.customer {
  align-self: flex-end;
  background: #005c4b;
  color: #e9edef;
  border-top-right-radius: 2px;
}

.sim-bubble .bubble-time {
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.45);
  text-align: right;
  margin-top: 4px;
}

.sim-typing-bubble {
  align-self: flex-start;
  background: #202c33;
  padding: 8px 14px;
  border-radius: 8px;
  border-top-left-radius: 2px;
  display: none;
  align-items: center;
  gap: 4px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: #8696a0;
  border-radius: 50%;
  animation: typingBounce 1.2s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

.sim-rec-pulse {
  animation: simRecPulse 0.9s infinite alternate ease-in-out;
}
@keyframes simRecPulse {
  0% { transform: scale(0.95); opacity: 0.7; }
  100% { transform: scale(1.15); opacity: 1; }
}

.sim-vbar.played {
  background: #53bdeb !important;
}

.sim-vbar.animating {
  animation: simWaveBounce 0.5s infinite ease-in-out alternate;
}
@keyframes simWaveBounce {
  0% { transform: scaleY(0.35); }
  100% { transform: scaleY(1.35); }
}

.quick-prompts-tray {
  padding: 8px 12px;
  background: #111b21;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.prompt-chip {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #8696a0;
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 0.75rem;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s;
}

/* ========== LIGHT THEME STYLING FOR SIMULATOR ========== */
[data-theme="light"] .whatsapp-sim-frame {
  background: #ffffff;
  border: 2px solid #e2e8f0;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .whatsapp-sim-messages {
  background-color: #f8fafc;
  background-image: radial-gradient(#e2e8f0 1px, transparent 0);
  color: var(--text-primary);
}

[data-theme="light"] .sim-bubble.agent {
  background: #ecfdf5;
  color: #0f172a;
  border-top-left-radius: 4px;
}

[data-theme="light"] .sim-bubble.customer {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  border-top-right-radius: 4px;
}

[data-theme="light"] .sim-bubble .bubble-time {
  color: rgba(15, 23, 42, 0.45);
}

[data-theme="light"] .sim-typing-bubble {
  background: #f8fafc;
  color: var(--text-primary);
}

[data-theme="light"] .typing-dot {
  background: var(--text-muted);
}

[data-theme="light"] .quick-prompts-tray {
  background: #f1f5f9;
  border-top: 1px solid #e2e8f0;
}

[data-theme="light"] .prompt-chip {
  background: rgba(239, 246, 255, 0.5);
  border: 1px solid rgba(10, 185, 129, 0.3);
  color: #0f172a;
}

[data-theme="light"] .prompt-chip:hover {
  background: rgba(16, 185, 129, 0.15);
}

[data-theme="light"] .sim-title-group p .online-dot {
  background: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.3);
}

[data-theme="light"] .sim-phone-bar {
  background: #f1f5f9;
  color: #475569;
  border-bottom: 1px solid #e2e8f0;
}

/* Light theme WhatsApp Simulator Header and Avatar */
[data-theme="light"] .whatsapp-sim-header {
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  padding: 12px 16px;
}

[data-theme="light"] .sim-avatar {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
}

[data-theme="light"] .sim-title-group h4 {
  color: var(--text-primary);
}

[data-theme="light"] .sim-title-group p {
  color: var(--text-secondary);
}

[data-theme="light"] .sim-avatar-wrapper {
  background: transparent;
}

/* ========== DARK THEME OVERRIDES FOR SIMULATOR ========== */
/* Base dark theme styles for simulator elements */
[data-theme="dark"] .sim-title-group h4 {
  color: #f1f5f9;
}

[data-theme="dark"] .sim-title-group p {
  color: #94a3b8;
}

[data-theme="dark"] .prompt-chip {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #8696a0;
}

[data-theme="dark"] .whatsapp-sim-footer {
  background: #111b21;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .whatsapp-sim-footer input {
  flex: 1;
  background: #2a3942;
  border: none;
  border-radius: 8px;
  color: #d1d7db;
  padding: 9px 14px;
  font-size: 0.85rem;
  outline: none;
}

[data-theme="dark"] .whatsapp-sim-footer input::placeholder {
  color: #8696a0;
}

[data-theme="dark"] .btn-send-sim {
  background: #00a884;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

[data-theme="dark"] .btn-send-sim:hover {
  background: #029474;
}

/* Light theme btn-xs hover state */
[data-theme="light"] .btn-xs:hover {
  background: rgba(255, 255, 255, 0.8);
}

/* ========== LIGHT THEME PHONE STATUS BAR ========== */
[data-theme="light"] .sim-phone-notch {
  background: #d1d5db;
}

[data-theme="light"] .phone-icon-net {
  color: #475569;
}

[data-theme="light"] .sim-phone-icons {
  color: #475569;
}

/* ========== LIGHT THEME STYLING FOR CATALOG PILLS ========== */
[data-theme="light"] .catalog-pill-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

[data-theme="light"] .catalog-pill-item .item-title {
  color: #0f172a;
}

[data-theme="light"] .catalog-pill-item .item-desc {
  color: #647489;
}

[data-theme="light"] .catalog-pill-item .item-price {
  background: rgba(16, 185, 129, 0.1);
  color: #064e3b;
}

/* Dark theme catalog pill item styling - ensure visibility on dark background */
[data-theme="dark"] .catalog-pill-item {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

[data-theme="dark"] .catalog-pill-item .item-title {
  color: #f1f5f9;
}

[data-theme="dark"] .catalog-pill-item .item-desc {
  color: #cbd5e1;
}

[data-theme="dark"] .catalog-pill-item .item-price {
  background: rgba(16, 185, 129, 0.25);
  color: #ffffff;
}

/* Light theme prompt chip hover state */
[data-theme="light"] .prompt-chip:hover {
  background: rgba(16, 185, 129, 0.15);
  border-color: #10b981;
  color: #064e3b;
}

/* ========== LIGHT THEME SIMULATOR FOOTER ========== */
[data-theme="light"] .whatsapp-sim-footer {
  background: #f8fafc;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid #e2e8f0;
}

[data-theme="light"] .whatsapp-sim-footer input {
  flex: 1;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  color: #0f172a;
  padding: 9px 14px;
  font-size: 0.85rem;
  outline: none;
}

[data-theme="light"] .whatsapp-sim-footer input:focus {
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

[data-theme="light"] .whatsapp-sim-footer input::placeholder {
  color: #94a3b8;
}

[data-theme="light"] .btn-send-sim {
  background: var(--accent-emerald);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  flex-shrink: 0;
}

[data-theme="light"] .btn-send-sim:hover {
  background: #059669;
}

[data-theme="light"] .btn-send-sim:active {
  transform: scale(0.95);
}

/* Dark theme prompt chip hover state */
.prompt-chip:hover {
  background: rgba(0, 168, 132, 0.15);
  border-color: #00a884;
  color: #00a884;
}

/* =========================================================================
   MOBILE & TABLET RESPONSIVE DESIGN SYSTEM
   ========================================================================= */

/* Medium Laptops & Landscape Tablets (<= 1150px) */
@media (max-width: 1150px) {
  .sandbox-container {
    grid-template-columns: minmax(0, 1fr) 390px;
    gap: 20px;
  }

  .crm-layout {
    grid-template-columns: 300px 1fr;
  }
}

/* Tablet Portrait & Smaller Devices (<= 960px) */
@media (max-width: 960px) {
  .sandbox-container {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .whatsapp-sim-frame {
    order: -1; /* Simulator on top so user can chat immediately on mobile */
    position: static;
    max-width: 480px;
    width: 100%;
    margin: 0 auto;
    height: clamp(500px, 72vh, 600px);
    border-radius: 20px;
  }

  .sim-phone-bar {
    border-radius: 20px 20px 0 0;
  }

  .crm-layout {
    grid-template-columns: 280px 1fr;
    height: 600px;
  }
}

/* Standard Mobile Devices (<= 768px) */
@media (max-width: 768px) {
  /* Header */
  .app-header {
    height: 58px;
    padding: 0 14px;
  }

  .logo-badge {
    width: 32px;
    height: 32px;
    font-size: 0.95rem;
    border-radius: 8px;
  }

  .brand-name {
    font-size: 1.05rem;
  }

  .header-right {
    gap: 8px;
  }

  .connection-pill {
    padding: 4px 8px;
    font-size: 0.72rem;
    gap: 5px;
  }

  #logoutBtn {
    padding: 5px 10px;
    font-size: 0.75rem;
  }

  /* Navigation Tabs: Horizontal touch scrollable */
  .portal-nav {
    padding: 8px 12px 0 12px;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 6px;
  }

  .portal-nav::-webkit-scrollbar {
    display: none;
  }

  .nav-tab {
    padding: 8px 14px;
    font-size: 0.8rem;
    flex-shrink: 0;
    white-space: nowrap;
    border-radius: 6px 6px 0 0;
    gap: 6px;
  }

  /* Trial & Subscription Banner */
  #trialBanner {
    padding: 10px 14px !important;
    flex-direction: column !important;
    gap: 10px !important;
    align-items: stretch !important;
    text-align: center;
  }

  #trialBanner > div:first-child {
    justify-content: center;
  }

  #openUpgradeModalBtn {
    width: 100% !important;
    justify-content: center;
    padding: 8px 14px !important;
    font-size: 0.82rem !important;
  }

  /* Main Container */
  .portal-main {
    padding: 14px 10px;
  }

  /* Cards */
  .card {
    padding: 16px 14px;
    border-radius: 12px;
    margin-bottom: 16px;
  }

  .card-title {
    font-size: 1.05rem;
    gap: 8px;
    flex-wrap: wrap;
  }

  .card-subtitle {
    font-size: 0.8rem;
    margin-bottom: 14px;
    line-height: 1.45;
  }

  /* Persona Selector Grid: Compact 2-column mobile layout */
  .persona-selector-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 16px;
  }

  .persona-select-card {
    padding: 10px 8px;
    border-radius: 8px;
  }

  .persona-select-card .card-icon {
    font-size: 1.4rem;
    margin-bottom: 4px;
  }

  .persona-select-card .card-title {
    font-size: 0.82rem;
    font-weight: 700;
  }

  .persona-select-card .card-tagline {
    font-size: 0.68rem;
    line-height: 1.25;
  }

  /* Sandbox Actions Row */
  .sandbox-header-row {
    flex-direction: column !important;
    gap: 12px !important;
  }

  .sandbox-header-actions {
    width: 100% !important;
    flex-direction: column !important;
    gap: 8px !important;
  }

  .sandbox-header-actions button {
    width: 100% !important;
    justify-content: center;
  }

  #applyPersonaBtn {
    order: 1;
    padding: 12px !important;
    font-size: 0.92rem !important;
  }

  #editPersonaBtn {
    order: 2;
    padding: 10px !important;
    font-size: 0.85rem !important;
  }

  /* WhatsApp Simulator Frame on Mobile */
  .whatsapp-sim-frame {
    order: -1;
    position: static;
    max-width: 100%;
    height: clamp(480px, 72vh, 580px);
    border-radius: 16px;
  }

  .sim-phone-bar {
    border-radius: 16px 16px 0 0;
    padding: 6px 12px;
  }

  .whatsapp-sim-header {
    padding: 10px 12px;
  }

  .sim-avatar {
    width: 36px;
    height: 36px;
    font-size: 1.15rem;
  }

  .sim-title-group h4 {
    font-size: 0.88rem;
  }

  .sim-title-group p {
    font-size: 0.68rem;
  }

  #simResetBtn {
    padding: 4px 8px;
    font-size: 0.72rem;
  }

  .whatsapp-sim-messages {
    padding: 12px 8px;
    gap: 8px;
  }

  .sim-bubble {
    max-width: 88%;
    padding: 8px 11px;
    font-size: 0.85rem;
    line-height: 1.35;
  }

  .sim-bubble .bubble-time {
    font-size: 0.62rem;
  }

  /* Quick Prompt Chips */
  .quick-prompts-tray {
    padding: 6px 8px;
    gap: 6px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .quick-prompts-tray::-webkit-scrollbar {
    display: none;
  }

  .prompt-chip {
    padding: 6px 11px;
    font-size: 0.74rem;
    border-radius: 14px;
    min-height: 30px;
    display: inline-flex;
    align-items: center;
    touch-action: manipulation;
  }

  /* Chat Input on Mobile: 16px to prevent iOS auto-zoom */
  .whatsapp-sim-footer {
    padding: 8px;
    gap: 6px;
  }

  .whatsapp-sim-footer input {
    font-size: 16px !important;
    padding: 10px 14px;
    border-radius: 20px;
  }

  .btn-send-sim {
    width: 40px;
    height: 40px;
    min-width: 40px;
  }

  /* Sandbox Blueprint Details */
  .sandbox-details-panel {
    padding: 16px 14px;
    gap: 16px;
    border-radius: 14px;
  }

  #sbDetailName {
    font-size: 1.05rem;
  }

  #sbDetailDesc {
    font-size: 0.78rem;
    line-height: 1.45;
  }

  .catalog-pill-item {
    padding: 8px 10px;
  }

  .catalog-pill-item .item-title {
    font-size: 0.8rem;
  }

  .catalog-pill-item .item-price {
    font-size: 0.8rem;
    padding: 2px 6px;
  }

  #applyPersonaBtn2 {
    padding: 12px;
    font-size: 0.92rem;
  }

  /* Modals on Mobile */
  .auth-overlay {
    padding: 16px 12px calc(32px + env(safe-area-inset-bottom)) !important;
    align-items: flex-start !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .auth-card {
    margin: auto 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 24px 16px !important;
    border-radius: 16px;
  }

  #personaEditorModal .auth-card {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 95vh !important;
    border-radius: 16px;
  }

  #personaEditorModal .auth-card > div:first-child {
    padding: 14px 16px !important;
  }

  #personaEditorModal .auth-card > div:nth-child(2) {
    padding: 14px !important;
    gap: 14px !important;
  }

  #personaEditorModal div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  #personaEditorModal .auth-card > div:last-child {
    padding: 12px 14px !important;
    flex-direction: column !important;
    gap: 8px !important;
    align-items: stretch !important;
  }

  #personaEditorModal .auth-card > div:last-child > div {
    flex-direction: column !important;
    gap: 8px !important;
    width: 100% !important;
  }

  #personaEditorModal .auth-card button {
    width: 100% !important;
    justify-content: center;
  }

  #edSaveToLiveBotBtn {
    padding: 12px !important;
    font-size: 0.88rem !important;
  }

  #upgradeModal .auth-card {
    padding: 20px 14px !important;
  }

  #upgradeModal div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Tab 1 Pairing State */
  #whatsappPairingView > div:first-child {
    flex-direction: column !important;
    gap: 14px !important;
    align-items: stretch !important;
  }

  #whatsappPairingView button {
    width: 100% !important;
    justify-content: center;
  }

  .qr-image {
    width: 200px;
    height: 200px;
  }

  /* Tab 2 Matrix Setup */
  #matrixTemplateButtons {
    gap: 6px !important;
  }

  #matrixTemplateButtons button {
    flex-grow: 1;
    text-align: center;
    justify-content: center;
  }

  #tab-matrix .card > div:first-child {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }

  #tab-matrix .card button {
    width: 100% !important;
    justify-content: center;
  }

  /* Tab 3 Controls */
  #tab-controls div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* Tab 4 CRM & Live Inbox on Mobile */
  .crm-layout {
    grid-template-columns: 1fr;
    height: clamp(540px, calc(100vh - 120px), 780px);
    position: relative;
    overflow: hidden;
  }

  .crm-sidebar {
    height: 100%;
    max-height: 100%;
    min-height: 0;
    border-right: none;
    border-bottom: none;
    display: flex;
    flex-direction: column;
  }

  .crm-chat {
    height: 100%;
    max-height: 100%;
    min-height: 0;
    display: none;
  }

  /* When customer or appointment is tapped on mobile, switch panel */
  .crm-layout.crm-mobile-chat-active .crm-sidebar {
    display: none !important;
  }

  .crm-layout.crm-mobile-chat-active .crm-chat.active-panel {
    display: flex !important;
  }

  .crm-mobile-back-btn {
    display: inline-flex !important;
  }

  .crm-chat-header {
    padding: 12px 14px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .crm-chat-input {
    padding: 10px 12px;
  }

  .crm-chat-input input {
    font-size: 16px !important;
  }

  /* Tab 5 Collective Intelligence */
  #tab-shared-brain div[style*="repeat(3, 1fr)"] {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  /* Tab 6 Super Admin */
  .admin-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .admin-kpi-card {
    padding: 14px;
  }

  .kpi-value {
    font-size: 1.5rem;
  }

  .admin-log-console {
    height: 260px;
    font-size: 0.72rem;
    padding: 10px;
  }
}

/* Extra Small Phones (<= 480px) */
@media (max-width: 480px) {
  #statusText {
    display: none;
  }

  .connection-pill {
    padding: 4px 6px;
  }

  .persona-selector-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .persona-select-card {
    padding: 8px 6px;
  }

  .persona-select-card .card-icon {
    font-size: 1.2rem;
  }

  .persona-select-card .card-title {
    font-size: 0.78rem;
  }

  .admin-kpi-grid {
    grid-template-columns: 1fr;
  }
}

/* =========================================================
   NEW REDESIGNED DASHBOARD LAYOUT (STUDENT DASHBOARD STYLE)
   - Left vertical navigation sidebar
   - Topbar with Light / Dark Theme toggle
   - Overview Tab with Top Personas Carousel (Clients Style)
   - KPI Stat Cards & Active Conversations List
   ========================================================= */

.portal-app-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  position: relative;
}

/* Left Sidebar */
.portal-sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 45;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 2px 0 16px rgba(0, 0, 0, 0.02);
}

.sidebar-brand {
  height: 72px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-color);
  text-decoration: none;
}

.sidebar-brand .logo-badge {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-emerald), var(--accent-cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.15rem;
  color: #fff;
  box-shadow: 0 4px 14px var(--accent-emerald-glow);
  flex-shrink: 0;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
}

.sidebar-brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.4px;
  color: var(--text-primary);
  line-height: 1.2;
}

.sidebar-brand-title span {
  color: var(--accent-emerald);
}

.sidebar-brand-sub {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar-nav-container {
  flex: 1;
  padding: 20px 12px;
  overflow-y: auto;
}

.sidebar-nav-title {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  padding: 0 12px 10px 12px;
  text-transform: uppercase;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-nav .nav-tab {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border-bottom: none;
  position: relative;
}

.sidebar-nav .nav-tab .nav-tab-icon {
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  flex-shrink: 0;
}

.sidebar-nav .nav-tab .nav-tab-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav .nav-tab:hover {
  color: var(--text-primary);
  background: rgba(16, 185, 129, 0.08);
  transform: translateX(2px);
}

.sidebar-nav .nav-tab.active {
  color: #ffffff !important;
  background: var(--accent-emerald) !important;
  box-shadow: 0 4px 14px var(--accent-emerald-glow) !important;
  font-weight: 700;
}

.sidebar-nav .nav-tab.active .nav-tab-label {
  color: #ffffff;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.sidebar-user-card {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.sidebar-user-info {
  min-width: 0;
  flex: 1;
}

.sidebar-user-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Body Content Wrapper */
.portal-body-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-y: auto;
  height: 100vh;
}

/* App Topbar */
.app-topbar {
  min-height: 72px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 32px;
  position: sticky;
  top: 0;
  z-index: 2500 !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
}

.topbar-left {
  display: flex;
  flex-direction: column;
}

.topbar-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.topbar-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Theme Toggle Button */
.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s ease;
  user-select: none;
}

.theme-toggle-btn:hover {
  border-color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.1);
  transform: translateY(-1px);
}

.theme-toggle-btn .theme-icon {
  font-size: 1rem;
}

/* =========================================================
   OVERVIEW TAB: TOP PERSONAS ROW (MATCHING REFERENCE IMAGE)
   ========================================================= */

.overview-personas-section {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-card);
}

.personas-section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 12px;
}

.personas-section-header .title-area h2 {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 3px;
  letter-spacing: -0.2px;
}

.personas-section-header .title-area p {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.personas-cards-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 16px;
}

.persona-top-card {
  border-radius: var(--radius-lg);
  padding: 18px 14px 14px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  border: 2px solid transparent;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.03);
}

.persona-top-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
}

.persona-top-card.active {
  border-color: var(--accent-emerald) !important;
  box-shadow: 0 8px 24px -2px rgba(16, 185, 129, 0.3) !important;
}

.persona-active-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--accent-emerald);
  color: #fff;
  border-radius: 10px;
  padding: 2px 7px;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.4);
}

.persona-avatar-wrap {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  overflow: hidden;
  margin-bottom: 10px;
  border: 3px solid #ffffff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  position: relative;
  flex-shrink: 0;
}

.persona-avatar-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.persona-card-name {
  font-size: 0.95rem;
  font-weight: 800;
  color: #1e293b;
  margin-bottom: 2px;
}

[data-theme="dark"] .persona-card-name {
  color: #0f172a; /* keep crisp dark text on pastel card */
}

.persona-card-role {
  font-size: 0.72rem;
  color: #475569;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 12px;
  min-height: 28px;
}

.persona-card-actions {
  display: flex;
  gap: 6px;
  width: 100%;
  margin-top: auto;
}

.persona-card-actions button {
  padding: 6px 8px;
  font-size: 0.75rem;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.btn-select-persona {
  flex: 1;
  background: #ffffff;
  color: #1e293b;
  border: 1px solid rgba(0, 0, 0, 0.12) !important;
}

.btn-select-persona:hover {
  background: #f8fafc;
}

.persona-top-card.active .btn-select-persona {
  background: var(--accent-emerald) !important;
  color: #ffffff !important;
  border-color: var(--accent-emerald) !important;
}

.btn-edit-persona {
  background: rgba(255, 255, 255, 0.85);
  color: #334155;
  border: 1px solid rgba(0, 0, 0, 0.08) !important;
}

.btn-edit-persona:hover {
  background: #ffffff;
  color: #0f172a;
}

/* Add Custom Persona Card */
.persona-add-card {
  border-radius: var(--radius-lg);
  padding: 20px 14px;
  border: 2px dashed var(--border-color);
  background: rgba(255, 255, 255, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s ease;
  min-height: 195px;
}

[data-theme="dark"] .persona-add-card {
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(255, 255, 255, 0.12);
}

.persona-add-card:hover {
  border-color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.05);
  transform: translateY(-4px);
}

.persona-add-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent-emerald);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 10px;
  font-weight: 700;
}

.persona-add-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.persona-add-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* =========================================================
   OVERVIEW TAB: KPI METRIC CARDS
   ========================================================= */

.overview-kpis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-card);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kpi-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px -4px rgba(0, 0, 0, 0.08);
}

.kpi-icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.kpi-body {
  min-width: 0;
}

.kpi-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.kpi-value {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
  margin: 2px 0;
}

.kpi-subtext {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.kpi-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 700;
}

.kpi-badge.positive {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.kpi-badge.warm {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.kpi-badge.neutral {
  background: rgba(2, 132, 199, 0.15);
  color: #0284c7;
}

/* =========================================================
   OVERVIEW TAB: ACTIVE CONVERSATIONS & CONTROLS
   ========================================================= */

.overview-conv-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
}

.overview-conv-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.overview-conv-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  gap: 14px;
}

.overview-conv-item:hover {
  border-color: rgba(16, 185, 129, 0.4);
  background: var(--bg-card);
  box-shadow: var(--shadow-card);
  transform: translateY(-1px);
}

.conv-item-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  flex: 1;
}

.conv-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10b981, #06b6d4);
  color: #ffffff;
  font-weight: 800;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.conv-meta {
  min-width: 0;
  flex: 1;
}

.conv-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.conv-phone {
  font-size: 0.92rem;
  font-weight: 750;
  color: var(--text-primary);
}

.conv-lead-tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.conv-last-msg {
  font-size: 0.82rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 500px;
  margin-top: 3px;
}

.conv-time {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.conv-item-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.btn-conv-pause {
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.btn-conv-pause:hover {
  border-color: var(--warning);
  color: var(--warning);
}

.btn-conv-pause.paused {
  background: rgba(245, 158, 11, 0.12);
  border-color: var(--warning);
  color: var(--warning);
}

.btn-conv-open {
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 8px;
  background: var(--accent-emerald);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 8px var(--accent-emerald-glow);
}

.btn-conv-open:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

/* =========================================================
   CUSTOM PERSONA MODAL & FORM STYLES
   ========================================================= */

.modal-dialog-custom {
  background: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3) !important;
}

.avatar-selection-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(85px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.avatar-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 4px;
  border: 2px solid var(--border-color);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-tertiary);
}

.avatar-option:hover {
  border-color: var(--accent-emerald);
}

.avatar-option input[type="radio"] {
  display: none;
}

.avatar-option img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid transparent;
}

.avatar-option input[type="radio"]:checked + img {
  border-color: var(--accent-emerald);
  box-shadow: 0 0 10px var(--accent-emerald-glow);
}

.avatar-option:has(input[type="radio"]:checked) {
  border-color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.08);
}

.avatar-name {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Products in Custom Persona */
.custom-products-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.product-edit-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 3fr auto;
  gap: 8px;
  align-items: center;
  background: var(--bg-tertiary);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.product-edit-row input {
  padding: 6px 10px;
  font-size: 0.8rem;
}

.btn-remove-row {
  background: transparent;
  color: var(--danger);
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px;
}

/* Responsive Overrides */
@media (max-width: 900px) {
  .portal-app-layout {
    flex-direction: column;
  }

  .portal-sidebar {
    width: 100%;
    height: auto;
    position: relative;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }

  .sidebar-nav {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 6px;
  }

  .sidebar-nav .nav-tab {
    width: auto;
    padding: 8px 12px;
  }

  .sidebar-footer {
    display: none;
  }

  .portal-body-wrapper {
    height: auto;
  }

  .product-edit-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}

/* ==========================================
   WhatsApp Native Location & Media Simulator Bubbles
   ========================================== */

.sim-bubble.wa-location-bubble {
  padding: 4px;
  max-width: 90% !important;
  background: #202c33;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.sim-bubble.wa-media-bubble {
  padding: 4px;
  max-width: 85% !important;
  background: #202c33;
  border-radius: 8px;
  overflow: hidden;
}

.wa-map-preview {
  position: relative;
  height: 120px;
  border-radius: 6px 6px 4px 4px;
  overflow: hidden;
  background: linear-gradient(135deg, #1f2937 0%, #111827 50%, #0f172a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.wa-map-grid {
  position: absolute;
  inset: 0;
  background-image: 
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 24px 24px;
}

.wa-map-road-1 {
  position: absolute;
  height: 6px;
  width: 140%;
  background: rgba(255, 214, 10, 0.35);
  transform: rotate(-18deg);
  top: 45%;
  left: -20%;
  border-top: 1px solid rgba(255, 214, 10, 0.5);
  border-bottom: 1px solid rgba(255, 214, 10, 0.5);
}

.wa-map-road-2 {
  position: absolute;
  width: 6px;
  height: 140%;
  background: rgba(255, 255, 255, 0.2);
  transform: rotate(35deg);
  left: 55%;
  top: -20%;
}

.wa-map-marker {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.wa-map-pulse {
  position: absolute;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.35);
  animation: waMapPulse 2s infinite ease-out;
}

@keyframes waMapPulse {
  0% { transform: scale(0.6); opacity: 1; }
  100% { transform: scale(2.2); opacity: 0; }
}

.wa-map-pin-icon {
  width: 26px;
  height: 26px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
}

.wa-location-details {
  padding: 8px 8px 4px 8px;
}

.wa-location-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.3;
}

.wa-location-address {
  font-size: 0.75rem;
  color: #cfd9df;
  margin-top: 2px;
  line-height: 1.35;
}

.wa-tenant-confirmation-notice {
  margin-top: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px dashed rgba(16, 185, 129, 0.35);
  font-size: 0.72rem;
  color: #10b981;
  line-height: 1.35;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* =========================================================
   REAL-TIME NOTIFICATION POPUPS & OVERVIEW ALERTS
   ========================================================= */

/* Floating Toast Container in Overview / Dashboard */
.portal-toast-container {
  position: fixed;
  top: 24px;
  right: 28px;
  z-index: 999999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}

.portal-toast-popup {
  pointer-events: auto;
  width: 380px;
  max-width: 90vw;
  background: rgba(17, 24, 39, 0.96);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55), 0 0 1px rgba(255, 255, 255, 0.1);
  animation: toastSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.portal-toast-popup.fade-out {
  opacity: 0;
  transform: translateX(40px);
}

@keyframes toastSlideIn {
  0% { opacity: 0; transform: translateX(50px) scale(0.96); }
  100% { opacity: 1; transform: translateX(0) scale(1); }
}

/* Specific Alert Type Accents */
.portal-toast-confirm {
  border-left: 4px solid #8B5CF6;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.12), rgba(17, 24, 39, 0.98));
}

.portal-toast-urgent {
  border-left: 4px solid #F59E0B;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), rgba(17, 24, 39, 0.98));
}

.portal-toast-appt {
  border-left: 4px solid #10B981;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(17, 24, 39, 0.98));
}

.portal-toast-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.portal-toast-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.portal-toast-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  transition: color 0.15s ease;
}

.portal-toast-close:hover {
  color: #fff;
}

.portal-toast-body {
  margin: 6px 0 10px 0;
}

.portal-toast-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #ffffff !important;
  margin-bottom: 2px;
}

.portal-toast-desc {
  font-size: 0.8rem;
  color: #cbd5e1 !important;
  line-height: 1.4;
}

.portal-toast-time {
  font-size: 0.74rem;
  color: var(--accent-cyan);
  margin-top: 4px;
}

.portal-toast-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* Notification Bell Button */
.topbar-alerts-btn {
  position: relative;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 6px 12px;
  color: var(--text-primary);
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.topbar-alerts-btn:hover {
  border-color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.1);
}

.alerts-count-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #EF4444;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 10px;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
  animation: pulseAlert 2s infinite;
}

@keyframes pulseAlert {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* Overview Alerts Section */
.overview-alerts-section {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.05), rgba(139, 92, 246, 0.05));
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-md);
  padding: 18px 20px;
}

.overview-alerts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.overview-alert-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 14px;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.overview-alert-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-cyan);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

/* =========================================================
   MOBILE & WEB RESPONSIVE ADAPTATION (UI/UX PRO MAX)
   - Off-canvas sidebar drawer with backdrop blur
   - Thumb-friendly bottom navigation bar
   - WhatsApp-style CRM conversation switch on small screens
   - Full touch target sizing & iOS zoom prevention
   ========================================================= */

/* Desktop defaults for mobile-only elements */
.portal-sidebar-toggle-btn {
  display: none;
}

/* --------------------------------------------------------------------------
   RTL (Right-to-Left) Support for Arabic/Moroccan Content
-------------------------------------------------------------------------- */
html[dir="rtl"], [dir="rtl"] html {
  direction: rtl;
  text-align: right;
}

[dir="rtl"] body {
  font-family: 'Times New Roman', 'Arial Unicode MS', sans-serif;
}

/* RTL sidebar adjustments */
[dir="rtl"] .portal-sidebar {
  left: 0;
  right: auto;
}

/* RTL navigation tabs */
[dir="rtl"] .portal-nav {
  flex-direction: row-reverse;
}

[dir="rtl"] .nav-tab {
  margin-right: 0;
  margin-left: 6px;
}

/* RTL CRM table adjustments */
[dir="rtl"] .crm-table th,
[dir="rtl"] .crm-table td {
  text-align: right;
}

/* RTL form adjustments */
[dir="rtl"] .form-label {
  margin-left: 0;
  margin-right: 8px;
}

/* RTL mobile back button */
[dir="rtl"] .crm-mobile-back-btn {
  margin-right: 0;
  margin-left: 12px;
}

.sidebar-close-btn {
  display: none;
}

.sidebar-brand-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.portal-sidebar-backdrop {
  display: none;
}

.portal-mobile-bottom-nav {
  display: none;
}

.crm-mobile-back-btn {
  display: none;
}

/* Tablet & Mobile Breakpoint (<= 991px) */
@media (max-width: 991px) {
  .portal-app-layout {
    display: block;
    width: 100%;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
  }

  /* Off-canvas sidebar drawer */
  .portal-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    height: 100vh;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
    border-right: 1px solid var(--border-color);
  }

  .portal-sidebar.open {
    transform: translateX(0);
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.5);
  }

  /* Backdrop Overlay: Strictly display: none when inactive so it NEVER blocks clicks */
  .portal-sidebar-backdrop {
    display: none !important;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 998;
    opacity: 0;
    pointer-events: none !important;
    transition: opacity 0.25s ease;
  }

  .portal-sidebar-backdrop.active {
    display: block !important;
    opacity: 1;
    pointer-events: auto !important;
  }

  /* Hamburger toggle button */
  .portal-sidebar-toggle-btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    width: 38px;
    height: 38px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    padding: 6px;
    flex-shrink: 0;
    transition: all 0.2s ease;
  }

  .portal-sidebar-toggle-btn:hover {
    border-color: var(--accent-emerald);
    background: rgba(16, 185, 129, 0.1);
  }

  .portal-sidebar-toggle-btn .hamburger-bar {
    width: 20px;
    height: 2px;
    background-color: var(--text-primary);
    border-radius: 2px;
    transition: transform 0.2s ease;
  }

  /* Drawer Close button */
  .sidebar-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.1rem;
    margin-right: 14px;
    transition: all 0.15s ease;
  }

  .sidebar-close-btn:hover {
    color: #fff;
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--danger);
  }

  /* Main body wrapper with bottom nav clearance */
  .portal-body-wrapper {
    height: auto;
    min-height: 100vh;
    padding-bottom: 76px;
    overflow-x: hidden;
  }

  /* Compact Topbar */
  .app-topbar {
    padding: 10px 16px;
    min-height: 60px;
    gap: 10px;
  }

  .topbar-left {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    min-width: 0;
  }

  .topbar-title {
    font-size: 1.05rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .topbar-desc {
    display: none;
  }

  .theme-toggle-btn #themeToggleText {
    display: none;
  }

  .theme-toggle-btn {
    padding: 7px 10px;
  }

  /* Mobile Bottom Navigation Bar */
  .portal-mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 62px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    z-index: 1001;
    padding: 4px 6px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
    justify-content: space-around;
    align-items: center;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }

  .mobile-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    flex: 1;
    min-height: 48px;
    padding: 6px 2px;
    border-radius: 8px;
    transition: all 0.15s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
  }

  .mobile-nav-btn * {
    pointer-events: none;
  }

  .mobile-nav-btn.active {
    color: var(--accent-emerald-dark);
  }

  [data-theme="dark"] .mobile-nav-btn.active {
    color: var(--accent-emerald);
  }

  .mobile-nav-btn.active .mobile-nav-icon {
    transform: translateY(-2px);
  }

  .mobile-nav-icon {
    font-size: 1.25rem;
    transition: transform 0.15s ease;
  }

  .mobile-nav-label {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.02em;
  }
}

/* Smartphone Breakpoint (<= 768px) */
@media (max-width: 768px) {
  /* Prevent iOS Safari 100% zoom trigger on input focus */
  input, select, textarea {
    font-size: 16px !important;
  }

  /* Compact App Topbar to prevent horizontal blowout */
  .app-topbar {
    padding: 8px 12px !important;
    min-height: 54px !important;
    gap: 8px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }

  .topbar-left {
    min-width: 0 !important;
    flex: 1 1 auto !important;
    gap: 8px !important;
  }

  .topbar-title-group {
    min-width: 0 !important;
    overflow: hidden !important;
  }

  .topbar-title {
    font-size: 0.92rem !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  .topbar-right {
    display: flex !important;
    align-items: center !important;
    gap: 5px !important;
    flex-shrink: 0 !important;
  }

  /* Hide secondary desktop buttons from topbar on mobile */
  #startTourBtn,
  #topbarSupportBtn,
  #notifSoundToggle {
    display: none !important;
  }

  /* Compact Language Selector (Flag Icon Only) */
  .lang-dropdown-btn {
    padding: 6px 8px !important;
    min-width: 36px !important;
    min-height: 36px !important;
    border-radius: 8px !important;
    gap: 0 !important;
    justify-content: center !important;
  }

  .lang-dropdown-btn #currentLangLabel,
  .lang-dropdown-btn > svg:not(.flag-svg) {
    display: none !important;
  }

  /* Compact Theme Toggle Button */
  .theme-toggle-btn {
    padding: 6px 8px !important;
    min-width: 36px !important;
    min-height: 36px !important;
    border-radius: 8px !important;
    justify-content: center !important;
  }

  .theme-toggle-btn #themeToggleText {
    display: none !important;
  }

  /* Compact Connection Status Pill */
  .connection-pill {
    padding: 6px 8px !important;
    min-height: 36px !important;
    border-radius: 8px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0 !important;
  }

  .connection-pill #statusText {
    display: none !important;
  }

  /* Compact Logout Button on Mobile Topbar */
  #logoutBtn {
    padding: 6px 8px !important;
    min-width: 36px !important;
    min-height: 36px !important;
    border-radius: 8px !important;
    font-size: 0.75rem !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    white-space: nowrap !important;
  }

  #logoutBtn .logout-text {
    display: none !important;
  }

  /* Mobile Overview KPIs: 2 columns */
  .overview-kpis-grid,
  .overview-kpis {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

  .kpi-stat-card {
    padding: 14px 12px !important;
  }

  .kpi-value {
    font-size: 1.35rem !important;
  }

  /* Top Personas Row: Horizontal snap scroll */
  .top-personas-track {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 12px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 12px;
  }

  .top-personas-track::-webkit-scrollbar {
    display: none;
  }

  .top-persona-card {
    min-width: 240px;
    max-width: 80vw;
    flex-shrink: 0;
  }

  /* Alerts Grid: Single column */
  .overview-alerts-grid {
    grid-template-columns: 1fr !important;
  }

  /* Mobile CRM WhatsApp-style UX */
  .crm-layout {
    display: block;
    height: calc(100vh - 145px);
    min-height: 520px;
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-md);
  }

  .crm-sidebar {
    width: 100%;
    height: 100%;
    border-right: none;
    display: flex;
    flex-direction: column;
  }

  .crm-chat {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-card);
    z-index: 10;
    display: none !important;
    flex-direction: column;
  }

  /* When customer or appointment is open, expand chat full-screen */
  .crm-layout.crm-mobile-chat-active .crm-chat.active-panel {
    display: flex !important;
  }

  .crm-layout.crm-mobile-chat-active .crm-sidebar {
    display: none !important;
  }

  .crm-mobile-back-btn {
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 7px 12px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
    touch-action: manipulation;
  }

  .crm-mobile-back-btn:hover {
    background: var(--accent-emerald-light);
    color: var(--accent-emerald-dark);
    border-color: var(--accent-emerald);
  }

  .crm-chat-header {
    padding: 10px 12px;
    gap: 8px;
    flex-wrap: wrap;
  }

  .crm-chat-header #crmChatHeaderPhone {
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .crm-chat-header .btn {
    padding: 6px 9px !important;
    font-size: 0.74rem !important;
  }

  /* Billing Toggle Responsive Sizing */
  #tabBillingCycleMonthlyBtn,
  #tabBillingCycleYearlyBtn {
    padding: 6px 12px !important;
    font-size: 0.78rem !important;
  }

  /* Modal cards containment */
  .auth-card {
    padding: 20px 14px !important;
    max-width: calc(100vw - 20px) !important;
  }

  .portal-toast-container {
    top: 14px !important;
    right: 14px !important;
    left: 14px !important;
  }

  .portal-toast-popup {
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* Ultra-compact Smartphone Breakpoint (<= 480px) */
@media (max-width: 480px) {
  .overview-kpis-grid,
  .overview-kpis {
    grid-template-columns: 1fr !important;
  }

  .connection-pill #statusText {
    display: none !important;
  }

  .connection-pill {
    padding: 6px 8px !important;
  }

  #logoutBtn {
    padding: 6px 8px !important;
    font-size: 0.75rem !important;
  }

  #tabBillingCycleMonthlyBtn,
  #tabBillingCycleYearlyBtn {
    padding: 5px 8px !important;
    font-size: 0.72rem !important;
  }
}

/* ==========================================================================
   INTERACTIVE DASHBOARD ANALYTICS & CONVERSION CHARTS
   ========================================================================== */

.overview-analytics-section {
  position: relative;
  z-index: 1;
}

.analytics-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

@media (max-width: 992px) {
  .analytics-grid {
    grid-template-columns: 1fr !important;
  }
}

.chart-range-pills .range-btn {
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.chart-range-pills .range-btn:hover:not(.active) {
  background: rgba(15, 23, 42, 0.05) !important;
  color: var(--text-primary) !important;
}

.funnel-legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
  border-radius: 6px;
  background: var(--bg-base);
}

.funnel-legend-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-weight: 500;
}

.funnel-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.funnel-legend-count {
  font-weight: 700;
  color: var(--text-primary);
}

/* ==========================================================================
   GUIDED ONBOARDING TOUR & SPOTLIGHT OVERLAY
   ========================================================================== */

.portal-tour-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

.tour-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.tour-card {
  position: relative;
  z-index: 10002;
  background: var(--bg-surface, #ffffff);
  color: var(--text-primary, #0f172a);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.18), 0 0 0 1px rgba(16, 185, 129, 0.25);
  padding: 24px;
  max-width: 440px;
  width: 90%;
  animation: tourCardPop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes tourCardPop {
  0% { transform: scale(0.92); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.tour-spotlight-ring {
  position: absolute;
  z-index: 10001;
  border-radius: 14px;
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.4), 0 0 25px rgba(16, 185, 129, 0.5);
  border: 2px solid var(--accent-emerald, #10b981);
  pointer-events: none;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
   LANGUAGE SWITCHER & RTL SUPPORT (ARABIC)
   ========================================================================== */

.lang-option-btn:hover {
  background: rgba(16, 185, 129, 0.1) !important;
  color: #059669 !important;
}

.lang-option-btn.active {
  background: rgba(16, 185, 129, 0.15) !important;
  color: #059669 !important;
  font-weight: 700 !important;
}

/* RTL Layout Mode for Arabic */
[dir="rtl"] .portal-app-layout {
  flex-direction: row-reverse;
}

[dir="rtl"] .sidebar-brand {
  flex-direction: row-reverse;
  text-align: right;
}

[dir="rtl"] .sidebar-brand-text {
  text-align: right;
}

[dir="rtl"] .nav-tab {
  flex-direction: row-reverse;
  text-align: right;
}

[dir="rtl"] .topbar-left,
[dir="rtl"] .topbar-right {
  flex-direction: row-reverse;
}

[dir="rtl"] .topbar-title-group {
  text-align: right;
}

[dir="rtl"] .lang-dropdown-menu {
  right: auto !important;
  left: 0 !important;
  text-align: right;
}

[dir="rtl"] .lang-option-btn {
  flex-direction: row-reverse;
  text-align: right;
}

[dir="rtl"] .personas-section-header {
  flex-direction: row-reverse;
}

[dir="rtl"] .title-area {
  text-align: right;
}

[dir="rtl"] .kpi-stat-card {
  flex-direction: row-reverse;
  text-align: right;
}

[dir="rtl"] .overview-alerts-header {
  flex-direction: row-reverse;
}

[dir="rtl"] .tour-actions {
  flex-direction: row-reverse;
}

/* ==========================================================================
   Language Dropdown with Real Vector SVG Flags
   ========================================================================== */
.lang-dropdown-btn {
  transition: all 0.2s ease;
  min-height: 34px;
}

.lang-dropdown-btn:hover {
  border-color: var(--accent-emerald) !important;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.15);
}

.lang-dropdown-menu {
  background: var(--bg-surface, #ffffff);
  border: 1px solid var(--border-color);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 99999 !important;
}

.lang-dropdown-container.open .lang-dropdown-menu {
  display: block !important;
}

.lang-option-btn {
  transition: background 0.15s ease, color 0.15s ease;
}

.lang-option-btn:hover {
  background: rgba(16, 185, 129, 0.12) !important;
  color: var(--accent-emerald) !important;
}

.lang-option-btn.active {
  background: rgba(16, 185, 129, 0.18) !important;
  color: var(--accent-emerald) !important;
}

.flag-svg {
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   Persona Intelligence & Closing Performance Section
   ========================================================================== */
.persona-closing-section {
  width: 100%;
}

.persona-stats-table-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.persona-stats-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.88rem;
}

.persona-stats-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-surface);
  white-space: nowrap;
}

.persona-stats-table td {
  padding: 14px;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}

.persona-stats-table tbody tr {
  transition: background 0.15s ease;
}

.persona-stats-table tbody tr:hover {
  background: var(--bg-tertiary);
}

.persona-stats-table tbody tr:last-child td {
  border-bottom: none;
}

.persona-cell-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.persona-avatar-circle {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.95rem;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.persona-title-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.persona-name-text {
  font-weight: 700;
  color: var(--text-primary);
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.persona-role-badge {
  font-size: 0.73rem;
  color: var(--text-muted);
  font-weight: 500;
}

.persona-active-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  background: rgba(16, 185, 129, 0.15);
  color: #059669;
}

.persona-active-pill.inactive {
  background: var(--bg-tertiary);
  color: var(--text-muted);
}

/* Stacked Lead Distribution Bar */
.lead-dist-container {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 140px;
  max-width: 240px;
}

.lead-dist-bar {
  display: flex;
  height: 8px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  width: 100%;
}

.lead-dist-segment {
  height: 100%;
  transition: width 0.3s ease;
}

.lead-dist-segment.hot {
  background: #10b981;
}

.lead-dist-segment.warm {
  background: #f59e0b;
}

.lead-dist-segment.nurture {
  background: #94a3b8;
}

.lead-dist-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.lead-dist-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

/* Mobile Persona Cards */
.persona-stats-mobile-cards {
  display: none; /* Hidden on desktop */
}

.persona-mobile-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.persona-mobile-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.persona-mobile-card-identity {
  display: flex;
  align-items: center;
  gap: 10px;
}

.persona-mobile-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
}

.persona-mobile-metric-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.persona-mobile-metric-val {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--text-primary);
}

.persona-mobile-metric-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 600;
}

.persona-mobile-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
  font-size: 0.8rem;
}

/* Benchmark Comparison Bars */
.persona-comp-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.persona-comp-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
}

.persona-comp-name {
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.persona-comp-val {
  font-weight: 800;
  color: var(--accent-emerald, #10b981);
}

.persona-comp-bar-bg {
  height: 10px;
  background: var(--bg-tertiary);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  position: relative;
}

.persona-comp-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  background: linear-gradient(90deg, #10b981, #059669);
}

/* Responsive Media Queries for Persona Closing Module */
@media (min-width: 769px) {
  #personaStatsDesktopTable {
    display: block;
  }
  #personaStatsMobileCards {
    display: none;
  }
}

@media (max-width: 768px) {
  #personaStatsDesktopTable {
    display: none !important;
  }
  #personaStatsMobileCards {
    display: flex !important;
    flex-direction: column;
    gap: 12px;
  }
  .persona-closing-kpis {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }
  .persona-closing-section .card {
    padding: 16px !important;
  }
}

@media (max-width: 480px) {
  .persona-closing-kpis {
    grid-template-columns: 1fr !important;
  }
  .persona-mobile-metrics-grid {
    grid-template-columns: repeat(3, 1fr);
    padding: 8px 6px;
  }
  .persona-mobile-metric-val {
    font-size: 0.95rem;
  }
}

/* ==========================================================
   Super Admin Sandbox AI Ratings & Quality Workspace Styles
   ========================================================== */
.sb-ratings-workspace {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sb-kpi-scorecard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
}

.sb-kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.sb-kpi-card:hover {
  border-color: rgba(56, 189, 248, 0.4);
  transform: translateY(-2px);
}

.sb-kpi-card .kpi-label {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sb-kpi-card .kpi-num {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
}

.sb-kpi-card .kpi-sub {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Star Distribution Bars */
.sb-dist-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-bottom: 3px;
}

.sb-dist-bar-wrap {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}

.sb-dist-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* Filter Toolbar */
.sb-toolbar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.sb-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.sb-chip {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.sb-chip:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

.sb-chip.active {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border-color: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
}

/* Interaction Cards */
.sb-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 16px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

.sb-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.sb-card.rated-5 {
  border-left: 4px solid #10b981;
}

.sb-card.rated-4 {
  border-left: 4px solid #38bdf8;
}

.sb-card.rated-3 {
  border-left: 4px solid #f59e0b;
}

.sb-card.rated-2 {
  border-left: 4px solid #f97316;
}

.sb-card.rated-1 {
  border-left: 4px solid #ef4444;
}

.sb-card.unrated {
  border-left: 4px solid rgba(255, 255, 255, 0.2);
}

.sb-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sb-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

/* Chat Exchanges */
.sb-exchange {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.sb-bubble-user {
  background: rgba(30, 41, 59, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px 12px 12px 2px;
  padding: 12px 16px;
  max-width: 85%;
  align-self: flex-start;
  color: var(--text-primary);
  font-size: 0.92rem;
  line-height: 1.55;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.sb-bubble-bot {
  background: rgba(6, 78, 59, 0.35);
  border: 1px solid rgba(16, 185, 129, 0.4);
  border-radius: 12px 12px 2px 12px;
  padding: 12px 16px;
  max-width: 85%;
  align-self: flex-end;
  color: var(--text-primary);
  font-size: 0.92rem;
  line-height: 1.55;
  white-space: pre-wrap;
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.1);
}

/* Star Rating Controls */
.sb-rating-panel {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
}

.sb-stars-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sb-star-btn {
  background: transparent;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  color: rgba(148, 163, 184, 0.45);
  cursor: pointer;
  padding: 2px 4px;
  transition: transform 0.15s ease, color 0.15s ease, text-shadow 0.15s ease;
  user-select: none;
}

.sb-star-btn:hover {
  transform: scale(1.25);
  color: #fbbf24;
}

.sb-star-btn.active,
.sb-star-btn.hover-active {
  color: #fbbf24;
  text-shadow: 0 0 12px rgba(251, 191, 36, 0.65);
}

.sb-notes-wrap {
  flex: 1;
  min-width: 250px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.sb-note-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  color: var(--text-primary);
  font-size: 0.8rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.sb-note-input:focus {
  border-color: #38bdf8;
  background: rgba(255, 255, 255, 0.07);
}

/* ==========================================================
   Tabbed Conversation Studio Styles (Separate Tabs per Visitor)
   ========================================================== */
.sb-view-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.sb-view-btn.active {
  background: rgba(56, 189, 248, 0.15) !important;
  border-color: #38bdf8 !important;
  color: #38bdf8 !important;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
}

.sb-tabbed-studio {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 16px;
  min-height: 580px;
  margin-top: 6px;
}

@media (max-width: 992px) {
  .sb-tabbed-studio {
    grid-template-columns: 1fr;
  }
}

.sb-conv-tabs-sidebar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  height: 680px;
  overflow: hidden;
}

.sb-conv-sidebar-header {
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sb-conv-tabs-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sb-conv-tab-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.sb-conv-tab-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(56, 189, 248, 0.35);
}

.sb-conv-tab-item.active {
  background: rgba(56, 189, 248, 0.08);
  border-color: #38bdf8;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.12);
}

.sb-conv-tab-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: #38bdf8;
  border-radius: 4px 0 0 4px;
}

.sb-conv-tab-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sb-conv-tab-title {
  font-weight: 700;
  font-size: 0.84rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.sb-conv-tab-badge {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border-radius: 10px;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 7px;
}

.sb-conv-tab-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.sb-conv-tab-snippet {
  font-size: 0.76rem;
  color: var(--text-secondary);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-style: italic;
}

.sb-conv-tab-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2px;
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* Right Dialogue Pane */
/* Right Dialogue Pane: Authentic WhatsApp Chat Frame */
.sb-conv-dialogue-pane {
  background: #0b141a;
  border: 1px solid #202c33;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  height: 720px;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
}

/* WhatsApp Chat Top Bar */
.wa-chat-topbar {
  background: #202c33;
  border-bottom: 1px solid #2a3942;
  padding: 12px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  z-index: 5;
}

.wa-topbar-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.wa-topbar-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #00a884;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  position: relative;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.wa-online-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #25d366;
  border: 2px solid #202c33;
  box-shadow: 0 0 6px #25d366;
}

.wa-topbar-info h3 {
  font-size: 1rem;
  font-weight: 700;
  color: #e9edef;
  margin: 0 0 3px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.wa-topbar-status {
  font-size: 0.76rem;
  color: #8696a0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.wa-topbar-pills {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.wa-pill {
  background: #111b21;
  border: 1px solid #2a3942;
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 0.74rem;
  color: #e9edef;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* WhatsApp Messages Thread (Authentic Wallpaper) */
.sb-dialogue-thread {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background-color: #0b141a;
  background-image: radial-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 0);
  background-size: 20px 20px;
  scroll-behavior: smooth;
}

/* Centered WhatsApp Date Divider */
.wa-date-divider {
  display: flex;
  justify-content: center;
  margin: 6px 0 10px 0;
}

.wa-date-divider span {
  background: #182229;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 5px 14px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #8696a0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Exchange Turn Wrapper */
.sb-thread-turn {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 20px;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
}

.sb-thread-turn:last-child {
  border-bottom: none;
  padding-bottom: 4px;
}

/* Message Rows */
.wa-msg-row {
  display: flex;
  width: 100%;
}

.wa-row-incoming {
  justify-content: flex-start;
}

.wa-row-outgoing {
  justify-content: flex-end;
}

/* WhatsApp Bubble Base */
.wa-bubble {
  max-width: 82%;
  padding: 10px 14px;
  position: relative;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

/* Incoming Visitor Bubble */
.wa-incoming-bubble {
  background: #202c33;
  color: #e9edef;
  border-radius: 8px 8px 8px 2px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Outgoing Bot Bubble */
.wa-outgoing-bubble {
  background: #005c4b;
  color: #e9edef;
  border-radius: 8px 8px 2px 8px;
  border: 1px solid rgba(0, 168, 132, 0.35);
}

/* Bubble Sender Header */
.wa-bubble-sender {
  font-size: 0.78rem;
  font-weight: 700;
  color: #53bdeb;
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.wa-bot-sender {
  color: #25d366;
}

.wa-tag-pill {
  font-size: 0.7rem;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.25);
  padding: 1px 6px;
  border-radius: 4px;
  color: #8696a0;
}

.wa-latency-pill {
  color: #53bdeb;
}

/* Bubble Message Text */
.wa-bubble-text {
  font-size: 0.96rem;
  line-height: 1.52;
  color: #e9edef;
  font-weight: 400;
  letter-spacing: 0.01em;
}

.wa-outgoing-bubble .wa-bubble-text {
  white-space: pre-wrap;
}

/* Bubble Meta Footer: Time + How long ago */
.wa-bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  font-size: 0.72rem;
  color: #8696a0;
  margin-top: 6px;
  user-select: none;
}

.wa-outgoing-bubble .wa-bubble-meta {
  color: rgba(255, 255, 255, 0.75);
}

.wa-meta-dot {
  opacity: 0.6;
}

.wa-time-ago {
  font-weight: 600;
  color: #53bdeb;
}

.wa-outgoing-bubble .wa-time-ago {
  color: #bbf7d0;
}

.wa-checkmarks {
  color: #53bdeb;
  font-size: 0.88rem;
  font-weight: bold;
  letter-spacing: -0.1em;
  margin-left: 2px;
}

/* WhatsApp Supervisor Grading & Quality Console */
.wa-grading-console {
  background: #111b21;
  border: 1px solid #222e35;
  border-radius: 10px;
  padding: 14px 18px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.wa-grading-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.wa-grading-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #e9edef;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Star Rating Buttons */
.sb-stars-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sb-star-btn {
  background: transparent;
  border: none;
  font-size: 1.8rem;
  line-height: 1;
  color: #64748b;
  cursor: pointer;
  padding: 2px 4px;
  transition: transform 0.15s ease, color 0.15s ease, text-shadow 0.15s ease;
  user-select: none;
}

.sb-star-btn:hover {
  transform: scale(1.3);
  color: #fbbf24;
}

.sb-star-btn.active,
.sb-star-btn.hover-active {
  color: #fbbf24;
  text-shadow: 0 0 14px rgba(251, 191, 36, 0.7);
}

.wa-rating-badge .badge-rated {
  background: rgba(251, 191, 36, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.35);
  font-weight: 700;
  font-size: 0.78rem;
  padding: 3px 10px;
  border-radius: 12px;
}

.wa-rating-badge .badge-unrated {
  background: rgba(255, 255, 255, 0.06);
  color: #8696a0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-weight: 600;
  font-size: 0.76rem;
  padding: 3px 10px;
  border-radius: 12px;
}

/* AI Critique / Analysis Callout in WhatsApp Theme */
.wa-critique-box {
  background: #182229;
  border-left: 4px solid #00a884;
  border-radius: 0 8px 8px 0;
  padding: 10px 14px;
  line-height: 1.52;
}

.wa-critique-header {
  font-size: 0.85rem;
  font-weight: 700;
  color: #00a884;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.wa-critique-content {
  font-size: 0.9rem;
  color: #e9edef;
  line-height: 1.5;
}

/* Supervisor Note Form */
.wa-notes-form {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.wa-note-input {
  flex: 1;
  min-width: 240px;
  background: #202c33;
  border: 1px solid #374248;
  border-radius: 8px;
  color: #e9edef;
  font-size: 0.9rem;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.wa-note-input:focus {
  border-color: #00a884;
  background: #2a3942;
}

.wa-save-btn {
  background: #00a884;
  border: none;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.86rem;
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.2s ease, transform 0.1s ease;
}

.wa-save-btn:hover {
  background: #029474;
  transform: translateY(-1px);
}

/* ========== LIGHT THEME OVERRIDES FOR WHATSAPP STUDIO ========== */
[data-theme="light"] .sb-conv-dialogue-pane {
  background: #efeae2;
  border-color: #d1d7db;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .wa-chat-topbar {
  background: #f0f2f5;
  border-bottom-color: #d1d7db;
}

[data-theme="light"] .wa-topbar-info h3 {
  color: #111b21;
}

[data-theme="light"] .wa-topbar-status {
  color: #54656f;
}

[data-theme="light"] .wa-pill {
  background: #ffffff;
  border-color: #d1d7db;
  color: #111b21;
}

[data-theme="light"] .sb-dialogue-thread {
  background-color: #efeae2;
  background-image: radial-gradient(rgba(0, 0, 0, 0.04) 1px, transparent 0);
}

[data-theme="light"] .wa-date-divider span {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.06);
  color: #54656f;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .wa-incoming-bubble {
  background: #ffffff;
  border-color: #e2e8f0;
  color: #111b21;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .wa-incoming-bubble .wa-bubble-text {
  color: #111b21;
}

[data-theme="light"] .wa-outgoing-bubble {
  background: #d9fdd3;
  border-color: #bbf7d0;
  color: #111b21;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .wa-outgoing-bubble .wa-bubble-text {
  color: #111b21;
}

[data-theme="light"] .wa-outgoing-bubble .wa-bubble-meta {
  color: #54656f;
}

[data-theme="light"] .wa-outgoing-bubble .wa-time-ago {
  color: #059669;
}

[data-theme="light"] .wa-grading-console {
  background: #ffffff;
  border-color: #d1d7db;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .wa-grading-title {
  color: #111b21;
}

[data-theme="light"] .sb-star-btn {
  color: #cbd5e1;
}

[data-theme="light"] .sb-star-btn:hover,
[data-theme="light"] .sb-star-btn.active,
[data-theme="light"] .sb-star-btn.hover-active {
  color: #d97706;
  text-shadow: 0 0 10px rgba(217, 119, 6, 0.4);
}

[data-theme="light"] .wa-critique-box {
  background: #f0fdf4;
  border-left-color: #16a34a;
}

[data-theme="light"] .wa-critique-header {
  color: #16a34a;
}

[data-theme="light"] .wa-critique-content {
  color: #166534;
}

[data-theme="light"] .wa-note-input {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #0f172a;
}

[data-theme="light"] .wa-note-input:focus {
  border-color: #10b981;
  background: #ffffff;
}

[data-theme="light"] .sb-thread-turn {
  border-bottom-color: #d1d7db;
}

[data-theme="light"] .sb-conv-tabs-sidebar {
  background: #ffffff;
  border-color: #e2e8f0;
}

[data-theme="light"] .sb-conv-sidebar-header {
  background: #f8fafc;
  border-bottom-color: #e2e8f0;
}

[data-theme="light"] .sb-conv-tab-item {
  background: #ffffff;
  border-color: #e2e8f0;
}

[data-theme="light"] .sb-conv-tab-item:hover {
  background: #f1f5f9;
  border-color: #93c5fd;
}

[data-theme="light"] .sb-conv-tab-item.active {
  background: #eff6ff;
  border-color: #3b82f6;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.15);
}

[data-theme="light"] .sb-kpi-card {
  background: #ffffff;
  border-color: #e2e8f0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

/* ==========================================================================
   AGENTWATS EXECUTIVE DESIGN SYSTEM OVERHAUL
   ========================================================================== */

/* Typography & Headings */
h1, h2, h3, h4, .card-title, .portal-modal-title, .aw-modal-title {
  font-family: var(--font-heading);
  letter-spacing: -0.015em;
}

code, pre, .font-mono-code, .font-mono {
  font-family: var(--font-mono);
}

/* Universal Modal Backdrop & "Hark Window" Overhaul */
.aw-modal-backdrop,
.modal-backdrop,
.auth-overlay,
.portal-modal-backdrop {
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  background: rgba(6, 9, 15, 0.72) !important;
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.22s !important;
}

.aw-modal-card,
.auth-card,
.modal-dialog-custom,
.portal-modal {
  border-radius: var(--radius-lg, 16px) !important;
  border: 1px solid var(--border-color) !important;
  box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05) !important;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

/* Specific AW Modal Classes */
.aw-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
}

.aw-modal-backdrop.open {
  opacity: 1 !important;
  visibility: visible !important;
  display: flex !important;
}

.aw-modal-card {
  background: var(--bg-secondary);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.96) translateY(8px);
}

.aw-modal-backdrop.open .aw-modal-card {
  transform: scale(1) translateY(0);
}

.aw-modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-tertiary);
}

.aw-modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}

.aw-modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  font-size: 1.1rem;
  line-height: 1;
  transition: all 0.15s ease;
}

.aw-modal-close:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}

.aw-modal-body {
  padding: 24px;
  overflow-y: auto;
  color: var(--text-primary);
  font-size: 0.85rem;
}

.aw-modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Executive Sub-Navigation Toolbar */
.aw-subnav-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  margin-bottom: 24px;
  overflow-x: auto;
  scrollbar-width: none;
}

.aw-subnav-bar::-webkit-scrollbar {
  display: none;
}

.aw-subnav-separator {
  width: 1px;
  height: 22px;
  background: var(--border-color);
  margin: 0 4px;
  flex-shrink: 0;
}

.aw-badge-node {
  background: rgba(147, 51, 234, 0.15);
  color: #c084fc;
  border: 1px solid rgba(147, 51, 234, 0.35);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.aw-badge-human {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.35);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.aw-subnav-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

.aw-subnav-btn:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.aw-subnav-btn.active {
  color: #ffffff !important;
  background: linear-gradient(135deg, #10b981, #059669) !important;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.28);
}

.aw-sub-panel {
  display: none;
}

.aw-sub-panel.active {
  display: block;
  animation: awFadeIn 0.25s ease-out;
}

@keyframes awFadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Executive Terminal Window */
.aw-terminal-window {
  background: #07090e;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

.aw-terminal-header {
  background: #0c101a;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}

.aw-terminal-body {
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: #cbd5e1;
  height: 380px;
  overflow-y: auto;
  line-height: 1.6;
}





/* AI Persona Page Product Cards */
.sb-product-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  gap: 12px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.sb-product-card:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(16, 185, 129, 0.35);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.sb-product-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  flex-shrink: 0;
}

.sb-product-thumb-placeholder {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ==========================================================================
   COMMERCIAL REDESIGN v2 — LINEAR/VERCEL STYLE
   Design tokens, collapsible sidebar, notification center, user avatar menu,
   admin vertical workspace nav, KPI cards v2
   ========================================================================== */

/* ---- Design Tokens Extension ---- */
:root {
  --font-size-xs:   0.72rem;
  --font-size-sm:   0.85rem;
  --font-size-base: 0.95rem;
  --font-size-lg:   1.1rem;
  --font-size-xl:   1.35rem;
  --font-size-2xl:  1.75rem;
  --font-size-3xl:  2.4rem;

  --color-success:       #10b981;
  --color-success-bg:    #ecfdf5;
  --color-success-muted: rgba(16, 185, 129, 0.12);
  --color-error:         #ef4444;
  --color-error-bg:      #fef2f2;
  --color-error-muted:   rgba(239, 68, 68, 0.12);
  --color-warning:       #f59e0b;
  --color-warning-bg:    #fffbeb;
  --color-warning-muted: rgba(245, 158, 11, 0.12);
  --color-info:          #3b82f6;
  --color-info-bg:       #eff6ff;
  --color-info-muted:    rgba(59, 130, 246, 0.12);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  --sidebar-width-full:      256px;
  --sidebar-width-collapsed: 64px;
  --sidebar-transition:      width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --topbar-height:           60px;

  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);
}

[data-theme="dark"] {
  --color-success-bg:    rgba(16, 185, 129, 0.12);
  --color-error-bg:      rgba(239, 68, 68, 0.12);
  --color-warning-bg:    rgba(245, 158, 11, 0.12);
  --color-info-bg:       rgba(59, 130, 246, 0.12);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.55), 0 8px 10px -6px rgba(0,0,0,0.35);
}

/* ---- Collapsible Sidebar ---- */
.portal-sidebar {
  width: var(--sidebar-width-full);
  transition: var(--sidebar-transition);
}

.portal-sidebar.collapsed {
  width: var(--sidebar-width-collapsed);
  min-width: var(--sidebar-width-collapsed);
}

.portal-sidebar.collapsed .sidebar-brand-text,
.portal-sidebar.collapsed .sidebar-nav-group-title,
.portal-sidebar.collapsed .sidebar-nav-divider-label,
.portal-sidebar.collapsed .sidebar-user-info {
  display: none !important;
}

.portal-sidebar.collapsed .sidebar-nav .nav-tab {
  justify-content: center;
  padding: 11px;
}

.portal-sidebar.collapsed .sidebar-nav .nav-tab .nav-tab-label {
  display: none !important;
}

.portal-sidebar.collapsed .sidebar-brand {
  justify-content: center;
  padding: 0 12px;
}

.portal-sidebar.collapsed .sidebar-collapse-btn {
  margin-left: 0;
}

/* Tooltip for collapsed sidebar items */
.portal-sidebar.collapsed .sidebar-nav .nav-tab {
  position: relative;
}

.portal-sidebar.collapsed .sidebar-nav .nav-tab[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(var(--sidebar-width-collapsed) + 2px);
  top: 50%;
  transform: translateY(-50%);
  background: #1e293b;
  color: #f8fafc;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

[data-theme="dark"] .portal-sidebar.collapsed .sidebar-nav .nav-tab[data-tooltip]::after {
  background: #f8fafc;
  color: #0f172a;
}

.portal-sidebar.collapsed .sidebar-nav .nav-tab[data-tooltip]:hover::after {
  opacity: 1;
}

/* Sidebar Collapse Toggle Button */
.sidebar-collapse-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s ease;
  flex-shrink: 0;
  margin-left: auto;
}

.sidebar-collapse-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.sidebar-collapse-btn svg {
  transition: transform 0.25s ease;
}

/* Hide collapse btn on mobile */
@media (max-width: 768px) {
  .sidebar-collapse-btn { display: none !important; }
}

/* ---- Sidebar Nav Grouping ---- */
.sidebar-nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 6px;
}

.sidebar-nav-group-title {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 16px 4px;
  transition: opacity 0.2s ease;
}

.sidebar-nav-divider {
  height: 1px;
  background: var(--border-color);
  margin: 8px 14px;
}

/* ---- Topbar Compact ---- */
.app-topbar-v2 {
  min-height: var(--topbar-height) !important;
  height: var(--topbar-height) !important;
  padding: 0 20px !important;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 2500;
  box-shadow: var(--shadow-xs);
}

.topbar-right-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ---- Topbar Icon Buttons ---- */
.topbar-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s ease;
  position: relative;
}

.topbar-icon-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-color);
}

/* ---- Notification Bell ---- */
.notif-bell-btn {
  position: relative;
}

.notif-unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  background: var(--color-error);
  color: #fff;
  font-size: 0.58rem;
  font-weight: 800;
  border-radius: 99px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  border: 2px solid var(--bg-secondary);
}

/* ---- Notification Center Panel ---- */
.notif-center-panel {
  position: fixed;
  top: calc(var(--topbar-height) + 4px);
  right: 16px;
  width: 360px;
  max-height: 480px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: var(--shadow-xl);
  z-index: 4000;
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: fadeIn 0.15s ease;
}

.notif-center-panel.open {
  display: flex;
}

.notif-center-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.notif-center-title {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text-primary);
}

.notif-mark-read-btn {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-success);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.notif-center-list {
  overflow-y: auto;
  flex: 1;
}

.notif-center-list::-webkit-scrollbar { width: 4px; }
.notif-center-list::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background 0.1s ease;
}

.notif-item:hover {
  background: var(--bg-tertiary);
}

.notif-item.unread {
  background: var(--color-info-bg);
}

[data-theme="dark"] .notif-item.unread {
  background: rgba(59, 130, 246, 0.06);
}

.notif-item-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  background: var(--bg-tertiary);
}

.notif-item-body {
  flex: 1;
  min-width: 0;
}

.notif-item-title {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.notif-item-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.notif-item-time {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.notif-empty-state {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.84rem;
}

.notif-center-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border-color);
  text-align: center;
  flex-shrink: 0;
}

.notif-center-footer a {
  font-size: 0.78rem;
  color: var(--color-success);
  font-weight: 600;
  text-decoration: none;
}

/* ---- User Avatar Menu ---- */
.topbar-user-wrapper {
  position: relative;
}

.topbar-user-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--text-primary);
}

.topbar-user-btn:hover {
  background: var(--bg-tertiary);
}

.topbar-user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10b981, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  flex-shrink: 0;
}

.topbar-user-name {
  font-size: 0.8rem;
  font-weight: 600;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-user-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 210px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow-xl);
  z-index: 4000;
  overflow: hidden;
  display: none;
  animation: fadeIn 0.12s ease;
}

.topbar-user-dropdown.open {
  display: block;
}

.topbar-user-dropdown-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
}

.topbar-user-dropdown-name {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text-primary);
}

.topbar-user-dropdown-plan {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.topbar-user-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: none;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
  transition: all 0.1s ease;
}

.topbar-user-menu-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.topbar-user-menu-item.danger {
  color: var(--color-error);
}

.topbar-user-menu-item.danger:hover {
  background: var(--color-error-muted);
}

.topbar-user-menu-divider {
  height: 1px;
  background: var(--border-color);
  margin: 4px 0;
}

.topbar-user-menu-item-icon {
  width: 18px;
  text-align: center;
  font-size: 0.95rem;
}

/* ---- Admin Workspace (Vertical Sub-Nav) ---- */
.admin-workspace {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  min-height: calc(100vh - 220px);
}

.admin-workspace-nav {
  border-right: 1px solid var(--border-color);
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--bg-secondary);
  overflow-y: auto;
  max-height: calc(100vh - 220px);
  position: sticky;
  top: 0;
}

.admin-workspace-nav::-webkit-scrollbar { width: 4px; }
.admin-workspace-nav::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }

.admin-workspace-nav-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-bottom: 6px;
}

.admin-workspace-nav-title {
  font-size: 0.60rem;
  font-weight: 800;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 10px 4px;
}

.admin-workspace-nav-divider {
  height: 1px;
  background: var(--border-color);
  margin: 6px 8px;
}

.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 7px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: all 0.15s ease;
}

.admin-nav-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.admin-nav-item.active {
  background: var(--color-success-muted);
  color: var(--color-success);
  font-weight: 700;
}

[data-theme="dark"] .admin-nav-item.active {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.admin-nav-icon {
  font-size: 0.92rem;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.admin-workspace-content {
  padding: 24px;
  min-width: 0;
  overflow-y: auto;
  max-height: calc(100vh - 220px);
}

.admin-workspace-content::-webkit-scrollbar { width: 5px; }
.admin-workspace-content::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }

/* Admin workspace mobile: stack vertically */
@media (max-width: 900px) {
  .admin-workspace {
    grid-template-columns: 1fr;
  }
  .admin-workspace-nav {
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    flex-direction: row;
    flex-wrap: wrap;
    max-height: none;
    position: static;
    padding: 10px;
    gap: 4px;
  }
  .admin-workspace-nav-group {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 0;
  }
  .admin-workspace-nav-title {
    display: none;
  }
  .admin-workspace-nav-divider {
    display: none;
  }
  .admin-workspace-content {
    max-height: none;
    padding: 16px;
  }
}

/* ---- KPI Cards v2 ---- */
.kpi-card-v2 {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: box-shadow 0.2s ease, transform 0.15s ease;
  cursor: default;
}

.kpi-card-v2:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.kpi-card-v2 .kpi-v2-label {
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.kpi-card-v2 .kpi-v2-number {
  font-size: var(--font-size-2xl);
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -0.02em;
}

.kpi-card-v2 .kpi-v2-trend {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--text-muted);
}

.kpi-trend-up   { color: var(--color-success) !important; }
.kpi-trend-down { color: var(--color-error) !important; }
.kpi-trend-flat { color: var(--text-muted) !important; }

.kpi-v2-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

/* ---- Topbar Page Title compact ---- */
.topbar-page-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.topbar-page-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.topbar-page-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ---- Topbar Divider ---- */
.topbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border-color);
  margin: 0 4px;
}

/* ---- Lang Btn compact ---- */
.topbar-lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 7px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.topbar-lang-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* ---- Badge utilities ---- */
.badge-success  { background: var(--color-success-muted); color: var(--color-success);  border: 1px solid rgba(16,185,129,0.3); }
.badge-error    { background: var(--color-error-muted);   color: var(--color-error);    border: 1px solid rgba(239,68,68,0.3); }
.badge-warning  { background: var(--color-warning-muted); color: var(--color-warning);  border: 1px solid rgba(245,158,11,0.3); }
.badge-info     { background: var(--color-info-muted);    color: var(--color-info);     border: 1px solid rgba(59,130,246,0.3); }

/* ---- Sidebar Footer refined ---- */
.sidebar-footer-v2 {
  padding: 12px 14px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.sidebar-user-card-v2 {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.sidebar-user-card-v2:hover {
  background: var(--bg-tertiary);
}

.sidebar-user-avatar-v2 {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10b981, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  flex-shrink: 0;
}

.sidebar-user-info-v2 {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name-v2 {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-status-v2 {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.portal-sidebar.collapsed .sidebar-user-info-v2 { display: none; }
.portal-sidebar.collapsed .sidebar-footer-v2 { padding: 10px 8px; }
.portal-sidebar.collapsed .sidebar-user-card-v2 { justify-content: center; padding: 8px; }

/* Hide legacy topbar logout and sound toggle from topbar - they move to user menu */
.topbar-logout-btn { display: none !important; }
#notifSoundToggle.topbar-sound-btn { display: none !important; }


/* ==========================================================================
   AGENTWATS COMMERCIAL UI — EXECUTIVE REDESIGN (Product & Vision Aligned)
   Clean, Calm, Intelligent, Professional, Spacious, High-Contrast Typography
   ========================================================================== */

/* Agent Status Panel (Employee Panel) */
.agent-employee-panel {
  background: var(--bg-surface, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 16px;
  padding: 20px 24px;
  margin-bottom: 24px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.03);
}

.agent-panel-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.agent-panel-profile {
  display: flex;
  align-items: center;
  gap: 16px;
}

.agent-avatar-container {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg-tertiary, #f1f5f9);
  flex-shrink: 0;
  border: 2px solid var(--border-color, #e2e8f0);
}

.agent-avatar-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.agent-panel-bio {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.agent-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.agent-name-row h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.agent-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
}

.agent-status-badge.status-active {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.agent-status-badge.status-paused {
  background: rgba(245, 158, 11, 0.12);
  color: #d97706;
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.agent-status-badge.status-offline {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.agent-status-badge .pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.status-active .pulse-dot {
  box-shadow: 0 0 6px #10b981;
}

.agent-role-title {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.agent-specs-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.agent-spec-item strong {
  color: var(--text-primary);
  font-weight: 600;
}

.agent-spec-dot {
  color: var(--border-color);
  font-size: 0.7rem;
}

.agent-panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Activation Checklist Strip */
.agent-activation-strip {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.activation-steps-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.act-step {
  font-size: 0.78rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 5px;
}

.act-step.ready {
  color: var(--accent-emerald, #10b981);
  font-weight: 600;
}

/* Performing items cards */
.performing-card {
  padding: 18px 20px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
}

.performing-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.performing-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.performing-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg-tertiary);
  font-size: 0.82rem;
}

.performing-item-name {
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.performing-item-metric {
  font-weight: 700;
  color: var(--accent-emerald);
}

/* Activity feed */
.activity-feed-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}

.activity-feed-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.8rem;
  border-left: 2.5px solid var(--accent-emerald);
  background: var(--bg-tertiary);
}

.activity-feed-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-left: auto;
  white-space: nowrap;
}

/* Orders List in CRM */
.crm-order-card {
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.crm-order-card:hover {
  border-color: var(--accent-emerald);
}

.crm-order-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.crm-order-phone {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text-primary);
}

.crm-order-amount {
  font-weight: 800;
  font-size: 0.92rem;
  color: var(--accent-emerald);
}

.crm-order-details {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* ==========================================================================
   Topbar Brand, Live Status Badge & Language Selector Enhancements
   ========================================================================== */
.topbar-brand-status-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
}

.topbar-business-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-live-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  text-decoration: none;
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.topbar-live-status-badge.status-offline {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
  animation: pulse-offline 2s infinite ease-in-out;
}

.topbar-live-status-badge.status-offline:hover {
  background: rgba(239, 68, 68, 0.22);
  transform: translateY(-1px);
}

@keyframes pulse-offline {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.85; transform: scale(1.03); }
}

.status-dot-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

.topbar-lang-dropdown {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.topbar-lang-select {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  min-height: 36px;
}

.topbar-account-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  padding: 4px 10px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
}

.topbar-account-pill-btn:hover {
  border-color: var(--accent-emerald);
}

/* ==========================================================================
   Sales Hub Navigation & Sub-panes (Industrial Grade Polish)
   ========================================================================== */
.sales-hub-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
}

.sales-subnav-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.sales-subnav {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-tertiary);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  overflow-x: auto;
  max-width: 100%;
}

.sales-pill-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.sales-pill-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.sales-pill-btn.active {
  background: var(--bg-card);
  color: var(--accent-emerald);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.sales-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sales-subpane {
  display: none;
  animation: fadeInPane 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.sales-subpane.active {
  display: block;
}

@keyframes fadeInPane {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Products Grid */
.sales-products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.sales-product-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-card);
}

.sales-product-card:hover {
  transform: translateY(-2px);
  border-color: rgba(16, 185, 129, 0.4);
}

.product-card-img-wrap {
  width: 100%;
  height: 160px;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.product-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-card-type-tag {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  background: rgba(15, 23, 42, 0.8);
  color: #fff;
  backdrop-filter: blur(4px);
}

.product-card-type-tag.cod { background: rgba(16, 185, 129, 0.85); }
.product-card-type-tag.digital { background: rgba(139, 92, 246, 0.85); }
.product-card-type-tag.service { background: rgba(6, 182, 212, 0.85); }

.product-card-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.product-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.product-card-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-card-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.product-card-price {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--accent-emerald);
}

/* Orders List & Filter */
.sales-orders-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.sales-filter-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.sales-filter-btn.active {
  background: var(--accent-emerald);
  color: #fff;
  border-color: var(--accent-emerald);
}

.sales-orders-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sales-order-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all 0.2s ease;
}

.sales-order-card:hover {
  border-color: rgba(16, 185, 129, 0.4);
}

.order-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.order-id-time {
  display: flex;
  align-items: center;
  gap: 10px;
}

.order-id-badge {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-primary);
}

.order-time-text {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.order-badge-status {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
}

.status-pending { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.status-confirmed { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.status-in_route { background: rgba(139, 92, 246, 0.15); color: #8b5cf6; }
.status-delivered { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.status-abandoned { background: rgba(239, 68, 68, 0.15); color: #ef4444; }

.order-card-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  padding: 10px 0;
  border-top: 1px dashed var(--border-color);
  border-bottom: 1px dashed var(--border-color);
}

.order-info-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.order-info-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.order-info-val {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
}

.order-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

/* Drivers Grid */
.sales-drivers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.sales-driver-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  transition: all 0.2s ease;
}

.sales-driver-card:hover {
  border-color: rgba(16, 185, 129, 0.4);
}

.driver-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.driver-avatar-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
}

.driver-name-phone {
  flex: 1;
}

.driver-name-text {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.driver-phone-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.driver-score-badge-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--bg-tertiary);
  padding: 8px 12px;
  border-radius: 8px;
}

.driver-stat-pill {
  font-size: 0.78rem;
  font-weight: 700;
}

.score-high { color: #10b981; }
.score-warn { color: #f59e0b; }
.score-low { color: #ef4444; }

.driver-delay-warning {
  padding: 6px 10px;
  border-radius: 6px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Settings Card & Webhook URL Box */
.sales-settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
  margin-top: 16px;
}

.sales-settings-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sales-webhook-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
}

.sales-webhook-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  outline: none;
}

/* Responsive Mobile Bottom Nav and Flawless Header Adjustments */
@media (max-width: 768px) {
  .app-header {
    padding: 0 14px;
    height: 60px;
  }
  
  .topbar-business-name {
    max-width: 110px;
    font-size: 0.9rem;
  }
  
  .topbar-live-status-badge {
    padding: 3px 6px;
    font-size: 0.7rem;
  }
  
  .topbar-lang-select {
    padding: 4px 6px;
    font-size: 0.75rem;
  }

  .portal-mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 1000;
    backdrop-filter: blur(12px);
    padding-bottom: env(safe-area-inset-bottom);
  }
  
  .portal-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    flex: 1;
    height: 100%;
    padding: 4px 0;
    transition: color 0.15s;
  }
  
  .portal-nav-item.active {
    color: var(--accent-emerald);
  }
  
  .portal-nav-item i {
    font-size: 1.15rem;
  }
  
  .app-main {
    padding-bottom: 80px !important;
  }
}


/* --------------------------------------------------------------------------
   Responsive Table Container & Accessibility Utilities
-------------------------------------------------------------------------- */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1rem;
}
.table-responsive > table {
  width: 100%;
  margin-bottom: 0;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* --------------------------------------------------------------------------
   COD DELIVERY PIPELINE — KANBAN BOARD (5 STAGES)
-------------------------------------------------------------------------- */
.kanban-view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.kanban-board-container {
  display: grid;
  grid-template-columns: repeat(5, minmax(250px, 1fr));
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 16px;
  -webkit-overflow-scrolling: touch;
}

.kanban-column {
  background: var(--bg-tertiary, #f8fafc);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  min-height: 480px;
  max-height: 720px;
  transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
}

.kanban-column.drag-over {
  border: 2px dashed var(--accent-emerald, #10b981) !important;
  background: rgba(16, 185, 129, 0.05) !important;
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.15);
}

.kanban-column-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
  position: sticky;
  top: 0;
  background: var(--bg-card, #ffffff);
  z-index: 2;
}

.kanban-column-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  font-weight: 800;
  color: var(--text-primary, #0f172a);
}

.kanban-column-stage-pill {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.kanban-column-stats {
  font-size: 0.72rem;
  color: var(--text-muted, #64748b);
  padding: 4px 14px 8px;
  border-bottom: 1px dashed var(--border-color, #e2e8f0);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.kanban-cards-dropzone {
  flex: 1;
  padding: 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 120px;
}

.kanban-card {
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 10px;
  padding: 12px;
  cursor: grab;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  user-select: none;
  position: relative;
}

.kanban-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.07);
  border-color: var(--border-hover, #cbd5e1);
}

.kanban-card:active {
  cursor: grabbing;
}

.kanban-card.dragging {
  opacity: 0.4;
  transform: scale(0.96);
  border: 1px dashed var(--accent-emerald, #10b981);
}

.kanban-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.kanban-card-num {
  font-family: 'Fira Code', monospace;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--text-primary);
}

.kanban-card-amount {
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--accent-emerald, #10b981);
}

.kanban-card-cust {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.kanban-card-item {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kanban-card-addr {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kanban-card-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  border-top: 1px solid var(--border-color, #e2e8f0);
  padding-top: 8px;
  margin-top: 4px;
}

.kanban-empty-dropzone {
  text-align: center;
  padding: 30px 10px;
  color: var(--text-muted);
  font-size: 0.75rem;
  border: 1px dashed var(--border-color);
  border-radius: 8px;
  margin: 10px 0;
}

/* ─────────────────────────────────────────────────────────────────────────────
   MOROCCAN DARIJA NEURAL VOICE STUDIO & PTT PLAYER
   ───────────────────────────────────────────────────────────────────────────── */
.voice-studio-container {
  background: var(--bg-surface, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 16px;
  padding: 24px;
  margin-top: 24px;
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
}

.voice-studio-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.voice-presets-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 16px 0;
}

.voice-preset-chip {
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-color, #e2e8f0);
  background: var(--bg-surface-elevated, #f8fafc);
  color: var(--text-primary, #1e293b);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.voice-preset-chip:hover {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.06);
  transform: translateY(-1px);
}

.voice-preset-chip.active {
  background: #10b981;
  color: #ffffff;
  border-color: #10b981;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.voice-player-bubble {
  background: #0b141a;
  color: #e9edef;
  border-radius: 18px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 16px 0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.voice-play-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #00a884;
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: transform 0.15s ease, background 0.15s ease;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 168, 132, 0.4);
}

.voice-play-btn:hover {
  transform: scale(1.06);
  background: #02b68f;
}

.voice-waveform-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.voice-waveform {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 32px;
  width: 100%;
}

.voice-bar {
  flex: 1;
  min-width: 2px;
  max-width: 5px;
  height: 8px;
  background: #8696a0;
  border-radius: 2px;
  transition: height 0.1s ease, background 0.15s ease;
}

.voice-bar.played {
  background: #00a884;
}

.voice-bar.animating {
  animation: pulseVoiceBar 0.5s ease-in-out infinite alternate;
}

@keyframes pulseVoiceBar {
  0% { transform: scaleY(0.4); }
  100% { transform: scaleY(1.3); }
}

.voice-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  color: #8696a0;
}



/* Real-time AWS Network Latency Badge and Telemetry */
.network-latency-pill {
    display: inline-flex;
    align-items: center;
    margin-left: 8px;
    padding: 3px 8px;
    font-size: 0.72rem;
    font-family: 'Fira Code', monospace;
    font-weight: 700;
    border-radius: 6px;
    background: rgba(6, 78, 59, 0.45);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.35);
    backdrop-filter: blur(8px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.15);
}
.network-latency-pill::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-right: 5px;
    border-radius: 50%;
    background-color: currentColor;
    box-shadow: 0 0 6px currentColor;
    animation: latencyPulse 2s infinite ease-in-out;
}
@keyframes latencyPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
}


/* ========================================================================= */
/* AGENT WATS LUXURY MERCHANT PORTAL DESIGN SYSTEM (v3.0.0 EXECUTIVE)       */
/* Tailored for High-End Merchants, Luxury Commerce & Maximum Accessibility */
/* ========================================================================= */

:root, [data-theme="light"] {
  --bg-primary: #F8FAFC;
  --bg-secondary: #FFFFFF;
  --bg-tertiary: #F1F5F9;
  --bg-card: #FFFFFF;
  --border-color: #E2E8F0;
  --border-focus: #10B981;
  --accent-emerald: #10B981;
  --accent-emerald-light: rgba(16, 185, 129, 0.08);
  --accent-emerald-glow: rgba(16, 185, 129, 0.2);
  --accent-gold: #D97706;
  --accent-gold-light: rgba(217, 119, 6, 0.1);
  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --shadow-card: 0 4px 20px -2px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.02);
  --shadow-hover: 0 10px 30px -4px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.03);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

[data-theme="dark"] {
  --bg-primary: #0A0D14;
  --bg-secondary: #101624;
  --bg-tertiary: #161E30;
  --bg-card: #121929;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #10B981;
  --accent-emerald: #10B981;
  --accent-emerald-light: rgba(16, 185, 129, 0.15);
  --accent-emerald-glow: rgba(16, 185, 129, 0.3);
  --accent-gold: #F59E0B;
  --accent-gold-light: rgba(245, 158, 11, 0.15);
  --text-primary: #F8FAFC;
  --text-secondary: #CBD5E1;
  --text-muted: #94A3B8;
  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --shadow-hover: 0 16px 40px -10px rgba(0, 0, 0, 0.7);
}

/* Sidebar Luxury Styling */
.portal-sidebar {
  background: var(--bg-secondary) !important;
  border-right: 1px solid var(--border-color) !important;
  box-shadow: 2px 0 16px rgba(0, 0, 0, 0.03);
}

.sidebar-brand-wrapper {
  border-bottom: 1px solid var(--border-color);
  padding: 12px 16px;
}

.sidebar-nav-group-title {
  font-size: 0.68rem !important;
  font-weight: 800 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.08em !important;
  color: var(--text-muted) !important;
  margin: 18px 14px 6px !important;
}

.sidebar-nav .nav-tab {
  height: 42px !important;
  min-height: 42px !important;
  border-radius: 10px !important;
  font-size: 0.86rem !important;
  font-weight: 600 !important;
  padding: 0 12px !important;
  margin: 2px 10px !important;
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  color: var(--text-secondary) !important;
  border: 1px solid transparent !important;
  background: transparent !important;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1) !important;
  cursor: pointer !important;
}

.sidebar-nav .nav-tab:hover {
  background: var(--bg-tertiary) !important;
  color: var(--text-primary) !important;
}

.sidebar-nav .nav-tab.active {
  background: var(--accent-emerald-light) !important;
  color: var(--accent-emerald) !important;
  font-weight: 700 !important;
  border-color: rgba(16, 185, 129, 0.25) !important;
}

.sidebar-nav .nav-tab .nav-tab-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.85;
}

.sidebar-nav .nav-tab.active .nav-tab-icon {
  opacity: 1;
  color: var(--accent-emerald);
}

.sidebar-nav-divider {
  height: 1px;
  background: var(--border-color);
  margin: 12px 16px;
  opacity: 0.7;
}

/* Luxury Header Bar */
.app-topbar {
  background: var(--bg-secondary) !important;
  border-bottom: 1px solid var(--border-color) !important;
  backdrop-filter: blur(12px) !important;
  height: 68px !important;
  padding: 0 24px !important;
}

.topbar-biz-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.topbar-live-status-badge {
  padding: 5px 12px !important;
  border-radius: 20px !important;
  font-size: 0.75rem !important;
  font-weight: 700 !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 7px !important;
  transition: all 0.2s ease !important;
}

.topbar-live-status-badge.connected {
  background: rgba(16, 185, 129, 0.1) !important;
  border: 1px solid rgba(16, 185, 129, 0.25) !important;
  color: #10B981 !important;
}

.topbar-live-status-badge.disconnected {
  background: rgba(148, 163, 184, 0.1) !important;
  border: 1px solid rgba(148, 163, 184, 0.25) !important;
  color: var(--text-muted) !important;
}

/* Executive KPI Stat Cards */
.overview-kpis-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)) !important;
  gap: 16px !important;
  margin-bottom: 24px !important;
}

.kpi-stat-card {
  background: var(--bg-card) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-lg) !important;
  padding: 20px 22px !important;
  box-shadow: var(--shadow-card) !important;
  display: flex !important;
  align-items: center !important;
  gap: 16px !important;
  transition: transform 0.2s ease, box-shadow 0.2s ease !important;
}

.kpi-stat-card:hover {
  transform: translateY(-2px) !important;
  box-shadow: var(--shadow-hover) !important;
}

.kpi-icon-wrap {
  width: 48px !important;
  height: 48px !important;
  border-radius: 12px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0 !important;
}

.kpi-label {
  font-size: 0.8rem !important;
  font-weight: 600 !important;
  color: var(--text-muted) !important;
  text-transform: uppercase !important;
  letter-spacing: 0.04em !important;
  margin-bottom: 4px !important;
}

.kpi-value {
  font-size: 1.85rem !important;
  font-weight: 800 !important;
  color: var(--text-primary) !important;
  line-height: 1.1 !important;
  font-feature-settings: "tnum" 1 !important;
  letter-spacing: -0.03em !important;
}

.kpi-subtext {
  font-size: 0.75rem !important;
  color: var(--text-muted) !important;
  margin-top: 4px !important;
}

/* Executive Agent Status Strip */
.agent-employee-panel {
  background: var(--bg-card) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-lg) !important;
  padding: 18px 24px !important;
  margin-bottom: 24px !important;
  box-shadow: var(--shadow-card) !important;
}

.agent-panel-main {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  flex-wrap: wrap !important;
  gap: 16px !important;
}

.agent-panel-profile {
  display: flex !important;
  align-items: center !important;
  gap: 16px !important;
}

.agent-avatar-container img {
  width: 52px !important;
  height: 52px !important;
  border-radius: 50% !important;
  object-fit: cover !important;
  border: 2px solid var(--accent-emerald) !important;
}

.agent-specs-row {
  display: flex !important;
  gap: 8px !important;
  align-items: center !important;
  flex-wrap: wrap !important;
  margin-top: 4px !important;
  font-size: 0.8rem !important;
}

.agent-activation-strip {
  margin-top: 14px !important;
  padding-top: 14px !important;
  border-top: 1px solid var(--border-color) !important;
}

.activation-steps-row {
  display: flex !important;
  gap: 12px !important;
  flex-wrap: wrap !important;
}

.act-step {
  font-size: 0.75rem !important;
  font-weight: 700 !important;
  padding: 4px 10px !important;
  border-radius: 8px !important;
  background: var(--bg-tertiary) !important;
  color: var(--text-secondary) !important;
  border: 1px solid var(--border-color) !important;
}

.act-step.ready {
  background: rgba(16, 185, 129, 0.1) !important;
  color: #10B981 !important;
  border-color: rgba(16, 185, 129, 0.25) !important;
}

/* Sales Hub Pills & Action Buttons */
.sales-subview-nav {
  display: flex !important;
  gap: 8px !important;
  overflow-x: auto !important;
  padding-bottom: 4px !important;
}

.sales-pill-btn {
  padding: 8px 16px !important;
  border-radius: 10px !important;
  font-size: 0.84rem !important;
  font-weight: 700 !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
  border: 1px solid var(--border-color) !important;
  background: var(--bg-tertiary) !important;
  color: var(--text-secondary) !important;
  cursor: pointer !important;
  transition: all 0.15s ease !important;
}

.sales-pill-btn:hover {
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
}

.sales-pill-btn.active {
  background: var(--accent-emerald) !important;
  color: #FFFFFF !important;
  border-color: var(--accent-emerald) !important;
}

.sales-pill-btn.active .badge {
  background: rgba(255, 255, 255, 0.25) !important;
  color: #FFFFFF !important;
}

/* Luxury Kanban & Orders Board */
.kanban-board {
  gap: 16px !important;
}

.kanban-column {
  background: var(--bg-tertiary) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-lg) !important;
  padding: 14px !important;
}

.kanban-card {
  background: var(--bg-card) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-md) !important;
  padding: 14px !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04) !important;
  transition: transform 0.18s ease, box-shadow 0.18s ease !important;
}

.kanban-card:hover {
  transform: translateY(-2px) !important;
  box-shadow: var(--shadow-hover) !important;
}

/* High-Contrast Luxury Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
