/* ============================================================
   InWorkflo Client Dashboard — Premium Design System v2
   Dark glassmorphic theme · Animated surfaces · Rich depth
   ============================================================ */

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

/* ── Keyframe Animations ──────────────────────────────────── */

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

@keyframes gradient-shift {
  0%   { background-position: 0% 50%; }
  25%  { background-position: 50% 100%; }
  50%  { background-position: 100% 50%; }
  75%  { background-position: 50% 0%; }
  100% { background-position: 0% 50%; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes shimmer {
  0%   { left: -100%; }
  100% { left: 200%; }
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25%      { transform: translate(30px, -40px) scale(1.05); }
  50%      { transform: translate(-20px, -70px) scale(0.95); }
  75%      { transform: translate(-40px, -20px) scale(1.02); }
}

@keyframes pulse-glow {
  0%, 100% { opacity: 1; box-shadow: 0 0 4px currentColor; }
  50%      { opacity: 0.6; box-shadow: 0 0 10px currentColor; }
}

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

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

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

@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(0.75); }
}

@keyframes stat-entrance {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes border-glow-pulse {
  0%, 100% { border-color: rgba(91, 7, 154, 0.2); }
  50%      { border-color: rgba(168, 85, 247, 0.35); }
}

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  /* Backgrounds – richer darks with subtle warmth */
  --bg-primary: hsl(232, 25%, 5%);
  --bg-secondary: hsl(232, 22%, 7%);
  --bg-surface: hsla(232, 25%, 10%, 0.72);
  --bg-surface-hover: hsla(232, 22%, 14%, 0.82);
  --bg-elevated: hsla(234, 24%, 16%, 0.65);
  --bg-sidebar: hsla(232, 30%, 5%, 0.96);
  --bg-header: hsla(232, 28%, 6%, 0.65);

  /* Glassmorphism surfaces */
  --glass-bg: hsla(232, 22%, 12%, 0.55);
  --glass-bg-hover: hsla(232, 22%, 16%, 0.65);
  --glass-border: hsla(0, 0%, 100%, 0.07);
  --glass-blur: 20px;
  --glass-bg-strong: hsla(232, 22%, 10%, 0.8);

  /* Borders */
  --border-subtle: hsla(0, 0%, 100%, 0.04);
  --border-default: hsla(0, 0%, 100%, 0.07);
  --border-hover: hsla(0, 0%, 100%, 0.13);
  --border-accent: hsla(276, 91%, 32%, 0.35);
  --border-glow: hsla(270, 100%, 65%, 0.18);

  /* Text */
  --text-primary: hsl(220, 30%, 93%);
  --text-secondary: hsl(220, 15%, 58%);
  --text-muted: hsl(220, 12%, 38%);
  --text-inverse: hsl(232, 25%, 5%);

  /* Accent Gradient – brand purples */
  --accent-start: #5B079A;
  --accent-mid: #7B2FBE;
  --accent-end: #A855F7;
  --gradient-accent: linear-gradient(135deg, var(--accent-start), var(--accent-mid), var(--accent-end));
  --gradient-accent-soft: linear-gradient(135deg, hsla(276, 91%, 32%, 0.14), hsla(270, 92%, 67%, 0.14));
  --gradient-accent-vertical: linear-gradient(180deg, var(--accent-start), var(--accent-end));

  /* Score Colors */
  --color-hot: #ef4444;
  --color-hot-bg: hsla(0, 84%, 60%, 0.11);
  --color-warm: #f59e0b;
  --color-warm-bg: hsla(38, 92%, 50%, 0.11);
  --color-cool: #3b82f6;
  --color-cool-bg: hsla(217, 91%, 60%, 0.11);
  --color-cold: #6b7280;
  --color-cold-bg: hsla(220, 9%, 46%, 0.11);

  /* Status Colors */
  --status-new: #818cf8;
  --status-new-bg: hsla(235, 90%, 75%, 0.11);
  --status-responded: #34d399;
  --status-responded-bg: hsla(160, 60%, 52%, 0.11);
  --status-qualified: #fbbf24;
  --status-qualified-bg: hsla(45, 97%, 56%, 0.11);
  --status-handed-over: #22d3ee;
  --status-handed-over-bg: hsla(188, 82%, 53%, 0.11);
  --status-stale: #f97316;
  --status-stale-bg: hsla(25, 95%, 53%, 0.11);
  --status-disqualified: #ef4444;
  --status-disqualified-bg: hsla(0, 84%, 60%, 0.11);

  /* Source Colors */
  --source-whatsapp: #25d366;
  --source-meta: #1877f2;
  --source-web: #a78bfa;
  --source-csv: #f472b6;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Shadows – layered for depth */
  --shadow-sm: 0 1px 2px hsla(0, 0%, 0%, 0.25), 0 1px 3px hsla(0, 0%, 0%, 0.15);
  --shadow-md: 0 4px 6px hsla(0, 0%, 0%, 0.3), 0 2px 10px hsla(0, 0%, 0%, 0.2);
  --shadow-lg: 0 10px 25px hsla(0, 0%, 0%, 0.4), 0 4px 12px hsla(0, 0%, 0%, 0.25);
  --shadow-xl: 0 20px 50px hsla(0, 0%, 0%, 0.5), 0 8px 20px hsla(0, 0%, 0%, 0.3);
  --shadow-glow: 0 0 20px hsla(276, 91%, 32%, 0.18), 0 0 40px hsla(276, 91%, 32%, 0.06);
  --shadow-glow-strong: 0 0 30px hsla(276, 91%, 32%, 0.3), 0 0 60px hsla(276, 91%, 32%, 0.1);

  /* Skeleton loading */
  --skeleton-base: hsla(232, 22%, 14%, 0.6);
  --skeleton-shimmer: linear-gradient(90deg, transparent 0%, hsla(0, 0%, 100%, 0.04) 40%, hsla(0, 0%, 100%, 0.08) 50%, hsla(0, 0%, 100%, 0.04) 60%, transparent 100%);

  /* Layout */
  --sidebar-width: 240px;
  --header-height: 64px;

  /* Transitions – refined easing */
  --transition-fast: 150ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --transition-base: 250ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --transition-slow: 400ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Light Mode Override ─────────────────────────────────────── */
body.light-mode {
  /* Backgrounds */
  --bg-primary: hsl(220, 25%, 96%);
  --bg-secondary: hsl(0, 0%, 100%);
  --bg-surface: hsla(0, 0%, 100%, 0.88);
  --bg-surface-hover: hsla(220, 25%, 96%, 0.92);
  --bg-elevated: hsla(0, 0%, 100%, 0.95);
  --bg-sidebar: hsl(220, 25%, 93%);
  --bg-header: hsla(0, 0%, 100%, 0.82);

  /* Glassmorphism */
  --glass-bg: hsla(0, 0%, 100%, 0.65);
  --glass-bg-hover: hsla(0, 0%, 100%, 0.8);
  --glass-border: hsla(0, 0%, 0%, 0.06);
  --glass-bg-strong: hsla(0, 0%, 100%, 0.88);

  /* Borders */
  --border-subtle: hsla(0, 0%, 0%, 0.04);
  --border-default: hsla(0, 0%, 0%, 0.08);
  --border-hover: hsla(0, 0%, 0%, 0.14);
  --border-accent: hsla(276, 91%, 32%, 0.2);
  --border-glow: hsla(270, 100%, 65%, 0.12);

  /* Text */
  --text-primary: hsl(215, 28%, 17%);
  --text-secondary: hsl(215, 16%, 47%);
  --text-muted: hsl(215, 13%, 60%);
  --text-inverse: hsl(0, 0%, 98%);

  /* Shadows – lighter */
  --shadow-sm: 0 1px 2px hsla(0, 0%, 0%, 0.06);
  --shadow-md: 0 4px 12px hsla(0, 0%, 0%, 0.08);
  --shadow-lg: 0 8px 24px hsla(0, 0%, 0%, 0.1);
  --shadow-xl: 0 16px 40px hsla(0, 0%, 0%, 0.12);
  --shadow-glow: 0 0 20px hsla(276, 91%, 50%, 0.1);

  /* Skeleton */
  --skeleton-base: hsla(220, 15%, 90%, 0.7);
  --skeleton-shimmer: linear-gradient(90deg, transparent 0%, hsla(0, 0%, 100%, 0.5) 40%, hsla(0, 0%, 100%, 0.8) 50%, hsla(0, 0%, 100%, 0.5) 60%, transparent 100%);
}

body.light-mode::after {
  background-image: radial-gradient(hsla(0, 0%, 0%, 0.04) 1px, transparent 1px);
}

body.light-mode ::-webkit-scrollbar-thumb {
  background: hsla(0, 0%, 0%, 0.12);
}

body.light-mode ::-webkit-scrollbar-thumb:hover {
  background: hsla(0, 0%, 0%, 0.2);
}

/* ── Theme Toggle Button ── */
.theme-toggle-btn {
  background: var(--glass-bg);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  border-radius: var(--radius-full);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-left: 12px;
  font-size: 16px;
  backdrop-filter: blur(8px);
}

.theme-toggle-btn:hover {
  background: var(--glass-bg-hover);
  border-color: var(--border-hover);
  transform: rotate(15deg);
}

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

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
}

