/* ==========================================================================
   CATEDRAL DIGITAL — PAINEL DE VENDAS (THIAGO DUTRA)
   Design System: Minimalista Contemporâneo (Light Mode Obrigatório)
   Tipografia: Inter / Geist Sans + Space Mono / JetBrains Mono
   ========================================================================== */

:root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --panel-hover: #f1f5f9;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --subtle: #94a3b8;
  --accent: #2563eb;
  --accent-light: #eff6ff;
  --brand: #ea580c;
  --brand-light: #fff7ed;
  --brand-subtle: #ffedd5;
  --green: #16a34a;
  --green-light: #f0fdf4;
  --red: #dc2626;
  --red-light: #fef2f2;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Space Mono', SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow-card: 0 1px 3px 0 rgba(15, 23, 42, 0.06), 0 1px 2px -1px rgba(15, 23, 42, 0.04);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.45;
  min-height: 100vh;
}

/* Container Principal */
.dash-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 18px 24px 48px;
}

/* Header Superior */
.dash-header {
  margin-bottom: 20px;
}

.dash-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  object-fit: cover;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.brand-titles h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.2;
}

.brand-titles p {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  font-family: var(--font-mono);
}

/* Abas de Navegação */
.dash-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
}

.nav-tab {
  background: transparent;
  border: none;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.nav-tab:hover {
  color: var(--text);
  background-color: var(--panel-hover);
}

.nav-tab.active {
  color: var(--text);
  font-weight: 600;
  background-color: var(--panel);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
}

/* Barra de Filtros e Ações */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.filter-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Controles de Formulário e Seletor de Período */
.date-picker-wrapper {
  position: relative;
  display: inline-block;
}

.date-btn {
  height: 36px;
  padding: 0 12px;
  font-size: 13px;
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s ease;
}

.date-btn:hover,
.date-btn.active {
  border-color: #ea580c;
  box-shadow: 0 0 0 1px rgba(234, 88, 12, 0.2);
}

.date-btn .date-icon {
  font-size: 14px;
}

.date-btn .chevron-icon {
  color: var(--muted);
  transition: transform 0.2s ease;
}

.date-btn.active .chevron-icon {
  transform: rotate(180deg);
}

.select-control {
  height: 36px;
  padding: 0 10px;
  font-size: 12px;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: border-color 0.15s ease;
}

.select-control:hover {
  border-color: var(--line-strong);
}

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

.btn-primary {
  height: 34px;
  padding: 0 14px;
  font-size: 12px;
  font-weight: 600;
  color: #ffffff;
  background-color: var(--text);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: opacity 0.15s ease;
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-icon {
  height: 34px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}

.btn-icon:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

/* Legenda do Topo */
.stamp-notice {
  font-size: 11px;
  color: var(--subtle);
  margin-bottom: 14px;
}

/* Grid de Cards do DRE (5 colunas desktop) */
.dre-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

@media (max-width: 1200px) {
  .dre-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

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

@media (max-width: 480px) {
  .dre-grid {
    grid-template-columns: 1fr;
  }
}

/* Card DRE */
.metric-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  position: relative;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 82px;
  transition: border-color 0.15s ease;
}

.metric-card:hover {
  border-color: var(--line-strong);
}

.card-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
}

.card-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.2;
}

.card-stamp {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

.card-value {
  font-family: var(--font-mono);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.15;
}

.card-value.green {
  color: var(--green);
}

.card-value.red {
  color: var(--red);
}

.card-value.brand {
  color: var(--brand);
}

.card-subtext {
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.25;
}

/* Grid de KPIs de Funil (4 colunas desktop) */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

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

@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
}

.kpi-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}

.kpi-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

.kpi-value {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.kpi-sub {
  font-size: 10.5px;
  font-family: var(--font-mono);
  color: var(--muted);
  margin-top: 2px;
}

/* Seção de Gráficos */
.chart-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

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

.chart-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.chart-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.chart-subtitle {
  font-size: 11px;
  color: #94a3b8;
  font-family: var(--font-sans);
}

/* Legenda Customizada (Imagem 2) */
.chart-legend-custom {
  display: flex;
  align-items: center;
  gap: 14px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: #64748b;
  font-weight: 500;
}

.legend-circle {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

.legend-circle.orange {
  border: 2px solid #ea580c;
  background: #ffffff;
}

.legend-circle.blue {
  border: 2px solid #3b82f6;
  background: #ffffff;
}

.chart-container-large {
  width: 100%;
  height: 250px;
  position: relative;
}

/* Tooltip Customizado Flutuante Premium (Imagem 2) */
.chart-custom-tooltip {
  position: absolute;
  display: none;
  pointer-events: none;
  z-index: 100;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 14px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  min-width: 180px;
  transition: opacity 0.1s ease, transform 0.1s ease;
}

.chart-custom-tooltip.active {
  display: block;
}

.chart-custom-tooltip .tooltip-date {
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 8px;
}

.chart-custom-tooltip .tooltip-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 6px;
  font-size: 12px;
}

.chart-custom-tooltip .tooltip-row:last-child {
  margin-bottom: 0;
}

.chart-custom-tooltip .tooltip-left {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #64748b;
}

.chart-custom-tooltip .tooltip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.chart-custom-tooltip .tooltip-dot.orange {
  background: #ea580c;
}

.chart-custom-tooltip .tooltip-dot.blue {
  background: #3b82f6;
}

.chart-custom-tooltip .tooltip-val {
  font-weight: 700;
  color: #0f172a;
  font-family: var(--font-mono);
  font-size: 12.5px;
}

/* Gráficos em Linha Dupla */
.charts-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

@media (max-width: 900px) {
  .charts-split {
    grid-template-columns: 1fr;
  }
}

.chart-container-medium {
  width: 100%;
  height: 200px;
  position: relative;
}

/* Rankings de Produtos */
.rankings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

@media (max-width: 900px) {
  .rankings-grid {
    grid-template-columns: 1fr;
  }
}

.rank-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 12px;
}

