:root {
  --gold-deep: #A8790E;
  --gold: #C89820;
  --gold-mid: #D8B048;
  --gold-light: #E8D088;
  --cream-accent: #F8F0C0;

  --black: #0B0B0C;
  --near-black: #17130A;
  --ink: #201D16;
  --ink-soft: #6B6558;

  --bg: #FAF8F2;
  --card: #FFFFFF;
  --border: rgba(11, 11, 12, 0.09);
  --border-soft: rgba(11, 11, 12, 0.06);

  --ok: #3E7D4C;
  --warn: #B4791B;
  --danger: #B33A3A;
  --muted: #9A9382;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 1px 2px rgba(20, 16, 5, 0.04), 0 8px 24px -12px rgba(20, 16, 5, 0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 600;
  margin: 0;
  color: var(--black);
}

.app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */

.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--black) 0%, var(--near-black) 100%);
  display: flex;
  flex-direction: column;
  padding: 32px 20px 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  justify-content: center;
  padding: 8px 8px 28px;
  border-bottom: 1px solid rgba(200, 152, 32, 0.18);
  margin-bottom: 20px;
}

.brand-logo {
  width: 100%;
  max-width: 152px;
  height: auto;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: rgba(240, 232, 210, 0.72);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.nav-item:hover:not(.is-disabled) {
  background: rgba(200, 152, 32, 0.10);
  color: var(--gold-light);
}

.nav-item.active {
  background: rgba(200, 152, 32, 0.16);
  border-color: rgba(200, 152, 32, 0.35);
  color: var(--gold-light);
}

.nav-item.is-disabled {
  cursor: default;
  opacity: 0.55;
}

.nav-badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(240, 232, 210, 0.10);
  color: rgba(240, 232, 210, 0.6);
  padding: 3px 7px;
  border-radius: 999px;
}

.sidebar-footer {
  font-size: 11px;
  color: rgba(240, 232, 210, 0.38);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 16px;
  border-top: 1px solid rgba(200, 152, 32, 0.14);
}

.sidebar-footer-divider { opacity: 0.5; }

.sidebar-sair {
  width: 100%;
  margin-top: 10px;
  background: none;
  border: 1px solid rgba(240, 232, 210, 0.2);
  color: rgba(240, 232, 210, 0.7);
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.sidebar-sair:hover {
  border-color: rgba(200, 152, 32, 0.5);
  color: var(--gold-light);
}

/* Content */

.content {
  flex: 1;
  min-width: 0;
  width: 100%;
  padding: 44px clamp(20px, 4vw, 56px) 64px;
}

.mobile-topbar { display: none; }
.sidebar-overlay { display: none; }

.view { display: none; }
.view.active { display: block; }

.view-header {
  margin-bottom: 28px;
}

.view-header h1 {
  font-size: 34px;
  letter-spacing: 0.01em;
}

.view-subtitle {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 14.5px;
  max-width: 620px;
  line-height: 1.5;
}

.card {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 24px 26px;
  margin-bottom: 22px;
}

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

.card-header h2 {
  font-size: 20px;
}

.quick-actions { display: flex; gap: 8px; }

/* Buttons */

.btn {
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-deep) 100%);
  color: #FFFDF6;
  box-shadow: 0 4px 14px -4px rgba(168, 121, 14, 0.55);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 6px 18px -4px rgba(168, 121, 14, 0.65);
}

.btn-primary:disabled {
  background: #D8D2C2;
  color: #8F897A;
  box-shadow: none;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--ink);
}

.btn-ghost:hover { background: var(--bg); border-color: var(--gold-mid); }

.btn-danger {
  background: var(--danger);
  color: #FFF6F4;
}

.btn-danger:hover { background: #9C3131; }

.btn-danger-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--danger);
}

.btn-danger-ghost:hover { background: rgba(179, 58, 58, 0.06); border-color: var(--danger); }

/* Estados grid */

.estados-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}

.estado-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--bg);
  transition: border-color 0.15s ease, background 0.15s ease;
  user-select: none;
}

.estado-chip:hover { border-color: var(--gold-mid); }

.estado-chip.checked {
  border-color: var(--gold);
  background: rgba(200, 152, 32, 0.07);
}

.estado-chip input { accent-color: var(--gold-deep); margin: 0; }

.estado-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.estado-dot.ok { background: var(--ok); }
.estado-dot.warn { background: var(--warn); }
.estado-dot.danger { background: var(--danger); }
.estado-dot.muted { background: var(--muted); }

.estado-chip-label {
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.estado-chip-uf { font-size: 11px; color: var(--ink-soft); font-weight: 400; }

.card-footer {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border-soft);
}

.selecao-resumo { font-size: 13px; color: var(--ink-soft); }

