/* =============================================
   COMPONENTS.CSS — Todos os componentes visuais
   BI Desafio v1.0
   ============================================= */

/* --- KPI Card --- */
.kpi-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  transition: all var(--transition);
  cursor: default;
  position: relative;
  overflow: hidden;
}
.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.kpi-card.clickable { cursor: pointer; }
.kpi-card .kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}
.kpi-card .kpi-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.kpi-card .kpi-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}
.kpi-card .kpi-sub {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 4px;
}
.kpi-card .kpi-sparkline { margin-top: 8px; }
.kpi-card .sparkline { display: block; }
.kpi-card.lg .kpi-value { font-size: 2rem; }

/* KPI target status */
.kpi-card.target-ok { border-left: 3px solid var(--success); }
.kpi-card.target-warn { border-left: 3px solid var(--warning); }
.kpi-card.target-bad { border-left: 3px solid var(--danger); }

/* --- Card generico --- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
}
.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- Chart Container --- */
.chart-container {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
}
.chart-container .chart-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}
.chart-container canvas {
  width: 100% !important;
  height: auto;
  max-height: 250px;
}
.chart-container.tall canvas { max-height: 350px; }

/* --- Performance Table --- */
.perf-table-wrap {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  overflow-x: auto;
}
.perf-table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.perf-table-title { font-size: 0.85rem; font-weight: 700; }
.perf-table-search {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 0.8rem;
  width: 180px;
}
.perf-table {
  width: 100%;
  font-size: 0.8rem;
}
.perf-table th {
  padding: 10px 12px;
  text-align: left;
  font-weight: 700;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.perf-table th:hover { color: var(--primary); }
.perf-table th.not-sortable { cursor: default; }
.perf-table th.not-sortable:hover { color: var(--muted); }
.perf-table th.sorted-asc::after { content: ' \25B2'; font-size: 0.6rem; }
.perf-table th.sorted-desc::after { content: ' \25BC'; font-size: 0.6rem; }
.perf-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}
.perf-table tr:hover td { background: var(--card-hover); }
.perf-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.perf-table .currency { font-weight: 600; }

/* Tabela operacional de trafego */
.traffic-name {
  display: inline-block;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}
.traffic-creative-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}
.traffic-creative-link:hover { text-decoration: underline; }
.traffic-creative-link:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: 2px;
}
.traffic-metric {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 72px;
  min-height: 28px;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.traffic-metric--good {
  color: #16723a;
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.25);
}
.traffic-metric--warn {
  color: #9a6200;
  background: rgba(245, 158, 11, 0.17);
  border-color: rgba(245, 158, 11, 0.28);
}
.traffic-metric--bad {
  color: #b42332;
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.24);
}
.traffic-metric--neutral {
  color: var(--text-secondary);
  background: var(--bg-subtle);
  border-color: var(--border);
}
.traffic-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 10px;
  padding: 12px 16px;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.traffic-legend strong { color: var(--text); }
