/* ==========================================================================
   CATEDRAL DIGITAL — PAINEL DE VENDAS
   Design System Oficial Catedral Digital v1.0.0 (Versão Light Editorial)
   Cores Oficiais: Azul Catedral #082032, Laranja Catedral #FF4C29, Ardósia #334756, Cinza #D2D2D2
   Tipografia: Manrope (Sans-serif) + Space Mono (Métricas & Moedas)
   ========================================================================== */

:root {
  /* Tokens Oficiais da Marca Catedral Digital */
  --cd-navy: #082032;        /* Azul Catedral */
  --cd-charcoal: #2C394B;    /* Grafite */
  --cd-slate: #334756;       /* Ardósia */
  --cd-gray: #D2D2D2;        /* Cinza */
  --cd-orange: #FF4C29;      /* Laranja Catedral */
  --cd-white: #FFFFFF;

  /* Superfície, Fundo & Contraste (Estritamente Versão Light) */
  --background: #F8FAFC;
  --foreground: #082032;
  --card: #FFFFFF;
  --card-foreground: #082032;
  --popover: #FFFFFF;
  --popover-foreground: #082032;

  /* Ações & Destaques Primários */
  --primary: #FF4C29;
  --primary-hover: #E63E1C;
  --primary-foreground: #FFFFFF;
  --secondary: #082032;
  --secondary-hover: #142E41;
  --secondary-foreground: #FFFFFF;

  /* Apoio & Tipografia Secundária */
  --muted: #F1F5F9;
  --muted-foreground: #526675;
  --accent: #FF4C29;
  --accent-foreground: #FFFFFF;
  --destructive: #DC2626;
  --destructive-foreground: #FFFFFF;

  /* Bordas e Controles */
  --border: #E2E8F0;
  --border-strong: #D2D2D2;
  --input: #E2E8F0;
  --ring: rgba(255, 76, 41, 0.25);

  /* Tipografia Canônica do Design System */
  --font-sans: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Space Mono', 'JetBrains Mono', Menlo, monospace;
  --letter-spacing: -0.01em;

  /* Raios de Borda do Design System Oficial (8px controles, 12px cards) */
  --radius: 8px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  /* Sombras Neutras com Base Azul Catedral */
  --shadow-color: rgba(8, 32, 50, 0.05);
  --shadow-blur: 16px;
  --shadow-spread: 0px;
  --shadow-opacity: 0.05;

  /* Cores de Status Operacional */
  --status-todo: #526675;
  --status-doing: #FF4C29;
  --status-review: #D97706;
  --status-blocked: #DC2626;
  --status-done: #059669;

  /* Sombras Modernas e Limpas */
  --shadow-sm: 0 1px 3px rgba(8, 32, 50, 0.04), 0 1px 2px rgba(8, 32, 50, 0.02);
  --shadow-card: 0 2px 8px rgba(8, 32, 50, 0.04), 0 1px 2px rgba(8, 32, 50, 0.02);
  --shadow-hover: 0 6px 18px rgba(8, 32, 50, 0.08);
  --shadow-popover: 0 16px 36px -8px rgba(8, 32, 50, 0.12), 0 4px 12px rgba(8, 32, 50, 0.04);
}

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

button {
  font-family: inherit;
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background-color: var(--background);
  color: var(--foreground);
  min-height: 100vh;
  line-height: 1.5;
  letter-spacing: var(--letter-spacing);
  overflow-x: hidden;
}

body, button, input, select, textarea, optgroup {
  font-family: var(--font-sans);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
}

/* Números Tabulares Padronizados */
.mono, .num, .card-value, .kpi-value, .card-stamp, .rank-val, .stage-val, .stage-count, .table-num {
  font-family: var(--font-mono);
  font-feature-settings: 'tnum' 1, 'lnum' 1;
  font-variant-numeric: tabular-nums;
}

/* Container Principal */
.dash-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem 2rem 4rem 2rem;
}

/* ==================== HEADER EXECUTIVO ==================== */
.dash-header {
  margin-bottom: 1.5rem;
}

