/* Self Imobi — demo system
   Paleta: navy premium + champagne gold.
   Mobile first (390) escalando até 1440.
*/

:root {
  --bg: #0a1628;
  --bg-2: #0d1a30;
  --surface: #13213a;
  --surface-2: #182a48;
  --border: #1f2d4a;
  --border-strong: #2a3b5e;

  --gold: #c9a961;
  --gold-soft: #e8d9a8;
  --gold-dim: #8d7640;

  --text: #f0ead6;
  --text-dim: #a8b2c7;
  --text-mute: #6b7693;

  --ok: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
  --info: #60a5fa;

  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --shadow-soft: 0 1px 0 rgba(255,255,255,.03), 0 8px 24px rgba(0,0,0,.25);
  --shadow-pop: 0 1px 0 rgba(255,255,255,.04), 0 18px 48px rgba(0,0,0,.45);

  --topbar-h: 48px;

  --font-serif: "Fraunces", Georgia, serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  background-image:
    radial-gradient(1200px 600px at 85% -10%, rgba(201,169,97,.07), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(96,165,250,.05), transparent 55%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140' viewBox='0 0 140 140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.025 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* -- Typography -- */
h1, h2, h3, h4 { font-family: var(--font-serif); font-weight: 500; margin: 0; letter-spacing: -0.01em; color: var(--text); }
h1 { font-size: 28px; line-height: 1.15; font-weight: 400; }
h2 { font-size: 22px; line-height: 1.2; }
h3 { font-size: 17px; line-height: 1.3; }
.num { font-variant-numeric: tabular-nums; }
.eyebrow { font-family: var(--font-sans); font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--gold); font-weight: 600; }
.muted { color: var(--text-dim); }
.mute-strong { color: var(--text-mute); }
small { font-size: 12px; color: var(--text-dim); }
a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-soft); }

/* -- Layout shell -- */
.shell { display: grid; grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(10,22,40,.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 8px 18px;
  display: flex; align-items: center; gap: 14px;
  height: var(--topbar-h);
  flex-shrink: 0;
}
.topbar-spacer { flex: 1 1 auto; }
.badge-client {
  font-size: 11px;
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--text-dim);
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.badge-client b { color: var(--gold); font-weight: 500; }
.hamburger {
  background: transparent; border: 1px solid var(--border-strong);
  color: var(--text); width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}

.main { padding: 18px; max-width: 1440px; margin: 0 auto; width: 100%; }

/* -- Sidebar (padrão Self) -- */
.sidebar { display: none; }

/* Header: logo quadrado + wordmark + slogan */
.sb-head {
  display: flex; align-items: center; gap: 12px;
  padding: 0 6px 22px 6px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sb-logo {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #c9a961, #a08043);
  display: flex; align-items: center; justify-content: center;
  color: #0a1628; font-weight: 800; font-size: 14px;
  letter-spacing: 0.04em;
  box-shadow: 0 1px 0 rgba(255,255,255,.15) inset, 0 6px 16px rgba(201,169,97,.22);
  flex: 0 0 40px;
}
.sb-brand { min-width: 0; }
.sb-word {
  font-family: var(--font-sans);
  font-size: 13px; font-weight: 700;
  letter-spacing: 1px; color: var(--text);
  line-height: 1.1;
}
.sb-slogan {
  font-size: 11px; letter-spacing: 0.4px;
  color: var(--text-mute);
  margin-top: 3px;
}

/* Nav: scroll aqui se o conteúdo passar da altura disponível (não na sidebar inteira,
   senão o rodapé/header também somem e o foot sobrepõe os items). */
.sb-nav {
  display: flex; flex-direction: column; gap: 2px;
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto;
  /* reserva um espaço pro scroll pra evitar sumir borda à direita */
  margin-right: -6px; padding-right: 6px;
}
.sb-section {
  font-size: 10px; letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-mute);
  font-weight: 600;
  padding: 18px 6px 8px 6px;
}

/* Item */
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-dim);
  font-weight: 500; font-size: 13px;
  transition: background .18s ease, color .18s ease;
  text-decoration: none;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item:hover .nav-ic svg { color: var(--gold); }