/* Dot pattern background */
body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: radial-gradient(hsla(0, 0%, 100%, 0.025) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
  z-index: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: hsla(0, 0%, 100%, 0.07);
  border-radius: var(--radius-full);
  transition: background 0.2s;
}

::-webkit-scrollbar-thumb:hover {
  background: hsla(0, 0%, 100%, 0.15);
}

/* ── App Layout ────────────────────────────────────────────── */
.app {
  display: flex;
  height: 100vh;
  position: relative;
  z-index: 1;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  padding: var(--space-lg) 0;
  position: relative;
  z-index: 10;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

/* Subtle inner glow on sidebar right edge */
.sidebar::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 1px;
  background: linear-gradient(
    180deg,
    transparent 0%,
    hsla(270, 100%, 65%, 0.08) 30%,
    hsla(270, 100%, 65%, 0.12) 50%,
    hsla(270, 100%, 65%, 0.08) 70%,
    transparent 100%
  );
  pointer-events: none;
}

.sidebar-brand {
  padding: 0 var(--space-lg);
  margin-bottom: var(--space-2xl);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.sidebar-brand .brand-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--gradient-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 2px 10px hsla(276, 91%, 32%, 0.35);
}

.sidebar-brand .brand-text {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: 0 var(--space-sm);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 13px;
  font-weight: 500;
  user-select: none;
  position: relative;
  border: 1px solid transparent;
}

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

.nav-item.active {
  color: var(--text-primary);
  background: linear-gradient(135deg, hsla(276, 91%, 32%, 0.08), hsla(270, 92%, 67%, 0.06));
  border: 1px solid var(--border-accent);
}

/* Active left accent bar */
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  background: var(--gradient-accent-vertical);
  border-radius: var(--radius-full);
  box-shadow: 0 0 8px hsla(276, 91%, 32%, 0.4);
}

.nav-icon {
  font-size: 18px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--gradient-accent);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  min-width: 20px;
  text-align: center;
  box-shadow: 0 2px 6px hsla(276, 91%, 32%, 0.3);
}

.sidebar-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border-subtle);
  margin-top: auto;
}

.sidebar-client {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.sidebar-client:hover {
  background: var(--bg-surface-hover);
}

.client-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--gradient-accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-end);
  flex-shrink: 0;
  border: 1px solid var(--border-accent);
}

.client-info {
  overflow: hidden;
}

.client-name {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.client-plan {
  font-size: 10px;
  color: var(--text-muted);
}

/* ── Main Content ──────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Header */
.header {
  height: var(--header-height);
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-xl);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-header);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.header-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.header-search {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--glass-bg);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  width: 220px;
  transition: all var(--transition-base);
  backdrop-filter: blur(8px);
}

.header-search:focus-within {
  border-color: var(--accent-mid);
  box-shadow: 0 0 0 3px hsla(276, 70%, 50%, 0.12), var(--shadow-glow);
  width: 280px;
}

.header-search input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  width: 100%;
}

.header-search input::placeholder {
  color: var(--text-muted);
}

.header-search .search-icon {
  color: var(--text-muted);
  font-size: 14px;
  flex-shrink: 0;
}

/* Live badge */
.live-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #34d399;
  background: hsla(160, 60%, 52%, 0.08);
  border: 1px solid hsla(160, 60%, 52%, 0.15);
  padding: 4px 12px;
  border-radius: var(--radius-full);
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34d399;
  animation: pulse-dot 2s ease-in-out infinite;
  box-shadow: 0 0 6px hsla(160, 60%, 52%, 0.4);
}

/* ── Content Area ──────────────────────────────────────────── */
.content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-xl);
}

/* ── Cards – Glassmorphic ──────────────────────────────────── */
.card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  transition: all var(--transition-base);
  position: relative;
}

.card:hover {
  border-color: var(--border-glow);
  box-shadow: var(--shadow-md), 0 0 20px hsla(270, 100%, 65%, 0.04);
}

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

.card-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.card-body {
  padding: var(--space-lg);
  overflow: hidden;
}

/* ── Stat Cards – Enhanced ─────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.stat-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
  animation: stat-entrance 0.5s cubic-bezier(0.16, 1, 0.3, 1) backwards;
  /* Gradient left border accent */
  border-left: 3px solid transparent;
  border-image: var(--gradient-accent-vertical) 1;
  border-image-slice: 1;
  border-image-width: 0 0 0 3px;
}

.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.1s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:nth-child(4) { animation-delay: 0.2s; }

/* Top gradient line on hover */
.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--gradient-accent);
  opacity: 0;
  transition: opacity var(--transition-base);
}

/* Subtle radial glow in top-right corner */
.stat-card::after {
  content: '';
  position: absolute;
  top: -30px;
  right: -30px;
  width: 80px;
  height: 80px;
  background: radial-gradient(circle, hsla(270, 92%, 67%, 0.06) 0%, transparent 70%);
  border-radius: 50%;
  opacity: 0;
  transition: opacity var(--transition-slow);
  pointer-events: none;
}

.stat-card:hover {
  border-color: var(--border-glow);
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg), 0 0 24px hsla(276, 91%, 32%, 0.08);
}

.stat-card:hover::before {
  opacity: 1;
}

.stat-card:hover::after {
  opacity: 1;
}

