/* =====================================================================
   CRM — busca, filtros, lista de leads, etiquetas, aniversário, histórico
   (dashboard/crm.js). Pedidos do cliente Max, 02/out/2026.

   CELULAR PRIMEIRO: as regras de base são o desenho de 360–390px (uma coluna,
   alvos de toque de 44px, campos com 16px pra o iOS não dar zoom, folhas de
   tela cheia). O que muda em telas maiores entra só em `min-width`:
     ≥ 560px  rótulo e valor lado a lado nos Detalhes
     ≥ 768px  folhas viram janela centrada; lista em duas colunas de cartões
     ≥ 900px  funil com as colunas lado a lado (sem abas de etapa)
     ≥ 1200px lista vira tabela
   Usa os tokens do painel (styles.css :root). Nada depende de hover.
   ===================================================================== */

/* ---------------------------------------------------------------- base */
#crm-tab {
  --crm-touch: 44px;
  --crm-sheet-bg: #0d1628;
}
#crm-tab .page-header {
  margin-bottom: 14px;
  gap: 10px;
}
/* PRIMEIRA DOBRA NO CELULAR: busca + filtros numa linha, Funil|Lista + "⋯
   Mais" na outra, abas de etapa logo abaixo — o primeiro lead aparece na
   metade de cima da tela. As ações do topo (Novo lead, Modo, Campos e
   estágios, Atualizar) continuam no HTML e são acionadas pela folha "Mais";
   o título some porque a barra do celular já diz "CRM". Do tablet pra cima
   (min-width: 768px, lá embaixo) tudo volta ao lugar de sempre. */
#crm-tab .page-header {
  margin-bottom: 6px;
}
#crm-tab .page-header h1 {
  display: none;
}
#crm-tab .page-header-actions {
  display: none;
}
#crm-tab .subtabs {
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
#crm-tab .subtabs .subtab {
  flex: 0 0 auto;
  white-space: nowrap;
}
.crm-wide-only {
  display: none !important;
}
#crm-tab .page-header-actions > button {
  min-width: 0;
  padding: 6px 8px;
  font-size: 11px;
  letter-spacing: 0.06em;
  line-height: 1.25;
  white-space: normal;
}
#crm-tab .page-header-actions > button,
#crm-tab .subtabs .subtab {
  min-height: var(--crm-touch);
}
/* A explicação do modo é texto de apoio: some no celular (o botão "Modo"
   continua dizendo qual é) e volta do tablet pra cima. */
#crm-tab #crm-mode-desc {
  display: none;
  margin-bottom: 12px;
}
/* A regra global de campos do painel (input:not(…) com oito negações) pesa
   mais que qualquer classe e fixava 14px — por isso o !important aqui. */
.crm-input {
  font-size: 16px !important;
}

