/* ========= SF Pro Display Font Family ========= */
@font-face {
  font-family: 'SF Pro Display';
  src: url('/fonts/sf-pro-display-thin.woff2') format('woff2');
  font-weight: 100;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'SF Pro Display';
  src: url('/fonts/sf-pro-display-thinitalic.woff2') format('woff2');
  font-weight: 100;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'SF Pro Display';
  src: url('/fonts/sf-pro-display-ultralight.woff2') format('woff2');
  font-weight: 200;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'SF Pro Display';
  src: url('/fonts/sf-pro-display-ultralightitalic.woff2') format('woff2');
  font-weight: 200;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'SF Pro Display';
  src: url('/fonts/sf-pro-display-light.woff2') format('woff2');
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'SF Pro Display';
  src: url('/fonts/sf-pro-display-lightitalic.woff2') format('woff2');
  font-weight: 300;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'SF Pro Display';
  src: url('/fonts/sf-pro-display-regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'SF Pro Display';
  src: url('/fonts/sf-pro-display-regularitalic.woff2') format('woff2');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'SF Pro Display';
  src: url('/fonts/sf-pro-display-medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'SF Pro Display';
  src: url('/fonts/sf-pro-display-mediumitalic.woff2') format('woff2');
  font-weight: 500;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'SF Pro Display';
  src: url('/fonts/sf-pro-display-semibold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'SF Pro Display';
  src: url('/fonts/sf-pro-display-semibolditalic.woff2') format('woff2');
  font-weight: 600;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'SF Pro Display';
  src: url('/fonts/sf-pro-display-bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'SF Pro Display';
  src: url('/fonts/sf-pro-display-bolditalic.woff2') format('woff2');
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'SF Pro Display';
  src: url('/fonts/sf-pro-display-heavy.woff2') format('woff2');
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'SF Pro Display';
  src: url('/fonts/sf-pro-display-heavyitalic.woff2') format('woff2');
  font-weight: 800;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'SF Pro Display';
  src: url('/fonts/sf-pro-display-black.woff2') format('woff2');
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'SF Pro Display';
  src: url('/fonts/sf-pro-display-blackitalic.woff2') format('woff2');
  font-weight: 900;
  font-style: italic;
  font-display: swap;
}

/* ========= SF Mono Font Family ========= */
@font-face {
  font-family: 'SF Mono';
  src: url('/fonts/sfmono-light.woff2') format('woff2');
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'SF Mono';
  src: url('/fonts/sfmono-lightitalic.woff2') format('woff2');
  font-weight: 300;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'SF Mono';
  src: url('/fonts/sfmono-regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'SF Mono';
  src: url('/fonts/sfmono-regularitalic.woff2') format('woff2');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'SF Mono';
  src: url('/fonts/sfmono-medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'SF Mono';
  src: url('/fonts/sfmono-mediumitalic.woff2') format('woff2');
  font-weight: 500;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'SF Mono';
  src: url('/fonts/sfmono-semibold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'SF Mono';
  src: url('/fonts/sfmono-semibolditalic.woff2') format('woff2');
  font-weight: 600;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'SF Mono';
  src: url('/fonts/sfmono-bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'SF Mono';
  src: url('/fonts/sfmono-bolditalic.woff2') format('woff2');
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'SF Mono';
  src: url('/fonts/sfmono-heavy.woff2') format('woff2');
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'SF Mono';
  src: url('/fonts/sfmono-heavyitalic.woff2') format('woff2');
  font-weight: 800;
  font-style: italic;
  font-display: swap;
}

/* ========= Base ========= */
:root {
  color-scheme: light;
  --color-primary: #2563eb;
  --color-primary-strong: #1d4ed8;
  --color-primary-soft: #e0ecff;
  --color-bg: #f3f5f8;
  --color-surface: #ffffff;
  --color-surface-alt: #f8fafc;
  --color-border: #e2e8f0;
  --color-text: #0f172a;
  --color-muted: #64748b;
  --color-muted-strong: #475569;
  --bg: var(--color-bg);
  --panel: var(--color-surface);
  --card: var(--color-surface);
  --text: var(--color-text);
  --muted: var(--color-muted);
  --border: var(--color-border);
  --input: var(--color-surface-alt);
  --bubble-in: var(--color-surface);
  --bubble-out: var(--color-primary-soft);
  --ig: #E1306C;
  --ig-soft: rgba(225, 48, 108, 0.10);
  --ig-soft2: rgba(225, 48, 108, 0.06);
  --ig-border: rgba(225, 48, 108, 0.35);
  --sidebar-bg: #0f172a;
  --sidebar-text: #e2e8f0;
  --sidebar-hover: rgba(255, 255, 255, 0.08);
  --topbar-bg: var(--color-surface);
  --topbar-border: var(--color-border);
  --topbar-text: var(--color-text);
  --topbar-title: var(--color-muted-strong);
  --topbar-pill-bg: var(--color-surface-alt);
  --topbar-pill-text: var(--color-text);
  --topbar-pill-border: var(--color-border);
  --topbar-pill-hover: var(--color-surface);
  --topbar-pill-border-hover: var(--color-border);
  --topbar-toggle-bg: var(--color-surface-alt);
  --topbar-toggle-border: var(--color-border);
  --topbar-toggle-color: var(--color-muted-strong);
  --topbar-toggle-hover: var(--color-surface);
  --color-success: #16a34a;
  --color-warning: #d97706;
  --color-danger: #dc2626;
  --color-skeleton: #e2e8f0;
  --color-skeleton-shine: #f8fafc;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 6px 18px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 12px 40px rgba(15, 23, 42, 0.1);
  --shadow-lg: 0 18px 50px rgba(15, 23, 42, 0.14);
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --font-12: 12px;
  --font-14: 14px;
  --font-16: 16px;
  --font-18: 18px;
  --font-ui: "SF Pro Display", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: "SF Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: var(--color-bg);
  --panel: var(--color-surface);
  --card: var(--color-surface);
  --text: var(--color-text);
  --muted: var(--color-muted);
  --border: var(--color-border);
  --input: var(--color-surface-alt);
  --bubble-in: var(--color-surface);
  --bubble-out: var(--color-primary-soft);
  --sidebar-bg: #0f172a;
  --sidebar-text: #e2e8f0;
  --sidebar-hover: rgba(255, 255, 255, 0.08);
  --topbar-bg: var(--color-surface);
  --topbar-border: var(--color-border);
  --topbar-text: var(--color-text);
  --topbar-title: var(--color-muted-strong);
  --topbar-pill-bg: var(--color-surface-alt);
  --topbar-pill-text: var(--color-text);
  --topbar-pill-border: var(--color-border);
  --topbar-pill-hover: var(--color-surface);
  --topbar-pill-border-hover: var(--color-border);
  --topbar-toggle-bg: var(--color-surface-alt);
  --topbar-toggle-border: var(--color-border);
  --topbar-toggle-color: var(--color-muted-strong);
  --topbar-toggle-hover: var(--color-surface);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --color-primary: #5b8cff;
  --color-primary-strong: #4c7dff;
  --color-primary-soft: #1d2b44;
  --color-bg: #0b1118;
  --color-surface: #121a24;
  --color-surface-alt: #0f1620;
  --color-border: #1f2a37;
  --color-text: #e2e8f0;
  --color-muted: #94a3b8;
  --color-muted-strong: #cbd5e1;
  --color-success: #22c55e;
  --color-warning: #f59e0b;
  --color-danger: #f87171;
  --color-skeleton: #1f2a37;
  --color-skeleton-shine: #243244;
  --shadow-sm: 0 6px 18px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 14px 36px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

button,
input,
textarea,
select {
  font-family: var(--font-ui);
}

code,
pre,
kbd,
samp,
.mono {
  font-family: var(--font-mono);
}

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

.hidden {
  display: none !important;
}

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

.eyebrow {
  font-size: var(--font-12);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.title {
  font-weight: 700;
}

/* ========= Layout shell ========= */
.layout-shell {
  overflow: hidden;
}

.no-scroll {
  overflow: hidden;
}

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: 100vh;
}

.sidebar-nav {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 16px 14px;
  gap: 16px;
}

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

.brand-logo {
  height: 40px;
  border-radius: 12px;
}

.nav-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item {
  color: var(--sidebar-text);
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background .12s ease, color .12s ease;
}

.nav-item:hover {
  background: var(--sidebar-hover);
}

.nav-item.active {
  background: #2563eb;
  color: #fff;
}

.main-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}

.topbar {
  min-height: 60px;
  background: var(--topbar-bg);
  /* Dark slate - only topbar */
  border-bottom: 1px solid var(--topbar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  color: var(--topbar-text);
}

.topbar-left {
  display: flex;
  align-items: center;
}

.topbar-left .title {
  font-size: 15px;
  font-weight: 500;
  color: var(--topbar-title);
  letter-spacing: 0.3px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-right .user-email,
.topbar-right .user-role,
.topbar-right .build-stamp {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.build-stamp {
  margin-left: 10px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.55);
  font-weight: 500;
  letter-spacing: 0.2px;
  white-space: nowrap;
  display: none;
  align-items: center;
}

.build-stamp.is-visible {
  display: inline-flex;
}

/* Pill container for user info */
.topbar-pill {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--topbar-pill-bg);
  /* Slightly lighter slate */
  border-radius: 24px;
  padding: 4px 4px 4px 16px;
  border: 1px solid var(--topbar-pill-border);
}

.topbar-pill .user-email {
  font-weight: 500;
  font-size: 13px;
  color: var(--topbar-pill-text);
  padding-right: 10px;
}

.topbar-pill .user-role.badge {
  padding: 5px 12px;
  border-radius: 999px;
  background: #22c55e;
  font-size: 12px;
  font-weight: 600;
  color: #052e16;
  margin-right: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.topbar-pill .user-role.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  background: #052e16;
  border-radius: 50%;
}

.topbar-pill .btn.ghost {
  background: transparent;
  border: 1px solid var(--topbar-pill-border);
  color: var(--topbar-pill-text);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  transition: all 0.15s;
}

.topbar-pill .btn.ghost:hover {
  background: var(--topbar-pill-hover);
  border-color: var(--topbar-pill-border-hover);
}

/* Generic badge (used in multiple places) */
.badge {
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--color-surface-alt);
  font-size: var(--font-12);
  color: var(--color-text);
}

.main-area main {
  flex: 1;
  overflow: auto;
  min-height: 0;
  padding: 1px;
  background: var(--bg);
}

.drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .35);
  z-index: 5;
}

.drawer-backdrop.show {
  display: block;
}

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

.mobile-only {
  display: none;
}

.profile-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .35);
  z-index: 40;
}

.profile-backdrop.show {
  display: block;
}

/* ========= Banner + Auth ========= */
.banner {
  width: 100%;
  padding: 10px 16px;
  text-align: center;
  font-size: 14px;
  color: #fff;
  background: var(--color-primary);
}

.banner.warn {
  background: var(--color-warning);
}

.banner.error {
  background: var(--color-danger);
}

.auth-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: #0f172a;
}

.logo-small {
  height: 28px;
}

.auth-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 520px;
}

.auth-inputs input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-size: 14px;
  background: #f8fafc;
}

.auth-inputs button {
  padding: 10px 14px;
  border: 0;
  border-radius: 10px;
  background: #2563eb;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

/* ========= Buttons ========= */
.btn {
  border: 0;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: var(--font-14);
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease, color .12s ease;
}

.btn.primary {
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 10px 30px rgba(37, 99, 235, 0.18);
}

.btn.primary:hover {
  transform: translateY(-1px);
  background: var(--color-primary-strong);
  box-shadow: 0 14px 34px rgba(37, 99, 235, 0.22);
}

.btn.ghost {
  background: var(--color-surface-alt);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn.ghost.active {
  background: var(--color-surface);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.btn.warning {
  border-color: var(--color-warning);
  color: var(--color-warning);
  background: transparent;
}

.btn.warning:hover {
  background: rgba(217, 119, 6, 0.12);
}

.btn.ghost:hover {
  background: var(--color-surface);
}

.btn.small {
  padding: 7px 12px;
  font-size: 13px;
}

.btn:disabled {
  opacity: .6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--input);
  font-size: var(--font-14);
  color: var(--text);
}

.icon-btn {
  background: transparent;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  color: var(--color-muted-strong);
  transition: background .12s, color .12s, transform .12s;
}

.icon-btn.ghost {
  background: var(--color-surface-alt);
}

.icon-btn:hover {
  background: var(--color-surface);
  color: var(--color-text);
  transform: translateY(-1px);
}

#attach-btn {
  color: #475569;
}

#attach-btn svg {
  width: 20px;
  height: 20px;
  display: block;
}

#attach-btn:hover {
  color: #0f172a;
}

