@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;700&family=Inter:wght@400;500;600;700&display=swap");

:root {
  --bg: #eeede9;
  --surface: #ffffff;
  --surface-sunken: #f6f5f2;
  --border: #e4e2dc;
  --text: #131313;
  --text-muted: #71706c;
  --text-faint: #a3a29d;

  --ink: #131313;
  --ink-text: #ffffff;
  --red: #e8231b;
  --red-soft: #fbeae9;

  --green-soft: #e7f4ea;
  --green-text: #1a7a3e;
  --blue-soft: #e8eefb;
  --blue-text: #2c5cc5;
  --amber-soft: #f7edda;
  --amber-text: #9a5f16;
  --gray-soft: #eae9e5;

  /* Sidebar/topbar/bottom-nav são sempre escuros (identidade fixa, não
     segue o tema claro/escuro do conteúdo). */
  --nav-bg: #131313;
  --nav-text: #f2f1ef;
  --nav-text-muted: #8f8e8a;
  --nav-hover: #1f1f21;

  /* Cantos generosos e consistentes — visual de app moderno. */
  --radius-xl: 26px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --radius-pill: 999px;

  --shadow-card: 0 1px 2px rgba(19, 19, 19, 0.04), 0 10px 24px -16px rgba(19, 19, 19, 0.16);
  --shadow-card-hover: 0 4px 10px rgba(19, 19, 19, 0.08), 0 20px 34px -18px rgba(19, 19, 19, 0.24);
  --shadow-pop: 0 20px 40px -20px rgba(19, 19, 19, 0.35);

  --font-display: "Space Grotesk", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;

  --sidebar-w: 232px;
  --bottomnav-h: 66px;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #060607;
  --surface: #212126;
  --surface-sunken: #2a2a30;
  --border: #34343a;
  --text: #eeeeec;
  --text-muted: #92918d;
  --text-faint: #5f5e5b;

  --ink: #eeeeec;
  --ink-text: #131313;
  --red-soft: #241715;

  --green-soft: #16241a;
  --green-text: #4ade80;
  --blue-soft: #161d2c;
  --blue-text: #7ba7f7;
  --amber-soft: #271f14;
  --amber-text: #dba85e;
  --gray-soft: #2d2d33;

  --nav-bg: #000000;
  --nav-hover: #18181c;

  --shadow-card: 0 2px 4px rgba(0, 0, 0, 0.55), 0 14px 28px -14px rgba(0, 0, 0, 0.75);
  --shadow-card-hover: 0 4px 10px rgba(0, 0, 0, 0.6), 0 22px 36px -16px rgba(0, 0, 0, 0.8);
  --shadow-pop: 0 20px 40px -20px rgba(0, 0, 0, 0.85);

  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  font-size: 14.5px;
}

html, body {
  overflow-x: hidden;
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  transition: background-color 0.2s ease, color 0.2s ease;
  overflow: hidden;
  /* `overflow: hidden` sozinho não é suficiente num PWA standalone do
     iOS — o WKWebView ainda dá bounce elástico no documento inteiro
     (é isso que "estica" a tela e espreme o topbar sticky durante o
     gesto). Travar o body como um retângulo fixo do tamanho da tela
     tira o documento da equação: só o .app-layout rola de verdade. */
  position: fixed;
  inset: 0;
  width: 100%;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  margin: 0;
}

/* ---------- Logo lockup ---------- */

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}

.brand-mark {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  display: block;
}

.brand-mark svg {
  width: 100%;
  height: 100%;
  display: block;
}

.brand-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  line-height: 1;
}

.brand-text span {
  color: var(--red);
}

/* ---------- Splash de abertura ---------- */

.splash {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--nav-bg);
  opacity: 1;
  transition: opacity 0.45s ease;
}