.crm-input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  font: inherit;
  font-size: 16px; /* abaixo disso o iOS dá zoom na página ao focar */
  color: var(--fg);
  background: rgba(8, 14, 28, 0.7);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-sizing: border-box;
}
.crm-input:focus-visible,
.crm-sheet button:focus-visible,
.crm-toolbar button:focus-visible,
.crm-chip:focus-visible,
.crm-stage-tab:focus-visible,
.crm-list button:focus-visible,
.crm-collapse > summary:focus-visible,
.crm-dbtn:focus-visible,
.crm-card-move:focus-visible {
  outline: 2px solid var(--andy-cyan);
  outline-offset: 2px;
}
.crm-hint {
  margin: 4px 0;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--fg-dim);
}
.crm-error {
  margin: 6px 0 0;
  font-size: 0.85rem;
  color: var(--danger);
  min-height: 1.2em;
}
.crm-dim {
  color: var(--fg-dim);
}
.crm-count {
  flex: 0 0 auto;
  margin-left: auto;
  padding: 1px 8px;
  font-size: 0.72rem;
  color: var(--fg-mid);
  background: rgba(255, 255, 255, 0.07);
  border-radius: 999px;
}
.crm-dot {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* ------------------------------------------------------- barra de busca */
.crm-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  margin-bottom: 6px;
}
.crm-toolbar-row {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
/* No celular o botão de filtros é o ícone + a contagem; o nome está no
   aria-label. */
.crm-filter-btn .crm-tool-label {
  display: none;
}
.crm-status {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 0 8px;
  padding: 8px 10px;
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--fg);
  background: rgba(92, 200, 255, 0.1);
  border: 1px solid rgba(92, 200, 255, 0.35);
  border-radius: var(--radius-sm);
}
.crm-status[hidden] {
  display: none;
}
.crm-status > span {
  flex: 1 1 auto;
  min-width: 0;
}
.crm-status-close {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  margin: -8px -8px -8px 0;
  font-size: 1.2rem;
  color: var(--fg-mid);
  background: transparent;
  border: 0;
  cursor: pointer;
}
.crm-warn {
  margin: 6px 0;
  padding: 8px 10px;
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--fg);
  background: rgba(255, 212, 92, 0.1);
  border: 1px solid rgba(255, 212, 92, 0.4);
  border-radius: var(--radius-sm);
}
.crm-tool-btn {
  min-height: 44px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.crm-filter-count {
  min-width: 20px;
  padding: 1px 6px;
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
  color: #06121f;
  background: var(--andy-cyan);
  border-radius: 999px;
}
.crm-filter-count[hidden] {
  display: none;
}
.crm-view-toggle {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  overflow: hidden;
}
.crm-view-btn {
  min-height: 44px;
  padding: 0 14px;
  font: inherit;
  font-size: 0.85rem;
  color: var(--fg-mid);
  background: transparent;
  border: 0;
  cursor: pointer;
  white-space: nowrap;
}
.crm-view-btn.active {
  color: #06121f;
  font-weight: 600;
  background: var(--andy-cyan);
}

/* --------------------------------------------- filtros ligados (chips) */
.crm-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.crm-chips[hidden] {
  display: none;
}
.crm-chip {
  min-height: 44px;
  max-width: 100%;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-size: 0.8rem;
  color: var(--fg);
  background: rgba(92, 200, 255, 0.1);
  border: 1px solid rgba(92, 200, 255, 0.35);
  border-radius: 999px;
  cursor: pointer;
  overflow-wrap: anywhere;
  text-align: left;
}
.crm-chip span {
  font-size: 1.1rem;
  line-height: 1;
  color: var(--fg-mid);
}
.crm-chip-clear {
  color: var(--fg-mid);
  background: transparent;
  border-style: dashed;
  border-color: var(--border-strong);
}

/* -------------------------------------------------------------- etiquetas */
.crm-tag {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 2px 9px;
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--fg-mid);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crm-tag.more {
  color: var(--fg-dim);
  border-style: dashed;
}
.crm-bday {
  display: inline-flex;
  padding: 2px 8px;
  font-size: 0.72rem;
  color: #ffd45c;
  background: rgba(255, 212, 92, 0.1);
  border: 1px solid rgba(255, 212, 92, 0.3);
  border-radius: 999px;
  white-space: nowrap;
}
.crm-bday.today {
  color: #06121f;
  font-weight: 700;
  background: #ffd45c;
}
.crm-stagechip {
  display: inline-flex;
  max-width: 100%;
  padding: 2px 9px;
  font-size: 0.74rem;
  color: var(--fg-mid);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ------------------------------------------- funil: uma etapa por tela */
.crm-stage-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 4px;
  padding-bottom: 2px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.crm-stage-tabs::-webkit-scrollbar {
  display: none;
}
.crm-stage-tabs[hidden],
.crm-stage-tabs:empty {
  display: none;
}
.crm-stage-tab {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-size: 0.85rem;
  color: var(--fg-mid);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.crm-stage-tab.active {
  color: var(--fg);
  font-weight: 600;
  border-color: var(--andy-cyan);
  background: rgba(92, 200, 255, 0.12);
}
#crm-tab .crm-board {
  gap: 12px;
  padding: 2px 0 16px;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}
#crm-tab .crm-board[hidden],
#crm-tab .crm-col[hidden] {
  display: none;
}
#crm-tab .crm-col {
  flex: 0 0 100%;
  min-width: 0;
  max-height: max(360px, calc(100dvh - 150px));
  scroll-snap-align: start;
}
#crm-tab .crm-col-body {
  overscroll-behavior-y: contain;
}
#crm-tab .crm-card {
  font-size: 0.9rem;
  /* O realce de toque do card inteiro piscava por cima da folha "Mover". */
  -webkit-tap-highlight-color: transparent;
}
.crm-card-move:active,
.crm-pick:active,
.crm-stage-tab:active {
  background: rgba(92, 200, 255, 0.16);
}
.crm-card-extras {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.crm-card-extras:empty {
  display: none;
}
.crm-card-move {
  width: 100%;
  min-height: 44px;
  margin-top: 8px;
  font: inherit;
  font-size: 0.85rem;
  color: var(--fg);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
#crm-tab .crm-card-info {
  min-width: 44px;
  min-height: 44px;
}

/* ----------------------------------------------------------- estado vazio */
.crm-empty {
  width: 100%;
  padding: 36px 16px;
  text-align: center;
  color: var(--fg-mid);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  box-sizing: border-box;
}
.crm-empty-icon {
  font-size: 2rem;
  margin-bottom: 6px;
}
.crm-empty p {
  margin: 4px 0;
}
.crm-empty .crm-foot-btn {
  margin-top: 12px;
}

/* ------------------------------------------------------- lista (cartões) */
.crm-list[hidden] {
  display: none;
}
.crm-listbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
/* Celular: UMA linha (ordenar + direção). A contagem de leads vai pra linha
   do "Selecionar todos" e o exportar pro "⋯ Mais" — duas linhas aqui
   empurravam o primeiro lead pra baixo da dobra. */
.crm-listcount {
  display: none;
  font-size: 0.85rem;
  color: var(--fg-mid);
}
.crm-lhead-count {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--fg-dim);
}
.crm-sortsel {
  flex: 1 1 60%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--fg-dim);
}
/* O rótulo "Ordenar por" continua pro leitor de tela; na tela do celular o
   próprio campo já diz o que é. */