.rank-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  font-weight: 500;
}

.rank-bar-wrap {
  width: 140px;
  height: 8px;
  background-color: var(--line);
  border-radius: 4px;
  overflow: hidden;
}

.rank-bar-fill {
  height: 100%;
  background-color: var(--brand);
  border-radius: 4px;
}

.rank-val {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text);
  width: 65px;
  text-align: right;
}

/* Tabelas Analíticas */
.table-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

.table-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.dash-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  text-align: left;
}

.dash-table th {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background-color: var(--bg);
  white-space: nowrap;
}

.dash-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-family: var(--font-sans);
  white-space: nowrap;
}

.dash-table tr:hover td {
  background-color: #fafbfc;
}

.dash-table .mono {
  font-family: var(--font-mono);
}

.dash-table .num {
  text-align: right;
  font-family: var(--font-mono);
}

.table-notice {
  font-size: 11px;
  color: var(--muted);
  margin-top: 12px;
  line-height: 1.4;
}

/* Visual de Funil (Aba Esteira) */
.funnel-visual-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  text-align: center;
}

.funnel-diagram {
  max-width: 480px;
  margin: 16px auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.funnel-step {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  color: #ffffff;
  font-weight: 600;
  font-size: 13px;
  box-shadow: var(--shadow-sm);
}

.funnel-front {
  background-color: var(--brand);
  clip-path: polygon(0 0, 100% 0, 85% 100%, 15% 100%);
  padding: 14px 20px;
}

.funnel-bumps {
  background-color: #f97316;
  width: 70%;
  opacity: 0.95;
  clip-path: polygon(0 0, 100% 0, 85% 100%, 15% 100%);
}

.funnel-upsell {
  background-color: #fb923c;
  width: 45%;
  opacity: 0.9;
}

/* Aba Oculta */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.2s ease-in-out;
}

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

/* Rodapé */
.dash-footer {
  margin-top: 36px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  flex-wrap: wrap;
  gap: 10px;
}

.dash-footer-link {
  color: var(--accent);
  text-decoration: none;
  font-family: var(--font-mono);
}

.dash-footer-link:hover {
  text-decoration: underline;
}

/* ==================== CALENDÁRIO POPOVER OFICIAL (IMAGEM 1) ==================== */
.calendar-popover {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 500;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.05);
  padding: 18px;
  width: 440px;
  box-sizing: border-box;
}

.calendar-popover.active {
  display: flex;
}

/* Coluna Esquerda: Presets Rápidos */
.cal-presets {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 125px;
  flex-shrink: 0;
}

.cal-preset-item {
  background: transparent;
  border: none;
  text-align: left;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 500;
  color: #475569;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.12s ease;
  font-family: var(--font-sans);
}

.cal-preset-item:hover {
  background: #fff7ed;
  color: #ea580c;
}

.cal-preset-item.active {
  color: #ea580c;
  font-weight: 700;
  background: #ffedd5;
}

/* Divisor Vertical */
.cal-divider {
  width: 1px;
  background: #f1f5f9;
  margin: 0 12px;
  flex-shrink: 0;
}

/* Coluna Direita: Grade do Mês */
.cal-body {
  flex: 1;
}

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

.cal-month-title {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.01em;
}

.cal-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cal-nav-btn {
  background: transparent;
  border: none;
  color: #ea580c;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s ease;
}

.cal-nav-btn:hover {
  background: #ffedd5;
}

/* Dias da Semana */
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 34px);
  gap: 2px;
  text-align: center;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
}

/* Grade dos Dias */
.cal-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 34px);
  gap: 2px;
  text-align: center;
  margin-bottom: 16px;
}

.cal-day-cell {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 500;
  color: #0f172a;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.1s ease;
  user-select: none;
  background: transparent;
}

.cal-day-cell:hover:not(.empty):not(.range-start):not(.range-end) {
  background: #f8fafc;
}

.cal-day-cell.empty {
  cursor: default;
  pointer-events: none;
  background: transparent;
}

/* Highlight de Range Selecionado (Imagem 1) */
.cal-day-cell.range-start {
  background: #ea580c !important;
  color: #ffffff !important;
  font-weight: 700;
  border-radius: 6px;
}

.cal-day-cell.range-end {
  background: #ea580c !important;
  color: #ffffff !important;
  font-weight: 700;
  border-radius: 6px;
}

.cal-day-cell.in-range {
  background: #ffedd5 !important;
  color: #0f172a !important;
  font-weight: 600;
  border-radius: 0;
}

.cal-day-cell.range-start.range-end {
  border-radius: 6px !important;
}

/* Rodapé do Popover */
.cal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
}

.cal-selected-range {
  font-size: 11px;
  color: #64748b;
  font-family: var(--font-mono);
  line-height: 1.35;
}

.btn-cal-apply {
  background: #ea580c;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
  font-family: var(--font-sans);
}

.btn-cal-apply:hover {
  background: #c2410c;
}