.dash-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-avatar-wrap {
  width: 44px;
  height: 44px;
  border-radius: calc(var(--radius) * 0.65);
  background: var(--secondary);
  box-shadow: 0 2px 8px rgba(8, 32, 50, 0.08);
  flex-shrink: 0;
  overflow: hidden;
  padding: 2px;
}

.brand-avatar {
  width: 100%;
  height: 100%;
  border-radius: calc(var(--radius) * 0.55);
  object-fit: cover;
  background-color: #ffffff;
  display: block;
}

.brand-titles {
  display: flex;
  flex-direction: column;
}

.brand-eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--primary);
  letter-spacing: 0.06em;
  margin-bottom: 0.15rem;
}

.brand-titles h1 {
  font-size: 1.18rem;
  font-weight: 700;
  color: var(--foreground);
  line-height: 1.2;
}

.brand-titles p {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted-foreground);
  margin-top: 0.15rem;
  font-family: var(--font-sans);
}

/* Ações do Topo */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.cloud-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.76rem;
  font-weight: 600;
  background-color: var(--muted);
  border: 1px solid var(--border);
  color: var(--muted-foreground);
}

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

.cloud-dot.online {
  background-color: #059669;
  box-shadow: 0 0 6px rgba(5, 150, 105, 0.4);
}

.cloud-dot.syncing {
  background-color: #d97706;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.3; }
  100% { opacity: 1; }
}

/* Botões Padrão Catedral */
.btn, .btn-primary, .btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  min-height: 36px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.18s ease;
  border: 1px solid transparent;
  outline: none;
  text-decoration: none;
  user-select: none;
  line-height: 1.2;
  box-sizing: border-box;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
  border: 1px solid transparent;
  box-shadow: 0 2px 8px rgba(255, 76, 41, 0.22);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255, 76, 41, 0.32);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-apply-filter {
  padding: 0.45rem 0.95rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.btn-secondary {
  background-color: #ffffff;
  color: var(--foreground);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background-color: var(--muted);
  border-color: var(--ring);
}

.btn-icon-only {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: calc(var(--radius) * 0.55);
  color: var(--muted-foreground);
}

.btn-icon-only:hover {
  color: var(--primary);
}

.btn-auto-refresh {
  color: #059669;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.78rem;
  font-weight: 600;
}

.pulse-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #059669;
  box-shadow: 0 0 6px rgba(5, 150, 105, 0.4);
}

/* ==================== ABAS DE NAVEGAÇÃO ==================== */
.dash-nav {
  display: inline-flex;
  background-color: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 0.7);
  padding: 0.25rem;
  gap: 0.25rem;
  margin-bottom: 1.25rem;
  overflow-x: auto;
  max-width: 100%;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 1.1rem;
  border-radius: calc(var(--radius) * 0.5);
  background-color: transparent;
  border: none;
  color: var(--muted-foreground);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: var(--font-sans);
  white-space: nowrap;
}

.nav-tab svg {
  opacity: 0.7;
  transition: opacity 0.15s ease;
}

.nav-tab:hover {
  color: var(--foreground);
}

.nav-tab:hover svg {
  opacity: 1;
}

.nav-tab.active {
  background-color: #ffffff;
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(8, 32, 50, 0.06);
}

.nav-tab.active svg {
  opacity: 1;
  color: var(--primary);
}

/* ==================== BARRA DE FILTROS ==================== */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.filter-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.date-picker-wrapper {
  position: relative;
  display: inline-block;
}

.date-btn {
  height: 38px;
  padding: 0 14px;
  font-size: 0.82rem;
  font-family: var(--font-sans);
  font-weight: 600;
  color: var(--foreground);
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.18s ease;
  box-shadow: var(--shadow-sm);
}

.date-btn:hover,
.date-btn.active {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px rgba(255, 76, 41, 0.18);
}

.date-icon-svg {
  color: var(--primary);
  flex-shrink: 0;
}

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

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