.crm-sortsel-text {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
#crm-sortdir {
  order: 4;
  align-self: flex-end;
  min-width: 48px;
  justify-content: center;
}
.crm-sortdir-text {
  display: none;
}
.crm-ltable {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}
.crm-lrow {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  grid-template-areas:
    'check name name'
    'check phone phone'
    'stage stage stage'
    'tags tags tags'
    'bday bday assigned'
    'origin origin last';
  align-items: center;
  gap: 6px 8px;
  padding: 10px 12px 10px 4px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 0.85rem;
  min-width: 0;
}
.crm-lrow.selected {
  border-color: var(--andy-cyan);
  background: rgba(92, 200, 255, 0.08);
}
.crm-lcell {
  min-width: 0;
  overflow-wrap: anywhere;
}
.c-check {
  grid-area: check;
  align-self: start;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.c-check input,
.crm-check input[type='checkbox'],
.crm-check input[type='radio'] {
  width: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--andy-cyan);
  flex: 0 0 auto;
}
.c-name {
  grid-area: name;
}
.c-phone {
  grid-area: phone;
  color: var(--fg-mid);
  white-space: nowrap;
}
.c-stage {
  grid-area: stage;
  padding-left: 8px;
}
.c-tags:has(.crm-dim) {
  display: none; /* sem etiqueta, a linha some no cartão */
}
.c-tags {
  grid-area: tags;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding-left: 8px;
}
.c-bday {
  grid-area: bday;
  padding-left: 8px;
}
.c-assigned {
  grid-area: assigned;
  justify-self: end;
  text-align: right;
  color: var(--fg-mid);
}
.c-origin {
  grid-area: origin;
  padding-left: 8px;
  font-size: 0.78rem;
  color: var(--fg-dim);
}
.c-last {
  grid-area: last;
  justify-self: end;
  font-size: 0.78rem;
  color: var(--fg-dim);
}
.c-origin::before,
.c-last::before {
  content: attr(data-label) ': ';
}
.c-created {
  display: none;
}
.crm-lname {
  width: 100%;
  min-height: 44px;
  padding: 0;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  text-align: left;
  color: var(--fg);
  background: none;
  border: 0;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.crm-bday-edit {
  min-height: 44px;
  padding: 0 10px;
  font: inherit;
  font-size: 0.85rem;
  color: var(--fg);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
}
/* Cabeçalho no celular: só o "selecionar todos" (ordenar fica no seletor). */
.crm-lhead {
  grid-template-columns: 44px minmax(0, 1fr);
  grid-template-areas: 'check check';
  padding: 0 12px 0 4px;
  background: transparent;
  border-style: dashed;
}
.crm-lhead .crm-lcell:not(.c-check) {
  display: none;
}
.crm-lhead .c-check {
  justify-content: flex-start;
  gap: 10px;
  padding-left: 11px;
  font-size: 0.85rem;
  color: var(--fg-mid);
}
.crm-sortbtn {
  padding: 0;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  font-weight: 600;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  white-space: nowrap;
}
.crm-more {
  width: 100%;
  min-height: 44px;
  margin-top: 10px;
}

/* --------------------------------------------- barra de ação em massa */
/* Presa ao rodapé da TELA (fixed: `sticky` não segura dentro da área de
   conteúdo do painel). À esquerda sobra o trilho do menu (64px no celular). */
.crm-bulkbar {
  position: fixed;
  left: 72px;
  right: 8px;
  bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  z-index: 150;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 12px;
  background: #101b33;
  border: 1px solid var(--andy-cyan);
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}
.crm-bulkbar[hidden] {
  display: none;
}
/* Com a barra na tela, a lista ganha folga embaixo: o último lead nunca
   fica escondido atrás dela. */
#crm-tab.crm-has-bulk {
  padding-bottom: 140px;
}
/* Celular: 1ª linha = contagem + limpar; 2ª = as três ações, ícone em cima
   do rótulo (o botão padrão do painel, em caixa alta espaçada, não cabia). */
.crm-bulk-count {
  grid-column: 1 / 3;
  font-size: 0.85rem;
  font-weight: 600;
}
.crm-bulk-btn {
  min-width: 0;
  min-height: 52px;
  padding: 4px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font: inherit;
  font-size: 0.74rem;
  line-height: 1.1;
  color: var(--fg);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  overflow-wrap: anywhere;
}
.crm-bulk-clear {
  justify-self: end;
  width: 44px;
  height: 44px;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--fg-mid);
  background: none;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

/* -------------------------------------------- folha (tela cheia no celular) */
html.crm-sheet-open,
html.crm-sheet-open body {
  overflow: hidden;
}
.crm-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(5, 8, 16, 0.78);
}
.crm-sheet {
  width: 100%;
  height: 100%;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  color: var(--fg);
  background: var(--crm-sheet-bg, #0d1628);
  outline: none;
}
.crm-sheet-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 16px;
  border-bottom: 1px solid var(--border);
}
.crm-sheet-head h3 {
  flex: 1;
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.crm-sheet-close {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--fg-mid);
  background: none;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}
.crm-sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 14px 16px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.crm-sheet-foot {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--crm-sheet-bg, #0d1628);
  border-top: 1px solid var(--border);
}
.crm-foot-btn {
  min-height: 44px;
  padding: 0 16px;
}
.crm-foot-btn.grow {
  flex: 1;
}
.crm-foot-btn.danger {
  color: #1a0606;
  background: var(--danger);
  border-color: var(--danger);
}

.crm-fgroup {
  margin: 0 0 18px;
  padding: 0;
  border: 0;
  min-width: 0;
}
.crm-fgroup legend,
.crm-subtitle,
.crm-label {
  display: block;
  margin: 0 0 6px;
  padding: 0;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-mid);
}
.crm-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.crm-label .crm-hint {
  display: inline;
  margin: 0;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}