.stat-icon {
  font-size: 20px;
  margin-bottom: var(--space-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--gradient-accent-soft);
  border: 1px solid hsla(270, 92%, 67%, 0.08);
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.stat-change {
  font-size: 11px;
  font-weight: 600;
  margin-top: var(--space-sm);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.stat-change.positive {
  color: #34d399;
  background: hsla(160, 60%, 52%, 0.1);
}

.stat-change.negative {
  color: #ef4444;
  background: hsla(0, 84%, 60%, 0.1);
}

/* ── Score Badge ───────────────────────────────────────────── */
.score-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.score-badge.hot {
  color: var(--color-hot);
  background: var(--color-hot-bg);
  border: 1px solid hsla(0, 84%, 60%, 0.2);
}

.score-badge.warm {
  color: var(--color-warm);
  background: var(--color-warm-bg);
  border: 1px solid hsla(38, 92%, 50%, 0.2);
}

.score-badge.cool {
  color: var(--color-cool);
  background: var(--color-cool-bg);
  border: 1px solid hsla(217, 91%, 60%, 0.2);
}

.score-badge.cold {
  color: var(--color-cold);
  background: var(--color-cold-bg);
  border: 1px solid hsla(220, 9%, 46%, 0.2);
}

/* ── Status Pill – Vibrant with glow ──────────────────────── */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  transition: box-shadow var(--transition-fast);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.status-pill.new {
  color: var(--status-new);
  background: var(--status-new-bg);
  box-shadow: 0 0 8px hsla(235, 90%, 75%, 0.1);
}
.status-pill.new .status-dot { background: var(--status-new); box-shadow: 0 0 4px var(--status-new); }

.status-pill.responded {
  color: var(--status-responded);
  background: var(--status-responded-bg);
  box-shadow: 0 0 8px hsla(160, 60%, 52%, 0.1);
}
.status-pill.responded .status-dot { background: var(--status-responded); box-shadow: 0 0 4px var(--status-responded); }

.status-pill.qualified {
  color: var(--status-qualified);
  background: var(--status-qualified-bg);
  box-shadow: 0 0 8px hsla(45, 97%, 56%, 0.1);
}
.status-pill.qualified .status-dot { background: var(--status-qualified); box-shadow: 0 0 4px var(--status-qualified); }

.status-pill.handed_over,
.status-pill.handed-over {
  color: var(--status-handed-over);
  background: var(--status-handed-over-bg);
  box-shadow: 0 0 8px hsla(188, 82%, 53%, 0.1);
}
.status-pill.handed_over .status-dot,
.status-pill.handed-over .status-dot { background: var(--status-handed-over); box-shadow: 0 0 4px var(--status-handed-over); }

.status-pill.stale {
  color: var(--status-stale);
  background: var(--status-stale-bg);
  box-shadow: 0 0 8px hsla(25, 95%, 53%, 0.1);
}
.status-pill.stale .status-dot { background: var(--status-stale); box-shadow: 0 0 4px var(--status-stale); }

.status-pill.disqualified {
  color: var(--status-disqualified);
  background: var(--status-disqualified-bg);
  box-shadow: 0 0 8px hsla(0, 84%, 60%, 0.1);
}
.status-pill.disqualified .status-dot { background: var(--status-disqualified); box-shadow: 0 0 4px var(--status-disqualified); }

/* ── Source Badge ──────────────────────────────────────────── */
.source-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
}

.source-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.source-dot.whatsapp { background: var(--source-whatsapp); box-shadow: 0 0 4px hsla(142, 70%, 49%, 0.3); }
.source-dot.meta_ads,
.source-dot.meta-ads { background: var(--source-meta); box-shadow: 0 0 4px hsla(214, 89%, 52%, 0.3); }
.source-dot.web_form,
.source-dot.web-form { background: var(--source-web); box-shadow: 0 0 4px hsla(259, 94%, 76%, 0.3); }
.source-dot.csv_import,
.source-dot.csv-import { background: var(--source-csv); box-shadow: 0 0 4px hsla(330, 86%, 70%, 0.3); }

/* ── Data Table – Polished ─────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.data-table thead th {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: var(--space-md) var(--space-md);
  border-bottom: 1px solid var(--border-default);
  text-align: left;
  position: sticky;
  top: 0;
  background: var(--glass-bg-strong);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 2;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: color var(--transition-fast);
}

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

.data-table tbody tr {
  cursor: pointer;
  transition: all var(--transition-fast);
}

.data-table tbody tr:hover {
  background: linear-gradient(90deg, hsla(270, 100%, 65%, 0.04), hsla(232, 22%, 14%, 0.5), transparent);
}

/* Subtle alternating rows */
.data-table tbody tr:nth-child(even) {
  background: hsla(232, 22%, 12%, 0.2);
}

.data-table tbody tr:nth-child(even):hover {
  background: linear-gradient(90deg, hsla(270, 100%, 65%, 0.04), hsla(232, 22%, 14%, 0.5), transparent);
}

.data-table tbody td {
  padding: var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
  white-space: nowrap;
  vertical-align: middle;
  transition: background var(--transition-fast);
}

.lead-name {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.lead-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

.lead-name-text .name {
  font-weight: 600;
  font-size: 13px;
}

.lead-name-text .company {
  font-size: 11px;
  color: var(--text-muted);
}

.score-bar-container {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.score-bar {
  width: 60px;
  height: 5px;
  background: hsla(0, 0%, 100%, 0.05);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
  /* Smooth gradient fills */
  background: linear-gradient(90deg, var(--accent-start), var(--accent-end));
}

.score-value {
  font-size: 12px;
  font-weight: 600;
  width: 32px;
}

.time-ago {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Content Grid ──────────────────────────────────────────── */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--space-md);
}

/* ── Chart Container ───────────────────────────────────────── */
.chart-container {
  position: relative;
  width: 100%;
  height: 220px;
}

.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ── Activity Feed – Refined ───────────────────────────────── */
.activity-feed {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
  transition: all var(--transition-fast);
  position: relative;
  /* Left border accent */
  border-left: 2px solid transparent;
}

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

.activity-item:hover {
  background: var(--bg-surface-hover);
  border-left-color: var(--accent-mid);
}

.activity-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.activity-icon.incoming {
  background: hsla(160, 60%, 52%, 0.1);
  border: 1px solid hsla(160, 60%, 52%, 0.08);
}

.activity-icon.qualified {
  background: hsla(45, 97%, 56%, 0.1);
  border: 1px solid hsla(45, 97%, 56%, 0.08);
}

.activity-icon.meeting {
  background: hsla(188, 82%, 53%, 0.1);
  border: 1px solid hsla(188, 82%, 53%, 0.08);
}

.activity-icon.outreach {
  background: hsla(263, 70%, 58%, 0.1);
  border: 1px solid hsla(263, 70%, 58%, 0.08);
}

.activity-text {
  flex: 1;
  min-width: 0;
}

.activity-text strong {
  font-weight: 600;
}

.activity-text p {
  font-size: 13px;
  line-height: 1.5;
}

.activity-time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── Conversation View ─────────────────────────────────────── */
.conversations-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 0;
  height: calc(100vh - var(--header-height) - var(--space-xl) * 2);
}

.convo-list {
  border-right: 1px solid var(--border-default);
  overflow-y: auto;
}

.convo-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.convo-item:hover {
  background: var(--bg-surface-hover);
}

.convo-item.active {
  background: var(--bg-elevated);
  border-left: 3px solid var(--accent-mid);
}

.convo-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
  background: var(--gradient-accent-soft);
  color: var(--accent-end);
  border: 1px solid var(--border-accent);
}

