* { box-sizing: border-box; }

:root {
  --black: #0a0a0a;
  --white: #ffffff;
  --line: #e0e0e0;
  --muted: #6b6b6b;
  --danger: #c0392b;
  --radius: 6px;
  --container: 560px;
}

body {
  font-family: 'Inter', -apple-system, Arial, sans-serif;
  font-weight: 300;
  background: #fafafa;
  margin: 0;
  color: var(--black);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.site-header {
  background: var(--white);
  padding: 1.4rem 1.2rem;
  text-align: center;
  border-bottom: 1px solid var(--line);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.site-header .logo { height: 50px; }

.sair-link {
  position: absolute;
  right: 1.2rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 0.82rem;
  text-decoration: none;
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: var(--radius);
  transition: color 0.15s, border-color 0.15s;
}
.sair-link:hover { color: var(--black); border-color: var(--black); }

main.container {
  max-width: var(--container);
  width: 100%;
  margin: 0 auto;
  padding: 1.4rem 1rem 3rem;
}

img, video, canvas, svg { max-width: 100%; }

h1, h2, h3 { font-family: 'Playfair Display', serif; font-weight: 700; color: var(--black); }

.page-title { font-size: 1.5rem; margin: 0 0 1.2rem; text-align: center; }

.panel-title {
  margin: 0 0 1rem;
  font-size: 1.05rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--line);
}

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.3rem;
  margin: 0 0 1.2rem;
}

.auth-card { margin-top: 1.5rem; }

label {
  display: block;
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  margin: 0.9rem 0 0.35rem;
  font-size: 0.98rem;
  color: var(--black);
}
label:first-of-type { margin-top: 0; }

input[type="text"], input[type="password"], input[type="date"], select, textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: none;
  font-size: 1rem;
  font-family: 'Inter', sans-serif;
  color: var(--black);
  background: var(--white);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--black);
}

textarea { min-height: 140px; resize: vertical; }

.fixed-value {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f5f5f5;
  color: var(--black);
  font-size: 1rem;
}

.hint { color: var(--muted); font-size: 0.88rem; margin: 0.2rem 0 1rem; text-align: center; }

.alert-error {
  background: #fdf0f0;
  border: 1px solid #e0b4b4;
  color: var(--danger);
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius);
  font-size: 0.88rem;
  margin-bottom: 1rem;
}

.alert-success {
  background: #f0f7f0;
  border: 1px solid #b9dab9;
  color: #256029;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius);
  font-size: 0.88rem;
  margin-bottom: 1rem;
}

.btn {
  display: inline-block;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  border: 1px solid var(--black);
  background: transparent;
  color: var(--black);
  transition: background 0.15s, color 0.15s;
}
.btn:hover { background: var(--black); color: var(--white); }
.btn-primary { background: var(--black); color: var(--white); }
.btn-primary:hover { background: #2a2a2a; }
.btn-outline { background: transparent; color: var(--black); }
.btn-small { padding: 6px 12px; font-size: 0.82rem; }
.btn-block { width: 100%; margin-top: 1.4rem; }
.btn:disabled { background: #bbb; border-color: #bbb; color: #fff; cursor: not-allowed; }

.footer-link { text-align: center; margin-top: 1.4rem; }
.footer-link a { color: var(--muted); font-size: 0.82rem; text-decoration: none; }
.footer-link a:hover { color: var(--black); }

.tabnav {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1.2rem;
  border-bottom: 1px solid var(--line);
}
.tabnav a {
  padding: 0.6rem 0.2rem;
  margin-right: 1rem;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.92rem;
  border-bottom: 2px solid transparent;
}
.tabnav a.active, .tabnav a:hover { color: var(--black); border-bottom-color: var(--black); }

.tabnav-scroll {
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding-bottom: 1px;
}
.tabnav-scroll a {
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 0.7rem 0.3rem;
  min-height: 44px;
  display: flex;
  align-items: center;
}
.tabnav-scroll::-webkit-scrollbar { height: 3px; }
.tabnav-scroll::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

.list { display: flex; flex-direction: column; gap: 0.6rem; }
.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: none; }
.list-row-title { font-weight: 500; }
.list-row-sub { font-size: 0.8rem; color: var(--muted); margin-top: 0.15rem; }

.checkbox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 0.8rem;
  margin-top: 0.4rem;
}
.checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: 'Inter', sans-serif;
  font-weight: 400;
  font-size: 0.9rem;
  margin: 0;
}
.checkbox-item input { width: auto; }