.traffic-legend span { display: inline-flex; align-items: center; gap: 6px; }
.traffic-legend small { margin-left: auto; }
.traffic-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.traffic-dot--good { background: #22c55e; }
.traffic-dot--warn { background: #f59e0b; }
.traffic-dot--bad { background: #ef4444; }
.traffic-dot--neutral { background: #94a3b8; }

[data-theme="dark"] .traffic-metric--good { color: #86efac; }
[data-theme="dark"] .traffic-metric--warn { color: #fcd34d; }
[data-theme="dark"] .traffic-metric--bad { color: #fca5a5; }

@media (max-width: 768px) {
  .traffic-legend small { width: 100%; margin-left: 0; }
}

/* Table cell status colors */
.perf-table td.target-ok { color: var(--success); font-weight: 600; }
.perf-table td.target-warn { color: var(--warning); font-weight: 600; }
.perf-table td.target-bad { color: var(--danger); font-weight: 600; }

/* Pagination */
.table-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--muted);
}
.table-pagination button {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font-size: 0.75rem;
  cursor: pointer;
}
.table-pagination button:disabled { opacity: 0.4; cursor: default; }

/* --- Funnel Visual --- */
.funnel-visual {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px;
}
.funnel-stage {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--primary-bg);
  border-radius: var(--radius-sm);
  position: relative;
  transition: background var(--transition);
}
.funnel-stage:hover { background: rgba(102, 126, 234, 0.14); }
.funnel-stage .funnel-bar {
  height: 32px;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  border-radius: 4px;
  min-width: 4px;
  transition: width 0.5s ease;
}
.funnel-stage .funnel-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  min-width: 100px;
}
.funnel-stage .funnel-value {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}
.funnel-stage .funnel-rate {
  font-size: 0.75rem;
  color: var(--muted);
  margin-left: auto;
}

/* --- Semaforo Funil --- */
.semaforo {
  display: flex;
  gap: 12px;
  justify-content: center;
  padding: 16px;
}
.semaforo-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  min-width: 70px;
}
.semaforo-item:hover { background: var(--bg-subtle); }
.semaforo-item .semaforo-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
}
.semaforo-item .semaforo-icon.green { background: var(--success-bg); color: var(--success); border: 2px solid var(--success); }
.semaforo-item .semaforo-icon.yellow { background: var(--warning-bg); color: var(--warning); border: 2px solid var(--warning); }
.semaforo-item .semaforo-icon.red { background: var(--danger-bg); color: var(--danger); border: 2px solid var(--danger); }
.semaforo-item .semaforo-label { font-size: 0.65rem; font-weight: 600; text-transform: uppercase; color: var(--muted); }
.semaforo-item .semaforo-value { font-size: 0.75rem; font-weight: 700; color: var(--text); }

/* --- Hero Card --- */
.hero-card {
  background: linear-gradient(135deg, var(--primary), var(--primary2));
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
}
.hero-card .hero-title { font-size: 1.2rem; font-weight: 800; margin-bottom: 8px; }
.hero-card .hero-message { font-size: 0.9rem; opacity: 0.9; margin-bottom: 16px; line-height: 1.5; }
.hero-card .hero-badges { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.hero-card .hero-links { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-card .hero-link {
  padding: 6px 14px;
  background: rgba(255,255,255,0.2);
  border-radius: 20px;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  transition: background var(--transition);
}
.hero-card .hero-link:hover { background: rgba(255,255,255,0.3); text-decoration: none; }

/* --- Timeline Bar --- */
.timeline-bar {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  margin-bottom: 20px;
  overflow-x: auto;
}
.timeline-phase {
  flex: 1;
  text-align: center;
  padding: 10px 8px;
  position: relative;
}
.timeline-phase::after {
  content: '';
  position: absolute;
  right: 0; top: 25%; bottom: 25%;
  width: 1px;
  background: var(--border);
}
.timeline-phase:last-child::after { display: none; }
.timeline-phase .phase-label { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; color: var(--muted); }
.timeline-phase .phase-dates { font-size: 0.65rem; color: var(--muted); margin-top: 2px; }
.timeline-phase.active { background: var(--primary-bg); border-radius: var(--radius-sm); }
.timeline-phase.active .phase-label { color: var(--primary); }
.timeline-phase .countdown { font-size: 0.8rem; font-weight: 700; color: var(--primary); margin-top: 4px; }

/* --- Pacing Card --- */
.pacing-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
}
.pacing-card .pacing-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.pacing-card .pacing-label { font-size: 0.75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; }
.pacing-card .pacing-values { display: flex; gap: 16px; margin-bottom: 8px; }
.pacing-card .pacing-current { font-size: 1.3rem; font-weight: 800; }
.pacing-card .pacing-target { font-size: 0.85rem; color: var(--muted); }
.pacing-card .pacing-bar-bg {
  height: 6px;
  background: var(--bg-subtle);
  border-radius: 3px;
  overflow: hidden;
}
.pacing-card .pacing-bar {
  height: 100%;
  border-radius: 3px;
  background: var(--primary);
  transition: width 0.5s ease;
}
.pacing-card .pacing-bar.over { background: var(--danger); }
.pacing-card .pacing-projected {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
  text-align: right;
}

/* --- Pacing Mobile --- */
.pacing-mobile { padding: 16px; }
.pacing-mobile-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.pacing-mobile-count { min-width: 0; }
.pacing-mobile-label { font-size: 0.75rem; color: var(--muted); }
.pacing-mobile-number { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.pacing-mobile-breakdown { font-size: 0.68rem; color: var(--text-muted); margin-top: 2px; }
.pacing-mobile-badge-area {
  flex-shrink: 0;
  text-align: right;
}
.pacing-mobile-days { font-size: 0.7rem; color: var(--muted); margin-top: 4px; white-space: nowrap; }
.pacing-mobile-bar-section { width: 100%; }
.pacing-mobile-bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--muted);
  margin-bottom: 4px;
}
.pacing-mobile-bar-labels + .pacing-mobile-bar-labels { margin-bottom: 0; margin-top: 4px; }
.pacing-mobile-bar-bg {
  background: var(--bg-card, #eee);
  border-radius: 6px;
  height: 18px;
  overflow: hidden;
}
.pacing-mobile-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.5s ease;
}
@media (max-width: 480px) {
  .pacing-mobile { padding: 12px; }
  .pacing-mobile-number { font-size: 1.3rem; }
  .pacing-mobile-bar-bg { height: 14px; }
}

/* --- Creative Card --- */
.creative-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  cursor: pointer;
  transition: all var(--transition);
}
.creative-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.creative-card .creative-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.creative-card .creative-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  font-size: 0.75rem;
}
.creative-card .creative-metric-label { color: var(--muted); }
.creative-card .creative-metric-value { font-weight: 600; text-align: right; }
.creative-card .creative-attr {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-light);
  font-size: 0.7rem;
  color: var(--muted);
}

/* --- Heatmap Table --- */
.heatmap-table { font-size: 0.75rem; }
.heatmap-table th { padding: 8px; text-align: center; }
.heatmap-table td {
  padding: 8px;
  text-align: center;
  font-weight: 600;
  border-radius: 4px;
}
.heatmap-cell-0 { background: rgba(102,126,234,0.05); }
.heatmap-cell-1 { background: rgba(102,126,234,0.15); }
.heatmap-cell-2 { background: rgba(102,126,234,0.30); }
.heatmap-cell-3 { background: rgba(102,126,234,0.50); color: #fff; }
.heatmap-cell-4 { background: rgba(102,126,234,0.75); color: #fff; }
.heatmap-cell-5 { background: rgba(102,126,234,1.00); color: #fff; }

/* --- Alert Items --- */
.alert-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
}
.alert-item.critical { background: var(--danger-bg); color: var(--danger); }
.alert-item.high { background: var(--warning-bg); color: #b45309; }
.alert-item.medium { background: var(--info-bg); color: var(--info); }
.alert-item.info { background: var(--success-bg); color: var(--success); }
.alert-item .alert-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* --- Badge --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
}
.badge.success { background: var(--success-bg); color: var(--success); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.warning { background: var(--warning-bg); color: #b45309; }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.neutral { background: var(--bg-subtle); color: var(--muted); }

/* --- Sub-Tab Nav --- */
.subtab-nav {
  display: flex;
  gap: 4px;
  background: var(--bg-subtle);
  padding: 4px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}
.subtab-btn {
  padding: 6px 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.subtab-btn:hover { color: var(--text); }
.subtab-btn.active {
  background: var(--card);
  color: var(--primary);
  box-shadow: var(--shadow);
}

/* --- Sync Status --- */
.sync-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}
.sync-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
}
.sync-card .sync-source { font-weight: 700; font-size: 0.85rem; margin-bottom: 8px; }
.sync-card .sync-detail { font-size: 0.75rem; color: var(--muted); }
.sync-card .sync-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  font-size: 0.75rem;
  font-weight: 600;
}
.sync-card .sync-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
}
.sync-dot.online { background: var(--success); }
.sync-dot.error { background: var(--danger); }
.sync-dot.partial { background: var(--warning); }

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  animation: fadeIn 0.2s ease;
}
.modal-content {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.modal-title { font-size: 1.1rem; font-weight: 700; }
.modal-close {
  background: none; border: none;
  font-size: 1.5rem; color: var(--muted);
  cursor: pointer;
  padding: 4px;
}
.modal-close:hover { color: var(--text); }
#creative-detail-modal .modal-content { max-width: 760px; }

.creative-daily-history {
  margin-top: 18px;
  margin-bottom: 16px;
}
.creative-daily-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 0.85rem;
  font-weight: 700;
}
.creative-daily-title .text-muted {
  font-size: 0.68rem;
  font-weight: 500;
  text-align: right;
}
.creative-daily-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
}
.creative-daily-table-wrap .perf-table th,
.creative-daily-table-wrap .perf-table td {
  padding: 8px 10px;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 16px; opacity: 0.5; }
