/* Identidade North Vision v1.0: Norte #032457, Royal #0237A5, Rota #0149DB, Horizonte #3F9FFE,
   Névoa #F2F5FA, Linha #DCE3EE, Grafite #4A5568. Texto corrido só em Norte, Grafite ou Branco. */
:root {
  --accent: #0149db;
  --accent-dark: #0237a5;
  --accent-light: rgba(1, 73, 219, 0.09);
  --accent-text: #0149db;
  --bg: #f2f5fa;
  --card: #ffffff;
  --surface-subtle: #eaeff7;
  --border: #dce3ee;
  --text: #032457;
  --text-muted: #4a5568;
  --text-faint: #6b7a90;
  --red: #e5484d;
  --green: #12b76a;
  --amber: #f5a524;
  --purple: #0237a5;
  --badge-red-bg: #fde8e9;
  --badge-red-bg-hover: #fbd3d5;
  --badge-green-bg: #d9f5e7;
  --badge-purple-bg: #dbe6fb;
  --overlay: rgba(3, 36, 87, 0.5);
  --radius: 12px;
  --shadow: 0 1px 2px rgba(3, 36, 87, 0.06), 0 1px 3px rgba(3, 36, 87, 0.04);
  --brand-green: #25d366;
  --green-strong: #0e9f55; /* verde legível como texto sobre fundo claro */
  --font-body: "Outfit", "Segoe UI", Arial, sans-serif;
  --font-display: "Archivo", Arial, sans-serif;
}

:root[data-theme="dark"] {
  --green-strong: #25d366;
  --bg: #021a40;
  --card: #032457;
  --surface-subtle: #0a3170;
  --border: #14407f;
  --text: #f2f5fa;
  --text-muted: #b7c4d9;
  --text-faint: #8195b5;
  --accent-light: rgba(63, 159, 254, 0.16);
  --accent-text: #3f9ffe;
  --red: #ff7a7f;
  --green: #25d366;
  --amber: #f5a524;
  --purple: #3f9ffe;
  --badge-red-bg: rgba(229, 72, 77, 0.25);
  --badge-red-bg-hover: rgba(229, 72, 77, 0.4);
  --badge-green-bg: rgba(18, 183, 106, 0.22);
  --badge-purple-bg: rgba(63, 159, 254, 0.2);
  --overlay: rgba(0, 8, 24, 0.65);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.25);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

button { font-family: inherit; cursor: pointer; color: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 384px;
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid var(--border);
}

.login-card-bar { height: 6px; background: var(--brand-green); }

.login-card-body { padding: 40px 32px 32px; text-align: center; }

.login-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 22px;
  margin: 0 auto 16px;
}

.login-title { margin: 0 0 4px; font-size: 20px; font-weight: 700; }
.login-subtitle { margin: 0 0 24px; color: var(--text-muted); font-size: 13px; }

.login-error {
  color: var(--red);
  font-size: 13px;
  text-align: left;
  margin: -8px 0 12px;
}

.login-hint { margin: 16px 0 0; color: var(--text-faint); font-size: 12px; }

form { text-align: left; }

/* ---------- Form fields ---------- */
.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 14px 0 6px;
}

.field-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.field-input:focus {
  border-color: var(--accent);
  background: var(--accent-light);
}

select.field-input option { background: var(--card); color: var(--text); }

textarea.field-input { resize: vertical; }

/* ---------- Buttons ---------- */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 14px;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--accent-dark); }
.btn-block { width: 100%; margin-top: 18px; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  color: var(--text);
  font-weight: 600;
}
.btn-ghost:hover { background: var(--bg); }

.btn-danger {
  background: var(--badge-red-bg);
  color: var(--red);
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 600;
}
.btn-danger:hover { background: var(--badge-red-bg-hover); }

.btn-sm { padding: 6px 12px; font-size: 12.5px; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-success { background: var(--badge-green-bg); color: var(--green); }
.badge-danger { background: var(--badge-red-bg); color: var(--red); }

/* ---------- Configurações ---------- */
.wa-connect-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
}
.wa-qr-img {
  width: 220px;
  height: 220px;
  border-radius: 10px;
  border: 1px solid var(--border);
  display: block;
  margin: 0 auto 14px;
}

.settings-stack { display: flex; flex-direction: column; gap: 18px; max-width: 640px; }

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