.convo-content {
  flex: 1;
  min-width: 0;
}

.convo-name {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 2px;
}

.convo-company {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.convo-preview {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.convo-meta {
  text-align: right;
  flex-shrink: 0;
}

.convo-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.convo-channel {
  font-size: 14px;
}

/* Chat Viewer */
.chat-viewer {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.chat-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.chat-header-name {
  font-weight: 700;
  font-size: 15px;
}

.chat-header-detail {
  font-size: 12px;
  color: var(--text-muted);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* Conversation Bubbles – Polished */
.chat-bubble,
.msg-bubble {
  max-width: 70%;
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-lg);
  font-size: 13px;
  line-height: 1.6;
  position: relative;
  animation: bubbleIn 0.3s ease-out;
}

.chat-bubble.lead,
.msg-bubble.received {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  align-self: flex-start;
  border-bottom-left-radius: var(--radius-sm);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.chat-bubble.agent,
.msg-bubble.sent {
  background: linear-gradient(135deg, hsla(276, 91%, 32%, 0.18), hsla(270, 92%, 67%, 0.12));
  border: 1px solid hsla(270, 92%, 67%, 0.2);
  align-self: flex-end;
  border-bottom-right-radius: var(--radius-sm);
  box-shadow: 0 2px 8px hsla(276, 91%, 32%, 0.1);
}

.chat-bubble .bubble-time,
.msg-bubble .bubble-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

.chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  gap: var(--space-md);
}

.chat-empty-icon {
  font-size: 48px;
  opacity: 0.3;
}

/* ── Lead Detail Panel ─────────────────────────────────────── */
.detail-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: hsla(0, 0%, 0%, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

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

.detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 480px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-default);
  z-index: 101;
  transform: translateX(100%);
  transition: transform var(--transition-slow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: -10px 0 40px hsla(0, 0%, 0%, 0.3);
}

.detail-panel.open {
  transform: translateX(0);
}

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

.detail-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--glass-bg);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all var(--transition-fast);
}

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

.detail-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
}

.detail-section {
  margin-bottom: var(--space-xl);
}

.detail-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-md);
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) 0;
}

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

.detail-value {
  font-size: 12px;
  font-weight: 600;
}

/* Score breakdown */
.score-breakdown-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.score-breakdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.score-breakdown-label {
  font-size: 11px;
  color: var(--text-secondary);
  width: 120px;
  flex-shrink: 0;
}

.score-breakdown-bar {
  flex: 1;
  height: 6px;
  background: hsla(0, 0%, 100%, 0.04);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.score-breakdown-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.score-breakdown-value {
  font-size: 11px;
  font-weight: 600;
  width: 30px;
  text-align: right;
}

/* ── Analytics View ────────────────────────────────────────── */
.analytics-hero {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.funnel-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-lg);
}

.funnel-step {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 600;
  transition: all var(--transition-base);
  position: relative;
  text-align: center;
  max-width: 100%;
  box-sizing: border-box;
}

.funnel-step:hover {
  transform: scaleX(1.03);
  filter: brightness(1.1);
}

.funnel-arrow {
  color: var(--text-muted);
  font-size: 16px;
}

.funnel-step .funnel-count {
  font-size: 18px;
  font-weight: 800;
  margin-right: 6px;
}

/* ── Donut Chart ───────────────────────────────────────────── */
.donut-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) 0;
}

.donut-chart-wrapper {
  position: relative;
  width: 110px;
  height: 110px;
  margin: 0 auto;
}

.donut-chart-wrapper canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.donut-center {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}

.donut-center-value {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.donut-center-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.donut-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 5px;
  width: 100%;
}

.donut-legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 12px;
}

.donut-legend-color {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.donut-legend-label {
  color: var(--text-secondary);
  flex: 1;
}

.donut-legend-value {
  font-weight: 600;
}

/* ── Response Time Distribution ────────────────────────────── */
.response-bars {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-md) 0;
}

.response-bar-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.response-bar-label {
  font-size: 12px;
  color: var(--text-secondary);
  width: 90px;
  flex-shrink: 0;
}

.response-bar-track {
  flex: 1;
  height: 8px;
  background: hsla(0, 0%, 100%, 0.03);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.response-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--gradient-accent);
  transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.response-bar-count {
  font-size: 12px;
  font-weight: 600;
  width: 30px;
  text-align: right;
}

/* ── Empty State ───────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl) var(--space-xl);
  color: var(--text-muted);
  text-align: center;
  gap: var(--space-md);
  min-height: 200px;
}

.empty-state-icon {
  font-size: 44px;
  opacity: 0.35;
}

.empty-state p {
  font-size: 14px;
  max-width: 320px;
  line-height: 1.6;
}

/* ── Filter Bar ────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

/* Filter Chips – Pill-shaped with smooth transitions */
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--glass-bg);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  padding: 6px 14px;
  cursor: pointer;
  transition: all var(--transition-base);
  user-select: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.filter-chip:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
  background: var(--glass-bg-hover);
  transform: translateY(-1px);
}

.filter-chip.active {
  background: linear-gradient(135deg, hsla(276, 91%, 32%, 0.16), hsla(270, 92%, 67%, 0.12));
  border-color: var(--border-accent);
  color: var(--accent-end);
  box-shadow: 0 0 12px hsla(276, 91%, 32%, 0.12);
}

/* ── Animation Utility Classes ─────────────────────────────── */
.animate-in {
  animation: slideUp 0.4s ease-out forwards;
}

.animate-in-delay-1 { animation-delay: 0.05s; opacity: 0; }
.animate-in-delay-2 { animation-delay: 0.1s;  opacity: 0; }
.animate-in-delay-3 { animation-delay: 0.15s; opacity: 0; }
.animate-in-delay-4 { animation-delay: 0.2s;  opacity: 0; }

