:root {
  --navy: #001260;
  --brand: #1D71B9;
  --gray: #706F6F;
  --mist: #DFE0E2;
  --bg: #f6f8fb;
  --erro: #c0392b;
  --ok: #1e8449;
}
* { box-sizing: border-box; }
/* Garante que o atributo HTML [hidden] sempre esconda, mesmo em elementos
   cuja classe define display (modal, filtros, faixas). */
[hidden] { display: none !important; }
body {
  font-family: "Raleway", system-ui, sans-serif;
  margin: 0; color: var(--navy); background: var(--bg);
}

/* Header */
header {
  background: #fff; border-bottom: 1px solid var(--mist);
  padding: 10px 20px; display: flex; align-items: center; gap: 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
header .logo { height: 34px; width: auto; display: block; }
header .header-titulo { font-weight: 700; color: var(--brand); font-size: 15px; letter-spacing: .3px; }
header #usuario { margin-left: auto; font-size: 14px; color: var(--gray); font-weight: 500; }

/* Layout */
section { padding: 24px 20px; max-width: 1120px; margin: 0 auto; }
h2 { font-weight: 800; color: var(--navy); }
h3 { font-weight: 700; color: var(--navy); margin: 0 0 4px; }

/* Card de login */
.card {
  max-width: 380px; margin: 56px auto; display: flex; flex-direction: column; gap: 10px;
  background: #fff; padding: 28px; border-radius: 16px;
  border: 1px solid var(--mist); box-shadow: 0 4px 18px rgba(0,18,96,0.06);
}
.card h2 { text-align: center; margin: 4px 0 8px; }

/* Inputs */
input, select {
  padding: 12px 14px; font-size: 14px; font-family: inherit;
  border: 2px solid var(--mist); border-radius: 12px; background: #fff; color: var(--navy);
  transition: border-color .15s;
}
input:focus, select:focus { outline: none; border-color: var(--brand); }
input::placeholder { color: #a9acb3; }

/* Botoes */
button {
  padding: 12px 16px; font-size: 14px; font-weight: 700; font-family: inherit;
  background: var(--navy); color: #fff; border: 0; border-radius: 12px; cursor: pointer;
  transition: background .15s, opacity .15s;
}
button:hover { background: #062a8c; }
button:disabled { opacity: .4; cursor: default; }
.btn-ghost {
  background: transparent; color: var(--brand); border: 2px solid var(--mist);
  padding: 8px 14px; font-size: 13px;
}
.btn-ghost:hover { background: #eef3f8; }

.msg { min-height: 18px; font-size: 14px; color: var(--erro); font-weight: 600; }
a { color: var(--brand); font-weight: 600; text-decoration: none; }
a:hover { text-decoration: underline; }
#link-toggle { text-align: center; font-size: 14px; }

/* Consulta direta de CNPJ */
.consulta-cnpj {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #fff; border: 1px solid var(--mist); border-radius: 14px;
  padding: 14px 16px; margin-bottom: 18px; box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.consulta-cnpj strong { color: var(--navy); }
.consulta-cnpj input { flex: 1; min-width: 220px; }

/* Grade de produtos (cards estilo "opcao" Rev) */
.produtos { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px,1fr)); gap: 12px; margin-top: 8px; }
.produtos .prod {
  background: #fff; border: 2px solid var(--mist); border-radius: 14px;
  padding: 22px 16px; text-align: center; cursor: pointer; color: var(--navy);
  font-weight: 700; transition: border-color .15s, background .15s, transform .05s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.produtos .prod:hover { border-color: var(--brand); background: rgba(29,113,185,0.05); }
.produtos .prod:active { transform: translateY(1px); }
.produtos .prod-avancado { background: var(--brand); color: #fff; border-color: var(--brand); }
.produtos .prod-avancado:hover { background: #155a93; color: #fff; }
/* Selo de potencial do lead */
.pot { display: inline-block; padding: 2px 9px; border-radius: 9px; font-size: 11px; font-weight: 700; }
.pot-alto { background: #1e8449; color: #fff; }
.pot-medio { background: #f0ad4e; color: #4a2f00; }
.pot-baixo { background: var(--mist); color: var(--gray); }

/* Atalhos de recem-abertas */
.presets { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--gray); }
.presets .btn-ghost { padding: 6px 10px; font-size: 12px; }
#f-atividade-wrap { width: 100%; }
#f-atividade { width: 100%; }

/* Filtros */
.filtros {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  background: #fff; padding: 16px; border-radius: 14px; border: 1px solid var(--mist);
  margin: 16px 0; box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.filtros h3 { width: 100%; }
.faixas { display: flex; flex-wrap: wrap; gap: 10px; width: 100%; align-items: center; font-size: 14px; color: var(--gray); }
.faixas label { display: inline-flex; align-items: center; gap: 4px; font-weight: 500; color: var(--navy); }
.filtros > label { font-size: 14px; color: var(--navy); display: inline-flex; align-items: center; gap: 6px; }
#btn-exportar { background: var(--brand); }
#btn-exportar:hover { background: #155a93; }
#btn-voltar, #btn-admin-voltar { background: transparent; color: var(--gray); border: 2px solid var(--mist); }
#btn-voltar:hover, #btn-admin-voltar:hover { background: #eef3f8; }

#resultado-info { color: var(--navy); font-weight: 700; }

/* Tabelas */
#tabela-wrap { overflow: auto; max-height: 64vh; border-radius: 12px; border: 1px solid var(--mist); background: #fff; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { border-bottom: 1px solid var(--mist); padding: 9px 10px; text-align: left; white-space: nowrap; }
th { background: var(--navy); color: #fff; position: sticky; top: 0; font-weight: 600; font-size: 12px; }
tbody tr:nth-child(even) { background: #fafbfd; }
tbody tr:hover { background: rgba(29,113,185,0.06); }
#tabela-pendentes { background: #fff; border-radius: 12px; overflow: hidden; }
#tabela-pendentes button { padding: 6px 12px; font-size: 12px; margin-right: 6px; }
.btn-det { padding: 5px 10px; font-size: 12px; background: var(--brand); }
.btn-det:hover { background: #155a93; }

/* Link de WhatsApp (celulares) */
.wa-link {
  display: inline-block; background: #25D366; color: #fff; font-weight: 700;
  font-size: 11px; padding: 2px 8px; border-radius: 8px; margin-left: 6px; white-space: nowrap;
}
.wa-link:hover { background: #1ebe5a; text-decoration: none; }

/* Modal de detalhes */
.modal { position: fixed; inset: 0; background: rgba(0,18,96,0.45); display: flex; align-items: flex-start; justify-content: center; padding: 32px 16px; z-index: 50; overflow: auto; }
.modal-box { background: #fff; border-radius: 16px; max-width: 720px; width: 100%; padding: 24px 26px; box-shadow: 0 18px 50px rgba(0,0,0,0.3); position: relative; }
.modal-x { position: absolute; top: 16px; right: 16px; }
.det-titulo { font-size: 20px; font-weight: 800; color: var(--navy); margin: 0 8px 2px 0; padding-right: 90px; }
.det-sub { color: var(--gray); font-weight: 600; margin-bottom: 16px; }
.det-secao { font-weight: 700; color: var(--brand); margin: 18px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .4px; }
.det-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; font-size: 14px; }
.det-grid .rotulo { color: var(--gray); }
.det-socio { padding: 8px 0; border-bottom: 1px solid var(--mist); font-size: 14px; }
.det-socio .nome { font-weight: 700; color: var(--navy); }
.det-socio .meta { color: var(--gray); font-size: 13px; }

/* Busca reversa por socio */
.btn-socio-empresas {
  background: transparent; color: var(--brand); border: 2px solid var(--mist);
  padding: 4px 10px; font-size: 12px; border-radius: 9px; margin-left: 6px;
}
.btn-socio-empresas:hover { background: #eef3f8; }
.socio-empresas { margin: 8px 0 4px; padding-left: 12px; border-left: 3px solid var(--mist); }
.socio-meta { color: var(--gray); font-size: 13px; padding: 6px 0; }
.socio-aviso { color: var(--gray); font-size: 12px; font-style: italic; margin-bottom: 6px; }
.socio-fones {
  background: #eef3f8; border-radius: 10px; padding: 8px 12px; margin-bottom: 10px;
  font-size: 13px; color: var(--navy); line-height: 1.9;
}
.socio-fones .sf-rotulo { font-weight: 700; color: var(--brand); margin-right: 4px; }
.socio-empresa {
  padding: 7px 10px; border: 1px solid var(--mist); border-radius: 10px;
  margin-bottom: 6px; cursor: pointer; background: #fff; transition: border-color .15s, background .15s;
}
.socio-empresa:hover { border-color: var(--brand); background: rgba(29,113,185,0.05); }
.socio-empresa .se-nome { font-weight: 700; color: var(--navy); display: block; }
.socio-empresa .se-meta { color: var(--gray); font-size: 13px; }

/* Resultados da busca por nome de socio */
#socio-resultados { margin: 0 0 18px; }
#socio-resultados:empty { margin: 0; }
.socio-lista-titulo { color: var(--navy); font-weight: 700; font-size: 14px; margin: 4px 0 8px; }
.socio-pessoa { margin-bottom: 8px; }
.btn-pessoa {
  width: 100%; text-align: left; background: #fff; color: var(--navy);
  border: 2px solid var(--mist); border-radius: 12px; padding: 12px 14px;
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
}
.btn-pessoa:hover { background: rgba(29,113,185,0.05); border-color: var(--brand); }
.btn-pessoa .pessoa-nome { font-weight: 700; }
.btn-pessoa .pessoa-meta { color: var(--brand); font-size: 13px; font-weight: 600; }
.socio-pessoa .socio-empresas { margin-top: 8px; }
.form-senha { display: flex; flex-direction: column; gap: 10px; max-width: 360px; margin-top: 14px; }

/* ===== Responsivo (smartphones) ===== */
@media (max-width: 640px) {
  header { flex-wrap: wrap; gap: 8px 10px; padding: 10px 12px; }
  header .header-titulo { font-size: 14px; }
  header #usuario { margin-left: auto; font-size: 13px; }
  header .btn-ghost { padding: 7px 10px; font-size: 12px; }

  section { padding: 16px 12px; }
  h2 { font-size: 20px; }

  /* tudo que e input/select/botao ocupa a largura toda e empilha */
  .consulta-cnpj { gap: 8px; }
  .consulta-cnpj strong { width: 100%; }
  .consulta-cnpj input,
  .consulta-cnpj button { width: 100%; min-width: 0; }

  .produtos { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .produtos .prod { padding: 16px 8px; font-size: 14px; }

  .filtros { gap: 10px; }
  .filtros h3 { font-size: 15px; }
  .filtros input:not([type="checkbox"]),
  .filtros select,
  .filtros > button { width: 100%; }
  /* checkbox + texto ("somente com contato", faixas) lado a lado, tamanho natural */
  .filtros > label,
  .faixas label { width: auto; display: inline-flex; align-items: center; gap: 6px; }
  .filtros > label input,
  .faixas label input { width: auto; }
  .faixas { gap: 8px 14px; }
  .faixas > span { width: 100%; }

  /* tabela rola na horizontal dentro da propria caixa, sem estourar a pagina */
  #tabela-wrap { max-height: 70vh; }

  /* modal de detalhes / troca de senha */
  .modal { padding: 14px 8px; }
  .modal-box { padding: 18px 14px; }
  .det-titulo { padding-right: 80px; font-size: 18px; }
  .det-grid { grid-template-columns: 1fr; }
  .form-senha { max-width: 100%; }
}
