:root {
  /* Cores Stone (via stone-cores.css vendorada). Lib canônica: stone-cores/. */
  /* Verde Stone (#00d700) é vivo demais p/ texto ou fundo c/ texto branco;
     fica como accent (--green-vivid). Ramp interativo usa verdes escuros legíveis. */
  --green-900: var(--stone-verde-escuro);    /* #00461e */
  --green-700: var(--stone-verde-escuro);    /* #00461e — hover/dark */
  --green-500: var(--stone-verde-escuro-2);  /* #007d00 — verde interativo */
  --green-50:  var(--stone-cinza-0);         /* #f5fff5 */
  --green-vivid: var(--stone-verde);         /* #00d700 — Verde Stone (accent) */
  --gray-900: var(--stone-preto);            /* #1e281e */
  --gray-700: var(--stone-cinza-3);          /* #505a50 */
  --gray-600: var(--stone-cinza-3);          /* #505a50 — texto muted legível */
  --gray-400: var(--stone-cinza-2);          /* #96a096 */
  --gray-300: var(--stone-cinza-1);          /* #c8d2c8 */
  --gray-200: var(--stone-cinza-1);          /* #c8d2c8 */
  --gray-100: var(--stone-cinza-0);          /* #f5fff5 */
  --gray-50:  var(--stone-cinza-0);          /* #f5fff5 */
  --red-600: var(--stone-vermelho);          /* #f54141 */
  --red-50: #fef2f2;                          /* tint funcional de erro (fora da paleta) */
  --amber-100: #fef3c7;                       /* tint funcional de alerta */
  --amber-800: #92400e;                       /* texto de alerta (contraste) */
  --topbar-height: 56px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* Ícones de linha (lucide-style) */
.ic { width: 1em; height: 1em; display: inline-block; vertical-align: -0.14em; flex-shrink: 0; }
.nav-icon .ic { width: 18px; height: 18px; }
.stage-icon .ic { width: 20px; height: 20px; }
.v-header-icon .ic { width: 24px; height: 24px; }
.k-col-title .ic { width: 16px; height: 16px; }
.flame .ic { width: 12px; height: 12px; vertical-align: -0.12em; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.5;
}

.hidden { display: none !important; }
.muted { color: var(--gray-600); font-size: 14px; }
.warn { color: var(--red-600); font-size: 12px; }

/* Loading + Auth */
.loading-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  color: var(--gray-600);
}

.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 16px;
  padding: 48px 40px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
}

.auth-brand {
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--green-500);
  margin-bottom: 24px;
  font-size: 14px;
}

.auth-card h1 {
  font-size: 24px;
  margin-bottom: 12px;
}

.auth-card p {
  color: var(--gray-600);
  margin-bottom: 24px;
}

/* App shell — topbar fixa em cima, conteudo abaixo (sem sidebar lateral). */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.topbar {
  height: var(--topbar-height);
  background: var(--stone-verde-escuro); /* verde escuro Stone (era preto #1e281e) */
  border-bottom: 1px solid rgba(0, 215, 0, .12);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.topbar-brand {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  height: 32px;
  text-decoration: none;
  color: inherit;
  padding: 0 4px;
  border-radius: 6px;
}
.topbar-brand img {
  height: 22px; width: auto; display: block;
  filter: brightness(0) invert(1);
}
.topbar-brand:hover { background: #2a2a2a; }

.topbar-nav {
  display: flex;
  flex-direction: row;
  gap: 4px;
  flex: 1 1 auto;
}

.nav-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  color: var(--gray-300);
  text-decoration: none;
  border-radius: 8px;
  font-size: 13px;
  transition: background .12s, color .12s;
  line-height: 1;
}
.nav-item:hover { background: #2a2a2a; color: white; }
.nav-item.active { background: var(--green-500); color: white; }
.nav-icon { font-size: 15px; display: inline-flex; }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
}
.topbar-user .user-email { color: rgba(255,255,255,.65); }
.topbar-user .btn-ghost {
  color: rgba(255,255,255,.75);
  border-color: rgba(255,255,255,.12);
  background: transparent;
}
.topbar-user .btn-ghost:hover {
  background: rgba(255,255,255,.08);
  color: white;
  border-color: rgba(255,255,255,.2);
}

/* Theme switcher (Atual / macOS / macOS Inter) — capsula transparente com borda
   verde sutil sobre topbar verde escuro Stone. */
.theme-switcher {
  display: inline-flex;
  background: rgba(255, 255, 255, 0);
  border: 1px solid rgba(0, 215, 0, .1);
  border-radius: 32px;
  padding: 2px;
  gap: 2px;
  box-shadow: none;
}
.theme-opt {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .3px;
  color: #dae2dd;
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 999px;
  border: 0;
  transition: background .15s ease, color .15s ease;
}
.theme-opt:hover { color: white; background: rgba(0, 215, 0, .08); }
.theme-opt.active { background: var(--stone-verde); color: var(--stone-verde-escuro); }

/* Tweaks de cores Stone — 4 swatches circulares pra permutar paleta de accent.
   Cor ativa ganha anel branco translucido. */
.tweak-swatches {
  display: inline-flex;
  gap: 6px;
  padding: 4px 6px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 999px;
}
.tweak-sw {
  width: 16px; height: 16px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.18);
  cursor: pointer;
  padding: 0;
  transition: transform .12s ease, box-shadow .15s ease;
}
.tweak-sw:hover { transform: scale(1.12); }
.tweak-sw.active {
  box-shadow: 0 0 0 2px var(--gray-900), 0 0 0 4px rgba(255,255,255,.9);
}

.user-email {
  font-size: 13px;
  color: var(--gray-600);
}

.content {
  flex: 1;
  padding: 32px 24px;
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
}

/* Page */
.page-header {
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 28px;
  font-weight: 700;
}

.page-subtitle {
  color: var(--gray-600);
  font-size: 14px;
  margin-top: 4px;
}

/* Metrics */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  padding: 20px;
}

.metric-label {
  font-size: 12px;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-bottom: 8px;
}

.metric-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}

.metric-sub {
  font-size: 12px;
  color: var(--gray-600);
}

/* Card */
.card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.card-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-900);
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 10px 20px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.btn-primary {
  background: var(--green-500);
  color: white;
}

.btn-primary:hover {
  background: var(--green-700);
}

.btn-ghost {
  background: transparent;
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}

.btn-ghost:hover {
  background: var(--gray-100);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}

/* Editor visual: modo edicao, outline em hover, painel lateral, modal de export. */
body.ve-mode { cursor: crosshair; }
body.ve-mode .ve-hovering {
  outline: 2px dashed #3b82f6 !important;
  outline-offset: 2px !important;
}
body.ve-mode .ve-selected {
  outline: 2px solid var(--stone-verde) !important;
  outline-offset: 2px !important;
}
body.ve-mode #visual-editor,
body.ve-mode #visual-editor *,
body.ve-mode #ve-export-modal,
body.ve-mode #ve-export-modal *,
body.ve-mode #editor-toggle { cursor: default !important; }

