@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Inter:wght@300;400;500;600&display=swap');


:root {
  --header-bg: #0f2b35;
  --section-tag: #6366f1;
  --accent: #6366f1;
  --accent2: #00c896;
  --bg: #f4f6f9;
  --bg-white: #ffffff;
  --border: #d0d7e3;
  --border-dash: #a0aec0;
  --text: #1a2035;
  --text-muted: #6b7a99;
  --sidebar-w: 220px;
  --topbar-h: 80px;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,0.07);
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── SIDEBAR ── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--header-bg);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-logo {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-logo img { height: 36px; object-fit: contain; }
.logo-text {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 800;
  font-size: 1.3rem;
  color: white;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-radius: 10px;
  text-decoration: none;
  color: rgba(255,255,255,0.65);
  font-size: 0.88rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.nav-item:hover { background: rgba(255,255,255,0.1); color: white; }

.nav-item.active {
  background: rgba(255,255,255,0.15);
  color: white;
  border-left: 3px solid var(--accent2);
}

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

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: rgba(255,255,255,0.5);
}

.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  flex-shrink: 0;
}
.status-dot.online { background: var(--accent2); box-shadow: 0 0 6px var(--accent2); }

/* ── TOPBAR ── */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  height: var(--topbar-h);
  background: var(--header-bg);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  z-index: 90;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: white;
  font-size: 1.4rem;
  cursor: pointer;
}

.topbar-title {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: white;
  flex: 1;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.filter-label {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.6);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.topbar-select {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  color: white;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  outline: none;
  font-family: 'Inter', sans-serif;
}

.topbar-select option { background: var(--header-bg); color: white; }

.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--section-tag);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 0.9rem;
  color: white;
}

/* ── MAIN ── */
.main-content {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  padding: 28px;
  min-height: calc(100vh - var(--topbar-h));
}

.page { display: none; }
.page.active { display: block; animation: fadeIn 0.3s ease; }

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

/* ── SECTION TAG ── */
.section-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--section-tag);
  color: white;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 8px 16px;
  border-radius: 8px 8px 0 0;
  margin-bottom: 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.section-block {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 0 12px 12px 12px;
  padding: 24px;
  margin-bottom: 28px;
  box-shadow: var(--shadow);
}

.section-block-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* ── BIG NUMBERS ── */
.big-numbers {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.big-numbers.cols-4 { grid-template-columns: repeat(4, 1fr); }
.big-numbers.cols-5 { grid-template-columns: repeat(5, 1fr); }

.kpi-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform .22s cubic-bezier(.2,.8,.2,1), box-shadow .22s ease, border-color .22s ease;
  position: relative;
  overflow: hidden;
  cursor: default;
}

/* Barrinha lateral colorida (accent) que aparece no hover */
.kpi-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--section-tag), var(--accent2));
  opacity: 0;
  transition: opacity .22s ease;
}

.kpi-card:hover {
  border-color: rgba(99,102,241,0.3);
  box-shadow: 0 8px 24px rgba(15,43,53,0.08), 0 2px 4px rgba(15,43,53,0.04);
  transform: translateY(-3px);
}
.kpi-card:hover::before { opacity: 1; }

.kpi-card.solid {
  border: 1px solid var(--border);
  border-style: solid;
}