.empty-state .empty-title { font-size: 1.1rem; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.empty-state .empty-message { font-size: 0.9rem; color: var(--muted); max-width: 400px; margin: 0 auto 20px; line-height: 1.6; }
.empty-state .empty-action { margin-top: 16px; }

/* --- Skeleton --- */
.skeleton {
  background: linear-gradient(90deg, var(--bg-subtle) 25%, var(--border-light) 50%, var(--bg-subtle) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
.skeleton-card { height: 100px; border-radius: var(--radius); }
.skeleton-chart { height: 250px; border-radius: var(--radius); }
.skeleton-line { height: 14px; margin-bottom: 8px; }
.skeleton-line.w-75 { width: 75%; }
.skeleton-line.w-50 { width: 50%; }

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* --- Strip Diagnostico --- */
.strip-diag {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.strip-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
}
.strip-item .strip-label { flex: 1; font-size: 0.8rem; font-weight: 600; }
.strip-item .strip-value { font-size: 0.85rem; font-weight: 700; }
.strip-item .strip-bar {
  width: 100px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.strip-item .strip-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s ease;
}
.strip-item.target-ok .strip-fill { background: var(--success); }
.strip-item.target-warn .strip-fill { background: var(--warning); }
.strip-item.target-bad .strip-fill { background: var(--danger); }

/* --- Creative Grid --- */
.creative-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

/* --- Insight Cards (v2) --- */
.insights-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}
.insight-card {
  display: flex;
  gap: 16px;
  padding: 16px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  background: var(--card);
  box-shadow: var(--shadow);
  transition: all var(--transition);
}
.insight-card:hover { box-shadow: var(--shadow-md); }
.insight-card .insight-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.insight-card .insight-body { flex: 1; min-width: 0; }
.insight-card .insight-title {
  font-size: 0.9rem;
  font-weight: 800;
  margin-bottom: 4px;
  color: var(--text);
}
.insight-card .insight-text {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
}
.insight-card .insight-list {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-light);
}
.insight-card .insight-item {
  font-size: 0.78rem;
  color: var(--text);
  padding: 3px 0;
}
.insight-card .insight-action {
  margin-top: 10px;
}
.insight-card .insight-action .btn-sm {
  padding: 4px 14px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid currentColor;
  border-radius: 16px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-decoration: none;
}
.insight-card .insight-action .btn-sm:hover {
  background: rgba(0,0,0,0.05);
}

/* Insight card types */
.insight-card.success {
  border-left: 4px solid var(--success);
  background: var(--success-bg);
}
.insight-card.success .insight-title { color: var(--success); }
.insight-card.success .insight-icon { background: var(--success-bg); }
.insight-card.success .insight-action .btn-sm { color: var(--success); }

.insight-card.danger {
  border-left: 4px solid var(--danger);
  background: var(--danger-bg);
}
.insight-card.danger .insight-title { color: var(--danger); }
.insight-card.danger .insight-icon { background: var(--danger-bg); }
.insight-card.danger .insight-action .btn-sm { color: var(--danger); }

.insight-card.warning {
  border-left: 4px solid var(--warning);
  background: var(--warning-bg);
}
.insight-card.warning .insight-title { color: #b45309; }
.insight-card.warning .insight-icon { background: var(--warning-bg); }
.insight-card.warning .insight-action .btn-sm { color: #b45309; }

.insight-card.info {
  border-left: 4px solid var(--info);
  background: var(--info-bg);
}
.insight-card.info .insight-title { color: var(--info); }
.insight-card.info .insight-icon { background: var(--info-bg); }
.insight-card.info .insight-action .btn-sm { color: var(--info); }

.insight-card.neutral {
  border-left: 4px solid var(--muted);
}

/* --- Target Status inline spans --- */
span.target-ok { color: var(--success); font-weight: 700; }
span.target-warn { color: var(--warning); font-weight: 700; }
span.target-bad { color: var(--danger); font-weight: 700; }

/* --- Text utilities --- */
.text-muted { color: var(--muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }

/* =============================================
   V3 COMPONENTS — Adapted from Reference BI
   ============================================= */

/* --- KPI Card Pro (with badge + progress) --- */
.kpi-pro {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  transition: all var(--transition);
  position: relative;
}
.kpi-pro:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.kpi-pro.clickable { cursor: pointer; }
.kpi-pro.clickable:active { transform: translateY(0); box-shadow: var(--shadow); }
.kpi-pro .kpi-pro-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.kpi-pro .kpi-pro-icon { font-size: 0.85rem; }
.kpi-pro .kpi-pro-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}
.kpi-pro .kpi-pro-badge {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.kpi-pro .kpi-pro-badge.ok { background: var(--success-bg); color: var(--success); }
.kpi-pro .kpi-pro-badge.atencao { background: var(--warning-bg); color: #b45309; }
.kpi-pro .kpi-pro-badge.critico { background: var(--danger-bg); color: var(--danger); }
.kpi-pro .kpi-pro-value {
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 4px;
}
.kpi-pro .kpi-pro-value.green { color: var(--success); }
.kpi-pro .kpi-pro-value.red { color: var(--danger); }
.kpi-pro .kpi-pro-value.orange { color: #b45309; }
.kpi-pro .kpi-pro-sub {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 8px;
}
.kpi-pro .kpi-pro-progress {
  height: 5px;
  background: var(--bg-subtle);
  border-radius: 3px;
  overflow: hidden;
}
.kpi-pro .kpi-pro-progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}
.kpi-pro .kpi-pro-progress-fill.ok { background: var(--primary); }
.kpi-pro .kpi-pro-progress-fill.atencao { background: var(--warning); }
.kpi-pro .kpi-pro-progress-fill.critico { background: var(--danger); }
.kpi-pro.lg .kpi-pro-value { font-size: 2.2rem; }

/* --- Filtro MAI / TIC / TEG da aba Pesquisas --- */
.survey-filter-kpi {
  width: 100%;
  appearance: none;
  color: var(--text);
  font: inherit;
  text-align: left;
}
.survey-filter-kpi.active {
  border-color: var(--primary);
  background: rgba(102, 126, 234, 0.08);
  box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.22);
}
.survey-filter-kpi.survey-filter-mai { border-left: 3px solid #dc3545; }
.survey-filter-kpi.survey-filter-tic { border-left: 3px solid #f59e0b; }
.survey-filter-kpi.survey-filter-teg { border-left: 3px solid #6c757d; }
.survey-filter-kpi:focus-visible {
  outline: 3px solid rgba(102, 126, 234, 0.35);
  outline-offset: 2px;
}

/* --- NPS: filtros, leitura individual e voz do lead --- */
.nps-filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 10px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: var(--card);
}
.nps-filter-stack { margin-bottom: 20px; }
.nps-filter-stack .nps-filter-bar { margin-bottom: 8px; }
.nps-filter-stack .nps-filter-bar:last-child { margin-bottom: 0; }
.nps-lesson-filter-bar { border-left: 3px solid var(--primary); }
.nps-lesson-filter.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.nps-lesson-filter.active strong { color: rgba(255,255,255,.82); }
.nps-filter-label { font-size: .75rem; font-weight: 700; color: var(--muted); margin-right: 4px; }
.nps-filter {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-secondary);
  cursor: pointer;
  font: inherit;
  font-size: .75rem;
}
.nps-filter strong { font-size: .68rem; color: var(--muted); }
.nps-filter:hover, .nps-filter.active { border-color: var(--primary); color: var(--primary); background: var(--primary-bg); }
.nps-kpi-grid { grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); }
.nps-score-kpi { overflow: visible; z-index: 5; }
.nps-tooltip-wrap { position: relative; margin-left: auto; }
.nps-tooltip-trigger {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid var(--primary);
  border-radius: 50%;
  background: var(--primary-bg);
  color: var(--primary);
  font: 800 .72rem/1 sans-serif;
  cursor: help;
}
.nps-tooltip-trigger:focus-visible { outline: 3px solid rgba(102, 126, 234, .28); outline-offset: 2px; }
.nps-score-tooltip {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  z-index: 50;
  width: min(320px, calc(100vw - 40px));
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, -5px);
  transition: opacity .15s ease, transform .15s ease, visibility .15s;
  pointer-events: none;
}
.nps-tooltip-wrap:hover .nps-score-tooltip,
.nps-tooltip-wrap:focus-within .nps-score-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}
.nps-tooltip-title { display: block; margin-bottom: 8px; font-size: .78rem; font-weight: 800; }
.nps-tooltip-summary { display: flex; flex-wrap: wrap; gap: 5px 10px; padding-bottom: 9px; border-bottom: 1px solid var(--border-light); font-size: .68rem; }
.nps-tooltip-list { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 14px; padding: 10px 0; }
.nps-tooltip-list > span { display: flex; justify-content: space-between; gap: 8px; font-size: .72rem; }
.nps-tooltip-list strong { font-variant-numeric: tabular-nums; }
.nps-tooltip-list small { margin-left: 2px; color: var(--muted); font-size: .62rem; font-weight: 500; }
.nps-tooltip-formula { display: block; padding-top: 8px; border-top: 1px solid var(--border-light); color: var(--muted); font-size: .65rem; }
.nps-lead-link {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--primary);
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}
.nps-text-preview { display: inline-block; min-width: 180px; max-width: 320px; line-height: 1.35; }
.nps-action-note {
  padding: 12px 16px;
  margin-bottom: 14px;
  border-left: 4px solid var(--danger);
  border-radius: var(--radius-sm);
  background: var(--danger-bg);
  color: var(--text-secondary);
  font-size: .82rem;
}
#nps-lead-modal .modal-content { max-width: 900px; }
.nps-lead-summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px; border-radius: var(--radius); background: var(--bg-subtle); }
.nps-lead-identity { display: flex; flex-direction: column; gap: 3px; }
.nps-lead-summary span { font-size: .75rem; color: var(--muted); }
.nps-lead-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.nps-whatsapp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: #25d366;
  color: #fff;
  font-size: .75rem;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(37, 211, 102, .22);
  transition: transform .15s ease, box-shadow .15s ease;
}
.nps-whatsapp-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(37, 211, 102, .32); }
.nps-whatsapp-missing { padding: 6px 9px; border-radius: 999px; background: var(--card); }
.nps-modal-section { margin-top: 20px; }
.nps-modal-section h3 { margin: 0 0 10px; font-size: .95rem; }
.nps-response-card { display: grid; gap: 9px; padding: 14px; margin-bottom: 10px; border: 1px solid var(--border-light); border-radius: var(--radius); }
.nps-response-head { display: flex; align-items: center; gap: 8px; }
.nps-response-head > span:last-child { margin-left: auto; color: var(--muted); font-size: .72rem; }
.nps-response-card b, .nps-answer span { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.nps-response-card p, .nps-answer p { margin: 4px 0 0; color: var(--text); font-size: .84rem; line-height: 1.5; white-space: pre-wrap; }
.nps-survey-group { margin-top: 14px; }
.nps-survey-group h4 { margin: 0 0 8px; font-size: .82rem; color: var(--primary); }
.nps-answer-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.nps-answer { padding: 10px 12px; border: 1px solid var(--border-light); border-radius: var(--radius-sm); background: var(--bg-subtle); min-width: 0; }
.nps-no-survey { padding: 16px; border-radius: var(--radius-sm); background: var(--warning-bg); color: #b45309; font-size: .82rem; }

/* --- Horizontal Funnel (box flow) --- */
.h-funnel {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 16px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  flex-wrap: wrap;
  justify-content: center;
}
.h-funnel-stage {
  text-align: center;
  padding: 12px 16px;
  min-width: 100px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  transition: all var(--transition);
}
.h-funnel-stage:hover { background: var(--primary-bg); border-color: var(--primary); }
.h-funnel-stage.clickable { cursor: pointer; }
.h-funnel-stage.clickable:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.h-funnel-stage.clickable:active { transform: translateY(0); box-shadow: none; }
.h-funnel-stage .h-funnel-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.3px;
}
.h-funnel-stage .h-funnel-value {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--primary);
}
.h-funnel-stage .h-funnel-sub {
  font-size: 0.7rem;
  color: var(--muted);
}
.h-funnel-arrow {
  font-size: 1.2rem;
  color: var(--muted);
  padding: 0 6px;
  flex-shrink: 0;
}

