/**
 * UNLOCKIFY AI — MASTER SAAS DESIGN SYSTEM
 * Apple-Level Fluidity × Premium SaaS Elegance × Effortless Usability
 * Supports complete Light Mode (Default) & Dark Mode via CSS custom properties.
 */

/* ==========================================================================
   1. DESIGN TOKENS & THEMING (LIGHT MODE DEFAULT)
   ========================================================================== */

:root {
  /* Surface & Background Hierarchy - Light Mode (Warm off-white) */
  --bg-app: #F7F8FA;
  --bg-surface: #FFFFFF;
  --bg-subtle: #F3F6FA;
  --bg-elevated: #FFFFFF;
  --bg-hover: rgba(15, 23, 42, 0.03);
  --bg-active: rgba(37, 99, 235, 0.06);
  --bg-sidebar: #FFFFFF;
  --bg-topbar: #FFFFFF;
  --bg-input: #FFFFFF;

  /* Typography Colors */
  --text-primary: #172033;
  --text-secondary: #667085;
  --text-muted: #98A2B3;
  --text-inverse: #ffffff;

  /* Brand Colors (Unlockify PK Identity: Refined Blue & Amber Gold) */
  --brand-primary: #2563EB;
  --brand-hover: #1D4ED8;
  --brand-light: #EFF6FF;
  --brand-border: #BFDBFE;
  --brand-accent: #F59E0B;
  --brand-accent-light: #FEF3C7;

  /* Semantic Status Colors */
  --status-success: #12B76A;
  --status-success-light: #ECFDF5;
  --status-success-border: #A7F3D0;

  --status-warning: #F79009;
  --status-warning-light: #FFFBEB;
  --status-warning-border: #FDE68A;

  --status-danger: #F04438;
  --status-danger-light: #FEF3F2;
  --status-danger-border: #FECDCA;

  --status-info: #2563EB;
  --status-info-light: #EFF6FF;
  --status-info-border: #BFDBFE;

  --status-purple: #7C3AED;
  --status-purple-light: #F5F3FF;
  --status-purple-border: #DDD6FE;

  /* Borders & Dividers */
  --border-subtle: #E6EAF0;
  --border-medium: #D1D9E0;
  --border-focus: #2563EB;

  /* Shadows (Subtle, Apple-grade) */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 4px 0 rgba(0, 0, 0, 0.06), 0 1px 2px -1px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.07), 0 2px 6px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 12px 24px -4px rgba(0, 0, 0, 0.09), 0 4px 8px -2px rgba(0, 0, 0, 0.04);
  --shadow-modal: 0 24px 48px -12px rgba(15, 23, 42, 0.14), 0 8px 16px -4px rgba(15, 23, 42, 0.06);
  --shadow-focus: 0 0 0 3px rgba(37, 99, 235, 0.14);

  /* Typography */
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Apple-Level Easing & Transitions */
  --ease-apple: cubic-bezier(0.16, 1, 0.3, 1);
  --duration-fast: 140ms;
  --duration-normal: 220ms;
  --duration-smooth: 320ms;

  /* Border Radii */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 9999px;

  /* Layout Dimensions */
  --sidebar-width: 256px;
  --sidebar-collapsed-width: 68px;
  --topbar-height: 60px;

  /* Safe Area Insets (iOS / Notch support) */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

/* ==========================================================================
   DARK THEME OVERRIDES
   ========================================================================== */

body.dark-theme,
[data-theme='dark'] {
  --bg-app: #0C111D;
  --bg-surface: #131929;
  --bg-subtle: #1A2236;
  --bg-elevated: #1E2842;
  --bg-hover: rgba(255, 255, 255, 0.04);
  --bg-active: rgba(59, 130, 246, 0.12);
  --bg-sidebar: #0E1524;
  --bg-topbar: #131929;
  --bg-input: #131929;

  --text-primary: #F2F5F9;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --text-inverse: #0f172a;

  --brand-primary: #3B82F6;
  --brand-hover: #60A5FA;
  --brand-light: rgba(59, 130, 246, 0.12);
  --brand-border: rgba(59, 130, 246, 0.28);
  --brand-accent: #F59E0B;
  --brand-accent-light: rgba(245, 158, 11, 0.12);

  --status-success: #10B981;
  --status-success-light: rgba(16, 185, 129, 0.12);
  --status-success-border: rgba(16, 185, 129, 0.25);

  --status-warning: #F59E0B;
  --status-warning-light: rgba(245, 158, 11, 0.12);
  --status-warning-border: rgba(245, 158, 11, 0.25);

  --status-danger: #EF4444;
  --status-danger-light: rgba(239, 68, 68, 0.12);
  --status-danger-border: rgba(239, 68, 68, 0.25);

  --status-info: #3B82F6;
  --status-info-light: rgba(59, 130, 246, 0.12);
  --status-info-border: rgba(59, 130, 246, 0.25);

  --status-purple: #A855F7;
  --status-purple-light: rgba(168, 85, 247, 0.12);
  --status-purple-border: rgba(168, 85, 247, 0.25);

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.13);
  --border-focus: #60A5FA;

  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.25);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.35), 0 1px 2px -1px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.45), 0 2px 6px -1px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 12px 24px -4px rgba(0, 0, 0, 0.55), 0 4px 8px -2px rgba(0, 0, 0, 0.32);
  --shadow-modal: 0 24px 48px -12px rgba(0, 0, 0, 0.72), 0 8px 16px -4px rgba(0, 0, 0, 0.45);
  --shadow-focus: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* ==========================================================================
   2. GLOBAL RESET & BASE STYLING
   ========================================================================== */

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

