/* Rotas · frente LEADS (leads, oportunidades, carteiras, territórios, segmentos, pipelines).
   Usa as variáveis do sistema visual da app (styles.css); tudo com prefixo .crm- para não colidir. */
.crm-raiz{display:flex;flex-direction:column;gap:16px;min-width:0}
.crm-a-carregar{display:flex;align-items:center;gap:10px;color:var(--muted);padding:30px 4px}
.crm-abas{align-self:flex-start;max-width:100%}
.crm-n{display:inline-grid;place-items:center;min-width:19px;height:19px;padding:0 5px;border-radius:10px;background:var(--bad);color:#fff;font-size:11px;font-weight:600;margin-left:2px}
.crm-corpo{display:flex;flex-direction:column;gap:14px;min-width:0}
.crm-filtros{display:flex;flex-wrap:wrap;gap:10px 12px;align-items:flex-end}
.crm-f{display:flex;flex-direction:column;gap:4px;font-size:12.5px;color:var(--muted);font-weight:500}
.crm-f select,.crm-f input{padding:8px 10px;border:1px solid var(--line-2);border-radius:10px;background:var(--surface-strong);color:var(--ink);font-size:14px;min-width:150px}
.crm-q{flex:1 1 200px}.crm-q input{width:100%}
.crm-chk{display:inline-flex;align-items:center;gap:8px;font-size:14px;color:var(--ink-2);cursor:pointer;min-height:36px}
.crm-chk input{width:18px;height:18px;accent-color:var(--accent)}
.crm-resumo{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px}
.crm-resumo>div{background:var(--surface);border:1px solid var(--line);border-radius:14px;padding:12px 14px;display:flex;flex-direction:column;gap:2px;box-shadow:var(--shadow)}
.crm-resumo b{font-family:var(--font-display);font-size:21px;font-weight:600;font-variant-numeric:tabular-nums}
.crm-resumo span{color:var(--muted);font-size:12.5px}
.crm-mau{color:var(--bad)}

.crm-raiz [hidden],.crm-sheet [hidden]{display:none!important}
.crm-curto{display:none}
.crm-mais summary{cursor:pointer;color:var(--accent);font-weight:500;font-size:13.5px;padding:10px 0 2px}

/* Quadro (Kanban) */
.crm-kanban{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(262px,1fr);gap:12px;overflow-x:auto;padding:2px 2px 14px;scroll-snap-type:x proximity;overscroll-behavior-x:contain;align-items:start}
.crm-col{background:var(--surface-2);border:1px solid var(--line);border-radius:16px;display:flex;flex-direction:column;min-height:180px;max-height:calc(100vh - 230px);scroll-snap-align:start;transition:background .2s,border-color .2s,box-shadow .2s,opacity .2s}
.crm-col header{display:flex;align-items:center;gap:8px;padding:11px 12px 8px;position:sticky;top:0}
.crm-col h3{font-size:13.5px;font-weight:600;flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.crm-col-dot{width:9px;height:9px;border-radius:50%;flex:none}
.crm-col-n{font-size:12px;color:var(--muted);background:var(--surface);border:1px solid var(--line);border-radius:8px;padding:0 7px;font-weight:600}
.crm-col-s{font-size:12px;color:var(--muted);font-variant-numeric:tabular-nums}
.crm-col-l{display:flex;flex-direction:column;gap:8px;padding:4px 8px 10px;overflow-y:auto;min-height:60px}
.crm-col-ganho{background:color-mix(in srgb,var(--good-soft) 55%,var(--surface-2))}
.crm-col-perdido{background:color-mix(in srgb,var(--bad-soft) 45%,var(--surface-2))}
.crm-vazio{color:var(--muted);font-size:12.5px;text-align:center;padding:16px 6px;border:1.5px dashed var(--line-2);border-radius:12px}
.crm-card{position:relative;background:var(--surface-strong);border:1px solid var(--line);border-radius:12px;padding:10px 11px 10px 30px;display:flex;flex-direction:column;gap:5px;cursor:pointer;box-shadow:0 1px 2px rgba(14,15,21,.05);transition:box-shadow .2s,transform .2s,border-color .2s;user-select:none;-webkit-user-select:none;touch-action:manipulation}
.crm-card:not([data-arrastar]){padding-left:11px}
.crm-card:hover{border-color:var(--line-2);box-shadow:var(--shadow)}
.crm-card-t{font-weight:600;font-size:14px;line-height:1.25}
.crm-card-c{font-size:12.5px;color:var(--muted)}
.crm-card-f{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin-top:2px}
.crm-valor{margin-left:auto;font-size:12.5px;font-weight:600;font-variant-numeric:tabular-nums}
.crm-av{width:24px;height:24px;border-radius:50%;display:grid;place-items:center;background:var(--surface-3);font-size:10.5px;font-weight:700;color:var(--ink-2)}
.crm-acao{display:flex;align-items:flex-start;gap:5px;font-size:12.5px;color:var(--ink-2);line-height:1.3}
.crm-acao .ic{width:14px;height:14px;color:var(--muted);flex:none;margin-top:1px}
.crm-acao b{white-space:nowrap}
.crm-acao.vencida,.crm-acao.vencida .ic{color:var(--bad)}
.crm-acao.hoje b{color:var(--warn)}
.crm-acao.fechada{color:var(--muted)}
.crm-pega{position:absolute;left:3px;top:7px;width:24px;height:30px;display:grid;place-items:center;border:0;background:transparent;color:var(--muted);border-radius:7px;cursor:grab;touch-action:none;padding:0}
.crm-pega:hover{background:var(--surface-3);color:var(--ink)}
.crm-pega .ic{width:16px;height:16px}
.a-arrastar{opacity:.35}
.crm-fantasma{position:fixed;left:0;top:0;z-index:80;pointer-events:none;box-shadow:var(--shadow-lg);opacity:.96;margin:0}
tr.crm-fantasma{display:block;background:var(--surface-strong);border-radius:12px;padding:8px}
tr.crm-fantasma td{border:0}
body.crm-arrastando{cursor:grabbing;user-select:none;-webkit-user-select:none}
body.crm-arrastando .crm-kanban,body.crm-arrastando .crm-estados-bar{scroll-snap-type:none!important;scroll-behavior:auto}
.crm-col.alvo-possivel{border-color:var(--line-2)}
.crm-col.proibido{opacity:.45}
.crm-col.sobre{border-color:var(--accent);box-shadow:0 0 0 3px var(--accent-ring);background:var(--accent-soft)}
.crm-col.proibido.sobre{border-color:var(--bad);box-shadow:0 0 0 3px var(--bad-soft);background:var(--surface-2)}
.crm-chip-estado i,.crm-alvo-chip i{width:7px;height:7px;border-radius:50%;background:var(--c);display:inline-block}

/* Lista */
.crm-estados-bar{display:flex;gap:6px;overflow-x:auto;padding:2px 0 6px;scrollbar-width:thin}
.crm-alvo-chip{display:inline-flex;align-items:center;gap:6px;padding:6px 10px;border-radius:10px;border:1.5px dashed var(--line-2);font-size:12.5px;white-space:nowrap;color:var(--ink-2);background:var(--surface);transition:all .2s}
.crm-alvo-chip.proibido{opacity:.35}
.crm-alvo-chip.alvo-possivel{border-style:solid}
.crm-alvo-chip.sobre{border-color:var(--accent);background:var(--accent-soft);box-shadow:0 0 0 3px var(--accent-ring)}
.crm-tabela-wrap{padding:6px;overflow-x:auto}
.crm-tabela td{vertical-align:middle}
.crm-linha{cursor:pointer}
.crm-linha:hover{background:var(--surface-2)}
.crm-td-pega{width:30px;position:relative;padding:0!important}
.crm-td-pega .crm-pega{position:static}
tr.inativo td{opacity:.55}
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}

/* Fila «sem próxima ação» e listas */
.crm-fila h3{display:flex;align-items:center;gap:8px;margin-bottom:10px}
.crm-fila ul{list-style:none;margin:0;padding:0;display:flex;flex-direction:column}
.crm-fila li{display:flex;align-items:center;gap:10px;padding:9px 0;border-top:1px solid var(--line);flex-wrap:wrap}
.crm-fila li>span:first-child{flex:1;min-width:200px}
.crm-fila-i{flex:1;min-width:200px;text-align:left;border:0;background:transparent;padding:0;cursor:pointer;display:flex;flex-direction:column;gap:2px;color:var(--ink)}
.crm-fila-i .sub{color:var(--muted);font-size:13px}
.crm-hist{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:0}
.crm-hist li{display:grid;grid-template-columns:150px 1fr;gap:10px;padding:7px 0;border-top:1px solid var(--line);font-size:13.5px}
.crm-hist time{color:var(--muted);font-size:12.5px;font-variant-numeric:tabular-nums}
.crm-hist s{color:var(--muted)}

/* Painel lateral */
.crm-sheet .panel{width:min(720px,100%)}
.crm-ficha fieldset{border:0;padding:0;margin:0;min-width:0;display:flex;flex-direction:column;gap:12px}
.crm-ficha fieldset[disabled]{opacity:.85}
.crm-bloco,.crm-pot{border:1px solid var(--line)!important;border-radius:14px;padding:12px 14px 14px!important}
.crm-bloco legend,.crm-pot legend,.crm-radio legend{font-size:12.5px;font-weight:600;color:var(--muted);padding:0 6px}
.crm-grid2{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
.crm-col2{grid-column:1/-1}
.crm-sheet textarea,.crm-sheet input[type=date],.crm-sheet input[type=email],.crm-sheet input[type=tel],.crm-sheet input[type=search],.crm-sheet input:not([type]){padding:10px 12px;border:1px solid var(--line-2);border-radius:10px;background:var(--surface-strong);color:var(--ink);width:100%}
.crm-sheet input[type=color]{height:42px;padding:3px;border:1px solid var(--line-2);border-radius:10px;background:var(--surface-strong);width:100%}
.crm-erro{color:var(--bad);font-size:14px;font-weight:500;background:var(--bad-soft);padding:9px 12px;border-radius:10px}
.crm-nota{font-size:13px}
.crm-ficha-extra{display:grid;gap:18px;margin-top:22px;padding-top:18px;border-top:1px solid var(--line)}
.crm-ficha-extra h3,.crm-sec h3{display:flex;align-items:center;gap:8px;margin-bottom:8px}
.crm-nota-f,.crm-linha-f{display:flex;gap:8px;margin:6px 0 10px;flex-wrap:wrap}
.crm-nota-f input,.crm-linha-f input{flex:1;min-width:160px;padding:8px 10px;border:1px solid var(--line-2);border-radius:10px;background:var(--surface-strong)}
.crm-nota-f select,.crm-linha-f select{padding:8px 10px;border:1px solid var(--line-2);border-radius:10px;background:var(--surface-strong)}
.crm-notas{list-style:none;margin:0;padding:0}
.crm-notas li{display:flex;flex-direction:column;gap:2px;padding:8px 0;border-top:1px solid var(--line);font-size:14px}
.crm-notas time{color:var(--muted);font-size:12px}
.crm-sec{display:flex;flex-direction:column;gap:10px;padding:14px 0;border-top:1px solid var(--line)}
.crm-sec:first-of-type{border-top:0;padding-top:0}
.crm-atr{list-style:none;margin:0;padding:0}
.crm-atr li{display:flex;justify-content:space-between;align-items:center;gap:10px;padding:8px 0;border-top:1px solid var(--line);font-size:14px}
.crm-radio{border:1px solid var(--line);border-radius:12px;padding:8px 12px 10px;display:flex;flex-direction:column;gap:4px}
.crm-radio label{display:flex;align-items:center;gap:8px;font-size:14px;min-height:30px}
.crm-lista-cli{max-height:260px;overflow:auto}

/* Territórios e mapa */
.crm-terr{display:grid;grid-template-columns:minmax(0,1.6fr) minmax(280px,1fr);gap:14px;align-items:start}
.crm-mapa-card{padding:8px}
.crm-mapa{height:520px;border-radius:12px;overflow:hidden;background:var(--map-bg)}
body.crm-desenhar .crm-mapa{cursor:crosshair;outline:3px solid var(--accent);outline-offset:2px}
body.crm-desenhar .crm-mapa .leaflet-container,body.crm-desenhar .leaflet-interactive{cursor:crosshair}
.crm-legenda{display:flex;flex-wrap:wrap;gap:10px;padding:8px 6px 2px;font-size:12.5px;color:var(--muted)}
.crm-legenda i{width:10px;height:10px;border-radius:50%;display:inline-block;margin-right:5px;vertical-align:-1px}
.crm-terr-l{display:flex;flex-direction:column;gap:10px}
.crm-terr-i header{display:flex;align-items:center;gap:8px;margin-bottom:4px}
.crm-terr-i header i{width:12px;height:12px;border-radius:4px}
.crm-terr-i p{font-size:13.5px;margin:4px 0}
.crm-terr-i.inativo{opacity:.6}
.crm-barra-desenho{position:fixed;left:50%;bottom:18px;transform:translateX(-50%);z-index:70;display:flex;align-items:center;gap:10px;flex-wrap:wrap;justify-content:center;background:var(--surface-strong);border:1px solid var(--line);box-shadow:var(--shadow-lg);border-radius:14px;padding:10px 14px;font-size:14px;max-width:calc(100vw - 24px)}

/* Pipelines */
.crm-tabela input:not([type=checkbox]):not([type=color]),.crm-tabela select{padding:6px 8px;border:1px solid var(--line-2);border-radius:8px;background:var(--surface-strong);max-width:220px}
.crm-tabela input[type=color]{width:38px;height:30px;padding:2px;border:1px solid var(--line-2);border-radius:8px}
.crm-in-n{width:70px}
.crm-matriz-wrap{overflow:auto;max-height:520px}
.crm-matriz{border-collapse:collapse;font-size:12.5px}
.crm-matriz th,.crm-matriz td{border:1px solid var(--line);padding:4px 6px;text-align:center}
.crm-matriz thead th{vertical-align:bottom;height:130px;white-space:nowrap}
.crm-matriz thead th span{writing-mode:vertical-rl;transform:rotate(180deg);font-weight:500}
.crm-matriz tbody th{text-align:left;white-space:nowrap;font-weight:500;position:sticky;left:0;background:var(--surface)}
.crm-matriz td.eu{color:var(--muted);background:var(--surface-2)}
.crm-matriz input{width:17px;height:17px;accent-color:var(--accent)}
.crm-listas{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:14px}
.crm-lista-s ul{list-style:none;margin:0;padding:0}

/* Comercial no terreno: separadores Rota / Leads */
.crm-terreno-tabs{max-width:1240px;margin:0 auto;padding:14px 22px 0;display:flex}
.crm-terreno{max-width:1240px;margin:0 auto;padding:16px 22px 40px}

@media (max-width:900px){
  .crm-longo{display:none}.crm-curto{display:inline}
  .crm-abas{align-self:stretch}
  .crm-resumo{grid-template-columns:repeat(2,minmax(0,1fr))}
  .crm-kanban{grid-auto-columns:minmax(78vw,1fr);margin:0 -16px;padding:2px 16px 14px;scroll-snap-type:x mandatory}
  .crm-col{max-height:none}
  .crm-terr{grid-template-columns:1fr}
  .crm-mapa{height:360px}
  .crm-grid2{grid-template-columns:1fr}
  .crm-hist li{grid-template-columns:1fr;gap:2px}
  .crm-f{flex:1 1 140px}.crm-f select,.crm-f input{min-width:0;width:100%}
  .crm-tabela thead{display:none}
  .crm-tabela,.crm-tabela tbody{display:block}
  .crm-tabela tr{display:grid;grid-template-columns:auto 1fr;gap:2px 10px;padding:12px 8px;border-bottom:1px solid var(--line)}
  .crm-tabela td{display:block;border:0;padding:2px 0!important}
  .crm-tabela td[data-l]::before{content:attr(data-l);display:block;font-size:11.5px;color:var(--muted)}
  .crm-tabela td:first-child{grid-row:span 8}
  .crm-tabela td.n{text-align:left}
  .crm-terreno,.crm-terreno-tabs{padding-left:14px;padding-right:14px}
  .crm-pega{width:32px;height:38px;top:4px;left:0}
  .crm-card{padding-left:34px}
}