/* ── View Transition ───────────────────────────────────────── */
.view-transition {
  animation: fade-in 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* ── Welcome Header ────────────────────────────────────────── */
.welcome-header {
  margin-bottom: var(--space-xl);
}

.welcome-header h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.welcome-header p {
  font-size: 14px;
  color: var(--text-secondary);
}

/* ── Time Range Filter ─────────────────────────────────────── */
.time-range-filter {
  display: inline-flex;
  background: var(--glass-bg);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  padding: 2px;
  gap: 2px;
}

.time-range-filter button {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.time-range-filter button:hover {
  color: var(--text-primary);
}

.time-range-filter button.active {
  background: var(--gradient-accent);
  color: white;
  box-shadow: 0 2px 6px hsla(276, 91%, 32%, 0.3);
}

/* ── Quick Actions ─────────────────────────────────────────── */
.quick-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.quick-actions button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--glass-bg);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 14px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.quick-actions button:hover {
  background: var(--glass-bg-hover);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.quick-actions button.primary {
  background: var(--gradient-accent);
  border-color: transparent;
  color: white;
}

.quick-actions button.primary:hover {
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}

/* ── Last Synced ───────────────────────────────────────────── */
.last-synced {
  font-size: 11px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ── Skeleton Loading ──────────────────────────────────────── */
.skeleton {
  background: var(--skeleton-base);
  background-image: var(--skeleton-shimmer);
  background-size: 800px 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
  height: 14px;
  width: 100%;
}

.skeleton-circle {
  background: var(--skeleton-base);
  background-image: var(--skeleton-shimmer);
  background-size: 800px 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.skeleton-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.skeleton-card .skeleton:nth-child(1) { width: 40%; height: 12px; }
.skeleton-card .skeleton:nth-child(2) { width: 60%; height: 24px; }
.skeleton-card .skeleton:nth-child(3) { width: 80%; height: 10px; }

/* ── Login Overlay – Redesigned ─────────────────────────────── */
.login-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  background: var(--bg-primary);
  overflow: hidden;
}

/* Gradient mesh background */
.login-overlay::before {
  content: '';
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(ellipse 600px 500px at 20% 30%, rgba(91,7,154,0.3) 0%, transparent 70%),
    radial-gradient(ellipse 500px 400px at 80% 70%, rgba(124,58,237,0.22) 0%, transparent 65%),
    radial-gradient(ellipse 400px 350px at 50% 50%, rgba(168,85,247,0.12) 0%, transparent 60%);
  animation: mesh-drift 25s ease-in-out infinite alternate;
  pointer-events: none;
}

/* Grid pattern overlay */
.login-overlay::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(124, 58, 237, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124, 58, 237, 0.04) 1px, transparent 1px);
  background-size: 64px 64px;
  -webkit-mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, black 20%, transparent 70%);
  mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, black 20%, transparent 70%);
  pointer-events: none;
}

/* Light mode overlay adjustments */
body.light-mode .login-overlay {
  background: #f8f9fc;
}
body.light-mode .login-overlay::before {
  background:
    radial-gradient(ellipse 600px 500px at 20% 30%, rgba(91,7,154,0.08) 0%, transparent 70%),
    radial-gradient(ellipse 500px 400px at 80% 70%, rgba(124,58,237,0.06) 0%, transparent 65%);
}
body.light-mode .login-overlay::after {
  background-image:
    linear-gradient(rgba(124, 58, 237, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124, 58, 237, 0.06) 1px, transparent 1px);
}

/* Top Nav on Login Screen */
.login-top-nav {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: var(--space-6) 0;
  z-index: 1002;
}

.login-top-nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  padding: 0 var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
}

.login-back-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-glass);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--border-default);
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-full);
  transition: all var(--transition-base);
  text-decoration: none;
}
.login-back-btn svg {
  width: 18px;
  height: 18px;
  transition: transform var(--transition-fast);
}
.login-back-btn:hover {
  color: var(--text-primary);
  background: var(--bg-glass-hover);
  border-color: var(--border-hover);
  transform: translateX(-3px);
}

.login-theme-toggle {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  background: var(--bg-glass);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  cursor: pointer;
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  transition: all var(--transition-fast);
}
.login-theme-toggle:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border-hover);
  color: var(--text-primary);
}
.login-theme-toggle svg { width: 20px; height: 20px; }
.login-theme-toggle .icon-moon { display: none; }
.login-theme-toggle .icon-sun { display: block; }
body.light-mode .login-theme-toggle .icon-moon { display: block; }
body.light-mode .login-theme-toggle .icon-sun { display: none; }

/* Floating Orbs */
.login-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
}
.login-orb-1 { width: 380px; height: 380px; background: rgba(91,7,154,0.25); top: 15%; right: 15%; animation: orb-float 22s ease-in-out infinite; }
.login-orb-2 { width: 300px; height: 300px; background: rgba(124,58,237,0.18); bottom: 15%; left: 15%; animation: orb-float 26s ease-in-out infinite reverse; }
.login-orb-3 { width: 250px; height: 250px; background: rgba(168,85,247,0.12); top: 50%; left: 45%; animation: orb-float 18s ease-in-out infinite; }

body.light-mode .login-orb-1 { background: rgba(91,7,154,0.06); }
body.light-mode .login-orb-2 { background: rgba(124,58,237,0.05); }
body.light-mode .login-orb-3 { background: rgba(168,85,247,0.04); }

/* Login Box Card */
.login-box {
  background: var(--bg-glass-strong);
  backdrop-filter: blur(28px) saturate(1.4);
  -webkit-backdrop-filter: blur(28px) saturate(1.4);
  padding: var(--space-2xl) var(--space-xl);
  border-radius: var(--radius-2xl);
  border: 1px solid var(--border-hover);
  box-shadow:
    var(--shadow-xl),
    0 0 60px rgba(124, 58, 237, 0.15),
    0 0 120px rgba(91, 7, 154, 0.08);
  width: 100%;
  max-width: 440px;
  text-align: center;
  position: relative;
  z-index: 1;
  animation: modal-pop 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

body.light-mode .login-box {
  background: rgba(255, 255, 255, 0.88);
  border-color: rgba(124, 58, 237, 0.18);
  box-shadow:
    0 24px 60px rgba(91, 7, 154, 0.1),
    0 0 40px rgba(124, 58, 237, 0.06);
}

.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-6);
}

/* Glass Badge for Brand Logo — Fitted and clean */
.login-logo-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.8);
}

.login-logo-img {
  height: 28px;
  width: auto;
  display: block;
}

.login-mobile-disclaimer {
  display: none;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  margin: var(--space-xs) 0 var(--space-md) 0;
  border-radius: var(--radius-md);
  background: rgba(124, 58, 237, 0.05);
  border: 1px dashed rgba(124, 58, 237, 0.2);
  color: var(--text-secondary);
  font-size: 11px;
  font-style: italic;
  text-align: center;
}

@media (max-width: 1024px) {
  .login-mobile-disclaimer {
    display: flex;
  }
}

.login-box h2 {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 22px;
  font-weight: 700;
  margin-bottom: var(--space-2);
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.login-box p {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin-bottom: var(--space-lg);
  line-height: 1.55;
}

.login-box form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  width: 100%;
}

/* Password wrapper & eye toggle inside input field */
.password-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  box-sizing: border-box;
}

.password-wrapper input {
  width: 100%;
  padding: 13px 44px 13px 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: all var(--transition-base);
  box-sizing: border-box;
}

.password-wrapper input:focus {
  border-color: var(--accent-mid);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.2), 0 0 16px rgba(124, 58, 237, 0.12);
  background: var(--bg-surface-hover);
}

.toggle-password {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast);
  z-index: 5;
}

.toggle-password:hover {
  color: var(--text-primary);
}

.toggle-password svg {
  width: 18px;
  height: 18px;
  display: block;
}

.login-submit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  background: var(--gradient-accent);
  color: #fff;
  border: none;
  padding: 13px;
  border-radius: var(--radius-lg);
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base);
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.35);
  margin-top: var(--space-xs);
  width: 100%;
}

.login-submit-btn svg {
  width: 18px;
  height: 18px;
  transition: transform var(--transition-fast);
}

.login-submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(124, 58, 237, 0.5);
}

.login-submit-btn:hover svg {
  transform: translateX(4px);
}