html, body {
  height: 100%;
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background-color var(--duration-normal) var(--ease-apple),
              color var(--duration-normal) var(--ease-apple);
}

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

button {
  cursor: pointer;
  border: none;
  background: none;
  touch-action: manipulation;
}

a {
  color: var(--brand-primary);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-apple);
}
a:hover {
  color: var(--brand-hover);
}

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Utility Helpers */
.hidden {
  display: none !important;
}

.text-muted {
  color: var(--text-muted);
}

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

.text-success {
  color: var(--status-success);
}

.text-danger {
  color: var(--status-danger);
}

.text-warning {
  color: var(--status-warning);
}

.text-brand {
  color: var(--brand-primary);
}

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

.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }

.p-0 { padding: 0 !important; }
.py-4 { padding-top: 16px; padding-bottom: 16px; }
.text-center { text-align: center; }

/* ==========================================================================
   3. AUTHENTICATION VIEW (LOGIN SCREEN)
   ========================================================================== */

.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background-color: var(--bg-app);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 40px 36px;
  box-shadow: var(--shadow-lg);
}

.auth-header {
  text-align: center;
  margin-bottom: 32px;
}

.brand-logo-large {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.7px;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.brand-logo-large .logo-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--brand-light);
  color: var(--brand-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: var(--shadow-xs);
}

.brand-logo-large .highlight {
  color: var(--brand-primary);
}

.auth-subtitle {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.auth-footer {
  margin-top: 28px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

/* ==========================================================================
   4. APP SHELL LAYOUT (SIDEBAR + TOPBAR + MAIN)
   ========================================================================== */

.app-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background-color: var(--bg-app);
}

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width var(--duration-smooth) var(--ease-apple),
              transform var(--duration-smooth) var(--ease-apple);
  z-index: 40;
  position: relative;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed .version-badge,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .user-details,
.sidebar.collapsed .sidebar-toggle-text,
.sidebar.collapsed .nav-badge {
  display: none !important;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 9px 0;
}

.sidebar.collapsed .brand-logo {
  justify-content: center;
  padding: 0;
}

.sidebar.collapsed .sidebar-header {
  padding: 0 12px;
  justify-content: center;
}

.sidebar.collapsed .sidebar-footer {
  padding: 14px 10px;
  justify-content: center;
}

.sidebar-header {
  height: var(--topbar-height);
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.brand-logo .logo-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--brand-light);
  color: var(--brand-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.brand-logo .highlight {
  color: var(--brand-primary);
}

.version-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--brand-primary);
  background: var(--brand-light);
  padding: 2px 6px;
  border-radius: var(--radius-full);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
  padding: 14px 8px 5px;
  user-select: none;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--duration-fast) var(--ease-apple);
  position: relative;
  text-align: left;
  width: 100%;
}

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

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

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 5px;
  bottom: 5px;
  width: 3px;
  background: var(--brand-primary);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
}

/* SVG Nav Icons */
.nav-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-item.active .nav-icon {
  opacity: 1;
  color: var(--brand-primary);
}

.nav-item:hover .nav-icon {
  opacity: 1;
}

.nav-icon svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.75;
}

.nav-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
}

.nav-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.nav-badge.badge-hot {
  background: var(--status-danger-light);
  color: var(--status-danger);
  border: 1px solid var(--status-danger-border);
}

.nav-badge.badge-due {
  background: var(--status-warning-light);
  color: var(--status-warning);
  border: 1px solid var(--status-warning-border);
}

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-sidebar);
  flex-shrink: 0;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 9px;
  overflow: hidden;
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  background: var(--brand-light);
  color: var(--brand-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  border: 1px solid var(--brand-border);
}

.user-details {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.user-role {
  font-size: 11px;
  color: var(--text-muted);
}

.btn-sidebar-collapse {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--duration-fast) var(--ease-apple);
  flex-shrink: 0;
}

.btn-sidebar-collapse:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-logout {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--duration-fast) var(--ease-apple);
}

.btn-logout:hover {
  background: var(--status-danger-light);
  color: var(--status-danger);
}

.btn-logout svg {
  width: 15px;
  height: 15px;
  stroke-width: 2;
}

/* MAIN WRAPPER & TOPBAR */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background-color: var(--bg-app);
}

.top-header {
  height: var(--topbar-height);
  padding: 0 24px;
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  z-index: 20;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-titles {
  display: flex;
  flex-direction: column;
}

.page-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text-primary);
  line-height: 1.2;
}

.page-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 1px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-indicator-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--status-success);
  flex-shrink: 0;
}

.status-pill.status-offline .status-dot {
  background: var(--status-danger);
}

.btn-theme-toggle {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-fast) var(--ease-apple);
}

.btn-theme-toggle svg {
  width: 15px;
  height: 15px;
  stroke-width: 1.75;
}

.btn-theme-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

.impersonation-banner {
  padding: 9px 24px;
  background: #fef3c7;
  color: #92400e;
  border-bottom: 1px solid #fde68a;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
}

body.dark-theme .impersonation-banner {
  background: #78350f;
  color: #fef3c7;
  border-bottom-color: #92400e;
}

/* CONTENT CONTAINER */
.content-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  scroll-behavior: smooth;
}

/* Conversations gets full-bleed treatment */
#tab-conversations.tab-pane.active {
  padding: 0;
  height: calc(100vh - var(--topbar-height));
  overflow: hidden;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.18s var(--ease-apple) forwards;
}

.tab-pane.active {
  display: block;
}

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