.settings-block-header { margin-bottom: 14px; }
.settings-block-header h2 { margin: 0 0 3px; font-size: 15.5px; }
.settings-block-header p { margin: 0; color: var(--text-muted); font-size: 12.5px; }

.settings-block-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.field-hint { font-size: 11.5px; color: var(--text-faint); margin: 4px 0 0; }

.color-swatches { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 2px; }

.color-swatch {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}
.color-swatch.selected { border-color: var(--text); box-shadow: 0 0 0 2px #fff inset; }

.settings-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.settings-row + .settings-row { margin-top: 12px; }

.user-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--surface-subtle);
}
.user-row:last-child { border-bottom: none; }

.user-row-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12.5px; flex-shrink: 0;
}

.user-row-main { flex: 1; min-width: 0; }
.user-row-name { font-size: 13.5px; font-weight: 600; }
.user-row-email { font-size: 11.5px; color: var(--text-faint); }

.user-row-role {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: 6px;
  padding: 3px 8px;
  flex-shrink: 0;
}

.logo-preview {
  width: 72px; height: 72px; border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--bg);
}

.logo-preview-placeholder {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 22px; flex-shrink: 0;
}

/* ---------- App shell ---------- */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: 236px;
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  position: relative;
  transition: width 0.18s ease;
}

.sidebar-toggle-btn {
  position: absolute;
  top: 22px;
  right: -12px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}
.sidebar-toggle-btn:hover { color: var(--text); background: var(--bg); }
.sidebar-toggle-btn svg { transition: transform 0.18s ease; }

.sidebar.collapsed {
  width: 72px;
  padding-left: 8px;
  padding-right: 8px;
}
.sidebar.collapsed .sidebar-toggle-btn svg { transform: rotate(180deg); }
.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-org-name { display: none; }
.sidebar.collapsed .sidebar-header { justify-content: center; padding-left: 0; padding-right: 0; }
.sidebar.collapsed .nav-item { justify-content: center; padding-left: 0; padding-right: 0; }
.sidebar.collapsed .sidebar-user { justify-content: center; padding-left: 0; padding-right: 0; }
.sidebar.collapsed .nav-badge { position: absolute; top: 4px; right: 10px; }

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 20px;
}

.sidebar-avatar, .sidebar-user-avatar, .chat-header-avatar, .user-avatar-sm {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}

.sidebar-org-name { font-weight: 700; font-size: 14.5px; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; min-height: 0; overflow-y: auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  background: transparent;
  border-radius: 8px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13.5px;
  text-align: left;
  position: relative;
}

.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--accent); color: #fff; font-weight: 600; }
.nav-item.active .nav-icon { color: #fff; }

.nav-icon { width: 17px; height: 17px; color: var(--text-faint); flex-shrink: 0; }
.nav-item.active .nav-icon { color: #fff; }

.nav-badge {
  margin-left: auto;
  background: var(--brand-green);
  color: #032457;
  font-size: 10px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 6px;
  min-width: 16px;
  text-align: center;
}

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

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
}

.sidebar-user-info { min-width: 0; }
.sidebar-user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-email { font-size: 11px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 28px 32px;
  overflow: hidden;
  position: relative;
}

.topbar { flex-shrink: 0; }

.view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: auto;
}

#view-mensagens { overflow: hidden; }

#view-crm { display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 14px;
}

.topbar-btn { position: relative; width: 34px; height: 34px; }

.topbar-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--card);
}

#notif-popover { top: 66px; right: 32px; width: 300px; max-height: 360px; overflow-y: auto; }

.notif-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 8px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
}
.notif-item:hover { background: var(--bg); }
.notif-item-name { font-size: 12.5px; font-weight: 600; }
.notif-item-preview { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.view-header { margin-bottom: 22px; }
.view-header h1 { margin: 0 0 4px; font-size: 21px; }
.view-header p { margin: 0; color: var(--text-muted); font-size: 13px; }

.view-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

/* ---------- Relatórios ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
}

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

.stat-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 8px;
}

.stat-value { font-size: 24px; font-weight: 700; }

/* ---------- Relatórios: anéis de KPI ---------- */

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

.kpi-ring-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transform: translateY(8px);
  animation: kpi-card-in 0.5s ease forwards;
}
.kpi-ring-card:nth-child(2) { animation-delay: 0.08s; }
.kpi-ring-card:nth-child(3) { animation-delay: 0.16s; }
.kpi-ring-card:nth-child(4) { animation-delay: 0.24s; }

