/* =====================================================
   CRM IRM — Stylesheet Principal
   ===================================================== */

:root {
  --bg:          #0f1117;
  --surface:     #1a1d27;
  --surface2:    #222638;
  --border:      #2e3248;
  --accent:      #4361ee;
  --accent-h:    #3a54d4;
  --success:     #2dc653;
  --danger:      #ef233c;
  --warning:     #f48c06;
  --info:        #3a86ff;
  --text:        #e2e8f0;
  --text-muted:  #8892a4;
  --radius:      10px;
  --radius-sm:   6px;
  --shadow:      0 4px 24px rgba(0,0,0,.45);
  --transition:  .18s ease;
  --sidebar-w:   240px;

  /* Sidebar tem cor própria da marca do cliente — não muda com o tema claro/escuro */
  --sidebar-bg:         var(--surface);
  --sidebar-text:       #e2e8f0;
  --sidebar-text-muted: #8892a4;
}

/* ---- Tema claro ---- */
/* A cor de destaque (--accent) da empresa é preservada nos dois temas —
   só o fundo, superfícies, bordas e texto mudam de contraste. */
[data-theme="light"] {
  --bg:          #f3f4f8;
  --surface:     #ffffff;
  --surface2:    #f1f2f7;
  --border:      #e2e5ee;
  --text:        #171a24;
  --text-muted:  #5c6270;
  --shadow:      0 4px 20px rgba(30,34,60,.08);
}

[data-theme="light"] .modal-overlay { background: rgba(20,22,35,.45); }
[data-theme="light"] .kanban-card:hover { box-shadow: 0 4px 14px rgba(30,34,60,.12); }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ===================================================
   LAYOUT APP
   =================================================== */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-logo {
  padding: 24px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo span {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--sidebar-text);
  letter-spacing: -.02em;
}

.sidebar-logo .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-group-label {
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--sidebar-text-muted);
  padding: 14px 20px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--sidebar-text-muted);
  font-size: .88rem;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all var(--transition);
  user-select: none;
}

.nav-item:hover {
  background: rgba(255,255,255,.07);
  color: var(--sidebar-text);
}

.nav-item.active {
  background: rgba(255,255,255,.07);
  color: var(--accent);
  border-left-color: var(--accent);
}

.nav-item .icon { font-size: 1rem; width: 20px; text-align: center; }

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: .68rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 99px;
  min-width: 18px;
  text-align: center;
}