/* Progress */

.progresso-card { border-color: rgba(200, 152, 32, 0.35); }

.progresso-lista {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.progresso-item {
  --pct: 0%;
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  overflow: hidden;
  isolation: isolate;
}

.progresso-item span { position: relative; z-index: 2; }

.progresso-item[data-status="concluido"] { border-color: var(--ok); color: var(--ok); }
.progresso-item[data-status="erro"] { border-color: var(--danger); color: var(--danger); }

/* Estado "rodando": preenchimento cresce com o tempo decorrido (--pct, via JS)
   + brilho varrendo a borda, pra ficar óbvio que está trabalhando de verdade. */

.progresso-item[data-status="rodando"] {
  border-color: var(--gold);
  color: var(--gold-deep);
  background:
    linear-gradient(90deg, rgba(200, 152, 32, 0.28) var(--pct), transparent var(--pct)),
    var(--bg);
  transition: background 0.25s linear;
  animation: progresso-glow 1.6s ease-in-out infinite;
}

.progresso-item[data-status="rodando"]::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(115deg, transparent 35%, rgba(255, 250, 230, 0.75) 50%, transparent 65%);
  background-size: 260% 100%;
  animation: progresso-shimmer 1.7s linear infinite;
  pointer-events: none;
}

@keyframes progresso-shimmer {
  0% { background-position: 160% 0; }
  100% { background-position: -60% 0; }
}

@keyframes progresso-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(200, 152, 32, 0.0); }
  50% { box-shadow: 0 0 8px 1px rgba(200, 152, 32, 0.45); }
}

/* Filters */

.filtros-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.select, .input {
  font-family: inherit;
  font-size: 13.5px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink);
}

.input { min-width: 220px; flex: 1; }

.toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  color: var(--ink-soft);
  cursor: pointer;
}

.toggle input { accent-color: var(--gold-deep); }

/* Filtro de situação (popover com checklist, valores vêm da própria base) */

.situacao-filtro { position: relative; }

.situacao-badge {
  margin-left: 6px;
  font-size: 10.5px;
  font-weight: 700;
  background: var(--gold);
  color: #FFFDF6;
  padding: 1px 6px;
  border-radius: 999px;
}

.situacao-painel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 30;
  width: 260px;
  max-width: 80vw;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
  padding: 12px;
}

.situacao-painel-acoes {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-soft);
}

.situacao-mini-btn {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--gold-deep);
  cursor: pointer;
}

.situacao-mini-btn:hover { text-decoration: underline; }

.situacao-lista {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}

.situacao-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
  color: var(--ink);
}

.situacao-item-esquerda { display: flex; align-items: center; gap: 8px; }
.situacao-item input { accent-color: var(--gold-deep); }
.situacao-item-count { font-size: 11.5px; color: var(--ink-soft); }

.contagem {
  margin-left: auto;
  font-size: 12.5px;
  color: var(--ink-soft);
}

/* Table */

.table-wrap { overflow-x: auto; }

.tabela {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.tabela thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.tabela tbody td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
}

.tabela tbody tr:hover { background: rgba(200, 152, 32, 0.04); }

.tabela a { color: var(--gold-deep); text-decoration: none; }
.tabela a:hover { text-decoration: underline; }

.col-check { width: 34px; }

.tabela-vazio {
  padding: 34px 10px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 13.5px;
  display: none;
}

.situacao-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--ink-soft);
  white-space: nowrap;
}

/* Telefone: cada número não quebra no meio, extras ficam atrás de "ver mais" */

.tel-cell { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.tel-num { white-space: nowrap; }
.tel-extra { display: flex; flex-direction: column; gap: 3px; }
.tel-extra[hidden] { display: none; }

.tel-toggle {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--gold-deep);
  cursor: pointer;
  white-space: nowrap;
}

.tel-toggle:hover { text-decoration: underline; }

/* Alerta de inconsistência (DDD x estado) */

.alerta-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--danger);
  background: rgba(179, 58, 58, 0.08);
  border: 1px solid rgba(179, 58, 58, 0.25);
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
  margin-top: 3px;
  cursor: help;
}

/* Observações */

.observacoes-card { padding: 0; }

.observacoes-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  padding: 18px 26px;
  cursor: pointer;
}

.observacoes-chevron { color: var(--ink-soft); transition: transform 0.15s ease; }
.observacoes-toggle.open .observacoes-chevron { transform: rotate(180deg); }

.observacoes-lista {
  padding: 0 26px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.observacao-linha {
  display: flex;
  gap: 10px;
  font-size: 13px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border-soft);
}

.observacao-uf {
  font-weight: 700;
  width: 30px;
  flex-shrink: 0;
  color: var(--ink);
}