@keyframes kpi-card-in { to { opacity: 1; transform: translateY(0); } }

.kpi-ring-wrap { position: relative; width: 96px; height: 96px; }
.kpi-ring { width: 96px; height: 96px; }

.kpi-ring-bg { fill: none; stroke: var(--bg); stroke-width: 10; }
.kpi-ring-fg {
  fill: none;
  stroke: var(--accent);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 326.73;
  stroke-dashoffset: 326.73;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  transition: stroke-dashoffset 1.1s cubic-bezier(0.4, 0, 0.2, 1);
}

.kpi-ring-value {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  font-weight: 800;
  color: var(--text);
}

.kpi-ring-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-align: center; }

/* ---------- Relatórios: gráficos (funil, visitas) ---------- */

.dashboard-charts-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  margin-top: 20px;
}

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

.chart-card-title { font-size: 13.5px; font-weight: 700; margin-bottom: 16px; }

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

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

.funnel-label { width: 118px; flex-shrink: 0; font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.funnel-bar-track { flex: 1; height: 16px; background: var(--bg); border-radius: 999px; overflow: hidden; }

.funnel-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  transition: width 0.9s cubic-bezier(0.4, 0, 0.2, 1);
}

.funnel-count { width: 26px; flex-shrink: 0; text-align: right; font-size: 12.5px; font-weight: 700; }

.visits-status-chart {
  display: flex;
  height: 18px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--bg);
}

.visits-status-segment { height: 100%; width: 0%; transition: width 0.9s cubic-bezier(0.4, 0, 0.2, 1); }

.visits-status-legend { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 16px; }

.visits-status-legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }

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

@media (max-width: 860px) {
  .dashboard-charts-row { grid-template-columns: 1fr; }
}

/* ---------- Mensagens ---------- */
.messages-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 0;
  height: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.conv-list-panel {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}

.conv-list-header { padding: 18px 18px 12px; }
.conv-list-header h2 { margin: 0 0 2px; font-size: 17px; }
.conv-list-header p { margin: 0; color: var(--text-muted); font-size: 12px; }

.conv-search { margin: 0 18px 10px; width: calc(100% - 36px); }

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

.conv-item {
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 10px 18px;
  border: none;
  background: transparent;
  text-align: left;
  border-bottom: 1px solid var(--surface-subtle);
}
.conv-item:hover { background: var(--bg); }
.conv-item.active { background: var(--accent-light); }

.conv-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
  object-fit: cover;
}

.conv-item-main { flex: 1; min-width: 0; }
.conv-item-top { display: flex; justify-content: space-between; gap: 6px; }
.conv-item-name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item-time { font-size: 11px; color: var(--text-faint); flex-shrink: 0; }
.conv-item-preview { font-size: 12.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }

.conv-unread-badge {
  background: var(--brand-green);
  color: #032457;
  font-size: 10px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 6px;
  flex-shrink: 0;
  align-self: center;
}

.chat-panel { display: flex; flex-direction: column; min-height: 0; }

.chat-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-size: 14px;
}

.chat-active { display: flex; flex-direction: column; min-height: 0; height: 100%; position: relative; }

.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.chat-header-info { flex: 1; min-width: 0; }
.chat-header-name { font-weight: 700; font-size: 14.5px; }
.chat-header-phone { font-size: 12px; color: var(--text-muted); }
.chat-header-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-bubble {
  max-width: 62%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.4;
  position: relative;
}

.chat-bubble.in {
  align-self: flex-start;
  background: var(--surface-subtle);
  border-bottom-left-radius: 4px;
}

.chat-bubble.out {
  align-self: flex-end;
  background: var(--brand-green);
  color: #032457;
  border-bottom-right-radius: 4px;
}

.chat-bubble-time {
  display: block;
  font-size: 10px;
  opacity: 0.65;
  margin-top: 3px;
  text-align: right;
}

.chat-day-divider {
  align-self: center;
  font-size: 11px;
  color: var(--text-faint);
  background: var(--bg);
  padding: 3px 10px;
  border-radius: 999px;
  margin: 6px 0;
  text-transform: uppercase;
  font-weight: 600;
}

.chat-input-bar {
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

.chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  outline: none;
}
.chat-input:focus { border-color: var(--accent); }

