:root {
  --app-canvas: #eef0f2;
  --app-canvas-dark: #0b141a;
  --panel: #ffffff;
  --panel-dark: #111b21;
  --border-dark: #202c33;
  --border-dark-2: #2a3942;
  --input-dark: #202c33;
  --chat-wallpaper: #efeae2;
  --composer: #f0f2f5;
  --wa-green: #00a884;
  --brand-from: #3b82f6;
  --brand-to: #4f46e5;
  --cta: #2563eb;
  --radius: 0.5rem;
  --card-radius-lg: 1.5rem; /* legacy dashboard / overview cards */
  --soft-surface: #F8F9FC;
  --chart-leads: #8B5CF6;
  --chart-appointments: #3B82F6;
  --chart-proposals: #EAB308;
  --chart-clients: #22C55E;
  /* App shell: sidebar + content share one inset token (open + collapsed). */
  --shell-gap: 0.75rem;   /* gap between sidebar and content */
  --shell-inset: 1.5rem;  /* top + outer-edge inset; tops must stay flush */
  /* Mobile header bar — must match Tailwind pt-14 (3.5rem) and .shell-main offset. */
  --shell-mobile-header: 3.5rem;
}

html {
  color-scheme: light;
}

html.dark {
  color-scheme: dark;
}

body.app-shell {
  background: var(--app-canvas);
  min-height: 100dvh;
  height: 100dvh;
  overflow: hidden;
}

body.app-shell.shell-menu-open {
  overflow: hidden;
}

.app-shell-frame {
  min-height: 100dvh;
  height: 100dvh;
  overflow: hidden;
}

html.dark body.app-shell {
  background: var(--app-canvas-dark);
}

[x-cloak] {
  display: none !important;
}

/* Form controls — match legacy soft inputs */
.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-field label {
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
}

html.dark .form-field label {
  color: #d1d5db;
}

.form-field input,
.form-field select,
.form-field textarea,
.input-field {
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: #fff;
  font-size: 0.875rem;
  width: 100%;
}

html.dark .form-field input,
html.dark .form-field select,
html.dark .form-field textarea,
html.dark .input-field {
  background: var(--input-dark);
  border-color: var(--border-dark-2);
  color: #f3f4f6;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus,
.input-field:focus {
  outline: 2px solid rgba(37, 99, 235, 0.25);
  border-color: #60a5fa;
}

/* Domain CTAs */
.btn-primary,
.btn-blue {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 0.5rem;
  background: #2563eb;
  color: #fff;
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  height: 2.25rem;
}

.btn-primary:hover,
.btn-blue:hover {
  background: #1d4ed8;
}

.btn-soft-blue {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: 0.5rem;
  background: #dbeafe;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.45rem 0.85rem;
}

html.dark .btn-soft-blue {
  background: rgba(30, 58, 138, 0.35);
  color: #93c5fd;
  border-color: rgba(59, 130, 246, 0.3);
}

.btn-soft-green {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: 0.5rem;
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.45rem 0.85rem;
}

.btn-soft-pink {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: 0.5rem;
  background: #fce7f3;
  color: #be185d;
  border: 1px solid #fbcfe8;
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.45rem 0.85rem;
}

.btn-soft-indigo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: 0.5rem;
  background: #e0e7ff;
  color: #4338ca;
  border: 1px solid #c7d2fe;
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.45rem 0.85rem;
}

.btn-soft-orange {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: 0.5rem;
  background: #ffedd5;
  color: #c2410c;
  border: 1px solid #fed7aa;
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.45rem 0.85rem;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  padding: 0.45rem 0.75rem;
  color: #4b5563;
  font-size: 0.875rem;
}

.btn-ghost:hover {
  background: #f3f4f6;
}

html.dark .btn-ghost {
  color: #9ca3af;
}

html.dark .btn-ghost:hover {
  background: #1e293b;
}

.btn-wa {
  background: var(--wa-green);
  color: #fff;
  border-radius: 9999px;
}

.btn-wa:hover {
  filter: brightness(0.95);
}