/* --- Diagnostic Bars ("Diagnóstico em 10 segundos") --- */
.diag-bars {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  overflow: hidden;
}
.diag-bars .diag-title {
  padding: 12px 16px;
  font-size: 0.9rem;
  font-weight: 700;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 8px;
}
.diag-bar-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  gap: 12px;
}
.diag-bar-item:last-child { border-bottom: none; }
.diag-bar-item .diag-bar-indicator {
  width: 4px;
  height: 36px;
  border-radius: 2px;
  flex-shrink: 0;
}
.diag-bar-item .diag-bar-indicator.ok { background: var(--success); }
.diag-bar-item .diag-bar-indicator.atencao { background: var(--warning); }
.diag-bar-item .diag-bar-indicator.critico { background: var(--danger); }
.diag-bar-item .diag-bar-info { flex: 1; }
.diag-bar-item .diag-bar-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
}
.diag-bar-item .diag-bar-desc {
  font-size: 0.72rem;
  color: var(--muted);
}
.diag-bar-item .diag-bar-values {
  text-align: right;
  flex-shrink: 0;
}
.diag-bar-item .diag-bar-current {
  font-size: 1rem;
  font-weight: 800;
}
.diag-bar-item .diag-bar-current.ok { color: var(--text); }
.diag-bar-item .diag-bar-current.atencao { color: #b45309; }
.diag-bar-item .diag-bar-current.critico { color: var(--danger); }
.diag-bar-item .diag-bar-meta {
  font-size: 0.7rem;
  color: var(--muted);
}

/* --- Action Panel (Ação Recomendada) --- */
.action-panel {
  background: #fffbeb;
  border: 2px solid #f59e0b;
  border-radius: var(--radius);
  padding: 20px;
  position: sticky;
  top: 80px;
}
[data-theme="dark"] .action-panel {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.3);
}
.action-panel .action-panel-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #b45309;
  margin-bottom: 8px;
}
.action-panel .action-panel-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 12px;
}
.action-panel .action-panel-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.action-panel .action-tag {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}
.action-tag.gargalo { background: var(--danger-bg); color: var(--danger); }
.action-tag.secondary { background: var(--warning-bg); color: #b45309; }
.action-tag.info-tag { background: var(--info-bg); color: var(--info); }
.action-panel .action-panel-list {
  font-size: 0.8rem;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 12px;
}
.action-panel .action-panel-list li { margin-bottom: 6px; }
.action-panel .action-panel-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.action-panel .action-link {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
}
.action-panel .action-link:hover { text-decoration: underline; }

/* --- Backlog automático --- */
.backlog-auto {
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
}
.backlog-auto .backlog-title {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.backlog-auto ol {
  padding-left: 20px;
  font-size: 0.8rem;
  color: var(--text);
  line-height: 1.7;
}

/* --- Scale/Cut Creative Cards --- */
.scale-cut-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 768px) {
  .scale-cut-grid { grid-template-columns: 1fr; }
}
.scale-cut-col h4 {
  font-size: 0.95rem;
  font-weight: 800;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.scale-cut-col .scale-cut-desc {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 12px;
}
.scale-cut-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all var(--transition);
}
.scale-cut-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.scale-cut-card .sc-thumb {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: var(--primary-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
  color: var(--primary);
  font-weight: 800;
}
.scale-cut-card .sc-info { flex: 1; min-width: 0; }
.scale-cut-card .sc-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.scale-cut-card .sc-badges {
  display: flex;
  gap: 4px;
  margin-top: 3px;
  flex-wrap: wrap;
}
.scale-cut-card .sc-detail {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 2px;
}
.scale-cut-card .sc-metrics {
  text-align: right;
  flex-shrink: 0;
}
.scale-cut-card .sc-metric-main {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
}
.scale-cut-card .sc-metric-sub {
  font-size: 0.7rem;
  color: var(--muted);
}

/* --- Creative Detail Modal (v3) --- */
.creative-modal .cm-header {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  align-items: flex-start;
}
.creative-modal .cm-thumb {
  width: 80px;
  height: 80px;
  border-radius: var(--radius);
  background: var(--primary-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  flex-shrink: 0;
}
.creative-modal .cm-title-area { flex: 1; }
.creative-modal .cm-name {
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 4px;
}
.creative-modal .cm-campaign {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.5;
}
.creative-modal .cm-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.creative-modal .cm-kpi {
  padding: 10px;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
}
.creative-modal .cm-kpi-label {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
}
.creative-modal .cm-kpi-value {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary);
}
.creative-modal .cm-funnel {
  display: flex;
  gap: 0;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}
.creative-modal .cm-funnel-stage {
  text-align: center;
  flex: 1;
}
.creative-modal .cm-funnel-val {
  font-size: 1rem;
  font-weight: 800;
  color: var(--primary);
}
.creative-modal .cm-funnel-label {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--muted);
}
.creative-modal .cm-diag {
  padding: 12px;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
}
.creative-modal .cm-diag-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}
.creative-modal .cm-diag-text {
  font-size: 0.8rem;
  color: var(--muted);
}