.chat-send-btn {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--brand-green); color: #032457; border: none;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.chat-send-btn:hover { background: #1fb858; }

/* ---------- CRM Kanban ---------- */
.kanban-board {
  display: flex;
  gap: 14px;
  flex: 1;
  min-height: 0;
  overflow-x: auto;
  padding-bottom: 12px;
  align-items: flex-start;
}

.kanban-column {
  background: var(--surface-subtle);
  border-radius: var(--radius);
  width: 260px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  max-height: 100%;
}

.kanban-column-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px 10px;
  font-weight: 700;
  font-size: 12.5px;
}

.kanban-column-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.kanban-column-count { margin-left: auto; color: var(--text-faint); font-weight: 600; }

.kanban-cards {
  flex: 1;
  overflow-y: auto;
  padding: 0 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 40px;
}

.kanban-card {
  background: var(--card);
  border-radius: 10px;
  padding: 11px 12px;
  box-shadow: var(--shadow);
  cursor: grab;
  border: 1px solid transparent;
}
.kanban-card:active { cursor: grabbing; }
.kanban-card.dragging { opacity: 0.4; }

.kanban-card-name { font-weight: 600; font-size: 13px; margin-bottom: 6px; }

.kanban-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kanban-card-segment {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: 6px;
  padding: 2px 6px;
}

.kanban-card-owner {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; flex-shrink: 0;
}

.kanban-card-value { font-size: 11.5px; color: var(--green); font-weight: 700; margin-top: 4px; }

.kanban-column-dropzone { background: var(--accent-light); }

/* ---------- Contatos ---------- */
.contacts-search { max-width: 340px; margin-bottom: 16px; }

.table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  overflow-x: auto;
}

.data-table { width: 100%; border-collapse: collapse; min-width: 640px; }

.data-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  font-weight: 700;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 12px 18px;
  border-bottom: 1px solid var(--surface-subtle);
  font-size: 13.5px;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg); }

.stage-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
}
.stage-pill::before {
  content: "";
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--dot-color, var(--text-faint));
}

/* ---------- Agenda / Calendário ---------- */
.calendar-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.calendar-month-label { font-weight: 700; font-size: 15px; min-width: 160px; text-align: center; text-transform: capitalize; }
.cal-today-btn { margin-left: 6px; }

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

.calendar-weekday {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-faint);
  text-align: center;
  padding-bottom: 4px;
}

.calendar-day {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-height: 96px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.calendar-day:hover { border-color: var(--accent); }
.calendar-day.other-month { opacity: 0.4; }
.calendar-day.today { border-color: var(--accent); border-width: 2px; }

.calendar-day-num { font-size: 12px; font-weight: 700; }

.calendar-visit-chip {
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--accent-light);
  color: var(--accent-dark);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.calendar-visit-chip.status-cancelada { background: var(--badge-red-bg); color: var(--red); text-decoration: line-through; }
.calendar-visit-chip.status-realizada { background: var(--badge-green-bg); color: var(--green); }
.calendar-visit-chip.status-confirmada { background: var(--badge-purple-bg); color: var(--purple); }

.calendar-more { font-size: 10.5px; color: var(--text-faint); font-weight: 600; }

/* ---------- Modals ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal {
  background: var(--card);
  border-radius: 16px;
  width: 100%;
  max-width: 440px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.2);
}

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

.modal-header h3 { margin: 0; font-size: 16px; }

.modal-close {
  background: transparent;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: var(--text-faint);
  padding: 0 4px;
}
.modal-close:hover { color: var(--text); }

.modal-body { padding: 8px 22px 22px; overflow-y: auto; flex: 1; }

.modal-footer { padding: 14px 22px 20px; }

.modal-form-actions {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.day-visit-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--surface-subtle);
  cursor: pointer;
}
.day-visit-item:last-child { border-bottom: none; }

.day-visit-time { font-weight: 700; font-size: 13px; width: 46px; flex-shrink: 0; }
.day-visit-title { font-weight: 600; font-size: 13px; }
.day-visit-sub { font-size: 11.5px; color: var(--text-muted); }

.day-visit-status {
  margin-left: auto;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
}
.day-visit-status.agendada { background: var(--accent-light); color: var(--accent-text); }
.day-visit-status.confirmada { background: var(--badge-purple-bg); color: var(--purple); }
.day-visit-status.realizada { background: var(--badge-green-bg); color: var(--green); }
.day-visit-status.cancelada { background: var(--badge-red-bg); color: var(--red); }

.day-empty { color: var(--text-faint); text-align: center; padding: 24px 0; font-size: 13px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 200;
  box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}
.toast.error { background: var(--red); }
.toast:not(.error) { background: var(--brand-green); color: #032457; font-weight: 600; }

/* ---------- Mensagens: filtros, tags, arquivar ---------- */

.conv-filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 18px 10px;
}