/* ==========================================================================
   5. REUSABLE UI COMPONENTS (BUTTONS, CARDS, FORMS, BADGES)
   ========================================================================== */

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 15px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: all var(--duration-fast) var(--ease-apple);
  white-space: nowrap;
  user-select: none;
  letter-spacing: -0.1px;
}

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

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--brand-primary);
  color: #ffffff;
}
.btn-primary:hover {
  background: var(--brand-hover);
}

.btn-secondary {
  background: var(--bg-surface);
  border-color: var(--border-subtle);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
  background: var(--bg-subtle);
  border-color: var(--border-medium);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--status-danger);
  color: #ffffff;
  border-color: var(--status-danger);
}
.btn-danger:hover {
  background: #DC2626;
}

.btn-success {
  background: var(--status-success);
  color: #ffffff;
}
.btn-success:hover {
  background: #059669;
}

.btn-warning {
  background: var(--status-warning);
  color: #ffffff;
}
.btn-warning:hover {
  background: #D97706;
}

.btn-sm {
  padding: 5px 11px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-xs {
  padding: 3px 8px;
  font-size: 11px;
  border-radius: var(--radius-xs);
}

.btn-block {
  width: 100%;
}

.btn-icon {
  padding: 6px 10px;
}

/* CARDS */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

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

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  font-weight: 400;
}

.card-body {
  padding: 20px;
}

.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* SECTION HEADER */
.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.section-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 3px;
}

/* FORMS */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.form-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 3px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 13.5px;
  transition: all var(--duration-fast) var(--ease-apple);
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--brand-primary);
  box-shadow: var(--shadow-focus);
}

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

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}

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

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  border-radius: var(--radius-xs);
  accent-color: var(--brand-primary);
  cursor: pointer;
}

/* BADGES */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.badge-hot {
  background: var(--status-danger-light);
  color: var(--status-danger);
  border-color: var(--status-danger-border);
}

.badge-warm {
  background: var(--status-warning-light);
  color: var(--status-warning);
  border-color: var(--status-warning-border);
}

.badge-cold {
  background: var(--bg-subtle);
  color: var(--text-muted);
  border-color: var(--border-subtle);
}

.badge-unqualified {
  background: var(--bg-subtle);
  color: var(--text-muted);
  border-color: var(--border-subtle);
}

.badge-active, .badge-ai {
  background: var(--status-success-light);
  color: var(--status-success);
  border-color: var(--status-success-border);
}

.badge-success {
  background: var(--status-success-light);
  color: var(--status-success);
  border-color: var(--status-success-border);
}

.badge-info {
  background: var(--status-info-light);
  color: var(--status-info);
  border-color: var(--status-info-border);
}

.badge-purple {
  background: var(--status-purple-light);
  color: var(--status-purple);
  border-color: var(--status-purple-border);
}

.badge-secondary {
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

/* ALERTS */
.alert-box {
  padding: 11px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.45;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-danger {
  background: var(--status-danger-light);
  border: 1px solid var(--status-danger-border);
  color: var(--status-danger);
}

.alert-warning {
  background: var(--status-warning-light);
  border: 1px solid var(--status-warning-border);
  color: #92400e;
}

body.dark-theme .alert-warning {
  color: var(--status-warning);
}

.alert-success {
  background: var(--status-success-light);
  border: 1px solid var(--status-success-border);
  color: var(--status-success);
}

.alert-info {
  background: var(--status-info-light);
  border: 1px solid var(--status-info-border);
  color: var(--status-info);
}

/* TABLES */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.data-table th {
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  vertical-align: middle;
}

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

.data-table tbody tr:hover {
  background: var(--bg-hover);
}

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

/* EMPTY STATE */
.empty-state, .fu-empty-container {
  padding: 48px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.empty-icon, .fu-empty-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-lg);
  background: var(--brand-light);
  color: var(--brand-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  border: 1px solid var(--brand-border);
}

.empty-icon svg, .fu-empty-icon svg {
  width: 20px;
  height: 20px;
  stroke-width: 1.75;
}

.empty-title, .fu-empty-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.empty-desc, .fu-empty-desc {
  font-size: 13px;
  color: var(--text-secondary);
  max-width: 380px;
  margin: 0 auto 18px;
  line-height: 1.55;
}

/* TOGGLE SWITCH */
.toggle-switch {
  position: relative;
  display: inline-flex;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--border-medium);
  border-radius: var(--radius-full);
  transition: all var(--duration-normal) var(--ease-apple);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: var(--radius-full);
  transition: all var(--duration-normal) var(--ease-apple);
}

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

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(18px);
}

/* TOGGLE CARDS for AI settings */
.toggles-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.toggle-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-apple);
}

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

.toggle-card input[type="checkbox"] {
  margin-top: 2px;
  accent-color: var(--brand-primary);
  flex-shrink: 0;
}

.toggle-card strong {
  font-size: 13px;
  color: var(--text-primary);
  display: block;
}

.toggle-card p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.45;
}

/* INFO CALLOUT */
.info-callout {
  padding: 10px 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* LEAD DETAIL MODAL */
.modal-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lead-score-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px;
  background: var(--bg-subtle);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  margin-bottom: 16px;
}

.score-circle {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-full);
  background: var(--brand-primary);
  color: white;
  font-size: 16px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.score-details h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.score-reasons-list {
  font-size: 12px;
  color: var(--text-secondary);
  padding-left: 16px;
}

.lead-details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.detail-item .detail-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.detail-item .detail-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

/* LEADS TOOLBAR */
.leads-toolbar {
  padding: 12px 16px;
  display: flex;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  background: var(--bg-surface);
}

.leads-toolbar .search-box {
  flex: 1;
  min-width: 180px;
}

