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

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

/* ── iOS GLOBAL FIXES ────────────────────────────────────── */
/* Prevent double-tap zoom on buttons/links */
a, button, [role="button"] { touch-action: manipulation; }
/* Remove iOS tap highlight flash */
* { -webkit-tap-highlight-color: transparent; }
/* Prevent iOS text size adjustment on rotate */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
/* Prevent iOS input zoom — all inputs must be at least 16px */
input, textarea, select { font-size: 16px !important; }
/* Smooth momentum scrolling on iOS */
.content, .mob-home, .crm-ticket-list, .crm-messages, .crm-contact-panel,
.leads-table, .modal-content { -webkit-overflow-scrolling: touch; }

:root {
  /* ── Brand: blue-cyan gradient (matches Clousy logo) ── */
  --cyan:         #00c8f0;
  --cyan-hover:   #00a8d4;
  --cyan-dim:     rgba(0, 200, 240, 0.12);
  --cyan-glow:    rgba(0, 200, 240, 0.28);
  --cyan-border:  rgba(0, 200, 240, 0.18);
  --success:      #00c8f0;
  --success-dim:  rgba(0, 200, 240, 0.15);
  --danger:       #ef4444;
  --warning:      #f59e0b;
  --info:         #29b6f6;
  /* Logo gradient: #29b6f6 → #00e5ff → #00bcd4 */
  --gradient:     linear-gradient(135deg, #29b6f6, #00e5ff);
  --gradient-h:   linear-gradient(135deg, #00e5ff, #00bcd4);
  --green:        #00c8f0;
  --green-dark:   #00a8d4;
  --purple:       #29b6f6;
  --purple-light: #00e5ff;
  --indigo:       #29b6f6;

  /* ── Dark backgrounds (slight blue tint) ── */
  --bg:           #060b0f;
  --bg-alt:       #080d12;
  --surface:      #0c1318;
  --surface-2:    #101820;
  --surface-3:    #151e28;
  --border:       rgba(0, 200, 240, 0.10);
  --border-light: rgba(0, 200, 240, 0.06);
  --sidebar-bg:   #050a0e;
  --sidebar-text: #6a8899;
  --text:         #eef6fa;
  --muted:        #5a7888;
  --muted2:       #3a5868;
  --radius:       4px;
  --radius-lg:    8px;
  --shadow:       0 4px 32px rgba(0,0,0,.7);
  --shadow-lg:    0 16px 64px rgba(0,0,0,.85);
}

/* ── LIGHT MODE ─────────────────────────────────────────────── */
[data-theme="light"] {
  --bg:           #f0f6fa;
  --bg-alt:       #e6f0f7;
  --surface:      #ffffff;
  --surface-2:    #edf4f9;
  --surface-3:    #e0edf5;
  --border:       rgba(0, 160, 200, 0.18);
  --border-light: rgba(0, 160, 200, 0.09);
  --sidebar-bg:   #ffffff;
  --sidebar-text: #2a5068;
  --text:         #0a1520;
  --muted:        #3a6278;
  --muted2:       #6a8898;
  --shadow:       0 4px 24px rgba(0,0,0,.10);
  --shadow-lg:    0 16px 48px rgba(0,0,0,.15);
  --cyan-dim:     rgba(0, 160, 200, 0.10);
  --cyan-border:  rgba(0, 160, 200, 0.22);
}

[data-theme="light"] body { background: var(--bg); color: var(--text); }

/* Light mode — CRM scoped vars */
[data-theme="light"] .crm-page {
  --crm-bg:          #f4f7f7;
  --crm-surface:     #ffffff;
  --crm-surface2:    #f0f5f5;
  --crm-border:      rgba(0, 140, 120, 0.14);
  --crm-border2:     rgba(0, 140, 120, 0.07);
  --crm-muted:       rgba(0,0,0,0.42);
  --crm-muted2:      rgba(0,0,0,0.28);
  --crm-text:        rgba(0,0,0,0.88);
  background:        #f4f7f7;
}

/* Light mode — login background */
[data-theme="light"] #login-screen {
  background:
    radial-gradient(ellipse 70% 80% at -5% 50%, rgba(0,200,240,0.08) 0%, transparent 55%),
    radial-gradient(ellipse 60% 50% at 110% 50%, rgba(0,200,240,0.05) 0%, transparent 55%),
    #f4f7f7;
}
[data-theme="light"] .login-card {
  background: #ffffff;
  border: 1px solid var(--border);
  box-shadow: 0 8px 40px rgba(0,0,0,.08);
}
[data-theme="light"] .login-field input {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

/* Light mode — sidebar */
[data-theme="light"] .sidebar { background: var(--sidebar-bg); border-right-color: var(--border); }
[data-theme="light"] .nav-item { color: var(--muted); }
[data-theme="light"] .nav-item.active,
[data-theme="light"] .nav-item:hover { color: var(--cyan); background: var(--cyan-dim); }
[data-theme="light"] .sidebar-logo-icon { background: var(--surface-3); color: var(--cyan); }

/* Light mode — cards, tables, modals */
[data-theme="light"] .stat-card,
[data-theme="light"] .card,
[data-theme="light"] .modal-content,
[data-theme="light"] .client-card { background: #fff; border-color: var(--border); color: var(--text); }
[data-theme="light"] .leads-table thead tr { background: var(--surface-2); }
[data-theme="light"] .leads-table tbody tr:hover { background: var(--surface-2); }
[data-theme="light"] .leads-table td,
[data-theme="light"] .leads-table th { border-color: var(--border-light); color: var(--text); }

/* Light mode — mobile home */
[data-theme="light"] .mob-home { background: var(--bg); }
[data-theme="light"] .mob-home-header { background: var(--bg); }
[data-theme="light"] .mob-card { background: #fff; border-color: var(--border); color: var(--text); }
[data-theme="light"] .mob-bottom-bar { background: rgba(255,255,255,.92); border-color: var(--border); }

/* Light mode — inputs globally */
[data-theme="light"] input:not([type="checkbox"]):not([type="radio"]),
[data-theme="light"] textarea,
[data-theme="light"] select {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

/* Light mode — scrollbar */
[data-theme="light"] ::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); }

/* Light mode — hardcoded backgrounds */
[data-theme="light"] .content { background: var(--bg); }
[data-theme="light"] #app-screen { background: var(--bg); }
[data-theme="light"] .page { background: var(--bg); color: var(--text); }
[data-theme="light"] .stat-label { color: var(--muted); }
[data-theme="light"] .stat-value { color: var(--text); }
[data-theme="light"] .page-header h2,
[data-theme="light"] .page h2,
[data-theme="light"] .page h3 { color: var(--text); }
[data-theme="light"] .filters input,
[data-theme="light"] .filters select { background: #fff; color: var(--text); border-color: var(--border); }
[data-theme="light"] .btn-sm,
[data-theme="light"] .btn-edit { background: var(--surface-2); color: var(--text); border-color: var(--border); }
[data-theme="light"] .modal-content { background: #fff; color: var(--text); }
[data-theme="light"] .modal-content label { color: var(--muted); }
[data-theme="light"] .stuck-lead-item { background: var(--surface); border-color: var(--border); }
[data-theme="light"] .interaction-item { border-color: var(--border); }
[data-theme="light"] .status-badge { border: 1px solid var(--border); }
[data-theme="light"] nav { background: var(--sidebar-bg); }

/* Light mode — CRM chat */
[data-theme="light"] .crm-msg-bubble { background: var(--crm-surface); color: var(--crm-text); }
[data-theme="light"] .crm-msg.outbound .crm-msg-bubble { background: var(--crm-cyan-dim); color: var(--crm-text); }
[data-theme="light"] .crm-ticket-item { background: var(--crm-surface); border-color: var(--crm-border); }
[data-theme="light"] .crm-ticket-item:hover { background: var(--crm-surface2); }
[data-theme="light"] .crm-topbar { background: var(--crm-surface); border-color: var(--crm-border); }
[data-theme="light"] .crm-tab { color: var(--crm-muted); }
[data-theme="light"] .crm-tab.active { color: var(--crm-cyan); }
[data-theme="light"] .crm-send-area { background: var(--crm-surface); border-color: var(--crm-border); }
[data-theme="light"] .crm-msg-input { background: var(--crm-bg); color: var(--crm-text); }
[data-theme="light"] .crm-contact-panel { background: var(--crm-surface); border-color: var(--crm-border); }
[data-theme="light"] .crm-kanban-col { background: var(--crm-surface); border-color: var(--crm-border); }
[data-theme="light"] .crm-kanban-card { background: #fff; border-color: var(--crm-border); }
[data-theme="light"] .crm-kanban-card:hover { border-color: var(--crm-cyan-border); }

/* Conversations – light mode */
[data-theme="light"] .conv-wa-header { background: #e8f0ef; border-color: var(--border); }
[data-theme="light"] .conv-wa-name { color: var(--text); }
[data-theme="light"] .conv-wa-bg { background-color: #dfe7e6; background-image: radial-gradient(rgba(0,100,80,.04) 1px,transparent 1px), radial-gradient(rgba(0,100,80,.025) 1px,transparent 1px); }
[data-theme="light"] .conv-chat { background: #dfe7e6; }
[data-theme="light"] .conv-msg.inbound  { background: #fff; color: #111; box-shadow: 0 1px 2px rgba(0,0,0,.15); }
[data-theme="light"] .conv-msg.inbound .conv-msg-time { color: #888; }
[data-theme="light"] .conv-msg.outbound { background: #d9fdd3; color: #111; }
[data-theme="light"] .conv-msg.outbound .conv-msg-time { color: #555; }
[data-theme="light"] .conv-msg.system { background: rgba(0,0,0,.08); color: #666; }
[data-theme="light"] .conv-date-sep { background: rgba(0,0,0,.12); color: #555; }
[data-theme="light"] .conv-input-bar { background: #e8f0ef; border-color: var(--border); }
[data-theme="light"] .conv-input-textarea { background: #fff; border-color: var(--border); color: #111; }
[data-theme="light"] .conv-chat-info { background: var(--surface); border-color: var(--border); }
[data-theme="light"] .conv-wa-action-btn { color: var(--muted); }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  /* Use dvh with 100vh fallback for older iOS */
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  /* Prevent iOS pull-to-refresh breaking the app */
  overscroll-behavior: none;
}

h1, h2, h3, .logo, .stat-value {
  font-family: 'Bebas Neue', sans-serif;
  letter-spacing: 0.04em;
}

::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted2); }

.screen {
  height: 100vh;
  height: 100dvh;
}
.hidden { display: none !important; }

/* ─── LOGIN ─────────────────────────────────────────────── */
#login-screen {
  display: flex;
  height: 100vh;
  background:
    radial-gradient(ellipse 70% 80% at -5% 50%, rgba(0,200,240,0.14) 0%, transparent 55%),
    radial-gradient(ellipse 60% 50% at 110% 50%, rgba(0,200,240,0.07) 0%, transparent 55%),
    #070909;
  position: relative;
  overflow: hidden;
}

.login-bg-glow {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(0,200,240,0.045) 1px, transparent 1px);
  background-size: 30px 30px;
  pointer-events: none;
}

/* ── Left panel ── */
.login-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 3rem 4rem;
  position: relative;
  z-index: 1;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.login-logo-img {
  height: 56px;
  width: auto;
  display: block;
  /* SVG already transparent, no filter needed */
}

.login-logo-icon {
  width: 36px;
  height: 36px;
  background: rgba(0,200,240,0.12);
  border: 1px solid rgba(0,200,240,0.3);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.login-logo-text {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.4rem;
  letter-spacing: 0.1em;
  color: var(--text);
}

.login-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.5rem;
  padding-top: 3rem;
}

.login-badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: rgba(0,200,240,0.08);
  border: 1px solid rgba(0,200,240,0.2);
  border-radius: 100px;
  padding: .35rem 1rem;
  font-size: .72rem;
  font-weight: 600;
  color: var(--cyan);
  letter-spacing: 0.04em;
  width: fit-content;
}

.login-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(3rem, 5vw, 5.5rem);
  line-height: 0.95;
  letter-spacing: 0.02em;
  color: var(--text);
}

.login-title span {
  background: linear-gradient(135deg, #00c8f0, #00e5ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-desc {
  font-size: .95rem;
  color: var(--muted);
  line-height: 1.6;
  max-width: 380px;
}

.login-stats {
  display: flex;
  gap: 1.5rem;
  margin-top: .5rem;
}

.login-stat {
  display: flex;
  flex-direction: column;
  gap: .2rem;
}

.login-stat strong {
  font-size: .82rem;
  font-weight: 700;
  color: var(--cyan);
  letter-spacing: 0.04em;
}

.login-stat span {
  font-size: .72rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ── Right panel ── */
.login-right {
  width: 420px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: rgba(0,0,0,0.25);
  border-left: 1px solid rgba(0,200,240,0.08);
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 1;
}

.login-card {
  width: 100%;
  max-width: 360px;
}

.login-card h2 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 2.2rem;
  letter-spacing: 0.05em;
  color: var(--text);
  margin-bottom: .25rem;
}

.login-card-sub {
  font-size: .82rem;
  color: var(--muted);
  margin-bottom: 2.25rem;
}

.login-field {
  margin-bottom: 1.1rem;
}

.login-field label {
  display: block;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: .4rem;
}

.login-field input {
  width: 100%;
  padding: .8rem 1rem;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(0,200,240,0.12);
  border-radius: var(--radius);
  font-size: .95rem;
  color: var(--text);
  font-family: inherit;
  transition: border-color .2s, box-shadow .2s, background .2s;
  outline: none;
}

.login-field input:focus {
  border-color: var(--cyan);
  background: rgba(0,200,240,0.04);
  box-shadow: 0 0 0 3px rgba(0,200,240,0.10);
}

.login-card button[type="submit"] {
  margin-top: 1.75rem;
  width: 100%;
  padding: .9rem;
  background: var(--cyan);
  color: #000;
  border: none;
  border-radius: var(--radius);
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.1rem;
  letter-spacing: 0.15em;
  cursor: pointer;
  text-transform: uppercase;
  transition: background .2s, transform .15s, box-shadow .2s;
  box-shadow: 0 4px 24px rgba(0,200,240,0.3);
}

.login-card button[type="submit"]:hover {
  background: var(--cyan-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,200,240,0.45);
}

.login-card button[type="submit"]:active { transform: translateY(0); }

.login-footer-text {
  margin-top: 2rem;
  font-size: .72rem;
  color: var(--muted2);
  text-align: center;
  letter-spacing: 0.06em;
}

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

.error { color: var(--danger); font-size: .875rem; margin-top: .75rem; }

/* ─── APP LAYOUT ─────────────────────────────────────────── */
#app-screen { display: flex; height: 100vh; }

/* ─── SIDEBAR ────────────────────────────────────────────── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 0;
  border-right: 1px solid var(--border-light);
  position: relative;
}

.sidebar::after {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0; width: 1px;
  background: linear-gradient(to bottom, transparent, rgba(0,200,240,0.25), transparent);
  pointer-events: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: 0 1.25rem 2rem;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex: 1;
}

.sidebar-logo-img {
  height: 36px;
  width: auto;
  display: block;
  max-width: 160px;
}

/* ── Logo composited (HTML/CSS — font-independent) ── */
.app-logo-inline {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.sidebar-logo-icon-svg {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  filter: drop-shadow(0 0 6px rgba(41,182,246,0.4));
}
.sidebar-logo-wordmark {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  gap: 0;
}
.sidebar-logo-name {
  font-size: .95rem;
  font-weight: 900;
  letter-spacing: .05em;
  background: linear-gradient(135deg, #29b6f6, #00e5ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.sidebar-logo-crm {
  font-size: .5rem;
  font-weight: 700;
  letter-spacing: .25em;
  color: #00bcd4;
  opacity: .75;
  -webkit-text-fill-color: #00bcd4;
}

/* Login logo */
.app-logo-login { gap: .75rem; }
.login-logo-icon-svg {
  width: 60px;
  height: 60px;
  flex-shrink: 0;
  filter: drop-shadow(0 0 12px rgba(41,182,246,0.5));
}
.login-logo-wordmark {
  display: flex;
  flex-direction: column;
  line-height: 1;
  gap: .15rem;
}
.login-logo-name {
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: .06em;
  background: linear-gradient(135deg, #29b6f6, #00e5ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.login-logo-crm {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .3em;
  color: #00bcd4;
  -webkit-text-fill-color: #00bcd4;
  opacity: .8;
}

.sidebar-logo-icon {
  width: 28px;
  height: 28px;
  background: rgba(0,200,240,0.12);
  border: 1px solid rgba(0,200,240,0.3);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .85rem;
  flex-shrink: 0;
}

.logo {
  font-size: 1.4rem;
  letter-spacing: 0.12em;
  color: var(--text);
}
.logo span { color: var(--cyan); }

.wa-dot { width: 7px; height: 7px; border-radius: 50%; margin-left: auto; }
.wa-dot.connected    { background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.wa-dot.disconnected { background: var(--danger); box-shadow: 0 0 8px var(--danger); }

nav { flex: 1; padding: .5rem .625rem .625rem; display: flex; flex-direction: column; gap: 1px; overflow-y: auto; }

/* ── Section label (e.g. VENDAS, RASTREAMENTO) ── */
.nav-section-label {
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted2);
  padding: .9rem .875rem .35rem;
  margin-top: .25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .55rem .875rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .78rem;
  font-weight: 500;
  border-radius: 6px;
  border-left: 2px solid transparent;
  transition: all .15s;
  letter-spacing: 0.01em;
  text-transform: none;
}

.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: .7;
  transition: opacity .15s;
}

.nav-item:hover {
  background: rgba(0, 200, 240, 0.07);
  color: var(--cyan);
  border-left-color: rgba(0, 200, 240, 0.4);
}
.nav-item:hover .nav-icon { opacity: 1; }

.nav-item.active {
  background: rgba(0, 200, 240, 0.12);
  border-left-color: var(--cyan);
  color: var(--cyan);
  font-weight: 600;
}
.nav-item.active .nav-icon { opacity: 1; }

.sidebar-footer {
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  border-top: 1px solid var(--border-light);
  margin-top: .5rem;
}

#logout-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--sidebar-text);
  border-radius: var(--radius);
  padding: .4rem;
  cursor: pointer;
  font-size: .7rem;
  font-family: inherit;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: all .15s;
}
#logout-btn:hover { background: rgba(239,68,68,0.12); color: #fca5a5; border-color: rgba(239,68,68,0.3); }

.profile-btn {
  background: none; border: none; color: var(--sidebar-text);
  cursor: pointer; font-size: .82rem; font-family: inherit;
  text-align: left; padding: .2rem 0; opacity: .8; transition: opacity .15s;
}
.profile-btn:hover { opacity: 1; color: var(--text); }

/* ─── CONTENT ────────────────────────────────────────────── */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 2.25rem 2.5rem;
  background:
    radial-gradient(ellipse 60% 40% at 80% 0%, rgba(0,200,240,0.05) 0%, transparent 50%),
    var(--bg);
}
/* Flush mode: used by full-height pages (conversations, CRM) */
.content.page-flush {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.content.page-flush > .page:not(.hidden) {
  flex: 1;
  min-height: 0;
}

/* ─── PAGE TITLES ────────────────────────────────────────── */
.page h2 {
  font-size: 2.8rem;
  letter-spacing: 0.04em;
  margin-bottom: 1.75rem;
  color: var(--text);
  position: relative;
  display: inline-block;
}

.page h2::after {
  content: '';
  position: absolute;
  bottom: -6px; left: 0;
  width: 2.5rem; height: 3px;
  background: var(--cyan);
  border-radius: 2px;
}

.page h3 {
  font-size: 1.4rem;
  letter-spacing: 0.04em;
  margin: 2rem 0 1rem;
  color: var(--muted);
  text-transform: uppercase;
}

/* ─── KPI CARDS ──────────────────────────────────────────── */
.kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .75rem;
}
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: .75rem;
  margin-bottom: .5rem;
}
.kpi-card {
  border-radius: 10px;
  padding: 1rem 1.25rem .875rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
  border: 1px solid transparent;
  position: relative;
  overflow: hidden;
}
.kpi-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  font-family: 'Bebas Neue', sans-serif;
  letter-spacing: .03em;
}
.kpi-unit { font-size: 1rem; font-weight: 700; opacity: .8; }
.kpi-label {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  opacity: .75;
}
/* Color variants */
.kpi-blue   { background: rgba(41,182,246,.10); border-color: rgba(41,182,246,.2); color: #29b6f6; }
.kpi-green  { background: rgba(16,185,129,.10); border-color: rgba(16,185,129,.2); color: #10b981; }
.kpi-orange { background: rgba(245,158,11,.10); border-color: rgba(245,158,11,.2); color: #f59e0b; }
.kpi-purple { background: rgba(139,92,246,.10); border-color: rgba(139,92,246,.2); color: #8b5cf6; }
.kpi-cyan   { background: rgba(0,200,240,.12);  border-color: rgba(0,200,240,.22); color: var(--cyan); }
.kpi-teal   { background: rgba(6,182,212,.10);  border-color: rgba(6,182,212,.2);  color: #06b6d4; }

/* Light mode KPI */
[data-theme="light"] .kpi-blue   { background: rgba(41,182,246,.08); }
[data-theme="light"] .kpi-green  { background: rgba(16,185,129,.08); }
[data-theme="light"] .kpi-orange { background: rgba(245,158,11,.08); }
[data-theme="light"] .kpi-purple { background: rgba(139,92,246,.08); }
[data-theme="light"] .kpi-cyan   { background: rgba(0,200,240,.08);  }
[data-theme="light"] .kpi-teal   { background: rgba(6,182,212,.08);  }

/* ─── STATS GRID ─────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem 1.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
  border: 1px solid var(--border);
  border-bottom: 2px solid var(--cyan);
  position: relative;
  overflow: hidden;
  transition: transform .2s, box-shadow .2s, border-color .2s;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(0,0,0,.5), 0 0 30px rgba(0,200,240,0.08);
  border-color: rgba(0,200,240,0.25);
}

.stat-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at bottom left, rgba(0,200,240,0.06), transparent 60%);
  pointer-events: none;
}

.stat-card:nth-child(2) { border-bottom-color: rgba(0,200,240,.6); }
.stat-card:nth-child(3) { border-bottom-color: rgba(0,200,240,.4); }
.stat-card:nth-child(4) { border-bottom-color: var(--warning); }

.stat-value {
  font-size: 3.8rem;
  letter-spacing: 0.02em;
  color: var(--cyan);
  line-height: 1;
}

.stat-label {
  font-size: .68rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.stat-sub { font-size: .75rem; color: var(--muted); margin-top: .2rem; }

#page-conversions .stat-card .stat-value { color: var(--cyan); }

/* ─── INTERACTION LIST ───────────────────────────────────── */
.interaction-list { display: flex; flex-direction: column; gap: .5rem; }

.interaction-item {
  background: var(--surface);
  border-radius: var(--radius);
  padding: .875rem 1.125rem;
  border: 1px solid var(--border);
  display: flex;
  gap: .875rem;
  align-items: flex-start;
  transition: border-color .15s, background .15s;
}
.interaction-item:hover { border-color: rgba(0,200,240,0.25); background: var(--surface-2); }

.interaction-badge { font-size: .66rem; padding: .2rem .55rem; border-radius: 2px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.badge-message { background: rgba(0,200,240,0.15); color: var(--cyan); }
.badge-note    { background: rgba(245,158,11,0.15); color: #fbbf24; }

.interaction-meta    { font-size: .78rem; color: var(--muted); }
.interaction-content { flex: 1; font-size: .875rem; color: var(--text); }

/* ─── PAGE HEADER ────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  gap: .75rem;
}
.page-header h2 { margin-bottom: 0; }
.page-header h2::after { display: none; }

/* ─── CLIENT FILTER BAR ──────────────────────────────────── */
.page-client-bar { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.5rem; }

.page-client-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: var(--radius);
  padding: .35rem 1rem;
  font-size: .72rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: all .15s;
}
.page-client-btn:hover { border-color: var(--cyan); color: var(--cyan); }
.page-client-btn.active { background: rgba(0,200,240,0.12); border-color: var(--cyan); color: var(--cyan); }

/* ─── FILTERS ────────────────────────────────────────────── */
.filters { display: flex; gap: .75rem; margin-bottom: 1.25rem; }

.filters input, .filters select {
  padding: .6rem .875rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .875rem;
  color: var(--text);
  font-family: inherit;
  flex: 1;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.filters input:focus, .filters select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(0,200,240,0.10);
}
.filters select option { background: var(--surface-2); }

/* ─── TABLE ──────────────────────────────────────────────── */
.leads-table {
  width: 100%;
  border-collapse: collapse;
  background: transparent;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(0,200,240,0.08);
}

.leads-table thead {
  background: rgba(0,200,240,0.04);
}

.leads-table th {
  padding: .7rem 1rem;
  text-align: left;
  font-size: .6rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted2);
  font-weight: 700;
  border-bottom: 1px solid rgba(0,200,240,0.08);
  white-space: nowrap;
}

.leads-table td {
  padding: .75rem 1rem;
  border-top: 1px solid rgba(0,200,240,0.04);
  font-size: .85rem;
  color: var(--text);
  vertical-align: middle;
}

.leads-table tbody tr { transition: background 0.15s; }
.leads-table tbody tr:hover td {
  background: rgba(0,200,240,0.03);
}

/* ─── STATUS BADGES ──────────────────────────────────────── */
.status-badge {
  padding: .18rem .6rem;
  border-radius: 2px;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.status-new          { background: rgba(0,200,240,0.15);   color: var(--cyan); }
.status-contacted    { background: rgba(59,130,246,0.15);  color: #93c5fd; }
.status-qualified    { background: rgba(245,158,11,0.15);  color: #fcd34d; }
.status-converted    { background: rgba(0,200,240,0.2);    color: var(--cyan); border: 1px solid rgba(0,200,240,0.3); }
.status-lost         { background: rgba(239,68,68,0.15);   color: #fca5a5; }
.status-disqualified { background: rgba(138,154,138,0.12); color: var(--muted); }

/* ─── BUTTONS ────────────────────────────────────────────── */
.btn-primary {
  background: var(--cyan);
  color: #000;
  border: none;
  border-radius: var(--radius);
  padding: .575rem 1.25rem;
  font-size: .72rem;
  font-weight: 800;
  font-family: 'Bebas Neue', sans-serif;
  font-size: .95rem;
  letter-spacing: 0.12em;
  cursor: pointer;
  text-transform: uppercase;
  transition: all .2s;
  box-shadow: 0 2px 16px rgba(0,200,240,0.3);
}
.btn-primary:hover {
  background: var(--cyan-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(0,200,240,0.45);
}
.btn-primary:active { transform: translateY(0); }

.btn-danger {
  background: rgba(239,68,68,0.12);
  color: #fca5a5;
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius);
  padding: .575rem 1.1rem;
  font-size: .78rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: background .15s;
}
.btn-danger:hover { background: rgba(239,68,68,0.22); }

.btn-sm { padding: .3rem .65rem; font-size: .75rem; border-radius: var(--radius); cursor: pointer; font-weight: 600; border: none; font-family: inherit; letter-spacing: 0.05em; text-transform: uppercase; }
.btn-edit { background: rgba(0,200,240,0.10); color: var(--cyan); border: 1px solid rgba(0,200,240,0.2); }
.btn-del  { background: rgba(239,68,68,0.10); color: #fca5a5; border: 1px solid rgba(239,68,68,0.2); }
.btn-edit:hover { background: rgba(0,200,240,0.2); }
.btn-del:hover  { background: rgba(239,68,68,0.2); }

/* ─── PAGINATION ─────────────────────────────────────────── */
.pagination { display: flex; gap: .5rem; margin-top: 1.125rem; justify-content: flex-end; }
.pagination button {
  padding: .35rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: .78rem;
  font-family: inherit;
  letter-spacing: 0.05em;
  transition: all .15s;
}
.pagination button:hover { border-color: var(--cyan); color: var(--cyan); }
.pagination button.active {
  background: var(--cyan);
  color: #000;
  border-color: transparent;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0,200,240,0.3);
}

/* ─── WHATSAPP PAGE ──────────────────────────────────────── */
.wa-status-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 460px;
  border: 1px solid var(--border);
  border-top: 2px solid var(--cyan);
  box-shadow: var(--shadow);
}
.wa-status-card p { margin-bottom: 1rem; color: var(--text); }
#qr-image { max-width: 260px; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 1rem; filter: invert(1); }
.wa-actions { display: flex; gap: .75rem; }
.qr-loading-text { color: var(--muted); font-size: .95rem; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .2; } }
.dots { animation: blink 1.4s step-start infinite; }

/* ─── MODAL ──────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--border);
  position: relative;
  overflow: hidden;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-content::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--cyan);
}

.modal-content h3 {
  font-size: 1.8rem;
  letter-spacing: 0.05em;
  margin-bottom: 1.375rem;
  color: var(--text);
}

.modal-content label {
  display: block;
  font-size: .67rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: .35rem;
  margin-top: 1rem;
}

.modal-content input,
.modal-content select,
.modal-content textarea {
  width: 100%;
  padding: .625rem .875rem;
  background: rgba(0,0,0,.35);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
  color: var(--text);
  font-family: inherit;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

.modal-content input:focus,
.modal-content select:focus,
.modal-content textarea:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(0,200,240,0.10);
}

.modal-content select option { background: var(--surface-2); }
.modal-content textarea { resize: vertical; min-height: 80px; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
  margin-top: 1.75rem;
}

.modal-actions button {
  padding: .575rem 1.1rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .8rem;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: all .15s;
}
.modal-actions button:not(.btn-primary):not(.btn-danger) {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}
.modal-actions button:not(.btn-primary):not(.btn-danger):hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

/* ─── CLIENT MODAL REDESIGN ──────────────────────────────── */
.modal-content-wide {
  max-width: 680px !important;
  max-height: 90vh;
  overflow-y: auto;
  scrollbar-width: thin;
}
.cm-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.cm-header h3 { font-size: 1.6rem !important; margin-bottom: .15rem !important; }
.cm-subtitle { font-size: .75rem; color: var(--muted); letter-spacing: 0.06em; }
.cm-close {
  background: none; border: 1px solid rgba(255,255,255,0.08); color: var(--muted);
  border-radius: 6px; width: 32px; height: 32px; display: flex; align-items: center;
  justify-content: center; cursor: pointer; font-size: .75rem; flex-shrink: 0; transition: all .15s;
}
.cm-close:hover { background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.3); color: #fca5a5; transform: none !important; filter: none !important; }

/* Section cards */
.cm-section {
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.05);
  border-left-width: 3px;
  padding: 1rem 1.125rem;
  margin-bottom: .875rem;
}
.cm-section-base   { border-left-color: var(--cyan); background: rgba(0,200,240,0.02); }
.cm-section-ai     { border-left-color: #818cf8;      background: rgba(99,102,241,0.03); }
.cm-section-meta   { border-left-color: #25d366;      background: rgba(37,211,102,0.03); }
.cm-section-mp     { border-left-color: #f59e0b;      background: rgba(245,158,11,0.03); }
.cm-section-pixel  { border-left-color: #3b82f6;      background: rgba(59,130,246,0.03); }
.cm-section-brendi { border-left-color: #f97316;      background: rgba(249,115,22,0.03); }
.cm-section-insta  { border-left-color: #e1306c;      background: rgba(225,48,108,0.03); }

.cm-section-head {
  display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem;
}
.cm-section-icon {
  font-size: 1.1rem; width: 32px; height: 32px; display: flex; align-items: center;
  justify-content: center; background: rgba(255,255,255,0.04); border-radius: 6px; flex-shrink: 0;
}
.cm-section-title { display: block; font-size: .78rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text); }
.cm-section-sub   { display: block; font-size: .68rem; color: var(--muted); margin-top: .1rem; }

.cm-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

.cm-field { display: flex; flex-direction: column; }
.cm-field label { font-size: .62rem !important; font-weight: 700 !important; letter-spacing: 0.12em !important; text-transform: uppercase !important; color: var(--muted) !important; margin-bottom: .35rem !important; margin-top: 0 !important; }

.cm-hint { font-size: .65rem; color: var(--muted2); margin-top: .3rem; line-height: 1.4; }

.cm-webhook-url {
  background: rgba(0,0,0,.3); color: var(--cyan); font-size: .74rem;
  padding: .55rem .875rem; border-radius: var(--radius);
  border: 1px dashed rgba(0,200,240,0.22); font-family: monospace;
  word-break: break-all; cursor: pointer; transition: background .15s;
}
.cm-webhook-url:hover { background: rgba(0,200,240,0.06); }

.cm-copy-input {
  background: rgba(0,0,0,.3) !important; color: var(--cyan) !important;
  font-family: monospace !important; font-size: .78rem !important;
  cursor: copy !important; border: 1px dashed rgba(0,200,240,0.2) !important;
}

/* backward compat */
.mp-webhook-url { background: rgba(0,0,0,.3); color: var(--cyan); font-size:.76rem; padding:.55rem .875rem; border-radius:var(--radius); border:1px dashed rgba(0,200,240,0.22); font-family:monospace; word-break:break-all; cursor:pointer; transition:background .15s; }
.mp-webhook-url:hover { background: rgba(0,200,240,0.06); }

/* ─── AI SECTION ─────────────────────────────────────────── */
.ai-section { background: rgba(0,200,240,0.04); border: 1px solid rgba(0,200,240,0.18); border-radius: var(--radius); padding: 1rem; margin-top: .75rem; }
.ai-section-title { font-weight: 700; margin-bottom: .75rem; font-size: .85rem; color: var(--cyan); letter-spacing: 0.08em; text-transform: uppercase; }

.ai-toggle-label { display: inline-flex; align-items: center; cursor: pointer; }
.ai-toggle-label input[type="checkbox"] { display: none; }
.ai-toggle-track {
  width: 42px; height: 24px;
  background: var(--surface-3);
  border-radius: 99px;
  border: 1px solid var(--border);
  position: relative;
  transition: background .2s;
}
.ai-toggle-track::after {
  content: '';
  position: absolute;
  left: 3px; top: 3px;
  width: 16px; height: 16px;
  background: var(--muted);
  border-radius: 50%;
  transition: left .2s, background .2s;
}
.ai-toggle-label input:checked + .ai-toggle-track { background: var(--cyan-dim); border-color: var(--cyan); }
.ai-toggle-label input:checked + .ai-toggle-track::after { left: 21px; background: var(--cyan); }

/* ─── CLIENTS GRID ───────────────────────────────────────── */
.clients-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1rem;
}

.client-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.375rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--cyan);
  display: flex;
  flex-direction: column;
  gap: .875rem;
  transition: transform .2s, border-color .2s, box-shadow .2s;
}
.client-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,0,0,.5), 0 0 20px rgba(0,200,240,0.07);
}
.client-card-header { display: flex; justify-content: space-between; align-items: center; }
.client-card-header strong { font-size: 1rem; font-weight: 700; color: var(--text); }
.client-card-info { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; color: var(--muted); }
.client-card-actions { display: flex; gap: .5rem; margin-top: .25rem; }

.client-tag {
  background: rgba(0,200,240,0.12);
  color: var(--cyan);
  border-radius: 2px;
  padding: .15rem .65rem;
  font-size: .68rem;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ─── CHAT (CLIENTES) ────────────────────────────────────── */
.chat-messages {
  display: flex;
  flex-direction: column;
  gap: .6rem;
  padding: 1rem;
  background: #060c0c;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  min-height: 300px;
  max-height: 500px;
  overflow-y: auto;
  margin-bottom: 1rem;
}

.chat-bubble { max-width: 70%; display: flex; flex-direction: column; gap: .2rem; }
.chat-bubble.inbound  { align-self: flex-start; }
.chat-bubble.outbound { align-self: flex-end; }

.bubble-content {
  padding: .625rem 1rem;
  border-radius: 8px;
  font-size: .9rem;
  line-height: 1.45;
  word-break: break-word;
}
.inbound  .bubble-content { background: #0d1d2a; color: var(--text); border-bottom-left-radius: 2px; }
.outbound .bubble-content { background: #003a52; color: #d4f0ff; border-bottom-right-radius: 2px; }

.bubble-meta { font-size: .7rem; color: var(--muted); padding: 0 .3rem; }
.outbound .bubble-meta { text-align: right; }

.chat-input-area { display: flex; gap: .75rem; }
.chat-input-area input {
  flex: 1;
  padding: .7rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .95rem;
  font-family: inherit;
  color: var(--text);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.chat-input-area input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(0,200,240,0.10); }

/* ─── CONVERSAS 3-COLUMN ─────────────────────────────────── */
.conv-client-bar {
  display: flex;
  gap: .5rem;
  padding: .625rem 1rem;
  background: var(--sidebar-bg);
  overflow-x: auto;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.conv-client-btn {
  background: rgba(255,255,255,0.03);
  border: none;
  color: var(--sidebar-text);
  border-radius: 2px;
  padding: .3rem .875rem;
  font-size: .7rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: all .15s;
}
.conv-client-btn:hover { background: rgba(0,200,240,0.08); color: var(--cyan); }
.conv-client-btn.active { background: rgba(0,200,240,0.15); color: var(--cyan); }

#page-conversations.page { padding: 0; }
.conv-layout { display: flex; height: 100vh; overflow: hidden; }

.conv-ads {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.conv-leads {
  width: 280px;
  flex-shrink: 0;
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.conv-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #0b1515;
  overflow: hidden;
}

.conv-col-header {
  padding: .875rem 1rem;
  font-weight: 700;
  font-size: .65rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

/* ── WhatsApp-style header ── */
.conv-wa-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .625rem 1rem;
  background: #1a2626;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
  min-height: 56px;
}
.conv-wa-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00c8f0, #007a6e);
  color: #fff;
  font-weight: 700;
  font-size: .95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0;
  text-transform: uppercase;
}
.conv-wa-header-info { flex: 1; min-width: 0; }
.conv-wa-name {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-wa-status { font-size: .72rem; color: #00c8f0; margin-top: 1px; }
.conv-wa-actions { display: flex; gap: .25rem; }
.conv-wa-action-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: .375rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}
.conv-wa-action-btn:hover { background: rgba(255,255,255,0.08); color: var(--cyan); }

.conv-ad-item {
  padding: .75rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  transition: background .15s;
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.conv-ad-item:hover  { background: rgba(0,200,240,0.04); }
.conv-ad-item.active { background: rgba(0,200,240,0.08); border-left: 2px solid var(--cyan); }
.conv-ad-abandoned { border-left: 2px solid #f59e0b; }
.conv-ad-abandoned:hover { background: rgba(245,158,11,0.06); }
.conv-ad-abandoned.active { background: rgba(245,158,11,0.1); border-left: 2px solid #f59e0b; }
.conv-ad-abandoned .conv-ad-title { color: #fcd34d; }
.conv-ad-abandoned .conv-ad-meta { color: #f59e0b; }

.conv-ad-title { font-weight: 600; font-size: .85rem; color: var(--text); word-break: break-word; }
.conv-ad-meta  { font-size: .73rem; color: var(--muted); }
.conv-ad-badge {
  display: inline-block;
  background: var(--cyan);
  color: #000;
  border-radius: 2px;
  font-size: .63rem;
  font-weight: 700;
  padding: .1rem .45rem;
  margin-left: .35rem;
  letter-spacing: 0.05em;
}

.conv-lead-item {
  padding: .75rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  transition: background .15s;
}
.conv-lead-item:hover  { background: rgba(0,200,240,0.04); }
.conv-lead-item.active { background: rgba(0,200,240,0.08); border-left: 2px solid var(--cyan); }

.conv-lead-name    { font-weight: 600; font-size: .875rem; color: var(--text); }
.conv-lead-preview { font-size: .78rem; color: var(--muted); margin-top: .15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.conv-lead-meta    { font-size: .72rem; color: var(--muted2); margin-top: .2rem; display: flex; gap: .5rem; align-items: center; }

.conv-empty { padding: 1.5rem; color: var(--muted); font-size: .875rem; }

.conv-chat-info {
  padding: .75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.conv-chat-info-item { font-size: .8rem; color: var(--muted); }
.conv-chat-info-item strong { color: var(--text); }

/* ── WhatsApp background ── */
.conv-wa-bg {
  background-color: #0b1515;
  background-image:
    radial-gradient(rgba(0,200,240,0.018) 1px, transparent 1px),
    radial-gradient(rgba(0,200,240,0.01) 1px, transparent 1px);
  background-size: 30px 30px, 15px 15px;
  background-position: 0 0, 7px 7px;
}

.conv-messages {
  flex: 1;
  overflow-y: auto;
  padding: .75rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .3rem;
}

/* ── Bubble wrappers for tail positioning ── */
.conv-msg-wrap {
  display: flex;
  flex-direction: column;
}
.conv-msg-wrap.inbound  { align-items: flex-start; }
.conv-msg-wrap.outbound { align-items: flex-end; }
.conv-msg-wrap.system   { align-items: center; }
.conv-msg-wrap + .conv-msg-wrap { margin-top: .15rem; }
/* Group same-direction bubbles tighter */
.conv-msg-wrap.inbound  + .conv-msg-wrap.inbound  { margin-top: 2px; }
.conv-msg-wrap.outbound + .conv-msg-wrap.outbound { margin-top: 2px; }

.conv-msg {
  max-width: 68%;
  padding: .45rem .875rem .45rem .875rem;
  border-radius: 8px;
  font-size: .875rem;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
  position: relative;
}

/* Inbound: dark grey bubble, left tail */
.conv-msg.inbound {
  background: #1e2e2e;
  color: var(--text);
  border-bottom-left-radius: 2px;
  box-shadow: 0 1px 2px rgba(0,0,0,.35);
}
/* Outbound: WhatsApp green bubble, right tail */
.conv-msg.outbound {
  background: #005c4b;
  color: #e9feea;
  border-bottom-right-radius: 2px;
  box-shadow: 0 1px 2px rgba(0,0,0,.35);
}
.conv-msg.system {
  background: rgba(0,0,0,0.35);
  color: var(--muted);
  border-radius: 6px;
  font-size: .73rem;
  padding: .2rem .75rem;
  max-width: 80%;
  text-align: center;
}
.conv-msg.conv-msg-converted {
  background: rgba(0,200,240,0.15);
  border: 1px solid rgba(0,200,240,.35);
  color: var(--cyan);
  font-weight: 700;
  max-width: 90%;
  text-align: center;
  border-radius: 8px;
  box-shadow: none;
}

/* Timestamp + status row inside bubble */
.conv-msg-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .25rem;
  margin-top: .2rem;
}
.conv-msg-time {
  font-size: .67rem;
  opacity: .65;
  white-space: nowrap;
}
.conv-msg.inbound  .conv-msg-time { color: var(--muted); }
.conv-msg.outbound .conv-msg-time { color: #b2dfdb; }
.conv-msg-tick { font-size: .72rem; color: #53bdeb; line-height: 1; } /* blue ticks */
.conv-msg-tick.sent { color: #b2dfdb; }

.conv-msg-sender { font-size: .7rem; font-weight: 700; color: #00c8f0; margin-bottom: .2rem; letter-spacing: 0.03em; }

/* Date separator pill */
.conv-date-sep {
  align-self: center;
  background: rgba(0,0,0,0.4);
  color: var(--muted);
  font-size: .71rem;
  padding: .2rem .75rem;
  border-radius: 8px;
  margin: .6rem 0 .3rem;
}

.conv-msg-error { opacity: .6; outline: 1px solid #ef4444; }

.conv-receipt-card { display: block; text-decoration: none; }
.conv-receipt-preview {
  display: flex; align-items: center; gap: .75rem;
  background: rgba(0,200,240,0.08);
  border: 1px solid rgba(0,200,240,0.25);
  border-radius: 8px;
  padding: .75rem 1rem;
  cursor: pointer;
  transition: background .15s;
}
.conv-receipt-preview:hover { background: rgba(0,200,240,0.14); }
.conv-receipt-icon { font-size: 2rem; line-height: 1; }
.conv-receipt-title { font-size: .85rem; font-weight: 600; color: var(--text); }
.conv-receipt-sub { font-size: .75rem; color: var(--cyan); margin-top: .2rem; }

/* ── Message input bar ── */
.conv-input-bar {
  display: flex;
  align-items: flex-end;
  gap: .5rem;
  padding: .625rem .875rem;
  padding-bottom: calc(.625rem + env(safe-area-inset-bottom, 0px));
  background: #1a2626;
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.conv-input-textarea {
  flex: 1;
  background: #2a3d3d;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  color: var(--text);
  font-family: inherit;
  font-size: .9rem;
  line-height: 1.45;
  padding: .55rem 1rem;
  resize: none;
  outline: none;
  max-height: 120px;
  overflow-y: auto;
  transition: border-color .15s;
}
.conv-input-textarea::placeholder { color: var(--muted); }
.conv-input-textarea:focus { border-color: rgba(0,200,240,0.4); }
.conv-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #00a884;
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s, transform .1s;
}
.conv-send-btn:hover  { background: #00c49a; }
.conv-send-btn:active { transform: scale(.93); }

.conv-attach-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: color .15s, background .15s;
}
.conv-attach-btn:hover { color: var(--cyan); background: rgba(0,200,240,0.08); }

/* Media preview bubble */
.conv-msg-media { max-width: 240px; border-radius: 8px; display: block; margin-bottom: .35rem; }
.conv-msg-media-doc {
  display: flex; align-items: center; gap: .5rem;
  background: rgba(255,255,255,0.06); border-radius: 8px; padding: .5rem .75rem;
  font-size: .82rem; margin-bottom: .35rem;
}

.conv-back-btn { display: none; }

/* ─── BAR CHART ──────────────────────────────────────────── */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: .5rem;
  height: 150px;
  padding: 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.bar-item { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; gap: .3rem; }
.bar-fill {
  width: 100%;
  background: linear-gradient(180deg, var(--cyan), var(--cyan-hover));
  border-radius: 2px 2px 0 0;
  min-height: 4px;
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  transition: height .4s cubic-bezier(.4,0,.2,1);
  box-shadow: 0 0 12px rgba(0,200,240,0.3);
}
.bar-value { font-size: .68rem; font-weight: 700; color: #000; padding-top: 2px; }
.bar-label { font-size: .67rem; color: var(--muted); }
.bar-fill-blue { background: linear-gradient(180deg, #3b82f6, #1d4ed8) !important; box-shadow: 0 0 10px rgba(59,130,246,0.25) !important; }

/* ─── SOURCES ────────────────────────────────────────────── */
.sources-grid {
  display: flex;
  flex-direction: column;
  gap: .875rem;
  background: var(--surface);
  padding: 1.125rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.source-item { display: grid; grid-template-columns: 220px 1fr 100px; align-items: center; gap: 1rem; }
.source-label { font-size: .875rem; color: var(--text); }
.source-bar-wrap { background: var(--surface-3); border-radius: 2px; height: 5px; overflow: hidden; }
.source-bar-fill { height: 100%; background: var(--cyan); border-radius: 2px; transition: width .5s; }
.source-count { font-size: .875rem; color: var(--muted); }

/* ─── FUNNEL ─────────────────────────────────────────────── */
.funnel-wrap { display: flex; flex-direction: column; gap: .625rem; margin-bottom: .875rem; }
.funnel-step { display: flex; align-items: center; gap: .875rem; }
.funnel-bar {
  background: linear-gradient(90deg, var(--cyan), var(--cyan-hover));
  border-radius: 0 3px 3px 0;
  padding: .65rem 1.125rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-width: 130px;
  transition: width .5s cubic-bezier(.4,0,.2,1);
  box-shadow: 0 2px 16px rgba(0,200,240,0.25);
  position: relative;
  overflow: hidden;
}
.funnel-bar::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(255,255,255,.1), transparent);
  pointer-events: none;
}
.funnel-label { color: #000; font-size: .8rem; font-weight: 800; white-space: nowrap; letter-spacing: 0.08em; text-transform: uppercase; }
.funnel-count { color: #000; font-size: 1.2rem; font-weight: 800; }
.funnel-drop  { font-size: .78rem; color: #fca5a5; white-space: nowrap; }
.funnel-meta  { display: flex; gap: 1.5rem; font-size: .875rem; color: var(--muted); padding: .5rem 0 1rem; flex-wrap: wrap; }
.funnel-meta strong { color: var(--text); }

.meta-badge {
  background: #1877f2;
  color: #fff;
  border-radius: 2px;
  padding: .1rem .55rem;
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ─── STUCK LEADS ────────────────────────────────────────── */
.stuck-header { display: flex; align-items: center; justify-content: space-between; margin-top: 2rem; margin-bottom: 1rem; }
.stuck-header h3 { margin: 0; }
.stuck-leads-list { display: flex; flex-direction: column; gap: .5rem; }
.stuck-lead-item {
  background: var(--surface);
  border: 1px solid rgba(245,158,11,0.18);
  border-left: 3px solid var(--warning);
  border-radius: var(--radius);
  padding: .875rem 1.125rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  transition: border-color .15s;
}
.stuck-lead-item:hover { border-color: rgba(245,158,11,0.35); border-left-color: var(--warning); }
.stuck-lead-info { flex: 1; min-width: 120px; }
.stuck-lead-info strong { display: block; color: var(--text); }
.stuck-client { font-size: .8rem; color: var(--muted); margin-top: .15rem; }
.stuck-lead-meta { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }

/* ─── CONVERSION TABS ────────────────────────────────────── */
.conv-tabs { display: flex; gap: .5rem; }
.conv-tab {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .45rem 1.1rem;
  cursor: pointer;
  font-size: .75rem;
  font-family: inherit;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: all .15s;
}
.conv-tab:hover { border-color: var(--cyan); color: var(--cyan); }
.conv-tab.active {
  background: var(--cyan);
  color: #000;
  border-color: transparent;
  font-weight: 800;
  box-shadow: 0 2px 12px rgba(0,200,240,0.35);
}

.conv-chart-wrap { margin-top: 1.125rem; }
.conv-bar-chart  { height: 170px; }

.conv-rate { padding: .18rem .6rem; border-radius: 2px; font-size: .72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.rate-good { background: rgba(0,200,240,0.15); color: var(--cyan); }
.rate-mid  { background: rgba(245,158,11,0.15); color: #fcd34d; }
.rate-low  { background: rgba(239,68,68,0.15);  color: #fca5a5; }

#stuck-days-select {
  padding: .25rem .5rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: .82rem;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  outline: none;
}
#stuck-days-select:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(0,200,240,0.10); }
#stuck-days-select option { background: var(--surface-2); }

#profile-success { color: var(--cyan); font-size: .875rem; margin-top: .5rem; }

/* ─── REPORTS PAGE ──────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* ─── RESPONSIVE MOBILE ──────────────────────────────────── */
/* ── MOBILE HOME SCREEN ──────────────────────────────────── */
.mob-home {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg); overflow-y: auto;
  display: flex; flex-direction: column;
  /* iOS safe area padding */
  padding-top: env(safe-area-inset-top);
  padding-bottom: calc(2rem + env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch;
}
.mob-home-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg); z-index: 10;
}
.mob-home-brand { display: flex; align-items: center; gap: .5rem; }
.mob-home-greeting { padding: 1.25rem 1.25rem .5rem; }
.mob-cards-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: .75rem; padding: .75rem 1rem 1rem;
}
.mob-card {
  display: flex; flex-direction: column; align-items: center;
  gap: .55rem; padding: 1rem .5rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; cursor: pointer; transition: transform .12s, border-color .12s;
  font-size: .72rem; font-weight: 600; color: var(--text); text-align: center;
}
.mob-card:active { transform: scale(.94); border-color: var(--cyan-border); }
.mob-card-icon {
  width: 48px; height: 48px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
}
.mob-card-icon svg { width: 22px; height: 22px; }

/* ── MOBILE BOTTOM BAR ───────────────────────────────────── */
.mob-bottom-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  background: var(--surface); border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  /* safe-area-inset-bottom for iPhone home bar */
  padding: .55rem 1.25rem;
  padding-bottom: calc(.55rem + env(safe-area-inset-bottom));
  /* Prevent iOS scroll bleed */
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.mob-home-btn {
  display: flex; align-items: center; gap: .4rem;
  background: var(--cyan-dim); border: 1px solid var(--cyan-border);
  color: var(--cyan); border-radius: 10px; padding: .45rem .9rem;
  font-size: .78rem; font-weight: 700; cursor: pointer;
}

@media (max-width: 768px) {
  #app-screen { flex-direction: column; height: 100dvh; }

  /* Sidebar hidden on mobile when using card home */
  .sidebar { display: none; }

  /* Content takes full height minus bottom bar + iOS home bar */
  .content {
    padding: .875rem .875rem calc(4rem + env(safe-area-inset-bottom));
    overflow-y: auto; flex: 1;
    height: 100vh; height: 100dvh;
    -webkit-overflow-scrolling: touch;
  }
  .page h2 { font-size: 2rem; margin-bottom: .875rem; }
  .page h3 { font-size: 1.2rem; margin: 1.25rem 0 .625rem; }
  .page h2::after { display: none; }
  .sidebar-header { padding: .625rem .875rem; border-bottom: none; flex-shrink: 0; }
  .logo { font-size: 1.1rem; }
  #wa-indicator { display: none; }
  nav {
    display: flex; flex-direction: row; overflow-x: auto; flex: 1;
    scrollbar-width: none; padding: 0; gap: 0;
  }
  nav::-webkit-scrollbar { display: none; }
  .nav-item {
    padding: .7rem .75rem; white-space: nowrap;
    border-left: none; border-radius: 0;
    border-bottom: 2px solid transparent; font-size: .7rem;
  }
  .nav-item:hover, .nav-item.active {
    border-left-color: transparent;
    border-bottom-color: var(--cyan);
    background: rgba(0,200,240,0.08);
    color: var(--cyan);
  }
  /* sidebar fully hidden — see new mob-home above */

  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: .625rem; }
  .stat-card { padding: .875rem 1rem; }
  .stat-value { font-size: 2.8rem; }
  .stat-label { font-size: .66rem; }

  .page-header { flex-wrap: wrap; gap: .5rem; }
  .page-header h2 { font-size: 1.6rem; }
  .page-header .btn-primary { font-size: .85rem; padding: .45rem .8rem; }

  .filters { flex-direction: column; gap: .5rem; }

  .leads-table { display: block; overflow-x: auto; white-space: nowrap; font-size: .8rem; -webkit-overflow-scrolling: touch; }
  .leads-table th, .leads-table td { padding: .55rem .75rem; }

  .source-item { grid-template-columns: 1fr; gap: .25rem; }
  .funnel-meta { gap: .75rem; font-size: .8rem; }
  .bar-chart { height: 110px; padding: .75rem .5rem; gap: .3rem; }
  .bar-label { font-size: .63rem; }
  .clients-grid { grid-template-columns: 1fr; }

  .modal { align-items: flex-end; }
  .modal-content {
    margin: 0; padding: 1.375rem; max-width: 100%;
    border-radius: 8px 8px 0 0;
    max-height: 90dvh; overflow-y: auto;
  }

  .chat-messages { max-height: calc(100dvh - 280px); }
  .chat-bubble { max-width: 88%; }
  #qr-image { max-width: 190px; }
  .wa-status-card { padding: 1.125rem; }

  #page-conversations { height: calc(100dvh - 48px); }
  .conv-client-bar { padding: .5rem .75rem; gap: .375rem; }
  .conv-client-btn { font-size: .7rem; padding: .3rem .75rem; }
  .conv-layout { flex-direction: column; height: 100%; }

  .conv-ads   { width: 100%; height: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .conv-leads { width: 100%; height: 100%; border-right: none; border-bottom: 1px solid var(--border); display: none; }
  .conv-chat  { width: 100%; height: 100%; display: none; }

  .conv-ads.mob-hidden   { display: none; }
  .conv-leads.mob-active { display: flex; }
  .conv-chat.mob-active  { display: flex; }

  .conv-col-header { display: flex; align-items: center; gap: .5rem; }
  .conv-back-btn {
    display: inline-flex; align-items: center; justify-content: center;
    background: none; border: none; color: var(--cyan); font-size: 1.4rem;
    cursor: pointer; padding: 0 .25rem; line-height: 1; font-weight: 700;
  }

  .conv-msg { max-width: 85%; }
  .conv-messages { padding: .5rem .5rem .75rem; }
  .stuck-lead-item { flex-direction: column; gap: .5rem; align-items: flex-start; }
  .conv-tabs { flex-wrap: wrap; }
  .conv-tab { font-size: .75rem; padding: .35rem .75rem; }
}

@media (max-width: 420px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: .5rem; }
  .stat-value { font-size: 2.4rem; }
  .nav-item { padding: .65rem .6rem; font-size: .68rem; }
  .leads-table { font-size: .76rem; }
}

/* ===== ANALYST FULL PAGE ===== */
.content:has(#page-analyst:not(.hidden)) {
  padding: 0;
  overflow: hidden;
}
#page-analyst {
  padding: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#analyst-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 20px;
  position: relative;
  width: 100%;
}
#analyst-page-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-top: 80px;
  text-align: center;
  transition: all 0.3s ease;
}
#analyst-page-header.compact {
  padding-top: 20px;
  padding-bottom: 10px;
}
#analyst-logo {
  font-size: 48px;
  margin-bottom: 16px;
  filter: drop-shadow(0 0 20px rgba(108,99,255,0.5));
}
#analyst-page-header.compact #analyst-logo { font-size: 28px; margin-bottom: 8px; }
#analyst-greeting {
  font-size: 32px;
  font-weight: 700;
  background: linear-gradient(135deg, #6c63ff, #3ecfcf);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}
#analyst-page-header.compact #analyst-greeting { font-size: 18px; }
#analyst-subtitle {
  color: rgba(255,255,255,0.5);
  font-size: 14px;
  margin-bottom: 40px;
}
#analyst-page-header.compact #analyst-subtitle { display: none; }
#analyst-page-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 32px;
  width: 100%;
}
#analyst-page-suggestions.hidden { display: none; }
.analyst-suggestion {
  background: rgba(108,99,255,0.1);
  border: 1px solid rgba(108,99,255,0.25);
  border-radius: 20px;
  color: rgba(255,255,255,0.75);
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.analyst-suggestion:hover {
  background: rgba(108,99,255,0.2);
  border-color: rgba(108,99,255,0.5);
  color: white;
}
#analyst-page-messages {
  width: 100%;
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
#analyst-page-messages.hidden { display: none; }
.analyst-page-msg { display: flex; gap: 12px; width: 100%; }
.analyst-page-msg-user { flex-direction: row-reverse; }
.analyst-page-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.analyst-page-msg-ai .analyst-page-avatar {
  background: linear-gradient(135deg, #6c63ff, #3ecfcf);
}
.analyst-page-msg-user .analyst-page-avatar {
  background: rgba(255,255,255,0.1);
}
.analyst-page-bubble {
  max-width: calc(100% - 52px);
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
}
.analyst-page-msg-ai .analyst-page-bubble {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text, #e0e0e0);
  border-top-left-radius: 4px;
}
.analyst-page-msg-user .analyst-page-bubble {
  background: linear-gradient(135deg, rgba(108,99,255,0.3), rgba(62,207,207,0.2));
  border: 1px solid rgba(108,99,255,0.3);
  color: white;
  border-top-right-radius: 4px;
}
.analyst-typing-dots {
  color: rgba(255,255,255,0.4);
  font-style: italic;
}
#analyst-page-input-wrap {
  width: 100%;
  padding: 16px 0 24px;
  position: sticky;
  bottom: 0;
  background: linear-gradient(to top, var(--bg, #0f0f1a) 80%, transparent);
}
#analyst-page-input-box {
  display: flex;
  align-items: flex-end;
  background: rgba(255,255,255,0.06);
  border: 1.5px solid rgba(108,99,255,0.3);
  border-radius: 16px;
  padding: 12px 14px;
  gap: 10px;
  transition: border-color 0.2s;
}
#analyst-page-input-box:focus-within {
  border-color: rgba(108,99,255,0.7);
}
#analyst-page-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text, #e0e0e0);
  font-size: 14px;
  font-family: inherit;
  resize: none;
  max-height: 200px;
  line-height: 1.5;
}
#analyst-page-input::placeholder { color: rgba(255,255,255,0.3); }
#analyst-page-send {
  background: linear-gradient(135deg, #6c63ff, #3ecfcf);
  border: none;
  border-radius: 10px;
  color: white;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s;
}
#analyst-page-send:hover { opacity: 0.85; }
#analyst-page-hint {
  text-align: center;
  font-size: 11px;
  color: rgba(255,255,255,0.2);
  margin-top: 8px;
}

/* ===== SMOOTH ANIMATIONS & CAKTO-STYLE REDESIGN ===== */

/* Page fade-in transition */
.page:not(.hidden) {
  animation: pageIn 0.25s ease forwards;
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Nav items - smooth hover (enhance existing transitions) */
.nav-item {
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease !important;
  border-left: 3px solid transparent;
  border-radius: 0 8px 8px 0;
  margin-right: 8px;
}

/* CRM Sub-navigation in sidebar */
.crm-subnav {
  overflow: hidden;
}
.crm-subnav.hidden { display: none; }
.nav-subitem {
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .32rem .875rem .32rem 2.25rem;
  font-size: .74rem;
  color: var(--muted);
  cursor: pointer;
  border-left: 2px solid transparent;
  border-radius: 0 8px 8px 0;
  margin-right: 8px;
  text-decoration: none;
  transition: color .15s, background .15s;
  position: relative;
}
.nav-subitem::before {
  content: '';
  position: absolute;
  left: 1.1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--muted);
  opacity: .5;
  transition: background .15s, opacity .15s;
}
.nav-subitem:hover { color: var(--text); background: rgba(255,255,255,.04); }
.nav-subitem:hover::before { opacity: .8; }
.nav-subitem.active {
  color: var(--cyan);
  background: rgba(0,200,240,.08);
  border-left-color: var(--cyan);
  font-weight: 600;
}
.nav-subitem.active::before { background: var(--cyan); opacity: 1; }

/* Hide horizontal CRM tabs on desktop (sidebar handles navigation) */
@media (min-width: 769px) {
  .crm-tabs { display: none !important; }
}
.nav-item:hover {
  background: rgba(108,99,255,0.12) !important;
  color: #a89fff !important;
  border-left-color: rgba(108,99,255,0.4);
}
.nav-item.active {
  background: rgba(108,99,255,0.18) !important;
  color: #6c63ff !important;
  border-left-color: #6c63ff !important;
  font-weight: 600;
}

/* Stat cards - hover lift */
.stat-card {
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease !important;
}
.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  border-color: rgba(108,99,255,0.3) !important;
}

/* Dashboard stat cards - bigger, cleaner */
.stats-grid .stat-card {
  padding: 20px 24px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.03);
}
.stat-card .stat-value {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.stat-card .stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  opacity: 0.5;
  margin-bottom: 8px;
}

/* All buttons - smooth */
button,
.btn-primary,
.btn-sm,
.btn-edit,
.btn-danger {
  transition: all 0.18s ease !important;
}
button:hover,
.btn-primary:hover {
  transform: translateY(-1px);
  filter: brightness(1.1);
}
button:active,
.btn-primary:active {
  transform: translateY(0);
}

/* Modal - slide up + fade */
.modal-content {
  animation: modalIn 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Table rows - smooth hover */
.leads-table tr {
  transition: background 0.15s ease !important;
}
.leads-table tbody tr:hover td {
  background: rgba(108,99,255,0.08) !important;
}

/* Inputs & selects - smooth focus */
input,
textarea,
select {
  transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
}
input:focus,
textarea:focus,
select:focus {
  border-color: rgba(108,99,255,0.6) !important;
  box-shadow: 0 0 0 3px rgba(108,99,255,0.12) !important;
  outline: none !important;
}

/* Client cards */
.client-card {
  transition: transform 0.22s ease, box-shadow 0.22s ease !important;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.06);
}

/* Conversations - lead items */
.conv-lead-item {
  transition: background 0.15s ease, border-left-color 0.15s ease !important;
  border-left: 3px solid transparent;
}
.conv-lead-item:hover {
  background: rgba(108,99,255,0.1) !important;
  border-left-color: rgba(108,99,255,0.4);
}
.conv-lead-item.active {
  border-left-color: #6c63ff !important;
}

/* ─── TABLE enhancements ─────────────────────────────── */
.leads-table .btn-edit {
  background: rgba(0,200,240,0.08);
  border: 1px solid rgba(0,200,240,0.18);
  color: var(--cyan);
  border-radius: 5px;
  padding: .3rem .75rem;
  font-size: .68rem;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all .15s;
}
.leads-table .btn-edit:hover {
  background: rgba(0,200,240,0.16);
  transform: translateY(0) !important;
  filter: none !important;
}
.leads-table .btn-danger {
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.2);
  color: #fca5a5;
  border-radius: 5px;
  padding: .3rem .75rem;
  font-size: .68rem;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all .15s;
}
.leads-table .btn-danger:hover {
  background: rgba(239,68,68,0.15);
  transform: translateY(0) !important;
  filter: none !important;
}
.leads-table td:has(.btn-edit) { white-space: nowrap; }

/* Phone cell - truncate */
.leads-table .td-phone {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: .8rem;
  font-family: monospace;
}

/* Name cell */
.leads-table .td-name {
  font-weight: 600;
  color: var(--text);
}

/* ─── LEADS PAGE HEADER ──────────────────────────────── */
.leads-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

/* ─── DATE RANGE PICKER ──────────────────────────────── */
.conv-date-range {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .75rem 0;
  animation: fadeInDown 0.2s ease;
}

.conv-date-range input[type="date"] {
  padding: .5rem .875rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .82rem;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  color-scheme: dark;
}

.conv-date-range input[type="date"]:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(0,200,240,0.10);
}

.conv-date-range .date-sep {
  color: var(--muted2);
  font-size: .8rem;
  font-weight: 600;
}

.conv-date-range .btn-date-apply {
  padding: .5rem 1.25rem;
  background: var(--cyan);
  color: #000;
  border: none;
  border-radius: var(--radius);
  font-family: 'Bebas Neue', sans-serif;
  font-size: .95rem;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: background .2s, transform .15s;
  box-shadow: 0 2px 12px rgba(0,200,240,0.25);
}

.conv-date-range .btn-date-apply:hover {
  background: var(--cyan-hover);
  transform: translateY(-1px) !important;
  filter: none !important;
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── GRUPOS WHATSAPP ────────────────────────────────── */
.conv-ad-groups {
  border-left: 3px solid #25d366 !important;
  background: rgba(37,211,102,0.04) !important;
}
.conv-ad-groups:hover {
  background: rgba(37,211,102,0.08) !important;
}
.conv-ad-groups.active {
  background: rgba(37,211,102,0.12) !important;
  border-left-color: #25d366 !important;
}

.conv-msg-group-sender {
  font-size: .68rem;
  font-weight: 700;
  color: var(--cyan);
  margin-bottom: .2rem;
  letter-spacing: 0.02em;
}

/* ─── LOGIN RESPONSIVE ───────────────────────────────── */
@media (max-width: 768px) {
  .login-left { display: none; }
  .login-right {
    width: 100%; border-left: none;
    /* iOS: allow scroll when keyboard opens */
    overflow-y: auto; -webkit-overflow-scrolling: touch;
    padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  }
  /* Login screen needs to scroll on iOS when keyboard is open */
  #login-screen { overflow-y: auto; align-items: flex-start; }
  .login-card { margin: auto; width: 100%; max-width: 100%; }
}

/* Conv ad folders */
.conv-ad-item {
  transition: background 0.18s ease, transform 0.18s ease !important;
  border-radius: 8px;
}
.conv-ad-item:hover {
  transform: translateX(3px);
  background: rgba(108,99,255,0.1) !important;
}
.conv-ad-item.active {
  background: rgba(108,99,255,0.18) !important;
  border-left: 3px solid #6c63ff;
}

/* Status badges - subtle pulse on "new" */
.status-new {
  animation: subtlePulse 2.5s ease infinite;
}
@keyframes subtlePulse {
  0%,  100% { box-shadow: 0 0 0 0 rgba(62,207,207,0.3); }
  50%        { box-shadow: 0 0 0 4px rgba(62,207,207,0); }
}

/* Page headers */
.page-header {
  padding-bottom: 20px;
  margin-bottom: 24px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

/* Sidebar logo area glow */
.logo {
  position: relative;
}

/* Scrollbar refinement */
::-webkit-scrollbar       { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(108,99,255,0.3); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(108,99,255,0.5); }

/* Analyst suggestions */
.analyst-suggestion {
  transition: all 0.2s ease !important;
}
.analyst-suggestion:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(108,99,255,0.2);
}

/* Toast animation (matches any .toast class added via JS) */
.toast {
  animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(16px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ─── MOBILE RESPONSIVE ──────────────────────────────────── */
@media (max-width: 768px) {
  /* Layout */
  #app-screen { flex-direction: column; }

  /* Sidebar vira barra inferior */
  .sidebar {
    width: 100%;
    height: auto;
    flex-direction: row;
    padding: 0;
    border-right: none;
    border-top: 1px solid var(--border-light);
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 100;
    background: var(--sidebar-bg);
    order: 2;
  }

  .sidebar::after { display: none; }

  /* Esconde header e footer da sidebar no mobile */
  .sidebar-header,
  .sidebar-footer { display: none; }

  /* Nav vira barra horizontal */
  nav {
    flex-direction: row;
    padding: 0;
    gap: 0;
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }
  nav::-webkit-scrollbar { display: none; }

  .nav-item {
    flex: 1;
    min-width: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: .55rem .25rem .45rem;
    font-size: .55rem;
    border-left: none !important;
    border-radius: 0 !important;
    border-bottom: 2px solid transparent;
    text-align: center;
    letter-spacing: 0.05em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .nav-item::before {
    content: attr(data-icon);
    font-size: 1.1rem;
    margin-bottom: .15rem;
    display: block;
  }

  .nav-item:hover,
  .nav-item.active {
    border-left-color: transparent !important;
    border-bottom-color: var(--cyan) !important;
    background: rgba(0,200,240,0.08);
  }

  /* Content ocupa o espaço acima */
  .content {
    padding: 1.25rem 1rem 5rem;
    order: 1;
    min-height: 100vh;
  }

  /* Títulos menores */
  .page h2 { font-size: 2rem; }

  /* Stats em 2 colunas */
  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  /* Filtros em coluna */
  .filters { flex-direction: column; }

  /* Tabela com scroll horizontal */
  .leads-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Page header empilha */
  .page-header { flex-wrap: wrap; }

  /* Login em coluna */
  #login-screen { flex-direction: column; }
  .login-left { display: none; }
  .login-right { width: 100%; min-height: 100vh; border-left: none; border-top: none; }
}

/* ─── PRINT / PDF (dark mode) ────────────────────────────────────────────────── */
@media print {
  /* Força o browser a imprimir cores de fundo e texto */
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }

  /* Esconde tudo que não é o relatório */
  #login-screen, .sidebar, #page-reports .page-header button,
  #page-reports input[type="date"], #page-reports select { display: none !important; }

  /* Layout: só a seção de relatórios aparece */
  body { background: #0f0f1a !important; margin: 0; }
  #app-screen { display: block !important; }
  main { display: block !important; padding: 16px 24px !important; background: #0f0f1a !important; }
  #page-reports { display: block !important; }
  .page:not(#page-reports) { display: none !important; }

  /* Cabeçalho */
  #page-reports .page-header { display: flex !important; margin-bottom: 20px; flex-wrap: nowrap; }
  #page-reports h2 { color: #fff !important; font-size: 22px; }

  /* KPI Cards — garante fundo e cor do valor */
  .stat-card {
    background: #1a1a2e !important;
    border: 1px solid rgba(255,255,255,0.12) !important;
    border-bottom: 2px solid #00c8f0 !important;
    break-inside: avoid;
  }
  .stat-card .stat-label,
  .stat-label { color: rgba(255,255,255,0.5) !important; }
  .stat-card .stat-value,
  .stat-value { color: #00c8f0 !important; }

  /* Cards genéricos (gráficos, funil, tabela) */
  .card {
    background: #1a1a2e !important;
    border: 1px solid rgba(255,255,255,0.08) !important;
    break-inside: avoid;
    margin-bottom: 14px;
  }
  .card h4 { color: rgba(255,255,255,0.5) !important; }

  /* Tabela */
  .leads-table th { background: rgba(255,255,255,0.05) !important; color: rgba(255,255,255,0.55) !important; }
  .leads-table td { color: #ddd !important; border-color: rgba(255,255,255,0.06) !important; }
  .leads-table tr:nth-child(even) td { background: rgba(255,255,255,0.03) !important; }

  /* Funil */
  #report-funnel > div { background: rgba(255,255,255,0.04) !important; border: 1px solid rgba(255,255,255,0.07) !important; }
  #report-funnel > div > div { color: #fff !important; }

  /* Gráficos */
  #chart-daily, #chart-ads-donut { max-height: 200px !important; }

  /* Sem quebra de página no meio dos blocos */
  .stats-grid, #report-funnel, #report-ads-table { break-inside: avoid; }

  /* Rodapé com data */
  #page-reports::after {
    content: "Gerado em " attr(data-print-date) " · Closy CRM";
    display: block;
    text-align: center;
    color: rgba(255,255,255,0.3);
    font-size: 11px;
    margin-top: 28px;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.08);
  }
}

/* ═══════════════════════════════════════════════════════════════════
   CRM — Premium Dark Design
═══════════════════════════════════════════════════════════════════ */

.crm-page {
  padding: 0; display: flex; flex-direction: column;
  height: 100%; height: 100dvh; overflow: hidden;
  background: #080c14;
  --crm-bg:       #080c14;
  --crm-surface:  #0d1320;
  --crm-surface2: #111826;
  --crm-border:   rgba(255,255,255,0.07);
  --crm-border2:  rgba(255,255,255,0.04);
  --crm-muted:    rgba(255,255,255,0.38);
  --crm-muted2:   rgba(255,255,255,0.22);
  --crm-text:     rgba(255,255,255,0.92);
  --crm-cyan:     #00c8f0;
  --crm-cyan-dim: rgba(0,200,240,0.1);
  --crm-cyan-border: rgba(0,200,240,0.2);
}

.crm-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem; border-bottom: 1px solid var(--crm-border);
  background: var(--crm-surface); flex-shrink: 0; gap: 1rem; min-height: 52px;
}
.crm-tabs { display: flex; gap: 0; height: 52px; }
.crm-tab {
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--crm-muted); padding: 0 1.1rem; font-size: .82rem; font-weight: 500;
  cursor: pointer; transition: color .15s, border-color .15s; white-space: nowrap;
  display: flex; align-items: center; gap: .4rem;
}
.crm-tab:hover { color: var(--crm-text); }
.crm-tab.active { color: var(--crm-cyan); border-bottom-color: var(--crm-cyan); font-weight: 600; }
.crm-topbar-right select {
  padding: .3rem .75rem; border-radius: 8px; border: 1px solid var(--crm-border);
  background: var(--crm-bg); color: var(--crm-text); font-size: .8rem;
}

.crm-stats-bar {
  display: flex; border-bottom: 1px solid var(--crm-border); flex-shrink: 0;
  background: var(--crm-surface);
}
.crm-stat {
  flex: 1; display: flex; align-items: center; gap: .75rem;
  padding: .65rem 1.5rem; border-right: 1px solid var(--crm-border2);
}
.crm-stat:last-child { border-right: none; }
.crm-stat span { font-size: 1.35rem; font-weight: 800; color: var(--crm-cyan); font-family: 'Bebas Neue', sans-serif; line-height: 1; }
.crm-stat label { font-size: .68rem; color: var(--crm-muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 500; margin-top: 2px; }

.crm-tab-content { flex: 1; overflow: hidden; display: flex; flex-direction: column; min-height: 0; }
.crm-tab-content.hidden { display: none; }

.crm-layout { display: flex; flex: 1; overflow: hidden; min-height: 0; }

.crm-ticket-list {
  width: 310px; min-width: 280px; border-right: 1px solid var(--crm-border);
  display: flex; flex-direction: column; flex-shrink: 0;
  background: var(--crm-surface);
}
.crm-list-header {
  padding: .85rem .85rem .65rem; display: flex; flex-direction: column; gap: .5rem;
  border-bottom: 1px solid var(--crm-border); flex-shrink: 0;
}
.crm-list-header input {
  width: 100%; padding: .5rem .75rem; border-radius: 8px;
  border: 1px solid var(--crm-border); background: var(--crm-bg);
  color: var(--crm-text); font-size: .82rem; transition: border-color .15s;
}
.crm-list-header input::placeholder { color: var(--crm-muted2); }
.crm-list-header input:focus { outline: none; border-color: var(--crm-cyan-border); }
.crm-list-header select {
  width: 100%; padding: .4rem .75rem; border-radius: 8px;
  border: 1px solid var(--crm-border); background: var(--crm-bg);
  color: var(--crm-text); font-size: .8rem;
}
.crm-tickets-scroll { flex: 1; overflow-y: auto; }
.crm-tickets-scroll::-webkit-scrollbar { width: 3px; }
.crm-tickets-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }

.crm-ticket-item {
  display: flex; align-items: flex-start; gap: .75rem;
  padding: .9rem 1rem; border-bottom: 1px solid var(--crm-border2);
  cursor: pointer; transition: background .1s;
}
.crm-ticket-item:hover { background: rgba(255,255,255,.03); }
.crm-ticket-item.active {
  background: var(--crm-cyan-dim);
  border-left: 2px solid var(--crm-cyan);
  padding-left: calc(1rem - 2px);
}

.crm-ticket-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: .82rem; font-weight: 700; color: #fff;
}
.crm-ticket-avatar-img {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  object-fit: cover; display: block; border: 1.5px solid rgba(255,255,255,.08);
}

.crm-ticket-body { flex: 1; min-width: 0; }
.crm-ticket-row1 { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.crm-ticket-name { font-size: .86rem; font-weight: 600; color: var(--crm-text); display: flex; align-items: center; gap: .4rem; }
.crm-ticket-time { font-size: .68rem; color: var(--crm-muted2); flex-shrink: 0; }
.crm-ticket-row2 { display: flex; align-items: center; justify-content: space-between; gap: .4rem; }
.crm-ticket-preview { font-size: .77rem; color: var(--crm-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.crm-ticket-badges { display: flex; align-items: center; gap: .3rem; flex-shrink: 0; }
.crm-ticket-unread {
  background: var(--crm-cyan); color: #000; border-radius: 20px;
  font-size: .62rem; font-weight: 800; min-width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center; padding: 0 5px;
}

.crm-status-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.crm-status-dot.new       { background: #3b82f6; box-shadow: 0 0 5px #3b82f666; }
.crm-status-dot.waiting   { background: #f59e0b; box-shadow: 0 0 5px #f59e0b66; }
.crm-status-dot.attending { background: #00c8f0; box-shadow: 0 0 5px #00c8f066; }
.crm-status-dot.resolved  { background: rgba(255,255,255,.25); }

.crm-silence-badge { font-size: .62rem; padding: 2px 7px; border-radius: 20px; font-weight: 600; white-space: nowrap; }
.crm-silence-badge.warn   { background: rgba(245,158,11,.15); color: #f59e0b; border: 1px solid rgba(245,158,11,.2); }
.crm-silence-badge.danger { background: rgba(239,68,68,.12);  color: #ef4444; border: 1px solid rgba(239,68,68,.18); }

.crm-chat-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; background: var(--crm-bg); }

.crm-chat-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--crm-muted); gap: 1rem;
}
.crm-chat-empty span { font-size: 3rem; opacity: .25; filter: grayscale(1); }
.crm-chat-empty p { font-size: .88rem; opacity: .4; }
.crm-chat-active { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.crm-chat-header {
  padding: .75rem 1.25rem; border-bottom: 1px solid var(--crm-border);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--crm-surface); flex-shrink: 0; min-height: 58px;
}
.crm-chat-header-info { display: flex; align-items: center; gap: .85rem; }
.crm-chat-avatar {
  width: 38px; height: 38px; border-radius: 50%; background: var(--crm-surface2);
  display: flex; align-items: center; justify-content: center;
  font-size: .88rem; font-weight: 700; color: var(--crm-cyan); flex-shrink: 0; overflow: hidden;
}
.crm-chat-name { font-weight: 600; font-size: .95rem; color: var(--crm-text); line-height: 1.2; }
.crm-chat-phone { font-size: .73rem; color: var(--crm-muted); margin-top: 2px; }
.crm-chat-actions { display: flex; align-items: center; gap: .5rem; }
.crm-status-select {
  font-size: .78rem; padding: .3rem .75rem; border-radius: 8px;
  border: 1px solid var(--crm-border); background: var(--crm-bg); color: var(--crm-text);
  cursor: pointer; transition: border-color .15s;
}
.crm-status-select:focus { outline: none; border-color: var(--crm-cyan-border); }

.crm-messages {
  flex: 1; overflow-y: auto; padding: 1.25rem;
  display: flex; flex-direction: column; gap: .65rem;
  background: var(--crm-bg);
}
.crm-messages::-webkit-scrollbar { width: 3px; }
.crm-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 2px; }

.crm-msg { display: flex; flex-direction: column; max-width: 65%; }
.crm-msg.inbound  { align-self: flex-start; }
.crm-msg.outbound { align-self: flex-end; }
.crm-msg-bubble { padding: .6rem 1rem; border-radius: 14px; font-size: .875rem; line-height: 1.5; word-break: break-word; }
.crm-msg.inbound .crm-msg-bubble {
  background: var(--crm-surface2); color: var(--crm-text);
  border-bottom-left-radius: 4px; border: 1px solid var(--crm-border);
}
.crm-msg.outbound .crm-msg-bubble {
  background: var(--crm-cyan); color: #000; font-weight: 500; border-bottom-right-radius: 4px;
}
.crm-msg-time { font-size: .64rem; color: var(--crm-muted2); margin-top: 4px; padding: 0 2px; }
.crm-msg.outbound .crm-msg-time { text-align: right; color: rgba(0,200,240,.45); }

.crm-date-sep {
  text-align: center; font-size: .7rem; color: var(--crm-muted2);
  padding: .2rem 1rem; margin: .25rem auto;
  background: var(--crm-surface); border-radius: 20px;
  border: 1px solid var(--crm-border2); align-self: center;
}

.crm-qr-suggestions {
  padding: .5rem .85rem; border-top: 1px solid var(--crm-border);
  background: var(--crm-surface); display: flex; gap: .35rem; flex-wrap: wrap; flex-shrink: 0;
}
.crm-qr-chip {
  background: var(--crm-surface2); border: 1px solid var(--crm-border);
  color: var(--crm-text); border-radius: 8px; padding: .25rem .75rem;
  font-size: .78rem; cursor: pointer; transition: all .12s; display: flex; align-items: center; gap: .3rem;
}
.crm-qr-chip:hover { background: var(--crm-cyan); color: #000; border-color: var(--crm-cyan); }
.crm-qr-chip-shortcut { color: var(--crm-cyan); font-weight: 700; font-family: monospace; }
.crm-qr-chip:hover .crm-qr-chip-shortcut { color: #000; }

.crm-input-area {
  padding: .85rem 1.25rem; border-top: 1px solid var(--crm-border);
  display: flex; gap: .6rem; align-items: flex-end;
  background: var(--crm-surface); flex-shrink: 0;
}
.crm-input-area textarea {
  flex: 1; resize: none; border-radius: 12px;
  border: 1px solid var(--crm-border); background: var(--crm-bg);
  color: var(--crm-text); padding: .6rem 1rem;
  font-size: .88rem; max-height: 120px; overflow-y: auto;
  font-family: inherit; line-height: 1.4; transition: border-color .15s;
}
.crm-input-area textarea::placeholder { color: var(--crm-muted2); }
.crm-input-area textarea:focus { outline: none; border-color: var(--crm-cyan-border); }
.crm-send-btn {
  width: 40px; height: 40px; border-radius: 12px; border: none;
  background: var(--crm-cyan); color: #000; font-size: 1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all .15s; font-weight: 700;
}
.crm-send-btn:hover { background: #00e8cc; transform: scale(1.05); }

.crm-back-btn {
  background: none; border: none; color: var(--crm-muted); cursor: pointer;
  font-size: 1.3rem; padding: 0 .25rem; line-height: 1; display: none; transition: color .12s;
}
.crm-back-btn:hover { color: var(--crm-text); }

.crm-contact-panel {
  width: 270px; min-width: 240px; border-left: 1px solid var(--crm-border);
  background: var(--crm-surface); display: flex; flex-direction: column;
  overflow-y: auto; flex-shrink: 0;
}
.crm-contact-panel::-webkit-scrollbar { width: 3px; }
.crm-contact-panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 2px; }
.crm-contact-header {
  padding: .85rem 1.1rem; border-bottom: 1px solid var(--crm-border);
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.crm-contact-header h4 { font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; color: var(--crm-muted); font-weight: 600; }
.crm-contact-body { padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .85rem; }
.crm-contact-field { display: flex; flex-direction: column; gap: 4px; }
.crm-contact-field label { font-size: .66rem; text-transform: uppercase; color: var(--crm-muted2); letter-spacing: .08em; font-weight: 600; }
.crm-contact-field span { font-size: .83rem; color: var(--crm-text); word-break: break-word; }
.crm-contact-actions { padding: .75rem 1.1rem; border-top: 1px solid var(--crm-border); display: flex; flex-direction: column; gap: .4rem; }

/* Avatar row */
.cp-avatar-row { display: flex; align-items: center; gap: .85rem; }
.cp-avatar { width: 46px; height: 46px; border-radius: 50%; background: var(--crm-cyan-dim); border: 1px solid var(--crm-cyan-border); display: flex; align-items: center; justify-content: center; font-size: 1rem; font-weight: 700; color: var(--crm-cyan); flex-shrink: 0; }
.cp-avatar-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

/* Inline editable inputs in contact panel */
.cp-inline-input {
  background: transparent; border: none; border-bottom: 1px solid transparent;
  color: var(--crm-text); font-size: .83rem; width: 100%; padding: 2px 0;
  transition: border-color .15s; outline: none;
}
.cp-inline-input:hover { border-bottom-color: var(--crm-border); }
.cp-inline-input:focus { border-bottom-color: var(--crm-cyan-border); }
.cp-name-input { font-size: .9rem; font-weight: 600; }

/* Section label */
.cp-section-label {
  font-size: .62rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--crm-muted2); font-weight: 700; margin-top: .35rem;
  padding-bottom: .3rem; border-bottom: 1px solid var(--crm-border);
}

/* Tags */
.cp-tags-row { display: flex; flex-wrap: wrap; gap: 5px; min-height: 24px; }
.crm-tag { display: inline-flex; align-items: center; border-radius: 5px; padding: 2px 7px; font-size: .72rem; font-weight: 600; border: 1px solid; }
.cp-tag-add-row { display: flex; gap: 5px; align-items: center; }
.cp-tag-input { flex: 1; background: var(--crm-bg); border: 1px solid var(--crm-border); color: var(--crm-text); border-radius: 6px; padding: 4px 8px; font-size: .78rem; outline: none; }
.cp-tag-input:focus { border-color: var(--crm-cyan-border); }
.cp-tag-btn { background: var(--crm-surface); border: 1px solid var(--crm-border); color: var(--crm-muted); border-radius: 6px; padding: 3px 9px; cursor: pointer; font-size: .78rem; font-weight: 700; }
.cp-tag-auto { color: var(--crm-cyan); border-color: var(--crm-cyan-border); background: var(--crm-cyan-dim); font-size: .65rem; }

/* Notes textarea */
.cp-notes-input {
  width: 100%; background: var(--crm-bg); border: 1px solid var(--crm-border); color: var(--crm-text);
  border-radius: 8px; padding: .5rem .7rem; font-size: .8rem; resize: vertical;
  font-family: inherit; outline: none; box-sizing: border-box;
}
.cp-notes-input:focus { border-color: var(--crm-cyan-border); }

/* Kanban sub-tabs */
.kanban-subtabs {
  display: flex; gap: .375rem; padding: .625rem 1rem .25rem;
  background: var(--crm-bg); flex-shrink: 0;
}
.kanban-subtab {
  display: flex; align-items: center; gap: .35rem;
  padding: .3rem .75rem; border-radius: 20px; border: 1px solid transparent;
  font-size: .75rem; font-weight: 500; cursor: pointer;
  color: var(--crm-muted); background: transparent;
  transition: all .15s;
}
.kanban-subtab:hover { color: var(--crm-text); background: rgba(255,255,255,.04); }
.kanban-subtab.active {
  color: var(--cyan); background: rgba(0,200,240,.1);
  border-color: rgba(0,200,240,.25);
}

.crm-kanban {
  display: flex; gap: 1rem; padding: 1.25rem;
  overflow-x: auto; height: 100%; align-items: flex-start; background: var(--crm-bg);
}
.crm-kanban::-webkit-scrollbar { height: 4px; }
.crm-kanban::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 2px; }
.crm-kanban-col {
  flex: 1; min-width: 240px; max-width: 320px; background: var(--crm-surface);
  border-radius: 12px; border: 1px solid var(--crm-border);
  display: flex; flex-direction: column; max-height: calc(100% - 2px);
}
.crm-kanban-col-header {
  padding: .85rem 1rem; font-size: .78rem; font-weight: 700; color: var(--crm-text);
  border-bottom: 1px solid var(--crm-border); display: flex; align-items: center; gap: .5rem; flex-shrink: 0;
}
.crm-kanban-count {
  margin-left: auto; background: var(--crm-bg); border-radius: 20px;
  padding: .1rem .55rem; font-size: .7rem; color: var(--crm-muted); font-weight: 500;
  border: 1px solid var(--crm-border);
}
.crm-kanban-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.crm-kanban-dot.new       { background: #3b82f6; }
.crm-kanban-dot.waiting   { background: #f59e0b; }
.crm-kanban-dot.attending { background: #00c8f0; }
.crm-kanban-dot.resolved  { background: rgba(255,255,255,.25); }
.crm-kanban-cards { padding: .6rem; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: .45rem; min-height: 80px; }
.crm-kanban-card {
  background: var(--crm-bg); border: 1px solid var(--crm-border);
  border-radius: 10px; padding: .75rem .9rem; cursor: pointer; transition: border-color .12s, transform .1s;
}
.crm-kanban-card:hover { border-color: var(--crm-cyan-border); transform: translateY(-1px); }
.crm-kanban-card[draggable="true"] { cursor: grab; }
.crm-kanban-card[draggable="true"]:active { cursor: grabbing; }
.crm-kanban-card.kanban-dragging { opacity: .35; transform: scale(.97); border-style: dashed; }
.crm-kanban-cards.kanban-drag-over { background: rgba(0,200,240,.06); border-radius: 8px; outline: 2px dashed var(--crm-cyan-border); outline-offset: -4px; }
.crm-kanban-empty { padding: .5rem; font-size: .78rem; color: var(--crm-muted); text-align: center; }
.crm-kanban-card-name { font-size: .83rem; font-weight: 600; color: var(--crm-text); margin-bottom: 3px; }
.crm-kanban-card-preview { font-size: .74rem; color: var(--crm-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crm-kanban-card-time { font-size: .66rem; color: var(--crm-muted2); margin-top: 5px; }

#crm-tab-tasks,
#crm-tab-appointments,
#crm-tab-quick-replies { padding: 1.25rem; overflow-y: auto; background: var(--crm-bg); }

.crm-task-item {
  background: var(--crm-surface); border: 1px solid var(--crm-border);
  border-radius: 12px; padding: .85rem 1rem; margin-bottom: .5rem;
  display: flex; align-items: flex-start; gap: .75rem;
}
.crm-task-item.done { opacity: .45; }
.crm-task-check { width: 17px; height: 17px; margin-top: 2px; accent-color: var(--crm-cyan); cursor: pointer; flex-shrink: 0; }
.crm-task-body { flex: 1; min-width: 0; }
.crm-task-title { font-size: .87rem; font-weight: 600; color: var(--crm-text); margin-bottom: 4px; }
.crm-task-meta  { font-size: .75rem; color: var(--crm-muted); display: flex; flex-wrap: wrap; gap: .5rem; }
.crm-task-actions { display: flex; gap: .3rem; flex-shrink: 0; }

.crm-appt-item {
  background: var(--crm-surface); border: 1px solid var(--crm-border);
  border-radius: 12px; padding: .85rem 1rem; margin-bottom: .5rem;
  display: flex; align-items: center; gap: .85rem;
}
.crm-appt-icon {
  width: 38px; height: 38px; border-radius: 10px; background: rgba(0,200,240,.1);
  display: flex; align-items: center; justify-content: center; font-size: 1rem; flex-shrink: 0;
}
.crm-appt-body { flex: 1; min-width: 0; }
.crm-appt-title { font-size: .87rem; font-weight: 600; color: var(--crm-text); margin-bottom: 4px; }
.crm-appt-meta  { font-size: .75rem; color: var(--crm-muted); }
.crm-appt-badge { font-size: .7rem; padding: 3px 8px; border-radius: 6px; font-weight: 600; background: rgba(108,99,255,.15); color: #a89fff; flex-shrink: 0; }
.crm-appt-badge.cancelled { background: rgba(255,100,100,.12); color: #ff6b6b; }
.crm-appt-item.cancelled { opacity: .65; border-style: dashed; }

/* Notificação badge */
.crm-notif-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px;
  font-size: .65rem; font-weight: 800; line-height: 1;
  background: #ff6b6b; color: #fff; margin-left: 4px; vertical-align: middle;
}
.crm-notif-badge.hidden { display: none; }

/* Filtros de agendamento (Ativos / Cancelados) */
.crm-appt-filter-btn {
  padding: 4px 12px; border-radius: 8px; border: 1px solid var(--crm-border);
  background: transparent; color: var(--crm-muted); font-size: .78rem; cursor: pointer;
  transition: all .15s; font-family: inherit;
}
.crm-appt-filter-btn.active, .crm-appt-filter-btn:hover {
  background: var(--crm-cyan-dim); border-color: var(--crm-cyan-border); color: var(--crm-cyan);
}

.crm-qr-item {
  background: var(--crm-surface); border: 1px solid var(--crm-border);
  border-radius: 12px; padding: .85rem 1rem; margin-bottom: .5rem;
  display: flex; align-items: center; gap: .85rem;
}
.crm-qr-shortcut {
  background: var(--crm-cyan-dim); color: var(--crm-cyan); border: 1px solid var(--crm-cyan-border);
  border-radius: 6px; padding: .2rem .6rem; font-size: .78rem; font-weight: 700;
  white-space: nowrap; flex-shrink: 0; font-family: monospace;
}
.crm-qr-body { flex: 1; font-size: .83rem; color: var(--crm-muted); min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 768px) {
  .crm-topbar { padding: 0 .75rem; overflow-x: auto; }
  .crm-tabs { flex-wrap: nowrap; }
  .crm-tab { padding: 0 .7rem; font-size: .75rem; }
  .crm-stat { padding: .5rem .75rem; }
  .crm-stat span { font-size: 1.1rem; }
  .crm-layout { position: relative; }
  .crm-ticket-list {
    width: 100%; min-width: 0; position: absolute; inset: 0;
    z-index: 1; transition: transform .25s ease; border-right: none;
  }
  .crm-ticket-list.hidden-mobile { transform: translateX(-100%); pointer-events: none; }
  .crm-chat-area {
    position: absolute; inset: 0;
    transform: translateX(100%); transition: transform .25s ease; z-index: 2;
  }
  .crm-chat-area.active-mobile { transform: translateX(0); }
  .crm-contact-panel {
    position: absolute; inset: 0; z-index: 3;
    transform: translateX(100%); transition: transform .25s ease;
    width: 100%; min-width: 0; border-left: none;
  }
  .crm-contact-panel.active-mobile { transform: translateX(0); }
  .crm-back-btn { display: flex !important; }
  .crm-kanban { flex-direction: column; padding: .75rem; }
  .crm-kanban-col { max-width: 100%; }
  #crm-tab-tasks, #crm-tab-appointments, #crm-tab-quick-replies { padding: .75rem; }
}