/* --- Two Column Layout (main + sidebar) --- */
.layout-2col {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  align-items: start;
}
@media (max-width: 1024px) {
  .layout-2col { grid-template-columns: 1fr; }
}

/* --- Section title with icon --- */
.section-title-icon {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 800;
  margin-top: 24px;
  margin-bottom: 12px;
  color: var(--text);
}
.section-title-icon .sti-icon { font-size: 1.1rem; }

/* --- Data Health Section --- */
.data-health {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow);
}
.data-health .dh-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 0.8rem;
}
.data-health .dh-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 8px;
}
.data-health .dh-badge.ok { background: var(--success-bg); color: var(--success); }
.data-health .dh-badge.warn { background: var(--warning-bg); color: #b45309; }

/* --- Ranking Cards (Top 5) --- */
.ranking-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
}
.ranking-card .ranking-title {
  font-size: 0.9rem;
  font-weight: 800;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ranking-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
}
.ranking-item:last-child { border-bottom: none; }
.ranking-item .rank-pos {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary);
  min-width: 28px;
}
.ranking-item .rank-name {
  flex: 1;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ranking-item .rank-value {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text);
}

/* --- Creative Ranking Grid --- */
.creative-ranking-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

/* --- Creative Library Grid --- */
.creative-library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

