/* Paleta Nova Era Drones (novaeradrones.com.br): petróleo #00303c + verde #70d44b */
:root {
  --green-900: #001d25;
  --green-700: #00303c;
  --green-600: #0a5c46;
  --green-500: #57b53a;
  --green-100: #e8f7e0;
  --accent: #70d44b;
  --bg: #f4f7f5;
  --card: #ffffff;
  --ink: #12262c;
  --muted: #5f7a74;
  --line: #dfe3eb;
  --danger: #c0392b;
  --amber: #b7791f;
  --blue: #2b6cb0;
  --purple: #6b46c1;
  --shadow: 0 1px 3px rgba(0, 48, 60, 0.10), 0 4px 12px rgba(0, 48, 60, 0.07);
  --radius: 12px;
  --col-w: 224px;
  --lane-w: 168px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 22px;
  background: linear-gradient(120deg, var(--green-700), var(--green-600));
  color: #fff;
  box-shadow: var(--shadow);
  flex-wrap: wrap;
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo-img { width: 42px; height: 42px; border-radius: 10px; }
.brand h1 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -0.2px; }
.brand .brand-accent { color: var(--accent); }
.brand .sub { margin: 2px 0 0; font-size: 12px; opacity: 0.85; }
.user-chip {
  font-size: 12.5px; font-weight: 700; color: #fff;
  background: rgba(255, 255, 255, 0.14); border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px; padding: 7px 13px; white-space: nowrap;
}

.stats { display: flex; gap: 10px; flex: 1; flex-wrap: wrap; }
.stat {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  padding: 7px 14px;
  min-width: 92px;
}
.stat .n { font-size: 17px; font-weight: 700; line-height: 1.1; }
.stat .l { font-size: 11px; opacity: 0.85; margin-top: 2px; }
.actions { display: flex; gap: 8px; }

/* ---------- Botões ---------- */
.btn {
  font: inherit; border: none; border-radius: 9px; padding: 9px 15px;
  cursor: pointer; font-weight: 600; white-space: nowrap;
  transition: transform 0.05s, filter 0.15s, background 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--green-700); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: rgba(255, 255, 255, 0.16); color: #fff; }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.26); }