.leads-filters {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* FILTER CHIPS */
.filter-chip {
  padding: 4px 11px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  transition: all var(--duration-fast) var(--ease-apple);
  cursor: pointer;
  white-space: nowrap;
}

.filter-chip:hover {
  border-color: var(--border-medium);
  color: var(--text-primary);
  background: var(--bg-hover);
}

.filter-chip.active {
  background: var(--brand-primary);
  color: white;
  border-color: var(--brand-primary);
}

/* ==========================================================================
   6. VIEW-SPECIFIC STYLES
   ========================================================================== */

/* --- OVERVIEW TAB --- */
.overview-greeting {
  margin-bottom: 22px;
}

.overview-greeting-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.6px;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.overview-greeting-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
}

.urgent-banner {
  background: var(--status-danger-light);
  border: 1px solid var(--status-danger-border);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  color: var(--status-danger);
  gap: 12px;
}

.urgent-banner-content {
  flex: 1;
  font-size: 13px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.metric-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
  transition: all var(--duration-fast) var(--ease-apple);
}

.metric-card:hover {
  transform: translateY(-1px);
  border-color: var(--border-medium);
  box-shadow: var(--shadow-sm);
}

.metric-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.metric-title {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metric-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.metric-icon svg {
  width: 15px;
  height: 15px;
  stroke-width: 1.75;
}

.metric-card-hot .metric-icon {
  background: var(--status-danger-light);
  color: var(--status-danger);
}

.metric-card-warm .metric-icon {
  background: var(--status-warning-light);
  color: var(--status-warning);
}

.metric-card-success .metric-icon {
  background: var(--status-success-light);
  color: var(--status-success);
}

.metric-card-brand .metric-icon {
  background: var(--brand-light);
  color: var(--brand-primary);
}

.metric-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.8px;
  line-height: 1.1;
  margin-bottom: 4px;
}

.metric-footer {
  font-size: 11.5px;
  color: var(--text-secondary);
}

/* OVERVIEW 2-COLUMN SECTION */
.overview-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 18px;
}

.recent-chats-list {
  display: flex;
  flex-direction: column;
}

.overview-recent-item {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-apple);
  background: var(--bg-surface);
  min-width: 0;
}

.overview-recent-item:last-child {
  border-bottom: none;
}

.overview-recent-item:hover {
  background: var(--bg-hover);
}

.overview-recent-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid var(--border-subtle);
}

.overview-recent-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.overview-recent-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.overview-recent-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

.overview-recent-time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.overview-recent-preview {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  display: block;
  line-height: 1.35;
}

/* ==========================================================================
   CONVERSATIONS 3-COLUMN WORKSPACE (Apple x Linear x Intercom)
   ========================================================================== */

.chat-workspace {
  display: grid;
  grid-template-columns: 27% 49% 24%;
  height: calc(100vh - var(--topbar-height));
  background: var(--bg-surface);
  overflow: hidden;
  position: relative;
}

/* --- COLUMN 1: CONVERSATION INBOX --- */
.chat-sidebar {
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  height: 100%;
  overflow: hidden;
  min-width: 0;
}

.chat-sidebar-header {
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-surface);
  flex-shrink: 0;
}

.chat-inbox-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-inbox-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
  margin: 0;
}

.chat-search-wrap .form-input {
  width: 100%;
  font-size: 12.5px;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
}

.chat-filters {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.chat-filters::-webkit-scrollbar {
  height: 3px;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-surface);
}

/* Individual Conversation Row Item in Inbox */
.chat-list-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-apple);
  background: var(--bg-surface);
  min-width: 0;
  position: relative;
}

.chat-list-item:hover {
  background: var(--bg-hover);
}

.chat-list-item.active {
  background: var(--brand-light);
  border-left: 3px solid var(--brand-primary);
}

.chat-item-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid var(--border-subtle);
}

.chat-item-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-item-row-1 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.chat-item-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

.chat-item-time {
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.chat-item-preview {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.35;
  max-width: 100%;
  display: block;
}

/* --- COLUMN 2: CENTER ACTIVE CONVERSATION --- */
.chat-main {
  display: flex;
  flex-direction: column;
  background: var(--bg-app);
  height: 100%;
  overflow: hidden;
  min-width: 0;
  position: relative;
  border-right: 1px solid var(--border-subtle);
}

.chat-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  text-align: center;
  background: var(--bg-surface);
  height: 100%;
}

.empty-icon-wrap {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-xl);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.empty-icon-wrap svg {
  width: 24px;
  height: 24px;
  color: var(--text-muted);
  stroke-width: 1.5;
}

.empty-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.empty-desc {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 300px;
  line-height: 1.55;
}

.chat-thread-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.chat-thread-header {
  padding: 9px 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
  z-index: 10;
}

.chat-header-customer {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.chat-customer-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-customer-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.active-customer-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

.chat-customer-sub {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 1px;
}

.dot-separator {
  color: var(--border-medium);
}

.window-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-secondary);
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.chat-banner-warning {
  background: #fffbeb;
  color: #92400e;
  border-bottom: 1px solid #fde68a;
  padding: 7px 14px;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}

body.dark-theme .chat-banner-warning {
  background: #78350f;
  color: #fef3c7;
  border-bottom-color: #92400e;
}

/* Messages Stream */
.messages-stream {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-app);
}

/* Message Bubbles */
.msg-bubble {
  max-width: 70%;
  padding: 8px 12px;
  border-radius: var(--radius-lg);
  font-size: 13.5px;
  line-height: 1.5;
  position: relative;
  word-break: break-word;
  animation: fadeIn 0.15s var(--ease-apple) forwards;
}

