/* Painel Zenvee — tema escuro moderno.
   CSP: style-src 'self' — nada de estilo inline; larguras dinamicas usam <progress>. */

:root {
  color-scheme: dark;
  --fundo: #0b0f14;
  --fundo-2: #10161d;
  --painel: #151d26;
  --painel-hover: #1a242f;
  --borda: #223041;
  --borda-forte: #2e4257;
  --tinta: #e6edf3;
  --tinta-2: #9fb0c0;
  --tinta-3: #64748b;
  --acento: #34d399;
  --acento-forte: #10b981;
  --acento-tinta: #052e22;
  --alerta: #fbbf24;
  --erro: #f87171;
  --info: #60a5fa;
  --raio: 12px;
  --sombra: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }

html { background: var(--fundo); }

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--tinta);
  background:
    radial-gradient(1200px 400px at 80% -10%, rgba(16, 185, 129, .07), transparent 60%),
    var(--fundo);
  min-height: 100vh;
}

a { color: var(--acento); }

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--acento);
  outline-offset: 2px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ── Topbar ─────────────────────────────────────────── */
.topo {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: .65rem 1.5rem;
  background: rgba(11, 15, 20, .85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--borda);
}

.marca {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  font-weight: 800;
  letter-spacing: .02em;
  font-size: 1rem;
  white-space: nowrap;
}

.marca::before {
  content: "";
  width: .65rem;
  height: .65rem;
  border-radius: 50%;
  background: var(--acento);
  box-shadow: 0 0 12px var(--acento);
}

.topo nav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }

.topo nav a {
  color: var(--tinta-2);
  text-decoration: none;
  font-weight: 600;
  font-size: .9rem;
  padding: .4rem .85rem;
  border-radius: 999px;
  transition: color .15s, background .15s;
}

.topo nav a:hover { color: var(--tinta); background: var(--painel-hover); }

.topo nav a.ativo {
  color: var(--acento);
  background: var(--acento-tinta);
}

.sair { display: flex; align-items: center; gap: .5rem; }

.sair button {
  border: 1px solid var(--borda-forte);
  background: transparent;
  color: var(--tinta-2);
  padding: .4rem .9rem;
  border-radius: 999px;
  font: inherit;
  font-size: .85rem;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}

.sair button:hover { color: var(--erro); border-color: var(--erro); }

.sair .trocar-senha {
  color: var(--tinta-2);
  text-decoration: none;
  font-size: .85rem;
  font-weight: 600;
  padding: .4rem .6rem;
}

.sair .trocar-senha:hover { color: var(--acento); }

.senha-cartao { margin: 1.5rem 0; }

.mensagem {
  border-radius: 8px;
  padding: .55rem .9rem;
  font-size: .9rem;
  border: 1px solid var(--borda-forte);
  background: var(--painel);
}

.mensagem-success {
  color: var(--acento);
  border-color: rgba(52, 211, 153, .35);
  background: var(--acento-tinta);
}

/* ── Conteudo ───────────────────────────────────────── */
main { padding: 1.75rem 1.5rem 3rem; max-width: 76rem; margin: 0 auto; }

h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -.01em; margin: 0 0 .35rem; }

h2 { font-size: .95rem; font-weight: 700; color: var(--tinta-2); margin: 2rem 0 .75rem; text-transform: uppercase; letter-spacing: .06em; }

section > h2:first-child { margin-top: 1.5rem; }

.atualizacao { color: var(--tinta-3); font-size: .875rem; margin-top: 0; }

/* ── Cards ──────────────────────────────────────────── */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: .9rem;
  margin: 1.25rem 0 .5rem;
}

.card {
  background: linear-gradient(180deg, var(--painel), var(--fundo-2));
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  padding: 1rem 1.1rem;
  box-shadow: var(--sombra);
}

.card h2 { margin: 0; font-size: .72rem; }

.card .valor {
  margin: .45rem 0 0;
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}

.card ul { margin: .5rem 0 0; padding-left: 1.1rem; color: var(--tinta-2); }

.card p { color: var(--tinta-2); margin: .4rem 0 0; font-size: .9rem; }

.card p.valor { color: var(--tinta); }

/* ── Tabelas ────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--fundo-2);
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  overflow: hidden;
  margin: 0 0 1.5rem;
  font-size: .9rem;
}

th, td { text-align: left; padding: .6rem .9rem; }

th {
  background: var(--painel);
  color: var(--tinta-2);
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--borda-forte);
}

td { border-bottom: 1px solid var(--borda); font-variant-numeric: tabular-nums; }

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

tbody tr { transition: background .12s; }

tbody tr:hover { background: var(--painel-hover); }

/* ── Barras de distribuicao (CSP-safe: <progress>) ──── */
progress.barra {
  appearance: none;
  -webkit-appearance: none;
  width: 9rem;
  height: .5rem;
  margin-left: .6rem;
  vertical-align: middle;
  border: none;
  border-radius: 999px;
  background: var(--borda);
  overflow: hidden;
}

progress.barra::-webkit-progress-bar { background: var(--borda); border-radius: 999px; }

progress.barra::-webkit-progress-value {
  background: linear-gradient(90deg, var(--acento-forte), var(--acento));
  border-radius: 999px;
}

progress.barra::-moz-progress-bar {
  background: linear-gradient(90deg, var(--acento-forte), var(--acento));
  border-radius: 999px;
}

/* ── Badges de status ───────────────────────────────── */
.badge {
  display: inline-block;
  padding: .12rem .6rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  border: 1px solid var(--borda-forte);
  color: var(--tinta-2);
  background: var(--painel);
  white-space: nowrap;
}