.radio-group, .checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.4rem;
}
.radio-item, .checkbox-line {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: 'Inter', sans-serif;
  font-weight: 400;
  font-size: 0.95rem;
}
.radio-item input, .checkbox-line input { width: auto; }
.checkbox-line.disabled { opacity: 0.45; }

.export-panel .export-fields { display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: flex-end; }
.export-panel label { display: flex; flex-direction: column; font-size: 0.8rem; color: var(--muted); gap: 0.3rem; font-family: 'Inter', sans-serif; font-weight: 400; margin: 0; }
.export-panel input, .export-panel select { padding: 0.5rem; font-size: 0.9rem; }

.loteamento h2 { border-bottom: 1px solid var(--line); padding-bottom: 0.4rem; font-size: 1.05rem; }
.count { background: var(--black); color: var(--white); border-radius: 999px; padding: 0.1rem 0.6rem; font-size: 0.78rem; font-family: 'Inter', sans-serif; }
section.loteamento { margin-bottom: 1.8rem; }

.lead-card { position: relative; padding: 1rem; }
.card-header { display: flex; justify-content: space-between; font-size: 0.82rem; color: var(--muted); margin-bottom: 0.5rem; flex-wrap: wrap; gap: 0.3rem; padding-right: 4rem; }
.corretor { font-weight: 600; color: var(--black); }
.texto { margin: 0.4rem 0; line-height: 1.45; font-size: 0.94rem; }
.badges { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.4rem 0; }
.badge { background: #f2f2f2; color: #444; font-size: 0.74rem; padding: 0.2rem 0.55rem; border-radius: 999px; font-family: 'Inter', sans-serif; }
.audio-block { margin-top: 0.6rem; }
.audio-block audio { width: 100%; }
.transcricao { font-size: 0.88rem; color: #333; background: #f7f7f7; padding: 0.6rem; border-radius: 6px; margin-top: 0.5rem; }
.transcricao-pendente { font-size: 0.83rem; color: #999; font-style: italic; }
.vazio { color: #999; font-style: italic; font-size: 0.9rem; }

.btn-excluir {
  position: absolute; top: 0.7rem; right: 0.7rem;
  background: transparent; border: 1px solid #e0b4b4; color: var(--danger);
  font-size: 0.72rem; padding: 0.15rem 0.5rem; border-radius: 999px; cursor: pointer; opacity: 0.75;
}
.btn-excluir:hover { opacity: 1; background: #fdf0f0; }

.audio-controls { display: flex; gap: 0.6rem; margin-top: 0.5rem; flex-wrap: wrap; }
.btn-record { flex: 1; min-width: 120px; }
.btn-record.recording { background: var(--danger); color: var(--white); border-color: var(--danger); animation: pulse-border 1.2s infinite; }
.btn-stop { flex: 1; min-width: 120px; }
.btn-delete { color: var(--danger); border-color: var(--danger); display: none; }
#recordStatus { font-size: 0.85rem; color: var(--muted); margin-top: 0.4rem; min-height: 1.1rem; }
.recording-indicator { display: none; align-items: center; gap: 0.5rem; margin-top: 0.6rem; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--danger); animation: pulse-dot 1.2s infinite; flex-shrink: 0; }
.rec-text { color: var(--danger); font-weight: 500; font-size: 0.95rem; }
@keyframes pulse-dot { 0% { opacity: 1; transform: scale(1); } 50% { opacity: 0.35; transform: scale(1.4); } 100% { opacity: 1; transform: scale(1); } }
@keyframes pulse-border { 0% { box-shadow: 0 0 0 0 rgba(192,57,43,0.5); } 70% { box-shadow: 0 0 0 8px rgba(192,57,43,0); } 100% { box-shadow: 0 0 0 0 rgba(192,57,43,0); } }
audio.preview { width: 100%; margin-top: 0.6rem; display: none; }

.whatsapp-help { text-align: center; margin-top: 2.2rem; }
.whatsapp-help a { display: inline-block; background: var(--white); border: 1px solid var(--line); color: #666; font-family: 'Inter', sans-serif; font-size: 0.8rem; padding: 8px 16px; border-radius: var(--radius); text-decoration: none; }

/* ---------- CRM: pilulas de estagio ---------- */
.pill {
  display: inline-block;
  font-family: 'Inter', sans-serif;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  border: 1px solid transparent;
}
.pill-novo { background: #eef0f2; color: #444; border-color: #d8dade; }
.pill-contato { background: #eaf1fb; color: #1c5fa8; border-color: #cfe0f5; }
.pill-visitou { background: #f3ecfb; color: #6a3fb5; border-color: #e1d3f5; }
.pill-negociando { background: #fdf3e0; color: #a3690a; border-color: #f6e0b4; }
.pill-fechado { background: #eaf7ec; color: #256029; border-color: #cbe9cf; }
.pill-perdido { background: #fdf0f0; color: #c0392b; border-color: #f2d0cd; }

.badge-vencido { background: #fdf0f0; color: var(--danger); border: 1px solid #e0b4b4; }

/* ---------- CRM: lista de fichas ---------- */
.lista-top { margin-bottom: 1rem; }
.filtro-estagio-row { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 1rem; }
.filtro-estagio-row label { margin: 0; font-size: 0.85rem; }
.filtro-estagio-row select { width: auto; flex: 1; padding: 8px; }

.ficha-row { cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s; }
.ficha-row:hover { border-color: var(--black); }
.ficha-row.vencido { border-color: var(--danger); background: #fffaf9; }

.footer-back { border: none; background: transparent; padding: 0.4rem 0; margin-bottom: 0.6rem; color: var(--muted); font-size: 0.9rem; }
.footer-back:hover { background: transparent; color: var(--black); }

.retorno-row { display: flex; gap: 0.6rem; margin-top: 0.4rem; flex-wrap: wrap; }
.retorno-row input[type="date"] { flex: 0 0 160px; }
.retorno-row input[type="text"] { flex: 1; min-width: 150px; }
.retorno-botoes { display: flex; gap: 0.6rem; margin-top: 0.6rem; }
.retorno-botoes .btn { flex: 1; }

#detalheAcoes label:first-of-type { margin-top: 0.9rem; }

/* ---------- CRM: selos de retorno ---------- */
.selo {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-family: 'Inter', sans-serif;
}
.selo-atrasado { background: #fdf0f0; color: var(--danger); border-color: #e0b4b4; }
.selo-hoje { background: #fdf3e0; color: #a3690a; border-color: #f6e0b4; }
.selo-em-dia { background: #eef0f2; color: #444; border-color: #d8dade; }

/* ---------- CRM: aba Retornos ---------- */
.retorno-item { padding: 1rem; }
.retorno-data-destaque {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 1.25rem;
  margin-bottom: 0.4rem;
}

/* ---------- CRM: aba Visão geral ---------- */
.kpi-row { display: flex; gap: 0.7rem; flex-wrap: wrap; margin-bottom: 0.4rem; }
.kpi-tile {
  flex: 1 1 100px;
  min-width: 100px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.9rem 0.6rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.kpi-valor {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 1.7rem;
  line-height: 1;
}
.kpi-label { font-size: 0.72rem; color: var(--muted); line-height: 1.3; }

.bar-chart { display: flex; flex-direction: column; gap: 0.5rem; }
.bar-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  padding: 0.5rem 0.4rem;
  border-radius: var(--radius);
  min-height: 44px;
  transition: background 0.15s;
}
.bar-row:hover, .bar-row:active { background: #f2f2f2; }
.bar-label {
  flex: 0 0 82px;
  font-size: 0.78rem;
  color: var(--black);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-track {
  flex: 1;
  min-width: 0;
  background: #eef0f2;
  border-radius: 999px;
  height: 14px;
  overflow: hidden;
}
.bar-fill { height: 100%; border-radius: 999px; transition: width 0.25s; }
.fill-novo { background: #9aa1ab; }
.fill-contato { background: #3a7bc8; }
.fill-visitou { background: #8a5cd6; }
.fill-negociando { background: #d99a2b; }
.fill-fechado { background: #3f9a4c; }
.fill-perdido { background: #c0392b; }
.bar-valor { flex: 0 0 26px; text-align: right; font-size: 0.82rem; font-weight: 500; }

/* ---------- CRM: ajustes mobile ---------- */
@media (max-width: 420px) {
  main.container { padding: 1.1rem 0.8rem 3rem; }
  .card { padding: 1rem 0.9rem; }
  .kpi-tile { flex: 1 1 90px; padding: 0.8rem 0.4rem; }
  .kpi-valor { font-size: 1.45rem; }
  .bar-label { flex-basis: 68px; font-size: 0.72rem; }
  .retorno-row { flex-direction: column; }
  .retorno-row input[type="date"] { flex: 1 1 auto; }
  .export-panel .export-fields { flex-direction: column; align-items: stretch; }
}