/* Customer message (left) */
.msg-bubble.msg-incoming {
  align-self: flex-start;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-bottom-left-radius: var(--radius-xs);
  box-shadow: var(--shadow-xs);
}

/* AI Assistant message (right) */
.msg-bubble.msg-outgoing-ai {
  align-self: flex-end;
  background: var(--brand-primary);
  color: #ffffff;
  border-bottom-right-radius: var(--radius-xs);
}

.msg-bubble.msg-outgoing-ai .msg-sender-tag {
  color: rgba(255, 255, 255, 0.75);
}

.msg-bubble.msg-outgoing-ai .msg-meta {
  color: rgba(255, 255, 255, 0.7);
}

/* Human agent message (right, distinct) */
.msg-bubble.msg-outgoing-human {
  align-self: flex-end;
  background: var(--bg-subtle);
  color: var(--text-primary);
  border: 1px solid var(--border-medium);
  border-bottom-right-radius: var(--radius-xs);
  box-shadow: var(--shadow-xs);
}

.msg-sender-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 3px;
  color: var(--text-muted);
}

.msg-content {
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.msg-meta {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  text-align: right;
}

/* Sticky Composer */
.chat-composer-wrap {
  padding: 10px 14px 12px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.chat-composer-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.composer-input-row {
  display: flex;
  gap: 8px;
}

.composer-input {
  flex: 1;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-size: 13px;
  transition: all var(--duration-fast) var(--ease-apple);
}

.composer-input:focus {
  background: var(--bg-surface);
  border-color: var(--brand-primary);
  box-shadow: var(--shadow-focus);
  outline: none;
}

.composer-send-btn {
  padding: 0 15px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  font-size: 13px;
}

.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.composer-tools-left {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-composer-tool {
  padding: 3px 8px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-apple);
}

.btn-composer-tool:hover {
  background: var(--bg-subtle);
  border-color: var(--border-subtle);
  color: var(--text-primary);
}

.composer-hint {
  font-size: 10.5px;
  color: var(--text-muted);
}

/* --- COLUMN 3: CUSTOMER CONTEXT INSPECTOR --- */
.chat-inspector {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  height: 100%;
  overflow: hidden;
  min-width: 0;
}

.inspector-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.inspector-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.2px;
  margin: 0;
}

.btn-close-inspector {
  display: none;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  background: none;
  border: none;
  transition: all var(--duration-fast) var(--ease-apple);
}

.btn-close-inspector:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.inspector-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.inspector-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 10px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12.5px;
}

.empty-icon-sm {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-lg);
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}

.empty-icon-sm svg {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  stroke-width: 1.75;
}

.inspector-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.inspector-card.score-card {
  padding: 11px;
  background: var(--bg-subtle);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.score-card-header {
  display: flex;
  align-items: center;
  gap: 9px;
}

.score-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background: var(--brand-light);
  color: var(--brand-primary);
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  border: 1px solid var(--brand-border);
  flex-shrink: 0;
}

.score-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.score-name {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

.score-phone {
  font-size: 11px;
  color: var(--text-muted);
}

.score-pill-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 6px;
  border-top: 1px solid var(--border-subtle);
}

.score-numeric {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.inspector-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.6px;
  margin-bottom: 2px;
}

.inspector-detail-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-bottom: 4px;
}

.detail-label {
  font-size: 10.5px;
  color: var(--text-muted);
}

.detail-val {
  font-size: 12px;
  color: var(--text-primary);
  font-weight: 500;
}

.reasons-list {
  font-size: 11.5px;
  color: var(--text-secondary);
  padding-left: 14px;
  margin: 2px 0;
}

.requirement-box {
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-subtle);
  padding: 7px 9px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  line-height: 1.4;
  margin: 0;
}

.ai-recommendation-box {
  display: flex;
  gap: 7px;
  background: var(--brand-light);
  border: 1px solid var(--brand-border);
  padding: 8px 10px;
  border-radius: var(--radius-md);
}

.rec-icon {
  font-size: 13px;
  flex-shrink: 0;
}

.rec-text {
  font-size: 11.5px;
  color: var(--text-primary);
  line-height: 1.4;
  margin: 0;
}

.followup-status-box {
  padding: 8px 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11.5px;
}

.fu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.fu-label {
  color: var(--text-muted);
}

.fu-val {
  font-weight: 600;
  color: var(--text-primary);
}

/* Avatar helper */
.avatar {
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid var(--border-subtle);
}

.avatar-md {
  width: 34px;
  height: 34px;
  font-size: 12px;
}

/* Font mono */
.font-mono {
  font-family: var(--font-mono);
}

/* RESPONSIVENESS for Conversations */
@media (max-width: 1199px) {
  .chat-workspace {
    grid-template-columns: 33% 67%;
  }

  .chat-inspector {
    display: none;
    position: fixed;
    top: var(--topbar-height);
    right: 0;
    bottom: 0;
    width: 300px;
    z-index: 100;
    box-shadow: var(--shadow-lg);
    border-left: 1px solid var(--border-medium);
  }

  .chat-inspector.drawer-open {
    display: flex;
  }

  .btn-close-inspector {
    display: flex;
  }
}

@media (max-width: 767px) {
  .chat-workspace {
    grid-template-columns: 1fr;
    height: calc(100vh - var(--topbar-height));
    border-radius: 0;
    border: none;
  }

  .chat-sidebar.mobile-hidden {
    display: none;
  }

  .chat-main.mobile-hidden {
    display: none;
  }

  .mobile-back-btn {
    display: inline-flex !important;
  }
}

@media (min-width: 768px) {
  .mobile-back-btn {
    display: none !important;
  }
}

