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

:root {
  --bg-main: #080c14;
  --bg-card: #0f172a;
  --bg-card-inner: #080c14;
  --bg-card-hover: #16223d;
  --bg-input: #080c14;
  --border-color: #1e2e50;
  --border-glow: rgba(99, 102, 241, 0.35);

  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
  --purple-glow: rgba(168, 85, 247, 0.35);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #38bdf8;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* ============================================================
   SIDEBAR CLIENT AREA (COMPATIBILIDADE TOTAL)
============================================================ */
.sidebar {
  width: 240px;
  background: #080d19;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  padding: 24px 16px;
  min-height: 100vh;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 9999;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  padding: 0 8px;
}

.brand-icon {
  width: 34px;
  height: 34px;
  background: var(--primary-gradient);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.brand-text h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  line-height: 1.1;
}

.brand-text span {
  font-size: 10px;
  color: var(--text-muted);
}

.mobile-sidebar-close {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  margin-left: auto;
  padding: 6px;
  border-radius: 6px;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  border: 1px solid transparent;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  transform: translateX(3px);
  border-color: rgba(99, 102, 241, 0.2);
}

.nav-item.active {
  background: #18223c;
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.4);
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.15);
}

.nav-item .nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 12px;
  background: rgba(99, 102, 241, 0.2);
  color: #c7d2fe;
}

.sidebar-ai-box {
  background: linear-gradient(145deg, #131b31 0%, #0d1322 100%);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 12px;
  padding: 14px;
  margin-top: auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.sidebar-ai-box .ai-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #c7d2fe;
  margin-bottom: 6px;
}

.sidebar-ai-box p {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 12, 0.75);
  backdrop-filter: blur(4px);
  z-index: 9998;
}

/* ============================================================
   MAIN CONTAINER & HEADER
============================================================ */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-y: auto;
  padding: 20px 28px;
  gap: 18px;
}

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

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.mobile-menu-toggle {
  display: none;
  background: #0f172a;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 18px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.mobile-menu-toggle:hover {
  background: #1e293b;
  color: #38bdf8;
}

.title-badge-icon {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #3b82f6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
}

.title-text-group h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: #f8fafc;
  line-height: 1.2;
}

.title-text-group p {
  font-size: 11px;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.date-range-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #0f172a;
  border: 1px solid var(--border-color);
  color: #cbd5e1;
  font-size: 11px;
  font-weight: 600;
  padding: 8px 14px;
  height: 38px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.date-range-pill:hover {
  background: #1e293b;
  border-color: rgba(99, 102, 241, 0.4);
}

.export-dropdown-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.export-select {
  background: #0f172a;
  border: 1px solid var(--border-color);
  color: #f8fafc;
  font-size: 11px;
  font-weight: 600;
  padding: 0 10px;
  height: 38px;
  border-radius: 8px;
  outline: none;
  cursor: pointer;
}

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary);
  border: none;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 0 14px;
  height: 38px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.btn-download:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