.nav-item.is-active { background: var(--surface); color: var(--text); }
.nav-item.is-active .nav-ic svg { color: var(--gold); }
.nav-item.is-roadmap { opacity: 0.78; }
.nav-item.is-roadmap:hover { opacity: 1; }

.nav-bar {
  position: absolute;
  left: -18px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--gold);
}

.nav-ic { display: inline-flex; align-items: center; justify-content: center; }
.nav-ic svg { color: var(--text-mute); transition: color .18s ease; display: block; }

.nav-label { flex: 1; }

.nav-badge {
  font-size: 10px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px;
  background: rgba(201,169,97,.12); color: var(--gold-soft);
  border: 1px solid rgba(201,169,97,.3);
  letter-spacing: 0.02em;
}
.nav-badge.roadmap {
  background: var(--surface);
  color: var(--text-mute);
  border-color: var(--border);
  font-weight: 500;
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Rodapé: empresa + status / avatar + nome + botão sair.
   margin-top: auto empurra pro fundo RESPEITANDO o flow (sem sobrepor o nav). */
.sb-foot {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.sb-foot-top { padding: 0 2px; margin-bottom: 12px; }
.sb-foot-empresa { font-size: 12px; font-weight: 600; color: var(--text); line-height: 1.2; }
.sb-foot-status { font-size: 11px; color: var(--gold-dim); margin-top: 3px; letter-spacing: 0.02em; }

.sb-foot-user { display: flex; align-items: center; gap: 10px; }
.sb-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: var(--gold);
  font-size: 14px;
  flex: 0 0 36px;
}
.sb-user-info { min-width: 0; flex: 1; }
.sb-user-name { font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.2;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-user-role { font-size: 11px; color: var(--text-mute); margin-top: 2px; }
.sb-logout {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border-strong);
  color: var(--text-dim);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: border-color .18s ease, color .18s ease, background .18s ease;
}
.sb-logout:hover { border-color: var(--gold-dim); color: var(--gold); }

/* Drawer mobile: sidebar vira off-canvas vindo da esquerda */
.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(5,10,20,.6);
  backdrop-filter: blur(4px);
  z-index: 55; display: none;
}
.drawer-backdrop.show { display: block; }

@media (max-width: 1023px) {
  .sidebar.drawer-open {
    display: flex !important;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 288px; max-width: 85vw;
    background: var(--bg-2);
    border-right: 1px solid var(--border);
    padding: 22px 18px;
    z-index: 60;
    overflow-y: auto;
    box-shadow: 0 24px 60px rgba(0,0,0,.6);
  }
  /* No drawer mobile a sidebar inteira rola; nav interno sem scroll duplo. */
  .sidebar.drawer-open .sb-nav {
    overflow-y: visible;
    margin-right: 0; padding-right: 0;
  }
}

/* legacy avatar reusado por lead-card (não mexer) */
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, #c9a961, #8d7640);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; color: #0a1628; font-size: 13px;
}

/* -- Bottom nav (mobile) -- */
.botnav {
  position: sticky; bottom: 0; z-index: 40;
  background: rgba(10,22,40,.92);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 6px env(safe-area-inset-bottom, 6px);
}
.botnav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px; color: var(--text-mute); font-size: 10px;
  border-radius: 10px;
}
.botnav a.active { color: var(--gold); }
.botnav a svg { width: 20px; height: 20px; }

/* -- Cards & surfaces -- */
.card {
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-soft);
}
.card.pad-sm { padding: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; gap: 10px; }