.crm-subtitle {
  margin-top: 20px;
}
.crm-checks,
.crm-taglist,
.crm-picklist {
  margin: 0;
  padding: 0;
  list-style: none;
}
.crm-check {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 2px 0;
  cursor: pointer;
  min-width: 0;
}
.crm-check-label {
  min-width: 0;
  overflow-wrap: anywhere;
}
.crm-tagrow {
  border-bottom: 1px solid var(--border);
  min-width: 0;
}
/* Sub-etiqueta: recuada, com um traço ligando à principal de cima. */
.crm-tagrow.sub {
  margin-left: 14px;
  padding-left: 14px;
  border-left: 2px solid var(--border-strong);
}
.crm-seg {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.crm-seg-opt {
  position: relative;
  flex: 1 1 auto;
  cursor: pointer;
}
.crm-seg-opt input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.crm-seg-opt span {
  min-height: 44px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.88rem;
  color: var(--fg-mid);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.crm-seg-opt input:checked + span {
  color: #06121f;
  font-weight: 600;
  background: var(--andy-cyan);
  border-color: var(--andy-cyan);
}
.crm-seg-opt input:focus-visible + span {
  outline: 2px solid var(--andy-cyan);
  outline-offset: 2px;
}
.crm-pick {
  width: 100%;
  min-height: 48px;
  padding: 6px 4px;
  display: flex;
  align-items: center;
  gap: 10px;
  font: inherit;
  font-size: 0.95rem;
  text-align: left;
  color: var(--fg);
  background: none;
  border: 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  overflow-wrap: anywhere;
}
.crm-taglist .crm-pick {
  border-bottom: 0;
}
.crm-pick.current {
  color: var(--andy-cyan);
  font-weight: 600;
}
.crm-create {
  margin-bottom: 6px;
  color: var(--andy-cyan);
  border: 1px dashed rgba(92, 200, 255, 0.5);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
}
.crm-notice {
  margin-top: 6px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.crm-notice-hour {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--fg-mid);
}
.crm-notice-hour .crm-input {
  width: auto;
  min-width: 96px;
}

/* gerenciar etiquetas */
.crm-tagform {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.crm-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.crm-swatch {
  position: relative;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.crm-swatch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.crm-swatch span {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
}
.crm-swatch input:checked + span {
  border-color: #fff;
  box-shadow: 0 0 0 2px var(--andy-cyan);
}
.crm-swatch input:focus-visible + span {
  outline: 2px solid var(--andy-cyan);
  outline-offset: 3px;
}
.crm-tagrow-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  min-width: 0;
}
/* Nome nunca cortado: se a etiqueta + os quatro botões não cabem na linha,
   os botões descem pra linha de baixo. */
.crm-tagrow-open {
  flex: 1 1 auto;
  min-width: min(100%, 150px);
  min-height: 44px;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  color: var(--fg);
  background: none;
  border: 0;
  cursor: pointer;
  text-align: left;
}
.crm-tagrow-actions {
  display: flex;
  margin-left: auto;
}
.crm-iconbtn {
  width: 44px;
  height: 44px;
  font-size: 1rem;
  color: var(--fg-mid);
  background: none;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.crm-iconbtn.danger {
  color: var(--danger);
}
.crm-tagrow-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 0 14px;
}
.crm-tagrow-panel[hidden] {
  display: none;
}
.crm-tagrow-panel p {
  margin: 0;
}
.crm-rowbtns {
  display: flex;
  gap: 8px;
}

/* aniversário */
.crm-bdayform {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ------------------------------------- detalhes e histórico do lead */
.crm-collapse {
  margin: 0 0 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  min-width: 0;
}
.crm-collapse > summary {
  min-height: 44px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.crm-collapse > summary::-webkit-details-marker {
  display: none;
}
.crm-collapse > summary::after {
  content: '▾';
  margin-left: auto;
  color: var(--fg-dim);
  transition: transform 0.15s;
}
.crm-collapse[open] > summary::after {
  transform: rotate(180deg);
}
.crm-collapse > summary .crm-hint {
  font-weight: 400;
}
.crm-dgrid,
.crm-hist-body {
  padding: 0 12px 10px;
}
.crm-drow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    'label action'
    'value action';
  align-items: center;
  gap: 2px 8px;
  padding: 6px 0;
  border-top: 1px solid var(--border);
  min-width: 0;
}
.crm-dlabel {
  grid-area: label;
  font-size: 0.72rem;
  color: var(--fg-dim);
}
.crm-dvalue {
  grid-area: value;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}
.crm-dbtn {
  grid-area: action;
  min-width: 44px;
  min-height: 44px;
  padding: 0 12px;
  font: inherit;
  font-size: 0.8rem;
  color: var(--andy-cyan);
  background: rgba(92, 200, 255, 0.08);
  border: 1px solid rgba(92, 200, 255, 0.3);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.crm-hist-filter {
  display: flex;
  gap: 6px;
  margin: 0 -12px 8px;
  padding: 0 12px 4px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.crm-hist-filter::-webkit-scrollbar {
  display: none;
}
.crm-hist-chip {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 12px;
  font: inherit;
  font-size: 0.8rem;
  color: var(--fg-mid);
  background: none;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  cursor: pointer;
}
.crm-hist-chip.active {
  color: #06121f;
  font-weight: 600;
  background: var(--andy-cyan);
  border-color: var(--andy-cyan);
}
.crm-hist-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.crm-hist-day {
  margin: 10px 0 4px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg-dim);
}
.crm-hist-item {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  min-width: 0;
}
.crm-hist-icon {
  flex: 0 0 24px;
  text-align: center;
}
.crm-hist-text {
  flex: 1;
  min-width: 0;
}
.crm-hist-summary {
  font-size: 0.88rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.crm-hist-meta {
  margin-top: 2px;
  font-size: 0.74rem;
  color: var(--fg-dim);
  overflow-wrap: anywhere;
}
.crm-hist-imported {
  padding: 0 6px;
  border: 1px dashed var(--border-strong);
  border-radius: 999px;
}
.lead-section.crm-in-panel .crm-collapse {
  margin-bottom: 0;
}
/* Gaveta do lead no celular: o botão de etiqueta vira alvo de toque inteiro,
   e o chip de um fato quebra de linha em vez de empurrar o ✎/✕ pra fora da
   gaveta (com "remarcado N×" o chip passava dos 330px e os botões sumiam). */
#lead-content .lead-tag-add {
  min-height: 44px;
  padding: 0 14px;
  font-size: 0.85rem;
}
#lead-content .lead-fact {
  flex-wrap: wrap;
  min-width: 0;
}
#lead-content .lead-fact-actions {
  opacity: 1;
}
#lead-info-modal #li-close,
#lead-info-modal #li-open-chat,
#lead-info-modal .li-footer button {
  min-width: 44px;
  min-height: 44px;
}
/* Popup do lead no celular: ocupa a tela, o rodapé respeita a área segura. */
#lead-info-modal .li-content {
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  border-radius: 0;
}
#lead-info-modal .li-body {
  padding: 14px 14px calc(14px + env(safe-area-inset-bottom, 0px));
  overscroll-behavior: contain;
}