/* --- KPI Grid helpers --- */
.kpi-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi-grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }

@media (max-width: 768px) {
  .creative-ranking-grid { grid-template-columns: 1fr; }
  .creative-library-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
  .kpi-grid-3, .kpi-grid-4, .kpi-grid-5 { grid-template-columns: repeat(2, 1fr); }
}

/* --- Source Comparison (trafego vs organico side-by-side) --- */
.source-comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}
.source-comparison .source-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  transition: all var(--transition);
}
.source-comparison .source-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.source-comparison .source-card-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.source-comparison .source-card-title .source-icon { font-size: 1rem; }
.source-comparison .source-kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.source-comparison .source-kpi-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
}
.source-comparison .source-kpi-value {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
}
@media (max-width: 768px) {
  .source-comparison { grid-template-columns: 1fr; }
}

/* --- Bump Cards Grid (order bump cards) --- */
.bump-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.bump-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  transition: all var(--transition);
}
.bump-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.bump-card .bump-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bump-card .bump-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 4px;
}
.bump-card .bump-sub {
  font-size: 0.75rem;
  color: var(--muted);
}
.bump-card .bump-rate {
  font-size: 0.8rem;
  font-weight: 700;
  margin-top: 6px;
}
.bump-card .bump-rate.ok { color: var(--success); }
.bump-card .bump-rate.warn { color: #b45309; }
.bump-card .bump-rate.bad { color: var(--danger); }

/* --- Filter Row (search + filter dropdowns) --- */
.filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filter-row .filter-search {
  flex: 1;
  min-width: 180px;
  max-width: 320px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font-size: 0.82rem;
  transition: border-color var(--transition);
}
.filter-row .filter-search:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}
.filter-row .filter-search::placeholder { color: var(--muted); }
.filter-row .filter-select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color var(--transition);
}
.filter-row .filter-select:focus {
  outline: none;
  border-color: var(--primary);
}
.filter-row .filter-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.filter-row .filter-count {
  font-size: 0.75rem;
  color: var(--muted);
  margin-left: auto;
  white-space: nowrap;
}
@media (max-width: 768px) {
  .filter-row { flex-direction: column; align-items: stretch; }
  .filter-row .filter-search { max-width: 100%; }
  .filter-row .filter-count { margin-left: 0; }
}

/* Card hover effect (replaces inline JS handlers) */
.card-hover {
  transition: box-shadow .15s;
}
.card-hover:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* =============================================
   MOBILE OVERRIDES
   ============================================= */

/* Sub-tabs: scrollable on mobile */
@media (max-width: 600px) {
  .subtab-nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
  }
  .subtab-nav::-webkit-scrollbar { display: none; }
  .subtab-btn {
    padding: 6px 12px;
    font-size: 0.75rem;
    white-space: nowrap;
    flex-shrink: 0;
  }
}

/* KPI Pro cards: smaller on mobile */
@media (max-width: 480px) {
  .kpi-pro { padding: 12px 14px; }
  .kpi-pro .kpi-pro-value { font-size: 1.4rem; }
  .kpi-pro .kpi-pro-label { font-size: 0.68rem; }
  .kpi-pro .kpi-pro-sub { font-size: 0.7rem; }
  .kpi-pro .kpi-pro-badge { font-size: 0.55rem; padding: 1px 5px; }
  .kpi-pro.lg .kpi-pro-value { font-size: 1.6rem; }
}

@media (max-width: 600px) {
  .nps-filter-bar { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .nps-filter-label { display: none; }
  .nps-filter { flex-shrink: 0; }
  .nps-filter-stack { display: grid; gap: 8px; }
  .nps-filter-stack .nps-filter-bar { margin-bottom: 0; }
  .nps-answer-grid { grid-template-columns: 1fr; }
  .nps-response-head { flex-wrap: wrap; }
  .nps-response-head > span:last-child { width: 100%; margin-left: 0; }
  .nps-lead-summary { align-items: flex-start; flex-direction: column; }
  .nps-lead-actions { width: 100%; justify-content: space-between; }
  .nps-whatsapp-btn { flex: 1; }
  .nps-score-tooltip { left: auto; right: -8px; transform: translateY(-5px); }
  .nps-tooltip-wrap:hover .nps-score-tooltip,
  .nps-tooltip-wrap:focus-within .nps-score-tooltip { transform: translateY(0); }
}

@media (max-width: 480px) {
  .bottom-nav .bnav-item { font-size: .56rem; padding-left: 1px; padding-right: 1px; }
  .bottom-nav .bnav-item .bnav-icon { font-size: 1.05rem; }
}

/* Charts: taller on mobile for readability */
@media (max-width: 480px) {
  .chart-container { padding: 12px; }
  .chart-container canvas { max-height: 200px; }
  .chart-container.tall canvas { max-height: 280px; }
}

/* Horizontal funnel: wrap nicely on mobile */
@media (max-width: 600px) {
  .h-funnel {
    flex-direction: column;
    gap: 4px;
    padding: 12px;
  }
  .h-funnel-stage { min-width: unset; width: 100%; }
  .h-funnel-arrow {
    transform: rotate(90deg);
    padding: 2px 0;
    font-size: 1rem;
  }
}

/* Diagnostic bars: compact on mobile */
@media (max-width: 480px) {
  .diag-bar-item { padding: 10px 12px; gap: 8px; }
  .diag-bar-item .diag-bar-name { font-size: 0.78rem; }
  .diag-bar-item .diag-bar-current { font-size: 0.9rem; }
}

/* Scale/Cut grid: full width on mobile */
@media (max-width: 600px) {
  .scale-cut-grid { grid-template-columns: 1fr; gap: 12px; }
  .scale-cut-card { padding: 10px; gap: 10px; }
  .scale-cut-card .sc-thumb { width: 40px; height: 40px; font-size: 1rem; }
  .scale-cut-card .sc-name { font-size: 0.75rem; }
}

/* Modal: full-screen on mobile */
@media (max-width: 600px) {
  .modal-content {
    width: 95%;
    max-height: 85vh;
    padding: 16px;
    border-radius: var(--radius);
  }
  .modal-title { font-size: 0.95rem; }
  .creative-modal .cm-header { flex-direction: column; gap: 10px; }
  .creative-modal .cm-thumb { width: 60px; height: 60px; font-size: 1.5rem; }
  .creative-modal .cm-kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .creative-modal .cm-funnel { flex-wrap: wrap; gap: 8px; padding: 10px; }
}

/* Tables: better touch scroll */
@media (max-width: 768px) {
  .perf-table-wrap {
    -webkit-overflow-scrolling: touch;
  }
  .perf-table th { padding: 8px 10px; font-size: 0.65rem; }
  .perf-table td { padding: 6px 10px; font-size: 0.75rem; }
  .perf-table-search { width: 140px; }
}

/* Layout 2col: stack on mobile (already handled at 1024px) */

/* Action panel: compact */
@media (max-width: 480px) {
  .action-panel { padding: 14px; }
  .action-panel .action-panel-title { font-size: 0.9rem; }
}

/* Bottom nav: safe area inset for notched phones */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .bottom-nav {
    padding-bottom: calc(6px + env(safe-area-inset-bottom));
    height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
  }
}