#emoji-btn {
  color: #4b5563;
}

#emoji-btn svg {
  width: 20px;
  height: 20px;
  display: block;
}

#emoji-btn:hover {
  color: #111827;
}

/* ========= Layout ========= */
.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 0;
  padding: var(--space-4);
  height: calc(100vh - 72px);
  background: var(--bg);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ========= Sidebar ========= */
.sidebar-top {
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-logo {
  display: flex;
  gap: 10px;
  align-items: center;
}

.sidebar-logo img {
  height: 40px;
  border-radius: 12px;
}

.sidebar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-surface-alt);
  color: var(--color-muted);
}

.contact-filters {
  margin-top: 6px;
}

.contact-filters .input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface);
}

.sidebar-search input {
  border: 0;
  background: transparent;
  outline: none;
  font-size: var(--font-14);
  color: var(--color-text);
  flex: 1;
}

.contact-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  overflow-y: auto;
}

.contact-list::-webkit-scrollbar {
  width: 8px;
}

.contact-list::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, .12);
  border-radius: 8px;
}

.contact {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
  border-left: 3px solid transparent;
}

.contact:hover {
  background: var(--color-surface-alt);
}

.contact.active {
  background: var(--color-surface-alt);
  border-left-color: var(--color-primary);
}

.contact.is-archived {
  opacity: 0.75;
}

.contact.channel-instagram {
  position: relative;
  background: transparent;
  border-left-color: transparent;
}



.contact.channel-instagram:hover {
  background: transparent;
}

.contact.channel-instagram.active {
  background: var(--ig-soft);
  box-shadow: inset 0 0 0 1px var(--ig-border);
}

.contact-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--color-surface-alt);
  color: var(--color-muted-strong);
  display: grid;
  place-items: center;
  overflow: hidden;
  position: relative;
  font-weight: 700;
  font-size: 14px;
}

/* Avatar with initials - WhatsApp soft green style */
.contact-avatar.no-image {
  background: transparent;
  color: inherit;
  border: 0;
}

/* Dark mode support for initials avatar */
html[data-theme="dark"] .contact-avatar.no-image,
.dark .contact-avatar.no-image {
  background: transparent;
  color: inherit;
  border-color: transparent;
}

.contact-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.contact-avatar.no-image img {
  display: none;
}

.contact-avatar:not(.no-image) .avatar-initial {
  display: none;
}

.avatar-initial {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  border-radius: 9999px;
  width: 100%;
  height: 100%;
}

.contact-avatar.no-image .avatar-initial {
  background: #22c55e;
  color: #fff;
  border-radius: 9999px;
}

.contact-avatar.no-image[data-channel="ms"] .avatar-initial {
  background: #3b82f6;
  color: #fff;
}

.avatar-circle .avatar-fallback {
  background: #22c55e;
  color: #fff;
}

.avatar-circle[data-channel="ms"] .avatar-fallback {
  background: #3b82f6;
  color: #fff;
}

.avatar--messenger {
  background: #3b82f6;
  color: #fff;
}

.avatar--instagram {
  background: var(--ig);
  color: #fff;
}

.avatar--whatsapp {
  background: #22c55e;
  color: #fff;
}

.contact-avatar[data-channel="ms"] .avatar-fallback,
.avatar-circle[data-channel="ms"] .avatar-fallback {
  background: #3b82f6;
  color: #fff;
}

.contact-avatar[data-channel="ig"] .avatar-fallback,
.avatar-circle[data-channel="ig"] .avatar-fallback {
  background: var(--ig);
  color: #fff;
}

.contact-avatar[data-channel="wa"] .avatar-fallback,
.avatar-circle[data-channel="wa"] .avatar-fallback {
  background: #22c55e;
  color: #fff;
}

.contact-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.contact-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.contact-name-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.contact-name {
  font-weight: 700;
  color: var(--color-text);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.contact-channel-mark {
  width: 16px;
  height: 16px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 16px;
  line-height: 1;
  border: 0;
  background: transparent;
}

.contact-channel-mark.channel-wa {
  --wa-icon-color: #22c55e;
  position: relative;
  color: var(--wa-icon-color);
  font-size: 0;
  overflow: hidden;
}

.contact-channel-mark svg {
  width: 16px;
  height: 16px;
  display: block;
  fill: currentColor;
}

.contact-channel-mark.channel-wa svg {
  display: block;
}

.contact-row .contact-channel-mark {
  display: none !important;
}

.contact-time {
  color: var(--color-primary);
  font-size: 12px;
  font-weight: 500;
}

.contact-last-msg {
  color: var(--color-muted-strong);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.status-badge,
.assigned-badge,
.channel-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--color-surface-alt);
  color: var(--color-text);
  white-space: nowrap;
}

.status-new {
  background: var(--color-surface-alt);
  color: var(--color-text);
}

.status-in_conversation {
  background: #dbeafe;
  color: #1e3a8a;
}

.status-quoted {
  background: #fef3c7;
  color: #92400e;
}

.status-won {
  background: #dcfce7;
  color: #166534;
}

.status-lost {
  background: #fee2e2;
  color: #991b1b;
}

.assigned-badge {
  background: #e2e8f0;
  color: var(--color-text);
}

.assigned-none {
  background: var(--color-surface-alt);
  color: var(--color-muted);
}

.channel-badge {
  background: #dcfce7;
  color: #166534;
}

.channel-badge.channel-wa-icon {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #22c55e;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.channel-badge.channel-wa-icon svg {
  width: 16px;
  height: 16px;
  display: block;
  fill: currentColor;
}

.channel-badge.channel-ms-icon {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #2563eb;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.channel-badge.channel-ms-icon svg {
  width: 16px;
  height: 16px;
  display: block;
  fill: currentColor;
}

.channel-badge.channel-ig {
  background: var(--ig);
  color: #fff;
  border: 1px solid var(--ig-border);
}

.channel-badge.channel-ms {
  background: #dbeafe;
  color: #1e40af;
}

.channel-badge.channel-fb {
  background: #e0e7ff;
  color: #3730a3;
}

/* "Nuevo" badge for contacts that haven't been opened yet */
.is-new-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 999px;
  background: linear-gradient(135deg, #10b981, #06b6d4);
  color: #fff;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  animation: pulse-badge 2s infinite;
  flex-shrink: 0;
}

@keyframes pulse-badge {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
  }

  50% {
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
}

.contact.skeleton {
  pointer-events: none;
  cursor: default;
}

.contact.skeleton:hover {
  background: transparent;
}

.contact.skeleton .sk-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(90deg, var(--color-skeleton), var(--color-skeleton-shine), var(--color-skeleton));
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}

.contact.skeleton .sk-lines {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.contact.skeleton .sk-line {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--color-skeleton), var(--color-skeleton-shine), var(--color-skeleton));
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}

.contact.skeleton .sk-line.wide {
  width: 70%;
}

.contact.skeleton .sk-line.mid {
  width: 55%;
}

.contact.skeleton .sk-line.short {
  width: 35%;
}

/* ========= New Contact List Design ========= */
.btn.outline {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text);
}

.btn.outline:hover {
  background: var(--color-surface-alt);
  border-color: var(--color-muted);
}

.btn.full-width {
  width: 100%;
}

/* Filter Tags Container */
.filter-tags-container {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  position: relative;
}

.filter-label {
  font-size: 13px;
  color: var(--color-muted);
  white-space: nowrap;
}

.filter-tags {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-tag {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
}

.filter-tag:hover {
  background: var(--color-surface-alt);
  border-color: var(--color-muted);
}

.filter-tag.active {
  background: var(--color-primary-soft);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.filter-tag .remove-filter {
  margin-left: 6px;
  opacity: 0.6;
}

.filter-tag .remove-filter:hover {
  opacity: 1;
}

.filter-add-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px dashed var(--color-border);
  background: transparent;
  color: var(--color-muted);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s ease;
}

.filter-add-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-soft);
}

/* Filter Dropdown */
.filter-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 8px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  min-width: 200px;
  z-index: 100;
  padding: 8px 0;
}

.filter-dropdown-section {
  padding: 4px 0;
}

.filter-dropdown-section:not(:last-child) {
  border-bottom: 1px solid var(--color-border);
}

.filter-dropdown-title {
  padding: 6px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-dropdown-item {
  display: block;
  width: 100%;
  padding: 10px 14px;
  text-align: left;
  background: none;
  border: none;
  color: var(--color-text);
  font-size: 14px;
  cursor: pointer;
  transition: background .1s ease;
}

.filter-dropdown-item:hover {
  background: var(--color-surface-alt);
}

/* Larger Contact Avatar */
.contact-avatar {
  width: 48px;
  height: 48px;
  font-size: 16px;
}

.contact-avatar .avatar-initial {
  font-size: 16px;
  font-weight: 600;
}

/* Contact Phone Display */
.contact-phone {
  font-size: 12px;
  color: var(--color-muted);
  margin-top: 2px;
}

/* Unread Badge - WhatsApp style */
.unread-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 50%;
  background: #25D366;
  color: white;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.unread-badge.large {
  border-radius: 10px;
}

.contact.channel-ig .unread-badge,
.contact.channel-instagram .unread-badge {
  background: var(--ig);
  color: #fff;
  border: 1px solid var(--ig-border);
}

/* ========= Chat ========= */
.chat-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
  background-color: #efeae2;
  background-image: url('/assets/chat-bg-whatsapp-light.png');
  background-repeat: repeat;
  background-size: 420px auto;
}