/* =============================== telas maiores (só acréscimo) =========== */
@media (min-width: 560px) {
  .crm-drow {
    grid-template-columns: 120px minmax(0, 1fr) auto;
    grid-template-areas: 'label value action';
  }
  .crm-dlabel {
    font-size: 0.8rem;
  }
  .crm-bdayform {
    display: grid;
    grid-template-columns: 90px 1fr 110px;
    align-items: end;
  }
  .crm-bdayform .crm-hint,
  .crm-bdayform .crm-error {
    grid-column: 1 / -1;
  }
}

@media (min-width: 768px) {
  #crm-tab .page-header {
    margin-bottom: 14px;
  }
  #crm-tab .page-header h1 {
    display: block;
  }
  #crm-tab .page-header-actions {
    width: auto;
    display: flex;
  }
  #crm-tab .subtabs {
    flex-wrap: wrap;
    overflow-x: visible;
  }
  .crm-wide-only {
    display: inline-flex !important;
  }
  .crm-narrow-only {
    display: none !important;
  }
  .crm-filter-btn .crm-tool-label {
    display: inline;
  }
  #crm-tab .page-header-actions > button {
    padding: 0 14px;
    white-space: nowrap;
  }
  #crm-tab #crm-mode-desc {
    display: block;
  }
  .crm-toolbar {
    display: flex;
    flex-direction: row;
    align-items: center;
  }
  .crm-search {
    flex: 1 1 260px;
    max-width: 420px;
  }
  .crm-toolbar-row {
    flex-wrap: nowrap;
    justify-content: flex-start;
  }
  .crm-sheet-backdrop {
    align-items: center;
    padding: 24px;
    backdrop-filter: blur(6px);
  }
  .crm-sheet {
    width: min(520px, 100%);
    height: auto;
    max-height: min(86vh, 760px);
    border: 1px solid var(--border-strong);
    border-radius: 16px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
    overflow: hidden;
  }
  .crm-sheet.wide {
    width: min(640px, 100%);
  }
  #lead-info-modal .li-content {
    width: min(92vw, 600px);
    max-width: 600px;
    height: auto;
    max-height: 86vh;
    border-radius: 16px;
  }
  #lead-info-modal .li-body {
    padding: 18px 22px;
  }
  .crm-ltable {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .crm-lhead {
    grid-column: 1 / -1;
  }
  .crm-listcount {
    display: inline;
    order: 0;
    flex: 0 0 auto;
    margin-right: auto;
  }
  .crm-sortsel-text {
    position: static;
    width: auto;
    height: auto;
    clip-path: none;
  }
  .crm-sortsel {
    order: 0;
    flex: 0 0 auto;
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }
  #crm-sortdir,
  #crm-export {
    order: 0;
    align-self: auto;
  }
  .crm-sortdir-text {
    display: inline;
  }
  .crm-sortsel .crm-input {
    width: auto;
  }
  .crm-bulkbar {
    display: flex;
    flex-wrap: nowrap;
    left: 50%;
    right: auto;
    bottom: 16px;
    transform: translateX(-50%);
    width: max-content;
    max-width: calc(100vw - 32px);
    padding: 8px 8px 8px 16px;
  }
  #crm-tab.crm-has-bulk {
    padding-bottom: 88px;
  }
  .crm-bulk-count {
    flex: 0 0 auto;
    margin-right: 8px;
  }
  .crm-bulk-btn {
    flex: 0 0 auto;
    flex-direction: row;
    gap: 6px;
    min-height: 44px;
    padding: 0 14px;
    font-size: 0.85rem;
  }
  .crm-bulk-clear {
    order: 1;
  }
}

@media (min-width: 900px) {
  /* Funil com as colunas lado a lado, como sempre foi no computador. */
  .crm-stage-tabs {
    display: none;
  }
  #crm-tab .crm-board {
    gap: 14px;
    scroll-snap-type: none;
  }
  #crm-tab .crm-col {
    flex: 0 0 270px;
    max-height: calc(100vh - 300px);
    scroll-snap-align: none;
  }
  #crm-tab .crm-card {
    font-size: 0.82rem;
  }
}

/* Ponteiro fino (mouse): os alvos podem encolher sem prejudicar ninguém. */
@media (min-width: 900px) and (hover: hover) and (pointer: fine) {
  .crm-card-move {
    width: auto;
    min-height: 30px;
    padding: 0 10px;
    font-size: 0.76rem;
  }
  #crm-tab .crm-card-info {
    min-width: 0;
    min-height: 0;
  }
  .crm-chip {
    min-height: 32px;
  }
  .crm-tool-btn,
  .crm-view-btn,
  #crm-tab .page-header-actions > button,
  #crm-tab .subtabs .subtab {
    min-height: 36px;
  }
  #crm-tab #crm-search.crm-input,
  #crm-tab .crm-listbar .crm-input {
    min-height: 36px;
    padding: 6px 10px;
    font-size: 14px !important;
  }
}