.conv-type-tabs { display: flex; gap: 4px; background: var(--bg); border-radius: 8px; padding: 2px; }

.conv-type-tab {
  border: none;
  background: transparent;
  padding: 5px 10px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 6px;
}
.conv-type-tab.active { background: var(--card); color: var(--text); box-shadow: var(--shadow); }

.conv-filter-icons { display: flex; gap: 4px; flex-shrink: 0; }

.icon-btn {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 8px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }
.icon-btn.active { background: var(--accent-light); border-color: var(--accent); color: var(--accent-text); }

.conv-list-empty-hint {
  margin: 0 18px 8px;
  font-size: 11.5px;
  color: var(--text-faint);
  font-style: italic;
}

.popover {
  position: absolute;
  z-index: 50;
  top: 88px;
  right: 16px;
  width: 220px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.15);
  padding: 10px;
}

#chat-tag-popover { top: 58px; right: 20px; }

.popover-title { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-faint); margin-bottom: 6px; padding: 0 4px; }

.popover-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 6px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.popover-row:hover { background: var(--bg); }

.popover-row-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.popover-row-name { flex: 1; }
.popover-empty { padding: 10px 6px; font-size: 12px; color: var(--text-faint); }

.popover-add-row {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.popover-add-row input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12.5px;
  background: var(--bg);
}

.chat-view-lead-link { color: var(--accent-text); font-weight: 600; text-decoration: none; margin-left: 2px; }
.chat-view-lead-link:hover { text-decoration: underline; }

.chat-header-icons { display: flex; gap: 6px; margin-left: 10px; flex-shrink: 0; }

.chat-tag-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 0 20px;
}
.chat-tag-chips:empty { display: none; }

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px 2px 6px;
  border-radius: 999px;
  color: #fff;
}
.tag-chip-remove { cursor: pointer; opacity: 0.8; }
.tag-chip-remove:hover { opacity: 1; }

.chat-subtabs {
  display: flex;
  gap: 4px;
  padding: 10px 20px 0;
  border-bottom: 1px solid var(--border);
}

.chat-subtab {
  border: none;
  background: transparent;
  padding: 8px 4px;
  margin-right: 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
}
.chat-subtab.active { color: var(--accent-text); border-bottom-color: var(--accent); }

/* ---------- Mensagens: composer (anexo, áudio, gravação) ---------- */

.chat-attach-btn, .chat-mic-btn {
  width: 36px; height: 36px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 50%;
  flex-shrink: 0;
}
.chat-attach-btn:hover, .chat-mic-btn:hover { background: var(--bg); color: var(--text); }
.chat-mic-btn.recording { color: var(--red); }

.recording-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

.recording-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--red);
  animation: pulse-dot 1.2s infinite;
  flex-shrink: 0;
}
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.recording-label { color: var(--text-muted); font-size: 13px; flex: 1; }

/* ---------- Mensagens: player de áudio ---------- */

.audio-message {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 230px;
}

.audio-play-btn {
  width: 32px; height: 32px; border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.25);
  color: inherit;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.chat-bubble.in .audio-play-btn { background: var(--card); color: var(--text); box-shadow: var(--shadow); }

