/* FARO — visual portado do referencia-radar.html + peças novas (kit no header, banner de login, modal, paywall) */
:root {
  --azul: #1d4ed8; --laranja: #ea580c; --cinza: #64748b;
  --verde: #16a34a; --vermelho: #dc2626; --fundo: #f4f6f9;
  --card: #ffffff; --borda: #e2e8f0; --texto: #0f172a; --texto2: #55657a;

  /* sombra em camadas (receita Excalidraw), sobre o --texto #0f172a em vez de
     borda solta ou blur unico */
  --shadow-island: 0px 0px 1px 0px rgba(15,23,42,.17), 0px 0px 3px 0px rgba(15,23,42,.08), 0px 7px 14px 0px rgba(15,23,42,.05);
  --shadow-island-stronger: 0px 0px 1px 0px rgba(15,23,42,.17), 0px 0px 3px 0px rgba(15,23,42,.08), 0px 7px 14px 0px rgba(15,23,42,.18);
  --shadow-modal: 0px 100px 80px rgba(15,23,42,.07), 0px 41.7776px 33.4221px rgba(15,23,42,.0503198), 0px 22.3363px 17.869px rgba(15,23,42,.0417275), 0px 12.5216px 10.0172px rgba(15,23,42,.035), 0px 6.6501px 5.32008px rgba(15,23,42,.0282725), 0px 2.76726px 2.21381px rgba(15,23,42,.0196802);

  /* escala de z-index nomeada (receita Excalidraw): usar var(--z-...) sempre,
     nunca numero magico solto */
  --z-sticky: 10; --z-dropdown: 20; --z-gate: 25; --z-overlay: 30; --z-modal: 40;
  --z-popover: 50; --z-tooltip: 60; --z-toast: 70; --z-max: 80;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--fundo); color: var(--texto); display: flex; flex-direction: column; }