.kpi-value {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.9rem;
  color: var(--text);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.kpi-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.kpi-trend {
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.kpi-trend.up { color: #16a34a; }
.kpi-trend.down { color: #dc2626; }

.kpi-pending {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── SPARKLINE dentro do KPI card ── */
.kpi-sparkline {
  height: 28px;
  width: 100%;
  margin-top: 4px;
  opacity: .85;
  transition: opacity .2s ease;
  pointer-events: none;
}
.kpi-card:hover .kpi-sparkline { opacity: 1; }
.kpi-sparkline svg { width: 100%; height: 100%; display: block; overflow: visible; }
.kpi-sparkline .spark-area { fill: currentColor; opacity: .12; }
.kpi-sparkline .spark-line { fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.kpi-sparkline .spark-dot { fill: currentColor; }
.kpi-sparkline.color-accent { color: var(--section-tag); }
.kpi-sparkline.color-green  { color: #10b981; }
.kpi-sparkline.color-orange { color: #f97316; }
.kpi-sparkline.color-blue   { color: #2563eb; }
.kpi-sparkline.color-teal   { color: #1b4f5a; }
.kpi-sparkline.color-purple { color: #7b2fbe; }

/* Stagger animation para KPIs entrando */
.big-numbers .kpi-card {
  animation: kpiFadeUp .5s cubic-bezier(.2,.8,.2,1) both;
}
.big-numbers .kpi-card:nth-child(1) { animation-delay: .00s; }
.big-numbers .kpi-card:nth-child(2) { animation-delay: .05s; }
.big-numbers .kpi-card:nth-child(3) { animation-delay: .10s; }
.big-numbers .kpi-card:nth-child(4) { animation-delay: .15s; }
.big-numbers .kpi-card:nth-child(5) { animation-delay: .20s; }
.big-numbers .kpi-card:nth-child(6) { animation-delay: .25s; }
@keyframes kpiFadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ════════════════════════════════════════════════════════════════════
   TOOLTIP customizado (substitui title= nativo)
════════════════════════════════════════════════════════════════════ */
.kb-tip-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: rgba(99,102,241,.1);
  color: var(--section-tag);
  font-size: .7rem;
  font-weight: 700;
  cursor: help;
  user-select: none;
  transition: background .15s, transform .15s;
  border: 1px solid rgba(99,102,241,.2);
}
.kb-tip-trigger:hover {
  background: var(--section-tag);
  color: #fff;
  transform: scale(1.08);
}

#kbTooltip {
  position: fixed;
  z-index: 9999;
  max-width: 340px;
  background: #1a2035;
  color: #f1f5f9;
  font-size: .78rem;
  line-height: 1.55;
  padding: 12px 14px;
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,.25), 0 4px 8px rgba(0,0,0,.1);
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .18s ease, transform .18s ease;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 400;
}
#kbTooltip.show {
  opacity: 1;
  transform: translateY(0);
}
#kbTooltip strong {
  display: block;
  margin-bottom: 4px;
  color: #fff;
  font-weight: 700;
  font-size: .82rem;
}
#kbTooltip .kb-tip-list {
  margin-top: 6px;
  padding: 0;
  list-style: none;
}
#kbTooltip .kb-tip-list li {
  padding: 3px 0;
  color: rgba(241,245,249,.8);
}
#kbTooltip .kb-tip-list li strong {
  display: inline;
  color: #a5b4fc;
  font-weight: 600;
  margin: 0;
  font-size: inherit;
}
/* Seta apontando pro trigger */
#kbTooltip::after {
  content: '';
  position: absolute;
  width: 0; height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
}
#kbTooltip.arrow-top::after {
  top: -6px; left: var(--arrow-x, 20px);
  border-bottom: 6px solid #1a2035;
}
#kbTooltip.arrow-bottom::after {
  bottom: -6px; left: var(--arrow-x, 20px);
  border-top: 6px solid #1a2035;
}

/* Indicador "Atualizado a cada 30min" com dot pulsante */
.live-dot-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .68rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
}
.live-dot-indicator::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent2);
  box-shadow: 0 0 0 0 rgba(0,200,150,.5);
  animation: liveDotPulse 2s ease-in-out infinite;
}
@keyframes liveDotPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(0,200,150,.5); }
  50%     { box-shadow: 0 0 0 6px rgba(0,200,150,0); }
}

/* ── SECÇÃO block-title com flex pra comportar tooltip+badge ── */
.section-block-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.section-block-title-row .section-block-title {
  margin: 0;
  padding: 0;
  border: none;
}


/* ── CHARTS GRID ── */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

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

.chart-card.wide { grid-column: span 2; }
.chart-card.col3 { grid-column: span 1; }

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

.chart-header h3 {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
}

canvas { max-height: 240px !important; }

/* ── CONSULTANT SELECTOR ── */
.consultant-selector {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.consultant-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-white);
  color: var(--text-muted);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  font-size: 0.88rem;
  transition: all 0.2s;
  box-shadow: var(--shadow);
}