.login-footer-text {
  margin-top: var(--space-lg);
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

@media (max-width: 600px) {
  .login-top-nav {
    padding: var(--space-4) 0;
  }
  .login-top-nav-inner {
    padding: 0 var(--space-4);
  }
  .login-back-btn {
    font-size: 12px;
    padding: 4px 12px;
  }
  .login-theme-toggle {
    width: 36px;
    height: 36px;
  }
  .login-box {
    margin: var(--space-sm);
    padding: var(--space-lg) var(--space-md);
    max-width: calc(100vw - 32px);
  }
  .login-box h2 {
    font-size: 20px;
  }
  .login-box p {
    font-size: 12.5px;
    margin-bottom: var(--space-md);
  }
}

/* ── Settings Modal System ─────────────────────────────────── */
.settings-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1010;
  width: 540px;
  max-width: 92vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4), 0 0 32px rgba(120, 40, 200, 0.12);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  overflow: hidden;
  animation: modal-pop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modal-pop {
  from { opacity: 0; transform: translate(-50%, -46%) scale(0.97); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.settings-modal-header {
  padding: var(--space-lg) var(--space-xl);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.settings-modal-title-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.settings-modal-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: var(--gradient-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 4px 12px rgba(91, 7, 154, 0.3);
  color: #fff;
  flex-shrink: 0;
}

.settings-modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.settings-modal-header p {
  margin: 3px 0 0 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.modal-close-btn {
  background: var(--bg-surface-hover);
  border: 1px solid var(--border-default);
  color: var(--text-muted);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  transition: all var(--transition-fast);
}

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

/* Nav Tabs */
.settings-nav-tabs {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-md);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
}

.settings-tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 8px 13px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.settings-tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-surface-hover);
}

.settings-tab-btn.active {
  color: var(--text-primary);
  background: var(--bg-surface);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  border-color: var(--border-default);
}

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

/* Modal Body */
.settings-modal-body {
  padding: var(--space-xl);
  overflow-y: auto;
  flex: 1;
}

.settings-tab-content {
  display: none;
  animation: fadeIn 0.25s ease;
}

.settings-tab-content.active {
  display: block;
}

/* Fields & Groups */
.settings-field-group {
  margin-bottom: var(--space-lg);
}

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

.settings-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-xs);
}

.settings-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-xs);
}

.settings-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  background: var(--bg-surface-hover);
  color: var(--text-muted);
  border: 1px solid var(--border-default);
}

.settings-badge.success {
  background: rgba(52, 211, 153, 0.12);
  color: #34d399;
  border-color: rgba(52, 211, 153, 0.3);
}

.settings-badge.error {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}

.settings-input-with-btn {
  display: flex;
  gap: var(--space-sm);
}

.settings-input,
.settings-textarea {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  box-sizing: border-box;
  outline: none;
  transition: all var(--transition-fast);
}

.settings-input:focus,
.settings-textarea:focus {
  border-color: var(--accent-mid);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.15);
  background: var(--bg-elevated);
}

.settings-textarea {
  resize: vertical;
  min-height: 60px;
}

.settings-help-text {
  font-size: 11px;
  color: var(--text-muted);
  margin: 6px 0 0 0;
  line-height: 1.4;
}

/* Cards & Endpoint Displays */
.settings-info-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
}

.info-card-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.info-card-icon {
  font-size: 22px;
}

.info-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.info-card-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.meta-connect-btn {
  width: 100%;
  padding: 10px;
  border-radius: var(--radius-md);
  border: none;
  background: #1877F2;
  color: #ffffff;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background var(--transition-fast), transform var(--transition-fast);
  box-shadow: 0 4px 12px rgba(24, 119, 242, 0.25);
}

.meta-connect-btn:hover {
  background: #166FE5;
  transform: translateY(-1px);
}

.endpoint-box {
  background: var(--bg-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.endpoint-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: monospace;
  font-size: 11px;
}

.ep-method {
  background: rgba(168, 85, 247, 0.15);
  color: var(--accent-mid);
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 700;
}

.ep-url {
  color: var(--text-secondary);
  word-break: break-all;
}

/* Account Profile Card */
.account-profile-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
}

.profile-avatar-large {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--gradient-accent);
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  box-shadow: 0 4px 12px rgba(91, 7, 154, 0.3);
}

.profile-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.profile-role-badge {
  font-size: 11px;
  color: var(--accent-mid);
  font-weight: 500;
  margin-top: 2px;
}

/* Danger Button */
.settings-danger-btn {
  width: 100%;
  padding: 11px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.08);
  color: #ef4444;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  transition: all var(--transition-fast);
}

.settings-danger-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.5);
}

/* Primary & Sec Buttons */
.settings-primary-btn {
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--gradient-accent);
  color: #fff;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  transition: all var(--transition-fast);
  box-shadow: 0 4px 12px rgba(91, 7, 154, 0.25);
}

.settings-primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(91, 7, 154, 0.35);
}

.settings-sec-btn {
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-primary);
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.settings-sec-btn:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-hover);
}

/* Footer */
.settings-modal-footer {
  padding: var(--space-md) var(--space-xl);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
}

/* ── Mobile Sidebar & Backdrop ─────────────────────────────── */
.mobile-sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}

.mobile-sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.mobile-menu-btn {
  display: none;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.mobile-menu-btn svg {
  width: 20px;
  height: 20px;
}

.mobile-menu-btn:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-hover);
}

/* ── Responsive Dashboard Breakpoints ───────────────────────── */
@media (max-width: 1280px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .grid-2,
  .analytics-hero {
    grid-template-columns: 1fr;
  }
  .conversations-layout {
    grid-template-columns: 280px 1fr;
  }
  .grid-3 {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 768px) {
  .mobile-menu-btn {
    display: flex;
  }
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: -100%;
    z-index: 100;
    transition: left var(--transition-slow);
    width: 280px;
    min-width: 280px;
    max-width: 85vw;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: var(--shadow-xl);
    padding: var(--space-md) 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
  }
  .sidebar.mobile-open {
    left: 0;
  }
  .sidebar-brand {
    margin-bottom: var(--space-md);
    padding: 0 var(--space-md);
  }
  .sidebar-nav {
    flex: 1 1 auto;
    overflow-y: auto;
  }
  .sidebar-footer {
    padding: var(--space-md);
    margin-top: auto;
    flex-shrink: 0;
  }
  .main {
    margin-left: 0;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }
  .header {
    height: auto;
    min-height: auto;
    padding: var(--space-md);
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-xs);
    width: 100%;
    box-sizing: border-box;
  }
  .header-left {
    flex: 1 1 auto;
    min-width: 0;
    gap: var(--space-sm);
  }
  .header-title {
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .header-subtitle {
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
  }
  .header-right {
    gap: 6px;
    flex-shrink: 0;
  }
  .content {
    padding: var(--space-sm);
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    overflow-x: hidden;
  }
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .conversations-layout {
    grid-template-columns: 1fr;
    position: relative;
    overflow: hidden;
  }
  .convo-list {
    width: 100%;
    display: flex;
    flex-direction: column;
  }
  .chat-viewer {
    display: none;
    width: 100%;
  }
  .conversations-layout.mobile-show-chat .convo-list {
    display: none;
  }
  .conversations-layout.mobile-show-chat .chat-viewer {
    display: flex;
    flex-direction: column;
  }
  .mobile-convo-back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface-hover);
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    margin-right: 8px;
    cursor: pointer;
    flex-shrink: 0;
  }
  .detail-panel {
    width: 100%;
  }
  .header-search {
    display: none;
  }
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
  .outbound-pipeline-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    padding: var(--space-md) var(--space-xs);
    width: 100%;
    box-sizing: border-box;
  }
  .pipeline-connector {
    display: none;
  }
  .pipeline-step {
    min-width: 0;
    padding: 8px 4px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    text-align: center;
  }
  .pipeline-step span {
    font-size: 10px;
  }
  .pipeline-count {
    font-size: 14px !important;
  }
}