.splash-mark {
  width: 72px;
  height: 72px;
  color: #fff;
  animation: splashPop 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.splash-mark svg {
  width: 100%;
  height: 100%;
  display: block;
}

.splash-hide {
  opacity: 0;
  pointer-events: none;
}

@keyframes splashPop {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

/* ---------- Layout: sidebar + main ---------- */

.app-layout {
  display: flex;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior-y: none;
  background: var(--bg);
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  margin: 0;
  z-index: 40;
  background: var(--nav-bg);
  border-right: none;
  border-radius: 0 var(--radius-xl) var(--radius-xl) 0;
  overflow: hidden;
  box-shadow: var(--shadow-pop);
}

.sidebar > .content {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 26px;
  height: 100%;
}

.sidebar-brand {
  padding: 0 6px;
  color: var(--nav-text);
}

.sidebar-brand.brand {
  color: var(--nav-text);
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 14px;
  border-radius: var(--radius-pill);
  border: none;
  background: transparent;
  color: var(--nav-text-muted);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background-color 0.2s cubic-bezier(0.22, 1, 0.36, 1), color 0.2s ease, transform 0.15s ease;
}

.nav-item:active {
  transform: scale(0.97);
}

.nav-item svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

.nav-item:hover {
  background: var(--nav-hover);
  color: var(--nav-text);
}

.nav-item.active {
  background: var(--red);
  color: #fff;
}

/* Disparado via JS (remove+reflow+adiciona a classe) toda vez que um
   item vira o ativo — sem isso a troca de aba era só uma cor mudando
   de instante, sem nenhum movimento. */
@keyframes navItemPop {
  0% { transform: scale(0.86); }
  55% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.nav-item.nav-pop {
  animation: navItemPop 0.38s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.nav-item svg {
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.nav-item.active svg {
  transform: scale(1.1);
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 14px;
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 14px;
  border-radius: var(--radius-pill);
  border: none;
  background: transparent;
  color: var(--nav-text-muted);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}

.theme-toggle:hover {
  background: var(--nav-hover);
  color: var(--nav-text);
}

.theme-toggle svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.theme-toggle .icon-moon {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: block;
}

.main {
  flex: 1;
  min-width: 0;
}

/* ---------- Topbar (mobile only, see media query) ---------- */

/* Altura de referência do conteúdo do topbar (sem a safe area) — usada
   também pra reservar espaço no .container, já que ele virou fixed e
   saiu do fluxo normal do documento. */
:root {
  --topbar-content-h: 52px;
}

.topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  /* Altura mínima fixa em vez de deixar só o conteúdo ditar o tamanho —
     a fonte de exibição carrega via @import (Google Fonts) e entra
     depois do texto já ter desenhado com a fonte de fallback; se a
     altura da barra depende só do conteúdo, isso podia deixá-la mais
     alta um instante depois. */
  min-height: var(--topbar-content-h);
  padding: 12px 18px;
  padding-top: calc(env(safe-area-inset-top) + 12px);
  /* Fixed, não sticky, e fora do .app-layout (ver index.html) — mesma
     causa raiz do bug que a navbar de baixo tinha: um elemento fixo
     dentro de um container com overflow/scroll "anda" ou perde o
     tamanho certo em WebKit/iOS. */
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  margin: 0;
  background: var(--nav-bg);
  color: var(--nav-text);
  box-shadow: var(--shadow-pop);
}

.topbar .brand {
  color: var(--nav-text);
}

.topbar > .content {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

#theme-toggle-mobile {
  color: var(--nav-text-muted);
}

#theme-toggle-mobile:hover {
  background: var(--nav-hover);
  color: var(--nav-text);
}

/* ---------- Container ---------- */

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 30px 26px 40px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 22px;
}

.page-header-text {
  animation: fadeSlideIn 0.3s ease;
}

.page-header h1 {
  font-size: clamp(1.4rem, 1.9vw, 1.75rem);
  letter-spacing: -0.02em;
}

.page-header p {
  margin: 5px 0 0;
  color: var(--text-muted);
  font-size: 0.83rem;
  line-height: 1.45;
  /* Reserva espaço pra 2 linhas sempre — os subtítulos de cada aba têm
     tamanhos diferentes, então sem isso o header muda de altura (e some/
     aparece some coisa) a cada troca de página. */
  min-height: calc(1.45em * 2);
}

.stat-pill {
  background: var(--red);
  color: #fff;
  border-radius: var(--radius-pill);
  padding: 9px 18px;
  display: flex;
  align-items: baseline;
  gap: 7px;
  font-family: var(--font-display);
}

.stat-pill strong {
  font-size: 1.1rem;
}

.stat-pill span {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #fff;
  opacity: 0.8;
  font-family: var(--font-body);
}

/* ---------- Filtros ---------- */

.filtros {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 10px;
  box-shadow: var(--shadow-card);
}

.filtros input {
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  background: var(--surface-sunken);
  color: var(--text);
  font-family: var(--font-body);
}

.filtros input:focus {
  outline: none;
  background: var(--gray-soft);
}

.filtros input[type="search"] {
  flex: 1;
  min-width: 200px;
}

.filtro-locked {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  color: var(--text-faint);
  font-size: 0.8rem;
  font-weight: 500;
}

/* Select customizado (evita o dropdown nativo do SO, fora do tema) */

.select {
  position: relative;
  min-width: 155px;
}

.select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
}

.select-trigger:hover {
  background: var(--gray-soft);
}

.select.open .select-trigger {
  background: var(--ink);
  color: var(--ink-text);
}

.select-trigger svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  color: var(--text-faint);
  transition: transform 0.18s ease;
}