.chat-mobile-tabs {
  display: none;
  padding: 8px 10px;
  gap: 8px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.chat-header {
  /* WhatsApp-like chat header - compact pill design */
  padding: 10px 16px;
  margin: 8px;
  background: var(--color-surface);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
}

.chat-header.ai-active {
  border-color: #38bdf8;
  box-shadow: 0 1px 3px rgba(56, 189, 248, 0.15);
}

.chat-header.channel-instagram {
  border-color: rgba(0, 0, 0, 0.06);
  border-bottom: 2px solid var(--ig);
  box-shadow: 0 1px 3px rgba(225, 48, 108, 0.08);
}

.chat-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.ai-active-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-left: 4px;
  white-space: nowrap;
}

.avatar-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--color-surface-alt);
  display: grid;
  place-items: center;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
}

.avatar-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.contact-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--color-text);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-subtitle {
  font-size: 12px;
  color: var(--color-muted);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-subtitle-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
  flex-shrink: 0;
}

.ai-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-select {
  min-width: 180px;
}

.search-panel {
  position: absolute;
  right: 0;
  top: 48px;
  z-index: 20;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 8px 10px;
  box-shadow: var(--shadow-sm);
}

.search-panel input {
  width: 240px;
  border: 0;
  outline: none;
  font-size: var(--font-14);
  background: transparent;
  color: var(--color-text);
}

.dropdown {
  position: absolute;
  right: 0;
  top: 48px;
  min-width: 190px;
  z-index: 20;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  padding: 6px 0;
}

.dropdown-item {
  width: 100%;
  padding: 10px 14px;
  text-align: left;
  background: none;
  border: 0;
  cursor: pointer;
  font-size: var(--font-14);
  color: var(--color-text);
}

.dropdown-item:hover {
  background: var(--color-surface-alt);
}

.dropdown-item.danger {
  color: var(--color-danger);
}

.chat-body {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: transparent;
  padding: var(--space-4);
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 6px;
  min-height: 0;
}

.chat-messages::-webkit-scrollbar {
  width: 10px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, .12);
  border-radius: 10px;
}

.day-separator {
  align-self: center;
  background: var(--color-surface);
  color: var(--color-muted-strong);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--color-border);
}

.message {
  width: 100%;
  display: flex;
  animation: fadeInUp .12s ease;
  background: transparent;
}

.message.in {
  justify-content: flex-start;
}

.message.out {
  justify-content: flex-end;
}

.message.channel-ms,
.message[data-channel="ms"],
.message[data-channel="MESSENGER"] {
  background: transparent !important;
}

.bubble {
  position: relative;
  max-width: min(70%, 640px);
  padding: 12px 14px 18px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--bubble-in);
  box-shadow: var(--shadow-sm);
  font-size: var(--font-14);
  line-height: 1.45;
  color: var(--text);
  display: inline-block;
}

.message.out .bubble {
  background: var(--bubble-out);
  border-color: transparent;
}

.message.out .bubble[data-channel="wa"] {
  background: #dcfce7;
  border-color: #86efac;
}

.message.out .bubble[data-channel="ms"] {
  background: #e8f1ff;
  border-color: #c7ddff;
}

.message.in .bubble[data-channel="ms"] {
  background: #ffffff;
  border-color: #d6e3ff;
}

.message.out .bubble[data-channel="ig"] {
  background: #fff;
  border-color: rgba(225, 48, 108, 0.55);
  box-shadow: 0 0 0 3px rgba(225, 48, 108, 0.08);
}

.message.in .bubble[data-channel="ig"] {
  background: #fff;
  border-color: var(--ig-border);
  box-shadow: 0 6px 14px rgba(225, 48, 108, 0.08);
}

html[data-theme="dark"] .message.in .bubble[data-channel="ms"] {
  background: #111827;
  border-color: rgba(59, 130, 246, 0.35);
}

.message.out.error .bubble {
  background: #ffe4e6;
  border-color: #fecdd3;
}

.bubble-text {
  margin-right: 48px;
  word-wrap: break-word;
}

.meta {
  position: absolute;
  right: 10px;
  bottom: 6px;
  font-size: 11px;
  color: var(--color-muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.meta .checks svg {
  width: 16px;
  height: 12px;
  display: block;
  color: #9aa3ac;
  transition: color 0.2s ease;
}

/* Status-based check colors */
.meta .checks[data-status="sent"] svg {
  color: #9aa3ac;
}

.meta .checks[data-status="delivered"] svg {
  color: #9aa3ac;
}

.meta .checks[data-status="read"] svg {
  color: #53bdeb;
}

.meta .checks[data-status="sending"] svg {
  color: #9aa3ac;
  width: 14px;
  height: 14px;
}

.meta .checks[data-status="failed"] svg {
  color: #ef4444;
}

/* Message bubble with image - constrained size */
.bubble.has-image,
.bubble:has(> img),
.bubble:has(.message-image),
.bubble:has(.attached-img) {
  padding: 6px;
  max-width: 320px;
  width: fit-content;
  display: inline-block;
  overflow: hidden;
}

.bubble.has-image .bubble-text,
.bubble:has(> img) .bubble-text {
  margin-right: 0;
}

.bubble.bubble-audio {
  padding: 10px 12px 18px;
  max-width: min(75%, 420px);
}

.bubble.bubble-audio .bubble-text {
  margin-right: 40px;
}

.bubble img,
.bubble .message-image,
.bubble .attached-img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 320px;
  object-fit: cover;
  border-radius: 12px;
  cursor: pointer;
}

.bubble:has(> img) .meta,
.bubble:has(.message-image) .meta,
.bubble:has(.attached-img) .meta {
  position: relative;
  right: auto;
  bottom: auto;
  margin-top: 4px;
  text-align: right;
}

/* Mobile: smaller image bubbles */
@media (max-width: 768px) {

  .bubble.has-image,
  .bubble:has(> img),
  .bubble:has(.message-image),
  .bubble:has(.attached-img) {
    max-width: 240px;
  }

  .bubble img,
  .bubble .message-image,
  .bubble .attached-img {
    max-height: 240px;
  }
}

.chat-input {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--panel);
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 2;
}

.page-shell[data-page="chat"] #audio-btn {
  display: none !important;
}

.input-field {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--input);
}

.input-field:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.input-field input {
  flex: 1;
  border: 0;
  background: transparent;
  outline: none;
  font-size: var(--font-14);
  color: var(--text);
}

.scroll-bottom {
  position: absolute;
  right: 20px;
  bottom: 88px;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-muted-strong);
  box-shadow: var(--shadow-sm);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, color .12s ease;
}

.scroll-bottom:hover {
  transform: translateY(-2px);
  color: var(--color-text);
}

.theme-toggle .icon-sun {
  display: none;
}

html[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

html[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

.emoji-picker {
  position: absolute;
  bottom: 72px;
  right: 90px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 10px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 240px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 200;
  font-size: 20px;
}

.emoji-picker span {
  cursor: pointer;
}

.attach-menu {
  position: absolute;
  bottom: 72px;
  left: 16px;
  width: 220px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  padding: 8px 0;
  z-index: 220;
}

.attach-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 0;
  background: none;
  cursor: pointer;
  font-size: var(--font-14);
  color: var(--color-text);
}

.attach-item-icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 20px;
  color: var(--attach-icon-color, var(--color-muted-strong));
}

.attach-item-icon svg {
  width: 20px;
  height: 20px;
  display: block;
  fill: currentColor;
}

.attach-item[data-action="document"] {
  --attach-icon-color: #8b5cf6;
}

.attach-item[data-action="media"] {
  --attach-icon-color: #0ea5e9;
}

.attach-item[data-action="camera"] {
  --attach-icon-color: #3b82f6;
}

.attach-item[data-action="audio-file"] {
  --attach-icon-color: #7c3aed;
}

.attach-item[data-action="contact"] {
  --attach-icon-color: #a855f7;
}

.attach-item:hover {
  background: var(--color-surface-alt);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  color: var(--color-muted-strong);
  margin: auto;
  max-width: 360px;
}

.empty-icon {
  font-size: 40px;
}

.empty-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.loader {
  padding: 12px;
  text-align: center;
  font-weight: 600;
  color: var(--color-muted-strong);
}

/* ========= Info panel ========= */
.info-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .35);
  z-index: 70;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}

.info-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.info-panel {
  min-width: 0;
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: min(420px, 92vw);
  max-width: 92vw;
  z-index: 80;
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border-radius: 0;
  transform: translateX(100%);
  transition: transform .2s ease;
}

.info-panel.show {
  transform: translateX(0);
}

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

.info-tabs {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
}

.tab {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-surface-alt);
  cursor: pointer;
  font-weight: 600;
  color: var(--color-muted-strong);
}

.tab.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.info-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.info-top {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface-alt);
}

.info-identity {
  display: flex;
  align-items: center;
  gap: 12px;
}

.info-identity-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.info-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.info-avatar-wrap {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: var(--color-surface);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.info-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.info-name {
  font-size: var(--font-18);
  font-weight: 700;
  color: var(--color-text);
}

.info-phone {
  font-size: var(--font-14);
  color: var(--color-muted);
}

.info-about {
  font-size: 13px;
  color: var(--color-muted-strong);
}

.info-section {
  margin-top: 18px;
}

.info-section-title {
  font-weight: 700;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.info-section.card {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 12px;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
}

.media-grid img {
  width: 100%;
  aspect-ratio: 1/1;
  object-fit: cover;
  border-radius: 10px;
  cursor: pointer;
}

.toggle-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 10px;
  cursor: pointer;
}

.toggle-row input {
  pointer-events: none;
}

.info-note {
  font-size: 12px;
  color: var(--color-muted);
  margin-top: 6px;
}

.tab-panel {
  display: none;
}

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

.placeholder-card {
  border: 1px dashed var(--color-border);
  border-radius: 12px;
  padding: 14px;
  background: var(--color-surface-alt);
  color: var(--color-muted-strong);
}

/* ========= Modal ========= */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(0, 0, 0, .82);
  justify-content: center;
  align-items: center;
}

.modal.show {
  display: flex;
}

.modal-content {
  max-width: 92%;
  max-height: 92%;
  border-radius: 10px;
  box-shadow: 0 0 12px rgba(0, 0, 0, .5);
}

.modal .close {
  position: absolute;
  top: 16px;
  right: 24px;
  color: #fff;
  font-size: 34px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .5);
}

.modal .panel {
  max-height: 90vh;
  overflow: auto;
}