.badge-ok, .badge-concluido, .badge-resolvido, .badge-success, .badge-ativo {
  color: var(--acento);
  border-color: rgba(52, 211, 153, .35);
  background: var(--acento-tinta);
}

.badge-erro, .badge-error, .badge-expirado, .badge-bloqueado, .badge-falhou, .badge-indisponivel {
  color: var(--erro);
  border-color: rgba(248, 113, 113, .35);
  background: rgba(248, 113, 113, .08);
}

.badge-pendente, .badge-parcial, .badge-expira_em_breve, .badge-em_processamento, .badge-processando, .badge-waiting {
  color: var(--alerta);
  border-color: rgba(251, 191, 36, .35);
  background: rgba(251, 191, 36, .08);
}

/* Segmentos do CRM — um matiz por categoria (VIP dourado) */
.badge-vip {
  color: #fbbf24;
  border-color: rgba(251, 191, 36, .45);
  background: rgba(251, 191, 36, .1);
}

.badge-regular {
  color: #22d3ee;
  border-color: rgba(34, 211, 238, .35);
  background: rgba(34, 211, 238, .08);
}

.badge-novo {
  color: var(--info);
  border-color: rgba(96, 165, 250, .35);
  background: rgba(96, 165, 250, .08);
}

.badge-risco {
  color: #fb923c;
  border-color: rgba(251, 146, 60, .4);
  background: rgba(251, 146, 60, .09);
}

.badge-inativo, .badge-perdido {
  color: var(--tinta-3);
  border-color: var(--borda-forte);
  background: var(--painel);
}

/* Linhas tingidas por lifecycle (tabelas de clientes) */
tbody tr.linha-ativo { background: rgba(52, 211, 153, .08); }
tbody tr.linha-ativo:hover { background: rgba(52, 211, 153, .16); }

tbody tr.linha-novo { background: rgba(96, 165, 250, .09); }
tbody tr.linha-novo:hover { background: rgba(96, 165, 250, .17); }

tbody tr.linha-prospect { background: rgba(167, 139, 250, .09); }
tbody tr.linha-prospect:hover { background: rgba(167, 139, 250, .17); }

tbody tr.linha-inativo { background: rgba(148, 163, 184, .07); }
tbody tr.linha-inativo:hover { background: rgba(148, 163, 184, .14); }

tbody tr.linha-perdido { background: rgba(248, 113, 113, .08); }
tbody tr.linha-perdido:hover { background: rgba(248, 113, 113, .16); }

/* ── Formularios / filtros ──────────────────────────── */
.filtros {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem .9rem;
  align-items: end;
  background: var(--fundo-2);
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  padding: 1rem 1.1rem;
  margin: 1.25rem 0;
}

.filtros label {
  display: block;
  font-size: .72rem;
  font-weight: 700;
  color: var(--tinta-3);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .25rem;
}

.filtros .campo { display: flex; flex-direction: column; }

input[type="text"], input[type="number"], input[type="password"], select {
  background: var(--painel);
  border: 1px solid var(--borda-forte);
  color: var(--tinta);
  border-radius: 8px;
  padding: .45rem .7rem;
  font: inherit;
  font-size: .9rem;
  min-width: 8.5rem;
}

input::placeholder { color: var(--tinta-3); }

button[type="submit"], .botao {
  background: var(--acento-forte);
  color: #04120c;
  border: none;
  border-radius: 8px;
  padding: .5rem 1.1rem;
  font: inherit;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  transition: filter .15s;
}

button[type="submit"]:hover, .botao:hover { filter: brightness(1.12); }

a.exportar {
  color: var(--acento);
  font-weight: 700;
  font-size: .9rem;
  text-decoration: none;
  border: 1px solid rgba(52, 211, 153, .4);
  border-radius: 8px;
  padding: .45rem 1rem;
  transition: background .15s;
}

a.exportar:hover { background: var(--acento-tinta); }

/* ── Paginacao / avisos ─────────────────────────────── */
.paginacao { display: flex; gap: 1rem; margin: 0 0 1.5rem; }

.paginacao a { font-weight: 600; text-decoration: none; }

.paginacao a:hover { text-decoration: underline; }

p[role="alert"] {
  background: rgba(248, 113, 113, .08);
  border: 1px solid rgba(248, 113, 113, .3);
  color: var(--erro);
  border-radius: 8px;
  padding: .55rem .9rem;
  font-size: .9rem;
  display: inline-block;
}

/* ── Login ──────────────────────────────────────────── */
.login-corpo {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.login-cartao {
  width: 100%;
  max-width: 22rem;
  background: linear-gradient(180deg, var(--painel), var(--fundo-2));
  border: 1px solid var(--borda);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: var(--sombra);
}

.login-cartao h1 {
  display: flex;
  align-items: center;
  gap: .55rem;
  font-size: 1.2rem;
  margin-bottom: 1.25rem;
}

.login-cartao h1::before {
  content: "";
  width: .65rem;
  height: .65rem;
  border-radius: 50%;
  background: var(--acento);
  box-shadow: 0 0 12px var(--acento);
}

.login-cartao label {
  display: block;
  font-size: .78rem;
  font-weight: 700;
  color: var(--tinta-2);
  margin: .9rem 0 .3rem;
}

.login-cartao input { width: 100%; }

.login-cartao button { width: 100%; margin-top: 1.25rem; }

/* ── Responsivo ─────────────────────────────────────── */
@media (max-width: 720px) {
  .topo { flex-wrap: wrap; gap: .5rem; padding: .6rem 1rem; }
  main { padding: 1.25rem 1rem 2.5rem; }
  table { display: block; overflow-x: auto; white-space: nowrap; }
  .cards { grid-template-columns: 1fr 1fr; }
}
