:root {
  --bg: #f5f6f4;
  --surface: #ffffff;
  --surface-raised: #f0f2ee;
  --border: #e4e7e3;
  --text: #141815;
  --text-muted: #6b756f;
  --accent: #5c9a1b;
  --accent-light: #e9f5d8;
  --accent-contrast: #ffffff;
  --success: #1a7f5a;
  --danger: #b3261e;
  --radius: 14px;
  --shadow-card: 0 1px 2px rgba(20, 24, 21, 0.04), 0 1px 8px rgba(20, 24, 21, 0.04);
  --bubble-human-bg: #ffffff;
  --bubble-human-border: #e3e5e9;
  --bubble-ai-bg: #d9fdd3;
  --bubble-ai-text: #1f2430;
  --bubble-operador-bg: #d3e8fd;
  --bubble-operador-text: #1f2430;
}

html[data-theme="dark"] {
  --bg: #0d0f0e;
  --surface: #161918;
  --surface-raised: #1e2220;
  --border: #262a28;
  --text: #eef1ef;
  --text-muted: #8b938f;
  --accent: #c8f169;
  --accent-light: #1c2216;
  --accent-contrast: #10130f;
  --success: #4ade80;
  --danger: #f09b9b;
  --shadow-card: none;
  --bubble-human-bg: #1e2220;
  --bubble-human-border: #262a28;
  --bubble-ai-bg: #1c3a2e;
  --bubble-ai-text: #eef1ef;
  --bubble-operador-bg: #1c2a3a;
  --bubble-operador-text: #eef1ef;
}

* { box-sizing: border-box; }

/* Scrollbar customizada — fina e no tema, em vez da nativa do SO */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
  background-clip: padding-box;
}

::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}

::-webkit-scrollbar-corner {
  background: transparent;
}

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app-shell {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
}

.sidebar {
  width: 252px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 40;
  transition: width 0.18s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 6px 22px;
}

.sidebar-logo {
  height: 44px;
  width: auto;
  max-width: 168px;
  object-fit: contain;
  display: block;
}

.sidebar-collapse-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 26px;
  height: 26px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  flex-shrink: 0;
}

.sidebar-collapse-btn:hover { background: var(--surface-raised); color: var(--text); }

.icone-colapsado { display: none; }

.sidebar-icon { width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-label { white-space: nowrap; }

/* Menu colapsado — só ícones */
body.sidebar-colapsada .sidebar { width: 68px; }
body.sidebar-colapsada .sidebar-logo { display: none; }
body.sidebar-colapsada .sidebar-brand { justify-content: center; padding: 4px 0 22px; }
body.sidebar-colapsada .icone-expandido { display: none; }
body.sidebar-colapsada .icone-colapsado { display: inline; }
body.sidebar-colapsada .sidebar-label { display: none; }
body.sidebar-colapsada .sidebar-nav a,
body.sidebar-colapsada .sidebar-footer a,
body.sidebar-colapsada .sidebar-footer button {
  justify-content: center;
  padding: 10px 0;
}

@media (max-width: 900px) {
  .sidebar-collapse-btn { display: none; }
  body.sidebar-colapsada .sidebar { width: 100%; }
  body.sidebar-colapsada .sidebar-logo { display: block; }
  body.sidebar-colapsada .sidebar-brand { justify-content: space-between; }
  body.sidebar-colapsada .sidebar-label { display: inline; }
  body.sidebar-colapsada .sidebar-nav a,
  body.sidebar-colapsada .sidebar-footer a,
  body.sidebar-colapsada .sidebar-footer button {
    justify-content: flex-start;
    padding: 10px 12px;
  }
}

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

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 9px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
}

.sidebar-nav a:hover { background: var(--surface-raised); color: var(--text); }

.sidebar-nav a.active {
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 700;
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 10px;
}

.sidebar-footer a, .sidebar-footer button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 9px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}