/* ========= Pipeline ========= */
.pipeline-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(220px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.pipeline-column {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  min-height: 200px;
}

.pipeline-col-header {
  padding: 10px 12px;
  font-weight: 700;
  border-bottom: 1px solid #e2e8f0;
}

.pipeline-col-body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 120px;
  transition: background .15s ease;
}

.pipeline-col-body.drag-over {
  background: #e0ecff;
}

.pipeline-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
  cursor: grab;
  transition: transform .15s ease, box-shadow .15s ease;
}

.pipeline-card.dragging {
  opacity: .6;
}

.pipeline-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
}

.pipeline-card.disabled {
  opacity: .5;
  cursor: not-allowed;
}

.pipeline-card-title {
  font-weight: 700;
  font-size: 14px;
}

.pipeline-card-sub {
  font-size: 12px;
  color: #64748b;
  margin-top: 4px;
}

@media (max-width:900px) {
  .pipeline-board {
    grid-template-columns: repeat(5, minmax(200px, 1fr));
  }
}

.modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  font-size: 30px;
  color: #111;
  background: rgba(255, 255, 255, .9);
  display: grid;
  place-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
}

.modal-nav.prev {
  left: 24px;
}

.modal-nav.next {
  right: 24px;
}

/* ========= Toasts ========= */
.toast-container {
  position: fixed;
  right: 24px;
  bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
}

.toast {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: var(--font-14);
  box-shadow: var(--shadow-sm);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .15s ease, transform .15s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.success {
  border-left-color: var(--color-success);
}

.toast.error {
  border-left-color: var(--color-danger);
}

/* ========= Onboarding ========= */
.onboarding-shell {
  min-height: calc(100vh - 120px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5) var(--space-4);
  background:
    radial-gradient(140% 140% at 12% 10%, rgba(37, 99, 235, 0.12), transparent 55%),
    radial-gradient(120% 120% at 88% 0%, rgba(20, 184, 166, 0.12), transparent 60%);
  border-radius: var(--radius-lg);
}

.onboarding-card {
  width: min(920px, 96vw);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.onboarding-header h1 {
  margin: 6px 0 8px;
  font-size: 26px;
}

.onboarding-header p {
  margin: 0;
  color: var(--color-muted-strong);
  font-size: var(--font-14);
}

.onboarding-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.onboarding-steps {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.step-item {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.step-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: transparent;
  border: 0;
  text-align: left;
  cursor: pointer;
  color: inherit;
}

.step-toggle:hover {
  background: var(--color-surface-alt);
}

.step-mark {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.step-number {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
}

.step-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid var(--color-border);
  display: grid;
  place-items: center;
  color: var(--color-muted-strong);
  background: var(--color-surface);
}

.step-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.step-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--color-text);
}

.step-desc {
  font-size: 13px;
  color: var(--color-muted);
}

.step-chevron {
  margin-left: auto;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  color: var(--color-muted);
  transition: transform .15s ease;
}

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

.step-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height .2s ease;
}

.step-item.open .step-body {
  max-height: 220px;
}

.step-body-inner {
  padding: 0 var(--space-4) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  color: var(--color-muted-strong);
  font-size: var(--font-14);
}

.step-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.step-item.done {
  border-color: rgba(22, 163, 74, 0.4);
  background: var(--color-surface-alt);
}

.step-item.done .step-number {
  background: rgba(22, 163, 74, 0.16);
  color: var(--color-success);
}

.step-item.done .step-icon {
  color: var(--color-success);
  border-color: rgba(22, 163, 74, 0.35);
}

.step-item.done .step-complete {
  border-color: rgba(22, 163, 74, 0.4);
  color: var(--color-success);
}

@media (max-width:720px) {
  .onboarding-shell {
    padding: var(--space-4);
  }

  .onboarding-card {
    padding: var(--space-4);
  }

  .step-toggle {
    align-items: flex-start;
  }

  .step-mark {
    flex-direction: column;
    align-items: flex-start;
  }

  .step-chevron {
    margin-top: 4px;
  }
}

/* ========= App Views ========= */
.app-view-panel {
  height: 100%;
}

#app-view {
  min-height: 100%;
}

.page-shell {
  min-height: 100%;
  padding-bottom: 24px;
}

.view-shell {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-4);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-3);
}

.stat-card {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 14px;
  box-shadow: var(--shadow-sm);
}

.stat-label {
  font-size: 12px;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text);
  margin-top: 6px;
}

.team-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.team-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface-alt);
}

.team-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  background: var(--color-surface);
  color: var(--color-muted-strong);
  border: 1px solid var(--color-border);
}

.team-info {
  flex: 1;
  min-width: 0;
}

.team-name {
  font-weight: 700;
  color: var(--color-text);
}

.status-pill {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}

.status-pill.online {
  background: #dcfce7;
  color: #166534;
  border-color: #bbf7d0;
}

.status-pill.busy {
  background: #fef3c7;
  color: #92400e;
  border-color: #fde68a;
}

.status-pill.offline {
  background: var(--color-surface);
  color: var(--color-muted);
  border-color: var(--color-border);
}

.integrations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-4);
}

.integration-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--color-surface) 0%, var(--color-surface-alt) 100%);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.integration-card.loading {
  opacity: .6;
  pointer-events: none;
}

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

.integration-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 700;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
}

.integration-icon.fb {
  background: #dbeafe;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.integration-icon.ig {
  background: #fce7f3;
  color: #be185d;
  border-color: #fbcfe8;
}

.integration-icon.wa {
  background: #dcfce7;
  color: #166534;
  border-color: #bbf7d0;
}

.integration-title {
  font-weight: 700;
  color: var(--color-text);
}

.integration-sub {
  font-size: 12px;
}

.integration-body {
  color: var(--color-muted-strong);
  font-size: 13px;
  line-height: 1.4;
}

.integration-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.integration-actions {
  display: flex;
  gap: 8px;
}

.integration-state {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-muted-strong);
}

.integration-state.connected {
  background: #dcfce7;
  color: #166534;
  border-color: #bbf7d0;
}

.integration-state.error {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fecaca;
}

.integration-state.idle {
  background: var(--color-surface);
  color: var(--color-muted-strong);
  border-color: var(--color-border);
}

/* ========= Utils ========= */
.highlight {
  background: #fef08a;
  padding: 0 2px;
  border-radius: 4px;
}

.loader.hidden,
.empty-state.hidden {
  display: none !important;
}

/* ========= Animations ========= */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shimmer {
  0% {
    background-position: 0% 50%;
  }

  100% {
    background-position: 200% 50%;
  }
}

/* ========= Responsive ========= */
@media (max-width:1080px) {
  .app-shell {
    grid-template-columns: 320px minmax(0, 1fr);
    grid-template-areas: "sidebar chat";
    height: calc(100vh - 72px);
  }

  .info-panel {
    display: flex;
  }
}

@media (max-width:900px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    gap: 12px;
    padding: 12px;
  }

  .sidebar {
    order: 1;
    height: 320px;
  }

  .chat-area {
    order: 2;
    height: calc(100vh - 420px);
  }
}

@media (max-width:640px) {
  .auth-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .auth-inputs {
    width: 100%;
  }

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

  .chat-actions {
    align-self: flex-end;
  }

  .chat-input {
    flex-wrap: wrap;
  }

  .chat-input .btn.primary {
    width: 100%;
  }

  .scroll-bottom {
    right: 12px;
    bottom: 100px;
  }
}

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

  .sidebar-nav {
    position: fixed;
    inset: 0 auto 0 0;
    width: 260px;
    transform: translateX(-100%);
    transition: transform .2s ease;
    z-index: 6;
    height: 100vh;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 4;
  }

  .mobile-only {
    display: inline-flex;
  }
}

@media (max-width:768px) {
  body {
    overflow: hidden;
  }

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

  .main-area main {
    padding: 10px;
  }

  .chat-container,
  .app-shell {
    height: calc(100vh - 60px);
    padding: 0;
  }

  .panel.sidebar {
    display: none;
  }

  .chat-area {
    height: 100%;
  }

  .info-panel {
    display: flex;
  }

  .chat-mobile-tabs {
    display: flex;
  }

  .ai-controls {
    width: 100%;
    gap: 6px;
  }

  .ai-controls select {
    flex: 1;
  }

  .ai-controls .btn {
    padding: 8px 10px;
  }

  .bubble {
    max-width: 85%;
  }

  .bubble.bubble-audio {
    max-width: 92%;
  }
}

/* ===== Base rule: back button hidden by default (desktop) ===== */
.mobile-back-btn {
  display: none;
}