.mobile-convo-back-btn {
  display: none;
}

/* Global Overflow & Responsiveness Protection */
.card,
.stat-card,
.recent-activity,
.activity-feed,
.response-bars,
.funnel-container,
.donut-container,
.chart-container {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
  word-break: break-word;
  overflow-wrap: break-word;
}

@media (max-width: 480px) {
  .header {
    padding: 10px var(--space-sm);
  }
  .header-right {
    gap: 4px;
  }
  .last-synced {
    display: none;
  }
  .quick-action-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .theme-toggle-btn {
    width: 32px;
    height: 32px;
  }
  .stat-card {
    padding: var(--space-md);
  }
  .stat-value {
    font-size: 22px;
  }
  .data-table th,
  .data-table td {
    padding: 10px 12px;
    font-size: 12px;
  }
}

/* ── Outbound Pipeline View ──────────────────────────────────── */

.outbound-pipeline-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: var(--space-lg) var(--space-md);
}

.pipeline-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 80px;
}

.pipeline-step span {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.pipeline-count {
  font-size: 16px !important;
  font-weight: 700 !important;
  color: var(--text-primary) !important;
}

.pipeline-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-surface-hover);
  border: 2px solid var(--border-default);
  transition: all var(--transition-base);
}

.pipeline-dot.active {
  background: var(--accent-start);
  border-color: var(--accent-mid);
  box-shadow: 0 0 12px rgba(91, 7, 154, 0.4);
}

.pipeline-connector {
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, var(--border-default), var(--border-accent));
  min-width: 40px;
  max-width: 120px;
  margin: 0 var(--space-sm);
  margin-bottom: 38px;
}

/* Outreach Mobile Cards */
.outreach-mobile-list {
  display: none;
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-sm) 0;
}

.outreach-mobile-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  box-sizing: border-box;
  width: 100%;
}

.outreach-mobile-card:hover {
  border-color: var(--border-hover);
  background: var(--bg-surface-hover);
}

.outreach-mobile-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-bottom: var(--space-xs);
}

.outreach-mobile-card-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.outreach-mobile-card-title strong {
  font-size: 14px;
  color: var(--text-primary);
}

.outreach-mobile-card-sub {
  font-size: 11.5px;
  color: var(--text-secondary);
}

.outreach-mobile-touches-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: var(--space-sm) 0;
}

.mobile-touch-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  padding: 3px 8px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-hover);
  border: 1px solid var(--border-subtle);
}

.mobile-touch-chip.sent {
  color: #34d399;
  border-color: rgba(52, 211, 153, 0.3);
}

.mobile-touch-chip.draft {
  color: var(--accent-mid);
  border-color: rgba(168, 85, 247, 0.3);
}

.outreach-mobile-expand-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent-mid);
  padding-top: var(--space-xs);
  border-top: 1px solid var(--border-subtle);
  margin-top: var(--space-xs);
}

.outreach-mobile-drafts-container {
  margin-top: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  width: 100%;
}

@media (max-width: 768px) {
  .outreach-desktop-table {
    display: none !important;
  }
  .outreach-mobile-list {
    display: flex !important;
  }
}

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

.touch-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-sm);
}

.touch-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-mid);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.touch-subject {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border-subtle);
}

.touch-body {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
  max-height: 200px;
  overflow-y: auto;
  padding-right: var(--space-sm);
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal;
}

.touch-actions {
  margin-top: var(--space-md);
  display: flex;
  justify-content: flex-end;
}

.btn-approve-send {
  padding: 8px 18px;
  border-radius: var(--radius-md);
  border: none;
  background: linear-gradient(135deg, var(--accent-start), var(--accent-mid));
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  box-shadow: var(--shadow-md);
  transition: all var(--transition-base);
}

.btn-approve-send:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}

.btn-approve-send:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-approve-send.btn-sent {
  background: linear-gradient(135deg, hsl(152, 68%, 35%), hsl(152, 68%, 45%));
  opacity: 1;
  cursor: default;
  font-size: 13px;
}

.btn-approve-send.btn-locked {
  background: var(--bg-surface-hover);
  color: var(--text-muted);
  border: 1px solid var(--border-default);
  opacity: 0.8;
  font-size: 11px;
}

.touch-sent-info {
  margin-top: var(--space-sm);
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
}

.touch-timer-info {
  margin-top: 6px;
  font-size: 10px;
  color: var(--text-muted);
  text-align: right;
  font-style: italic;
}

/* Import Leads Card */
.import-leads-card {
  padding: var(--space-lg);
}

.import-header {
  display: flex;
  align-items: baseline;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.import-textarea {
  width: 100%;
  min-height: 120px;
  max-height: 250px;
  padding: var(--space-md);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: 'Inter', monospace;
  font-size: 12px;
  line-height: 1.5;
  resize: vertical;
  transition: border-color var(--transition-base);
  box-sizing: border-box;
}

.import-textarea:focus {
  outline: none;
  border-color: var(--accent-start);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.15);
}

.import-textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

.import-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-md);
  gap: var(--space-md);
}

.import-status {
  font-size: 12px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.import-status.processing {
  background: rgba(139, 92, 246, 0.1);
  color: var(--accent-start);
  border: 1px solid rgba(139, 92, 246, 0.2);
}

.import-status.success {
  background: rgba(52, 211, 153, 0.1);
  color: hsl(152, 68%, 50%);
  border: 1px solid rgba(52, 211, 153, 0.2);
}

.import-status.error {
  background: rgba(239, 68, 68, 0.1);
  color: hsl(0, 80%, 60%);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.import-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(139, 92, 246, 0.3);
  border-top-color: var(--accent-start);
  border-radius: 50%;
  animation: import-spin 0.8s linear infinite;
}

@keyframes import-spin {
  to { transform: rotate(360deg); }
}

/* Client Onboarding Form */
.onboarding-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.onboarding-form label {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.onboarding-form input,
.onboarding-form textarea,
.onboarding-form select {
  width: 100%;
  padding: var(--space-md);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  box-sizing: border-box;
  transition: border-color var(--transition-base);
}

.onboarding-form input:focus,
.onboarding-form textarea:focus {
  border-color: var(--accent-start);
  outline: none;
}

.onboarding-success {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  text-align: center;
}

.onboarding-success .password-display {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-warm);
  margin: var(--space-sm) 0;
  font-family: monospace;
  letter-spacing: 2px;
}

/* ══════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE FIXES (appended — no desktop rules changed)
   ══════════════════════════════════════════════════════════════ */

/* ── Base: Outreach Touch Card (missing base styles) ──────── */
.outreach-touch-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-sizing: border-box;
  width: 100%;
  transition: border-color var(--transition-fast);
}