.select-control {
  height: 38px;
  padding: 0 28px 0 14px;
  font-size: 0.82rem;
  font-family: var(--font-sans);
  font-weight: 500;
  color: var(--foreground);
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  box-shadow: var(--shadow-sm);
  transition: all 0.18s ease;
}

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

.select-control:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px rgba(255, 76, 41, 0.18);
}

/* ==================== FILTRO VISUAL DE ORIGEM ==================== */
.source-segmented-container {
  display: inline-flex;
  align-items: center;
  background-color: var(--muted);
  padding: 2px 3px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.source-segmented-filter {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.source-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: calc(var(--radius) * 0.7);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted-foreground);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  white-space: nowrap;
}

.source-pill:hover {
  color: var(--foreground);
  background-color: rgba(255, 255, 255, 0.65);
}

.source-pill.active {
  background-color: #ffffff;
  color: var(--foreground);
  font-weight: 600;
  border-color: rgba(226, 232, 240, 0.9);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.source-pill-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-all { background-color: #64748b; }
.dot-paid { background-color: #2563eb; }
.dot-org { background-color: #059669; }

.source-pill-badge {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  background-color: rgba(100, 116, 139, 0.1);
  color: #475569;
}

.source-pill.active .source-pill-badge {
  background-color: #f1f5f9;
  color: #0f172a;
}

.source-pill-badge.badge-paid {
  background-color: rgba(37, 99, 235, 0.1);
  color: #1d4ed8;
}

.source-pill.active .source-pill-badge.badge-paid {
  background-color: #dbeafe;
  color: #082032;
}

.source-pill-badge.badge-org {
  background-color: rgba(5, 150, 105, 0.1);
  color: #047857;
}

.source-pill.active .source-pill-badge.badge-org {
  background-color: #d1fae5;
  color: #065f46;
}

/* ==================== CARD DE ATRIBUIÇÃO DE ORIGEM ==================== */
.attribution-card {
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1.15rem;
  margin-bottom: 1.15rem;
  box-shadow: var(--shadow-card);
}

.attribution-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.65rem;
}

.attr-title-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.attr-badge-tag {
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--foreground);
  background-color: var(--muted);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.attr-period-hint {
  font-size: 0.74rem;
  color: var(--muted-foreground);
}

.attr-metrics-headline {
  font-size: 0.8rem;
  color: var(--muted-foreground);
}

.attr-metrics-headline strong {
  font-family: var(--font-mono);
  color: var(--foreground);
  font-weight: 700;
}

/* Barra Proporcional */
.attr-progress-track {
  width: 100%;
  height: 8px;
  background-color: #f1f5f9;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
  margin-bottom: 0.85rem;
  border: 1px solid rgba(226, 232, 240, 0.8);
}

.attr-bar-segment {
  height: 100%;
  transition: width 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.attr-bar-segment.is-paid {
  background: linear-gradient(90deg, #3b82f6, #2563eb);
}

.attr-bar-segment.is-org {
  background: linear-gradient(90deg, #10b981, #059669);
}

/* Grade de Detalhamento */
.attr-grid-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 640px) {
  .attr-grid-cards {
    grid-template-columns: 1fr;
  }
}

.attr-col-card {
  padding: 0.75rem 0.9rem;
  border-radius: calc(var(--radius) * 0.75);
  border: 1px solid var(--border);
  background-color: #fcfcfd;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.attr-col-card:hover {
  background-color: #ffffff;
  border-color: #cbd5e1;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.attr-col-card.active-filter {
  background-color: #ffffff;
}

.attr-col-card.is-paid.active-filter {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.attr-col-card.is-org.active-filter {
  border-color: #059669;
  box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.15);
}

.attr-col-header {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.35rem;
}

.attr-dot-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.attr-col-title {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--muted-foreground);
  flex: 1;
}

.attr-col-pct {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.attr-col-card.is-paid .attr-col-pct {
  background-color: #dbeafe;
  color: #1d4ed8;
}

.attr-col-card.is-org .attr-col-pct {
  background-color: #d1fae5;
  color: #047857;
}

.attr-col-main {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 0.25rem;
}

.attr-col-vendas {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--foreground);
}

.attr-col-fat {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted-foreground);
}

.attr-col-footer {
  font-size: 0.72rem;
  color: var(--muted-foreground);
  line-height: 1.3;
}

.stamp-notice {
  font-size: 0.74rem;
  font-family: var(--font-mono);
  color: var(--muted-foreground);
  margin-bottom: 1.15rem;
}

/* ==================== DRE GRID (8 CARDS) ==================== */
.dre-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

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

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

.metric-card {
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 0.75);
  padding: 0.85rem 1rem;
  position: relative;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 86px;
  transition: all 0.18s ease;
}

.metric-card:hover {
  border-color: var(--ring);
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
}

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

.card-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted-foreground);
  letter-spacing: 0.05em;
  line-height: 1.25;
}