/* ========= Phone optimizations (<= 480px) ========= */
@media (max-width:480px) {

  /* --- 1) Back button: show, replace mobile tabs --- */
  .mobile-back-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--color-text, #1e293b);
    cursor: pointer;
    border-radius: 50%;
    flex-shrink: 0;
    margin-right: 4px;
  }

  .mobile-back-btn:active {
    background: var(--color-surface-alt, rgba(0, 0, 0, 0.06));
  }

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

  /* --- 2) Topbar: compact for phone --- */
  .topbar {
    padding: 6px 10px;
    min-height: 44px;
  }

  .topbar-right .user-email,
  .topbar-right .user-role,
  .topbar-right .build-stamp,
  #user-email,
  #user-role,
  #build-stamp {
    display: none !important;
  }

  .topbar-right {
    gap: 6px;
  }

  #logout-btn {
    font-size: 11px;
    padding: 6px 10px;
    min-height: 36px;
  }

  .topbar-theme-toggle {
    width: 36px;
    height: 36px;
    margin-right: 4px;
  }

  .topbar-left .title {
    font-size: 15px;
  }

  /* --- 3) Chat header: single row, no column layout --- */
  .chat-header {
    flex-direction: row !important;
    align-items: center;
    min-height: 48px;
    padding: 6px 8px;
    gap: 6px;
  }

  .chat-title {
    flex: 1;
    min-width: 0;
    gap: 6px;
  }

  .chat-actions {
    gap: 4px;
    align-self: center !important;
    flex-shrink: 0;
  }

  .chat-header .icon-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
  }

  /* AI controls: hide on phone (accessible via menu) */
  .ai-controls {
    display: none;
  }

  .contact-title {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .contact-subtitle,
  .contact-subtitle-row {
    font-size: 11px;
  }

  .avatar-circle {
    width: 36px;
    height: 36px;
    min-width: 36px;
  }

  .avatar-circle img {
    width: 36px;
    height: 36px;
  }

  /* --- 4) Chat input: fixed bottom, bigger buttons --- */
  .chat-input {
    padding: 6px 8px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom));
    gap: 4px;
    flex-wrap: nowrap !important;
  }

  .chat-input .btn.primary {
    width: auto !important;
  }

  #send-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    flex-shrink: 0;
  }

  #attach-btn {
    width: 32px;
    height: 32px;
    min-width: 32px;
    font-size: 20px;
  }

  #audio-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    font-size: 20px;
  }

  .input-field {
    flex: 1;
    min-width: 0;
  }

  #message-input {
    width: 100%;
    font-size: 16px;
    padding: 10px 12px;
    min-height: 44px;
  }

  #emoji-btn {
    width: 32px;
    height: 32px;
  }

  /* --- 5) Bubbles: wider on phone --- */
  .bubble {
    max-width: 92%;
  }

  .bubble .text {
    font-size: 14px;
    line-height: 1.45;
  }

  .meta {
    font-size: 10px;
  }

  /* --- 6) Scroll: momentum + safe area --- */
  .chat-messages,
  .chat-body {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .chat-body {
    padding: 8px 4px;
  }

  .scroll-bottom {
    right: 10px;
    bottom: 80px;
    width: 40px;
    height: 40px;
  }

  /* --- 7) Fix height chain: body → layout → main-area → main → app-shell → chat-area --- */
  body.page-chat {
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
  }

  body.page-chat .layout {
    height: 100%;
    overflow: hidden;
  }

  body.page-chat .main-area {
    height: 100%;
    overflow: hidden;
  }

  body.page-chat .topbar {
    flex-shrink: 0;
  }

  body.page-chat .main-area main {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    height: auto;
  }

  body.page-chat .app-view-panel {
    height: 100%;
    overflow: hidden;
  }

  .page-shell[data-page="chat"] {
    height: 100%;
    overflow: hidden;
  }

  .page-shell[data-page="chat"] .app-shell {
    height: 100% !important;
    overflow: hidden;
  }

  .page-shell[data-page="chat"] .chat-area {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .chat-header {
    flex-shrink: 0;
  }

  .chat-input {
    flex-shrink: 0;
  }

  .ai-suggestion-box {
    flex-shrink: 0;
  }

  .page-shell[data-page="chat"] .chat-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
  }

  /* --- Contact list: larger tap targets --- */
  .contact.conv-item {
    padding: 14px 12px;
    min-height: 64px;
  }

  .contact-avatar {
    width: 48px;
    height: 48px;
    min-width: 48px;
  }

  .contact-name {
    font-size: 15px;
  }

  .contact-last-msg {
    font-size: 13px;
  }

  .contact-time {
    font-size: 11px;
  }

  .contact-phone {
    font-size: 11px;
  }

  /* --- Sidebar: compact for phone --- */
  .sidebar-top {
    padding: 10px 10px 6px;
  }

  .sidebar-top .btn {
    min-height: 40px;
    font-size: 13px;
  }

  .sidebar-search {
    padding: 6px 10px;
  }

  .sidebar-search input {
    font-size: 16px;
    min-height: 36px;
  }

  .filter-tag {
    min-height: 32px;
    padding: 6px 12px;
    font-size: 12px;
  }

  .filter-add-btn {
    min-width: 32px;
    min-height: 32px;
  }

  /* --- Attach menu: full width at bottom --- */
  .attach-menu {
    bottom: 100%;
    left: 0;
    right: auto;
    width: 100vw;
    max-width: 100vw;
    border-radius: 12px 12px 0 0;
  }

  .attach-item {
    padding: 12px 16px;
    min-height: 44px;
  }

  /* --- Emoji picker: full width --- */
  .emoji-picker {
    width: 100%;
    left: 0;
    right: 0;
    bottom: 100%;
    border-radius: 12px 12px 0 0;
  }

  /* --- Modals: full width on phone --- */
  .modal .panel {
    width: 100vw !important;
    max-width: 100vw !important;
    border-radius: 12px 12px 0 0;
  }

  /* --- Dropdown menu: wider --- */
  .dropdown {
    min-width: 200px;
    right: 0;
  }

  .dropdown-item {
    padding: 12px 16px;
    min-height: 44px;
  }

  /* --- AI suggestion box: compact --- */
  .ai-suggestion-box {
    margin: 4px 8px;
    padding: 10px;
  }

  /* --- Info panel: full screen on phone --- */
  .info-panel {
    width: 100vw;
    position: fixed;
    inset: 0;
    z-index: 10;
    border-radius: 0;
  }

  .info-header {
    min-height: 48px;
    padding: 8px 12px;
  }

  .info-icon-btn {
    width: 44px;
    height: 44px;
  }
}


@media (max-width:1100px) {
  .info-panel {
    width: min(420px, 92vw);
    max-width: 92vw;
  }
}

@media (max-width:700px) {
  .table-responsive {
    overflow-x: auto;
  }

  .table {
    display: block;
  }

  .table thead {
    display: none;
  }

  .table tbody {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .table tr {
    display: flex;
    flex-direction: column;
    gap: 6px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px;
    background: #fff;
  }

  .table td {
    padding: 0 !important;
  }
}

/* ========= AI Suggestion Box ========= */
.ai-suggestion-box {
  margin: 0 var(--space-4);
  margin-bottom: var(--space-3);
  padding: var(--space-3);
  background: linear-gradient(135deg, var(--color-primary-soft) 0%, var(--color-surface) 100%);
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  animation: fadeInUp 0.2s ease;
}

.ai-suggestion-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.ai-suggestion-icon {
  font-size: 18px;
}

.ai-suggestion-title {
  font-weight: 700;
  font-size: var(--font-14);
  color: var(--color-primary);
  flex: 1;
}

.ai-suggestion-text {
  padding: var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-14);
  line-height: 1.5;
  color: var(--color-text);
  max-height: 150px;
  overflow-y: auto;
  white-space: pre-wrap;
}

.ai-suggestion-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-3);
  justify-content: flex-end;
}

.ai-global-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.ai-global-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-global-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-alt);
  font-size: 14px;
  cursor: pointer;
}

.ai-global-toggle input {
  transform: scale(1.1);
}

.day-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.day-chips.disabled {
  opacity: 0.6;
  pointer-events: none;
}

.day-chip {
  border: 1px solid var(--color-border);
  background: var(--color-surface-alt);
  color: var(--color-text);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}

.day-chip.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.ai-global-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.ai-suggestion-box.loading .ai-suggestion-text {
  color: var(--color-muted);
  font-style: italic;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========= AI Auto-Mode Toggle ========= */
.ai-auto-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface-alt);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-muted-strong);
  transition: all 0.15s ease;
}

.ai-auto-toggle.locked {
  opacity: 0.6;
  cursor: not-allowed;
}

.ai-auto-toggle.locked input {
  pointer-events: none;
}

.ai-auto-toggle:hover {
  background: var(--color-surface);
  border-color: var(--color-muted);
}

.ai-auto-toggle input {
  display: none;
}

.ai-auto-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-muted);
  transition: all 0.15s ease;
}

.ai-auto-toggle.active {
  background: var(--color-primary-soft);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.ai-auto-toggle.active .ai-auto-indicator {
  background: var(--color-success);
  box-shadow: 0 0 8px var(--color-success);
  animation: pulse 2s infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

/* ========= WA Connection Status Card (Settings) ========= */
.wa-status-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  margin-bottom: 16px;
  transition: all 0.2s ease;
}

.wa-status-card.connected {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(6, 182, 212, 0.1));
  border-color: rgba(16, 185, 129, 0.4);
}

.wa-status-card.disconnected {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(239, 68, 68, 0.05));
  border-color: rgba(245, 158, 11, 0.4);
}

.wa-status-card.error {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(239, 68, 68, 0.05));
  border-color: rgba(239, 68, 68, 0.4);
}

.wa-status-icon {
  font-size: 28px;
  line-height: 1;
}

.wa-status-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wa-status-label {
  font-weight: 600;
  font-size: 15px;
  color: var(--color-text);
}

.wa-status-phone {
  font-size: 13px;
  color: var(--color-muted-strong);
}

.wa-status-card .btn.small {
  padding: 6px 10px;
  font-size: 16px;
}

/* ========= Save Contact Button ========= */
.save-contact-btn {
  margin-left: auto;
  animation: pulse-badge 2s infinite;
}

.save-contact-btn.hidden {
  display: none;
}

/* ========= Image Lightbox ========= */
.lightbox-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
}

.lightbox-overlay.hidden {
  display: none;
}

.lightbox-image {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;
  font-size: 28px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.lightbox-download {
  position: absolute;
  bottom: 30px;
  color: white;
  background: rgba(255, 255, 255, 0.15);
  padding: 10px 20px;
  border-radius: 999px;
  text-decoration: none;
  font-size: 14px;
}

.lightbox-download:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ========= Message Media (WhatsApp Style) ========= */
.message-media {
  width: min(280px, 100%);
  max-width: 100%;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}

/* ========= Audio Message (WhatsApp Style) ========= */
.audio-message {
  --audio-btn-bg: #16a34a;
  --audio-btn-shadow: rgba(22, 163, 74, 0.25);
  --audio-btn-ring: rgba(22, 163, 74, 0.12);
  --wave-active: #16a34a;
  --wave-muted: rgba(22, 163, 74, 0.25);
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 10px;
  align-items: center;
  width: min(320px, 100%);
}

.message[data-channel="ms"] .audio-message,
.message.channel-messenger .audio-message {
  --audio-btn-bg: #2563eb;
  --audio-btn-shadow: rgba(37, 99, 235, 0.25);
  --audio-btn-ring: rgba(37, 99, 235, 0.12);
  --wave-active: #2563eb;
  --wave-muted: rgba(37, 99, 235, 0.25);
}

.message[data-channel="ig"] .audio-message,
.message.channel-instagram .audio-message {
  --audio-btn-bg: #e1306c;
  --audio-btn-shadow: rgba(225, 48, 108, 0.25);
  --audio-btn-ring: rgba(225, 48, 108, 0.12);
  --wave-active: #e1306c;
  --wave-muted: rgba(225, 48, 108, 0.25);
}

html[data-theme="dark"] .audio-message {
  --audio-btn-bg: #22c55e;
  --audio-btn-shadow: rgba(34, 197, 94, 0.35);
  --audio-btn-ring: rgba(34, 197, 94, 0.22);
  --wave-active: #22c55e;
  --wave-muted: rgba(34, 197, 94, 0.35);
}

html[data-theme="dark"] .message[data-channel="ms"] .audio-message,
html[data-theme="dark"] .message.channel-messenger .audio-message {
  --audio-btn-bg: #3b82f6;
  --audio-btn-shadow: rgba(59, 130, 246, 0.35);
  --audio-btn-ring: rgba(59, 130, 246, 0.22);
  --wave-active: #3b82f6;
  --wave-muted: rgba(59, 130, 246, 0.35);
}

html[data-theme="dark"] .message[data-channel="ig"] .audio-message,
html[data-theme="dark"] .message.channel-instagram .audio-message {
  --audio-btn-bg: #fb7185;
  --audio-btn-shadow: rgba(251, 113, 133, 0.35);
  --audio-btn-ring: rgba(251, 113, 133, 0.22);
  --wave-active: #fb7185;
  --wave-muted: rgba(251, 113, 133, 0.35);
}

.audio-play-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 0;
  background: var(--audio-btn-bg);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 6px 14px var(--audio-btn-shadow);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.audio-play-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px var(--audio-btn-shadow);
}