.sidebar-user {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.user-info { flex: 1; min-width: 0; }
.user-info .name { font-size: .83rem; font-weight: 600; color: var(--sidebar-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info .role { font-size: .72rem; color: var(--sidebar-text-muted); text-transform: capitalize; }

.btn-logout {
  background: none;
  border: none;
  color: var(--sidebar-text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px;
  transition: color var(--transition);
}
.btn-logout:hover { color: var(--danger); }

/* Select de troca de empresa — cor sólida fixa (fundo translúcido não
   é respeitado pela lista nativa de opções em vários navegadores) */
.sidebar-select {
  background: #1c1f2c;
  border: 1px solid rgba(255,255,255,.14);
  color: #e2e8f0;
}
.sidebar-select option {
  background: #1c1f2c;
  color: #e2e8f0;
  padding: 6px;
}

/* ---- Main ---- */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.page-header {
  padding: 22px 28px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -.02em;
}

.page-body {
  padding: 20px 28px 32px;
  flex: 1;
}

/* ===================================================
   COMPONENTES
   =================================================== */

/* ---- Botões ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1.4;
}

.btn-primary   { background: var(--accent);   color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-h); border-color: var(--accent-h); }

.btn-success   { background: var(--success);  color: #fff; }
.btn-success:hover { filter: brightness(1.1); }

.btn-danger    { background: var(--danger);   color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }

.btn-ghost     { background: transparent;     color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }

.btn-sm { padding: 5px 10px; font-size: .78rem; }
.btn-icon { padding: 7px; }

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

/* ---- Inputs ---- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: .8rem; font-weight: 500; color: var(--text-muted); margin-bottom: 5px; }

.form-control, .form-select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  transition: border-color var(--transition);
  outline: none;
}

.form-control:focus, .form-select:focus {
  border-color: var(--accent);
}

textarea.form-control { resize: vertical; min-height: 80px; }

.form-row { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ---- Badge ---- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-success { background: rgba(45,198,83,.15); color: var(--success); }
.badge-danger  { background: rgba(239,35,60,.15);  color: var(--danger); }
.badge-warning { background: rgba(244,140,6,.15);  color: var(--warning); }
.badge-info    { background: rgba(58,134,255,.15); color: var(--info); }
.badge-muted   { background: var(--surface2); color: var(--text-muted); }

/* ---- Tabela ---- */
.table-wrap { overflow-x: auto; }

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

thead th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

tbody tr:hover { background: var(--surface2); }
tbody td { padding: 10px 12px; }

/* ---- Cabeçalhos ordenáveis ---- */
.th-sort {
  cursor: pointer;
  user-select: none;
  transition: color var(--transition);
}
.th-sort:hover { color: var(--text); }
.th-sort::after {
  content: '↕';
  margin-left: 5px;
  opacity: .35;
  font-size: .7rem;
}
.th-sort.sorted-asc::after  { content: '↑'; opacity: 1; color: var(--accent); }
.th-sort.sorted-desc::after { content: '↓'; opacity: 1; color: var(--accent); }

/* ---- Toolbar de busca ---- */
.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}

.search-wrap { position: relative; flex: 1; min-width: 200px; }
.search-wrap input {
  padding-left: 34px;
}
.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: .9rem;
  pointer-events: none;
}

/* ---- Paginação ---- */
.pagination {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 16px;
  flex-wrap: wrap;
}

.page-btn {
  min-width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-muted);
  font-size: .8rem;
  cursor: pointer;
  transition: all var(--transition);
}
.page-btn:hover, .page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-btn:disabled { opacity: .35; cursor: not-allowed; }

/* ---- Toast ---- */
#toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}

.toast {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: .85rem;
  min-width: 240px;
  max-width: 360px;
  box-shadow: var(--shadow);
  animation: slideIn .2s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast.toast-success { border-color: var(--success); }
.toast.toast-error   { border-color: var(--danger); }
.toast .toast-icon   { font-size: 1rem; flex-shrink: 0; }

@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 20px;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: fadeUp .2s ease;
}

.modal-lg { max-width: 760px; }

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

.modal-title { font-size: 1rem; font-weight: 600; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 2px;
}
.modal-close:hover { color: var(--danger); }

.modal-body { padding: 20px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

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

/* ---- Loading ---- */
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-muted);
  padding: 40px;
}

/* ---- Transição entre telas (SPA) ---- */
#spa-root.spa-fade-in { animation: spaFadeIn .28s ease; }

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

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 48px 20px;
}

.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 10px; }
.empty-state p { font-size: .88rem; }

/* ===================================================
   KANBAN
   =================================================== */

.kanban-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 28px 0;
  flex-wrap: wrap;
}

.kanban-board {
  display: flex;
  gap: 14px;
  padding: 16px 28px 28px;
  overflow-x: auto;
  align-items: flex-start;
  flex: 1;
  min-height: 0;
}

.kanban-col {
  flex: 0 0 260px;
  min-width: 260px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.kanban-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 8px;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: none;
  gap: 8px;
}

.col-title-wrap { display: flex; align-items: center; gap: 8px; }

.col-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.col-name {
  font-size: .82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.col-count {
  background: var(--surface2);
  color: var(--text-muted);
  font-size: .72rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 99px;
}

.kanban-cards {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 80px;
  transition: background var(--transition);
}

.kanban-cards.drag-over {
  background: var(--surface2);
  border-color: var(--accent);
}

/* ---- Kanban Card ---- */
.kanban-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  cursor: grab;
  transition: all var(--transition);
  user-select: none;
}

.kanban-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
}

.kanban-card:active { cursor: grabbing; }
.kanban-card.dragging { opacity: .4; transform: rotate(2deg); }

.card-title {
  font-size: .83rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}

.card-contact {
  font-size: .75rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
}

.card-value {
  font-size: .75rem;
  font-weight: 600;
  color: var(--success);
}

.card-resp {
  font-size: .72rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 3px;
}

.card-late {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: .7rem;
  color: var(--danger);
  font-weight: 600;
}