.kpi-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.kpi {
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  position: relative; overflow: hidden;
}
.kpi .lbl { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-mute); font-weight: 600; }
.kpi .val { font-family: var(--font-serif); font-size: 28px; font-weight: 400; margin-top: 6px; color: var(--text); font-variant-numeric: tabular-nums; }
.kpi .delta { margin-top: 4px; font-size: 12px; display: flex; align-items: center; gap: 4px; color: var(--text-dim); }
.kpi .delta.up { color: var(--ok); }
.kpi .delta.down { color: var(--bad); }
.kpi .accent-line {
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, var(--gold), transparent);
}

/* -- Buttons -- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  color: var(--text); font-weight: 500; cursor: pointer; font-family: var(--font-sans);
  font-size: 13px; transition: all .18s ease;
}
.btn:hover { background: var(--surface); border-color: var(--gold-dim); }
.btn.primary {
  background: linear-gradient(180deg, #cfaf6a, #a68945);
  color: #0a1628; border-color: var(--gold);
  box-shadow: 0 1px 0 rgba(255,255,255,.2) inset, 0 10px 24px rgba(201,169,97,.2);
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 7px 12px; font-size: 12px; }

/* -- Chips -- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  font-size: 11px; color: var(--text-dim); font-weight: 500;
}
.chip.gold { background: rgba(201,169,97,.1); border-color: rgba(201,169,97,.35); color: var(--gold-soft); }
.chip.ok { background: rgba(74,222,128,.1); border-color: rgba(74,222,128,.3); color: var(--ok); }
.chip.warn { background: rgba(251,191,36,.1); border-color: rgba(251,191,36,.3); color: var(--warn); }
.chip.bad { background: rgba(248,113,113,.1); border-color: rgba(248,113,113,.3); color: var(--bad); }
.chip.info { background: rgba(96,165,250,.1); border-color: rgba(96,165,250,.3); color: var(--info); }

/* -- Forms -- */
.input, .select, .textarea {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  font-family: var(--font-sans);
  font-size: 13px;
  width: 100%;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,169,97,.15); }
.textarea { min-height: 140px; resize: vertical; line-height: 1.6; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-dim); font-weight: 500; }

/* -- Chart (sparkline/bars) -- */
.chart-area { height: 150px; width: 100%; }