.audio-message.is-playing .audio-play-btn {
  transform: translateY(-1px);
  box-shadow: 0 0 0 4px var(--audio-btn-ring), 0 8px 18px var(--audio-btn-shadow);
}

.audio-icon {
  width: 16px;
  height: 16px;
}

.audio-icon-pause {
  display: none;
}

.audio-message.is-playing .audio-icon-play {
  display: none;
}

.audio-message.is-playing .audio-icon-pause {
  display: block;
}

.audio-message.is-loading {
  opacity: 0.78;
}

.audio-message.is-loading .audio-play-btn {
  cursor: not-allowed;
  box-shadow: none;
  opacity: 0.7;
}

.audio-message.is-loading .audio-waveform {
  pointer-events: none;
}

.audio-message.is-loading .audio-waveform-bars span {
  background: var(--color-skeleton);
}

.audio-waveform {
  position: relative;
  height: 32px;
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.audio-waveform:focus-visible {
  outline: 2px solid var(--audio-btn-bg);
  outline-offset: 2px;
  border-radius: 8px;
}

.audio-waveform-bars {
  display: flex;
  align-items: center;
  gap: 2px;
  width: 100%;
  height: 100%;
}

.audio-waveform-bars span {
  width: 3px;
  height: calc(var(--h) * 100%);
  background: var(--wave-muted);
  border-radius: 999px;
  transition: background 0.15s ease;
}

.audio-waveform-bars span.is-active {
  background: var(--wave-active);
}

.audio-time {
  font-size: 11px;
  color: var(--color-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.audio-divider {
  opacity: 0.6;
}

.audio-element {
  display: none;
}

.message.sticker .bubble {
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 6px 6px 10px;
}

.message.sticker .bubble-text {
  padding: 0;
}

.message.sticker .meta {
  display: block;
  text-align: right;
  margin-top: 4px;
  font-size: 12px;
  color: var(--color-muted);
}

.message-media.sticker {
  width: min(160px, 100%);
  max-width: 160px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.message-image.message-sticker {
  width: 100%;
  max-width: 160px;
  height: auto;
  border-radius: 12px;
  background: transparent;
}

.message-media.sticker .media-placeholder {
  padding: 16px;
  border-radius: 12px;
  border: 1px dashed var(--color-border);
  background: transparent;
}

.message-image {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.attached-img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 12px;
}

.message-image:hover {
  opacity: 0.9;
}

.media-caption {
  padding: 8px 0 0 0;
  font-size: 14px;
  color: var(--color-text);
  line-height: 1.4;
}

.media-placeholder {
  padding: 40px 20px;
  text-align: center;
  background: var(--color-surface-alt);
  border-radius: 8px;
  color: var(--color-muted);
  font-size: 13px;
}

/* ========= Info Panel Redesign (WhatsApp-like) ========= */

/* Header del panel */
.info-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
}

.info-header-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-primary);
}

/* Tabs tipo pill */
.info-tabs-pill {
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 12px 20px;
  background: var(--color-surface);
}

.tab-pill {
  padding: 8px 24px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-pill:hover {
  background: var(--color-surface-alt);
}

.tab-pill.active {
  background: var(--color-text);
  color: var(--color-surface);
  border-color: var(--color-text);
}

/* Info body scrollable */
.info-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 20px 20px;
}

/* Section labels */
.info-section-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-muted);
  margin: 20px 0 12px;
  text-transform: capitalize;
}

/* Contact Card - Main card */
.contact-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 20px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.contact-card-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #D9FDD3;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
}

.contact-card-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.contact-card-avatar-img[src=""],
.contact-card-avatar-img:not([src]) {
  display: none;
}

.contact-card-avatar-initials {
  font-size: 22px;
  font-weight: 700;
  color: #1F7A3A;
  position: absolute;
}

.contact-card-details {
  flex: 1;
  min-width: 0;
}

.contact-card-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 4px;
}

.contact-card-phone {
  font-size: 14px;
  color: var(--color-muted);
  margin-bottom: 2px;
}

.contact-card-email {
  font-size: 13px;
  color: var(--color-primary);
}

.btn-link {
  background: none;
  border: none;
  color: var(--color-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  text-decoration: none;
}

.btn-link:hover {
  text-decoration: underline;
}

.btn-link--small {
  font-size: 12px;
}

/* Icon buttons row */
.info-icon-buttons {
  display: flex;
  justify-content: center;
  gap: 16px;
  padding: 16px 0;
}

.info-icon-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.info-icon-btn:hover {
  background: var(--color-surface-alt);
  color: var(--color-text);
}

.info-icon-btn.active,
.info-icon-btn:has(input:checked) {
  background: var(--color-primary-soft);
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.info-icon-btn--primary {
  background: #25D366;
  border-color: #25D366;
  color: white;
}

.info-icon-btn--primary:hover {
  background: #1da855;
  border-color: #1da855;
  color: white;
}

/* Profile section */
.profile-section {
  padding: 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
}

.profile-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.profile-label {
  font-size: 12px;
  color: var(--color-muted);
}

.profile-value {
  font-size: 13px;
  font-weight: 500;
  color: #25D366;
}

.profile-info-text {
  font-size: 12px;
  color: var(--color-muted);
  margin-bottom: 12px;
  line-height: 1.4;
}

/* Status section */
.status-section {
  background: var(--color-surface-alt);
  border-radius: 12px;
  padding: 4px;
}

.input-full {
  width: 100%;
}

/* Assign section */
.assign-section {
  margin-top: 8px;
}

.assign-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.assign-msg {
  margin-top: 6px;
  font-size: 12px;
}

/* Files section */
.files-section {
  margin-top: 8px;
}

.files-count {
  font-size: 12px;
  color: var(--color-muted);
  margin-left: 4px;
}

.files-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 12px;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 4px;
}

.files-grid-item {
  height: 84px;
  border-radius: 12px;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.15s ease;
}

.files-grid-item:hover {
  border-color: var(--color-primary);
  transform: scale(1.02);
}

.files-grid-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.files-grid-item svg {
  width: 32px;
  height: 32px;
  color: var(--color-muted);
}

/* Mobile: 2 columns for files grid */
@media (max-width: 768px) {
  .files-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Info note at bottom */
.info-note {
  text-align: center;
  font-size: 11px;
  padding: 16px 0;
  color: var(--color-muted);
}

/* Tab panel visibility */
.tab-panel {
  display: none;
}

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

.media-error {
  padding: 20px;
  text-align: center;
  background: rgba(239, 68, 68, 0.1);
  border-radius: 8px;
  color: var(--color-error);
  font-size: 13px;
}

.message-media.loading .media-placeholder {
  animation: shimmer 1.5s ease-in-out infinite;
  background: linear-gradient(90deg, var(--color-skeleton), var(--color-skeleton-shine), var(--color-skeleton));
  background-size: 200% 100%;
}

/* ========= Image Modal / Lightbox ========= */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

.modal-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.2);
}

.invite-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.invite-badge.active {
  background: rgba(34, 197, 94, 0.15);
  color: #16a34a;
  border: 1px solid rgba(34, 197, 94, 0.4);
}

.invite-badge.consumed {
  background: rgba(59, 130, 246, 0.12);
  color: #2563eb;
  border: 1px solid rgba(59, 130, 246, 0.35);
}

.invite-badge.expired {
  background: rgba(234, 179, 8, 0.12);
  color: #b45309;
  border: 1px solid rgba(234, 179, 8, 0.35);
}

.invite-badge.revoked {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.modal .close {
  position: absolute;
  top: 20px;
  right: 24px;
  font-size: 32px;
  color: white;
  cursor: pointer;
  z-index: 10001;
  background: rgba(0, 0, 0, 0.5);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.modal .close:hover {
  background: rgba(0, 0, 0, 0.8);
}

.modal-content {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: none;
  font-size: 40px;
  padding: 16px 20px;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.2s;
}

.modal-nav:hover {
  background: rgba(255, 255, 255, 0.2);
}

.modal-nav.prev {
  left: 20px;
}

.modal-nav.next {
  right: 20px;
}

/* Chat page compact layout - matches WhatsApp Web */
body.page-chat .main-area main {
  padding: 1px !important;
}

/* WhatsApp-like chat header refinements */
.chat-header .icon-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  background: var(--color-surface-alt);
  border: 1px solid rgba(0, 0, 0, 0.04);
  transition: background 0.15s, transform 0.1s;
}

.chat-header .icon-btn:hover {
  background: var(--color-border);
  transform: scale(1.05);
}

.chat-header .icon-btn svg {
  width: 18px;
  height: 18px;
}

.chat-header .ai-select {
  min-width: 140px;
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 16px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: var(--color-surface);
}

.chat-header .btn.small {
  padding: 5px 12px;
  font-size: 12px;
  border-radius: 14px;
}

.chat-header .ai-auto-toggle {
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 12px;
}

/* ========= Topbar Theme Toggle ========= */
.topbar-theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--topbar-toggle-border);
  background: var(--topbar-toggle-bg);
  color: var(--topbar-toggle-color);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  margin-right: 12px;
}

.topbar-theme-toggle:hover {
  background: var(--topbar-toggle-hover);
  transform: scale(1.05);
}

/* Show moon in light mode, sun in dark mode */
.topbar-theme-toggle .icon-sun {
  display: none;
}

.topbar-theme-toggle .icon-moon {
  display: block;
}

html[data-theme="dark"] .topbar-theme-toggle .icon-sun {
  display: block;
}

html[data-theme="dark"] .topbar-theme-toggle .icon-moon {
  display: none;
}

/* ========= Dark Theme ========= */
html[data-theme="dark"] {
  --color-bg: #0f172a;
  --color-surface: #1e293b;
  --color-surface-alt: #334155;
  --color-text: #f1f5f9;
  --color-muted: #94a3b8;
  --color-border: #475569;
  --bg: #0f172a;
  --panel: #1e293b;
  --card: #1e293b;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --border: #475569;
  --input: #334155;
  --bubble-in: #0b1220;
  --bubble-out: #1f2a44;
  --sidebar-bg: #020617;
  --sidebar-text: #e2e8f0;
  --sidebar-hover: rgba(255, 255, 255, 0.08);
  --topbar-bg: #0f172a;
  --topbar-border: rgba(255, 255, 255, 0.06);
  --topbar-text: #e2e8f0;
  --topbar-title: rgba(226, 232, 240, 0.7);
  --topbar-pill-bg: #1e293b;
  --topbar-pill-text: #f1f5f9;
  --topbar-pill-border: rgba(255, 255, 255, 0.12);
  --topbar-pill-hover: rgba(255, 255, 255, 0.08);
  --topbar-pill-border-hover: rgba(255, 255, 255, 0.2);
  --topbar-toggle-bg: rgba(255, 255, 255, 0.06);
  --topbar-toggle-border: rgba(255, 255, 255, 0.15);
  --topbar-toggle-color: #e2e8f0;
  --topbar-toggle-hover: rgba(255, 255, 255, 0.12);
}