/* ===================================================
   DASHBOARD
   =================================================== */

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

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

.metric-label {
  font-size: .75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 6px;
}

.metric-value {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.1;
}

.metric-value.green  { color: var(--success); }
.metric-value.red    { color: var(--danger); }
.metric-value.blue   { color: var(--info); }
.metric-value.yellow { color: var(--warning); }

.metric-sub { font-size: .75rem; color: var(--text-muted); margin-top: 4px; }

/* Gráfico de barras simples */
.bar-chart { display: flex; flex-direction: column; gap: 10px; }

.bar-item { display: flex; align-items: center; gap: 10px; font-size: .8rem; }
.bar-label { width: 150px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; }
.bar-track { flex: 1; height: 8px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.bar-fill  { height: 100%; border-radius: 4px; transition: width .6s cubic-bezier(.22,1,.36,1); position: relative; }
.bar-val   { width: 50px; text-align: right; color: var(--text-muted); font-size: .75rem; }

/* ---- Barras com brilho (glow) ---- */
.bar-track.glow { height: 9px; background: var(--surface2); }
.bar-fill.glow {
  box-shadow: 0 0 10px -1px currentColor, 0 0 2px 0 currentColor;
  position: relative;
}
.bar-fill.glow::after {
  content: '';
  position: absolute; top: 50%; right: 0;
  width: 8px; height: 8px;
  background: #fff;
  border-radius: 50%;
  transform: translate(40%, -50%);
  box-shadow: 0 0 8px 2px currentColor;
  opacity: .9;
}

/* ---- Gráfico de linha/área com brilho ---- */
.chart-glow-line   { filter: drop-shadow(0 0 5px var(--accent)); }
.chart-glow-dot     { filter: drop-shadow(0 0 4px var(--accent)); cursor: pointer; }
.chart-glow-dot:hover { r: 5; }

/* ---- Gráfico de barras verticais ---- */
.vbar-chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 160px;
  padding-top: 10px;
}
.vbar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  min-width: 0;
}
.vbar-track {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.vbar-fill {
  width: 60%;
  min-width: 14px;
  border-radius: 6px 6px 2px 2px;
  transition: height .6s cubic-bezier(.22,1,.36,1);
  cursor: pointer;
  box-shadow: 0 0 12px -2px currentColor;
}
.vbar-fill:hover { filter: brightness(1.25); box-shadow: 0 0 18px -1px currentColor; }
.vbar-label {
  margin-top: 8px;
  font-size: .68rem;
  color: var(--text-muted);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}
.vbar-value { font-size: .7rem; font-weight: 600; margin-bottom: 4px; color: var(--text); }

/* ---- Donut chart ---- */
.donut-wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
}
.donut-svg circle.donut-seg {
  cursor: pointer;
  transition: stroke-width .18s ease, opacity .18s ease;
  filter: drop-shadow(0 0 4px currentColor);
}
.donut-svg circle.donut-seg:hover { stroke-width: 22; filter: drop-shadow(0 0 8px currentColor); }
.donut-center-value { font-size: 1.5rem; font-weight: 700; fill: var(--text); }
.donut-center-label { font-size: .6rem; fill: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }

.donut-legend { display: flex; flex-direction: column; gap: 8px; font-size: .78rem; }
.donut-legend-item { display: flex; align-items: center; gap: 8px; cursor: default; }
.donut-legend-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 6px 0 currentColor; }
.donut-legend-name { color: var(--text-muted); flex: 1; }
.donut-legend-val { font-weight: 600; }

/* ---- Tooltip de gráfico ---- */
.chart-tooltip {
  position: fixed;
  z-index: 9999;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 11px;
  font-size: .76rem;
  box-shadow: var(--shadow);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .12s ease, transform .12s ease;
  white-space: nowrap;
}
.chart-tooltip.visible { opacity: 1; transform: translateY(0); }
.chart-tooltip strong { color: var(--text); }

/* ---- Gauge circular (ex.: taxa de conversão) ---- */
.gauge-wrap { display: flex; align-items: center; justify-content: center; }
.gauge-svg circle.gauge-track { opacity: .5; }
.gauge-svg circle.gauge-fill {
  transition: stroke-dashoffset .7s cubic-bezier(.22,1,.36,1);
  filter: drop-shadow(0 0 5px currentColor);
}