/* ── Tablet (768px–1024px) ────────────────────────────────── */
@media (max-width: 1024px) {
  .analytics-hero {
    grid-template-columns: 1fr;
  }
}

/* ── Mobile (≤768px) ──────────────────────────────────────── */
@media (max-width: 768px) {

  /* --- 1. Enable body-level scroll & pull-to-refresh --- */
  body {
    overflow-y: auto;
    overflow-x: hidden;
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
  }
  .app {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    flex-direction: column;
  }
  .main {
    overflow: visible;
    flex: 1 1 auto;
  }
  .content {
    overflow: visible;
    min-height: 0;
  }

  /* --- 2. Login overlay: allow scroll on short screens --- */
  .login-overlay {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    align-items: flex-start;
    padding: var(--space-xl) 0;
  }
  .login-box {
    margin: auto var(--space-md);
    flex-shrink: 0;
  }

  /* --- 3. Stats grid: 2 columns on mobile --- */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* --- 4. Stat card text: prevent word-break mid-word --- */
  .stat-label {
    font-size: 11px;
    line-height: 1.3;
    word-break: normal;
    overflow-wrap: normal;
    hyphens: none;
  }
  .stat-value {
    font-size: 24px;
  }
  .stat-icon {
    width: 34px;
    height: 34px;
    font-size: 16px;
    margin-bottom: var(--space-sm);
  }

  /* --- 5. Recent Activity: tighter padding --- */
  .activity-item {
    padding: var(--space-sm) var(--space-md);
    gap: var(--space-sm);
  }
  .activity-text p {
    font-size: 12px;
  }
  .activity-time {
    font-size: 10px;
  }

  /* --- 6. Outreach title: proper placement --- */
  .outbound-view .card > h3 {
    font-size: 16px !important;
    font-weight: 700 !important;
    margin: 0 0 var(--space-md) 0 !important;
    padding: 0;
    word-break: normal;
  }

  /* --- 7. Outreach touch cards: visible on mobile --- */
  .outreach-touch-card {
    padding: var(--space-md);
  }
  .touch-body {
    max-height: none;
    font-size: 12px;
    padding-right: 0;
  }
  .touch-subject {
    font-size: 12px;
  }
  .touch-label {
    font-size: 11px;
  }
  .touch-actions {
    justify-content: stretch;
  }
  .touch-actions .btn-approve-send {
    width: 100%;
    text-align: center;
  }

  /* --- 8. Analytics hero: single column --- */
  .analytics-hero {
    grid-template-columns: 1fr !important;
  }

  /* --- 9. Chart container mobile height --- */
  .chart-container {
    height: 180px;
  }

  /* --- 10. Funnel & donut containers --- */
  .funnel-container {
    padding: var(--space-md);
  }
  .funnel-step {
    font-size: 12px;
    padding: var(--space-xs) var(--space-sm);
  }
  .donut-container {
    min-height: 180px;
  }

  /* --- 11. Response bars mobile --- */
  .response-bar-label {
    width: 70px;
    font-size: 11px;
  }
  .response-bar-item {
    gap: var(--space-sm);
  }

  /* --- 12. Import card mobile --- */
  .import-header {
    flex-direction: column;
    gap: var(--space-sm);
    align-items: flex-start;
  }
  .import-leads-card {
    padding: var(--space-md);
  }
  .import-actions {
    flex-direction: column;
    align-items: stretch;
  }

  /* --- 13. Card body with inline max-height: override --- */
  .card-body[style*="max-height"] {
    max-height: 240px !important;
  }

  /* --- 14. Detail panel full-screen on mobile --- */
  .detail-panel {
    max-width: 100vw;
    box-sizing: border-box;
  }
  .detail-body {
    padding: var(--space-md);
  }

  /* --- 15. Settings modal mobile --- */
  .settings-modal {
    width: 95vw !important;
    max-width: 95vw !important;
    left: 50% !important;
    transform: translateX(-50%) translateY(-50%) !important;
  }

  /* --- 16. Welcome header mobile --- */
  .welcome-header h1 {
    font-size: 20px;
  }

  /* --- 17. Global card padding tighter on mobile --- */
  .card {
    padding: var(--space-md);
  }
  .card-header {
    padding: 0 0 var(--space-sm) 0;
  }

  /* --- 18. Data table mobile scroll hint --- */
  .table-container {
    -webkit-overflow-scrolling: touch;
  }
}

/* ── Small Mobile (≤480px) ────────────────────────────────── */
@media (max-width: 480px) {

  /* Stats grid: single column */
  .stats-grid {
    grid-template-columns: 1fr !important;
    gap: var(--space-sm);
  }

  /* Stat cards: compact */
  .stat-card {
    padding: var(--space-sm) var(--space-md);
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--space-md);
  }
  .stat-icon {
    margin-bottom: 0;
    width: 36px;
    height: 36px;
    font-size: 16px;
    flex-shrink: 0;
  }
  .stat-value {
    font-size: 22px;
    margin-bottom: 2px;
  }
  .stat-label {
    font-size: 10px;
  }
  .stat-sub {
    font-size: 10px;
  }

  /* Pipeline: 2x2 grid */
  .outbound-pipeline-bar {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px;
  }
  .pipeline-step span {
    font-size: 9px;
  }
  .pipeline-count {
    font-size: 13px !important;
  }

  /* Response bars: tighter */
  .response-bar-label {
    width: 55px;
    font-size: 10px;
  }
  .response-bar-count {
    width: 24px;
    font-size: 11px;
  }
  .response-bar-item {
    gap: var(--space-xs);
  }

  /* Activity items: compact */
  .activity-item {
    padding: var(--space-xs) var(--space-sm);
    gap: var(--space-xs);
  }
  .activity-icon {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }
  .activity-text p {
    font-size: 11px;
  }
  .activity-time {
    font-size: 9px;
  }

  /* Content padding */
  .content {
    padding: var(--space-xs);
  }

  /* Chart container */
  .chart-container {
    height: 160px;
  }

  /* Funnel steps */
  .funnel-step {
    font-size: 11px;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
  }
  .funnel-container {
    padding: var(--space-sm);
    width: 100%;
    box-sizing: border-box;
  }

  /* Touch cards */
  .outreach-touch-card {
    padding: var(--space-sm);
  }
  .touch-body {
    font-size: 11px;
    line-height: 1.5;
  }

  /* Import textarea */
  .import-textarea {
    min-height: 80px;
    font-size: 11px;
  }

  /* Conversations */
  .convo-item {
    padding: var(--space-sm);
  }
  .convo-name {
    font-size: 13px;
  }
  .convo-preview {
    font-size: 11px;
  }

  /* Login */
  .login-overlay {
    padding: var(--space-md) 0;
  }
  .login-box {
    padding: var(--space-lg) var(--space-md);
  }
  .login-box h2 {
    font-size: 18px;
  }
  .login-box p {
    font-size: 12px;
  }
}

/* ── Landscape phone (short height) ───────────────────────── */
@media (max-height: 500px) and (max-width: 900px) {
  .login-overlay {
    align-items: flex-start;
    padding: var(--space-sm) 0;
  }
  .login-box {
    padding: var(--space-md);
  }
  .login-orb {
    display: none;
  }
}