/* Source comparison: already stacks at 768px, tweak card padding */
@media (max-width: 480px) {
  .source-comparison .source-card { padding: 14px; }
  .source-comparison .source-kpi-value { font-size: 0.95rem; }
}

/* Insight cards: compact on mobile */
@media (max-width: 480px) {
  .insight-card { padding: 12px 14px; gap: 12px; }
  .insight-card .insight-title { font-size: 0.82rem; }
  .insight-card .insight-text { font-size: 0.75rem; }
  .insight-card .insight-icon { font-size: 1.1rem; width: 30px; height: 30px; }
}

/* Creative grid: single column on mobile */
@media (max-width: 480px) {
  .creative-grid { grid-template-columns: 1fr; }
  .creative-library-grid { grid-template-columns: 1fr; }
}

/* Hero card: compact */
@media (max-width: 480px) {
  .hero-card { padding: 16px; }
  .hero-card .hero-title { font-size: 1rem; }
  .hero-card .hero-message { font-size: 0.82rem; }
}

/* Timeline bar: scrollable on mobile */
@media (max-width: 600px) {
  .timeline-bar { padding: 10px; gap: 0; }
  .timeline-phase { padding: 8px 6px; }
  .timeline-phase .phase-label { font-size: 0.6rem; }
  .timeline-phase .phase-dates { font-size: 0.55rem; }
}

/* Bump cards: 2-col on tablet, 1-col on mobile */
@media (max-width: 480px) {
  .bump-cards-grid { grid-template-columns: 1fr; }
  .bump-card { padding: 12px; }
  .bump-card .bump-value { font-size: 1.2rem; }
}

/* =============================================
   RESPONSIVE INLINE-STYLE REPLACEMENTS
   Replaces inline grid/flex styles in JS tabs
   to prevent horizontal overflow on mobile
   ============================================= */