.card-stamp {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--muted-foreground);
  background-color: var(--muted);
  border: 1px solid var(--border);
  padding: 0.12rem 0.45rem;
  border-radius: 1rem;
}

.card-value {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--foreground);
  line-height: 1.2;
}

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

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

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

.card-subtext {
  font-size: 0.72rem;
  color: var(--muted-foreground);
  margin-top: 4px;
  line-height: 1.25;
}

/* ==================== KPI GRID (8 CARDS) ==================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

@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-color: var(--card);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 0.7);
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow-card);
  transition: all 0.18s ease;
}

.kpi-card:hover {
  border-color: var(--ring);
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
}

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

.kpi-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--foreground);
}

.kpi-sub {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: var(--muted-foreground);
  margin-top: 3px;
}

/* ==================== GRÁFICOS & PAINÉIS ==================== */
.chart-panel {
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 0.85);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-card);
}

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

.chart-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--foreground);
  letter-spacing: -0.01em;
}

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

.chart-subtitle {
  font-size: 0.74rem;
  color: var(--muted-foreground);
  font-family: var(--font-mono);
}

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

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  color: var(--muted-foreground);
  font-weight: 500;
  font-family: var(--font-mono);
}

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

.legend-circle.blue {
  border: 2px solid var(--primary);
  background: #ffffff;
}

.legend-circle.orange {
  border: 2px solid var(--foreground);
  background: #ffffff;
}

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

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

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

.chart-custom-tooltip .tooltip-date {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--foreground);
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}

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

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

.chart-custom-tooltip .tooltip-left {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted-foreground);
}

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

.chart-custom-tooltip .tooltip-dot.blue {
  background: var(--primary);
}

.chart-custom-tooltip .tooltip-dot.orange {
  background: var(--foreground);
}

.chart-custom-tooltip .tooltip-val {
  font-weight: 700;
  color: var(--foreground);
  font-family: var(--font-mono);
}

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

@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: 1.25rem;
  margin-bottom: 1.5rem;
}

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

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

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

.rank-bar-wrap {
  width: 140px;
  height: 6px;
  background-color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
}

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

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

/* ==================== TABELAS ANALÍTICAS ==================== */
.table-panel {
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 0.75);
  padding: 1.25rem 1.4rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-card);
  overflow-x: auto;
}

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

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

.dash-table th {
  background-color: var(--sidebar);
  padding: 0.75rem 0.9rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-foreground);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.dash-table td {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border);
  color: var(--foreground);
  white-space: nowrap;
  vertical-align: middle;
}

.dash-table tr:hover td {
  background-color: rgba(8, 32, 50, 0.03);
}

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

.table-notice {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: var(--muted-foreground);
  margin-top: 1rem;
  line-height: 1.45;
}

/* ==================== FUNIL & ESTEIRA (PADRÃO CATEDRAL TAREFAS) ==================== */
.funnel-visual-card {
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 0.85);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-card);
}

.funnel-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 10px;
}

.funnel-badge-live {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--status-done);
  background-color: rgba(5, 150, 105, 0.08);
  border: 1px solid rgba(5, 150, 105, 0.2);
  padding: 0.25rem 0.6rem;
  border-radius: 1rem;
}

.funnel-pipeline-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
}