/* ==========================================================================
   GROUPED SETTINGS SECTIONS (Business Profile, AI Settings, etc.)
   ========================================================================== */

.settings-group {
  margin-bottom: 24px;
}

.settings-group:last-child {
  margin-bottom: 0;
}

.settings-group-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.settings-group-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

.settings-group-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Sticky save bar at bottom of settings forms */
.settings-save-bar {
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin: 0 -20px -20px;
}

/* ==========================================================================
   FAQ ACCORDION
   ========================================================================== */

.faq-list {
  display: flex;
  flex-direction: column;
}

.faq-item {
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.faq-item:last-child {
  border-bottom: none;
}

.faq-question-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-apple);
  gap: 12px;
}

.faq-question-row:hover {
  background: var(--bg-hover);
}

.faq-question-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.faq-question-text {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
}

.faq-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.faq-chevron {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  transition: transform var(--duration-fast) var(--ease-apple);
  flex-shrink: 0;
}

.faq-chevron svg {
  width: 16px;
  height: 16px;
  stroke-width: 2;
}

.faq-item.open .faq-chevron {
  transform: rotate(180deg);
}

.faq-answer-wrap {
  display: none;
  padding: 0 16px 14px;
  background: var(--bg-subtle);
  border-top: 1px solid var(--border-subtle);
}

.faq-item.open .faq-answer-wrap {
  display: block;
}

.faq-answer-text {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  padding: 12px 0 8px;
}

.faq-actions {
  display: flex;
  gap: 6px;
  padding-top: 8px;
}

/* ==========================================================================
   BUSINESS HOURS DAY ROWS
   ========================================================================== */

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

.hours-day-row {
  display: grid;
  grid-template-columns: 120px 1fr 110px 110px auto;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--duration-fast) var(--ease-apple);
}

.hours-day-row:last-child {
  border-bottom: none;
}

.hours-day-row.is-closed {
  opacity: 0.6;
}

.hours-day-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.hours-status-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.hours-status-toggle input[type="checkbox"] {
  accent-color: var(--brand-primary);
}

.hours-time-input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font-mono);
  outline: none;
  transition: border-color var(--duration-fast) var(--ease-apple);
}

.hours-time-input:focus {
  border-color: var(--brand-primary);
  box-shadow: var(--shadow-focus);
}

.hours-time-input:disabled {
  opacity: 0.4;
  background: var(--bg-subtle);
  cursor: not-allowed;
}

/* ==========================================================================
   WHATSAPP CONNECTION — Trust-First Presentation
   ========================================================================== */

.wa-connection-hero {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

.wa-status-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--status-success-light);
  border: 1px solid var(--status-success-border);
  color: var(--status-success);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wa-status-icon.status-disconnected {
  background: var(--bg-subtle);
  border-color: var(--border-medium);
  color: var(--text-muted);
}

.wa-status-icon svg {
  width: 22px;
  height: 22px;
  stroke-width: 2;
}

.wa-status-content {
  flex: 1;
}

.wa-status-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.wa-status-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.wa-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  padding: 16px 20px;
}

.wa-detail-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wa-detail-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.wa-detail-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.wa-detail-value.font-mono {
  font-family: var(--font-mono);
  font-size: 12px;
}

.wa-tech-details {
  border-top: 1px solid var(--border-subtle);
  margin-top: 4px;
}

.wa-tech-summary {
  padding: 10px 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color var(--duration-fast) var(--ease-apple);
}

.wa-tech-summary:hover {
  color: var(--text-primary);
}

.wa-tech-body {
  padding: 0 20px 16px;
}

.meta-status-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.meta-status-table td {
  padding: 6px 0;
  vertical-align: top;
}

.meta-status-table td:first-child {
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  padding-right: 16px;
  width: 140px;
}

.meta-status-table td:last-child {
  color: var(--text-primary);
  font-weight: 500;
  font-family: var(--font-mono);
  font-size: 11.5px;
  word-break: break-all;
}

.coexistence-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--status-success-light);
  color: var(--status-success);
  border: 1px solid var(--status-success-border);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
}

.coexistence-feature-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0 0;
}

.coexistence-feature-list li {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.whatsapp-connect-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 18px;
  align-items: flex-start;
}

/* ==========================================================================
   FOLLOW-UP ENGINE
   ========================================================================== */

.fu-header-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: var(--shadow-xs);
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.fu-header-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.fu-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.fu-badge-magic {
  background: var(--status-purple-light);
  color: var(--status-purple);
  border: 1px solid var(--status-purple-border);
}

.fu-badge-status {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.fu-badge-dot-green {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--status-success);
}

.fu-badge-dot-purple {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--status-purple);
}

.fu-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* KPI GRID - fix class mismatch (support both fu-kpi-title and fu-kpi-label) */
.fu-kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.fu-kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px;
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  transition: all var(--duration-fast) var(--ease-apple);
}

.fu-kpi-card:hover {
  transform: translateY(-1px);
  border-color: var(--border-medium);
  box-shadow: var(--shadow-sm);
}

.fu-kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

/* Both class names work */
.fu-kpi-title, .fu-kpi-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.fu-kpi-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

.fu-kpi-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
  margin-bottom: 2px;
  letter-spacing: -0.6px;
}