.select.open .select-trigger svg {
  color: inherit;
  transform: rotate(180deg);
}

.select-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.select-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  min-width: 180px;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border: none;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card-hover);
  z-index: 30;
  max-height: 240px;
  overflow-y: auto;
  animation: fadeSlideIn 0.15s ease;
}

.select-menu li {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.83rem;
  color: var(--text);
  cursor: pointer;
}

.select-menu li:hover {
  background: var(--surface-sunken);
}

.select-menu li.active {
  background: var(--red);
  color: #fff;
}

/* ---------- Dashboard (KPIs + gráficos) ---------- */

.dashboard-view {
  animation: fadeSlideIn 0.35s ease;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi-tile {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-card);
}

.kpi-tile:first-child {
  background: var(--red);
  color: #fff;
}

.kpi-tile:first-child .kpi-label {
  color: rgba(255, 255, 255, 0.75);
}

.kpi-tile:first-child .kpi-icon {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.kpi-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--red-soft);
  color: var(--red);
}

.kpi-icon svg {
  width: 15px;
  height: 15px;
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
}

.kpi-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin-bottom: 8px;
}

.chart-panel {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
}

.chart-panel h2 {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bar-row-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.bar-row-label .bar-count {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.74rem;
}

.bar-track {
  height: 9px;
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  width: 0%;
  transition: width 0.7s ease;
}

/* ---------- Grid de leads ---------- */

.leads-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 14px;
  align-items: start;
}

/* Acima de 900px sobra espaço de sobra — cartões mais largos evitam que
   telefone/valor/data fiquem truncados com "..." dentro da mini-grade. */
@media (min-width: 900px) {
  .leads-grid {
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  }
}

.status-msg {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-muted);
  padding: 48px 0;
  font-size: 0.88rem;
  animation: fadeSlideIn 0.3s ease;
}

.status-msg.error {
  color: var(--red);
}

/* Skeleton loading */

.skeleton-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 18px;
  height: 200px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.skeleton-line {
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--surface-sunken) 25%, var(--gray-soft) 37%, var(--surface-sunken) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}

@keyframes shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes loginCardIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Card ---------- */

.lead-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: box-shadow 0.22s ease, transform 0.22s ease, background-color 0.2s ease;
  animation: cardIn 0.35s ease both;
  animation-delay: var(--card-delay, 0s);
}

/* Fundo do card acompanha o status — mesma paleta do badge, pra bater o
   olho na grade sem precisar ler o texto de cada card. */
.lead-card-contatado { background: var(--blue-soft); }
.lead-card-em-atendimento { background: var(--green-soft); }

@media (hover: hover) and (pointer: fine) {
  .lead-card:hover {
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-4px);
  }
}

.lead-card-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}

.lead-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--ink-text);
  background: var(--ink);
}

.lead-card-heading {
  flex: 1;
  min-width: 0;
}