/* ============================================================
   2. FILTROS DO RELATÓRIO
============================================================ */
.filters-panel {
  background: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.filters-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.filters-title {
  font-size: 13px;
  font-weight: 700;
  color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 6px;
}

.filters-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-clear-filters {
  background: #1e293b;
  color: #cbd5e1;
  border: 1px solid var(--border-color);
  font-size: 11px;
  padding: 6px 12px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-clear-filters:hover {
  background: #334155;
  color: #fff;
}

.btn-refresh {
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 11px;
  font-weight: 700;
  padding: 6px 14px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-refresh:hover {
  background: var(--primary-hover);
}

.filters-inputs-grid {
  display: grid;
  grid-template-columns: 2fr 2fr 1.5fr 1.5fr;
  gap: 12px;
}

.filter-col {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-col label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
}

.filter-control {
  background: #080c14;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: #fff;
  font-size: 11px;
  height: 34px;
  padding: 0 10px;
  outline: none;
  transition: border-color 0.2s;
}

.filter-control:focus {
  border-color: var(--primary);
}

.period-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.date-inp {
  flex: 1;
  text-align: center;
}

.period-sep {
  color: var(--text-dim);
  font-weight: 700;
}

/* ============================================================
   3. 6 KPI CARDS ROW
============================================================ */
.kpi-six-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}

.kpi-mini-card {
  background: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  transition: all 0.2s;
}

.kpi-mini-card:hover {
  border-color: rgba(99, 102, 241, 0.5);
  transform: translateY(-2px);
}

.kpi-top-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.kpi-title {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}

.kpi-mid-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.kpi-val {
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: #f8fafc;
}

.kpi-val.highlight-pink {
  color: #f43f5e;
}

.kpi-badge {
  font-size: 9px;
  font-weight: 700;
  color: #10b981;
}

.kpi-subtext {
  font-size: 8px;
  color: var(--text-dim);
}

/* ============================================================
   4. MIDDLE ROW: FUNIL + EVOLUÇÃO
============================================================ */
.rel-two-col-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.rel-card {
  background: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  transition: all 0.2s;
}

.rel-card:hover {
  border-color: rgba(99, 102, 241, 0.4);
}

.rel-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.rel-card-title {
  font-size: 13px;
  font-weight: 700;
  color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 6px;
}

.rel-card-title.highlight-purple {
  color: #c084fc;
}

.rel-card-sub {
  font-size: 9px;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
}

.panel-link {
  font-size: 10px;
  color: #38bdf8;
  text-decoration: none;
  font-weight: 600;
}

.panel-link:hover {
  text-decoration: underline;
}

/* Funnel Section */
.funnel-layout {
  display: flex;
  gap: 14px;
}

.funnel-bars-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
}

.funnel-step-item {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 26px;
}

.f-step-label {
  font-size: 10px;
  color: #cbd5e1;
  width: 110px;
  flex-shrink: 0;
  white-space: nowrap;
}

.f-step-track {
  flex: 1;
  background: #080c14;
  height: 20px;
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}

.f-step-bar {
  height: 100%;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  transition: width 0.6s ease;
}

.f-step-val {
  font-size: 9px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.funnel-metrics-sub {
  width: 140px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.funnel-stat-box {
  background: #080c14;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.f-stat-label {
  font-size: 9px;
  color: var(--text-muted);
}

.f-stat-row {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.f-stat-val {
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: #f8fafc;
}

.f-stat-badge {
  font-size: 9px;
  font-weight: 700;
  color: #10b981;
}

.f-stat-sub {
  font-size: 8px;
  color: var(--text-dim);
}

/* Evolution Chart */
.timeframe-select {
  background: #080c14;
  border: 1px solid var(--border-color);
  color: #fff;
  font-size: 10px;
  height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  outline: none;
}

.chart-legend-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: #cbd5e1;
}

.legend-item .bullet {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.line-chart-wrap {
  width: 100%;
  height: 135px;
  display: flex;
  flex-direction: column;
  position: relative;
}

.evolution-svg {
  width: 100%;
  height: 110px;
}

.chart-x-labels {
  display: flex;
  justify-content: space-between;
  font-size: 8px;
  color: var(--text-dim);
  padding: 0 10px;
}

/* ============================================================
   5. LOWER-MIDDLE ROW & TABLES
============================================================ */
.rel-split-grid {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 16px;
}

.table-card-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.analytics-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.analytics-table th {
  color: var(--text-dim);
  font-size: 9px;
  font-weight: 700;
  text-align: left;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.analytics-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(30, 46, 80, 0.4);
  color: #cbd5e1;
  white-space: nowrap;
}

.analytics-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.camp-title-cell {
  font-weight: 700;
  color: #f8fafc;
}

.conv-highlight-cell {
  font-weight: 700;
  color: #38bdf8;
  text-align: right;
}

/* Donut Chart Layout */
.donut-content-layout {
  display: flex;
  align-items: center;
  gap: 16px;
}

.donut-chart-wrap {
  width: 105px;
  height: 105px;
  position: relative;
  flex-shrink: 0;
}

.donut-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.donut-center-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.donut-total-number {
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}

.donut-total-label {
  font-size: 8px;
  color: var(--text-muted);
}

.donut-legend-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.donut-legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
}

.d-leg-left {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #cbd5e1;
}

.d-leg-bullet {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.d-leg-val {
  font-weight: 700;
}

/* ============================================================
   6. BUGS & RESUMO IA
============================================================ */
.badge-red {
  background: #ef4444;
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 10px;
}

.bugs-table td {
  font-size: 10px;
}

.diag-badge {
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.ai-summary-text-box {
  background: #080c14;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 11px;
  line-height: 1.5;
  color: #cbd5e1;
  flex: 1;
  min-height: 110px;
}

.btn-generate-ai {
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 10px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-generate-ai:hover {
  background: var(--primary-hover);
}

/* ============================================================
   RESPONSIVIDADE MULTI-DISPOSITIVO
============================================================ */
@media (max-width: 1200px) {
  .kpi-six-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .rel-two-col-grid {
    grid-template-columns: 1fr;
  }

  .rel-split-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1024px) {
  body {
    flex-direction: column;
  }

  .mobile-menu-toggle {
    display: inline-flex;
  }

  .mobile-sidebar-close {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: -320px;
    width: 280px;
    height: 100vh;
    box-shadow: none;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
    overflow-y: auto;
  }

  .sidebar.open {
    left: 0;
    box-shadow: 16px 0 50px rgba(0, 0, 0, 0.85);
  }

  .sidebar-backdrop.active {
    display: block;
  }

  .main-wrapper {
    padding: 16px 16px;
  }

  .analytics-header {
    flex-direction: column;
    align-items: stretch;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .filters-inputs-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 768px) {
  .kpi-six-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .filters-inputs-grid {
    grid-template-columns: 1fr;
  }

  .funnel-layout {
    flex-direction: column;
  }

  .funnel-metrics-sub {
    width: 100%;
    flex-direction: row;
  }

  .funnel-stat-box {
    flex: 1;
  }

  .donut-content-layout {
    flex-direction: column;
  }
}

@media (max-width: 520px) {
  .main-wrapper {
    padding: 12px 10px;
    gap: 14px;
  }

  .kpi-six-grid {
    grid-template-columns: 1fr;
  }

  .title-text-group h1 {
    font-size: 18px;
  }

  .header-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .export-dropdown-wrap {
    width: 100%;
  }

  .export-select {
    flex: 1;
  }

  .funnel-step-item {
    flex-direction: column;
    align-items: flex-start;
    height: auto;
    gap: 4px;
  }

  .f-step-label {
    width: 100%;
  }

  .f-step-track {
    width: 100%;
  }

  .funnel-metrics-sub {
    flex-direction: column;
  }
}