@media (min-width: 1200px) {
  /* Lista vira tabela: uma linha por lead, colunas alinhadas. */
  .crm-ltable {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow-x: auto;
  }
  .crm-lrow,
  .crm-lhead {
    grid-column: auto;
    grid-template-columns:
      44px minmax(150px, 1.5fr) 130px 124px minmax(130px, 1.3fr)
      110px 178px 124px 84px 96px;
    grid-template-areas: none;
    gap: 0 10px;
    min-width: 1110px;
    padding: 4px 12px 4px 4px;
    border: 0;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    background: transparent;
    font-size: 0.82rem;
  }
  .crm-lrow:last-child {
    border-bottom: 0;
  }
  .crm-lrow .crm-lcell,
  .crm-lhead .crm-lcell:not(.c-check) {
    grid-area: auto;
    display: block;
    justify-self: stretch;
    padding-left: 0;
    text-align: left;
    font-size: inherit;
  }
  .crm-lrow .c-check,
  .crm-lhead .c-check {
    display: flex;
    justify-content: center;
    padding-left: 0;
  }
  .crm-lrow .c-tags,
  .crm-lrow .c-tags:has(.crm-dim) {
    display: flex;
  }
  .crm-lhead {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #0f1a30;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--fg-mid);
  }
  .crm-selall-label {
    display: none;
  }
  .c-origin::before,
  .c-last::before {
    content: none;
  }
  .c-origin,
  .c-last,
  .c-created {
    color: var(--fg-mid);
  }
  .crm-lname {
    min-height: 36px;
    font-size: 0.88rem;
  }
  .crm-bday-edit {
    min-height: 32px;
    padding: 0 8px;
    font-size: 0.8rem;
  }
  .crm-lrow:not(.crm-lhead):hover {
    background: rgba(255, 255, 255, 0.03);
  }
}

/* =====================================================================
   Filtros e Etiquetas — redesenho de 19/out/2026 (pedido do cliente Max:
   "não podemos fazer melhor?"). Pílulas no lugar de checkbox nativo, folha de
   baixo no celular, menu ⋯ por etiqueta e pop-up de edição.
   ===================================================================== */

/* ---- folha de baixo (celular) e pop-up pequeno (desktop) ---- */
.crm-sheet.bottom {
  height: auto;
  max-height: calc(100dvh - 24px);
  padding-top: 4px;
  border-top: 1px solid var(--border-strong);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -18px 50px rgba(0, 0, 0, 0.45);
}
.crm-sheet.bottom::before {
  content: '';
  display: block;
  flex: 0 0 auto;
  width: 40px;
  height: 4px;
  margin: 4px auto 2px;
  border-radius: 2px;
  background: var(--border-strong);
}
.crm-sheet.bottom .crm-sheet-body {
  min-height: 160px;
}
.crm-sheet.bottom .crm-sheet-head {
  padding-top: 2px;
}

/* ---- seções do filtro ---- */
.crm-filters {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.crm-fsec {
  min-width: 0;
}
.crm-fsec-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  margin: 0 0 8px;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-mid);
}
.crm-fsec-hint {
  font-size: 0.74rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--fg-dim);
}
.crm-fsec-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}
.crm-fsec-select {
  margin-bottom: 8px;
}

/* ---- pílulas selecionáveis ---- */
.crm-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.crm-pill {
  --pill: var(--andy-cyan);
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: var(--crm-touch);
  max-width: 100%;
  padding: 0 12px 0 10px;
  color: var(--fg-mid);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: 0.88rem;
  line-height: 1.2;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
}
.crm-pill input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.crm-pill-check {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  font-size: 10px;
  line-height: 1;
  color: transparent;
  border: 1.5px solid var(--border-strong);
  border-radius: 50%;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
}
.crm-pill-text {
  min-width: 0;
  overflow-wrap: anywhere;
}
.crm-pill-n {
  flex: 0 0 auto;
  padding: 1px 7px;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: var(--fg-dim);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
}
.crm-pill-n:empty {
  display: none;
}
.crm-pill:has(input:checked) {
  color: var(--fg);
  border-color: var(--pill);
  background: color-mix(in srgb, var(--pill) 20%, transparent);
}
.crm-pill:has(input:checked) .crm-pill-check {
  color: #06121f;
  background: var(--pill);
  border-color: var(--pill);
}
.crm-pill:has(input:checked) .crm-pill-n {
  color: var(--fg);
  background: color-mix(in srgb, var(--pill) 28%, transparent);
}
.crm-pill:has(input:focus-visible) {
  outline: 2px solid var(--andy-cyan);
  outline-offset: 2px;
}
/* Sub-etiqueta já incluída pela principal marcada: lê como "dentro", sem toque. */
.crm-pill.included {
  color: var(--fg-mid);
  border-style: dashed;
  border-color: color-mix(in srgb, var(--pill) 55%, transparent);
  background: color-mix(in srgb, var(--pill) 10%, transparent);
  cursor: default;
}
.crm-pill.included .crm-pill-check {
  color: var(--pill);
  border-color: color-mix(in srgb, var(--pill) 55%, transparent);
}
.crm-pill.included input {
  cursor: default;
}
/* Principal com sub-etiquetas: ela em cima, as sub recuadas com um traço. */
.crm-tagfam {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin-top: 10px;
}
.crm-tagfam .crm-pills.sub {
  margin-left: 14px;
  padding-left: 12px;
  border-left: 2px solid var(--border-strong);
}

/* ---- rodapé: contagem ao vivo ---- */
.crm-foot-btn.busy {
  opacity: 0.75;
}