.visual-editor {
  position: fixed;
  top: 72px; right: 16px;
  width: 320px;
  max-height: calc(100vh - 100px);
  background: #ffffff;
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,.18);
  z-index: 9000;
  display: flex; flex-direction: column;
  font-size: 13px;
  overflow: hidden;
}
.visual-editor .ve-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
}
.visual-editor .ve-head strong { font-size: 13px; }
.visual-editor .ve-close {
  background: transparent; border: none; cursor: pointer;
  font-size: 22px; line-height: 1; color: var(--gray-600); padding: 0 4px;
}
.visual-editor .ve-hint {
  padding: 24px 14px; color: var(--gray-600); font-size: 12px; text-align: center;
}
.visual-editor .ve-target { padding: 12px 14px; overflow-y: auto; flex: 1; }
.visual-editor .ve-target-row {
  display: flex; align-items: center; gap: 6px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 6px 8px;
  margin-bottom: 12px;
}
.visual-editor .ve-target-row code {
  flex: 1; font-size: 12px; color: var(--green-700);
  background: transparent; padding: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.visual-editor .ve-step {
  width: 22px; height: 22px;
  border: 1px solid var(--gray-300);
  background: white; border-radius: 6px; cursor: pointer;
  font-size: 12px; color: var(--gray-700);
}
.visual-editor .ve-step:hover { color: var(--green-700); }
.visual-editor .ve-props { display: flex; flex-direction: column; gap: 10px; }
.visual-editor .ve-row {
  display: grid; grid-template-columns: 70px 1fr; align-items: center; gap: 10px;
}
.visual-editor .ve-row > span:first-child {
  font-size: 11px; color: var(--gray-600); font-weight: 600;
  text-transform: uppercase; letter-spacing: .4px;
}
.visual-editor .ve-color-wrap { display: flex; align-items: center; gap: 6px; }
.visual-editor .ve-color-wrap input[type="color"] {
  width: 28px; height: 28px; padding: 0; border: 1px solid var(--gray-200); border-radius: 6px; cursor: pointer;
}
.visual-editor .ve-color-wrap input[type="range"],
.visual-editor .ve-range-wrap input[type="range"] { flex: 1; height: 16px; }
.visual-editor .ve-range-wrap { display: flex; align-items: center; gap: 8px; }
.visual-editor .ve-range-wrap output { font-size: 11px; color: var(--gray-700); min-width: 36px; }
.visual-editor .ve-shadow-wrap { display: flex; align-items: center; gap: 6px; }
.visual-editor .ve-actions {
  display: flex; gap: 6px; margin-top: 14px; padding-top: 12px;
  border-top: 1px solid var(--gray-200);
}
.visual-editor .ve-foot {
  padding: 10px 14px;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
  text-align: right;
}

#editor-toggle.active {
  background: var(--stone-verde);
  color: var(--stone-verde-escuro);
  border-color: var(--stone-verde);
}

/* Modal de exportacao do CSS. */
.ve-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 9100; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.ve-modal-content {
  background: white; border-radius: 12px; padding: 20px;
  max-width: 720px; width: 100%; max-height: 80vh; display: flex; flex-direction: column;
}
.ve-modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.ve-modal-head h3 { font-size: 16px; }
.ve-modal textarea {
  flex: 1; min-height: 280px; width: 100%;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px;
  padding: 12px; border: 1px solid var(--gray-200); border-radius: 8px;
  background: #f8fafc; color: #0f172a; resize: vertical;
}
.ve-modal-foot { display: flex; justify-content: flex-end; margin-top: 12px; }

/* Botao discreto de filtro no header da tabela Resumo (ao lado do nome da coluna).
   Quase invisivel em estado idle; ganha cor no hover ou quando ha filtro ativo. */
.th-filter-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px;
  padding: 0; margin-left: 4px;
  background: transparent; border: none;
  color: var(--gray-300);
  cursor: pointer;
  vertical-align: -3px;
  position: relative;
  transition: color .12s ease;
}
.th-filter-btn .ic { width: 11px; height: 11px; }
.th-filter-btn:hover { color: var(--gray-700); }
.th-filter-btn.active { color: var(--green-700); }
.th-filter-badge {
  position: absolute; top: -3px; right: -6px;
  background: var(--stone-verde);
  color: var(--stone-verde-escuro);
  font-size: 9px; font-weight: 700;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 999px;
  min-width: 10px;
  text-align: center;
}
/* Popover do filtro de header: input de busca + lista scroll. */
.row-filter-pop {
  width: 240px; max-height: 320px;
  display: flex; flex-direction: column;
}
.row-filter-pop .fp-search {
  padding: 6px 10px;
  border-bottom: 1px solid var(--gray-100);
}
.row-filter-pop .fp-search input {
  width: 100%; height: 28px;
  padding: 0 8px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 13px;
}
.row-filter-pop .fp-list {
  overflow-y: auto; max-height: 220px; padding: 4px 0;
}

/* Celula com count + TPV lado a lado: "2 | 195K". Nao quebra linha. */
td.cell-ct { padding: 6px 8px; line-height: 1.2; white-space: nowrap; }
td.cell-ct .ct-n {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
td.cell-ct .ct-sep {
  display: inline-block;
  margin: 0 5px;
  color: var(--gray-300);
  font-weight: 400;
}
td.cell-ct .ct-tpv {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--gray-600);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

/* Celulas clicaveis com numero (drill-down pro modal de leads). */
td.cell-num { cursor: pointer; position: relative; }
td.cell-num:hover { background: rgba(0, 70, 30, .06); }
td.cell-num.muted:hover { background: transparent; cursor: default; }

/* =========================== Modal de lista de leads ==========================
   Drill-down a partir do Resumo. Backdrop blur + container centralizado.
   Hierarquia: eyebrow + titulo grande > 3 stats > tabela > footer.
*/
.leads-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 18, .42);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9200;
  display: flex; align-items: center; justify-content: center;
  padding: 32px 24px;
  animation: lmFade .18s ease-out;
}
@keyframes lmFade { from { opacity: 0; } to { opacity: 1; } }

.leads-modal {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 24px 70px rgba(15, 23, 18, .22), 0 0 0 1px rgba(0,0,0,.04);
  width: 100%; max-width: 880px;
  max-height: calc(100vh - 64px);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: lmSlide .22s cubic-bezier(.2,.7,.3,1);
}
@keyframes lmSlide { from { transform: translateY(8px) scale(.99); } to { transform: none; } }

.leads-modal-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px;
  padding: 22px 28px 18px;
  border-bottom: 1px solid var(--gray-100);
}
.leads-modal-eyebrow {
  display: inline-block;
  font-size: 11px; font-weight: 700; letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--green-700);
  margin-bottom: 6px;
}
.leads-modal-title h2 {
  font-size: 20px; font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--gray-900);
  line-height: 1.25;
  margin: 0;
}
.leads-modal-close {
  width: 32px; height: 32px;
  border: none; background: transparent; color: var(--gray-600);
  font-size: 22px; line-height: 1;
  border-radius: 8px; cursor: pointer; flex-shrink: 0;
  transition: background .12s ease, color .12s ease;
}
.leads-modal-close:hover { background: var(--gray-100); color: var(--gray-900); }

.leads-modal-summary {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
  padding: 18px 28px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-100);
}
.leads-summary-stat { display: flex; flex-direction: column; gap: 2px; }
.lss-label {
  font-size: 11px; font-weight: 600; letter-spacing: .4px; text-transform: uppercase;
  color: var(--gray-600);
}
.lss-value {
  font-size: 20px; font-weight: 700;
  color: var(--gray-900);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.015em;
}
.leads-modal-loading {
  grid-column: 1 / -1;
  text-align: center; color: var(--gray-600); font-size: 13px; padding: 6px 0;
}
.leads-modal-loading .dots::after {
  content: '';
  animation: lmDots 1.2s steps(4, end) infinite;
}
@keyframes lmDots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } 100% { content: ''; } }
.leads-modal-error {
  grid-column: 1 / -1;
  color: var(--red-600); font-size: 13px; padding: 6px 0;
}

