/* RotaCerta — folha de estilo única (mobile first) */
:root {
  --navy: #01003d;
  --navy-2: #0d0b5e;
  --azul: #1b15d1;
  --verde: #26d100;
  --verde-esc: #22850d;
  --oliva: #314d15;
  --terra: #853407;

  --fundo: #eef0f6;
  --superficie: #ffffff;
  --linha: #d9dce8;
  --texto: #01003d;
  --texto-2: #4a4a6a;
  --texto-3: #7a7a95;

  --frio: #2f6fe0;
  --morno: #e8a800;
  --quente: #e0322b;

  --perigo: #c62828;
  --raio-sm: 6px;
  --raio: 10px;
  --raio-lg: 16px;
  --sombra: 0 1px 2px rgba(1, 0, 61, .06), 0 4px 14px rgba(1, 0, 61, .05);
  --fonte: 'Figtree', 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
  --menu-l: 248px;
  --topo-h: 58px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--fonte); font-size: 15px; line-height: 1.5;
  color: var(--texto); background: var(--fundo);
}
img { max-width: 100%; height: auto; }
a { color: var(--azul); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; font-weight: 800; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0 0 1em; }
:focus-visible { outline: 3px solid var(--azul); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Estrutura ---------- */
.topo {
  position: sticky; top: 0; z-index: 30; height: var(--topo-h);
  display: flex; align-items: center; gap: 12px; padding: 0 14px;
  background: var(--navy); color: #fff;
}
.topo .logo img { height: 34px; display: block; }
.topo .usuario-topo { margin-left: auto; text-align: right; font-size: .82rem; line-height: 1.25; }
.topo .usuario-topo small { color: #b9b8e6; display: block; }
.btn-menu {
  background: none; border: 0; color: #fff; padding: 8px; margin-left: -6px; cursor: pointer; border-radius: var(--raio-sm);
}
.btn-menu svg { display: block; }

.menu {
  position: fixed; top: var(--topo-h); bottom: 0; left: 0; width: var(--menu-l); z-index: 40;
  background: var(--navy); color: #fff; padding: 18px 12px 24px; overflow-y: auto;
  transform: translateX(-100%); transition: transform .2s ease;
}
.menu.aberto { transform: none; }
.menu-fundo { display: none; position: fixed; inset: var(--topo-h) 0 0 0; background: rgba(1, 0, 61, .45); z-index: 35; }
.menu-fundo.aberto { display: block; }

/* Menu desenhado como paradas de uma rota pontilhada */
.menu nav { position: relative; }
.menu nav::before {
  content: ""; position: absolute; left: 21px; top: 14px; bottom: 14px;
  border-left: 3px dotted rgba(38, 209, 0, .35);
}
.menu a {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 9px 10px 9px 38px; border-radius: var(--raio); margin-bottom: 2px;
  color: #d8d7f5; text-decoration: none; font-weight: 600; font-size: .94rem;
}
.menu a::before {
  content: ""; position: absolute; left: 16px; width: 13px; height: 13px; border-radius: 50%;
  background: var(--navy); border: 3px solid #4a49a0;
}
.menu a:hover { background: var(--navy-2); color: #fff; }
.menu a.ativo { background: var(--navy-2); color: #fff; }
.menu a.ativo::before { background: var(--verde); border-color: var(--verde); }
.menu .grupo { font-size: .75rem; color: #8988c4; padding: 14px 10px 4px 38px; font-weight: 600; }
.menu .rodape-menu { margin-top: 22px; padding: 12px 10px 0 12px; border-top: 1px solid #1d1b6e; font-size: .8rem; color: #8988c4; }
.menu .rodape-menu a { padding-left: 0; display: inline; color: #d8d7f5; }
.menu .rodape-menu a::before { display: none; }

.conteudo { padding: 18px 14px 90px; max-width: 1280px; margin: 0 auto; }

@media (min-width: 1000px) {
  .btn-menu { display: none; }
  .menu { transform: none; }
  .menu-fundo, .menu-fundo.aberto { display: none; }
  .conteudo { margin-left: var(--menu-l); padding: 26px 32px 48px; max-width: calc(1280px + var(--menu-l)); }
}

.cabecalho { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 18px; }
.cabecalho h1 { margin: 0; }
.cabecalho .acoes { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.subtitulo { color: var(--texto-2); margin: -10px 0 18px; }

/* ---------- Componentes ---------- */
.caixa {
  background: var(--superficie); border: 1px solid var(--linha); border-radius: var(--raio-lg);
  padding: 18px; margin-bottom: 18px;
}
.caixa > h2:first-child { margin-bottom: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 16px; border-radius: var(--raio); border: 1.5px solid transparent;
  background: var(--verde); color: var(--navy); font: inherit; font-weight: 700; text-decoration: none;
  cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #2fe606; }
.btn-sec { background: var(--superficie); color: var(--navy); border-color: var(--linha); }
.btn-sec:hover { background: #f5f6fb; border-color: #b9bdd2; }
.btn-azul { background: var(--azul); color: #fff; }
.btn-azul:hover { background: #2a24e6; }
.btn-perigo { background: var(--superficie); color: var(--perigo); border-color: #f0c4c4; }
.btn-perigo:hover { background: #fdf1f1; }
.btn-pq { min-height: 34px; padding: 0 11px; font-size: .86rem; }
.btn-bloco { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* Botão flutuante de nova visita (SDR no celular) */
.fab {
  position: fixed; right: 16px; bottom: 18px; z-index: 25; height: 56px; padding: 0 22px;
  border-radius: 28px; box-shadow: 0 6px 20px rgba(1, 0, 61, .3); font-size: 1rem;
}
@media (min-width: 1000px) { .fab { display: none; } }

/* Formulários */
.form-grade { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 700px) {
  .form-grade { grid-template-columns: repeat(6, 1fr); }
  .c2 { grid-column: span 2; } .c3 { grid-column: span 3; } .c4 { grid-column: span 4; } .c6 { grid-column: span 6; }
}
.campo label, .rotulo { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 5px; color: var(--texto-2); }
.campo .ajuda { font-size: .8rem; color: var(--texto-3); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number],
input[type=date], input[type=datetime-local], input[type=url], select, textarea {
  width: 100%; min-height: 44px; padding: 9px 12px; border: 1.5px solid var(--linha);
  border-radius: var(--raio); background: #fff; color: var(--texto); font: inherit; font-size: 16px;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--azul); box-shadow: 0 0 0 3px rgba(27, 21, 209, .15); }
.obrig { color: var(--quente); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--verde-esc); }

/* Seletor de temperatura: três botões grandes para usar com o polegar */
.seletor-temp { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.seletor-temp input { position: absolute; opacity: 0; pointer-events: none; }
.seletor-temp label {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 64px; border: 2px solid var(--linha); border-radius: var(--raio); cursor: pointer;
  font-weight: 700; color: var(--texto-2); background: #fff; margin: 0;
}
.seletor-temp label small { font-weight: 500; font-size: .74rem; color: var(--texto-3); }
.seletor-temp input:focus-visible + label { outline: 3px solid var(--azul); outline-offset: 2px; }
.seletor-temp input[value=frio]:checked + label { border-color: var(--frio); background: #eaf1fd; color: var(--frio); }
.seletor-temp input[value=morno]:checked + label { border-color: var(--morno); background: #fff7df; color: #8a6400; }
.seletor-temp input[value=quente]:checked + label { border-color: var(--quente); background: #fdecea; color: var(--quente); }

/* Selos */
.temp { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: .78rem; font-weight: 700; }
.temp-frio { background: #eaf1fd; color: var(--frio); }
.temp-morno { background: #fff3cc; color: #8a6400; }
.temp-quente { background: #fdecea; color: var(--quente); }
.selo { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: .76rem; font-weight: 700; background: #eceef5; color: var(--texto-2); }
.selo-verde { background: #e3f8dc; color: var(--oliva); }
.selo-azul { background: #e9e8fd; color: var(--azul); }
.selo-terra { background: #f8ebe3; color: var(--terra); }
.selo-vermelho { background: #fdecea; color: var(--perigo); }

/* Alertas */
.alerta { padding: 12px 14px; border-radius: var(--raio); margin-bottom: 14px; border-left: 4px solid; background: #fff; }
.alerta-sucesso { border-color: var(--verde-esc); background: #effbea; }
.alerta-erro { border-color: var(--perigo); background: #fdf1f1; }
.alerta-aviso { border-color: var(--morno); background: #fff8e5; }
.alerta-info { border-color: var(--azul); background: #f0effe; }
.alerta ul { margin: 6px 0 0; padding-left: 18px; }

/* Tabelas: viram cartões no celular */
.tabela-rolagem { overflow-x: auto; }
table.tabela { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tabela th { text-align: left; font-size: .8rem; color: var(--texto-3); font-weight: 600; padding: 8px 10px; border-bottom: 1.5px solid var(--linha); white-space: nowrap; }
.tabela td { padding: 11px 10px; border-bottom: 1px solid #eceef5; vertical-align: middle; }
.tabela tr:hover td { background: #fafbfe; }
.tabela .num { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 760px) {
  .tabela-cartoes thead { display: none; }
  .tabela-cartoes, .tabela-cartoes tbody, .tabela-cartoes tr, .tabela-cartoes td { display: block; width: 100%; }
  .tabela-cartoes tr { background: #fff; border: 1px solid var(--linha); border-radius: var(--raio); padding: 10px 12px; margin-bottom: 10px; }
  .tabela-cartoes td { border: 0; padding: 3px 0; display: flex; gap: 10px; justify-content: space-between; }
  .tabela-cartoes td::before { content: attr(data-r); color: var(--texto-3); font-size: .8rem; font-weight: 600; }
  .tabela-cartoes td:first-child { font-weight: 700; font-size: 1rem; }
  .tabela-cartoes td:first-child::before { content: none; }
}

/* Indicadores do painel */
.indicadores { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 18px; }
@media (min-width: 900px) { .indicadores { grid-template-columns: repeat(4, 1fr); gap: 14px; } }
.ind { background: var(--superficie); border: 1px solid var(--linha); border-radius: var(--raio-lg); padding: 14px 16px; text-decoration: none; color: inherit; display: block; }
.ind strong { display: block; font-size: 1.9rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.ind span { font-size: .85rem; color: var(--texto-2); }
.ind.destaque { background: var(--navy); color: #fff; border-color: var(--navy); }
.ind.destaque span { color: #c4c3ee; }
.ind.destaque strong { color: var(--verde); }
.grade-graficos { display: grid; grid-template-columns: 1fr; gap: 18px; }
@media (min-width: 900px) { .grade-graficos { grid-template-columns: 1fr 1fr; } }
.grafico { position: relative; height: 260px; }

/* Filtros */
.filtros { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
.filtros .campo label { font-size: .8rem; }
@media (min-width: 900px) { .filtros { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); } }

/* ---------- Kanban ---------- */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; scroll-snap-type: x mandatory; align-items: flex-start; }
.k-coluna {
  flex: 0 0 86%; max-width: 320px; scroll-snap-align: start;
  background: #e4e7f1; border-radius: var(--raio-lg); padding: 10px; border-top: 4px solid var(--cor, var(--azul));
}
@media (min-width: 700px) { .k-coluna { flex-basis: 280px; } }
.k-titulo { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 10px; font-weight: 700; }
.k-titulo .qtd { background: #fff; border-radius: 20px; padding: 0 9px; font-size: .8rem; }
.k-lista { min-height: 80px; display: flex; flex-direction: column; gap: 8px; }
.k-card {
  background: #fff; border-radius: var(--raio); padding: 11px 12px; border: 1px solid var(--linha);
  border-left: 5px solid var(--frio); cursor: grab; text-decoration: none; color: inherit; display: block;
}
.k-card.t-morno { border-left-color: var(--morno); }
.k-card.t-quente { border-left-color: var(--quente); }
.k-card:active { cursor: grabbing; }
.k-card .k-nome { font-weight: 700; display: block; }
.k-card .k-emp { font-size: .86rem; color: var(--texto-2); display: block; }
.k-card .k-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; font-size: .78rem; color: var(--texto-3); }
.k-card.expirando { box-shadow: 0 0 0 2px var(--quente); }
.k-card .novo { background: var(--verde); color: var(--navy); }
.sortable-ghost { opacity: .35; }
.sortable-drag { transform: rotate(2deg); }

/* ---------- Linha do tempo: o histórico do lead como uma rota ---------- */
.rota { list-style: none; margin: 0; padding: 0; position: relative; }
.rota::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; border-left: 3px dotted #b7c7b0; }
.rota li { position: relative; padding: 0 0 16px 30px; }
.rota li::before {
  content: ""; position: absolute; left: 0; top: 4px; width: 17px; height: 17px; border-radius: 50%;
  background: #fff; border: 3px solid var(--verde-esc);
}
.rota li.t-atribuicao::before { border-color: var(--azul); }
.rota li.t-parecer::before { background: var(--verde); border-color: var(--verde); }
.rota li.t-coluna::before { border-color: var(--terra); }
.rota li.t-aguardando::before, .rota li.t-redistribuicao::before { border-color: var(--quente); }
.rota li:last-child { padding-bottom: 0; }
.rota .quando { font-size: .78rem; color: var(--texto-3); }
.rota .texto { white-space: pre-line; }

/* Detalhe do lead */
.detalhe { display: grid; grid-template-columns: 1fr; gap: 18px; }
@media (min-width: 1000px) { .detalhe { grid-template-columns: 1.2fr 1fr; } }
dl.dados { display: grid; grid-template-columns: 1fr; gap: 10px 18px; margin: 0; }
@media (min-width: 600px) { dl.dados { grid-template-columns: 1fr 1fr; } }
dl.dados dt { font-size: .78rem; color: var(--texto-3); font-weight: 600; }
dl.dados dd { margin: 0; font-weight: 600; word-break: break-word; }
.foto-fachada { border-radius: var(--raio); max-height: 260px; object-fit: cover; width: 100%; }
.prazo { padding: 10px 14px; border-radius: var(--raio); background: #f0effe; margin-bottom: 14px; font-weight: 600; }
.prazo.urgente { background: #fdecea; color: var(--perigo); }

/* Paginação */
.paginacao { display: flex; gap: 6px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.paginacao a, .paginacao span { min-width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--raio-sm); border: 1px solid var(--linha); background: #fff; text-decoration: none; color: var(--texto); }
.paginacao .atual { background: var(--navy); color: #fff; border-color: var(--navy); }

.vazio { text-align: center; padding: 40px 18px; color: var(--texto-2); }
.vazio h2 { color: var(--texto); }

/* Diálogo */
dialog { border: 0; border-radius: var(--raio-lg); padding: 22px; width: min(460px, 92vw); box-shadow: 0 20px 60px rgba(1, 0, 61, .35); }
dialog::backdrop { background: rgba(1, 0, 61, .5); }
dialog .botoes { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }

/* ---------- Tela de acesso ---------- */
.acesso { min-height: 100vh; display: grid; grid-template-columns: 1fr; background: var(--navy); }
.acesso-arte { display: none; position: relative; overflow: hidden; color: #fff; padding: 48px; }
.acesso-arte svg.trajeto { position: absolute; inset: 0; width: 100%; height: 100%; }
.acesso-arte .frase { position: relative; max-width: 420px; margin-top: auto; }
.acesso-arte .frase h2 { font-size: 2.3rem; font-weight: 800; line-height: 1.1; margin-bottom: 14px; }
.acesso-arte .frase p { color: #c4c3ee; font-size: 1.05rem; }
.acesso-form { background: var(--fundo); display: flex; align-items: center; justify-content: center; padding: 28px 18px; }
.acesso-form .cartao { width: 100%; max-width: 400px; }
.acesso-form .logo-acesso { height: 46px; margin-bottom: 26px; }
.acesso-form h1 { font-size: 1.6rem; }
@media (min-width: 900px) {
  .acesso { grid-template-columns: 1.1fr 1fr; }
  .acesso-arte { display: flex; flex-direction: column; }
  .acesso-form { border-radius: 28px 0 0 28px; }
}

/* Impressão / PDF vertical */
@media print {
  @page { size: A4 portrait; margin: 14mm; }
  body { background: #fff; font-size: 11pt; }
  .topo, .menu, .menu-fundo, .fab, .nao-imprimir, .filtros { display: none !important; }
  .conteudo { margin: 0; padding: 0; max-width: none; }
  .caixa { border: 0; padding: 0; break-inside: avoid; }
  .tabela td, .tabela th { padding: 4px 6px; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Destaque rápido em campos preenchidos automaticamente (GPS / Receita) */
.preenchido { background: #effbea !important; border-color: var(--verde-esc) !important; transition: background .6s; }