/* ---- aviso diário (dentro da seção da data) ---- */
.crm-notice {
  margin-top: 12px;
  padding: 0 12px;
}
.crm-notice > summary {
  min-height: var(--crm-touch);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 -12px;
  padding: 0 12px;
  font-size: 0.88rem;
  cursor: pointer;
  list-style: none;
}
.crm-notice > summary::-webkit-details-marker {
  display: none;
}
.crm-notice > summary::after {
  content: '▾';
  margin-left: auto;
  color: var(--fg-dim);
  transition: transform 0.15s;
}
.crm-notice[open] > summary::after {
  transform: rotate(180deg);
}
.crm-notice-state {
  padding: 1px 8px;
  font-size: 0.72rem;
  color: var(--fg-mid);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
}
.crm-notice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 2px 0 6px;
}
.crm-notice .crm-check {
  min-height: 40px;
}

/* ---- gerenciar etiquetas: linha, "+ sub" e menu ⋯ ---- */
.crm-taglist.manager .crm-tagrow-main {
  position: relative;
  flex-wrap: nowrap;
  gap: 4px;
}
.crm-taglist.manager .crm-tagrow-open {
  min-width: 0;
  flex: 1 1 auto;
}
.crm-taglist.manager .crm-tagrow-open .crm-tag {
  max-width: 100%;
}
.crm-taglist.manager .crm-tagrow-open .crm-count {
  white-space: nowrap;
}
.crm-tagrow-actions {
  flex: 0 0 auto;
  gap: 2px;
}
.crm-subbtn {
  width: auto;
  min-width: 44px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.95rem;
  color: var(--andy-cyan);
}
.crm-subbtn-text {
  display: none;
  font-size: 0.78rem;
}
.crm-iconbtn[aria-expanded='true'] {
  color: var(--andy-cyan);
  background: rgba(92, 200, 255, 0.1);
}
.crm-menu {
  position: absolute;
  top: calc(100% - 4px);
  right: 0;
  z-index: 5;
  min-width: 230px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  background: var(--surface-elev);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.5);
}
.crm-menu-item {
  min-height: 44px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  font: inherit;
  font-size: 0.9rem;
  text-align: left;
  color: var(--fg);
  background: none;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.crm-menu-item:hover,
.crm-menu-item:focus-visible {
  background: rgba(255, 255, 255, 0.06);
  outline: none;
}
.crm-menu-item.danger {
  color: var(--danger);
}
.crm-menu-item > span {
  width: 18px;
  text-align: center;
  color: var(--fg-mid);
}
.crm-menu-item.danger > span {
  color: inherit;
}
.crm-empty-note {
  margin: 18px 0;
  text-align: center;
  color: var(--fg-dim);
}

/* ---- pop-up: criar / editar etiqueta ---- */
.crm-tagedit {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.crm-tagedit-preview {
  display: flex;
  justify-content: center;
  padding: 14px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
}
.crm-tagedit-preview .crm-tag {
  font-size: 0.95rem;
  padding: 5px 12px;
}
.crm-tag.ghost {
  opacity: 0.55;
}
.crm-tagedit .crm-label > span {
  display: block;
}
.crm-tagedit .crm-swatches {
  gap: 6px;
}
.crm-tagedit .crm-error:empty {
  display: none;
}
.crm-danger {
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.crm-linkbtn {
  min-height: 40px;
  padding: 0 4px;
  font: inherit;
  font-size: 0.88rem;
  color: var(--fg-mid);
  background: none;
  border: 0;
  cursor: pointer;
}
.crm-linkbtn.danger {
  color: var(--danger);
}
.crm-danger-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: var(--danger-soft);
  border: 1px solid var(--danger-line);
  border-radius: 12px;
}
.crm-danger-box p {
  margin: 0;
  font-size: 0.9rem;
}
.crm-danger-box .crm-pill {
  --pill: var(--danger);
  min-height: 40px;
}
.crm-danger-box .crm-foot-btn.danger {
  align-self: stretch;
}

/* ---- ⚙ Campos e estágios: abas, linhas, sugestões, pop-up ---- */
/* As abas ficam presas no topo da folha enquanto a lista rola por baixo. */
.crm-cfg-sheet .crm-sheet-body {
  padding-top: 0;
}
.crm-cfgtabs {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 0 -16px 12px;
  padding: 12px 16px 10px;
  background: var(--crm-sheet-bg, #0d1628);
  border-bottom: 1px solid var(--border);
}
.crm-cfgtabs .crm-seg-opt {
  flex: 1 1 0;
}
.crm-cfgtabs .crm-seg-opt > span {
  gap: 8px;
}
/* O contador é um <span> dentro da opção: desfaz o desenho de botão que a
   regra genérica `.crm-seg-opt span` lhe daria. */
.crm-cfgtabs .crm-cfgtab-n {
  min-height: 0;
  min-width: 22px;
  padding: 0 6px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 18px;
  color: var(--fg-mid);
  background: rgba(255, 255, 255, 0.1);
  border: 0;
  border-radius: 999px;
}
.crm-cfgtabs .crm-seg-opt input:checked + span .crm-cfgtab-n {
  color: #06121f;
  background: rgba(6, 18, 31, 0.16);
}
.crm-cfgpane > .crm-hint {
  margin: 0 0 8px;
}
.crm-cfgpane .crm-taglist.manager {
  border-top: 1px solid var(--border);
}
.crm-cfgrow .crm-tagrow-open {
  min-width: 0;
  padding: 10px 0;
  gap: 10px;
  transition: background 120ms ease-out;
}
.crm-cfgrow.field .crm-tagrow-open {
  align-items: flex-start;
}
.crm-cfgrow .crm-tagrow-open:active {
  background: rgba(255, 255, 255, 0.04);
}
.crm-cfgrow-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.crm-cfgrow-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}
.crm-cfgrow-name {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
/* A dica da IA nunca mais é cortada numa linha: até duas, com reticências. */
.crm-cfgrow-hint {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--fg-dim);
  overflow-wrap: anywhere;
}
.crm-ftype,
.crm-ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px 1px 6px;
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: 0.02em;
  white-space: nowrap;
  border-radius: 999px;
}
.crm-ftype {
  color: var(--fg-mid);
  background: rgba(255, 255, 255, 0.07);
}
.crm-ftype svg {
  flex: 0 0 auto;
  opacity: 0.85;
}
.crm-ai-badge {
  padding-left: 8px;
  color: var(--andy-cyan);
  background: rgba(92, 200, 255, 0.12);
}
.crm-cfgrow.stage .crm-dot {
  width: 12px;
  height: 12px;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08);
}
.crm-stageflag {
  padding: 0 7px;
  font-size: 0.66rem;
  font-weight: 600;
  line-height: 1.6;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 999px;
}
.crm-stageflag.won {
  color: var(--success);
  background: rgba(102, 247, 166, 0.12);
}
.crm-stageflag.lost {
  color: var(--danger);
  background: var(--danger-soft);
}
.crm-cfgsug {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
}
.crm-cfgsug-label {
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-dim);
}
.crm-cfgsug-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px 0 14px;
  font: inherit;
  font-size: 0.88rem;
  color: var(--andy-cyan);
  background: rgba(92, 200, 255, 0.06);
  border: 1px dashed rgba(92, 200, 255, 0.45);
  border-radius: 999px;
  cursor: pointer;
  transition: background 120ms ease-out;
}
.crm-cfgsug-btn .crm-ftype {
  color: var(--andy-cyan);
  background: rgba(92, 200, 255, 0.12);
}
.crm-cfgsug-btn:active {
  background: rgba(92, 200, 255, 0.18);
}
.crm-cfgsug-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* pop-up de campo e de estágio */
.crm-cfgedit code {
  padding: 1px 5px;
  font-size: 0.85em;
  color: var(--fg-mid);
  background: rgba(255, 255, 255, 0.07);
  border-radius: 4px;
}
.crm-cfgedit textarea.crm-input {
  min-height: 0;
  line-height: 1.4;
  resize: vertical;
}
.crm-cfgedit .crm-pill svg {
  flex: 0 0 auto;
  margin-right: 2px;
  vertical-align: -2px;
}
.crm-counter {
  align-self: flex-end;
  margin-top: -2px;
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--fg-dim);
}
.crm-switch {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 44px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.crm-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
}
.crm-switch-track {
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 24px;
  margin-top: 1px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  transition:
    background 160ms ease-out,
    border-color 160ms ease-out;
}
.crm-switch-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  transition: transform 160ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.crm-switch input:checked + .crm-switch-track {
  background: var(--andy-cyan);
  border-color: var(--andy-cyan);
}
.crm-switch input:checked + .crm-switch-track::after {
  background: #06121f;
  transform: translateX(18px);
}
.crm-switch input:focus-visible + .crm-switch-track {
  outline: 2px solid var(--andy-cyan);
  outline-offset: 2px;
}
.crm-switch-text {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.9rem;
  line-height: 1.35;
}
.crm-switch-text .crm-hint {
  margin: 0;
}
.crm-stagechip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 5px 14px 5px 10px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 40%, transparent);
  border-radius: 999px;
  overflow-wrap: anywhere;
}
.crm-stagechip .crm-dot {
  width: 10px;
  height: 10px;
  background: var(--c);
}
@media (hover: hover) and (pointer: fine) {
  .crm-cfgrow .crm-tagrow-open:hover {
    background: rgba(255, 255, 255, 0.03);
  }
  .crm-cfgsug-btn:hover {
    background: rgba(92, 200, 255, 0.14);
  }
}