.sidebar-footer a:hover, .sidebar-footer button:hover {
  background: var(--surface-raised);
  color: var(--text);
}

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

.mobile-topbar {
  display: none;
}

.sidebar-overlay { display: none; }

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.25);
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 39;
  }

  .sidebar-overlay.open { display: block; }

  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
  }

}

.mobile-topbar-logo {
  height: 32px;
  width: auto;
  object-fit: contain;
}

.nav-toggle {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 4px;
  font-size: 1.3rem;
  line-height: 1;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 32px 60px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-card);
}

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

@media (max-width: 640px) {
  .container { padding: 16px 12px 40px; }
  .card { padding: 14px; }
  .grid-kpi { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
  h1 { font-size: 1.25rem; margin-bottom: 14px; }
  .kpi-value { font-size: 1.5rem; }
}

.kpi-label {
  font-size: 0.76rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-value {
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--text);
}

h1 { font-size: 1.5rem; margin: 0 0 20px; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  cursor: grab;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th {
  text-align: left;
  font-size: 0.78rem;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
}

td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
}

tr:hover td { background: var(--accent-light); }

.clickable-row { cursor: pointer; }

a.row-link {
  color: var(--text);
  text-decoration: none;
  display: block;
}

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

.search-box {
  margin-bottom: 18px;
}

.search-box input {
  width: 100%;
  max-width: 340px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.92rem;
  background: var(--surface);
  color: var(--text);
}

.search-box select {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.92rem;
  background: var(--surface);
  color: var(--text);
}

.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 480px;
  overflow-y: auto;
  padding: 4px;
}

.bubble {
  max-width: 65%;
  width: fit-content;
  padding: 6px 8px 7px 9px;
  border-radius: 7.5px;
  font-size: 0.875rem;
  line-height: 1.35;
}

.bubble::after {
  content: "";
  display: table;
  clear: both;
}

.bubble .msg-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble .msg-time {
  float: right;
  font-size: 0.68rem;
  color: var(--text-muted);
  opacity: 0.85;
  margin: 5px 0 -3px 8px;
  clear: both;
}

.bubble.human {
  align-self: flex-start;
  background: var(--bubble-human-bg);
  border: 1px solid var(--bubble-human-border);
  border-top-left-radius: 2px;
}

.bubble.ai {
  align-self: flex-end;
  background: var(--bubble-ai-bg);
  color: var(--bubble-ai-text);
  border-top-right-radius: 2px;
}

.bubble.ai .msg-time { color: var(--bubble-ai-text); opacity: 0.65; }

.bubble.operador {
  align-self: flex-end;
  background: var(--bubble-operador-bg);
  color: var(--bubble-operador-text);
  border-top-right-radius: 2px;
}

.bubble.operador .msg-time { color: var(--bubble-operador-text); opacity: 0.65; }

.data-separador {
  display: flex;
  justify-content: center;
  margin: 8px 0;
}

.data-separador span {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 600;
  padding: 4px 14px;
  border-radius: 999px;
}

.section-gap { margin-top: 24px; }

.btn {
  background: var(--accent);
  color: var(--accent-contrast);
  border: none;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.btn:hover { opacity: 0.9; }

.summary-box {
  background: var(--accent-light);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 0.92rem;
  line-height: 1.5;
}

.muted { color: var(--text-muted); font-size: 0.85rem; }

.lead-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}

.lead-header .meta { color: var(--text-muted); font-size: 0.9rem; margin-top: 4px; }

@media (max-width: 640px) {
  .lead-header {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }

  .lead-header > div:last-child {
    align-items: stretch !important;
    width: 100%;
  }

  .lead-header form {
    width: 100%;
  }

  .lead-header input[type="text"],
  .lead-header input[type="datetime-local"] {
    flex: 1;
    width: auto !important;
  }
}