.lead-card-heading h3 {
  font-size: 0.94rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lead-origem {
  margin: 2px 0 0;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-weight: 600;
}

.badge {
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  background: var(--gray-soft);
  color: var(--text-muted);
  white-space: nowrap;
}

/* O card inteiro já carrega o tom do status (ver .lead-card-*) — o badge
   usa a superfície "neutra" por cima pra continuar legível como um chip,
   em vez de se misturar com o fundo colorido do card. */
.badge-contatado { background: var(--surface); color: var(--blue-text); }
.badge-em-atendimento { background: var(--surface); color: var(--green-text); }

.lead-info {
  display: grid;
  /* Telefone é sempre o valor mais longo — ganha mais espaço que Valor e
     Data, que raramente passam de 10 caracteres. */
  grid-template-columns: 1.3fr 0.85fr 0.85fr;
  gap: 8px;
  margin: 0;
  padding: 12px 14px;
  background: var(--surface-sunken);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.lead-info > div {
  min-width: 0;
}

.lead-info dt {
  font-size: 0.6rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.lead-info dd {
  margin: 2px 0 0;
  font-size: 0.76rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lead-resumo {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.45;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Expand toggle + panel */

.btn-expand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  padding: 10px 0 0;
  margin-top: 2px;
}

.btn-expand:hover {
  color: var(--text);
}

.btn-expand svg {
  width: 12px;
  height: 12px;
  transition: transform 0.25s ease;
}

.lead-card.expanded .btn-expand svg {
  transform: rotate(180deg);
}

.lead-expand {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.3s ease;
}

.lead-card.expanded .lead-expand {
  grid-template-rows: 1fr;
}

.lead-expand-inner {
  overflow: hidden;
  min-height: 0;
}

.lead-expand-content {
  padding-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lead-resumo-full {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.lead-resumo-full p {
  margin: 0 0 7px;
}

.lead-resumo-full p:last-child {
  margin-bottom: 0;
}

.lead-detalhes {
  display: flex;
  flex-direction: column;
  background: var(--surface-sunken);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.lead-detalhes > div {
  min-width: 0;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
}

.lead-detalhes > div:last-child {
  border-bottom: none;
}

.lead-detalhes dt {
  font-size: 0.65rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.lead-detalhes dd {
  margin: 3px 0 0;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.4;
  overflow-wrap: break-word;
}

.lead-detalhes dd.dd-copyable {
  align-items: flex-start;
}

.lead-detalhes .dd-text {
  white-space: normal;
}

/* ---------- Seções do expandido (Resumo / Detalhes) ---------- */

.lead-expand-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.lead-expand-section-head h4 {
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
}

.lead-expand-section + .lead-expand-section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* ---------- Copiar (telefone, e-mail) ---------- */

dd.dd-copyable {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.dd-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.btn-copy {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.btn-copy svg {
  width: 13px;
  height: 13px;
}

.btn-copy:hover {
  background: var(--gray-soft);
  color: var(--text);
}

.btn-copy:active {
  transform: scale(0.9);
}

.btn-copy.copied {
  color: var(--green-text);
}

.lead-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 4px;
}

.lead-actions button {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius-pill);
  font-size: 0.74rem;
  font-weight: 700;
  font-family: var(--font-body);
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease, transform 0.1s ease;
}

.lead-actions button:active {
  transform: scale(0.97);
}

.lead-actions svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.btn-whatsapp {
  background: #1fa855;
  color: #fff;
}

.btn-whatsapp:hover {
  background: #17913f;
}

.btn-status {
  background: var(--surface-sunken);
  color: var(--text);
  border: none !important;
}

.btn-status:hover {
  background: var(--gray-soft);
}

.btn-status:disabled,
.btn-whatsapp:disabled {
  opacity: 0.55;
  cursor: default;
}

/* ---------- Paginação ---------- */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 26px;
}

.pagination button {
  padding: 9px 18px;
  border: none;
  background: var(--surface);
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: var(--font-body);
  color: var(--text);
  box-shadow: var(--shadow-card);
}

.pagination button:hover:not(:disabled) {
  background: var(--red);
  color: #fff;
  box-shadow: 0 10px 20px -10px rgba(232, 35, 27, 0.5);
}

.pagination button:disabled {
  opacity: 0.35;
  cursor: default;
  box-shadow: none;
}

.pagination-info {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ---------- Botões genéricos ---------- */

.btn-primary {
  background: var(--red);
  color: #fff;
  border: none;
  padding: 12px 18px;
  border-radius: var(--radius-pill);
  font-size: 0.86rem;
  font-weight: 700;
  font-family: var(--font-body);
  cursor: pointer;
  box-shadow: 0 12px 24px -12px rgba(232, 35, 27, 0.55);
}

.btn-primary:hover {
  opacity: 0.92;
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: default;
  box-shadow: none;
}

.btn-secondary {
  background: var(--surface-sunken);
  border: none;
  color: var(--text);
  padding: 9px 16px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  font-family: var(--font-body);
}

.btn-secondary:hover {
  background: var(--gray-soft);
}

/* ---------- Login ---------- */
/* Painel de marca sólido de um lado, cartão de acesso arredondado
   sobreposto do outro — sem blobs desfocados genéricos. */

.login-body {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--nav-bg);
  color-scheme: dark;
}

.login-body::before,
.login-body::after {
  content: none;
}

.login-brand-panel {
  background: var(--nav-bg);
  color: var(--nav-text);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 44px;
}

.login-brand-panel .brand {
  color: var(--nav-text);
}

.login-brand-panel .brand-mark {
  width: 32px;
  height: 32px;
}

.login-brand-panel .brand-text {
  font-size: 1.2rem;
}

.login-brand-panel-foot {
  font-size: 0.78rem;
  color: var(--nav-text-muted);
}

.login-card {
  position: static;
  top: auto;
  left: auto;
  transform: none;
  z-index: auto;
  background: var(--bg);
  border-radius: var(--radius-xl) 0 0 var(--radius-xl);
  overflow: hidden;
  box-shadow: none;
  padding: 52px 48px;
  width: 100%;
  max-width: none;
  margin: 0;
  animation: none;
  display: flex;
  align-items: center;
  height: 100%;
}

.login-card > .content {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 340px;
}

.login-card h1 {
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
  color: var(--text);
}

.login-card .subtitle {
  margin: 0 0 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.login-card label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.login-card input {
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius-pill);
  font-size: 0.88rem;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-body);
  box-shadow: var(--shadow-card);
}

.login-card input:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--red);
}

.login-card .error {
  color: var(--red);
  font-size: 0.78rem;
  min-height: 1.2em;
  margin: 0;
  font-weight: 600;
}

.login-card button {
  margin-top: 8px;
}

@media (max-width: 760px) {
  .login-body {
    grid-template-columns: 1fr;
  }

  .login-brand-panel {
    padding: 32px;
    min-height: 180px;
  }

  .login-card {
    padding: 36px 28px;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }

  .login-card > .content {
    max-width: 100%;
  }
}

/* ---------- Responsivo ---------- */

.bottom-nav {
  display: none;
  position: fixed;
  bottom: calc(6px + env(safe-area-inset-bottom));
  left: 14px;
  right: 14px;
  z-index: 40;
  background: var(--nav-bg);
  border: none;
  border-radius: var(--radius-pill);
  overflow: hidden;
  box-shadow: var(--shadow-pop);
  padding: 8px 8px;
  justify-content: space-around;
  align-items: center;
  animation: navRiseIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes navRiseIn {
  from { opacity: 0; transform: translateY(18px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.bottom-nav > .content {
  position: relative;
  z-index: 3;
  display: flex;
  width: 100%;
  justify-content: space-around;
  align-items: center;
}

.bottom-nav .nav-item {
  flex-direction: column;
  gap: 3px;
  padding: 8px 10px;
  font-size: 0.6rem;
  text-align: center;
  border-radius: var(--radius-pill);
}

@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .chart-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .sidebar {
    display: none;
  }

  .topbar {
    display: flex;
  }

  .app-layout {
    flex-direction: column;
  }

  .container {
    /* Topbar virou fixed (fora do fluxo) — sem esse padding-top o
       conteúdo começaria escondido embaixo dela. */
    padding: calc(env(safe-area-inset-top) + var(--topbar-content-h) + 24px + 18px) 16px calc(var(--bottomnav-h) + 28px);
  }

  .bottom-nav {
    display: flex;
  }

  .lead-actions {
    flex-direction: column;
  }

  .lead-info {
    grid-template-columns: 1fr 1fr;
  }

  /* Telefone ocupa a linha toda (é o campo mais largo, com botão de
     copiar); Valor e Data dividem a segunda linha — sem item órfão. */
  .lead-info > div:first-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 400px) {
  .stat-pill span {
    display: none;
  }
}