.audio-track { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.audio-seek { width: 100%; height: 3px; accent-color: currentColor; }
.audio-time { font-size: 10.5px; opacity: 0.75; }

.audio-volume-btn, .audio-more-btn {
  width: 24px; height: 24px;
  border: none; background: transparent; color: inherit; opacity: 0.8;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.audio-volume-btn:hover, .audio-more-btn:hover { opacity: 1; }

/* ---------- Mensagens: mídia (imagem/arquivo) na bolha ---------- */

.chat-media-image { max-width: 220px; border-radius: 10px; display: block; margin-bottom: 4px; }

.chat-media-file {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
}
.chat-media-file-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: rgba(255,255,255,0.25);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.chat-bubble.in .chat-media-file-icon { background: var(--bg); }

/* ---------- Mensagens: bolha com estrela (salvar) ---------- */

.chat-bubble { position: relative; }

.msg-star-btn {
  position: absolute;
  top: -8px;
  width: 20px; height: 20px;
  border: none;
  background: var(--card);
  border-radius: 50%;
  box-shadow: var(--shadow);
  color: var(--text-faint);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.chat-bubble:hover .msg-star-btn { display: flex; }
.chat-bubble.out .msg-star-btn { left: -8px; }
.chat-bubble.in .msg-star-btn { right: -8px; }
.msg-star-btn.starred { display: flex; color: var(--amber); }

/* ---------- Mensagens: abas Arquivos / Links / Salvos ---------- */

.subtab-empty { text-align: center; color: var(--text-faint); padding: 40px 0; font-size: 13px; }

.arquivos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
  padding: 16px 20px;
}
.arquivos-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
}
.arquivos-item img { width: 100%; height: 90px; object-fit: cover; display: block; }
.arquivos-item-file { height: 90px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 6px; text-align: center; font-size: 10.5px; color: var(--text-muted); }
.arquivos-item-date { font-size: 10px; color: var(--text-faint); padding: 4px 6px; }

.links-list { padding: 12px 20px; display: flex; flex-direction: column; gap: 10px; }
.links-item { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.links-item a { color: var(--accent-text); font-weight: 600; font-size: 13px; word-break: break-all; }
.links-item-date { font-size: 10.5px; color: var(--text-faint); margin-top: 2px; }

/* ---------- Lead modal ---------- */

.lead-field { margin-bottom: 14px; }
.lead-field-label { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--text-faint); margin-bottom: 3px; }
.lead-field-value { font-size: 14px; }
.lead-stage-row { display: flex; align-items: center; gap: 10px; }

@media (max-width: 860px) {
  .app-shell { flex-direction: column; height: auto; min-height: 100vh; overflow: visible; }
  html, body { overflow: auto; }
  .sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
  #view-mensagens { overflow-y: auto; }
  .messages-layout { grid-template-columns: 1fr; height: auto; }
  .main-content { padding: 18px; overflow: visible; }
  .view { overflow: visible; }
}

/* ---------- Marca (fixa, não editável pelo sistema) ---------- */
/* Lockup: símbolo oficial + nome em Poppins. Claro: North #073CA4 / Vision #082B56. Escuro: North verde / Vision branco. */
.brand-for-dark { display: none; }
:root[data-theme="dark"] .brand-for-light { display: none; }
:root[data-theme="dark"] .brand-for-dark { display: block; }

.brand-lockup { display: flex; align-items: center; gap: 10px; }
.brand-symbol { height: 38px; width: auto; flex-shrink: 0; }
.brand-word { font-family: "Poppins", Arial, sans-serif; font-weight: 700; font-size: 21px; letter-spacing: -0.01em; line-height: 1; color: #082b56; white-space: nowrap; }
.brand-word b { font-weight: 700; color: #073ca4; }
:root[data-theme="dark"] .brand-word { color: #fff; }
:root[data-theme="dark"] .brand-word b { color: var(--brand-green); }

.brand-lockup-login { justify-content: center; margin: 0 auto 18px; gap: 14px; }
.brand-lockup-login .brand-symbol { height: 56px; }
.brand-lockup-login .brand-word { font-size: 32px; }
.sidebar.collapsed .brand-word { display: none; }

.login-title, .view-title, h1, h2 { font-family: var(--font-display); }
.nav-item.active, .btn-primary { font-family: var(--font-body); }

/* ---------- Foto de perfil ---------- */
.profile-photo-row { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.profile-photo {
  width: 72px; height: 72px; border-radius: 50%; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 22px; flex-shrink: 0;
  border: 1px solid var(--border);
}
.profile-photo img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-user-avatar { overflow: hidden; }

/* ---------- Follow-up ---------- */
.fu-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.fu-row h2 { margin: 0 0 3px; font-size: 15.5px; }

.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch-track { position: absolute; inset: 0; background: var(--border); border-radius: 999px; transition: background 0.15s; cursor: pointer; }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked + .switch-track { background: var(--brand-green); }
.switch input:checked + .switch-track::after { transform: translateX(20px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

.fu-step { border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 12px; background: var(--bg); }
.fu-step-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.fu-inline { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.fu-inline .field-input { margin: 0; }
.fu-text { font-size: 13px; color: var(--text-muted); padding-bottom: 9px; }
.fu-num { width: 80px; }
.fu-unit { width: 110px; }
.fu-grow { flex: 1; min-width: 200px; }
.fu-msg-head { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; gap: 10px; }
.fu-msg-head .field-label { margin: 0; }
.fu-insert { width: 190px; font-size: 12.5px; padding: 5px 8px; }
.fu-msg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 6px; }
.fu-bubble-wrap { background: var(--surface-subtle); border-radius: 10px; padding: 12px; display: flex; align-items: flex-start; }
.fu-bubble { background: #d9fdd3; color: #0b2a14; border-radius: 10px 10px 2px 10px; padding: 8px 12px; font-size: 13px; white-space: pre-wrap; max-width: 100%; word-break: break-word; }
@media (max-width: 760px) { .fu-msg-grid { grid-template-columns: 1fr; } }

.fu-days { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.fu-day { border: 1px solid var(--border); background: var(--card); color: var(--text-muted); border-radius: 999px; padding: 6px 14px; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.fu-day.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.fu-save-row { display: flex; justify-content: flex-start; }

.fu-item { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--surface-subtle); }
.fu-item:last-child { border-bottom: none; }
.fu-item-main { min-width: 0; }
.fu-item-title { font-weight: 600; font-size: 13.5px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.fu-item-msg { font-size: 12.5px; color: var(--text-muted); margin: 3px 0; white-space: pre-wrap; word-break: break-word; }
.fu-item-actions { display: flex; gap: 6px; flex-shrink: 0; }
.fu-tag { font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-subtle); color: var(--text-muted); }
.fu-tag-sent { background: var(--badge-green-bg); color: var(--green); }
.fu-tag-failed, .fu-tag-cancelled { background: var(--badge-red-bg); color: var(--red); }
.fu-tag-rescheduled { background: var(--accent-light); color: var(--accent-text); }

/* ---------- Verde da marca: destaques moderados ---------- */
.nav-item.active::before { content: ""; position: absolute; left: -8px; top: 22%; bottom: 22%; width: 3px; border-radius: 3px; background: var(--brand-green); }
.sidebar.collapsed .nav-item.active::before { left: -6px; }
.sidebar-user-avatar { position: relative; overflow: visible; }
.sidebar-user-avatar::after { content: ""; position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand-green); border: 2px solid var(--card); }
.sidebar-user-avatar img { border-radius: 50%; }
#stat-won, #stat-value-won, .kanban-card-value { color: var(--green-strong); }
.kpi-ring-card:nth-child(even) .kpi-ring-fg { stroke: var(--brand-green); }
.badge-success, .calendar-visit-chip.status-realizada, .day-visit-status.realizada, .fu-tag-sent { color: var(--green-strong); }

/* ---------- Detalhe de marca na base do menu: símbolo grande, cortado, sem invadir Configurações ---------- */
.sidebar-deco { position: relative; flex: 0 0 150px; overflow: hidden; pointer-events: none; margin: 0 -12px; }
.sidebar-deco img { position: absolute; left: -34px; bottom: -58px; width: 190px; height: auto; opacity: 0.1; transform: rotate(-4deg); }
:root[data-theme="dark"] .sidebar-deco img { opacity: 0.09; }
.sidebar.collapsed .sidebar-deco { display: none; }
@media (max-height: 700px) { .sidebar-deco { display: none; } }
@media (max-width: 900px) { .sidebar-deco { display: none; } }

/* ---------- Vídeo de fundo do login ---------- */
.login-screen { position: relative; overflow: hidden; }
.login-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.8s ease; z-index: 0; }
.login-video.ready { opacity: 1; }
/* Overlay de Azul Norte (manual: 55–70%) para o vídeo não disputar com o formulário */
.login-video-overlay { position: absolute; inset: 0; z-index: 1; background: linear-gradient(160deg, rgba(3, 36, 87, 0.62), rgba(3, 36, 87, 0.78)); opacity: 0; transition: opacity 0.8s ease; pointer-events: none; }
.login-video.ready + .login-video-overlay { opacity: 1; }
.login-card { position: relative; z-index: 2; }