/* Dark sidebar */
html[data-theme="dark"] .sidebar-nav {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
}

/* Dark topbar adjustments */
html[data-theme="dark"] .topbar {
  background: var(--topbar-bg);
  border-bottom-color: var(--topbar-border);
}

html[data-theme="dark"] .topbar-pill {
  background: var(--topbar-pill-bg);
}

/* Dark main area */
html[data-theme="dark"] .main-area {
  background: var(--bg);
}

html[data-theme="dark"] .main-area main {
  background: var(--bg);
}

/* Dark chat header */
html[data-theme="dark"] .chat-header {
  background: var(--color-surface);
  border-color: rgba(255, 255, 255, 0.06);
}

/* Dark chat messages area */
html[data-theme="dark"] .chat-messages-container {
  background: var(--color-bg);
}

/* Dark input area */
html[data-theme="dark"] .chat-input-bar {
  background: var(--color-surface);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

html[data-theme="dark"] .chat-input-bar input,
html[data-theme="dark"] .chat-input-bar textarea {
  background: var(--color-surface-alt);
  color: var(--color-text);
  border-color: var(--color-border);
}

html[data-theme="dark"] #attach-btn {
  color: #cbd5e1;
}

html[data-theme="dark"] #attach-btn:hover {
  color: #f8fafc;
  background: rgba(148, 163, 184, 0.18);
}

html[data-theme="dark"] #emoji-btn {
  color: #cbd5e1;
}

html[data-theme="dark"] #emoji-btn:hover {
  color: #f8fafc;
  background: rgba(148, 163, 184, 0.18);
}

html[data-theme="dark"] .contact-channel-mark.channel-wa {
  --wa-icon-color: #4ade80;
}

html[data-theme="dark"] .channel-badge.channel-wa-icon {
  color: #4ade80;
}

html[data-theme="dark"] .channel-badge.channel-ms-icon {
  color: #60a5fa;
}

html[data-theme="dark"] .attach-item[data-action="document"] {
  --attach-icon-color: #b79cff;
}

html[data-theme="dark"] .attach-item[data-action="media"] {
  --attach-icon-color: #67d7ff;
}

html[data-theme="dark"] .attach-item[data-action="camera"] {
  --attach-icon-color: #8ec5ff;
}

html[data-theme="dark"] .attach-item[data-action="audio-file"] {
  --attach-icon-color: #b38aff;
}

html[data-theme="dark"] .attach-item[data-action="contact"] {
  --attach-icon-color: #d39cff;
}

/* Dark contacts list */
html[data-theme="dark"] .contact-list-panel {
  background: var(--color-surface);
  border-color: rgba(255, 255, 255, 0.06);
}

html[data-theme="dark"] .contact-item {
  border-color: rgba(255, 255, 255, 0.04);
}

html[data-theme="dark"] .contact-item:hover {
  background: var(--color-surface-alt);
}

/* Dark buttons and inputs */
html[data-theme="dark"] .input,
html[data-theme="dark"] .select {
  background: var(--color-surface-alt);
  color: var(--color-text);
  border-color: var(--color-border);
}

html[data-theme="dark"] .btn.ghost {
  color: var(--color-text);
}

html[data-theme="dark"] .btn.ghost:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Dark mode: Pipeline only */
html[data-theme="dark"] .page-shell[data-page="pipeline"] .panel {
  background: #0f172a;
  border-color: rgba(148, 163, 184, 0.28);
}

html[data-theme="dark"] .page-shell[data-page="pipeline"] .pipeline-column {
  background: #111b2f;
  border-color: rgba(148, 163, 184, 0.32);
}

html[data-theme="dark"] .page-shell[data-page="pipeline"] .pipeline-col-header {
  color: #e2e8f0;
  background: rgba(15, 23, 42, 0.55);
  border-bottom-color: rgba(148, 163, 184, 0.24);
}

html[data-theme="dark"] .page-shell[data-page="pipeline"] .pipeline-count {
  color: #93c5fd;
}

html[data-theme="dark"] .page-shell[data-page="pipeline"] .pipeline-col-body.drag-over {
  background: rgba(59, 130, 246, 0.2);
}

html[data-theme="dark"] .page-shell[data-page="pipeline"] .pipeline-card {
  background: #1a2740;
  border-color: rgba(148, 163, 184, 0.3);
  box-shadow: 0 10px 24px rgba(2, 6, 23, 0.45);
}

html[data-theme="dark"] .page-shell[data-page="pipeline"] .pipeline-card:hover {
  border-color: rgba(147, 197, 253, 0.55);
  box-shadow: 0 14px 28px rgba(2, 6, 23, 0.55);
}

html[data-theme="dark"] .page-shell[data-page="pipeline"] .pipeline-card-title {
  color: #f8fafc;
}

html[data-theme="dark"] .page-shell[data-page="pipeline"] .pipeline-card-sub {
  color: #cbd5e1;
}

html[data-theme="dark"] .page-shell[data-page="pipeline"] .pipeline-badge {
  display: inline-flex;
  align-items: center;
  margin-top: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 11px;
  font-weight: 600;
}

html[data-theme="dark"] .page-shell[data-page="pipeline"] .pipeline-badge.status-new {
  background: #334155;
  color: #e2e8f0;
  border-color: #64748b;
}

html[data-theme="dark"] .page-shell[data-page="pipeline"] .pipeline-badge.status-in_conversation {
  background: #1e3a8a;
  color: #dbeafe;
  border-color: #3b82f6;
}

html[data-theme="dark"] .page-shell[data-page="pipeline"] .pipeline-badge.status-quoted {
  background: #78350f;
  color: #fde68a;
  border-color: #f59e0b;
}

html[data-theme="dark"] .page-shell[data-page="pipeline"] .pipeline-badge.status-won {
  background: #14532d;
  color: #dcfce7;
  border-color: #22c55e;
}

html[data-theme="dark"] .page-shell[data-page="pipeline"] .pipeline-badge.status-lost {
  background: #7f1d1d;
  color: #fee2e2;
  border-color: #ef4444;
}

/* ========= Send Button ========= */
#send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  color: #ffffff;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  flex-shrink: 0;
}

html[data-theme="dark"] .page-shell[data-page="chat"] .chat-area {
  background-color: #102032;
  background-image: url('/assets/chat-bg-whatsapp-dark-from-light.png');
  background-repeat: repeat;
  background-size: 420px auto;
}

html[data-theme="dark"] .page-shell[data-page="chat"] .chat-body {
  background: transparent;
}

html[data-theme="dark"] .bubble {
  color: #f8fafc;
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] .message.out .bubble {
  background: #223452;
  border-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .message.out .bubble[data-channel="wa"] {
  background: #11442a;
  border-color: rgba(16, 185, 129, 0.35);
}

html[data-theme="dark"] .message.out .bubble[data-channel="ms"] {
  background: #1a3a6d;
  border-color: rgba(59, 130, 246, 0.45);
}

html[data-theme="dark"] .message.in .bubble[data-channel="ms"] {
  background: #0c1a33;
  border-color: rgba(59, 130, 246, 0.35);
}

html[data-theme="dark"] .message.out .bubble[data-channel="ig"] {
  background: #2a1a23;
  border-color: rgba(225, 48, 108, 0.55);
  box-shadow: 0 0 0 3px rgba(225, 48, 108, 0.12);
}

html[data-theme="dark"] .message.in .bubble[data-channel="ig"] {
  background: #1d1217;
  border-color: rgba(225, 48, 108, 0.45);
  box-shadow: 0 6px 14px rgba(225, 48, 108, 0.12);
}

html[data-theme="dark"] .meta {
  color: rgba(226, 232, 240, 0.75);
}

html[data-theme="dark"] .day-separator {
  background: #111827;
  color: #cbd5f5;
  border-color: rgba(255, 255, 255, 0.08);
}

/* WhatsApp Send Button */
.send-btn-whatsapp {
  background: #25d366;
  box-shadow: 0 2px 8px rgba(37, 211, 102, 0.3);
}

.send-btn-whatsapp:hover {
  background: #1ebe5d;
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
}

.send-btn-messenger {
  background: #2563eb;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.send-btn-messenger:hover {
  background: #1d4ed8;
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.send-btn-messenger:active {
  transform: scale(0.95);
}

.send-btn-instagram {
  background: var(--ig);
  box-shadow: 0 2px 8px rgba(225, 48, 108, 0.3);
}

.send-btn-instagram:hover {
  background: #c81e5a;
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(225, 48, 108, 0.35);
}

.send-btn-instagram:active {
  transform: scale(0.95);
}

.send-btn-whatsapp:active {
  transform: scale(0.95);
}

.send-btn-whatsapp svg {
  width: 22px;
  height: 22px;
  margin-left: 2px;
  /* Visual centering for arrow */
}

/* Dark mode adjustments */
html[data-theme="dark"] .send-btn-whatsapp {
  box-shadow: 0 2px 8px rgba(37, 211, 102, 0.2);
}

html[data-theme="dark"] .send-btn-whatsapp:hover {
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.35);
}

html[data-theme="dark"] .send-btn-messenger {
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

html[data-theme="dark"] .send-btn-messenger:hover {
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

html[data-theme="dark"] .send-btn-instagram {
  box-shadow: 0 2px 8px rgba(225, 48, 108, 0.25);
}

html[data-theme="dark"] .send-btn-instagram:hover {
  box-shadow: 0 4px 12px rgba(225, 48, 108, 0.4);
}

/* Floating composer like reference (chat only) */
.page-shell[data-page="chat"] .chat-input {
  margin: 0 12px 12px;
  padding: 8px 12px;
  border: 0;
  border-radius: 22px;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.page-shell[data-page="chat"] .chat-input .input-field {
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(148, 163, 184, 0.32);
  border-radius: 16px;
  padding: 8px 12px;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.10);
}

.page-shell[data-page="chat"] .chat-input .input-field #attach-btn,
.page-shell[data-page="chat"] .chat-input .input-field #emoji-btn {
  width: 32px;
  height: 32px;
  min-width: 32px;
}

.page-shell[data-page="chat"] .chat-input .input-field:focus-within {
  border-color: rgba(59, 130, 246, 0.55);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.16);
}

.page-shell[data-page="chat"] .chat-input #message-input {
  padding: 0;
  min-height: 0;
}

.page-shell[data-page="chat"] .chat-input #message-input::placeholder {
  color: rgba(71, 85, 105, 0.9);
}

.page-shell[data-page="chat"] .chat-input .attach-menu,
.page-shell[data-page="chat"] .chat-input .emoji-picker {
  bottom: calc(100% + 8px);
}