.btn.danger { color: var(--danger); }
.btn.danger.ghost { background: #fbe9e7; }
.btn.danger.ghost:hover { background: #f7d9d5; }
.icon-btn {
  background: none; border: none; font-size: 18px; cursor: pointer;
  color: var(--muted); padding: 4px 8px; border-radius: 6px;
}
.icon-btn:hover { background: var(--line); }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 22px; flex-wrap: wrap; flex-shrink: 0;
}
.toolbar input[type="search"], .toolbar select {
  font: inherit; padding: 8px 12px; border: 1px solid var(--line);
  border-radius: 9px; background: #fff; color: var(--ink);
}
.toolbar input[type="search"] { flex: 1; min-width: 200px; }
.toolbar .hint { color: var(--muted); font-size: 12px; margin-left: auto; }

/* ---------- Abas Quadro/Mapa ---------- */
.view-tabs { display: flex; gap: 4px; background: #e9ede9; border-radius: 10px; padding: 3px; }
.view-tab {
  font: inherit; font-weight: 700; font-size: 13px; border: none; cursor: pointer;
  padding: 7px 14px; border-radius: 8px; background: transparent; color: var(--muted);
}
.view-tab.active { background: #fff; color: var(--green-700); box-shadow: 0 1px 2px rgba(20,53,31,0.12); }

/* ---------- Mapa ---------- */
.map-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 0 22px 18px; }
/* o atributo hidden precisa vencer o display:flex acima — senão o mapa
   aparece embaixo do quadro e cobre a tela */
.map-wrap[hidden] { display: none; }
.map-legend {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--ink); padding: 8px 2px;
}
.map-legend .map-hint { color: var(--muted); margin-left: auto; }
.pin-dot {
  display: inline-block; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.35); vertical-align: -2px;
}
.pin-dot.aprox { background: #ed8936; }
.pin-dot.exato { background: var(--green-600); }
/* isolation: as camadas internas do Leaflet têm z-index alto (400-800);
   isolar impede que elas passem na frente dos modais do CRM */
#map { flex: 1; min-height: 0; border-radius: var(--radius); box-shadow: var(--shadow); isolation: isolate; }

/* pino no mapa (divIcon do Leaflet) */
.lead-pin {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  cursor: grab;
}
.lead-pin.aprox { background: #ed8936; }
.lead-pin.exato { background: var(--green-600); }
.lead-pin.won { background: var(--green-600); }
.lead-pin.lost { background: var(--danger); }
.lead-pin.movendo { box-shadow: 0 0 0 4px rgba(112, 212, 75, 0.6); animation: pulse 1s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(112, 212, 75, 0.25); } }
.pin-flag { position: absolute; left: 10px; top: -12px; font-size: 13px; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.4)); }
.map-popup .pp-nome { font-weight: 700; font-size: 13.5px; margin-bottom: 4px; }
.map-popup .pp-linha { font-size: 12px; color: var(--muted); margin-top: 2px; }
.map-popup .pp-acoes { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.map-popup .pp-btn {
  font: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 8px; padding: 6px 10px;
}
.map-popup .pp-btn:hover { background: var(--green-100); }
.map-popup .pp-btn.primary { background: var(--accent); border-color: var(--accent); color: var(--green-700); }

/* ---------- Quadro swimlane ---------- */
.board-wrap { flex: 1; overflow: auto; padding: 0 0 24px; }
.swimboard {
  display: grid;
  grid-template-columns: var(--lane-w) repeat(8, var(--col-w));
  align-items: start;
  min-width: max-content;
}

/* Cabeçalho das colunas (etapas) */
.col-h {
  position: sticky; top: 0; z-index: 6;
  background: var(--bg);
  padding: 12px 12px 10px;
  font-weight: 700; font-size: 12.5px;
  display: flex; align-items: center; gap: 7px;
  border-bottom: 2px solid var(--line);
}
.col-h .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.corner {
  position: sticky; top: 0; left: 0; z-index: 8;
  background: var(--bg); border-bottom: 2px solid var(--line);
}

/* Rótulo da raia (coluna fixa à esquerda) */
.lane-label {
  position: sticky; left: 0; z-index: 5;
  background: var(--bg);
  padding: 12px 12px;
  border-bottom: 1px solid var(--line);
  border-right: 2px solid var(--line);
  min-height: 96px;
}
.lane-name { font-weight: 700; font-size: 13.5px; display: flex; align-items: center; gap: 6px; }
.role-badge {
  font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px;
  padding: 1px 6px; border-radius: 20px;
}
.role-badge.sdr { background: #e8f0fb; color: var(--blue); }
.role-badge.vendedor { background: var(--green-100); color: var(--green-700); }
.role-badge.outro { background: #eee; color: var(--muted); }
.lane-metrics { margin-top: 8px; display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--muted); }
.lane-metrics b { color: var(--ink); }

/* Célula (raia × etapa) */
.cell {
  border-bottom: 1px solid var(--line);
  border-right: 1px dashed #ecefec;
  padding: 8px 8px;
  min-height: 96px;
}
.cell.drop-hover { background: var(--green-100); box-shadow: inset 0 0 0 2px var(--green-500); }

/* Cores por coluna */
.st-novo .dot { background: #718096; }
.st-triagem .dot { background: var(--blue); }
.st-q_prod .dot { background: var(--green-500); }
.st-q_prest .dot { background: #2f855a; }
.st-perd_sdr .dot { background: var(--danger); }
.st-recebido .dot { background: var(--green-500); }
.st-negociacao .dot { background: var(--purple); }
.st-proposta .dot { background: var(--amber); }
.st-ganho .dot { background: var(--green-600); }
.st-perdido .dot { background: var(--danger); }
.col-h.st-q_prod, .col-h.st-q_prest { background: var(--green-100); }
.col-h.st-ganho { background: #eafaf0; }
.col-h.st-perdido, .col-h.st-perd_sdr { background: #fdece9; }

/* ---------- Card ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 10px; margin-bottom: 8px;
  box-shadow: 0 1px 2px rgba(20, 53, 31, 0.05);
  cursor: grab; transition: box-shadow 0.15s, border-color 0.15s;
}
.card:hover { box-shadow: var(--shadow); border-color: #cdd8ce; }
.card.dragging { opacity: 0.4; }
.card.won { border-left: 4px solid var(--green-600); }
.card.lost { border-left: 4px solid var(--danger); }
.card .name { font-weight: 700; font-size: 13px; margin-bottom: 2px; line-height: 1.25; }
.card .name .flag { font-size: 11px; margin-right: 3px; }
.card .row { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.card .row .ic { width: 13px; text-align: center; opacity: 0.85; flex-shrink: 0; }
.card .tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 7px; }
.tag { font-size: 10px; font-weight: 600; padding: 2px 6px; border-radius: 20px; background: var(--green-100); color: var(--green-700); }
.tag.canal.Meta { background: #eae6fb; color: #5b3fb0; }
.tag.canal.Google { background: #fde8e8; color: #c53030; }
.tag.canal.WhatsApp { background: #e3f7ec; color: #1f8a4c; }
.tag.canal.TikTok { background: #eee; color: #333; }
.tag.valor { background: #fdf3e0; color: var(--amber); }
.cell-empty { color: #b6c2b8; font-size: 11px; text-align: center; padding: 6px 0; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 53, 31, 0.45);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
/* O atributo hidden precisa vencer o display:flex acima */
.modal-backdrop[hidden] { display: none; }
.modal {
  background: #fff; border-radius: 16px; width: 640px; max-width: 100%;
  max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal.narrow { width: 460px; }
.modal.wide { width: 760px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 18px 20px; overflow-y: auto; }

/* Classificação do SDR */
.classify {
  background: var(--green-100); border-radius: 10px; padding: 10px 12px; margin-bottom: 16px;
}
.classify-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--green-700); }
.seg { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.seg-opt {
  display: flex; align-items: center; gap: 6px; cursor: pointer;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 11px; font-size: 12.5px; font-weight: 600; color: var(--ink);
}
.seg-opt input { margin: 0; }
.seg-opt.produtor:has(input:checked) { border-color: var(--green-500); background: #eafaf0; }
.seg-opt.prestador:has(input:checked) { border-color: var(--amber); background: #fdf6e8; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.grid .full { grid-column: 1 / -1; }
.section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; margin-top: 4px;
}
label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); }
label input, label select, label textarea {
  font: inherit; font-weight: 500; color: var(--ink);
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
label input:focus, label select:focus, label textarea:focus {
  outline: none; border-color: var(--green-500); box-shadow: 0 0 0 3px var(--green-100);
}
/* Autocompletar de cidades (dropdown próprio — datalist nativo falha no Safari) */
.ac-wrap { position: relative; }
.ac-box {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 70;
  background: #fff; border: 1px solid var(--line); border-radius: 9px;
  box-shadow: var(--shadow); max-height: 224px; overflow-y: auto; margin-top: 3px;
}
.ac-box[hidden] { display: none; }
.ac-item { padding: 9px 12px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--ink); }
.ac-item:hover, .ac-item.sel { background: var(--green-100); }
.ac-empty { padding: 9px 12px; font-size: 12px; color: var(--muted); }

.req { color: var(--danger); font-weight: 700; }
.req-hint { font-weight: 500; color: var(--muted); text-transform: none; }
.meta-line { margin-top: 14px; font-size: 11px; color: var(--muted); }
.meta-line .chip { display: inline-block; background: var(--green-100); color: var(--green-700);
  padding: 2px 8px; border-radius: 20px; margin-right: 6px; font-weight: 600; }
.modal-foot { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); }
.modal-foot .spacer { flex: 1; }

/* ---------- Equipe ---------- */
.muted-note { font-size: 12.5px; color: var(--muted); margin: 0 0 14px; line-height: 1.5; }
.team-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.team-row {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px;
}
.team-row .tname { font-weight: 600; flex: 1; }
.team-row.inactive { opacity: 0.5; }
.team-add { display: flex; gap: 8px; }
.team-add input { flex: 1; font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.team-add select { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.team-empty { color: var(--muted); font-size: 12.5px; text-align: center; padding: 10px; }
.team-row .tlogin { color: var(--muted); font-weight: 500; font-size: 11px; }
.team-row select { font: inherit; font-size: 12px; padding: 5px 6px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.role-badge.outro { background: #ede9fe; color: var(--purple); }
.user-add { display: grid; grid-template-columns: 1.4fr 1fr 1fr auto auto; gap: 8px; }
.user-add input, .user-add select { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

/* ---------- Campanhas ---------- */
.settings-row {
  display: flex; align-items: flex-end; gap: 10px; margin-bottom: 14px;
  background: #f6f8f6; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
.settings-row label.inline { flex: 1; }
.btn.small { padding: 8px 12px; font-size: 12.5px; }
.btn.primary.small { background: var(--green-600); color: #fff; }
.camp-add { display: grid; grid-template-columns: 2fr 1fr 1.4fr auto; gap: 8px; margin-bottom: 14px; }
.camp-add input, .camp-add select {
  font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.camp-list { display: flex; flex-direction: column; gap: 10px; }
.camp-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.camp-item.inactive { opacity: 0.55; }
.camp-item .camp-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.camp-item .cname { font-weight: 700; }
.camp-code {
  font-family: ui-monospace, Menlo, monospace; font-size: 12px; font-weight: 700;
  background: var(--green-100); color: var(--green-700); border-radius: 6px; padding: 2px 7px;
}
.camp-item .camp-head .spacer { flex: 1; }
.camp-link {
  display: flex; align-items: center; gap: 8px; margin-top: 8px;
}
.camp-link input {
  flex: 1; font: inherit; font-size: 12px; color: var(--muted);
  padding: 7px 9px; border: 1px dashed var(--line); border-radius: 8px; background: #fafcfa;
}
.camp-link .lbl { font-size: 11px; font-weight: 700; color: var(--muted); width: 86px; flex-shrink: 0; }
.camp-warn { font-size: 12px; color: var(--amber); margin-top: 6px; }
.camp-report { overflow-x: auto; }
.camp-report table { border-collapse: collapse; width: 100%; font-size: 13px; margin-top: 8px; }
.camp-report th, .camp-report td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); }
.camp-report th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }
.camp-report td.num, .camp-report th.num { text-align: right; }
.camp-report tr.best td { background: #eafaf0; }
.tag.campanha { background: #f3e8fd; color: var(--purple); }

/* ---------- Aviso de senha padrão ---------- */
.warn-bar {
  background: #fdecea; color: #a12a1c; border-bottom: 1px solid #f5c6bd;
  padding: 9px 22px; font-size: 13px; font-weight: 600; cursor: pointer; text-align: center;
}
.warn-bar:hover { background: #fbddd8; }
.warn-bar[hidden] { display: none; }

/* ---------- Relatório diário ---------- */
.report-controls { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 14px; }
.report-totals { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.rt-card { flex: 1; min-width: 110px; background: #f6f8f6; border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 14px; }
.rt-n { font-size: 20px; font-weight: 800; color: var(--green-700); }
.rt-l { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ---------- Importação ---------- */
#importFile { font: inherit; margin: 6px 0 12px; width: 100%; }
.import-actions { margin-bottom: 12px; }
.import-result .import-ok { color: var(--green-700); font-weight: 700; margin-top: 6px; }
.import-result .import-bad { color: var(--amber); font-weight: 700; margin-top: 10px; }
.import-list { margin: 6px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--muted); max-height: 180px; overflow-y: auto; }
.import-list li { margin-bottom: 3px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--green-900); color: #fff; padding: 11px 18px; border-radius: 10px;
  font-weight: 600; box-shadow: var(--shadow); z-index: 80; font-size: 13px;
}

@media (max-width: 620px) {
  .grid { grid-template-columns: 1fr; }
  .stats { order: 3; width: 100%; }
}