/* -- Feed -- */
.feed { display: flex; flex-direction: column; gap: 10px; }
.feed-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 10px 12px; border-radius: 10px;
  background: rgba(255,255,255,.015); border: 1px solid var(--border);
}
.feed-item .ico {
  width: 32px; height: 32px; border-radius: 10px; flex: 0 0 32px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--gold-soft); font-size: 14px;
}
.feed-item .ico.g { background: rgba(74,222,128,.08); color: var(--ok); }
.feed-item .ico.a { background: rgba(96,165,250,.08); color: var(--info); }
.feed-item .ico.o { background: rgba(201,169,97,.08); color: var(--gold); }
.feed-item .ico.m { background: rgba(37,211,102,.1); color: #4ee28a; font-size: 13px; }
a.feed-item.feed-link {
  text-decoration: none; color: inherit;
  transition: border-color .14s ease, background .14s ease;
}
a.feed-item.feed-link:hover { border-color: var(--gold-dim); background: rgba(255,255,255,.025); }
.feed-item .txt { flex: 1; }
.feed-item time { color: var(--text-mute); font-size: 11px; }

/* -- Kanban -- */
.kanban-wrap { overflow-x: auto; padding-bottom: 10px; }
.kanban { display: grid; grid-template-columns: repeat(6, 220px); gap: 10px; min-width: max-content; }
@media (min-width: 1280px) {
  .kanban { grid-template-columns: repeat(6, 1fr); min-width: 0; gap: 10px; }
  .kanban-col { padding: 10px; }
  .lead-card { padding: 10px; }
  .lead-card .name { font-size: 12.5px; }
}
.kanban-col {
  background: linear-gradient(180deg, var(--bg-2), transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  min-height: 400px;
  display: flex; flex-direction: column; gap: 10px;
}
.kanban-col > header { display: flex; align-items: center; justify-content: space-between; }
.kanban-col h3 { font-family: var(--font-sans); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--text-dim); font-weight: 600; }
.kanban-col .count { font-size: 11px; color: var(--text-mute); background: var(--surface); padding: 2px 8px; border-radius: 999px; }
.kanban-col .col-value { font-size: 11px; color: var(--gold); font-variant-numeric: tabular-nums; }
.kanban-col.col-prospectado { border-top: 2px solid #60a5fa; }
.kanban-col.col-contactado { border-top: 2px solid #a78bfa; }
.kanban-col.col-visita { border-top: 2px solid #fbbf24; }
.kanban-col.col-proposta { border-top: 2px solid #c9a961; }
.kanban-col.col-fechado { border-top: 2px solid #4ade80; }
.kanban-col.col-perdido { border-top: 2px solid #6b7693; opacity: .9; }

.lead-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  cursor: grab;
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
}
.lead-card:hover { border-color: var(--gold-dim); transform: translateY(-1px); box-shadow: var(--shadow-pop); }
.lead-card.dragging { opacity: .6; cursor: grabbing; }
.lead-card .top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.lead-card .avatar-sm { width: 32px; height: 32px; border-radius: 50%; font-size: 11px; }
.lead-card .name { font-weight: 500; color: var(--text); font-size: 13px; }
.lead-card .source { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-mute); }
.lead-card .imovel {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px; border-radius: 8px;
  background: var(--bg); border: 1px solid var(--border);
  font-size: 11px; color: var(--text-dim); margin-bottom: 8px;
}
.lead-card .meta { display: flex; justify-content: space-between; align-items: center; }
.lead-card .last { font-size: 11px; color: var(--text-mute); }
.lead-card .score {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.score-hi { background: rgba(74,222,128,.12); color: var(--ok); }
.score-md { background: rgba(251,191,36,.12); color: var(--warn); }
.score-lo { background: rgba(248,113,113,.12); color: var(--bad); }

/* -- Filtros bar -- */
.filterbar {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  padding: 12px 0; margin-bottom: 10px;
}
.filterbar .select { width: auto; min-width: 140px; }
.filterbar .search { flex: 1; min-width: 220px; }

/* -- Grid imoveis -- */
.imo-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.imo-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.imo-card:hover { transform: translateY(-2px); border-color: var(--gold-dim); box-shadow: var(--shadow-pop); }
.imo-img {
  aspect-ratio: 16 / 10;
  background: #1a2847 center / cover no-repeat;
  position: relative;
}
.imo-img .status {
  position: absolute; top: 10px; left: 10px;
}
.imo-img .fav {
  position: absolute; top: 10px; right: 10px;
  background: rgba(10,22,40,.6); backdrop-filter: blur(6px);
  width: 32px; height: 32px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center; color: var(--gold-soft);
}
.imo-info { padding: 14px; }
.imo-info h3 { font-family: var(--font-serif); font-size: 18px; font-weight: 400; margin-bottom: 2px; }
.imo-info .addr { font-size: 12px; color: var(--text-dim); margin-bottom: 10px; }
.imo-specs { display: flex; gap: 10px; font-size: 12px; color: var(--text-dim); margin-bottom: 10px; }
.imo-specs span { display: inline-flex; align-items: center; gap: 4px; }
.imo-price-row { display: flex; justify-content: space-between; align-items: baseline; }
.imo-price { font-family: var(--font-serif); font-size: 20px; color: var(--gold-soft); font-variant-numeric: tabular-nums; }
.imo-comm { font-size: 11px; color: var(--text-mute); }

/* -- Modal -- */
.modal {
  position: fixed; inset: 0;
  background: rgba(5,10,20,.75); backdrop-filter: blur(6px);
  display: none; z-index: 90;
  padding: 18px; overflow-y: auto;
}
.modal.open { display: flex; align-items: flex-start; justify-content: center; }
.modal .box {
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  max-width: 820px; width: 100%;
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  margin-top: 20px;
  margin-bottom: 40px;
}
.modal .box header { padding: 16px 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); }
.modal .box .close { background: var(--surface); border: 1px solid var(--border-strong); color: var(--text); width: 32px; height: 32px; border-radius: 10px; cursor: pointer; font-size: 18px; line-height: 1; }
.modal-content { padding: 20px; }
.modal-gallery { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 6px; margin-bottom: 20px; }
.modal-gallery > div { aspect-ratio: 4/3; background: #1a2847 center / cover no-repeat; border-radius: 8px; }
.modal-gallery > div:first-child { grid-row: 1 / span 2; aspect-ratio: 4/5; }

/* -- Agente IA -- */
.ai-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.chat-sim {
  background: var(--bg); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; max-height: 420px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 10px;
}
.chat-msg { max-width: 85%; padding: 10px 14px; border-radius: 14px; font-size: 13px; line-height: 1.5; }
.chat-msg.lead { background: var(--surface-2); color: var(--text); border-bottom-left-radius: 4px; }
.chat-msg.ai { background: linear-gradient(135deg, rgba(201,169,97,.14), rgba(201,169,97,.06)); border: 1px solid rgba(201,169,97,.3); color: var(--text); margin-left: auto; border-bottom-right-radius: 4px; }
.chat-msg time { display: block; margin-top: 4px; font-size: 10px; opacity: .6; }

/* -- Preview card -- */
.preview-grid { display: grid; grid-template-columns: 1fr; gap: 14px; margin-top: 10px; }
.preview-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
}
.preview-card .skeleton {
  aspect-ratio: 16/9;
  background-color: #182a48;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.preview-card .skeleton::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(10,22,40,0) 50%, rgba(10,22,40,.5));
}
.preview-card .content { padding: 16px; }
.preview-card h3 { font-family: var(--font-serif); font-size: 18px; font-weight: 400; margin-bottom: 4px; }
.preview-card .desc { font-size: 13px; color: var(--text-dim); margin-bottom: 10px; }
.preview-card .tag {
  position: absolute; top: 12px; right: 12px;
  padding: 4px 10px; background: rgba(10,22,40,.85); backdrop-filter: blur(6px);
  border: 1px solid var(--gold-dim); border-radius: 999px;
  font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-soft);
}

/* -- Toast -- */
.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--gold-dim);
  padding: 12px 18px; border-radius: 10px;
  color: var(--text); z-index: 100; font-size: 13px;
  box-shadow: var(--shadow-pop);
  opacity: 0; pointer-events: none; transition: opacity .25s ease, transform .25s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

/* -- Nav badge: variação verde WhatsApp (contador de mensagens) -- */
.nav-badge.wa {
  background: rgba(37,211,102,.14);
  color: #4ee28a;
  border-color: rgba(37,211,102,.4);
  font-weight: 700;
}

/* -- Bottom nav: ícone + badge sobreposto -- */
.botnav-ic { position: relative; display: inline-flex; }
.botnav-badge {
  position: absolute; top: -4px; right: -8px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px;
  background: #25D366; color: #052e14;
  font-size: 9px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 2px rgba(10,22,40,.92);
}

/* ======================================================================
   CONVERSAS (WhatsApp interface)
   Layout: lista (320px) + chat principal + painel lateral opcional.
   Em mobile <900px vira full-screen com toggle lista↔chat.
   ====================================================================== */

/* Verdes WhatsApp (usados só nas bolhas do corretor/bot e contadores) */
:root {
  --wa-green: #25D366;
  --wa-green-dark: #005c4b;
  --wa-green-bubble: #005c4b;
  --wa-tick: #53bdeb;
}

.chat-shell {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  height: calc(100vh - var(--topbar-h) - 36px - env(safe-area-inset-bottom, 0px));
  min-height: 560px;
}
@media (min-width: 760px) {
  .chat-shell { grid-template-columns: 320px 1fr; }
}
@media (min-width: 1280px) {
  .chat-shell { grid-template-columns: 340px 1fr 300px; }
}

/* --- LISTA DE CONVERSAS --- */
.chat-list {
  display: flex; flex-direction: column;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  min-width: 0;
  min-height: 0;
}
.chat-list-head {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-list-head h2 {
  font-family: var(--font-serif);
  font-size: 20px; font-weight: 400;
  margin-bottom: 10px;
}
.chat-search {
  position: relative;
}
.chat-search input {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px 9px 34px;
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 13px;
  width: 100%;
}
.chat-search input:focus { outline: none; border-color: var(--gold-dim); }
.chat-search svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--text-mute);
  pointer-events: none;
}
.chat-filters {
  display: flex; gap: 6px;
  padding: 10px 16px;
  overflow-x: auto;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}
.chat-filters::-webkit-scrollbar { display: none; }
.chat-filter {
  flex-shrink: 0;
  padding: 5px 11px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
  font-size: 11px; font-weight: 500;
  cursor: pointer;
  transition: all .18s ease;
  white-space: nowrap;
}
.chat-filter:hover { color: var(--text); border-color: var(--gold-dim); }
.chat-filter.active {
  background: rgba(201,169,97,.12);
  border-color: var(--gold-dim);
  color: var(--gold-soft);
}

.chat-list-scroll {
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 0;
}

.chat-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(31,45,74,.5);
  cursor: pointer;
  position: relative;
  transition: background .14s ease;
}
.chat-item:hover { background: rgba(255,255,255,.015); }
.chat-item.is-active {
  background: var(--bg-2);
  background: linear-gradient(90deg, rgba(201,169,97,.08), transparent 60%);
}
.chat-item.is-active::before {
  content: '';
  position: absolute; left: 0; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--gold);
}