/* ===================================================
   DETALHE NEGOCIAÇÃO / CONTATO (painel lateral)
   =================================================== */

.detail-panel {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

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

.timeline { display: flex; flex-direction: column; gap: 0; }

.timeline-item {
  display: flex;
  gap: 12px;
  padding-bottom: 16px;
  position: relative;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: 12px;
  top: 26px;
  bottom: 0;
  width: 1px;
  background: var(--border);
}

.timeline-item:last-child::before { display: none; }

.timeline-dot {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--surface2);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .7rem;
  flex-shrink: 0;
  z-index: 1;
}

.timeline-content { flex: 1; }
.timeline-meta { font-size: .72rem; color: var(--text-muted); margin-bottom: 3px; }
.timeline-text { font-size: .83rem; }

/* ===================================================
   PÁGINA DE LOGIN
   =================================================== */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -.04em;
  color: var(--text);
}

.login-logo p {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.login-error {
  background: rgba(239,35,60,.1);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: .83rem;
  color: var(--danger);
  margin-bottom: 14px;
}

/* ===================================================
   RESPONSIVIDADE
   =================================================== */

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    transform: translateX(-100%);
    width: 240px;
  }

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

  .main-content { margin-left: 0; }

  .page-header { padding: 16px 16px 0; }
  .page-body   { padding: 14px 16px 24px; }
  .kanban-board { padding: 14px 16px 24px; }
  .kanban-toolbar { padding: 12px 16px 0; }

  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }

  .detail-side { width: 100%; }
}

/* ===================================================
   UTILITÁRIOS
   =================================================== */

.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: .8rem; }
.text-right { text-align: right; }
.w-100 { width: 100%; }
.hidden { display: none !important; }
.bold { font-weight: 600; }

/* ===================================================
   CONVERSAS (WhatsApp)
   =================================================== */

.conv-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 0;
  height: calc(100vh - 84px);
  margin: 14px 28px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* ---- Coluna esquerda: lista de clientes ---- */
.conv-lista {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
}

.conv-lista-busca { padding: 12px; border-bottom: 1px solid var(--border); }
.conv-lista-itens { flex: 1; overflow-y: auto; min-height: 0; }

.conv-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 13px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}
.conv-item:hover  { background: var(--surface2); }
.conv-item.active { background: var(--surface2); box-shadow: inset 3px 0 0 var(--accent); }

.conv-item-avatar {
  width: 36px; height: 36px; flex-shrink: 0;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: .85rem;
}

