/* ============================================================================
   prospeccao.css — view «Prospecção» (parte 1, 06/11/2026; js/prospeccao.js; só DEV).
   Tema IB: painel reto, fio 1px, controle 2 px, sem sombra, sem vidro, chip só com fio. Cor só por token.
   Arquétipo: quadro de trabalho (fila à esquerda, empresa aberta à direita); Funil e Config em cards.
   ========================================================================== */

#prospeccao-view { padding: 1.5rem; }

.psp-wrap { display: flex; flex-direction: column; gap: var(--ds-gap-irmaos); min-width: 0; }
.psp-faixa { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.psp-abas > button { white-space: nowrap; }
.psp-n {
    display: inline-block; min-width: 1.5em; margin-left: 4px; padding: 0 5px;
    border: 1px solid currentColor; border-radius: var(--radius-xs);
    font-size: 12px; font-weight: 600; line-height: 1.4; font-variant-numeric: tabular-nums; text-align: center;
}
.psp-corpo { min-width: 0; }
.psp-oculto { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* texto auxiliar */
.psp-rot { margin: 0 0 6px; font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.psp-dim { color: var(--text-muted); font-size: 12.5px; }
.psp-nota { margin: 8px 0 0; font-size: 12.5px; color: var(--text-secondary); line-height: 1.5; }
.psp-fonte { display: block; margin-top: 2px; font-size: 12px; color: var(--text-muted); overflow-wrap: anywhere; }
.psp-sec { margin: 0 0 10px; font-size: 15px; font-weight: 600; color: var(--text-primary); }
.psp-campo { display: block; margin: 10px 0 4px; font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.psp-campo--inline { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 400; color: var(--text-primary); }
.psp-msg:empty { display: none; }
.psp-msg { margin: 0; }
.psp-msg.aviso { color: var(--st-atencao); }

/* em construção, vazio, erro */
.psp-construcao, .psp-vazio { text-align: left; }
.psp-construcao p, .psp-vazio p { margin: 0 0 6px; color: var(--text-secondary); }
.psp-construcao .psp-construcao__tit, .psp-vazio .psp-construcao__tit { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.psp-erro { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 0; }

/* skeleton: mesmas caixas da tela */
.psp-sk { display: inline-block; height: 12px; width: 120px; vertical-align: middle; border-radius: var(--radius-xs); }
.psp-sk--nome { width: 60%; height: 14px; }
.psp-sk--curto { width: 90px; }
.psp-sk--linha { width: 80%; }
.psp-sk--titulo { width: 260px; height: 22px; }
.psp-sk--botao { width: 110px; height: 36px; }
.psp-sk--campo { display: block; width: 100%; height: 36px; margin: 6px 0; }
.psp-sk--texto { display: block; width: 100%; height: 120px; margin: 6px 0; }
.psp-sk--num { width: 32px; }

/* ------------------------------------------------------------------ Aprovar */
.psp-aprovar { display: grid; grid-template-columns: minmax(240px, 320px) minmax(0, 1fr); gap: 24px; align-items: start; }
.psp-fila__lista { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--ib-fio); }
.psp-fila__lista > li { border-bottom: 1px solid var(--ib-fio); }
.psp-item {
    display: flex; flex-direction: column; gap: 4px; width: 100%; padding: 12px 10px;
    border: 0; border-left: 3px solid transparent; background: transparent; color: var(--text-primary);
    font: inherit; text-align: left; cursor: pointer;
}
.psp-item:hover { background: var(--ds-fill); }
.psp-item:focus-visible { outline: 2px solid var(--accent-color); outline-offset: -2px; }
.psp-item--sel { background: var(--ds-fill); border-left-color: var(--text-primary); }
.psp-item__l1 { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 14px; }
.psp-item__l2 { font-size: 12.5px; color: var(--text-secondary); }
.psp-item__l3 { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.psp-score { font-size: 12px; font-weight: 600; color: var(--text-secondary); font-variant-numeric: tabular-nums; }

.psp-emp { min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.psp-emp__cab { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px;
    padding-bottom: 12px; border-bottom: 1px solid var(--ib-fio-forte); }
.psp-emp__id { min-width: 0; }
.psp-emp__nome { margin: 0; font-size: 20px; font-weight: 600; line-height: 1.25; color: var(--text-primary); }
.psp-emp__sub { margin: 4px 0 0; font-size: 12.5px; color: var(--text-secondary); }
.psp-acoes { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.psp-perigo { color: var(--st-erro); }
.psp-perigo-cheio { background: var(--st-erro-fill); color: var(--st-erro-on); border-color: var(--st-erro-fill); }
.psp-perigo-cheio:hover:not(:disabled) { background: var(--st-erro); border-color: var(--st-erro); }
.psp-conf { margin: 0; }
.psp-avisos { margin: 4px 0 0; padding-left: 20px; font-size: 13.5px; line-height: 1.45; }
.psp-avisos li { margin: 2px 0; }
.psp-avisos { list-style: disc; }   /* 09/11: caixa da conferência e dossiê (o preflight do Tailwind zera o marcador) */

.psp-emp__grade { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 24px; align-items: start; }
.psp-dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0 0 14px; }
.psp-dl > div { min-width: 0; }
.psp-dl dt { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.psp-dl dd { margin: 2px 0 0; font-size: 14px; color: var(--text-primary); overflow-wrap: anywhere; }
.psp-gancho { padding: 12px 14px; margin-bottom: 14px; background: var(--bg-tertiary); border-left: 3px solid var(--graf-serie-1); }
.psp-gancho--sem { border-left-color: var(--st-risco); }
.psp-gancho p { margin: 0; }
.psp-gancho__txt { font-size: 14px; font-weight: 600; line-height: 1.45; color: var(--text-primary); }
.psp-gancho__data { font-variant-numeric: tabular-nums; padding: 0 4px; border: 1px solid currentColor; border-radius: var(--radius-xs); font-size: 12.5px; }
.psp-tese { margin: 0 0 14px; font-size: 13.5px; line-height: 1.5; color: var(--text-primary); }
.psp-fatos { margin: 0 0 14px; padding-left: 20px; list-style: disc; font-size: 13.5px; line-height: 1.45; }
.psp-fatos li { margin-bottom: 8px; }

.psp-toques { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.psp-toques > .psp-sec { margin-bottom: 0; }
.psp-toque { padding: 12px 14px; border: 1px solid var(--ib-fio); background: var(--bg-card); }
.psp-toque--erro { border-color: var(--st-erro); border-left-width: 3px; }
.psp-toque__rot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; font-size: 12px; font-weight: 600; color: var(--text-secondary); }
/* Campos: poço e borda do tema por token (o preflight do Tailwind no index zera a borda). */
.psp-toque input[type="text"], .psp-toque textarea,
.psp-modal textarea, .psp-modal input[type="search"],
.psp-config input[type="number"], .psp-config input[type="time"] {
    box-sizing: border-box; padding: 8px 10px; font: inherit; font-size: 13.5px; color: var(--text-primary);
    background: var(--ib-campo-fundo); border: 1px solid var(--ib-campo-borda); border-radius: var(--radius-field);
}
.psp-toque input[type="text"], .psp-toque textarea { width: 100%; }
.psp-toque input:focus-visible, .psp-toque textarea:focus-visible, .psp-modal :is(input, textarea):focus-visible,
.psp-config input:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 1px; }
.psp-conf-ok { margin: -4px 0 0; }
.psp-toque__assunto { font-weight: 600; }
.psp-toque textarea { line-height: 1.5; resize: vertical; min-height: 120px; }
.psp-toque [readonly] { background: transparent; border-style: dashed; }
.psp-toque__acoes { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.psp-toque__acoes[hidden] { display: none; }
/* E-mail como o contato vê (mesmas medidas de formato.montar): sempre branco, em qualquer tema. Edita no lugar. */
.psp-email__folha {
    --psp-papel: #ffffff; --psp-tinta: #1f1f1f; --psp-tinta-2: #555555;
    margin-top: 8px; padding: 16px 20px; border: 1px solid var(--ib-fio); background: var(--psp-papel);
    font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 23px; color: var(--psp-tinta);
}
.psp-toque input.psp-email__assunto { margin-top: 8px; padding: 4px 6px; font-size: 17px; font-weight: 600; background: transparent; border-color: transparent; }
.psp-toque input.psp-email__assunto:not([readonly]):hover { border-color: var(--ib-campo-borda); }
.psp-email__para { margin: 2px 0 0; padding: 0 7px; font-size: 12.5px; }
.psp-email__p { margin: 0 0 14px; }
.psp-toque .psp-email__corpo {
    display: block; width: calc(100% + 10px); min-height: 0; margin: 0 -5px 14px; padding: 2px 4px; resize: none; overflow: hidden; /* -5px = padding + borda: o texto alinha com a saudação */
    font: inherit; color: inherit; background: transparent; border: 1px dashed transparent;
}
.psp-toque .psp-email__corpo:not([readonly]):hover { border-color: var(--psp-tinta-2); }
.psp-email__ass { margin: 18px 0 0; font-size: 13px; line-height: 19px; color: var(--psp-tinta-2); }
.psp-email__logo { display: block; width: 120px; height: 53px; margin-top: 12px; border: 0; }
.psp-outros { margin: 0; padding-left: 18px; font-size: 13px; color: var(--text-secondary); }
.psp-outros li { margin: 4px 0; }

/* ------------------------------------------------------------------ Funil */
.psp-funil { display: flex; flex-direction: column; gap: var(--ds-gap-irmaos); }
.psp-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--ib-fio); border-bottom: 1px solid var(--ib-fio); }
.psp-kpi { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; }
.psp-kpi + .psp-kpi { border-left: 1px solid var(--ib-fio); }
.psp-kpi__v { font-size: 26px; font-weight: 300; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.psp-kpi__r { font-size: 12.5px; color: var(--text-secondary); }
.psp-funil__grade, .psp-config__grade { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--ds-gap-irmaos); align-items: start; }
.psp-bloco { padding: 16px; min-width: 0; }
.psp-bloco--largo { grid-column: 1 / -1; }
.psp-bloco__cab { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.psp-bloco__cab .ds-card-title { margin: 0; }
.psp-bloco__acoes { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.psp-bloco__cab .psp-bloco__acoes { margin-top: 0; }
/* Funil > Automação de e-mail (F3): 3 números, aviso e tabela por empresa */
.psp-auto .psp-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 12px; }
.psp-auto > .ds-aviso { margin-bottom: 12px; }

.psp-tab { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.psp-tab th, .psp-tab td { padding: 8px 6px; border-bottom: 1px solid var(--ib-fio); text-align: center; vertical-align: middle; }
.psp-tab th { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.psp-tab tfoot td { font-weight: 600; border-bottom: 0; }
.psp-tab .psp-tab__nome { text-align: left; }
/* Cabeçalho ordenável (09/11, mesmo padrão do CRM .cli-g-ord): a seta fica fora do fluxo para o rótulo seguir centrado */
.psp-ord {
    position: relative; display: inline-flex; align-items: center; padding: 0; border: 0; background: none;
    font: inherit; color: inherit; cursor: pointer; white-space: nowrap;
}
.psp-ord:hover:not(:disabled) { color: var(--text-primary); }
.psp-ord:disabled { cursor: default; }
.psp-ord:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 2px; border-radius: var(--radius-xs, 4px); }
.psp-ord svg { position: absolute; left: 100%; top: 50%; margin: -6px 0 0 4px; flex: none; opacity: 0; transition: transform .15s ease; }
.psp-ord:hover:not(:disabled) svg { opacity: .5; }
.psp-tab th[aria-sort="ascending"] .psp-ord, .psp-tab th[aria-sort="descending"] .psp-ord { color: var(--text-primary); }
.psp-tab th[aria-sort="ascending"] .psp-ord svg, .psp-tab th[aria-sort="descending"] .psp-ord svg { opacity: 1; }
.psp-tab th[aria-sort="descending"] .psp-ord svg { transform: rotate(180deg); }
@media (prefers-reduced-motion: reduce) { .psp-ord svg { transition: none; } }
.psp-tab__barra { width: 40%; }
.psp-barra { display: block; height: 8px; background: var(--bg-tertiary); }
.psp-barra > span { display: block; height: 100%; background: var(--graf-serie-1); }

/* ------------------------------------------------------------------ Config */
.psp-leitura { margin: 0; }
.psp-config { display: flex; flex-direction: column; gap: var(--ds-gap-irmaos); }
.psp-fs { margin: 0; padding: 0; border: 0; }
.psp-linha { display: flex; flex-wrap: wrap; gap: 16px; }
.psp-dias { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; }
.psp-dia, .psp-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-primary); cursor: pointer; }
.psp-check { margin-top: 14px; }
.psp-config input[type="number"] { width: 120px; }
.psp-config input:disabled { cursor: not-allowed; }

/* ------------------------------------------------------------------ modais (portal no <body>) */
.psp-modal--largo { max-width: 640px; }
.psp-modal textarea, .psp-modal input[type="search"] { width: 100%; box-sizing: border-box; font: inherit; }
.psp-modal__msg:empty { display: none; }
.psp-gerar__corpo { max-height: 320px; overflow-y: auto; margin-top: 10px; border-top: 1px solid var(--ib-fio); }
.psp-gerar__lista { list-style: none; margin: 0; padding: 0; }
.psp-gerar__item { padding: 8px 2px; border-bottom: 1px solid var(--ib-fio); font-size: 13.5px; }
.psp-gerar__item label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.psp-gerar__n { margin-right: auto; align-self: center; }
.psp-gerar__custo { font-size: 14px; color: var(--text-primary); }

/* ------------------------------------------------------------------ mobile */
@media (max-width: 1024px) {
    .psp-aprovar, .psp-emp__grade { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 768px) {
    #prospeccao-view { padding: 1rem; }
    .psp-funil__grade, .psp-config__grade { grid-template-columns: minmax(0, 1fr); }
    .psp-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .psp-kpi:nth-child(3) { border-left: 0; }
    .psp-kpi:nth-child(n+3) { border-top: 1px solid var(--ib-fio); }
    .psp-auto .psp-kpi:nth-child(3) { border-left: 1px solid var(--ib-fio); border-top: 0; }
    .psp-abas { overflow-x: auto; max-width: 100%; }
    .psp-dl { grid-template-columns: minmax(0, 1fr); }
    .psp-acoes > * { min-height: 44px; }
}

/* Parte 2a (06/11): link «Abrir no CRM» no cabeçalho da empresa (abre a Ficha na aba Prospecção). */
.psp-crm { display: inline-block; margin-top: 6px; font-size: 12.5px; color: var(--text-secondary); text-decoration: underline; text-underline-offset: 3px; }
.psp-crm:hover { color: var(--text-primary); }
.psp-crm:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 2px; }

/* ---------------------------------------------------------------- Hoje e Carteira (parte 2b, 07/11/2026) */
.psp-hc { display: flex; flex-direction: column; gap: var(--ds-gap-irmaos); }
.psp-hc__barra { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.psp-hc__resumo { font-size: 13px; }
.psp-hc__atr { color: var(--st-erro); font-weight: 600; }
.psp-hc__tab td { padding: 10px 6px; }
.psp-hc__gtit th { text-align: left; padding: 14px 6px 6px; font-size: 13px; font-weight: 600; color: var(--text-primary); border-bottom: 1px solid var(--ib-fio-forte); }
.psp-hc__grupo--atrasados .psp-hc__gtit th, .psp-hc__grupo--atrasados .psp-hc__data { color: var(--st-erro); }
.psp-hc__linha { cursor: pointer; }
.psp-hc__linha:hover td, .psp-cart__linha:hover td { background: var(--ds-fill); }
.psp-hc__data { white-space: nowrap; font-weight: 600; }
.psp-hc__emp { color: var(--text-primary); font-weight: 600; text-decoration: underline; text-decoration-color: var(--ib-fio-forte); text-underline-offset: 3px; }
.psp-hc__emp:hover { text-decoration-color: currentColor; }
.psp-hc__rodape { margin-top: 4px; }
.psp-hc__filtro { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-secondary); }
.psp-hc__filtro select { min-width: 140px; padding: 6px 8px; border: 1px solid var(--ib-campo-borda); border-radius: var(--radius-field); background: var(--ib-campo-fundo); color: var(--text-primary); font: inherit; font-size: 13px; }
.psp-hc__filtros { align-items: flex-end; }
.psp-hc__check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-primary); padding-bottom: 6px; }
.psp-hc__cad { margin-left: auto; }
.psp-hc__mini { padding: 4px 10px; font-size: 12.5px; }
.psp-cart__linha--sem td:first-child { box-shadow: inset 3px 0 0 var(--st-erro); }
.psp-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.psp-agendar input, .psp-agendar select { width: 100%; }
/* ---------------------------------------------------------------- filtros por tabela (10/11/2026)
   Busca + seleções sobre o que as colunas mostram (Hoje, Carteira, Automação do Funil, Lotes da Config). Mesmo campo
   dos seletores da Carteira; «n de N» à direita; «Limpar filtros» só ativo com filtro ligado. */
.psp-f { margin: 4px 0 12px; }
.psp-f__busca input { min-width: 200px; padding: 6px 8px; border: 1px solid var(--ib-campo-borda); border-radius: var(--radius-field); background: var(--ib-campo-fundo); color: var(--text-primary); font: inherit; font-size: 13px; }
.psp-f__busca input::placeholder { color: var(--text-secondary); }
.psp-hc__filtro select:focus-visible, .psp-f__busca input:focus-visible, .psp-f__link:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 1px; }
.psp-f__limpar { margin-bottom: 2px; }
.psp-f__limpar:disabled { opacity: .5; cursor: not-allowed; }
.psp-f__conta { margin-left: auto; padding-bottom: 6px; font-size: 13px; }
.psp-f__link { padding: 0; border: 0; background: none; color: var(--text-primary); font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.psp-f__vazio { padding: 24px 0; }
@media (max-width: 760px) {
    .psp-hc__tab { display: block; overflow-x: auto; }
    .psp-hc__cad { margin-left: 0; }
    .psp-hc__filtros > .psp-hc__filtro { flex: 1 1 140px; }
    .psp-hc__filtro select, .psp-f__busca input { min-width: 0; width: 100%; }
    .psp-f__conta { margin-left: 0; }
}