.chat-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #0a1628; font-weight: 700; font-size: 13px;
  flex: 0 0 44px;
  position: relative;
  box-shadow: 0 1px 0 rgba(255,255,255,.1) inset;
}
.chat-avatar .by-ic {
  position: absolute; bottom: -2px; right: -2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--bg-2);
  border: 2px solid var(--bg-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 9px;
}
.chat-avatar .by-ic.ai {
  background: linear-gradient(135deg, var(--gold), var(--gold-dim));
  color: #0a1628;
}
.chat-avatar .by-ic.human {
  background: var(--surface);
  color: var(--text-dim);
}

.chat-item-body { flex: 1; min-width: 0; }
.chat-item-row1 {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 8px; margin-bottom: 3px;
}
.chat-item-name {
  font-weight: 600; font-size: 13.5px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-item-time {
  font-size: 10.5px; color: var(--text-mute);
  white-space: nowrap; flex-shrink: 0;
}
.chat-item-time.unread { color: var(--wa-green); font-weight: 600; }
.chat-item-row2 {
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px;
}
.chat-item-preview {
  font-size: 12.5px; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1; min-width: 0;
}
.chat-item.unread .chat-item-preview { color: var(--text); }
.chat-item-badge {
  background: var(--wa-green);
  color: #052e14;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* --- CHAT PRINCIPAL --- */
.chat-main {
  display: flex; flex-direction: column;
  background:
    radial-gradient(ellipse at top, rgba(201,169,97,.025), transparent 60%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140' viewBox='0 0 140 140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.015 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"),
    var(--bg);
  min-width: 0;
  min-height: 0;
}
.chat-main-head {
  padding: 10px 16px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  flex-shrink: 0;
}
.chat-head-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #0a1628; font-weight: 700; font-size: 13px;
  flex: 0 0 40px;
}
.chat-head-info { flex: 1; min-width: 0; }
.chat-head-name {
  font-weight: 600; font-size: 14px; color: var(--text);
  line-height: 1.2;
}
.chat-head-status {
  font-size: 11px; color: var(--text-mute);
  margin-top: 2px;
  display: flex; align-items: center; gap: 4px;
}
.chat-head-status.online { color: var(--wa-green); }
.chat-head-status.typing { color: var(--gold); font-style: italic; }
.chat-head-actions {
  display: flex; gap: 4px;
}
.chat-head-btn {
  width: 36px; height: 36px; border-radius: 10px;
  background: transparent; border: 1px solid transparent;
  color: var(--text-dim);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all .14s ease;
}
.chat-head-btn:hover { background: var(--surface); color: var(--gold); }
.chat-back {
  width: 36px; height: 36px; border-radius: 10px;
  background: transparent; border: 1px solid var(--border-strong);
  color: var(--text); cursor: pointer;
  display: none;
  align-items: center; justify-content: center;
  flex-shrink: 0;
}

.chat-stream {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 10px 10px;
  display: flex; flex-direction: column; gap: 2px;
  min-height: 0;
}
.chat-day {
  align-self: center;
  padding: 4px 12px; margin: 10px 0 6px;
  background: rgba(13,26,48,.9);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 10.5px; color: var(--text-dim);
  font-weight: 500; letter-spacing: 0.02em;
  text-transform: capitalize;
}

.bubble-wrap { display: flex; margin: 0 6px; }
.bubble-wrap.lead { justify-content: flex-start; }
.bubble-wrap.me { justify-content: flex-end; }
.bubble-wrap + .bubble-wrap { margin-top: 2px; }
.bubble-wrap.first-of-group { margin-top: 8px; }
.bubble-wrap.ai-tag {
  margin-left: 10px;
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--gold); font-weight: 700;
  display: inline-flex; align-items: center; gap: 4px;
  margin-bottom: 2px; margin-top: 10px;
}
.bubble-wrap.ai-tag::before {
  content: '✦'; color: var(--gold); font-size: 11px;
}

.bubble {
  max-width: 78%;
  padding: 7px 12px 6px;
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.4;
  color: var(--text);
  position: relative;
  word-wrap: break-word;
  box-shadow: 0 1px 0.5px rgba(0,0,0,.3);
}
.bubble .time {
  font-size: 10px;
  color: rgba(240,234,214,.5);
  margin-left: 8px;
  float: right;
  margin-top: 3px;
  font-weight: 500;
  display: inline-flex; align-items: center; gap: 3px;
}
.bubble.lead {
  background: #13213a;
  border: 1px solid rgba(31,45,74,.8);
  border-top-left-radius: 4px;
}
.bubble.me {
  background: var(--wa-green-bubble);
  color: #e6f3ef;
  border-top-right-radius: 4px;
}
.bubble.me .time { color: rgba(230,243,239,.65); }
.bubble.ai {
  background: linear-gradient(135deg, #0d2e26, var(--wa-green-bubble));
  border: 1px solid rgba(201,169,97,.3);
  color: #e6f3ef;
  border-top-right-radius: 4px;
}
.bubble.ai .time { color: rgba(230,243,239,.65); }
.bubble.ai::before {
  content: '';
  position: absolute; top: -1px; right: -1px; width: 10px; height: 10px;
  background: var(--gold);
  border-top-right-radius: 10px;
  box-shadow: -2px 2px 0 var(--wa-green-bubble);
}

.bubble.lead.grouped { border-top-left-radius: 10px; }
.bubble.me.grouped, .bubble.ai.grouped { border-top-right-radius: 10px; }

.bubble-attach {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  background: rgba(0,0,0,.2);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  margin-bottom: 6px;
}
.bubble-attach .doc-ic {
  width: 32px; height: 32px; border-radius: 8px;
  background: #c33;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 9px; font-weight: 800;
  flex-shrink: 0;
}
.bubble-attach .doc-info { min-width: 0; flex: 1; }
.bubble-attach .doc-name {
  font-size: 12px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bubble-attach .doc-size { font-size: 10.5px; opacity: .7; margin-top: 1px; }

.bubble-reaction {
  position: absolute;
  bottom: -10px; left: 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 11px;
}

/* Composer */
.chat-composer {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-composer .icon-btn {
  width: 38px; height: 38px; border-radius: 10px;
  background: transparent; border: 1px solid transparent;
  color: var(--text-mute);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all .14s ease;
  flex-shrink: 0;
}
.chat-composer .icon-btn:hover { color: var(--gold); background: var(--surface); }
.chat-composer .input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 13.5px;
  color: var(--text);
}
.chat-composer .send-btn {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--wa-green);
  color: #052e14;
  border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(37,211,102,.3);
}
.chat-composer .send-btn:hover { filter: brightness(1.08); }

/* --- PAINEL LATERAL DIREITO --- */
.chat-sidepanel {
  display: none;
  background: var(--bg-2);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px 18px;
  min-width: 0;
}
@media (min-width: 1280px) { .chat-sidepanel { display: block; } }

.side-avatar {
  width: 88px; height: 88px; border-radius: 50%;
  margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
  color: #0a1628; font-weight: 700; font-size: 28px;
}
.side-name {
  font-family: var(--font-serif); font-size: 20px; font-weight: 400;
  text-align: center; margin-bottom: 2px;
}
.side-sub {
  text-align: center; font-size: 11.5px; color: var(--text-mute);
  margin-bottom: 20px;
}

.side-section {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.side-section h4 {
  font-family: var(--font-sans);
  font-size: 10px; letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-mute);
  font-weight: 600;
  margin-bottom: 10px;
}
.side-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0;
  font-size: 12.5px;
}
.side-row .lbl { color: var(--text-dim); }
.side-row .val { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; text-align: right; }

/* --- Mobile toggle (lista <-> chat) --- */
@media (max-width: 759px) {
  .chat-shell { grid-template-columns: 1fr; height: calc(100vh - var(--topbar-h) - 64px); }
  .chat-main { display: none; }
  .chat-list { border-right: none; }

  .chat-shell.mobile-chat .chat-list { display: none; }
  .chat-shell.mobile-chat .chat-main { display: flex; }
  .chat-shell.mobile-chat .chat-back { display: flex; }
}

/* -- Row helpers -- */
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 10px; }
.gap-sm { gap: 6px; }
.mt-sm { margin-top: 10px; }
.mt-md { margin-top: 20px; }
.mb-sm { margin-bottom: 10px; }
.mb-md { margin-bottom: 20px; }
.hide-mobile { display: none; }
.hide-desk { display: block; }