.consultant-btn.active {
  background: var(--section-tag);
  color: white;
  border-color: var(--section-tag);
}

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

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

th {
  text-align: left;
  padding: 10px 14px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border);
  background: #f8fafc;
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }

/* ── COMING SOON ── */
.coming-soon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  color: var(--text-muted);
  text-align: center;
  gap: 12px;
}

.coming-soon-icon { font-size: 3rem; }
.coming-soon h3 { font-family: 'Syne', sans-serif; font-size: 1.1rem; color: var(--text); }

/* ── MOBILE ── */
@media (max-width: 1024px) {
  .big-numbers { grid-template-columns: repeat(3, 1fr); }
  .big-numbers.cols-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 40px rgba(0,0,0,0.3); }
  .topbar { left: 0; padding: 0 16px; }
  .menu-toggle { display: block; }
  .main-content { margin-left: 0; padding: 16px; }
  .big-numbers { grid-template-columns: repeat(2, 1fr); }
  .big-numbers.cols-3 { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
  .chart-card.wide { grid-column: span 1; }
  .chart-card { overflow: hidden; }
  canvas { max-height: 220px !important; }
  .section-block-title-row { flex-wrap: wrap; gap: 4px; }
  .neg-filtros { flex-wrap: wrap; gap: 8px; }
  .consultant-selector { flex-wrap: wrap; gap: 6px; }
  .consultant-btn { font-size: .75rem; padding: 5px 10px; }
}

@media (max-width: 480px) {
  .big-numbers { grid-template-columns: 1fr 1fr; }
  .big-numbers.cols-3 { grid-template-columns: 1fr 1fr; }
  .topbar-right { gap: 8px; }
  .filter-label { display: none; }
  .chart-card { padding: 14px; }
  canvas { max-height: 200px !important; }
}

/* ── DEVICE CARDS ── */
.device-cards {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 20px 0;
  gap: 16px;
}

.device-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.device-icon { font-size: 2.8rem; }

.device-name {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--section-tag);
}

.device-value {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.6rem;
  color: var(--text);
}

.device-pct {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg);
  padding: 2px 10px;
  border-radius: 20px;
}

/* ── INTERESTS CLOUD ── */
.interests-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 0;
  align-items: center;
}

.interest-tag {
  background: linear-gradient(135deg, rgba(123,47,190,0.08), rgba(37,99,235,0.08));
  border: 1px solid rgba(123,47,190,0.2);
  color: var(--section-tag);
  border-radius: 20px;
  font-weight: 600;
  padding: 6px 14px;
}

.interest-tag.xl { font-size: 1.2rem; }
.interest-tag.lg { font-size: 1rem; }
.interest-tag.md { font-size: 0.88rem; }
.interest-tag.sm { font-size: 0.78rem; color: var(--text-muted); }

/* ── POST DESTAQUE ── */
.post-destaque {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 16px;
  background: var(--bg);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.post-thumb {
  font-size: 2.5rem;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border-radius: 10px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.post-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.4;
}

.post-meta { font-size: 0.8rem; color: var(--text-muted); }

/* ── META BAR ── */
.meta-bar-wrap {
  margin: 20px 0;
  padding: 16px 20px;
  background: var(--bg);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.meta-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.meta-bar-label span {
  color: var(--section-tag);
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
}

.meta-bar-bg {
  height: 10px;
  background: var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.meta-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--section-tag), var(--accent2));
  border-radius: 10px;
  transition: width 1s ease;
}

/* ── FUNNEL VISUAL ── */
.funnel-visual {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 0;
}

.funnel-step {
  width: var(--w);
  background: var(--c);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 0.85rem;
  transition: all 0.3s;
}

.funnel-step strong { font-family: 'Syne', sans-serif; font-size: 1rem; }
.funnel-step:hover { filter: brightness(1.1); transform: scaleX(1.02); }

/* ── BADGES ── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge.ok { background: rgba(0,200,150,0.12); color: #059669; }
.badge.in { background: rgba(37,99,235,0.12); color: #2563eb; }

/* ── COMPARATIVOS GRID ── */
.comparativos-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