.leads-modal-body { flex: 1; overflow-y: auto; }
.leads-table-wrap { padding: 0; }
.leads-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.leads-table thead th {
  position: sticky; top: 0; z-index: 1;
  background: #ffffff;
  text-align: left; padding: 10px 16px;
  font-size: 11px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
  color: var(--gray-600);
  border-bottom: 1px solid var(--gray-200);
}
.leads-table thead th.r { text-align: right; }
.leads-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
.leads-row { cursor: pointer; transition: background .12s ease; }
.leads-row:hover { background: var(--gray-50); }
.leads-row:last-child td { border-bottom: 0; }
.leads-col-name { width: 38%; }
.leads-col-tpv {
  width: 18%; text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 700; color: var(--green-700);
  letter-spacing: -0.01em;
}
.leads-col-stage { width: 18%; }
.leads-col-esp { width: 26%; }
.leads-name {
  font-weight: 600; color: var(--gray-900);
  display: flex; align-items: center; gap: 6px;
}
.leads-esp-name { color: var(--gray-900); font-weight: 500; }
.leads-sub { font-size: 12px; color: var(--gray-600); margin-top: 2px; }
.leads-fire, .leads-cal {
  display: inline-flex; align-items: center;
  width: 14px; height: 14px;
}
.leads-fire { color: #ea580c; }
.leads-cal { color: var(--stone-azul, #235096); }
.leads-fire .ic, .leads-cal .ic { width: 14px; height: 14px; }

.leads-empty {
  text-align: center; padding: 56px 24px; color: var(--gray-600);
}
.leads-empty-icon {
  display: inline-flex;
  margin: 0 auto 12px;
  color: var(--gray-400);
}
.leads-empty-icon .ic { width: 40px; height: 40px; }
.leads-empty p { font-size: 14px; }

.leads-modal-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
}
.leads-modal-hint { font-size: 12px; }

@media (max-width: 720px) {
  .leads-modal-summary { grid-template-columns: repeat(2, 1fr); }
  .leads-col-esp { display: none; }
  .leads-modal-head, .leads-modal-foot { padding-left: 20px; padding-right: 20px; }
  .leads-modal-summary { padding-left: 20px; padding-right: 20px; }
}

/* Drill-down inline na tabela Resumo: chevron + indentacao por depth. */
.row-label-wrap {
  display: inline-flex; align-items: center; gap: 6px;
}
.row-chevron {
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: none; cursor: pointer; padding: 0;
  color: var(--gray-400);
  transition: transform .15s cubic-bezier(.2,.7,.3,1), color .15s ease;
}
.row-chevron .ic { width: 14px; height: 14px; }
.row-chevron:hover { color: var(--green-700); }
.row-chevron.open { transform: rotate(90deg); color: var(--green-700); }
.row-chevron-spacer { display: inline-block; width: 18px; }

tr.child-row { background: rgba(0,70,30,.025); }
tr.child-row:hover { background: rgba(0,70,30,.05); }
tr.depth-1 td:first-child { padding-left: 28px; }
tr.depth-2 td:first-child { padding-left: 52px; }
tr.depth-1 td:first-child strong,
tr.depth-2 td:first-child strong { font-weight: 500; color: var(--gray-700); }

/* Group de controles no header do card (ex: filtro + seg de modo). */
.header-controls { display: inline-flex; align-items: center; gap: 10px; }

/* Wrap do filtro: botao + popover ancorado. */
.filter-wrap { position: relative; display: inline-block; }
.filter-wrap .icon-btn { position: relative; }
.filter-wrap .icon-btn.active {
  color: var(--green-700); border-color: var(--green-500); background: var(--green-50);
}
.filter-wrap .icon-btn:disabled,
.filter-wrap .icon-btn.muted { opacity: .35; cursor: not-allowed; }
.filter-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--stone-verde); color: var(--stone-verde-escuro);
  border-radius: 999px;
  font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
}
.filter-pop {
  position: absolute; top: calc(100% + 6px); right: 0;
  min-width: 220px;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.10);
  padding: 8px 0;
  z-index: 200;
}
.filter-pop .fp-head {
  padding: 6px 14px 8px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
  color: var(--gray-600);
  border-bottom: 1px solid var(--gray-100);
}
.filter-pop .fp-list { display: flex; flex-direction: column; padding: 6px 0; }
.filter-pop .fp-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px; cursor: pointer;
  font-size: 13px; color: var(--gray-900);
}
.filter-pop .fp-row:hover { background: var(--gray-50); }
.filter-pop .fp-row input[type="checkbox"] {
  width: 14px; height: 14px; margin: 0; accent-color: var(--green-500); cursor: pointer;
}
.filter-pop .fp-foot {
  border-top: 1px solid var(--gray-100);
  padding: 6px 10px 0;
  display: flex; justify-content: flex-end;
}

/* Botao apenas-icone, discreto. Usado pra acoes auxiliares como "atualizar". */
.icon-btn {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  color: var(--gray-600);
  cursor: pointer;
  padding: 0;
  transition: color .15s ease, background .15s ease, border-color .15s ease;
}
.icon-btn:hover { color: var(--green-700); border-color: var(--gray-300); background: var(--gray-50); }
.icon-btn:active { transform: scale(.96); }
.icon-btn .ic { width: 16px; height: 16px; }

/* Table */
table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 8px;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
}

th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-600);
  font-weight: 600;
}

td:nth-child(2),
td:nth-child(3),
td:nth-child(4),
th:nth-child(2),
th:nth-child(3),
th:nth-child(4) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

tbody tr:last-child td {
  border-bottom: none;
}

.error-box {
  background: var(--red-50);
  color: var(--red-600);
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
}

.info-box {
  background: var(--green-50);
  color: var(--green-900);
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 12px;
  border: 1px solid var(--green-500);
}

.badge-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.badge-status.pending { background: var(--gray-100); color: var(--gray-700); }
.badge-status.found { background: var(--green-50); color: var(--green-900); }
.badge-status.not-found { background: var(--amber-100); color: var(--amber-800); }
.badge-status.error { background: var(--red-50); color: var(--red-600); }
.badge-status.skip { background: var(--gray-100); color: var(--gray-600); }

.card-header > div {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Tree (hierarquia) */
.tree {
  font-size: 14px;
}

.tree-header {
  display: grid;
  grid-template-columns: 1fr 120px 160px;
  gap: 12px;
  padding: 14px 12px;
  background: var(--green-50);
  border: 1px solid var(--green-500);
  border-radius: 8px;
  margin-bottom: 12px;
  align-items: center;
}

.tree-columns {
  display: grid;
  grid-template-columns: 1fr 120px 160px;
  gap: 12px;
  padding: 8px 12px;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--gray-600);
  font-weight: 600;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--gray-200);
}

.tree-col-num { text-align: right; }

.tree-row {
  display: grid;
  grid-template-columns: 1fr 120px 160px;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-200);
  align-items: center;
}

.tree-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.tree-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}

.tree-toggle {
  cursor: pointer;
  user-select: none;
  transition: background 0.1s;
}

.tree-toggle:hover {
  background: var(--gray-50);
}

.tree-caret {
  display: inline-block;
  width: 14px;
  color: var(--gray-600);
  font-size: 10px;
  text-align: center;
}

.tree-icon {
  display: inline-block;
  width: 18px;
  text-align: center;
}

.tree-count {
  color: var(--gray-600);
  font-size: 12px;
  font-weight: normal;
}

.tree-level-1 {
  background: white;
  font-weight: 600;
}

.tree-level-2 {
  padding-left: 36px;
  background: var(--gray-50);
}

.tree-level-3 {
  padding-left: 60px;
  background: white;
  font-size: 13px;
  color: var(--gray-700);
}