/* --- 2-col grid that collapses to 1-col on mobile --- */
.grid-2col-responsive {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
@media (max-width: 768px) {
  .grid-2col-responsive { grid-template-columns: 1fr; }
}

/* --- Nested 2-col KPI grid inside cards --- */
.kpi-grid-2col-nested {
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 480px) {
  .kpi-grid-2col-nested { grid-template-columns: 1fr; }
}

/* --- 4-col grid for compact metric displays --- */
.grid-4col-responsive {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 4px;
  font-size: 0.72rem;
}
@media (max-width: 480px) {
  .grid-4col-responsive { grid-template-columns: 1fr 1fr; }
}

/* --- 3-col grid for modal KPIs --- */
.grid-3col-responsive {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
@media (max-width: 480px) {
  .grid-3col-responsive { grid-template-columns: 1fr 1fr; }
}

/* --- Flex row with wrap for attribution badges --- */
.flex-row-wrap {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

/* --- Break-even card flex container --- */
.breakeven-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

/* --- Semaphore page cards grid --- */
.grid-page-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

/* --- 2-col creative card metrics (inside card, inline) --- */
.grid-2col-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
  font-size: 0.78rem;
}

@media (max-width: 480px) {
  .creative-daily-title {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }
  .creative-daily-title .text-muted { text-align: left; }
}

/* =============================================
   COMERCIAL — RVOPS Revenue Operations
   ============================================= */
.commercial-hero {
  display:flex; justify-content:space-between; align-items:center; gap:24px;
  padding:24px; margin-bottom:14px; border-radius:18px; color:#fff;
  background:linear-gradient(125deg,#111827 0%,#312e81 55%,#4f46e5 100%);
  box-shadow:0 16px 40px rgba(49,46,129,.18);
}
.commercial-hero h1 { margin:3px 0 5px; font-size:1.65rem; letter-spacing:-.03em; }
.commercial-hero p { margin:0; color:rgba(255,255,255,.72); max-width:680px; }
.commercial-eyebrow { font-size:.68rem; font-weight:800; letter-spacing:.16em; text-transform:uppercase; color:#a5b4fc; }
.commercial-sync { display:flex; align-items:center; gap:10px; padding:11px 14px; min-width:205px; border:1px solid rgba(255,255,255,.13); border-radius:12px; background:rgba(255,255,255,.08); }
.commercial-sync > span { width:9px; height:9px; border-radius:50%; background:#f59e0b; box-shadow:0 0 0 5px rgba(245,158,11,.13); }
.commercial-sync.ok > span { background:#34d399; box-shadow:0 0 0 5px rgba(52,211,153,.13); }
.commercial-sync div { display:flex; flex-direction:column; }
.commercial-sync strong { font-size:.78rem; }
.commercial-sync small { margin-top:2px; color:rgba(255,255,255,.65); font-size:.68rem; }
.commercial-filterbar { display:flex; align-items:flex-end; gap:10px; flex-wrap:wrap; margin:12px 0 16px; padding:10px 12px; border:1px solid var(--border); border-radius:12px; background:var(--card); }
.commercial-filterbar label { display:flex; flex-direction:column; gap:3px; color:var(--muted); font-size:.66rem; font-weight:700; text-transform:uppercase; letter-spacing:.05em; }
.commercial-filterbar select { min-width:180px; padding:7px 30px 7px 9px; color:var(--text); background:var(--bg); border:1px solid var(--border); border-radius:8px; }
.commercial-filter-count { margin-left:auto; padding:7px 10px; color:var(--muted); font-size:.75rem; }
.commercial-pipeline-lock { display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin:12px 0 16px; padding:11px 14px; border:1px solid rgba(99,102,241,.22); border-radius:12px; background:rgba(99,102,241,.07); }
.commercial-pipeline-lock span { color:var(--muted); font-size:.68rem; font-weight:800; text-transform:uppercase; letter-spacing:.06em; }
.commercial-pipeline-lock strong { color:var(--text); }
.commercial-pipeline-lock small { margin-left:auto; color:var(--primary); font-weight:700; }
.commercial-note { margin:0 0 14px; padding:11px 13px; border-left:4px solid #6366f1; border-radius:0 9px 9px 0; background:rgba(99,102,241,.08); color:var(--muted); font-size:.78rem; }
.commercial-note strong { color:var(--text); }
.commercial-kpis { grid-template-columns:repeat(auto-fit,minmax(190px,1fr)); }
.commercial-rank-grid { display:grid; grid-template-columns:1fr 1fr; gap:14px; margin-top:16px; }
.commercial-rank-grid.single { grid-template-columns:1fr; }
.commercial-rank { padding:17px; border:1px solid var(--border); border-radius:14px; background:var(--card); }
.commercial-rank h3 { margin:0 0 12px; font-size:.9rem; }
.commercial-rank-row { display:grid; grid-template-columns:26px 1fr auto; gap:9px; align-items:center; padding:9px 0; border-top:1px solid var(--border); }
.commercial-rank-row:first-of-type { border-top:0; }
.rank-position { display:grid; place-items:center; width:24px; height:24px; border-radius:8px; background:var(--bg-subtle); color:var(--muted); font-weight:800; font-size:.72rem; }
.commercial-rank-row div { position:relative; display:flex; flex-direction:column; gap:2px; padding-bottom:5px; overflow:hidden; }
.commercial-rank-row div strong { font-size:.78rem; }
.commercial-rank-row div small { color:var(--muted); font-size:.66rem; }
.commercial-rank-row div i { position:absolute; bottom:0; left:0; height:2px; border-radius:2px; background:linear-gradient(90deg,#6366f1,#22c55e); }
.commercial-rank-row > b { font-size:.75rem; color:var(--success); }
.commercial-stage-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(145px,1fr)); gap:9px; margin-bottom:16px; }
.commercial-stage-card { position:relative; overflow:hidden; display:flex; flex-direction:column; padding:14px; border:1px solid var(--border); border-radius:12px; background:var(--card); }
.commercial-stage-card::before { content:''; position:absolute; inset:0 auto 0 0; width:4px; background:var(--stage-color); }
.commercial-stage-card span { color:var(--muted); font-size:.68rem; font-weight:700; text-transform:uppercase; }
.commercial-stage-card strong { margin:5px 0 1px; font-size:1.45rem; }
.commercial-stage-card small { color:var(--text); font-weight:700; }
.commercial-stage-card i { margin-top:5px; color:var(--muted); font-size:.65rem; font-style:normal; }
.stage-dot { display:inline-block; width:8px; height:8px; margin-right:7px; border-radius:50%; }
.commercial-action-banner { margin-bottom:14px; padding:16px 18px; border:1px solid rgba(239,68,68,.2); border-radius:14px; background:linear-gradient(100deg,rgba(239,68,68,.11),rgba(245,158,11,.07)); }
.commercial-action-banner div { display:grid; grid-template-columns:auto 1fr; gap:2px 9px; align-items:center; }
.commercial-action-banner div > span { grid-row:1/3; font-size:1.5rem; }
.commercial-action-banner strong { font-size:.9rem; }
.commercial-action-banner small { color:var(--muted); }
.commercial-lead-link { padding:0; border:0; background:none; color:var(--primary); font:inherit; font-weight:700; cursor:pointer; text-align:left; }
.commercial-lead-link:hover { text-decoration:underline; }
.commercial-secure-gate { max-width:620px; margin:70px auto; padding:34px; text-align:center; border:1px solid var(--border); border-radius:18px; background:var(--card); box-shadow:var(--shadow); }
.commercial-lock { display:grid; place-items:center; width:58px; height:58px; margin:0 auto 12px; border-radius:16px; background:rgba(99,102,241,.1); font-size:1.8rem; }
.commercial-secure-gate h2 { margin:0 0 8px; }
.commercial-secure-gate p { color:var(--muted); line-height:1.5; }
.commercial-auth-form { display:flex; gap:8px; max-width:460px; margin:18px auto 10px; }
.commercial-auth-form input { flex:1; min-width:0; padding:10px 12px; border:1px solid var(--border); border-radius:9px; color:var(--text); background:var(--bg); }
.commercial-lead-head { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:15px; }
.commercial-lead-head > div { display:flex; flex-direction:column; }
.commercial-lead-head span,.commercial-detail-grid span { color:var(--muted); font-size:.68rem; text-transform:uppercase; font-weight:700; }
.commercial-detail-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:10px; margin-bottom:16px; }
.commercial-detail-grid > div { display:flex; flex-direction:column; gap:3px; padding:10px; border-radius:9px; background:var(--bg-subtle); }

@media (max-width:768px) {
  .commercial-hero { align-items:flex-start; flex-direction:column; padding:18px; }
  .commercial-sync { width:100%; }
  .commercial-rank-grid { grid-template-columns:1fr; }
  .commercial-filter-count { width:100%; margin-left:0; padding-left:0; }
  .commercial-auth-form { flex-direction:column; }
  .commercial-detail-grid { grid-template-columns:1fr; }
  .commercial-lead-head { align-items:flex-start; flex-direction:column; }
}