@media (max-width: 768px) {
  .funnel-pipeline-bar { grid-template-columns: 1fr; }
}

.funnel-step-item {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.85rem 1rem;
  border-radius: calc(var(--radius) * 0.65);
  border: 1px solid var(--border);
  background-color: var(--muted);
  transition: all 0.18s ease;
}

.funnel-step-item:hover {
  background-color: #ffffff;
  border-color: var(--ring);
  box-shadow: 0 4px 12px rgba(8, 32, 50, 0.04);
}

.funnel-step-item.active {
  background-color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(255, 76, 41, 0.15);
}

.funnel-step-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--foreground);
}

.funnel-step-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.76rem;
  color: var(--muted-foreground);
  font-family: var(--font-mono);
}

.funnel-progress-track {
  width: 100%;
  height: 5px;
  background-color: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
}

.funnel-progress-fill {
  height: 100%;
  background-color: var(--primary);
  border-radius: 3px;
}

.badge-count {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  background-color: #ffffff;
  color: var(--primary);
  padding: 0.12rem 0.45rem;
  border-radius: 1rem;
  border: 1px solid var(--border);
  font-weight: 700;
}

/* ==================== ABAS OCULTAS & TRANSIÇÕES ==================== */
.tab-content {
  display: none;
}

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

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

/* ==================== RODAPÉ CATEDRAL ==================== */
.dash-footer {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.76rem;
  color: var(--muted-foreground);
  flex-wrap: wrap;
  gap: 12px;
}

.dash-footer-left {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

.footer-brand {
  font-weight: 700;
  color: var(--foreground);
}

.dash-footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
}

.footer-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #059669;
}

.dash-footer-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

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

/* ==================== CALENDÁRIO POPOVER OFICIAL ==================== */
.calendar-popover {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 500;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 1.1);
  box-shadow: var(--shadow-popover);
  padding: 1.15rem;
  width: 440px;
  box-sizing: border-box;
}

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

.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: 0.8rem;
  font-weight: 500;
  color: var(--muted-foreground);
  border-radius: calc(var(--radius) * 0.45);
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--font-sans);
}

.cal-preset-item:hover {
  background: var(--muted);
  color: var(--foreground);
}

.cal-preset-item.active {
  color: var(--primary);
  font-weight: 700;
  background-color: rgba(255, 76, 41, 0.08);
}

.cal-divider {
  width: 1px;
  background: var(--border);
  margin: 0 12px;
  flex-shrink: 0;
}

.cal-body {
  flex: 1;
}

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

.cal-month-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--foreground);
}

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

.cal-nav-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted-foreground);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.cal-nav-btn:hover {
  background: var(--muted);
  color: var(--primary);
  border-color: var(--ring);
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 34px);
  gap: 2px;
  text-align: center;
  margin-bottom: 6px;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted-foreground);
}

.cal-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 34px);
  gap: 2px;
  text-align: center;
  margin-bottom: 14px;
}

.cal-day-cell {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--foreground);
  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: var(--muted);
}

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

/* Range Selecionado Azul Catedral */
.cal-day-cell.range-start {
  background: var(--primary) !important;
  color: #ffffff !important;
  font-weight: 700;
  border-radius: 6px;
}

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

.cal-day-cell.in-range {
  background: rgba(255, 76, 41, 0.08) !important;
  color: var(--primary) !important;
  font-weight: 600;
  border-radius: 0;
}

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

.cal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.cal-selected-range {
  font-size: 0.74rem;
  color: var(--muted-foreground);
  font-family: var(--font-mono);
  line-height: 1.35;
}

.btn-cal-apply {
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius);
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(8, 32, 50, 0.08);
  transition: all 0.15s ease;
}

.btn-cal-apply:hover {
  filter: brightness(1.08);
}