.tree-children {
  margin: 0;
}

/* Linhas de lead clicáveis */
.lead-row {
  cursor: pointer;
  transition: background 0.1s;
}
.lead-row:hover {
  background: var(--gray-50);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px;
  z-index: 100;
  overflow-y: auto;
}

.modal {
  position: relative;
  background: white;
  border-radius: 16px;
  width: 100%;
  max-width: 640px;
  padding: 28px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.18);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border: none;
  background: var(--gray-100);
  color: var(--gray-700);
  border-radius: 8px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s;
}
.modal-close:hover {
  background: var(--gray-200);
}

/* Modal de feedback do dash */
#feedback-btn .ic { width: 14px; height: 14px; vertical-align: -2px; margin-right: 3px; }
#feedback-modal .modal { max-width: 520px; }
.fb-label { display: block; font-size: 12px; font-weight: 600; color: var(--gray-600); margin: 0 0 6px; }
.fb-field { width: 100%; min-width: 0; box-sizing: border-box; margin-bottom: 16px; }
.fb-textarea {
  border: 1px solid var(--gray-300); border-radius: 10px; padding: 10px 12px;
  font-size: 14px; font-family: inherit; resize: vertical; min-height: 110px; background: white;
}
.fb-textarea:focus, #feedback-modal .v-select:focus { outline: none; border-color: var(--green-700); }
.fb-field-head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 6px; }
.fb-mic {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px;
  border: 1px solid var(--gray-300); border-radius: 999px; background: white;
  font-size: 12px; font-weight: 600; color: var(--gray-700);
  font-family: inherit; cursor: pointer; transition: all .12s ease;
}
.fb-mic:hover { border-color: var(--gray-400); color: var(--gray-900); }
.fb-mic .ic { width: 14px; height: 14px; }
.fb-mic.rec { background: #fdecea; border-color: #f3b4ac; color: #b42318; }
.fb-mic.rec .fb-mic-ic { position: relative; }
.fb-mic.rec .fb-mic-ic::after {
  content: ''; position: absolute; top: -2px; right: -3px;
  width: 6px; height: 6px; border-radius: 50%; background: #d92d20;
  animation: fb-pulse 1s ease-in-out infinite;
}
@keyframes fb-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
.fb-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.fb-status { font-size: 13px; margin: 0 0 12px; }
.fb-status.fb-ok { color: var(--green-700); }
.fb-status.fb-err { color: #b42318; }

.modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-right: 40px;
  margin-bottom: 24px;
}
.modal-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--gray-900);
}

.modal-section {
  margin-bottom: 24px;
}
.modal-section:last-child {
  margin-bottom: 0;
}
.modal-section h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-600);
  font-weight: 600;
  margin-bottom: 12px;
}
.mp-tasks-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-600);
  font-weight: 600;
  margin: 16px 0 10px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px 24px;
}
.info-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 14px;
}
.info-label {
  color: var(--gray-600);
}
.info-value {
  color: var(--gray-900);
  font-weight: 500;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.unit-pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; padding: 2px 8px;
  background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: 999px;
  margin-left: 4px;
}
.unit-pill code { background: transparent; padding: 0; }

/* Ações no modal + form de lead */
.modal-actions { display: flex; gap: 8px; margin-bottom: 18px; }
.btn.danger { color: var(--red-600); border-color: #f3c0c0; }
.btn.danger:hover { background: var(--red-50); }
/* Hover dos botões Credenciar/Perder do lead: leve elevação + cor mais viva. */
.k-close-actions .btn { transition: transform .14s ease, box-shadow .14s ease, filter .14s ease; }
.k-close-actions .btn:hover { transform: translateY(-2px); box-shadow: 0 5px 16px rgba(0,0,0,.10); filter: saturate(1.4) brightness(1.03); }
.k-close-actions .btn:active { transform: translateY(0); box-shadow: none; }
/* Rótulos dos grupos de controle do Kanban (Agrupar / Fechados) */
.ctrl-label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--gray-600); font-weight: 700; align-self: center; white-space: nowrap; }
/* View-switcher (formato Kanban/Lista): encapsulado, é a escolha principal */
.seg-view { border: 1px solid var(--gray-300); padding: 3px; }
.seg-view .seg-btn { padding: 6px 12px; }
.lf-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}
.lf-field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.lf-field.lf-full { grid-column: 1 / -1; }
.lf-field > span { color: var(--gray-600); font-weight: 600; font-size: 12px; }
.lf-field input, .lf-field select {
  height: 36px; border: 1px solid var(--gray-300); border-radius: 8px;
  padding: 0 10px; font-size: 14px; font-family: inherit; background: white;
}
.lf-field input:focus, .lf-field select:focus { outline: 2px solid var(--green-vivid); border-color: var(--green-vivid); }
/* Checkbox alinhada lado a lado com o label. */
.lf-field.lf-checkbox {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding-top: 18px;
}
.lf-field.lf-checkbox input[type="checkbox"] {
  width: 16px; height: 16px;
  margin: 0; padding: 0;
  accent-color: var(--green-500);
  cursor: pointer;
}
.lf-field.lf-checkbox > span {
  font-size: 13px;
  color: var(--gray-900);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  cursor: pointer;
}
.lf-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.lf-units-wrap { margin-top: 14px; padding: 12px; background: var(--gray-50); border-radius: 10px; border: 1px solid var(--gray-200); }
.lf-units-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.lf-units-title { font-size: 12px; font-weight: 600; color: var(--gray-700); text-transform: uppercase; letter-spacing: .3px; }
.lf-units-title .muted { text-transform: none; font-weight: 400; font-size: 12px; }
.lf-unit-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.lf-unit-row:last-child { margin-bottom: 0; }
.lf-unit-idx { width: 28px; font-size: 12px; color: var(--gray-600); font-weight: 600; flex: 0 0 28px; }
.lf-unit-cnpj { flex: 1; height: 34px; border: 1px solid var(--gray-300); border-radius: 8px; padding: 0 10px; font-size: 13px; font-family: inherit; background: white; }
.lf-unit-cnpj:focus { outline: 2px solid var(--green-vivid); border-color: var(--green-vivid); }
.lf-unit-rm {
  width: 28px; height: 28px; flex: 0 0 28px;
  background: transparent; border: 1px solid var(--gray-200); border-radius: 6px;
  color: var(--gray-600); cursor: pointer; font-size: 16px; line-height: 1; padding: 0;
}
.lf-unit-rm:hover { background: #fef2f2; border-color: #fca5a5; color: var(--red-600); }

/* Timeline de tarefas */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}
.timeline-item {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 16px;
  padding: 12px 0;
  border-left: 2px solid var(--gray-200);
  margin-left: 6px;
  padding-left: 16px;
  position: relative;
}
.timeline-item::before {
  content: '';
  position: absolute;
  left: -7px;
  top: 18px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green-500);
  border: 2px solid white;
}
.timeline-date {
  font-size: 13px;
  color: var(--gray-600);
  font-variant-numeric: tabular-nums;
  padding-top: 1px;
}
.timeline-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.timeline-type {
  font-weight: 600;
  font-size: 14px;
  color: var(--gray-900);
}
.timeline-owner {
  display: block;
  font-size: 12px;
  color: var(--gray-600);
  margin-top: 2px;
}

/* ===================== FUNIL DE VENDAS ===================== */
.v-header {
  background: linear-gradient(90deg, var(--green-50), white 40%);
  border: 1px solid var(--gray-200);
  border-radius: 16px;
  padding: 20px 24px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}