.fu-kpi-subtext {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* KPI card accent colors */
.kpi-hot .fu-kpi-icon { background: var(--status-danger-light); }
.kpi-due .fu-kpi-icon { background: var(--status-warning-light); }
.kpi-replies .fu-kpi-icon { background: var(--brand-light); }
.kpi-recovered .fu-kpi-icon { background: var(--status-success-light); }
.kpi-active .fu-kpi-icon { background: var(--status-purple-light); }
.kpi-sent .fu-kpi-icon { background: var(--status-info-light); }

/* SEGMENTED NAV */
.fu-nav-wrapper {
  margin-bottom: 16px;
}

.fu-segmented-nav {
  display: inline-flex;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
  flex-wrap: wrap;
}

.fu-nav-tab {
  padding: 6px 13px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all var(--duration-fast) var(--ease-apple);
}

.fu-nav-tab-icon {
  font-size: 13px;
}

.fu-nav-tab:hover {
  color: var(--text-primary);
}

.fu-nav-tab.active {
  background: var(--bg-surface);
  color: var(--brand-primary);
  box-shadow: var(--shadow-xs);
}

/* MAGIC MODE SECTION */
.magic-mode-section {
  background: var(--bg-surface);
  border: 1px solid var(--status-purple-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 20px;
}

.magic-mode-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--status-purple-light);
  border-bottom: 1px solid var(--status-purple-border);
}

.magic-mode-title-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.magic-mode-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.magic-mode-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
  max-width: 500px;
}

.magic-mode-capabilities {
  padding: 12px 20px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--status-purple-border);
  background: var(--status-purple-light);
}

.magic-cap-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--status-purple);
  font-weight: 600;
}

.magic-mode-form-body {
  padding: 20px;
}

/* Sequences Grid */
.sequences-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.sequence-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-xs);
  transition: all var(--duration-fast) var(--ease-apple);
}

.sequence-card:hover {
  border-color: var(--border-medium);
  box-shadow: var(--shadow-sm);
}

.sequence-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 8px;
}

.sequence-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.sequence-card-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.45;
}

.sequence-step-pill-list {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.sequence-step-pill {
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  font-size: 11px;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* --- KNOWLEDGE BASE PROGRESS CARD --- */
.setup-progress-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-xs);
}

.setup-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.setup-progress-bar-bg {
  width: 100%;
  height: 6px;
  background: var(--bg-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.setup-progress-bar-fill {
  height: 100%;
  background: var(--brand-primary);
  border-radius: var(--radius-full);
  transition: width var(--duration-smooth) var(--ease-apple);
}

/* AI USAGE PROGRESS BARS */
.usage-progress-wrap {
  background: var(--bg-subtle);
  height: 8px;
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: 6px;
  margin-bottom: 4px;
}

.usage-progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width var(--duration-smooth) var(--ease-apple);
}

/* ==========================================================================
   7. MODALS & DIALOGS
   ========================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  animation: modalFadeIn 0.18s var(--ease-apple) forwards;
}

.modal-card {
  width: 100%;
  max-width: 540px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  overflow: hidden;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: modalScaleIn 0.2s var(--ease-apple) forwards;
}

.modal-card.modal-lg {
  max-width: 760px;
}

.modal-card form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.modal-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 18px;
  transition: all var(--duration-fast) var(--ease-apple);
  cursor: pointer;
}

.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.modal-body {
  padding: 22px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
  min-height: 0;
}

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

/* ==========================================================================
   CARD & TABLE RESPONSIVE UTILITIES
   ========================================================================== */

.desktop-only-table {
  display: block;
  width: 100%;
}

.mobile-only-cards {
  display: none;
}

.mobile-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
  transition: all var(--duration-fast) var(--ease-apple);
}

.mobile-card:hover {
  border-color: var(--border-medium);
  box-shadow: var(--shadow-md);
}

.mobile-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.mobile-card-title-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.mobile-card-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.2px;
  margin: 0;
  word-break: break-word;
}

.mobile-card-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex-shrink: 0;
}

.mobile-card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.45;
  margin: 0;
}

.mobile-card-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.mobile-card-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mobile-card-meta-item .meta-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
}

.mobile-card-meta-item .meta-value {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.mobile-pricing-hero {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 2px 0;
}

.mobile-pricing-hero .mobile-price {
  font-size: 18px;
  font-weight: 800;
  color: var(--brand-primary);
}

.mobile-pricing-hero .mobile-billing-type {
  font-size: 12px;
  color: var(--text-muted);
}

.mobile-card-features-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mobile-card-features-list li {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.35;
}

.mobile-card-features-text {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.35;
  white-space: pre-wrap;
}

.mobile-card-callout {
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-primary);
  background: var(--bg-subtle);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--brand-primary);
}

.mobile-card-action-note {
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--status-info);
  background: rgba(37, 99, 235, 0.08);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
}

.mobile-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.mobile-card-actions .btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

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

@keyframes modalScaleIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

/* ==========================================================================
   8. TOAST SYSTEM
   ========================================================================== */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  padding: 11px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  animation: toastSlideUp 0.22s var(--ease-apple) forwards;
  max-width: 320px;
}

.toast-success {
  border-left: 3px solid var(--status-success);
}

.toast-error, .toast-danger {
  border-left: 3px solid var(--status-danger);
}

.toast-warning {
  border-left: 3px solid var(--status-warning);
}

.toast-info {
  border-left: 3px solid var(--status-info);
}

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

/* ==========================================================================
   9. RESPONSIVE BREAKPOINTS
   ========================================================================== */

.mobile-menu-btn {
  display: none;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  font-size: 16px;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 35;
}