html[data-theme="dark"] .page-shell[data-page="chat"] .chat-input {
  background: transparent;
  box-shadow: none;
}

html[data-theme="dark"] .page-shell[data-page="chat"] .chat-input .input-field {
  background: rgba(2, 6, 23, 0.58);
  border-color: rgba(148, 163, 184, 0.3);
  box-shadow: 0 4px 12px rgba(2, 6, 23, 0.35);
}

html[data-theme="dark"] .page-shell[data-page="chat"] .chat-input #message-input::placeholder {
  color: rgba(148, 163, 184, 0.9);
}

/* ========= Full Emoji Picker ========= */
.emoji-picker {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  width: 340px;
  max-width: calc(100vw - 24px);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  z-index: 50;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.emoji-picker-header {
  padding: 10px 12px 6px;
  border-bottom: 1px solid var(--color-border);
}

.emoji-search-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface-alt);
  font-size: 13px;
  color: var(--color-text);
  outline: none;
  font-family: var(--font-ui);
}

.emoji-search-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.12);
}

.emoji-picker-categories {
  display: flex;
  gap: 2px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--color-border);
  overflow-x: auto;
}

.emoji-picker-categories::-webkit-scrollbar {
  display: none;
}

.emoji-cat-btn {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 18px;
  padding: 6px 8px;
  border-radius: 8px;
  transition: background .12s;
  flex-shrink: 0;
  line-height: 1;
}

.emoji-cat-btn:hover {
  background: var(--color-surface-alt);
}

.emoji-cat-btn.active {
  background: var(--color-primary-soft);
}

.emoji-picker-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  padding: 8px;
  max-height: 280px;
  overflow-y: auto;
  overflow-x: hidden;
}

.emoji-picker-grid::-webkit-scrollbar {
  width: 6px;
}

.emoji-picker-grid::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, .12);
  border-radius: 6px;
}

.emoji-item {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 22px;
  padding: 4px;
  border-radius: 8px;
  transition: background .1s, transform .1s;
  text-align: center;
  line-height: 1.2;
}

.emoji-item:hover {
  background: var(--color-surface-alt);
  transform: scale(1.15);
}

.emoji-no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 20px;
  color: var(--color-muted);
  font-size: 13px;
}

/* ========= Compact Contact Info Bar ========= */
.chat-contact-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 16px;
  margin: 0 8px;
  background: var(--color-surface-alt);
  border-radius: 10px;
  font-size: 12px;
  color: var(--color-muted-strong);
  flex-wrap: wrap;
  border: 1px solid var(--color-border);
}

.cci-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.cci-status {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.cci-tags {
  display: inline-flex;
  gap: 4px;
  flex-wrap: wrap;
}

.cci-tag {
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-size: 10px;
  font-weight: 500;
}

/* ========= AI Suggest Button (Composer Area) ========= */
.ai-suggest-composer {
  margin: 0 12px 4px;
  align-self: flex-start;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-primary);
  transition: all .15s;
}

.ai-suggest-composer:hover {
  background: var(--color-primary-soft);
  border-color: var(--color-primary);
}

/* ========= Transfer Button (Contact List) ========= */
.contact-transfer-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid var(--color-warning);
  background: transparent;
  color: var(--color-warning);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s, background .12s;
  z-index: 2;
}

.contact:hover .contact-transfer-btn,
.contact-transfer-btn:focus {
  opacity: 1;
}

.contact-transfer-btn:hover {
  background: rgba(217, 119, 6, 0.12);
}

.contact.conv-item {
  position: relative;
}

/* Transfer dropdown */
.transfer-dropdown {
  position: absolute;
  right: 10px;
  top: calc(50% + 18px);
  z-index: 30;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  min-width: 180px;
  padding: 6px 0;
  max-height: 200px;
  overflow-y: auto;
}

.transfer-dropdown-item {
  display: block;
  width: 100%;
  padding: 8px 14px;
  text-align: left;
  background: none;
  border: none;
  color: var(--color-text);
  font-size: 13px;
  cursor: pointer;
}

.transfer-dropdown-item:hover {
  background: var(--color-surface-alt);
}

/* Spectator mode banner */
.spectator-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 16px;
  margin: 0 8px 4px;
  background: rgba(217, 119, 6, 0.1);
  border: 1px solid rgba(217, 119, 6, 0.3);
  border-radius: 10px;
  font-size: 12px;
  color: var(--color-warning);
  font-weight: 500;
}

/* ========= Hamburger Button ========= */
.hamburger-btn {
  display: none;
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--topbar-text);
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: background .12s;
  margin-right: 8px;
  flex-shrink: 0;
}

.hamburger-btn:hover {
  background: var(--color-surface-alt);
}

/* ========= Tablet Breakpoint (768px – 1023px) ========= */
@media (max-width: 1023px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar-nav {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    z-index: 10;
    transform: translateX(-100%);
    transition: transform .25s ease;
  }

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

  .hamburger-btn {
    display: inline-flex;
  }

  .topbar {
    padding: 0 16px;
  }

  .topbar-right .user-email {
    display: none;
  }

  .topbar-pill {
    padding: 4px 4px 4px 8px;
  }

  .app-shell {
    grid-template-columns: 280px minmax(0, 1fr);
    padding: var(--space-2);
    height: calc(100vh - 60px);
  }

  .chat-header .ai-controls {
    flex-wrap: wrap;
  }

  .ai-select {
    min-width: 140px;
  }

  .info-panel {
    width: 300px;
  }
}

/* ========= Mobile Breakpoint (< 768px) ========= */
@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar-nav {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    z-index: 10;
    transform: translateX(-100%);
    transition: transform .25s ease;
  }

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

  .hamburger-btn {
    display: inline-flex;
  }

  .topbar {
    min-height: 50px;
    padding: 0 12px;
  }

  .topbar-right .user-email,
  .topbar-right .build-stamp {
    display: none;
  }

  .topbar-pill {
    padding: 2px 2px 2px 6px;
    gap: 0;
  }

  .topbar-pill .user-role.badge {
    font-size: 10px;
    padding: 3px 8px;
    margin-right: 4px;
  }

  .topbar-pill .btn.ghost {
    padding: 4px 10px;
    font-size: 11px;
  }

  .chat-header {
    margin: 4px;
    padding: 8px 10px;
    border-radius: 14px;
    gap: 8px;
    min-height: 48px;
  }

  .chat-header .ai-controls {
    flex-wrap: wrap;
    gap: 4px;
  }

  .ai-select {
    min-width: 120px;
    font-size: 12px;
  }

  .chat-actions {
    gap: 4px;
  }

  .chat-title {
    gap: 8px;
  }

  .contact-title {
    font-size: 14px;
  }

  .contact-subtitle {
    font-size: 11px;
  }

  .avatar-circle {
    width: 34px;
    height: 34px;
  }

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

  .search-panel input {
    width: 180px;
  }

  /* Modal responsive */
  .modal .panel {
    width: 92vw !important;
    max-width: 420px;
  }

  .info-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    max-width: 360px;
    z-index: 50;
    border-radius: 0;
  }

  .chat-mobile-tabs {
    display: flex;
  }

  /* AI suggestion box responsive */
  .ai-suggestion-box {
    margin: 0 4px;
    border-radius: 12px;
  }

  /* Emoji picker responsive */
  .emoji-picker {
    width: calc(100vw - 24px);
    max-width: 320px;
  }

  /* Attach menu responsive */
  .attach-menu {
    max-width: calc(100vw - 24px);
  }
}

/* Mobile chat list: WhatsApp-like style (no desktop impact) */
@media (max-width: 768px) {
  .page-shell[data-page="chat"] .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    gap: 0;
    padding: 0;
    height: 100%;
    min-height: 100%;
  }

  body.page-chat .main-area main {
    padding: 0 !important;
  }

  body.page-chat .page-shell {
    padding-bottom: 0;
    height: 100%;
  }

  .page-shell[data-page="chat"] .panel.sidebar {
    display: flex;
    width: 100%;
    border: 0;
    border-radius: 0;
    background: var(--color-bg);
    height: 100%;
    min-height: 0;
  }

  .page-shell[data-page="chat"][data-view="chat"] .panel.sidebar {
    display: none;
  }

  .page-shell[data-page="chat"][data-view="chat"] .chat-area {
    display: flex;
  }

  .page-shell[data-page="chat"][data-view="contacts"] .chat-area,
  .page-shell[data-page="chat"][data-view="contacts"] #info-panel {
    display: none;
  }

  .page-shell[data-page="chat"][data-view="profile"] .panel.sidebar,
  .page-shell[data-page="chat"][data-view="profile"] .chat-area {
    display: none;
  }

  .page-shell[data-page="chat"][data-view="profile"] #info-panel {
    display: flex;
  }

  .page-shell[data-page="chat"] .chat-area,
  .page-shell[data-page="chat"] #info-panel {
    height: 100%;
    min-height: 0;
    border-radius: 0;
  }

  .page-shell[data-page="chat"] .chat-body {
    min-height: 0;
  }

  .page-shell[data-page="chat"] .chat-input {
    margin: 0 8px 8px;
    padding: 8px 10px;
    border-radius: 18px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }

  .page-shell[data-page="chat"]:not([data-view]) .panel.sidebar {
    display: flex;
  }

  .page-shell[data-page="chat"]:not([data-view]) .chat-area {
    display: none;
  }

  .chat-mobile-tabs {
    position: sticky;
    top: 0;
    z-index: 6;
    background: var(--color-bg);
    padding: 8px 12px;
    border-bottom: 1px solid var(--color-border);
  }

  .chat-mobile-tabs .btn {
    border-radius: 999px;
    font-size: 12px;
    padding: 6px 12px;
  }

  .sidebar-top {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--color-bg);
    padding: 12px 12px 8px;
    border-bottom: 1px solid var(--color-border);
  }

  .sidebar-top .btn {
    border-radius: 999px;
    font-size: 13px;
    padding: 8px 12px;
  }

  .sidebar-search {
    background: var(--color-surface-alt);
    border-radius: 999px;
    padding: 8px 12px;
  }

  .sidebar-search input {
    font-size: 13px;
    background: transparent;
  }

  .filter-label {
    display: none;
  }

  .filter-tags-container {
    margin-top: 6px;
  }

  .filter-tags {
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .filter-tags::-webkit-scrollbar {
    display: none;
  }

  .filter-tag {
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
  }

  .contact-list {
    padding: 0;
  }

  .contact.conv-item {
    padding: 10px 12px;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }

  .contact.conv-item.active {
    background: var(--color-surface-alt);
  }

  .contact-row {
    align-items: flex-start;
  }

  .contact-name {
    font-size: 15px;
  }

  .contact-time {
    font-size: 11px;
  }

  .contact-phone {
    font-size: 11px;
  }

  .contact-last-msg {
    font-size: 13px;
  }

  .contact-avatar {
    width: 44px;
    height: 44px;
  }

  .contact-badges {
    gap: 6px;
  }
}