/* -- Responsive breakpoints -- */
@media (min-width: 600px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .imo-grid { grid-template-columns: repeat(2, 1fr); }
  .preview-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
  body { font-size: 14px; }
  .shell {
    grid-template-columns: 264px 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "top top"
      "side main";
  }
  .topbar { grid-area: top; padding: 10px 28px; justify-content: flex-end; }
  .sidebar {
    grid-area: side; display: flex; flex-direction: column;
    background: var(--bg-2); border-right: 1px solid var(--border);
    padding: 22px 18px;
    position: sticky; top: var(--topbar-h); align-self: flex-start;
    height: calc(100vh - var(--topbar-h));
    /* overflow fica no .sb-nav, não aqui — assim o sb-head e o sb-foot
       nunca saem da viewport nem são rolados pra fora */
    overflow: hidden;
    width: 264px;
  }
  .main { grid-area: main; padding: 28px 40px; }
  .botnav { display: none; }
  .hamburger { display: none; }
  .drawer-backdrop { display: none !important; }
  .hide-mobile { display: block; }
  .hide-desk { display: none; }
  .imo-grid { grid-template-columns: repeat(3, 1fr); }
  .preview-grid { grid-template-columns: repeat(3, 1fr); }
  .ai-grid { grid-template-columns: 1.4fr 1fr; }
  h1 { font-size: 34px; }
}

@media (min-width: 1280px) {
  .imo-grid { grid-template-columns: repeat(4, 1fr); }
}

/* -- Chart -- */
svg.spark .bar { fill: var(--gold); opacity: .85; }
svg.spark .bar:hover { opacity: 1; }
svg.spark .axis { stroke: var(--border); stroke-width: 1; }
svg.spark text { fill: var(--text-mute); font-size: 10px; font-family: var(--font-sans); }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dim); }