@media (max-width: 1280px) {
  .fu-kpi-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .whatsapp-connect-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1024px) {
  .overview-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 768px) {
  .mobile-menu-btn {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
    z-index: 900;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar-backdrop.mobile-open {
    display: block;
    z-index: 850;
  }

  .desktop-only-table {
    display: none !important;
  }

  .mobile-only-cards {
    display: flex !important;
    flex-direction: column;
    gap: 12px;
    padding: 14px 14px 20px;
  }

  .fu-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .top-header {
    padding: 0 14px;
    height: 56px;
  }

  .header-titles .page-title {
    font-size: 17px;
  }

  .header-titles .page-subtitle {
    display: none;
  }

  .content-container {
    padding: 12px;
  }

  .leads-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 12px 14px;
  }

  .leads-toolbar .search-box {
    width: 100%;
    min-width: 0;
  }

  .leads-filters {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .leads-filters .checkbox-label {
    grid-column: 1 / -1;
    margin-top: 2px;
  }

  /* MODAL AS BOTTOM SHEET ON MOBILE */
  .modal-overlay {
    align-items: flex-end !important;
    padding: 0 !important;
    z-index: 1000 !important;
  }

  .modal-card {
    border-radius: 20px 20px 0 0 !important;
    max-height: 90dvh !important;
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    box-shadow: 0 -12px 48px rgba(0, 0, 0, 0.45) !important;
    border-bottom: none !important;
    animation: modalSlideUpMobile 0.24s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
  }

  .modal-card.modal-lg {
    max-width: 100% !important;
  }

  .modal-card::before {
    content: '';
    display: block;
    width: 38px;
    height: 4.5px;
    border-radius: 4px;
    background: var(--border-medium);
    margin: 10px auto 2px;
    flex-shrink: 0;
  }

  .modal-header {
    padding: 12px 18px !important;
    border-bottom: 1px solid var(--border-subtle) !important;
  }

  .modal-header h3 {
    font-size: 15.5px !important;
  }

  .modal-body {
    padding: 16px 18px !important;
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    min-height: 0 !important;
  }

  .modal-footer {
    position: sticky !important;
    bottom: 0 !important;
    z-index: 20 !important;
    flex-shrink: 0 !important;
    background: var(--bg-elevated) !important;
    padding: 12px 18px !important;
    padding-bottom: max(14px, var(--sab)) !important;
    border-top: 1px solid var(--border-subtle) !important;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06) !important;
  }

  .modal-footer .btn {
    min-height: 44px !important;
    padding: 10px 18px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
  }

  /* Form controls inside modals on mobile */
  .modal-body .form-input,
  .modal-body .form-select,
  .modal-body .form-textarea {
    font-size: 16px !important; /* Prevents iOS Safari auto-zoom on input focus */
    min-height: 44px;
  }

  .modal-body .form-textarea {
    min-height: 72px;
  }

  /* CONVERSATIONS ON MOBILE */
  .chat-workspace {
    grid-template-columns: 1fr;
    height: calc(100dvh - 56px);
    border-radius: 0;
    border: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .chat-sidebar {
    height: 100%;
    display: flex;
    flex-direction: column;
  }

  .chat-sidebar.mobile-hidden {
    display: none !important;
  }

  .chat-main {
    height: 100%;
    display: flex;
    flex-direction: column;
  }

  .chat-main.mobile-hidden {
    display: none !important;
  }

  .chat-thread-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
  }

  .chat-thread-header {
    padding: 8px 12px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
  }

  .chat-header-customer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 8px;
  }

  .chat-customer-details {
    flex: 1;
    min-width: 0;
  }

  .active-customer-name {
    font-size: 14px;
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .chat-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  .chat-header-actions::-webkit-scrollbar {
    display: none;
  }

  .chat-header-actions .btn {
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 11.5px;
    padding: 5px 10px;
    min-height: 34px;
  }

  .messages-stream {
    flex: 1 1 auto;
    min-height: 0;
    padding: 12px;
    gap: 8px;
  }

  .msg-bubble {
    max-width: 86%;
    font-size: 13.5px;
    padding: 9px 12px;
  }

  .chat-composer-wrap {
    padding: 8px 12px;
    padding-bottom: max(10px, var(--sab));
  }

  .composer-input-row {
    display: flex;
    gap: 6px;
  }

  .composer-input {
    font-size: 16px !important;
    min-height: 44px;
  }

  .composer-send-btn {
    min-height: 44px;
    min-width: 58px;
    padding: 0 14px;
  }

  .chat-inspector {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(340px, 92vw);
    z-index: 1200;
    box-shadow: var(--shadow-modal);
    border-left: 1px solid var(--border-medium);
    background: var(--bg-surface);
    transform: translateX(100%);
    transition: transform 0.25s var(--ease-apple);
  }

  .chat-inspector.drawer-open {
    display: flex;
    transform: translateX(0);
  }

  .fu-header-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .fu-segmented-nav {
    width: 100%;
    overflow-x: auto;
  }

  .fu-nav-tab {
    flex: 1;
    justify-content: center;
    white-space: nowrap;
  }

  .status-indicator-group {
    display: none;
  }

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

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

  .hours-day-row {
    grid-template-columns: 100px 1fr 90px 90px;
  }

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

@media (max-width: 480px) {
  .fu-kpi-grid {
    grid-template-columns: 1fr;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .metric-card {
    padding: 12px;
  }

  .metric-value {
    font-size: 20px;
  }

  .hours-day-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .leads-filters {
    grid-template-columns: 1fr;
  }

  .active-customer-name {
    max-width: 120px;
  }
}

@media (max-width: 360px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .mobile-card {
    padding: 12px;
  }

  .modal-header h3 {
    font-size: 14px !important;
  }

  .active-customer-name {
    max-width: 95px;
  }
}

@keyframes modalSlideUpMobile {
  from {
    transform: translateY(100%);
    opacity: 0.5;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ==========================================================================
   10. ACCESSIBILITY & REDUCED MOTION
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Focus visibility */
:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}