.conv-item-corpo { flex: 1; min-width: 0; }
.conv-item-nome {
  font-size: .86rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-item-previa {
  font-size: .75rem; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-item-meta {
  display: flex; flex-direction: column; align-items: flex-end;
  gap: 4px; flex-shrink: 0;
}
.conv-item-hora { font-size: .66rem; color: var(--text-muted); white-space: nowrap; }

/* Bolinha de estado da janela gratuita */
.conv-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.conv-dot.aberta   { background: var(--success); }
.conv-dot.fechada  { background: var(--text-muted); opacity: .5; }

/* ---- Coluna direita: chat ---- */
.conv-chat { display: flex; flex-direction: column; min-height: 0; background: var(--bg); }

.conv-chat-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.conv-chat-header .voltar { display: none; }

.conv-msgs {
  flex: 1; overflow-y: auto; min-height: 0;
  padding: 18px;
  display: flex; flex-direction: column; gap: 8px;
}

.conv-bolha {
  max-width: min(72%, 560px);
  padding: 8px 12px 6px;
  border-radius: 12px;
  font-size: .85rem;
  line-height: 1.45;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.conv-bolha.recebida {
  align-self: flex-start;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 3px;
}
.conv-bolha.enviada {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 3px;
}
.conv-bolha.falhou { background: var(--danger); color: #fff; }

.conv-bolha-rodape {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 6px; margin-top: 3px;
  font-size: .64rem; opacity: .75;
}
.conv-bolha.recebida .conv-bolha-rodape { justify-content: flex-start; }

.conv-dia {
  align-self: center;
  font-size: .68rem; color: var(--text-muted);
  background: var(--surface); border: 1px solid var(--border);
  padding: 2px 12px; border-radius: 999px;
  margin: 6px 0;
}

/* ---- Rodapé: composer ou aviso de bloqueio ---- */
.conv-rodape { border-top: 1px solid var(--border); background: var(--surface); flex-shrink: 0; }

.conv-composer { display: flex; gap: 10px; align-items: flex-end; padding: 12px 16px; }
.conv-composer textarea {
  flex: 1; resize: none; max-height: 130px; min-height: 42px;
  font-family: inherit; font-size: .85rem;
}

.conv-bloqueio {
  padding: 14px 18px;
  display: flex; gap: 12px; align-items: center;
  background: rgba(244,140,6,.08);
  border-top: 2px solid var(--warning);
}
.conv-bloqueio .icone { font-size: 1.3rem; flex-shrink: 0; }
.conv-bloqueio .texto { flex: 1; font-size: .8rem; line-height: 1.45; }
.conv-bloqueio .texto strong { color: var(--warning); }

.conv-vazio {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px; color: var(--text-muted); text-align: center; padding: 30px;
}

/* Etiqueta de janela no cabeçalho do chat */
.conv-janela-tag {
  font-size: .7rem; font-weight: 600;
  padding: 3px 10px; border-radius: 999px;
  white-space: nowrap;
}
.conv-janela-tag.aberta  { background: rgba(45,198,83,.14); color: var(--success); }
.conv-janela-tag.fechada { background: rgba(136,146,164,.16); color: var(--text-muted); }

/* ---- Responsivo: vira uma coluna só ---- */
@media (max-width: 820px) {
  .conv-layout { grid-template-columns: 1fr; margin: 10px 12px 16px; height: calc(100vh - 130px); }
  .conv-layout .conv-chat  { display: none; }
  .conv-layout .conv-lista { border-right: none; }
  .conv-layout.mostrando-chat .conv-lista { display: none; }
  .conv-layout.mostrando-chat .conv-chat  { display: flex; }
  .conv-chat-header .voltar { display: inline-flex; }
}

/* ===================================================
   PÁGINAS LEGAIS (Privacidade / Termos)
   =================================================== */

.legal-page {
  min-height: 100vh;
  background: var(--bg);
  padding: 32px 20px 64px;
}

.legal-container {
  max-width: 760px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 44px;
  box-shadow: var(--shadow);
}

.legal-header { margin-bottom: 28px; }

.legal-back {
  display: inline-block;
  font-size: .82rem;
  color: var(--text-muted);
  margin-bottom: 18px;
}
.legal-back:hover { color: var(--accent); text-decoration: none; }

.legal-header h1 {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -.03em;
  color: var(--text);
}

.legal-updated {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.legal-body { color: var(--text); line-height: 1.7; }

.legal-intro {
  font-size: .95rem;
  color: var(--text);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 8px;
}

.legal-body h2 {
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--text);
  margin: 28px 0 10px;
  padding-top: 8px;
}

.legal-body h3 {
  font-size: .98rem;
  font-weight: 600;
  color: var(--text);
  margin: 18px 0 8px;
}

.legal-body p { margin: 0 0 12px; font-size: .9rem; }

.legal-body ul {
  margin: 0 0 14px;
  padding-left: 22px;
}
.legal-body li { margin-bottom: 6px; font-size: .9rem; }

.legal-body strong { color: var(--text); font-weight: 600; }
.legal-body a { color: var(--accent); }

.legal-footer {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  margin-top: 36px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: .82rem;
  color: var(--text-muted);
}
.legal-footer a { color: var(--text-muted); }
.legal-footer a:hover { color: var(--accent); text-decoration: none; }

@media (max-width: 600px) {
  .legal-container { padding: 28px 22px; }
  .legal-header h1 { font-size: 1.4rem; }
}

/* ---- Aviso LGPD na tela de login ---- */
.login-lgpd {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: .72rem;
  line-height: 1.55;
  color: rgba(255,255,255,0.62);
  text-align: center;
}
.login-lgpd a {
  color: rgba(255,255,255,0.85);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.login-lgpd a:hover { color: #fff; }