.v-header-title { display: flex; align-items: center; gap: 14px; }
.v-header-icon {
  width: 48px; height: 48px; border-radius: 14px;
  background: var(--green-500); color: white;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.v-header-title h1 { font-size: 22px; font-weight: 700; }
.v-header-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--gray-100); border-radius: 10px; }
.seg-btn {
  border: none; background: transparent; cursor: pointer;
  padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 600;
  color: var(--gray-700); font-family: inherit; transition: all .12s;
}
.seg-btn:hover { color: var(--gray-900); }
.seg-btn.active { background: white; color: var(--green-700); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

/* Seletor de Visão (GVR/GV/Especialista) — controle primário */
.seg-role { background: var(--green-100, #d6f3e2); }
.seg-role .seg-btn { color: var(--green-700); }
.seg-role .seg-btn.active { background: var(--green-500); color: white; box-shadow: 0 1px 4px rgba(0,168,104,.4); }

.v-select {
  height: 36px; border: 1px solid var(--gray-300); border-radius: 10px;
  padding: 0 12px; font-size: 13px; font-family: inherit; background: white; cursor: pointer;
  min-width: 180px;
}

/* Picker hierarquico (regional > distrito > especialista) com busca. */
.h-picker { position: relative; display: inline-block; }
.h-picker-btn {
  height: 36px; min-width: 200px; max-width: 280px;
  border: 1px solid var(--gray-300); border-radius: 10px; background: white;
  padding: 0 30px 0 11px; font-size: 13px; font-family: inherit; cursor: pointer;
  text-align: left; color: var(--gray-900);
  display: inline-flex; align-items: center; gap: 8px;
  position: relative;
}
.h-picker-btn:hover { border-color: var(--gray-400); }
.h-picker-btn:hover .h-picker-ic { color: var(--green-vivid, #00a868); }
.h-picker-ic { color: var(--gray-500, #6b7280); flex-shrink: 0; }
.h-picker-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.h-picker-btn::after {
  content: ""; position: absolute; right: 12px; top: 50%;
  width: 6px; height: 6px; border-right: 1.5px solid var(--gray-600); border-bottom: 1.5px solid var(--gray-600);
  transform: translateY(-75%) rotate(45deg);
}
.h-picker-panel {
  position: absolute; z-index: 50; top: calc(100% + 6px); left: 0;
  min-width: 320px; max-width: 380px;
  background: white; border: 1px solid var(--gray-200); border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.08), 0 0 0 1px rgba(0,0,0,.02);
  display: none; overflow: hidden;
}
.h-picker.open .h-picker-panel { display: block; }
.h-picker-search {
  border-bottom: 1px solid var(--gray-200); padding: 8px 10px; background: var(--gray-50);
}
.h-picker-search input {
  width: 100%; border: none; outline: none; background: transparent;
  font-size: 13px; font-family: inherit; color: var(--gray-900);
}
.h-picker-search input::placeholder { color: var(--gray-400); }
.h-picker-list { max-height: 380px; overflow-y: auto; padding: 4px 0; }
.h-picker-row {
  display: flex; align-items: stretch; width: 100%;
}
.h-picker-row:hover { background: var(--green-50); }
.h-picker-row.lvl-regional { padding-left: 4px; }
.h-picker-row.lvl-distrito { padding-left: 20px; }
.h-picker-row.lvl-especialista { padding-left: 40px; }
.h-picker-row.lvl-all { padding-left: 4px; }

.h-picker-chev-btn, .h-picker-chev-spacer {
  width: 22px; flex: 0 0 22px; display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; cursor: pointer; padding: 0;
  color: var(--gray-600);
}
.h-picker-chev-btn:hover { color: var(--gray-900); }
.h-picker-chev {
  display: inline-block; width: 0; height: 0;
  border-top: 4px solid transparent; border-bottom: 4px solid transparent;
  border-left: 5px solid currentColor;
  transition: transform .12s ease;
}
.h-picker-chev.open { transform: rotate(90deg); }

.h-picker-item {
  flex: 1 1 auto;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 4px; font-size: 13px; cursor: pointer; color: var(--gray-900);
  border: none; background: transparent; text-align: left;
  font-family: inherit;
}
.h-picker-item:hover { background: transparent; }
.h-picker-row:hover .h-picker-item { background: transparent; }
.h-picker-item.active { background: var(--green-50); font-weight: 600; color: var(--green-700); border-radius: 6px; }
.lvl-regional .h-picker-item { font-weight: 600; color: var(--green-700); font-size: 12px; text-transform: uppercase; letter-spacing: .3px; }
.lvl-distrito .h-picker-item { color: var(--gray-900); }
.lvl-especialista .h-picker-item { color: var(--gray-700); font-size: 12.5px; }
.lvl-all .h-picker-item { font-weight: 600; }

.h-picker-empty { padding: 16px; text-align: center; color: var(--gray-400); font-size: 13px; }
.h-picker-tag {
  margin-left: auto; font-size: 11px; color: var(--gray-400);
  background: var(--gray-100); border-radius: 6px; padding: 1px 6px;
}

.badge-pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  background: var(--gray-100); color: var(--gray-700);
  font-size: 12px; font-weight: 600; margin-left: 6px;
}

.v-card-emerald {
  background: linear-gradient(90deg, var(--green-50), white 50%);
  box-shadow: 0 0 0 1px rgba(0,168,104,.2), 0 2px 8px rgba(0,0,0,.04);
}

/* Stage cards */
.stage-cards {
  display: flex; flex-wrap: nowrap;
  gap: 10px; margin-bottom: 20px;
}
.stage-card {
  display: flex; align-items: center; gap: 10px;
  background: white;
  border: 1px solid var(--green-500);
  border-radius: 12px; padding: 12px 14px;
  flex: 1 1 0; min-width: 0;
}
/* Cada card e' um box branco com moldura verde fina; sem o gradiente dos sc-*. */
.stage-cards .stage-card { background: white; }
/* Faixa: o icone vira GLIFO colorido pequeno (sem o quadrado de fundo). A cor por
   metrica e' informacao/hierarquia; o que poluia era o quadrado preenchido. */
.stage-icon {
  width: 22px; height: 22px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.stage-body { min-width: 0; flex: 1; }
.stage-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-orange .stage-icon { background: #fff1e6; color: #ea580c; }
.sc-purple .stage-icon { background: #f3e8ff; color: #9333ea; }
.sc-amber .stage-icon { background: #fef3c7; color: #d97706; }
.sc-emerald .stage-icon { background: var(--green-50); color: var(--green-700); }
.sc-orange { background: linear-gradient(135deg, #fff7f0, white); }
.sc-purple { background: linear-gradient(135deg, #faf5ff, white); }
.sc-amber { background: linear-gradient(135deg, #fffbeb, white); }
.sc-emerald { background: linear-gradient(135deg, var(--green-50), white); }
.sc-blue .stage-icon { background: #dbeafe; color: #2563eb; }
.sc-blue { background: linear-gradient(135deg, #eff6ff, white); }
.sc-red .stage-icon { background: #fee2e2; color: #dc2626; }
/* Na faixa, mantem so a COR do glifo e tira o quadrado de fundo dos sc-*. */
.stage-cards .stage-icon { background: transparent; }
.sc-red { background: linear-gradient(135deg, #fef2f2, white); }
.stage-label { font-size: 12px; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--gray-600); }
.stage-value { font-size: 22px; font-weight: 700; color: var(--gray-900); line-height: 1.1; margin: 2px 0; font-variant-numeric: tabular-nums; }
.stage-sub { font-size: 12px; color: var(--gray-600); }

/* Giro do funil: sparkline + delta */
.giro-spark { margin-top: 4px; color: #2563eb; line-height: 0; }
.giro-delta {
  display: inline-block; font-size: 11px; font-weight: 600;
  padding: 1px 6px; border-radius: 6px; margin-left: 4px;
}
.giro-delta.up { background: var(--green-50); color: var(--green-700); }
.giro-delta.down { background: #fef2f2; color: #b91c1c; }
.giro-delta.neutral { background: var(--gray-100); color: var(--gray-600); }

/* Tables (vendas) */
.table-wrap { overflow-x: auto; }
#v-district-table, #v-vend-table, #rv-table { width: 100%; border-collapse: collapse; font-size: 13px; }
#v-district-table th, #v-vend-table th, #rv-table th {
  font-size: 12px; text-transform: none; letter-spacing: 0;
  color: var(--gray-700); font-weight: 600; padding: 10px 8px;
  border-bottom: 1px solid var(--gray-200); text-align: left; white-space: nowrap;
}
#v-district-table td, #v-vend-table td, #rv-table td { padding: 9px 8px; border-bottom: 1px solid var(--gray-100); }
#v-district-table th.c, #v-vend-table th.c, #rv-table th.c, td.c { text-align: center; }
#v-district-table th.r, #v-vend-table th.r, #rv-table th.r, td.r { text-align: right; }

/* Treeview da /resultados-venda: caret e indent por profundidade. */
#rv-table .rv-toggle { display: inline-block; width: 16px; text-align: center; cursor: pointer; user-select: none; color: var(--gray-500); font-size: 10px; margin-right: 6px; vertical-align: middle; transition: transform .12s; }
#rv-table .rv-toggle:hover { color: var(--gray-900); }
#rv-table .rv-toggle.leaf { visibility: hidden; }
#rv-table .rv-toggle.open { transform: rotate(90deg); }
#rv-table tr.depth-1 td:first-child { padding-left: 30px; }
#rv-table tr.depth-2 td:first-child { padding-left: 54px; color: var(--gray-700); }
#rv-table tr.depth-3 td:first-child { padding-left: 78px; color: var(--gray-600); }
#rv-table tr.rv-loading td { font-style: italic; color: var(--gray-500); }
td.b, .b { font-weight: 700; font-variant-numeric: tabular-nums; }
td.emerald, .emerald { color: var(--green-700); }
td.green, .green { color: #16a34a; }
td.orange, .orange { color: #ea580c; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--gray-900); }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--green-50); }
tr.totals { background: var(--gray-50); border-top: 2px solid var(--gray-200); font-weight: 700; }
tr.totals td { border-bottom: none; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.st-blue { background: #3b82f6; } .st-yellow { background: #eab308; }
.st-purple { background: #a855f7; } .st-orange { background: #f97316; }
.st-emerald { background: var(--green-500); } .st-slate { background: #94a3b8; }
.st-amber { background: #f59e0b; } .st-cyan { background: #06b6d4; }

/* Celulas tier/etapa na tabela Resumo por Regional/Distrito: tons lavados (vidro)
   pra reduzir saturacao e evitar visual ludico. Os dots no header (.dot.st-*)
   herdam das regras acima e continuam saturados, dando o sinal de cor sem competir. */
td.st-slate   { background: rgba(148,163,184,.10); color: #475569; }
td.st-amber   { background: rgba(245,158,11,.10);  color: #b45309; }
td.st-orange  { background: rgba(249,115,22,.10);  color: #c2410c; }
td.st-purple  { background: rgba(168,85,247,.10);  color: #7e22ce; }
td.st-blue    { background: rgba(59,130,246,.10);  color: #1d4ed8; }
td.st-yellow  { background: rgba(234,179,8,.10);   color: #a16207; }
td.st-emerald { background: rgba(0,125,0,.08);     color: var(--stone-verde-escuro); }
td.st-cyan    { background: rgba(6,182,212,.10);   color: #0e7490; }
.st-indigo { background: #6366f1; } .st-pink { background: #ec4899; }

.cell-pill { display: inline-block; padding: 3px 8px; border-radius: 8px; font-size: 13px; line-height: 1.3; }
.cell-pill.st-blue { background: #eff6ff; color: #2563eb; }
.cell-pill.st-yellow { background: #fefce8; color: #ca8a04; }
.cell-pill.st-purple { background: #faf5ff; color: #9333ea; }
.cell-pill.st-orange { background: #fff7ed; color: #ea580c; }
.cell-pill.st-emerald { background: var(--green-50); color: var(--green-700); }
.cell-pill.st-cyan { background: #ecfeff; color: #0891b2; }
.cell-pill.st-indigo { background: #eef2ff; color: #4f46e5; }
.cell-pill.st-pink { background: #fdf2f8; color: #db2777; }
.cell-pill.st-amber { background: #fffbeb; color: #d97706; }
.cell-pill .avg { display: block; font-size: 10px; color: var(--gray-400); }
.flame { font-size: 11px; color: var(--red-600); font-weight: 600; }

/* Segments */
.seg-row { display: grid; grid-template-columns: 180px 1fr 160px; gap: 12px; align-items: center; padding: 5px 0; }
.seg-name { font-size: 13px; color: var(--gray-700); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg-bar-wrap { background: var(--gray-100); border-radius: 6px; height: 14px; overflow: hidden; }
.seg-bar { height: 100%; background: var(--green-500); border-radius: 6px; }
.seg-num { font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }

/* ===================== KANBAN ===================== */
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  border: 1px solid var(--gray-300); background: white; cursor: pointer;
  font-size: 18px; color: var(--gray-700); transition: background .12s;
}
.icon-btn:hover { background: var(--gray-100); }

.kanban-board {
  display: grid; gap: 12px; overflow-x: auto; padding-bottom: 8px;
  align-items: start;
}
.k-col {
  background: var(--gray-50); border: 1px solid var(--gray-200);
  border-radius: 12px; display: flex; flex-direction: column; min-width: 0;
}
.k-col.drop-over { outline: 2px solid var(--green-500); background: var(--green-50); }
.k-col-head {
  padding: 10px 12px; border-bottom: 1px solid var(--gray-200);
  border-left: 4px solid var(--gray-300); border-radius: 12px 12px 0 0; background: white;
}
.st-blue-head { border-left-color: #3b82f6; }
.st-yellow-head { border-left-color: #eab308; }
.st-orange-head { border-left-color: #f97316; }
.st-red-head { border-left-color: #ef4444; }
.st-slate-head { border-left-color: #94a3b8; }
.st-amber-head { border-left-color: #f59e0b; }
.st-purple-head { border-left-color: #a855f7; }
.st-indigo-head { border-left-color: #6366f1; }
.k-col-title { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; }
.k-col-count {
  margin-left: auto; background: var(--gray-100); color: var(--gray-700);
  border-radius: 999px; padding: 1px 9px; font-size: 13px; font-variant-numeric: tabular-nums;
}
.k-col-sub { font-size: 12px; color: var(--gray-600); margin-top: 4px; }
.k-col-body { padding: 8px; display: flex; flex-direction: column; gap: 8px; min-height: 80px; }

.k-card {
  background: white; border: 1px solid var(--gray-200); border-radius: 10px;
  padding: 8px 10px; cursor: pointer; transition: box-shadow .12s, transform .12s;
}
.k-card[draggable="true"] { cursor: grab; }
.k-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.k-card.dragging { opacity: .4; }
.k-card.stuck { border-left: 3px solid var(--red-600); }
.k-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; }

/* Foguinho clicavel: minimalista. So o icone, cinza claro quando off, laranja preenchido quando on. */
.k-flame {
  flex: 0 0 auto;
  width: 20px; height: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; cursor: pointer; padding: 0; margin: -1px 0 0 -1px;
  color: var(--gray-300);
  transition: color .12s, transform .1s;
}
.k-flame:hover { color: #ea580c; }
.k-flame:active { transform: scale(.9); }
.k-flame.on { color: #ea580c; }
.k-flame .ic { width: 16px; height: 16px; }
.k-flame.on .ic { fill: currentColor; }

/* Indicador de reuniao agendada (so visual, nao clicavel). Sinaliza quando
   ha follow_up_date no lead. Cor azul-discreta pra nao competir com flame. */
.k-cal {
  flex: 0 0 auto;
  width: 20px; height: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--blue-600, #2563eb);
}
.k-cal .ic { width: 16px; height: 16px; }

/* Botao de edicao no card lead - mesmo padrao minimalista do foguinho. */
.k-edit {
  flex: 0 0 auto;
  width: 20px; height: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; cursor: pointer; padding: 0; margin: -1px -1px 0 0;
  color: var(--gray-300);
  transition: color .12s, transform .1s;
}
.k-edit:hover { color: var(--green-700); }
.k-edit:active { transform: scale(.9); }
.k-edit .ic { width: 14px; height: 14px; }
.k-card-name { font-weight: 600; font-size: 13px; line-height: 1.25; }
.baleia-badge {
  display: inline-block; margin-right: 6px; font-size: 13px; vertical-align: -1px;
}
.baleia-badge.proativa { filter: hue-rotate(20deg) saturate(1.2); }

.cnpj-flag {
  display: inline-block;
  margin-left: 6px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--green-700);
  background: var(--green-50);
  border: 1px solid var(--green-500);
  border-radius: 4px;
  padding: 0 4px;
  vertical-align: 1.5px;
}
.k-badge { flex-shrink: 0; font-size: 10px !important; padding: 1px 6px !important; }
.k-card-tpv { font-weight: 700; font-size: 14px; color: var(--gray-900); margin: 3px 0 2px; font-variant-numeric: tabular-nums; }
.k-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11px; }
.k-card-foot .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.k-days { color: var(--gray-400); flex-shrink: 0; }
.k-days.stuck { color: var(--red-600); font-weight: 600; }
.k-followup {
  display: inline-flex; align-items: center; gap: 4px;
  margin: 2px 0 4px; padding: 1px 6px; border-radius: 6px;
  font-size: 11px; font-weight: 600; line-height: 1.4;
}
.k-followup span { font-size: 10px; }
.fu-overdue { background: #fee2e2; color: #b91c1c; }
.fu-today   { background: #fef3c7; color: #92400e; }
.fu-soon    { background: #fef9c3; color: #854d0e; }
.fu-future  { background: #ecfdf5; color: #047857; }
.cell-pill.fu-overdue { background: #fee2e2; color: #b91c1c; }
.cell-pill.fu-today   { background: #fef3c7; color: #92400e; }
.cell-pill.fu-soon    { background: #fef9c3; color: #854d0e; }
.cell-pill.fu-future  { background: #ecfdf5; color: #047857; }

/* Vista Lista do kanban (alternativa tabular). */
.k-list-wrap { background: var(--white); border-radius: 12px; overflow: auto; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.k-list { width: 100%; border-collapse: collapse; font-size: 13px; }
.k-list th, .k-list td { padding: 10px 12px; text-align: left; vertical-align: middle; }
.k-list thead th { background: var(--gray-50); color: var(--gray-600); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; border-bottom: 1px solid var(--gray-200); position: sticky; top: 0; z-index: 1; }
.k-list th.right, .k-list td.right { text-align: right; }
.k-list-sort { cursor: pointer; user-select: none; white-space: nowrap; }
.k-list-sort:hover { color: var(--gray-900); }
.k-list-sort .sort-arr { margin-left: 4px; color: var(--green-700); font-size: 10px; vertical-align: 1px; }
.k-list thead th .th-filter-btn { vertical-align: middle; }
/* Popover de filtro por coluna do modo lista (reusa .filter-pop / .row-filter-pop). */
.klist-filter-pop { width: 240px; }
.klist-filter-pop .fp-range { display: flex; gap: 10px; padding: 10px 12px; }
.klist-filter-pop .fp-range label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--gray-500); }
.klist-filter-pop .fp-range input { width: 92px; height: 28px; padding: 0 8px; border: 1px solid var(--gray-200); border-radius: 6px; font-size: 13px; }
.k-list tbody tr { border-bottom: 1px solid var(--gray-100); transition: background .1s; }
.k-list tbody tr.k-list-row:hover { background: var(--gray-50); cursor: pointer; }
.k-list .k-list-name { font-weight: 600; color: var(--gray-900); }
.k-list .muted { color: var(--gray-400); }
.k-list .k-flame, .k-list .k-edit { margin: 0; }
.k-badge-fora {
  display: inline-block; margin-top: 6px; font-size: 10px; font-weight: 600;
  color: var(--amber-800); background: var(--amber-100); padding: 1px 6px; border-radius: 6px;
}
.k-empty { text-align: center; padding: 24px 8px; font-size: 13px; color: var(--gray-400); }

.cp-st-blue { background: #eff6ff; color: #2563eb; }
.cp-st-yellow { background: #fefce8; color: #ca8a04; }
.cp-st-orange { background: #fff7ed; color: #ea580c; }
.cp-st-red { background: #fef2f2; color: #dc2626; }
.cp-st-slate { background: #f1f5f9; color: #475569; }
.cp-st-amber { background: #fffbeb; color: #d97706; }
.cp-st-purple { background: #faf5ff; color: #9333ea; }
.cp-st-emerald { background: var(--green-50); color: var(--green-700); }

/* Responsive */
@media (max-width: 720px) {
  .info-grid { grid-template-columns: 1fr; }
  .seg-row { grid-template-columns: 110px 1fr 120px; }
  .topbar { padding: 0 12px; gap: 12px; }
  .topbar-user .user-email { display: none; }
  .nav-item { padding: 8px 10px; }
  .nav-label { display: none; }
}

/* ===== Importar em massa: grade tipo planilha ===== */
#bulk-modal .modal { max-width: 920px; width: 96vw; }
.bulk-toolbar { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.bulk-spacer { flex: 1; }
.bulk-save { font-size: 12px; color: var(--gray-600, #6b7280); min-width: 60px; }
.bulk-grid-wrap { max-height: 52vh; overflow: auto; border: 1px solid var(--gray-200, #e5e7eb); border-radius: 10px; }
.bulk-grid { width: 100%; border-collapse: collapse; font-size: 13px; }
.bulk-grid thead th {
  position: sticky; top: 0; z-index: 1; text-align: left; white-space: nowrap;
  background: var(--gray-50, #f9fafb); color: var(--gray-600, #6b7280);
  padding: 7px 8px; font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .03em;
  border-bottom: 1px solid var(--gray-200, #e5e7eb);
}
.bulk-grid td { padding: 3px 6px; border-bottom: 1px solid var(--gray-100, #f3f4f6); }
.bulk-grid th.bulk-idx, .bulk-grid td.bulk-idx { width: 30px; text-align: center; color: var(--gray-400, #9ca3af); font-size: 11px; }
.bulk-grid td.bcell {
  padding: 6px 8px; min-width: 72px; max-width: 240px; cursor: cell; outline: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; user-select: none;
}
.bulk-grid td.bcell.active { box-shadow: inset 0 0 0 2px var(--green-500, #10b981); border-radius: 3px; }
.bulk-grid td.bcell:has(.bcell-edit) { padding: 0; overflow: visible; }
.bcell-edit {
  width: 100%; box-sizing: border-box; border: 1px solid var(--green-500, #10b981);
  border-radius: 3px; outline: none; font: inherit; font-size: 13px; padding: 4px 6px; background: #fff; color: inherit;
}
select.bcell-edit { cursor: pointer; }
.bulk-del {
  border: none; background: transparent; color: var(--gray-400, #9ca3af); font-size: 17px; line-height: 1;
  cursor: pointer; border-radius: 6px; width: 26px; height: 26px; transition: background .12s ease, color .12s ease;
}
.bulk-del:hover { background: var(--red-50, #fef2f2); color: var(--red-600, #dc2626); }
.bulk-st { white-space: nowrap; }
.bulk-badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 500px; }
.bulk-badge.new { background: var(--green-50, #ecfdf5); color: var(--green-900, #065f46); }
.bulk-badge.exists { background: var(--amber-100, #fef3c7); color: var(--amber-800, #92400e); }
.bulk-badge.upd { background: #eff6ff; color: #1d4ed8; }
.bulk-badge.skip { background: var(--gray-100, #f3f4f6); color: var(--gray-600, #6b7280); }
.bulk-badge.err { background: var(--red-50, #fef2f2); color: var(--red-600, #dc2626); }
.bulk-policy { display: flex; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.bulk-result {
  margin-top: 10px; font-size: 13px; color: var(--gray-700, #374151);
  background: var(--gray-50, #f9fafb); border: 1px solid var(--gray-200, #e5e7eb); border-radius: 8px; padding: 8px 12px;
}
.bulk-result.warn { background: var(--red-50, #fef2f2); border-color: #fecaca; color: var(--red-600, #b91c1c); }

/* ===== Distribuição do funil: dois gráficos lado a lado (funil) + cross-filter ===== */
.charts-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.chart-col { min-width: 0; border: 1px solid var(--gray-200, #e5e7eb); border-radius: 12px; padding: 18px 16px 20px; }
.chart-col.col-stage { background: var(--gray-50, #f9fafb); }
.chart-col.col-tier { background: #f4faf7; border-color: #d8efe4; }
.chart-title { text-align: center; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--gray-700, #374151); margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--gray-200, #e5e7eb); }
.col-tier .chart-title { border-bottom-color: #d8efe4; }
.hbars { display: flex; flex-direction: column; gap: 16px; max-width: 100%; }
.hbar-row { cursor: pointer; }
.hbar-cap { text-align: center; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--gray-500, #9ca3af); margin-bottom: 6px; }
.hbar-bar {
  position: relative; overflow: hidden;
  height: 30px; border-radius: 8px; margin: 0 auto; min-width: 56px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
  transition: width .35s ease, filter .12s ease, transform .12s ease;
}
.hbar-hot { position: absolute; left: 0; top: 0; bottom: 0; background: #f97316; transition: width .35s ease; }
.hbar-row:hover .hbar-bar { filter: brightness(1.06); transform: translateY(-1px); }
.hbar-row.on .hbar-cap { color: var(--gray-900, #111827); }
.hbar-row.on .hbar-bar { outline: 2px solid var(--gray-900, #111827); outline-offset: 2px; }
.hbar-row:focus-visible { outline: none; }
.hbar-row:focus-visible .hbar-bar { outline: 2px solid var(--gray-900, #111827); outline-offset: 2px; }
.hbar-in { position: relative; z-index: 1; color: #fff; font-size: 12px; font-weight: 600; white-space: nowrap; text-shadow: 0 1px 1px rgba(0,0,0,.25); }
.stack-total { margin-top: 16px; font-size: 13px; color: var(--gray-600, #6b7280); text-align: center; }
.stack-empty { padding: 40px; text-align: center; }
/* Legenda (tooltip) das barras */
.chart-tip { position: fixed; z-index: 9100; pointer-events: none; background: var(--gray-900, #111827); color: #fff; border-radius: 8px; padding: 9px 11px; font-size: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.28); min-width: 150px; }
.chart-tip.hidden { display: none; }
.chart-tip .tip-title { font-weight: 700; margin-bottom: 6px; }
.chart-tip .tip-row { display: flex; justify-content: space-between; gap: 16px; line-height: 1.6; }
.chart-tip .tip-row span { color: #cbd5e1; }
.chart-tip .tip-hot b { color: #fb923c; }
@media (max-width: 760px) { .charts-2col { grid-template-columns: 1fr; gap: 24px; } }
.chart-filter-tag { font-size: 12px; color: var(--gray-700, #374151); display: inline-flex; align-items: center; gap: 6px; }
.chart-clear { border: none; background: var(--gray-100, #f3f4f6); color: var(--gray-700, #374151); border-radius: 500px; padding: 2px 10px; font-size: 11px; font-weight: 600; cursor: pointer; }
.chart-clear:hover { background: var(--gray-200, #e5e7eb); }

/* Badge "perdido em DD/MM" no card do kanban (pendência de retrabalho em Mapeado) */
.k-lost { display: inline-block; margin-top: 4px; font-size: 11px; font-weight: 600; color: var(--red-600, #dc2626); background: var(--red-50, #fef2f2); border-radius: 6px; padding: 1px 7px; }
.k-lost-reason { font-size: 10px; color: var(--gray-600, #6b7280); margin-top: 3px; line-height: 1.3; }

/* ===== Análise de Perdas: árvore de motivos ===== */
.perda-node { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; cursor: pointer; transition: background .12s ease; }
.perda-node:hover { background: var(--gray-50, #f9fafb); }
.perda-node.active { background: var(--red-50, #fef2f2); box-shadow: inset 2px 0 0 var(--red-600, #dc2626); }
.perda-node.lvl1 { font-weight: 700; font-size: 14px; margin-top: 8px; }
.perda-node.lvl2 { padding-left: 28px; font-size: 13px; }
.perda-node.lvl3 { padding-left: 48px; font-size: 12px; color: var(--gray-700, #374151); }
.perda-node-label { flex: 0 0 42%; max-width: 42%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.perda-node-bar-wrap { flex: 1; height: 8px; background: var(--gray-100, #f3f4f6); border-radius: 4px; overflow: hidden; }
.perda-node-bar { display: block; height: 100%; background: linear-gradient(90deg, #ef6c00, #f59e0b); border-radius: 4px; transition: width .3s ease; }
.perda-node.lvl1 .perda-node-bar { background: linear-gradient(90deg, #dc2626, #ef6c00); }
.perda-node-val { flex: 0 0 auto; font-weight: 600; color: var(--gray-700, #374151); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Saudação no login: overlay de tela inteira, bem breve */
.welcome-screen {
  position: fixed; inset: 0; z-index: 9300; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0b6e4f 0%, #15a878 60%, #38c293 100%);
  animation: wsFade .55s ease forwards 1.2s; /* segura ~1.2s e some */
}
.welcome-screen-msg {
  color: #fff; font-weight: 800; text-align: center; padding: 0 24px;
  font-size: clamp(26px, 5.5vw, 48px); letter-spacing: -.02em; line-height: 1.15;
  text-shadow: 0 2px 16px rgba(0,0,0,.18);
  opacity: 0; transform: translateY(16px) scale(.94);
  animation: wsMsgIn .5s cubic-bezier(.18,.9,.32,1.2) forwards;
}
@keyframes wsMsgIn { to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes wsFade { to { opacity: 0; visibility: hidden; } }
@media (prefers-reduced-motion: reduce) {
  .welcome-screen { animation-delay: .9s; }
  .welcome-screen-msg { animation: none; opacity: 1; transform: none; }
}