.stars { color: #d9a441; }

.linha-subtotal { background: #f3f5f8; }
.linha-subtotal td { padding-top: 6px; padding-bottom: 6px; }
html[data-theme="dark"] .linha-subtotal { background: #232734; }

/* Status / funil do lead */
.status-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
}

.status-novo { background: #e7ecf3; color: #4b5a72; }
.status-em_contato { background: #fdecc8; color: #8a5a00; }
.status-qualificado { background: #d9e8fd; color: #1e5fa8; }
.status-cliente { background: #d9fdd3; color: #1a7f5a; }
.status-perdido { background: #fbdada; color: #b3261e; }

html[data-theme="dark"] .status-novo { background: #2a3040; color: #b7c2d6; }
html[data-theme="dark"] .status-em_contato { background: #3a2f14; color: #f0c070; }
html[data-theme="dark"] .status-qualificado { background: #16283a; color: #7fb2ec; }
html[data-theme="dark"] .status-cliente { background: #0f3324; color: #6fd9a8; }
html[data-theme="dark"] .status-perdido { background: #3a1a1a; color: #f09b9b; }

.status-select {
  border: none;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
  background: #9aa4b2;
}

.status-dot.status-novo { background: #4b5a72; }
.status-dot.status-em_contato { background: #c9860a; }
.status-dot.status-qualificado { background: #1e5fa8; }
.status-dot.status-cliente { background: #1a7f5a; }
.status-dot.status-perdido { background: #b3261e; }

/* Alertas / banners */
.alert-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.alert-banner .alert-icon { font-size: 1.3rem; line-height: 1; }
.alert-banner strong { display: block; margin-bottom: 2px; }
.alert-banner .muted { margin-top: 2px; }

.alert-warning {
  background: #fdecc8;
  border: 1px solid #f0c070;
  color: #6b4d00;
}
.alert-warning .muted { color: #8a6a1a; }

html[data-theme="dark"] .alert-warning {
  background: #3a2f14;
  color: #f0c070;
}
html[data-theme="dark"] .alert-warning .muted { color: #c9a35e; }

.alert-success {
  background: #d9fdd3;
  border: 1px solid #8fd9a0;
  color: #14532d;
}
html[data-theme="dark"] .alert-success {
  background: #0f3324;
  color: #6fd9a8;
}

/* Estágios da régua — faixa de resumo */
.estagio-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.estagio-pill {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  border-left: 4px solid var(--accent);
}

.estagio-pill .estagio-nome {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.estagio-pill .estagio-total {
  font-size: 1.4rem;
  font-weight: 700;
}

.estagio-pill.d5, .estagio-pill.d0 { border-left-color: #4b5a72; }
.estagio-pill.d3 { border-left-color: #c9860a; }
.estagio-pill.d15 { border-left-color: #b3261e; }
.estagio-pill.d30 { border-left-color: #8a5a00; }

/* Tabela com cabeçalho fixo no scroll */
.table-scroll.tall {
  max-height: 640px;
  overflow-y: auto;
}

.table-scroll.tall thead th {
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

tr.linha-revisar td { background: rgba(179, 38, 30, 0.06); }
html[data-theme="dark"] tr.linha-revisar td { background: rgba(240, 155, 155, 0.08); }

.btn-mini {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.76rem;
  cursor: pointer;
  white-space: nowrap;
}

.btn-mini:hover { background: var(--accent-light); }

.btn-mini.ativo {
  background: #fbdada;
  border-color: #e5a5a5;
  color: #8a1f1f;
}

html[data-theme="dark"] .btn-mini.ativo {
  background: #3a1a1a;
  border-color: #5a2a2a;
  color: #f09b9b;
}

/* Extrato por cliente (inadimplência detalhada) */
.cliente-extrato {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
}

.cliente-extrato.linha-revisar { border-left: 3px solid #b3261e; }

.cliente-extrato-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.cliente-extrato-nome {
  font-weight: 600;
  font-size: 0.98rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cliente-extrato-totais {
  display: flex;
  gap: 20px;
  font-size: 0.88rem;
  flex-wrap: wrap;
}

@media (max-width: 640px) {
  .cliente-extrato { padding: 12px 14px; }
  .cliente-extrato-totais { gap: 12px; flex-direction: column; }
}

/* Agendamentos — calendário mensal */
.agenda-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.agenda-main { flex: 1; min-width: 0; }
.agenda-side { width: 300px; flex-shrink: 0; }

@media (max-width: 900px) {
  .agenda-layout { flex-direction: column; }
  .agenda-side { width: 100%; }
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.calendar-title { font-size: 1.15rem; font-weight: 700; }
.calendar-nav { display: flex; gap: 6px; }
.calendar-nav .btn-mini { text-decoration: none; display: inline-block; }

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 4px;
}

.calendar-weekdays div {
  text-align: center;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  padding: 4px 0;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar-day {
  min-height: 96px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  background: var(--surface-raised);
}

.calendar-day.outside { opacity: 0.35; }
.calendar-day.today { border-color: var(--accent); border-width: 2px; }

.calendar-day-num {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.calendar-day.today .calendar-day-num {
  color: var(--accent-contrast);
  background: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  font-weight: 700;
}

.calendar-day-eventos {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.evento-pill { position: relative; }

.evento-pill summary {
  list-style: none;
  cursor: pointer;
  background: var(--accent-light);
  color: var(--text);
  font-size: 0.66rem;
  padding: 2px 5px;
  border-radius: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.evento-pill summary::-webkit-details-marker { display: none; }
.evento-pill summary::marker { content: ""; }

.evento-pill[open] summary {
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
}

.evento-popup {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 30;
  width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-top: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.evento-popup-nome { font-weight: 700; font-size: 0.9rem; }

.evento-mais {
  font-size: 0.66rem;
  color: var(--text-muted);
  padding: 2px 5px;
}

@media (max-width: 900px) {
  .calendar-day { min-height: 60px; }
  .evento-pill summary { font-size: 0.6rem; }
}

.agenda-lista {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.agenda-lista-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
}

.agenda-lista-item:hover { background: var(--surface-raised); }

.agenda-lista-data {
  width: 42px;
  flex-shrink: 0;
  text-align: center;
  background: var(--surface-raised);
  border-radius: 8px;
  padding: 4px 0;
}

.agenda-lista-dia { font-weight: 700; font-size: 1rem; line-height: 1.1; }
.agenda-lista-mes { font-size: 0.6rem; color: var(--text-muted); text-transform: uppercase; }
.agenda-lista-nome { font-weight: 600; font-size: 0.86rem; }

/* Follow-up — fluxo de etapas conectadas */
.flow-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.flow {
  display: flex;
  flex-direction: column;
}

.flow-step { position: relative; }

.flow-step-badge {
  position: absolute;
  top: -11px;
  right: 16px;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  z-index: 2;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.flow-step-badge.badge-atrasado { color: var(--danger); border-color: var(--danger); }
.flow-step-badge.badge-agendado { color: var(--text-muted); }

.flow-step-card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  background: var(--surface-raised);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s ease;
}

.flow-step-card:hover { border-color: var(--accent); }
.flow-step-card.danger { border-color: rgba(240, 155, 155, 0.5); }

.flow-step-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  flex-shrink: 0;
}

.flow-step-body { flex: 1; min-width: 0; }

.flow-step-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.flow-step-title { font-weight: 700; font-size: 0.94rem; }

.flow-step-tag {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

.flow-step-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.flow-connector {
  width: 2px;
  height: 20px;
  background: var(--border);
  margin: 2px 0 2px 33px;
  position: relative;
}

.flow-connector::after {
  content: "";
  position: absolute;
  bottom: -3px;
  left: -2px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border);
}

.flow-connector.danger { background: rgba(240, 155, 155, 0.5); }
.flow-connector.danger::after { background: var(--danger); }

@media (max-width: 640px) {
  .flow-step-badge { position: static; display: inline-block; margin-bottom: 6px; }
  .flow-step-top { flex-direction: column; align-items: flex-start; gap: 4px; }
}

/* Perfil do lead — estilo hero + dashboard pessoal */
.profile-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.profile-main { flex: 1; min-width: 0; }
.profile-side { width: 300px; flex-shrink: 0; }

@media (max-width: 900px) {
  .profile-layout { flex-direction: column; }
  .profile-side { width: 100%; }
}

.profile-top-grid {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 16px;
}

@media (max-width: 640px) {
  .profile-top-grid { grid-template-columns: 1fr; }
}

.profile-hero {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.profile-hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 12px;
}

.profile-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 700;
  flex-shrink: 0;
}

.profile-badge {
  font-size: 0.68rem;
  font-weight: 600;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.profile-hero-name { font-size: 1.15rem; font-weight: 700; }
.profile-hero-role { color: var(--text-muted); font-size: 0.86rem; margin-top: 2px; }

.profile-hero-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.profile-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 1rem;
}

.profile-icon-btn:hover { border-color: var(--accent); }

.profile-stat-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.profile-stat-card {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
}

.profile-stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
}

.profile-stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }

.profile-split-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  justify-content: center;
}

.profile-split-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
}

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

.profile-charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 640px) {
  .profile-charts-grid { grid-template-columns: 1fr; }
}

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.donut {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.donut-hole {
  width: 68%;
  height: 68%;
  border-radius: 50%;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.donut-center-value { font-size: 1.3rem; font-weight: 700; }

.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
}

.donut-legend-item { display: flex; align-items: center; gap: 8px; }

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

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

.bar-chart-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bar-chart-label { font-size: 0.8rem; color: var(--text-muted); width: 24px; flex-shrink: 0; }

.bar-chart-track {
  flex: 1;
  height: 10px;
  background: var(--surface-raised);
  border-radius: 6px;
  overflow: hidden;
}

.bar-chart-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 6px;
}

.profile-fact {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.86rem;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}

.profile-fact:last-of-type { border-bottom: none; }

.finance-card { border: 1px solid var(--accent); }
.finance-card-title { font-weight: 700; margin-bottom: 10px; }

.finance-card-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.86rem;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.finance-card-row:last-of-type { border-bottom: none; }

.activity-list { display: flex; flex-direction: column; gap: 4px; }

.activity-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
}

.activity-item:last-child { border-bottom: none; }

.activity-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--surface-raised);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.activity-body { flex: 1; min-width: 0; }
.activity-title { font-weight: 600; font-size: 0.84rem; }

.status-sucesso { background: #d9fdd3; color: #1a7f5a; }
.status-falha { background: #fbdada; color: #b3261e; }
html[data-theme="dark"] .status-sucesso { background: #0f3324; color: #6fd9a8; }
html[data-theme="dark"] .status-falha { background: #3a1a1a; color: #f09b9b; }

/* Inadimplência — dashboard estilo fintech */
.kpi-card-v2-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.kpi-card-v2-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.kpi-card-v2-sub { font-size: 0.76rem; margin-top: 4px; }
.kpi-card-v2-sub.good { color: var(--success); }
.kpi-card-v2-sub.bad { color: var(--danger); }
.kpi-card-v2-sub.muted { color: var(--text-muted); }

.dash-grid-3 {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 16px;
}

.dash-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 900px) {
  .dash-grid-3, .dash-grid-2 { grid-template-columns: 1fr; }
}

.card-head-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.mini-bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 120px;
  padding-top: 10px;
}

.mini-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
}

.mini-bar-track {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  background: var(--surface-raised);
  border-radius: 6px;
  overflow: hidden;
}

.mini-bar-fill {
  width: 100%;
  background: var(--accent);
  border-radius: 6px;
  min-height: 3px;
}

.mini-bar-fill.horizontal { height: 100%; width: 0; }

.mini-bar-label {
  font-size: 0.66rem;
  color: var(--text-muted);
  margin-top: 6px;
  white-space: nowrap;
}

.health-score { font-size: 1.05rem; font-weight: 700; margin-top: 6px; }
.health-score-pct { font-size: 2rem; font-weight: 700; color: var(--accent); line-height: 1.2; }

.health-bar {
  height: 10px;
  background: var(--surface-raised);
  border-radius: 6px;
  overflow: hidden;
  margin-top: 8px;
}

.health-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 6px;
}

.balance-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.balance-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
}

.balance-card-name { font-weight: 700; font-size: 0.94rem; }
.balance-card-sub { color: var(--text-muted); font-size: 0.78rem; margin-top: 2px; }
.balance-card-value { margin-left: auto; font-weight: 700; font-size: 1.05rem; white-space: nowrap; }

@media (max-width: 640px) {
  .balance-card { flex-wrap: wrap; }
  .balance-card-value { margin-left: 54px; }
}

.goal-list { display: flex; flex-direction: column; gap: 14px; }

.goal-item-top {
  display: flex;
  justify-content: space-between;
  font-size: 0.86rem;
  margin-bottom: 4px;
}

/* Clientes — workspace estilo CRM */
.workspace-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 20px;
}

.workspace-stats {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.workspace-stat {
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.workspace-stat .muted { font-size: 0.72rem; font-weight: 500; }
.workspace-stat.bad { color: var(--danger); }
.workspace-stat.good { color: var(--success); }
.workspace-stat.warn { color: #c9860a; }

.lead-card-row {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
  cursor: grab;
}

.lead-card-row.arrastando,
.table-scroll.arrastando {
  cursor: grabbing;
  user-select: none;
}

.lead-card-row.arrastando .lead-card {
  pointer-events: none;
}

.lead-card {
  flex: 0 0 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.15s ease;
}

.lead-card:hover { border-color: var(--accent); }

.lead-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 6px;
}

.hot-tag {
  font-size: 0.66rem;
  font-weight: 700;
  background: #fbdada;
  color: #b3261e;
  border: 1px solid #e5a5a5;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

html[data-theme="dark"] .hot-tag {
  background: #3a1a1a;
  color: #f09b9b;
  border-color: #5a2a2a;
}

.lead-card-name { font-weight: 700; font-size: 0.92rem; margin-top: 4px; }
.lead-card-sub { font-size: 0.76rem; }
.lead-card-tags { margin-top: 6px; }

.lead-card-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 10px;
}

.lead-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--surface-raised);
  border: 1px solid var(--border);
}

.lead-dot.filled { background: var(--danger); border-color: var(--danger); }

.filter-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.filter-pill {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
}

.filter-pill:hover { border-color: var(--accent); }

.filter-pill.active {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
  font-weight: 600;
}

/* Status de parcela (régua de cobrança) */
.status-em_aberto { background: #e7ecf3; color: #4b5a72; }
.status-atrasado { background: #fbdada; color: #b3261e; }
.status-pago { background: #d9fdd3; color: #1a7f5a; }
.status-negociando { background: #fdecc8; color: #8a5a00; }

html[data-theme="dark"] .status-em_aberto { background: #2a3040; color: #b7c2d6; }
html[data-theme="dark"] .status-atrasado { background: #3a1a1a; color: #f09b9b; }
html[data-theme="dark"] .status-pago { background: #0f3324; color: #6fd9a8; }
html[data-theme="dark"] .status-negociando { background: #3a2f14; color: #f0c070; }

.status-dot.status-em_aberto { background: #4b5a72; }
.status-dot.status-atrasado { background: #b3261e; }
.status-dot.status-pago { background: #1a7f5a; }
.status-dot.status-negociando { background: #c9860a; }

/* Inbox (estilo caixa de entrada) */
.inbox {
  display: flex;
  height: calc(100vh - 88px);
  min-height: 520px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.inbox-sidebar {
  width: 320px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.inbox-sidebar .search-box {
  margin: 14px 14px 8px;
}

.inbox-sidebar .search-box input { width: 100%; max-width: none; }

.inbox-list {
  overflow-y: auto;
  flex: 1;
}

.inbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  text-decoration: none;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.inbox-item:hover { background: var(--surface-raised); }
.inbox-item.active { background: var(--accent-light); border-left: 3px solid var(--accent); }

.inbox-item-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}

.inbox-item-info { min-width: 0; flex: 1; }

.inbox-item-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.inbox-item-nome {
  font-weight: 600;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inbox-item-hora {
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.inbox-item-preview {
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.inbox-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.inbox-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.inbox-back {
  display: none;
  color: var(--text);
  text-decoration: none;
  font-size: 1.3rem;
  line-height: 1;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .inbox {
    height: calc(100vh - 150px);
  }

  .inbox-sidebar {
    width: 100%;
  }

  .inbox.has-active .inbox-sidebar {
    display: none;
  }

  .inbox:not(.has-active) .inbox-main {
    display: none;
  }

  .inbox-back {
    display: inline-block;
  }

  .inbox-header {
    padding: 12px 14px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .inbox-header .btn {
    padding: 7px 12px;
    font-size: 0.82rem;
  }
}

.inbox-main .chat-thread {
  flex: 1;
  max-height: none;
  padding: 20px;
  overflow-y: auto;
}

@media (max-width: 768px) {
  .inbox-main .chat-thread {
    padding: 14px;
  }
}

.inbox-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.inbox-composer {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.inbox-composer input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
}

.inbox-composer button {
  border-radius: 20px;
}

/* Inbox — painel de mídias/documentos (3ª coluna) */
.inbox-files {
  width: 260px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px;
  overflow-y: auto;
}

.inbox-files-title { font-weight: 700; font-size: 0.94rem; margin-bottom: 14px; }

.inbox-files-stats {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.inbox-files-stat {
  flex: 1;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 6px;
  text-align: center;
}

.inbox-files-stat-num { font-weight: 700; font-size: 1.1rem; }

.inbox-files-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

.inbox-files-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--surface-raised);
}

.inbox-files-item-tipo { font-weight: 600; font-size: 0.8rem; margin-bottom: 3px; }

.inbox-files-item-texto {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}

@media (max-width: 1100px) {
  .inbox-files { display: none; }
}

/* Chip de clique de botão de menu (WhatsApp manda o texto do botão como se
   fosse digitado — isso destaca visualmente que foi um clique, não texto livre) */
.bubble-botao {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  max-width: 75%;
  width: fit-content;
}

.bubble-botao .msg-time {
  font-size: 0.66rem;
  font-weight: 500;
  opacity: 0.75;
}

/* Bolhas de mídia (imagem/áudio/PDF processados por IA) */
.bubble.midia { display: flex; flex-direction: column; gap: 3px; }
.midia-bubble-header { font-weight: 700; font-size: 0.82rem; }
.midia-bubble-texto { font-size: 0.85rem; line-height: 1.42; white-space: pre-wrap; }

.midia-bubble-legenda {
  font-size: 0.78rem;
  font-style: italic;
  opacity: 0.8;
  margin-top: 2px;
}

/* Modal de configurações */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-overlay.open { display: flex; }

.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  width: 340px;
  max-width: 90vw;
}

.modal-box h2 { margin-bottom: 18px; }

.modal-close {
  float: right;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
}

.theme-options {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.theme-option {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
}

.theme-option.active {
  border-color: var(--accent);
  background: var(--accent-light);
  font-weight: 600;
}