/* ---- lista sem a coluna do aniversário (tenant sem o campo) ---- */
.crm-ltable.no-bday .crm-lrow {
  grid-template-areas:
    'check name name'
    'check phone phone'
    'stage stage stage'
    'tags tags tags'
    'origin origin assigned'
    'last last last';
}

@media (min-width: 560px) {
  .crm-fsec-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 768px) {
  .crm-sheet.bottom {
    max-height: min(86vh, 760px);
    padding-top: 0;
    border-radius: 16px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  }
  .crm-sheet.bottom::before {
    display: none;
  }
  .crm-sheet.small {
    width: min(440px, 100%);
  }
  .crm-pill {
    min-height: 36px;
    font-size: 0.85rem;
  }
  .crm-pill-check {
    width: 15px;
    height: 15px;
  }
  .crm-menu-item {
    min-height: 38px;
  }
  .crm-subbtn-text {
    display: inline;
  }
  .crm-cfgsug-btn {
    min-height: 36px;
    font-size: 0.84rem;
  }
  .crm-cfgrow .crm-tagrow-open {
    padding: 8px 0;
  }
  /* "Filtros · 2" em vez da bolinha: o rótulo está visível aqui. */
  .crm-filter-count {
    min-width: 0;
    padding: 0;
    font-size: inherit;
    font-weight: 600;
    color: var(--andy-cyan);
    background: none;
  }
  .crm-filter-count::before {
    content: '· ';
  }
  .crm-filter-count[hidden] {
    display: none;
  }
}

@media (min-width: 1200px) {
  .crm-ltable.no-bday .crm-lrow,
  .crm-ltable.no-bday .crm-lhead {
    grid-template-columns:
      44px minmax(150px, 1.5fr) 130px 124px minmax(130px, 1.3fr)
      110px 124px 84px 96px;
    min-width: 960px;
  }
}