/* ── AI CARDS ── */
.ai-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.ai-card {
  background: linear-gradient(135deg, rgba(99,102,241,0.05), rgba(99,102,241,0.02));
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: var(--radius);
  padding: 20px;
  min-height: 160px;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text);
}

.ai-loading {
  color: var(--text-muted);
  font-style: italic;
}

.ai-btn {
  background: var(--section-tag);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 10px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-btn:hover { opacity: 0.9; transform: translateY(-1px); }
.ai-btn:disabled { opacity: 0.6; cursor: not-allowed; }

@media (max-width: 768px) {
  .comparativos-grid { grid-template-columns: 1fr; }
  .ai-grid { grid-template-columns: 1fr; }
}

/* ── NEGOCIAÇÕES ── */
.neg-filtros {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.neg-filtro-grupo {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.neg-filtro-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.neg-select {
  background: var(--bg-white);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-family: 'Plus Jakarta Sans', sans-serif;
  outline: none;
  cursor: pointer;
  min-width: 160px;
}

.neg-select:focus { border-color: var(--section-tag); }

@media (max-width: 768px) {
  .neg-filtros { flex-direction: column; align-items: flex-start; }
}

/* ── TOPBAR EXTRAS ── */
.ctrlk-hint {
  display: flex; align-items: center; gap: 5px;
  font-size: .72rem; color: rgba(255,255,255,.45);
}
.ctrlk-hint kbd {
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2);
  border-radius: 4px; padding: 2px 6px; font-family: inherit; font-size: .7rem;
  color: rgba(255,255,255,.6);
}
@media (max-width: 900px) { .ctrlk-hint { display: none; } }

.last-update {
  display: flex; align-items: center; gap: 5px;
  font-size: .72rem; color: rgba(255,255,255,.45);
  white-space: nowrap;
}
@media (max-width: 768px) { .last-update { display: none; } }

.notif-btn, .darkmode-btn {
  background: rgba(255,255,255,.08); border: none;
  width: 36px; height: 36px; border-radius: 10px;
  color: rgba(255,255,255,.7); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  position: relative; transition: background .2s;
}
.notif-btn:hover, .darkmode-btn:hover { background: rgba(255,255,255,.15); color: #fff; }

.notif-badge {
  position: absolute; top: -4px; right: -4px;
  background: #dc2626; color: #fff;
  font-size: .65rem; font-weight: 700; min-width: 16px; height: 16px;
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  padding: 0 3px; border: 2px solid var(--header-bg);
}

.notif-dropdown {
  display: none; position: absolute; top: calc(var(--topbar-h) - 4px); right: 80px;
  width: 320px; background: #fff; border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,.15); z-index: 500;
  border: 1px solid var(--border); overflow: hidden;
}
.notif-dropdown.open { display: block; animation: fadeIn .15s ease; }
.notif-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  font-size: .82rem; font-weight: 700; color: var(--text);
}
.notif-item {
  display: flex; gap: 12px; padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9; transition: background .15s; cursor: pointer;
}
.notif-item:hover { background: #f8fafc; }
.notif-item:last-child { border-bottom: none; }
.notif-icon { font-size: 1.4rem; flex-shrink: 0; }
.notif-body { flex: 1; }
.notif-title { font-size: .82rem; font-weight: 600; color: var(--text); }
.notif-desc { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }
.notif-time { font-size: .7rem; color: var(--text-muted); margin-top: 4px; }
.notif-empty { padding: 24px; text-align: center; color: var(--text-muted); font-size: .84rem; }

/* ── PERFIL DROPDOWN ── */
.profile-wrap { position: relative; }

.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 800;
  font-size: .9rem; color: white; cursor: pointer;
  border: none; transition: transform .2s, box-shadow .2s;
  flex-shrink: 0;
}
.avatar:hover { transform: scale(1.08); box-shadow: 0 0 0 3px rgba(255,255,255,.2); }

.profile-dropdown {
  display: none; position: absolute; top: calc(var(--topbar-h) - 4px); right: 0;
  width: 240px; background: #fff; border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,.15); z-index: 500;
  border: 1px solid var(--border); overflow: hidden;
}
.profile-dropdown.open { display: block; animation: fadeIn .15s ease; }

.profile-header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px; background: linear-gradient(135deg, #0f2b35, #1b4f5a);
}
.profile-avatar-lg {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.2rem; color: #fff; flex-shrink: 0;
}
.profile-name { font-size: .88rem; font-weight: 700; color: #fff; }
.profile-cargo { font-size: .72rem; color: rgba(255,255,255,.6); margin-top: 2px; }
.profile-divider { height: 1px; background: var(--border); }
.profile-item {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; background: none; border: none;
  font-size: .84rem; color: var(--text); cursor: pointer;
  font-family: inherit; transition: background .15s; text-align: left;
}
.profile-item:hover { background: #f8fafc; }
.profile-item.danger { color: #dc2626; }
.profile-item.danger:hover { background: #fef2f2; }

/* ── DARK MODE ── */
body.dark {
  --bg: #0f172a;
  --bg-white: #1e293b;
  --border: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --header-bg: #0a1628;
  --shadow: 0 2px 12px rgba(0,0,0,.3);
}
body.dark .kpi-card { background: var(--bg-white); }
body.dark .chart-card { background: var(--bg-white); }
body.dark .section-block { background: var(--bg-white); }
body.dark th { background: #273548; }
body.dark tr:hover td { background: #273548; }
body.dark .ai-card { background: rgba(99,102,241,.08); border-color: rgba(99,102,241,.25); }
body.dark .neg-select { background: var(--bg-white); color: var(--text); border-color: var(--border); }
body.dark .profile-dropdown, body.dark .notif-dropdown { background: #1e293b; border-color: #334155; }
body.dark .profile-item { color: var(--text); }
body.dark .profile-item:hover { background: #273548; }
body.dark .notif-item:hover { background: #273548; }
body.dark .notif-header { color: var(--text); }
body.dark #ctrlkModal > div { background: #1e293b; }
body.dark #ctrlkInput { background: #1e293b; color: #f1f5f9; }
body.dark .ctrlk-item:hover { background: #273548; }
body.dark .table-wrap::after {
  background: linear-gradient(to left, rgba(30,41,59,.95), transparent);
}

/* Dark mode para elementos novos */
body.dark .kb-tip-trigger {
  background: rgba(165,180,252,.15);
  color: #a5b4fc;
  border-color: rgba(165,180,252,.25);
}
body.dark .kb-tip-trigger:hover {
  background: #6366f1;
  color: #fff;
}
body.dark #kbTooltip {
  background: #0f172a;
  border: 1px solid rgba(148,163,184,.15);
  box-shadow: 0 16px 40px rgba(0,0,0,.5);
}
body.dark #kbTooltip.arrow-top::after { border-bottom-color: #0f172a; }
body.dark #kbTooltip.arrow-bottom::after { border-top-color: #0f172a; }
body.dark .kpi-card:hover {
  border-color: rgba(165,180,252,.3);
  box-shadow: 0 8px 24px rgba(0,0,0,.35), 0 2px 4px rgba(0,0,0,.15);
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVO MOBILE — AlugueON Dashboard
═══════════════════════════════════════════════════════════════ */

/* Topbar: fica sempre full width no mobile */
@media (max-width: 768px) {
  .topbar {
    left: 0 !important;
    width: 100% !important;
  }
  .main-content {
    margin-left: 0 !important;
    padding-top: calc(var(--topbar-h) + 16px) !important;
  }
  /* Remove overflow:hidden do body que bloqueia scroll */
  body { overflow: auto !important; overflow-x: hidden !important; }
}

/* Funil menor em desktop */
#funilVisual svg { max-height: 300px; }

/* Tooltip touch — ativa ao tocar no “?” em mobile */
.kb-tip-trigger.touch-active {
  background: var(--section-tag);
  color: #fff;
}

/* Desabilita hover transform nos KPI cards em touch (evita card travado elevado) */
@media (hover: none) {
  .kpi-card:hover {
    transform: none !important;
    box-shadow: var(--shadow) !important;
    border-color: var(--border) !important;
  }
  .kpi-card:hover::before { opacity: 0 !important; }
  .funnel-step:hover { filter: none !important; transform: none !important; }
  .ai-btn:hover { transform: none !important; opacity: 1 !important; }
}

/* Linha 2 CRM: removida (agora usa 2 colunas direto via style) */

/* ──────────── TABLET / MOBILE (≤ 768px) ──────────── */
@media (max-width: 768px) {

  /* Previne scroll horizontal */
  html { overflow-x: hidden; }
  body { overflow-x: hidden !important; max-width: 100%; }
  * { max-width: 100%; box-sizing: border-box; }

  /* Sidebar: drawer lateral com transição suave */
  :root { --sidebar-w: 0px; --topbar-h: 56px; }
  .sidebar {
    transform: translateX(-100%);
    width: 260px !important;
    z-index: 1000;
    transition: transform 0.28s cubic-bezier(.4,0,.2,1);
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 6px 0 32px rgba(0,0,0,.35);
  }

  /* Main content sem deslocamento + safe-area para notch iPhones */
  .main-content {
    margin-left: 0 !important;
    padding: 16px 12px calc(28px + env(safe-area-inset-bottom)) 12px !important;
    width: 100% !important;
    overflow-x: hidden;
  }

  /* Topbar compacta e profissional */
  .topbar {
    left: 0 !important;
    padding: 0 16px;
    height: 56px;
    gap: 10px;
  }
  .menu-toggle {
    display: flex !important;
    width: 40px; height: 40px;
    align-items: center; justify-content: center;
    background: rgba(255,255,255,.08);
    border-radius: 10px;
    border: none; color: #fff; font-size: 1.1rem;
    cursor: pointer; flex-shrink: 0;
  }
  .topbar-title {
    font-size: .9rem;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
  }
  .topbar-right { gap: 8px; }
  .ctrlk-hint, .last-update { display: none !important; }

  /* Big Numbers: 2 colunas bem proporcionadas */
  .big-numbers,
  .big-numbers.cols-4 {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }
  .kpi-card {
    padding: 14px 10px !important;
    min-height: 72px;
  }
  .kpi-value { font-size: 1.3rem !important; line-height: 1.2; }
  .kpi-label { font-size: .68rem !important; margin-top: 4px; }

  /* Charts: 1 coluna por padrão */
  .charts-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* Linha 2 CRM: 2x2 no mobile */
  .crm-linha2 { grid-template-columns: 1fr 1fr !important; }

  /* Linha 3 CRM: 1 coluna no mobile */
  .crm-linha3 { grid-template-columns: 1fr !important; }

  /* Funil: tamanho lígico no mobile — não comprimir demais */
  #funilVisual { overflow: hidden; }
  #funilVisual svg { max-height: 260px; }

  /* Seções */
  .section-block { padding: 14px 12px !important; margin-bottom: 16px; }
  .section-tag { font-size: .72rem; padding: 4px 12px; margin-bottom: 14px; }
  .section-block-title { font-size: .82rem !important; margin-bottom: 12px !important; }

  /* section-block-title-row: live dot quebra linha ao invés de overflow no mobile */
  .section-block-title-row {
    flex-wrap: wrap;
    gap: 6px;
  }
  .section-block-title-row .live-dot-indicator {
    margin-left: 0 !important;
    font-size: .62rem;
  }

  /* Canvas compacto no mobile — doughnut fica sem restrição pois legenda fica embaixo */
  canvas { max-height: 200px !important; }
  canvas[id^="chart"] { max-height: 200px !important; }
  /* Doughnut charts: legenda bottom precisa de mais altura */
  #chartOrigem,
  #chartGenero,
  #chartCsatCRM,
  #chartOrigemContratos,
  #chartProdutoCRM,
  #chartPerfilLeads,
  #chartAdsDispositivo,
  #chartFontesVisualizacao,
  #chartPublicoSocial,
  #chartCampanha,
  #chartProdutoInd,
  #chartCsatInd,
  #chartNegConsultor,
  #chartNegProduto,
  #chartNegOrigem,
  #chartNegPipeline { max-height: none !important; height: auto !important; }

  /* Tabelas com hint de scroll */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    position: relative;
  }
  /* CRÍTICO: sobrescreve o * { max-width: 100% } que bloqueia scroll da tabela */
  .table-wrap table { max-width: none !important; }
  .table-wrap::after {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 28px; height: 100%;
    background: linear-gradient(to left, rgba(255,255,255,.9), transparent);
    pointer-events: none;
    border-radius: 0 var(--radius) var(--radius) 0;
  }

  /* Filtros empilhados */
  table { min-width: 480px; font-size: .78rem; }
  th, td { padding: 8px 10px !important; white-space: nowrap; }

  .neg-filtros { flex-direction: column !important; gap: 8px !important; align-items: stretch !important; }
  .neg-filtro-grupo { width: 100%; }
  .neg-select { width: 100% !important; min-width: unset !important; }

  /* Comparativos: 2 colunas no mobile */
  .comparativos-grid { grid-template-columns: 1fr 1fr !important; gap: 8px; }

  /* AI cards: 1 coluna */
  .ai-grid { grid-template-columns: 1fr !important; }
  .ai-card { font-size: .82rem; }
  .ai-btn { width: 100%; justify-content: center; margin-top: 12px; }

  /* Botoes de consultora */
  .consultant-selector {
    display: flex;
    flex-wrap: nowrap;
    gap: 0;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border);
    margin-bottom: 16px;
  }
  .consultant-btn {
    flex: 1;
    border-radius: 0 !important;
    font-size: .78rem !important;
    padding: 9px 6px !important;
    border: none !important;
    border-right: 1px solid var(--border) !important;
    text-align: center;
  }
  .consultant-btn:last-child { border-right: none !important; }

  /* Dropdowns reposicionados — posicionamento via position:fixed no mobile */
  .profile-dropdown, .notif-dropdown {
    position: fixed !important;
    top: 56px !important;
    left: auto !important;
    width: calc(100vw - 24px) !important;
    max-width: 320px !important;
  }
  .profile-dropdown { right: 12px !important; }
  .notif-dropdown   { right: 12px !important; }

  /* Login overlay responsivo */
  #loginOverlay > div:last-of-type {
    padding: 28px 24px 24px !important;
    max-width: calc(100vw - 32px) !important;
  }

  /* Overlay de fundo ao abrir sidebar — cobre o conteúdo quando sidebar abre */
  .sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 999;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }
  .sidebar-overlay.active { display: block; animation: fadeIn .2s ease; }

  /* Device cards gerencial */
  .device-cards { grid-template-columns: repeat(3, 1fr) !important; gap: 8px; }
  .device-card { padding: 12px 8px !important; }
}

/* ─── MOBILE: ajustes de UI menores ─── */
@media (max-width: 768px) {
  /* Toast de boas-vindas: recalibra para topbar de 56px */
  #boasVindasToast {
    top: 68px !important;
    right: 12px !important;
    max-width: calc(100vw - 24px) !important;
    font-size: .82rem !important;
  }

  /* Toast de erro/sucesso (showToast) também — via JS usa bottom:28px, OK no mobile */

  /* Login: safe area para iPhone notch */
  #loginOverlay {
    padding-bottom: env(safe-area-inset-bottom);
    padding-top: env(safe-area-inset-top);
  }

  /* Post da Semana: flex sem min-width causa overflow do texto */
  .post-destaque { align-items: flex-start; }
  .post-info {
    min-width: 0;
    flex: 1;
    overflow: hidden;
  }
  .post-title { word-break: break-word; white-space: normal; }
  .post-meta  { white-space: normal; }
  .neg-select, .topbar-select { min-height: 44px; }

  /* Botoes touch-friendly */
  .consultant-btn { min-height: 44px; }
  .ai-btn { min-height: 48px; font-size: .88rem !important; }
  .nav-item { min-height: 48px; }
}

/* ──────────── SMALL PHONE (≤ 480px) ──────────── */
@media (max-width: 480px) {
  .main-content { padding: 12px 10px calc(20px + env(safe-area-inset-bottom)) 10px !important; }
  .topbar-title { font-size: .82rem; }
  .kpi-value { font-size: 1.15rem !important; }
  .kpi-card { padding: 12px 8px !important; min-height: 66px; }
  .crm-linha2 { grid-template-columns: 1fr 1fr !important; }
  #funilVisual svg { max-height: 200px; }
  .comparativos-grid { grid-template-columns: 1fr 1fr !important; gap: 8px; }
  .device-cards { gap: 6px !important; }
  .device-icon svg { width: 24px !important; height: 24px !important; }
  table { min-width: 420px; font-size: .74rem; }
  th, td { padding: 7px 8px !important; }
}

/* ══════════════════════════════════════════════════ DARK MODE ══ */
body.dark {
  --bg: #0d1117;
  --bg-white: #161b22;
  --border: #30363d;
  --border-dash: #484f58;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --shadow: 0 2px 12px rgba(0,0,0,0.45);
  --header-bg: #090e14;
}
body.dark .kpi-card,
body.dark .chart-card,
body.dark .ai-card { background: var(--bg-white); border-color: var(--border); }
body.dark .section-block { background: transparent; }
body.dark select,
body.dark .neg-select { background: #1c2128; color: var(--text); border-color: var(--border); }
body.dark .topbar-select { background: rgba(255,255,255,.1) !important; color: #fff !important; }
body.dark .profile-dropdown,
body.dark .notif-dropdown { background: #1c2128; border-color: var(--border); }
body.dark .profile-item:hover { background: rgba(255,255,255,.06); }
body.dark .profile-divider { background: var(--border); }
body.dark table thead th { background: #1c2128; }
body.dark table tbody tr:hover td { background: rgba(255,255,255,.03); }
body.dark .ai-loading { color: var(--text-muted); }
body.dark .device-pct { background: rgba(255,255,255,.07); }
body.dark .kpi-sparkline { opacity: .45; }
body.dark .section-tag { background: rgba(99,102,241,.15); color: #a5b4fc; }
body.dark .funilItem { background: var(--bg-white) !important; border-color: var(--border) !important; }
body.dark .neg-notice,
body.dark .ai-notice { background: rgba(255,255,255,.04); border-color: var(--border); }

/* ══════════════════════════════════════════════ PROGRESS BAR ══ */
#topProgressBar {
  position: fixed; top: 0; left: 0; z-index: 9999;
  height: 3px; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 0 2px 2px 0;
  opacity: 0; pointer-events: none;
  transition: width .35s ease, opacity .25s ease;
}
#topProgressBar.pb-running { opacity: 1; }

/* ══════════════════════════════════════════ AVATAR ROLE BADGE ══ */
.avatar[data-role="admin"]     { box-shadow: 0 0 0 2.5px #6366f1, 0 0 0 4px rgba(99,102,241,.25); }
.avatar[data-role="consultora"]{ box-shadow: 0 0 0 2.5px #00c896, 0 0 0 4px rgba(0,200,150,.22); }

/* ═══════════════════════════════════════════ KPI ENTRY ANIMATION ══ */
@keyframes kpiIn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}
.kpi-card.kpi-in { animation: kpiIn .22s ease both; }

/* ═════════════════════════════════════════════════ EMPTY STATE ══ */
.chart-empty-state {
  display: none; flex-direction: column; align-items: center;
  justify-content: center; gap: 8px; padding: 32px 16px;
  color: var(--text-muted); font-size: .8rem; text-align: center;
}
.chart-empty-state.visible { display: flex; }
.chart-empty-state svg { opacity: .3; }

/* ══════════════════════════════════════════ COLLAPSIBLE SECTIONS ══ */
.collapse-arrow {
  display: none; margin-left: 8px; flex-shrink: 0;
  color: var(--text-muted); transition: transform .2s ease;
  align-items: center; justify-content: center;
}
.section-block.sb-collapsed .collapse-arrow { transform: rotate(-90deg); }
.section-block.sb-collapsed > *:not(.section-block-title-row) { display: none !important; }
@media (max-width: 768px) {
  .collapse-arrow { display: inline-flex; }
  .section-block-title-row { cursor: pointer; user-select: none; }
}