.errorlist {
  color: #dc2626;
  font-size: 0.85rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

/* Page panel (Leads, Tasks, …) */
.page-panel {
  background: var(--panel);
  border-radius: 1rem;
  border: 1px solid #e5e7eb;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  padding: 1.5rem;
}

html.dark .page-panel {
  background: var(--panel-dark);
  border-color: var(--border-dark);
}

/* Legacy MY AGENT dashboard cards: 24px radius, no hard border */
.legacy-card {
  background: var(--panel);
  border-radius: var(--card-radius-lg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  overflow: hidden;
}

html.dark .legacy-card {
  background: var(--panel-dark);
}

.soft-well {
  background: var(--soft-surface);
  border-radius: 1.5rem;
}

html.dark .soft-well {
  background: var(--input-dark);
}

.bg-soft { background: var(--soft-surface); }
html.dark .bg-soft { background: var(--input-dark); }
.bg-chart-leads { background: var(--chart-leads); }
.bg-chart-appointments { background: var(--chart-appointments); }
.bg-chart-proposals { background: var(--chart-proposals); }
.bg-chart-clients { background: var(--chart-clients); }

.icon-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: 0.75rem;
}

.icon-tile-blue { background: #dbeafe; color: #2563eb; }
.icon-tile-green { background: #dcfce7; color: #16a34a; }
.icon-tile-pink { background: #fce7f3; color: #db2777; }
.icon-tile-indigo { background: #e0e7ff; color: #4f46e5; }
.icon-tile-orange { background: #ffedd5; color: #ea580c; }

html.dark .icon-tile-blue { background: rgba(37, 99, 235, 0.2); color: #93c5fd; }
html.dark .icon-tile-green { background: rgba(22, 163, 74, 0.2); color: #86efac; }
html.dark .icon-tile-pink { background: rgba(219, 39, 119, 0.2); color: #f9a8d4; }
html.dark .icon-tile-indigo { background: rgba(79, 70, 229, 0.2); color: #a5b4fc; }
html.dark .icon-tile-orange { background: rgba(234, 88, 12, 0.2); color: #fdba74; }

/* Shell spacing — keep sidebar top flush with page frame top */
.shell-mobile-header {
  box-sizing: border-box;
  height: calc(var(--shell-mobile-header) + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
}

.sidebar-shell {
  /* Width must not depend on Alpine :class — if Alpine dies, the rail stays visible. */
  width: 18rem; /* w-72 — mobile overlay */
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (min-width: 1024px) {
  .app-shell-frame {
    gap: var(--shell-gap);
  }

  .sidebar-shell {
    width: 16rem; /* lg:w-64 */
    margin-top: var(--shell-inset);
    margin-right: var(--shell-inset);
    margin-bottom: 0;
    height: calc(100dvh - var(--shell-inset));
    /* Mobile overlay uses translate-x-full; never keep that transform on desktop. */
    transform: none;
  }

  .sidebar-shell.is-collapsed {
    width: 5rem; /* lg:w-20 */
  }

  .page-content {
    padding-top: var(--shell-inset);
    /* RTL: inline-end = outer (left); inline-start = toward sidebar (right) → gap only */
    padding-inline-end: var(--shell-inset);
    padding-inline-start: 0;
    padding-bottom: 2.5rem;
  }

  .shell-messages {
    padding-top: var(--shell-inset);
    padding-inline-end: var(--shell-inset);
    padding-inline-start: 0;
    padding-bottom: 0.5rem;
  }
}

/* Mobile / tablet: overlay sidebar; offset bleed pages by the real header height */
@media (max-width: 1023px) {
  .app-shell-frame {
    min-height: 100dvh;
    height: 100dvh;
  }

  .shell-main {
    padding-top: calc(var(--shell-mobile-header) + env(safe-area-inset-top, 0px));
  }

  .sidebar-shell {
    height: 100dvh;
  }

  .page-content {
    padding: 1.25rem 1.25rem 2.5rem;
    padding-bottom: calc(2.5rem + env(safe-area-inset-bottom, 0px));
  }

  .shell-messages {
    padding: 1.25rem 1.25rem 0.5rem;
  }
}

/* Bleed pages own the inset (cancel .page-content padding) */
.page-content.page-content--bleed {
  padding: 0 !important;
}

/* Full-bleed workspace (Chats / Contact). Mobile offsets the header; lg uses --shell-inset. */
.workspace-bleed {
  height: calc(100dvh - var(--shell-mobile-header) - env(safe-area-inset-top, 0px));
  margin: 0;
  border-radius: 0;
  border: 1px solid #e5e7eb;
  border-bottom: 0;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  overflow: hidden;
}

@media (min-width: 1024px) {
  .workspace-bleed {
    height: calc(100dvh - var(--shell-inset));
    margin-top: var(--shell-inset);
    /* RTL: end = outer left; start = toward sidebar → gap only */
    margin-inline-end: var(--shell-inset);
    margin-inline-start: 0;
    margin-bottom: 0;
    border-radius: 1rem 1rem 0 0;
  }
}

html.dark .workspace-bleed {
  background: var(--panel-dark);
  border-color: var(--border-dark);
}

/* Legacy ChatWindow.jsx — WhatsApp doodle tile at ~40% over the paper color */
.chat-wallpaper {
  background-color: var(--chat-wallpaper);
  background-image:
    linear-gradient(rgba(239, 234, 226, 0.62), rgba(239, 234, 226, 0.62)),
    url("../img/chat-wallpaper.png");
  background-size: auto, 400px;
  background-repeat: repeat;
}

html.dark .chat-wallpaper {
  background-color: var(--app-canvas-dark);
  background-image:
    linear-gradient(rgba(11, 20, 26, 0.93), rgba(11, 20, 26, 0.93)),
    url("../img/chat-wallpaper.png");
}

/* Sidebar nav active states */
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: 0.5rem;
  padding: 0.5rem;
  font-size: 0.875rem;
  color: #4b5563;
  transition: color 0.15s, background 0.15s;
}

html.dark .nav-item {
  color: #9ca3af;
}

.nav-item > [data-lucide] {
  color: #6b7280;
}

html.dark .nav-item > [data-lucide] {
  color: #9ca3af;
}

.nav-item:hover {
  background: #f3f4f6;
}

html.dark .nav-item:hover {
  background: #1e293b;
}

.nav-item.active-blue {
  background: #dbeafe !important;
  color: #1d4ed8 !important;
}
.nav-item.active-blue > [data-lucide] {
  color: #1d4ed8 !important;
}
.nav-item.active-green {
  background: #dcfce7 !important;
  color: #15803d !important;
}
.nav-item.active-green > [data-lucide] {
  color: #15803d !important;
}
.nav-item.active-pink {
  background: #fce7f3 !important;
  color: #be185d !important;
}
.nav-item.active-pink > [data-lucide] {
  color: #be185d !important;
}
.nav-item.active-indigo {
  background: #e0e7ff !important;
  color: #4338ca !important;
}
.nav-item.active-indigo > [data-lucide] {
  color: #4338ca !important;
}
.nav-item.active-orange {
  background: #ffedd5 !important;
  color: #c2410c !important;
}
.nav-item.active-orange > [data-lucide] {
  color: #c2410c !important;
}

html.dark .nav-item.active-blue {
  background: rgba(30, 58, 138, 0.35) !important;
  color: #93c5fd !important;
}
html.dark .nav-item.active-blue > [data-lucide] {
  color: #93c5fd !important;
}
html.dark .nav-item.active-green {
  background: rgba(20, 83, 45, 0.4) !important;
  color: #86efac !important;
}
html.dark .nav-item.active-green > [data-lucide] {
  color: #86efac !important;
}
html.dark .nav-item.active-pink {
  background: rgba(131, 24, 67, 0.35) !important;
  color: #f9a8d4 !important;
}
html.dark .nav-item.active-pink > [data-lucide] {
  color: #f9a8d4 !important;
}
html.dark .nav-item.active-indigo {
  background: rgba(49, 46, 129, 0.4) !important;
  color: #a5b4fc !important;
}
html.dark .nav-item.active-indigo > [data-lucide] {
  color: #a5b4fc !important;
}
html.dark .nav-item.active-orange {
  background: rgba(154, 52, 18, 0.35) !important;
  color: #fdba74 !important;
}
html.dark .nav-item.active-orange > [data-lucide] {
  color: #fdba74 !important;
}

.nav-item.coming-soon {
  opacity: 0.6;
  pointer-events: none;
  cursor: default;
}

/* Collapsed sidebar: center icon-only items */
@media (min-width: 1024px) {
  .sidebar-shell.is-collapsed .nav-item {
    width: 2.5rem;
    height: 2.5rem;
    margin-inline: auto;
    padding: 0;
    justify-content: center;
  }
  .sidebar-shell.is-collapsed .nav-item span {
    display: none;
  }
}

/* Contact / workspace tabs — horizontal snap on narrow screens */
.workspace-tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid #e5e7eb;
  padding: 0 1rem;
  background: #f9fafb;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
html.dark .workspace-tabs {
  border-color: var(--border-dark);
  background: #0f172a;
}
.workspace-tab {
  flex-shrink: 0;
  scroll-snap-align: start;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: #6b7280;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.workspace-tab.is-active {
  color: #1d4ed8;
  font-weight: 600;
  border-bottom-color: #2563eb;
}
html.dark .workspace-tab.is-active {
  color: #93c5fd;
  border-bottom-color: #3b82f6;
}

/* Lead status pipeline (legacy chevron steps) */
.pipeline-step-fill {
  clip-path: polygon(100% 0, 10px 0, 0 50%, 10px 100%, 100% 100%, calc(100% - 10px) 50%);
}
.pipeline-step-first .pipeline-step-fill {
  clip-path: polygon(100% 0, 10px 0, 0 50%, 10px 100%, 100% 100%);
}

/* Leads table row hover actions — hover-only on fine pointers; always visible on touch */
@media (hover: hover) and (pointer: fine) {
  .leads-table-row .row-actions {
    opacity: 0;
    transform: translateX(0.5rem);
    transition: opacity 0.3s ease, transform 0.3s ease;
  }
  .leads-table-row:hover .row-actions {
    opacity: 1;
    transform: translateX(0);
  }
  .leads-table-row:hover .actions-sticky {
    background: #fff;
  }
  html.dark .leads-table-row:hover .actions-sticky {
    background: #202c33;
  }
}

@media (hover: none) {
  .row-actions,
  .opacity-0.group-hover\:opacity-100 {
    opacity: 1 !important;
    transform: none !important;
  }
}

/* Legacy Leads.jsx TooltipContent — floated (portal-like) so table overflow doesn't clip */
.ui-tip-float {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  border: 0;
  border-radius: 0.375rem; /* rounded-md */
  background: #111827; /* gray-900 */
  color: #fff;
  font-size: 0.75rem; /* text-xs */
  line-height: 1rem;
  padding: 0.375rem 0.75rem; /* py-1.5 px-3 */
  white-space: nowrap;
  box-shadow: none;
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.12s ease, transform 0.12s ease;
}
.ui-tip-float.is-open {
  opacity: 1;
  transform: scale(1);
}

/* Contact detail left nav tabs */
.contact-tab-btn {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 0.75rem;
  border-radius: 0.75rem;
  padding: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #4b5563;
  transition: background 0.15s, color 0.15s;
}
html.dark .contact-tab-btn {
  color: #9ca3af;
}
.contact-tab-btn:hover {
  background: #f9fafb;
}
html.dark .contact-tab-btn:hover {
  background: #1f2c34;
}
.contact-tab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  padding: 0.5rem;
  background: #f3f4f6;
}
html.dark .contact-tab-icon {
  background: #1f2c34;
}
.contact-section-card {
  border-radius: 1rem;
  border: 1px solid #e5e7eb;
  background: #fff;
  padding: 1.5rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
html.dark .contact-section-card {
  background: #111b21;
  border-color: #2a3942;
}

/* Smooth in-app navigation (sidebar stays mounted) */
#main-content {
  position: relative;
}

#nav-progress {
  position: absolute;
  inset-inline: 0;
  top: 0;
  z-index: 30;
  height: 2px;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity 80ms ease;
}

#nav-progress.htmx-request {
  opacity: 1;
}

#nav-progress .nav-progress-bar {
  height: 100%;
  width: 40%;
  background: linear-gradient(90deg, #3b82f6, #6366f1);
  animation: nav-progress-slide 0.7s ease-in-out infinite;
}

@keyframes nav-progress-slide {
  0% { transform: translateX(150%); }
  100% { transform: translateX(-250%); }
}

/* Calendar month grid — keep usable even if Tailwind rebuild is stale */
.cal-month-frame {
  overflow-x: auto;
  overflow-y: visible;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  background: #f9fafb;
}

html.dark .cal-month-frame {
  border-color: #202c33;
  background: #0b141a;
}

.cal-month-weekdays,
.cal-month-week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  min-width: 56rem;
}

.cal-month-weekdays {
  border-bottom: 1px solid #e5e7eb;
  background: #fff;
}

html.dark .cal-month-weekdays {
  border-bottom-color: #202c33;
  background: #202c33;
}

.cal-month-week {
  border-bottom: 1px solid #e5e7eb;
}

.cal-month-week:last-child {
  border-bottom: 0;
}

html.dark .cal-month-week {
  border-bottom-color: #202c33;
}

.cal-month-day {
  min-height: 7rem;
  position: relative;
  overflow: visible;
  border-inline-start: 1px solid #e5e7eb;
  background: #fff;
}

.cal-month-day:first-child {
  border-inline-start: 0;
}

.cal-month-day.is-outside {
  background: #f3f4f6;
}

html.dark .cal-month-day {
  border-inline-start-color: #202c33;
  background: #111b21;
}

html.dark .cal-month-day.is-outside {
  background: rgba(11, 20, 26, 0.55);
}

.cal-event {
  width: 100%;
  min-width: 0;
}

.cal-appt-tooltip {
  width: 20rem;
  max-width: calc(100vw - 1.5rem);
}

@media (min-width: 640px) {
  .cal-month-day {
    min-height: 8rem;
  }
}

/* Phone: do not force a 56rem month grid that scrolls the page.
   Compact day cells; events are listed in the agenda below the grid. */
@media (max-width: 767px) {
  .cal-month-weekdays,
  .cal-month-week {
    min-width: 0;
  }

  .cal-month-frame {
    overflow-x: hidden;
  }

  .cal-month-day {
    min-height: 2.75rem;
  }
}

/* Tasks kanban — SortableJS (never override `transform` on the drag clone). */
/* Empty columns must stay tall enough to receive drops (Tailwind min-h may be stale). */
.js-kanban-column {
  min-height: min(20rem, 50dvh);
  width: 100%;
  border-radius: 0.75rem;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.js-kanban-card[data-status-url] {
  cursor: grab;
}

.js-kanban-card[data-status-url]:active,
.kanban-chosen,
.kanban-fallback {
  cursor: grabbing;
}

/* While dragging: every editable column advertises itself as a drop zone. */
body.kanban-dragging .js-kanban-column[data-can-edit="1"],
body.kanban-dragging .js-leads-column[data-can-edit="1"] {
  box-shadow: inset 0 0 0 2px rgba(16, 185, 129, 0.18);
  background: rgba(16, 185, 129, 0.03);
}

/* The column currently hosting the placeholder lights up. */
body.kanban-dragging .js-kanban-column:has(.kanban-ghost),
body.kanban-dragging .js-leads-column:has(.kanban-ghost) {
  box-shadow: inset 0 0 0 2px rgba(16, 185, 129, 0.55);
  background: rgba(16, 185, 129, 0.08);
}

/* Placeholder left in the list — dashed slot, not a faded twin of the card. */
.kanban-ghost {
  opacity: 1 !important;
  background: rgba(16, 185, 129, 0.06) !important;
  border: 2px dashed rgba(16, 185, 129, 0.5) !important;
  border-radius: 0.75rem !important;
  box-shadow: none !important;
}

.kanban-ghost > * {
  visibility: hidden;
}

.kanban-chosen {
  opacity: 1;
}

/* The clone that follows the pointer. Sortable positions it via `transform`,
   so tilt/scale use the standalone `rotate`/`scale` properties instead.
   `transition: none` is critical: the card carries Tailwind's
   `transition-all duration-200` (hover effect), which would animate every
   transform update and make the clone crawl behind the pointer. */
.kanban-fallback {
  opacity: 1 !important;
  transition: none !important;
  animation: none !important;
  rotate: 2deg;
  scale: 1.03;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.28) !important;
  cursor: grabbing !important;
  z-index: 100;
}

/* Hide the "drag here" hint whenever the column holds a real card or the placeholder. */
.js-kanban-column:has(.js-kanban-card) + .kanban-empty-hint {
  display: none;
}

/* Confirmation pulse after a successful save. */
.kanban-saved {
  animation: kanban-saved-pulse 0.9s ease-out;
}

@keyframes kanban-saved-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5);
  }
  100% {
    box-shadow: 0 0 0 12px rgba(16, 185, 129, 0);
  }
}

html.dark .kanban-ghost {
  background: rgba(74, 222, 128, 0.1) !important;
  border-color: rgba(74, 222, 128, 0.45) !important;
}

html.dark body.kanban-dragging .js-kanban-column[data-can-edit="1"],
body.kanban-dragging .js-leads-column[data-can-edit="1"] {
  background: rgba(74, 222, 128, 0.04);
}

html.dark body.kanban-dragging .js-kanban-column:has(.kanban-ghost),
body.kanban-dragging .js-leads-column:has(.kanban-ghost) {
  background: rgba(74, 222, 128, 0.1);
}

/* ── Shared responsive patterns (screen agents: use these, don't invent new ones) ── */

/* Public / auth: fill the dynamic viewport and clear the iOS home indicator. */
.safe-min-dvh {
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Bottom tab bars (contact mobile tabs, etc.) */
.tab-bar {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Toolbar: stack on phone; row from sm. Mark primary CTA with .toolbar-cta. */
.page-toolbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
}

.page-toolbar .toolbar-cta {
  width: 100%;
  min-height: 2.75rem; /* ~44px touch target */
}

@media (min-width: 640px) {
  .page-toolbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
  }

  .page-toolbar .toolbar-cta {
    width: auto;
  }
}

/* Board (kanban / pipeline): snap-scroll inside the component, never min-width the page. */
.board-scroll {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding-bottom: max(0.5rem, env(safe-area-inset-bottom, 0px));
}

.board-scroll > * {
  flex: 0 0 min(20rem, 85vw);
  min-width: 0;
  min-height: 12rem;
  scroll-snap-align: start;
}

/* Pipeline chevrons: same snap-scroll, auto-sized steps (not 20rem columns). */
.board-scroll.pipeline-scroll {
  gap: 0.125rem;
  align-items: stretch;
  padding-bottom: 0;
}
.board-scroll.pipeline-scroll > * {
  flex: 1 0 6.5rem;
  min-width: 6.5rem;
  min-height: 2rem;
}

/* Inbox: below lg show list OR thread — never both stacked. */
@media (max-width: 1023px) {
  .inbox-split[data-thread-open="true"] > .inbox-list {
    display: none;
  }
  .inbox-split[data-thread-open="false"] > .inbox-thread {
    display: none;
  }
}

/* Modals / dialogs: stay on-screen; do not use a raw sm:w-[500px] that overflows. */
.modal-panel {
  max-height: 90dvh;
  overflow-y: auto;
  width: min(calc(100vw - 2rem), 32rem);
  -webkit-overflow-scrolling: touch;
}

/* Touch targets helper — later screens can opt in. */
.touch-target {
  min-width: 2.75rem;
  min-height: 2.75rem;
}

/* WhatsApp connection: loading overlay + barcode wait */
.connection-panel {
  min-height: 9rem;
}
.connection-busy {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: color-mix(in srgb, #f0fdf4 88%, transparent);
  color: #166534;
  font-size: 0.875rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  backdrop-filter: blur(2px);
}
.connection-busy-sub {
  font-size: 0.75rem;
  font-weight: 500;
  color: #15803d;
  opacity: 0.85;
}
.dark .connection-busy {
  background: color-mix(in srgb, #052e16 88%, transparent);
  color: #bbf7d0;
}
.dark .connection-busy-sub {
  color: #86efac;
}
.htmx-request.connection-busy,
.connection-busy.htmx-request {
  opacity: 1;
  pointer-events: auto;
}
.connection-spinner {
  display: block;
  width: 1.75rem;
  height: 1.75rem;
  border: 3px solid #bbf7d0;
  border-top-color: #00a884;
  border-radius: 9999px;
  animation: connection-spin 0.7s linear infinite;
}
.connection-spinner-sm {
  width: 0.9rem;
  height: 0.9rem;
  border-width: 2px;
}
.connection-btn-spinner {
  display: none;
  width: 0.9rem;
  height: 0.9rem;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 9999px;
  animation: connection-spin 0.7s linear infinite;
}
form.htmx-request .connection-btn-spinner,
.htmx-request > .connection-btn-spinner {
  display: inline-block;
}
.connection-qr-img {
  image-rendering: pixelated;
}
.connection-qr-wait {
  animation: connection-pulse 1.4s ease-in-out infinite;
}
.connection-qr-skeleton {
  position: relative;
  width: 14rem;
  height: 14rem;
  max-width: 100%;
  overflow: hidden;
  border-radius: 0.75rem;
  background:
    linear-gradient(90deg, #dcfce7 0%, #f0fdf4 45%, #dcfce7 100%);
  background-size: 200% 100%;
  animation: connection-shimmer 1.4s linear infinite;
  border: 1px solid #bbf7d0;
}
.connection-qr-scan {
  position: absolute;
  inset-inline: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, #00a884, transparent);
  animation: connection-scan 1.6s ease-in-out infinite;
}
.connection-toast {
  animation: connection-fade 220ms ease;
}
.connection-status-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 9999px;
  background: #16a34a;
  box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.55);
  animation: connection-ping 1.6s ease-out infinite;
}
.connection-poll-hint {
  transition: opacity 160ms ease;
}
/* Keep the test-phone field in the DOM while pairing; only show it once status is connected.
   Status polls must not replace this form, or typing is wiped. */
#connection-status:not(:has(.connection-status-pill-ok)) ~ #connection-actions .connection-test-form {
  display: none;
}
#connection-status:has(.connection-status-pill-ok) ~ #connection-actions .connection-new-qr-form {
  display: none;
}
@keyframes connection-spin {
  to { transform: rotate(360deg); }
}
@keyframes connection-fade {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes connection-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}
@keyframes connection-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
@keyframes connection-scan {
  0% { top: 8%; opacity: 0.2; }
  50% { opacity: 1; }
  100% { top: 88%; opacity: 0.2; }
}
@keyframes connection-ping {
  0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(22, 163, 74, 0); }
  100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}

/* CRM list — column chooser (data-col cells hidden via wrapper class) */
.cols-hide-score [data-col="score"],
.cols-hide-status [data-col="status"],
.cols-hide-source [data-col="source"],
.cols-hide-tags [data-col="tags"],
.cols-hide-assignee [data-col="assignee"],
.cols-hide-created [data-col="created"] {
  display: none;
}

.form-confetti {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 80;
  overflow: hidden;
}

.form-confetti span {
  position: absolute;
  top: -12px;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  animation-name: form-confetti-fall;
  animation-timing-function: ease-in;
  animation-fill-mode: forwards;
}

@keyframes form-confetti-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110dvh) rotate(240deg); opacity: 0.2; }
}