@media (max-width: 500px) {
  .calendar-popover {
    width: min(calc(100vw - 28px), 360px);
    flex-direction: column;
    left: 0;
    padding: 12px;
  }
  .cal-presets {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
  }
  .cal-preset-item {
    padding: 4px 8px;
    font-size: 11px;
  }
  .cal-divider {
    width: 100%;
    height: 1px;
    margin: 8px 0;
  }
  .cal-weekdays,
  .cal-days-grid {
    grid-template-columns: repeat(7, 1fr);
  }
  .cal-day-cell {
    width: 100%;
    height: 30px;
    font-size: 11px;
  }
}

/* ==========================================================================
   TELA DE AUTENTICAÇÃO (LOGIN GOOGLE & OPERADOR CATEDRAL DIGITAL)
   ========================================================================== */
.auth-screen {
  position: fixed;
  inset: 0;
  background-color: var(--background);
  background-image: 
    radial-gradient(at 0% 0%, rgba(255, 76, 41, 0.08) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(30, 64, 175, 0.06) 0px, transparent 50%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1.5rem;
}

.auth-card {
  background-color: #ffffff;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 1.2);
  width: 100%;
  max-width: 440px;
  padding: 2.5rem 2.2rem;
  box-shadow: 0 20px 45px rgba(8, 32, 50, 0.08);
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
  text-align: center;
  animation: authFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes authFadeIn {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.auth-logo-badge {
  width: 54px;
  height: 54px;
  background: var(--secondary);
  border-radius: calc(var(--radius) * 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(255, 76, 41, 0.3);
  margin-bottom: 0.35rem;
}

.auth-brand h1 {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--foreground);
  letter-spacing: -0.02em;
}

.auth-brand p {
  font-size: 0.86rem;
  color: var(--muted-foreground);
}

.auth-badge-notice {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  background-color: rgba(255, 76, 41, 0.08);
  border: 1px solid rgba(255, 76, 41, 0.15);
  padding: 0.4rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  margin: 0 auto;
}

.btn-google-auth {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.85rem 1rem;
  background-color: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: calc(var(--radius) * 0.6);
  font-size: 0.92rem;
  font-weight: 600;
  color: #1e293b;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  transition: all 0.2s ease;
}

.btn-google-auth:hover {
  background-color: #f8fafc;
  border-color: #94a3b8;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

.btn-google-auth:active {
  transform: translateY(0);
}


.auth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--muted-foreground);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0.2rem 0;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border);
}

.auth-divider span {
  padding: 0 0.8rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  text-align: left;
}

.auth-input-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--foreground);
  margin-bottom: 0.35rem;
}

.auth-input-group input {
  width: 100%;
  padding: 0.75rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 0.5);
  font-size: 0.9rem;
  color: var(--foreground);
  background-color: #ffffff;
  outline: none;
  transition: border-color 0.15s ease;
}

.auth-input-group input:focus,
.auth-input-group input.highlight-pulse {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(46, 103, 255, 0.22);
}

.btn-auth-submit {
  width: 100%;
  justify-content: center;
  padding: 0.8rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.auth-status-msg {
  font-size: 0.82rem;
  line-height: 1.4;
  border-radius: 6px;
  padding: 0.65rem 0.85rem;
  display: none;
  text-align: left;
}

.auth-status-msg.error {
  display: block;
  background-color: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #b91c1c;
}

.auth-status-msg.info {
  display: block;
  background-color: rgba(255, 76, 41, 0.08);
  border: 1px solid rgba(255, 76, 41, 0.25);
  color: #1d4ed8;
}

/* User Pill no Header do Dashboard */
.auth-user-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: #ffffff;
  border: 1px solid var(--border);
  padding: 0.25rem 0.65rem 0.25rem 0.35rem;
  border-radius: 9999px;
  box-shadow: var(--shadow-sm);
}

.user-avatar-small {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--secondary);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.user-avatar-small img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-meta-small {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.user-name-small {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--foreground);
}

.user-role-small {
  font-size: 0.65rem;
  font-family: var(--font-mono);
  color: var(--muted-foreground);
}

.btn-logout-small {
  background: transparent;
  border: none;
  color: var(--muted-foreground);
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.15s ease;
  margin-left: 0.2rem;
}

.btn-logout-small:hover {
  color: #ef4444;
  background-color: #fee2e2;
}