/* ---------- header ---------- */
header { position: relative; background: #0f172a; color: #fff; padding: 10px 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; z-index: var(--z-sticky); }
header h1 { font-size: 17px; font-weight: 800; letter-spacing: .3px; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
header h1 svg { flex: none; }
header .sub { font-size: 11px; color: #94a3b8; }
#selKit { flex: 1 1 150px; min-width: 0; max-width: 300px; background: #1e293b; color: #fff; border: 1px solid #334155; border-radius: 8px; padding: 8px; font-size: 13px; font-weight: 600; cursor: pointer; }
#contador { background: var(--azul); color: #fff; font-weight: 700; font-size: 13px; padding: 5px 12px; border-radius: 999px; white-space: nowrap; }
#contaWrap { display: flex; align-items: center; margin-left: auto; }
#btnConta { background: var(--azul); border: 1px solid var(--azul); color: #fff; border-radius: 999px; padding: 7px 14px; font-size: 13px; font-weight: 700; cursor: pointer; }

/* peças que o auth.js monta no header */
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--azul); color: #fff; font-weight: 800; font-size: 15px; display: flex; align-items: center; justify-content: center; border: 2px solid #334155; cursor: pointer; text-transform: uppercase; }
.menu-conta { position: absolute; right: 10px; top: calc(100% + 6px); background: #fff; color: var(--texto); border: 1px solid var(--borda); border-radius: 10px; box-shadow: var(--shadow-island-stronger); padding: 8px; z-index: var(--z-dropdown); min-width: 210px; }
.menu-conta .quem { font-size: 12px; color: var(--texto2); padding: 6px 10px; border-bottom: 1px solid var(--borda); margin-bottom: 4px; word-break: break-all; }
.menu-conta button { width: 100%; text-align: left; border: none; background: none; padding: 9px 10px; border-radius: 6px; font-size: 13px; font-weight: 600; color: var(--texto); cursor: pointer; }
.menu-conta button:hover { background: #f1f5f9; }

/* ---------- banner "entre pra salvar" ---------- */
#banner-login { background: #dbeafe; color: #1e3a8a; padding: 8px 14px; font-size: 13px; display: flex; gap: 10px; align-items: center; border-bottom: 1px solid #bfdbfe; }
#banner-login[hidden] { display: none; }
#banner-login span { flex: 1; min-width: 0; }
#banner-login button.primario { padding: 6px 14px; font-size: 12.5px; }
#banner-login .fechar { background: none; border: none; color: #1e3a8a; font-size: 14px; padding: 4px 6px; cursor: pointer; }

/* ---------- layout ---------- */
#app { flex: 1; display: flex; min-height: 0; }
#painel { width: 400px; max-width: 100%; display: flex; flex-direction: column; background: var(--fundo); border-right: 1px solid var(--borda); }
/* Leaflet uses z-index 200–1000 internally. Keep those layers inside the map
   so they cannot cover login, onboarding, checkout or other app overlays. */
#mapa { position: relative; z-index: 0; flex: 1; min-height: 0; background: #dbe3ec; }

#controles { padding: 10px 12px; background: var(--card); border-bottom: 1px solid var(--borda); display: flex; flex-direction: column; gap: 8px; }
.linha { display: flex; gap: 6px; align-items: center; }
.linha input[type=text] { flex: 1; padding: 9px 10px; border: 1px solid var(--borda); border-radius: 8px; font-size: 14px; min-width: 0; }
button { cursor: pointer; border: 1px solid var(--borda); background: #fff; border-radius: 8px; padding: 8px 10px; font-size: 13px; font-weight: 600; color: var(--texto); font-family: inherit; }
button:active { transform: scale(.97); }
button.primario { background: var(--azul); border-color: var(--azul); color: #fff; }
#btnGeo { white-space: nowrap; }

#raioLinha { display: flex; align-items: center; gap: 10px; }
#raioLinha input[type=range] { flex: 1; accent-color: var(--azul); }
#raioVal { font-weight: 800; font-size: 15px; min-width: 64px; text-align: right; color: var(--azul); }

.chips { display: flex; gap: 5px; flex-wrap: wrap; }
.chip { font-size: 11.5px; font-weight: 700; padding: 5px 9px; border-radius: 999px; border: 1.5px solid var(--borda); background: #fff; color: var(--texto2); cursor: pointer; user-select: none; }
.chip.on { color: #fff; background: #0f172a; border-color: #0f172a; }

/* ---------- lista ---------- */
#lista { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.item { background: var(--card); border: 1px solid var(--borda); border-radius: 10px; padding: 10px 12px; }
.item.visitado { border-left: 4px solid var(--verde); }
.item.descartado { opacity: .45; }
.item .topo { display: flex; align-items: baseline; gap: 8px; }
.item .dist { font-size: 13px; font-weight: 800; color: var(--azul); white-space: nowrap; }
.item .nome { font-size: 14px; font-weight: 700; line-height: 1.25; }
.item .fant { color: var(--texto2); font-weight: 500; font-size: 12px; }
.item .meta { font-size: 12px; color: var(--texto2); margin-top: 3px; }
.item .dono { font-size: 12.5px; margin-top: 3px; }
.item .dono button { background: none; border: 0; padding: 0; font: inherit; font-weight: 700; color: var(--azul); cursor: pointer; }
.item .tags { display: flex; gap: 4px; margin-top: 5px; flex-wrap: wrap; }
.tag { font-size: 10px; font-weight: 800; padding: 2px 7px; border-radius: 4px; letter-spacing: .3px; }
.tag.seg { background: #e2e8f0; color: #475569; } /* cor real vem inline, por grupo de CNAE */
.tag.mg { background: #dcfce7; color: #166534; }
.tag.fil { background: #fef9c3; color: #854d0e; }
.tag.prec { background: #fee2e2; color: #991b1b; }
.item .acoes { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.acoes a, .acoes button { text-decoration: none; font-size: 12.5px; font-weight: 700; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--borda); background: #f8fafc; color: var(--texto); }
.acoes a.tel { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }
.acoes a.zap { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.acoes button.ck.on { background: var(--verde); border-color: var(--verde); color: #fff; }
.acoes button.x.on { background: var(--vermelho); border-color: var(--vermelho); color: #fff; }
.acoes button.primario { background: var(--azul); border-color: var(--azul); color: #fff; }
.item textarea { width: 100%; margin-top: 7px; border: 1px dashed var(--borda); border-radius: 8px; padding: 6px 8px; font-size: 12.5px; font-family: inherit; resize: vertical; min-height: 30px; display: none; }
.item textarea.aberta, .item textarea.tem { display: block; }

/* estados especiais da lista */
.item.aviso { color: var(--texto2); font-size: 13px; }
.item.paywall-faixa { border: 1.5px solid #bfdbfe; background: #eff6ff; font-size: 13px; }
.item.paywall-faixa b { color: var(--azul); }

/* nudge "começa por essa" + mensagem pronta (obra de conversão 29/08) */
.item.nudge { border: 1.5px solid #fcd34d; background: #fffbeb; position: relative; }
.nudge-x { position: absolute; top: 4px; right: 6px; border: 0; background: none; font-size: 16px; color: #92400e; cursor: pointer; padding: 4px 6px; line-height: 1; }
.nudge-t { font-size: 13.5px; }
.nudge-m { font-size: 12px; color: #92400e; margin-top: 3px; }
.nudge-bt { border: 1px solid #f59e0b; background: #f59e0b; color: #0f172a; font-weight: 800; font-size: 13px; padding: 8px 12px; border-radius: 9px; cursor: pointer; font-family: inherit; }
.acoes-grid .msgp { grid-column: 1 / -1; background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.msgp-txt { width: 100%; border: 1px solid var(--borda); border-radius: 10px; padding: 9px 10px; font-size: 13.5px; font-family: inherit; line-height: 1.45; resize: vertical; margin: 6px 0 10px; }
.msgp-teaser { display: block; width: 100%; text-align: left; border: 1px dashed #bfdbfe; background: #eff6ff; color: var(--texto); font-size: 12px; border-radius: 9px; padding: 8px 10px; margin: 0 0 10px; cursor: pointer; font-family: inherit; line-height: 1.4; }
.msgp-teaser b { color: var(--azul); }
.msgp-acoes { display: flex; flex-direction: column; gap: 8px; }

#rodape { padding: 8px 12px; background: var(--card); border-top: 1px solid var(--borda); display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--texto2); }
#rodape button { font-size: 12px; padding: 6px 10px; }

/* ---------- popup do mapa ---------- */
.leaflet-popup-content { font-family: inherit; font-size: 13px; margin: 10px 12px; }
.leaflet-popup-content b { font-size: 13.5px; }
.pop-acoes { display: flex; gap: 6px; margin-top: 8px; }
.pop-acoes a { text-decoration: none; font-weight: 700; font-size: 12px; padding: 5px 9px; border-radius: 7px; background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }

/* ---------- modal (login do auth.js / planos do paywall.js) ---------- */
.modal-fundo { position: fixed; inset: 0; background: rgba(15,23,42,.55); display: flex; align-items: center; justify-content: center; z-index: var(--z-overlay); padding: 16px; }
.modal { position: relative; background: #fff; border-radius: 14px; padding: 20px; width: 100%; max-width: 400px; box-shadow: var(--shadow-modal); }
.modal h2 { font-size: 17px; margin-bottom: 4px; }
.modal p { font-size: 13px; color: var(--texto2); margin-bottom: 12px; }
.modal input[type=email], .modal input[type=text], .modal input[type=tel], .modal input[type=number] { width: 100%; padding: 10px 12px; border: 1px solid var(--borda); border-radius: 8px; font-size: 15px; margin: 6px 0; }
.modal .acoes-modal { display: flex; gap: 8px; margin-top: 12px; }
.modal .acoes-modal button { flex: 1; padding: 10px; font-size: 14px; }
.modal .fechar { position: absolute; top: 10px; right: 10px; border: none; background: none; font-size: 15px; color: var(--texto2); padding: 6px; cursor: pointer; }
.modal .erro { color: var(--vermelho); font-size: 12.5px; margin-top: 6px; }

/* planos do paywall */
.planos { display: flex; gap: 10px; margin: 12px 0; }
.plano { flex: 1; border: 1.5px solid var(--borda); border-radius: 12px; padding: 14px 12px; text-align: center; cursor: pointer; background: #fff; }
.plano:hover, .plano.escolhido { border-color: var(--azul); background: #eff6ff; }
.plano .preco { font-size: 20px; font-weight: 800; color: var(--azul); }
.plano .periodo { font-size: 11.5px; color: var(--texto2); font-weight: 700; }
.plano .selo { display: inline-block; margin-top: 6px; font-size: 10px; font-weight: 800; background: #dcfce7; color: #166534; padding: 2px 8px; border-radius: 999px; }

/* toast (ex.: "Bem-vindo ao PRO 🎉") */
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #0f172a; color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 700; font-size: 13.5px; z-index: var(--z-toast); box-shadow: var(--shadow-island-stronger); }

/* ---------- mobile: página inteira rola (scroll nativo), nada de janelinha interna ---------- */
@media (max-width: 820px) {
  html, body { height: auto; }
  body { display: block; }
  header { position: sticky; top: 0; }
  #app { flex-direction: column-reverse; }
  #painel { width: 100%; flex: none; border-right: 0; }
  #lista { flex: none; overflow: visible; }
  #mapa { height: 38vh; flex: none; }
  #controles { position: static; }
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { white-space: nowrap; flex: none; }
  /* a barra de ações (contador · Planilha · PDF · Meus produtos) fica SEMPRE à
     vista: gruda no pé da tela durante o scroll da lista (achado do Uan 29/08 —
     com 2k empresas ela nunca aparecia e escondia a exportação da lista) */
  #rodape { position: sticky; bottom: 0; z-index: var(--z-sticky); box-shadow: var(--shadow-island); padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
  .fi-fab { bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important; }
  header h1 { font-size: 15px; }
  header .sub { display: none; }
  #selKit { order: 5; flex: 1 1 100%; max-width: none; }
  .planos { flex-direction: column; }
}

/* ============ v12: design de uso fácil (proposta aprovada 26/08) ============ */
.rotulo-passo { font-size: 11px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; color: var(--texto2); }

/* caixa de resumo da seleção (acima da lista) */
#resumo { margin: 8px 8px 0; background: #fff; border: 2px solid var(--azul); border-radius: 14px; padding: 10px 12px; box-shadow: var(--shadow-island); }
#resumo .r-n { font-size: 17px; font-weight: 900; }
#resumo .r-n b { color: var(--azul); }
#resumo .r-onde { font-size: 12px; color: var(--texto2); margin: 1px 0 8px; }
.btn-resumo-mail { display: block; width: 100%; text-align: center; background: var(--azul); color: #fff; border: none; border-radius: 10px; padding: 10px; font-weight: 800; font-size: 13.5px; cursor: pointer; font-family: inherit; }
.btn-resumo-mail small { display: block; font-weight: 600; font-size: 10.5px; opacity: .85; margin-top: 1px; }
.btn-resumo-mail:disabled { background: #cbd5e1; cursor: default; }

/* card: ações em grade com palavra */
.acoes-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.acoes-grid a, .acoes-grid button { text-decoration: none; text-align: center; font-size: 13px; font-weight: 800; padding: 9px 6px; border-radius: 10px; border: 1.5px solid var(--borda); background: #f8fafc; color: var(--texto); cursor: pointer; font-family: inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acoes-grid a.tel { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }
.acoes-grid a.zap { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.acoes-visita { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin-top: 6px; }
.acoes-visita button { font-size: 12px; font-weight: 800; padding: 8px 4px; border-radius: 10px; border: 1.5px solid var(--borda); background: #fff; color: var(--texto2); cursor: pointer; font-family: inherit; }
.acoes-visita button.ck.on { background: var(--verde); border-color: var(--verde); color: #fff; }
.acoes-visita button.x.on { background: var(--vermelho); border-color: var(--vermelho); color: #fff; }
.acoes-extra { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.acoes-extra a, .acoes-extra button { font-size: 12px; font-weight: 700; padding: 6px 9px; border-radius: 8px; border: 1px solid var(--borda); background: #f8fafc; color: var(--texto2); text-decoration: none; cursor: pointer; font-family: inherit; }

/* bottom-sheet (confirmação de e-mail / escolher rota) */
.sheet-fundo { position: fixed; inset: 0; background: rgba(15, 23, 42, .55); z-index: var(--z-overlay); display: flex; align-items: flex-end; }
.sheet-faro { background: #fff; width: 100%; max-width: 560px; margin: 0 auto; border-radius: 18px 18px 0 0; padding: 18px 16px 14px; box-shadow: var(--shadow-modal); }
.sheet-faro h3 { font-size: 16.5px; line-height: 1.35; margin: 0 0 4px; }
.sheet-faro h3 b { color: var(--azul); }
.sheet-quem { background: #f8fafc; border: 1px solid var(--borda); border-radius: 10px; padding: 8px 11px; margin: 10px 0; font-size: 12.5px; }
.sheet-quem div { padding: 3px 0; border-bottom: 1px dashed var(--borda); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-quem div:last-child { border: none; color: var(--texto2); font-weight: 700; }
.sheet-aviso { display: flex; gap: 7px; font-size: 12px; color: var(--texto2); margin: 8px 2px 10px; line-height: 1.45; }
.sheet-bt { display: block; width: 100%; text-align: center; border: none; border-radius: 11px; padding: 11px; font-weight: 800; font-size: 14px; cursor: pointer; font-family: inherit; color: #fff; background: var(--verde); }
.sheet-bt.azul { background: var(--azul); }
.sheet-bt + .sheet-bt { margin-top: 7px; }
.sheet-cancel { display: block; width: 100%; text-align: center; background: none; border: none; color: var(--texto2); font-weight: 700; padding: 10px; font-size: 13px; cursor: pointer; font-family: inherit; }