.observacao-texto { color: var(--ink-soft); line-height: 1.45; }
.observacao-texto strong { color: var(--ink); font-weight: 600; }

/* Lote bar (Prospectar) */

.lote-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
}

#lote-contagem { font-size: 13px; font-weight: 600; color: var(--ink); }
.lote-dica { font-size: 12.5px; color: var(--ink-soft); }

/* Disparo Meta */

.disparo-card { border-color: rgba(200, 152, 32, 0.3); }

.disparo-desc {
  font-size: 13.5px;
  color: var(--ink-soft);
  margin: 0 0 16px;
  line-height: 1.5;
}

.disparo-modelo-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.disparo-select { flex: 1; min-width: 220px; }

.select:disabled, .input:disabled, .btn:disabled { opacity: 0.6; cursor: not-allowed; }

.disparo-info {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 16px;
}

.disparo-info p {
  font-size: 12.5px;
  color: var(--ink-soft);
  margin: 0 0 8px;
  line-height: 1.5;
}

.disparo-info p:last-child { margin-bottom: 0; }

.disparo-resumo {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13.5px;
  color: var(--ink-soft);
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
}

.disparo-resumo-numero {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--gold-deep);
}

.disparo-acoes {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.empty-state {
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.6;
  padding: 40px 26px;
  text-align: center;
}

/* Modal */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 11, 12, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-overlay[hidden] { display: none; }

.modal {
  background: var(--card);
  border-radius: var(--radius);
  padding: 26px 28px;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 20px 60px -12px rgba(11, 11, 12, 0.45);
}

.modal h3 {
  font-size: 21px;
  margin-bottom: 12px;
}

.modal p {
  font-size: 13.5px;
  color: var(--ink-soft);
  line-height: 1.55;
  margin: 0 0 10px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

/* Popup grande de "buscando", com anel de progresso central */

.modal-buscando {
  max-width: 560px;
  padding: clamp(28px, 5vw, 48px) clamp(24px, 6vw, 48px) 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.ring {
  --pct: 0;
  width: clamp(150px, 34vw, 220px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(var(--gold) calc(var(--pct) * 1%), rgba(11, 11, 12, 0.08) 0);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background 0.3s linear;
  margin-bottom: 22px;
  flex-shrink: 0;
}

.ring::before {
  content: '';
  position: absolute;
  inset: clamp(10px, 2.4vw, 16px);
  border-radius: 50%;
  background: var(--card);
  box-shadow: inset 0 0 0 1px var(--border-soft);
}

.ring::after {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0%, rgba(200, 152, 32, 0.55) 12%, transparent 24%);
  animation: anel-varredura 1.4s linear infinite;
  opacity: 0.9;
  z-index: -1;
}

@keyframes anel-varredura {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.ring-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.ring-pct {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: clamp(30px, 7vw, 44px);
  font-weight: 700;
  color: var(--gold-deep);
  line-height: 1;
}

.ring-label {
  font-size: 11.5px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.buscando-titulo { font-size: clamp(20px, 4vw, 25px); margin-bottom: 6px; }

.buscando-subtitulo {
  font-size: 13.5px;
  color: var(--ink-soft);
  margin: 0 0 20px;
  max-width: 380px;
}

.progresso-lista-modal {
  justify-content: center;
  max-height: 180px;
  overflow-y: auto;
  width: 100%;
  padding: 2px;
}

.modal-actions-center { justify-content: center; width: 100%; }

/* Mobile topbar + sidebar como gaveta */

@media (max-width: 900px) {
  .app { flex-direction: column; }

  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: linear-gradient(180deg, var(--black) 0%, var(--near-black) 100%);
    position: sticky;
    top: 0;
    z-index: 40;
  }

  .mobile-topbar-logo { height: 30px; width: auto; }

  .mobile-menu-btn {
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid rgba(200, 152, 32, 0.3);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    flex-shrink: 0;
  }

  .mobile-menu-btn span {
    width: 16px;
    height: 2px;
    background: var(--gold-light);
    border-radius: 2px;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 240px;
    height: 100vh;
    z-index: 60;
    transition: left 0.22s ease;
  }

  .sidebar.open { left: 0; }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(11, 11, 12, 0.5);
    z-index: 50;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  .sidebar-overlay.visible { opacity: 1; pointer-events: auto; }

  .content { padding: 24px 16px 48px; }

  .view-header h1 { font-size: 27px; }

  .card { padding: 18px 16px; }

  .filtros-bar { flex-direction: column; align-items: stretch; }
  .input { min-width: 0; }
  .contagem { margin-left: 0; }

  .card-header { flex-direction: column; align-items: flex-start; }
  .quick-actions { width: 100%; }
  .quick-actions .btn { flex: 1; }
}
