/* ==========================================================================
   DESIGN TOKENS & RESET
   ========================================================================== */
@layer reset, base, components, utilities;

@layer reset {
  *, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
  }
}

@layer base {
  :root {
    /* Color Palette - Premium Light Mode (B3 Editorial) */
    --bg-primary: #F6F8FB;           /* Off-white editorial background */
    --bg-secondary: #FFFFFF;         /* Pure white for containers/cards */
    --bg-tati-bubble: #EEF6FF;       /* Soft blue background for Tati's dialogue */
    --bg-input: #F1F5F9;             /* Input background */
    
    --color-b3-blue: #0057B8;        /* B3 Institutional Blue */
    --color-b3-dark: #003B7A;        /* B3 Deep Corporate Blue */
    --color-b3-accent: #00AEEF;      /* Vibrant Cyan accent */
    
    --text-primary: #1E293B;        /* Slate 800 - high contrast body text */
    --text-secondary: #475569;      /* Slate 600 - secondary body text */
    --text-muted: #64748B;          /* Slate 500 - meta/muted text */
    
    --border-color: #E2E8F0;         /* Slate 200 - elegant thin border */
    
    --color-positive: #10B981;      /* Emerald 500 - positive indicators */
    --color-positive-bg: #ECFDF5;   /* Soft positive bg */
    --color-warning: #F59E0B;       /* Amber 500 - points of attention */
    --color-warning-bg: #FEF3C7;    /* Soft warning bg */
    --color-danger: #EF4444;        /* Red 500 - errors */
    --color-danger-bg: #FEF2F2;     /* Soft red bg */

    /* Typography */
    --font-heading: 'Outfit', 'Inter', sans-serif;
    --font-body: 'Inter', sans-serif;

    /* Shadows & Border Radius - Apple-inspired style */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-2xl: 32px;
    
    --shadow-soft: 0 10px 30px -5px rgba(15, 23, 42, 0.04), 0 20px 40px -10px rgba(15, 23, 42, 0.03);
    --shadow-hover: 0 20px 40px -5px rgba(0, 87, 184, 0.08), 0 10px 20px -10px rgba(0, 87, 184, 0.05);
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    max-width: 100vw;
    /* dvh: dynamic viewport height — respeita a barra do Safari */
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden; /* o scroll fica apenas no .app-content */
    display: flex;
    flex-direction: column;
  }

  html {
    overflow-x: hidden;
    overflow-y: hidden; /* previne scroll no nível do html */
    height: 100dvh;
  }

  /* Custom Scrollbar styling */
  ::-webkit-scrollbar {
    width: 6px;
    height: 6px;
  }
  ::-webkit-scrollbar-track {
    background: transparent;
  }
  ::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 10px;
  }
  ::-webkit-scrollbar-thumb:hover {
    background: var(--color-b3-blue);
  }
}

/* ==========================================================================
   MICRO-ANIMATIONS & TRANSITIONS
   ========================================================================== */
@keyframes float {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-6px); }
  100% { transform: translateY(0px); }
}

/* Regra global de visibilidade — remove completamente do fluxo */
.hidden {
  display: none !important;
}

@keyframes pulse-light {
  0% { box-shadow: 0 0 0 0 rgba(0, 87, 184, 0.2); }
  70% { box-shadow: 0 0 0 8px rgba(0, 87, 184, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 87, 184, 0); }
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-float {
  animation: float 4s ease-in-out infinite;
}

.animate-pulse {
  animation: pulse-light 2s infinite;
}

.animate-fade-in {
  animation: fade-in 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ==========================================================================
   ONBOARDING OVERLAY (TELA 0)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  /* Sem transition de opacity — usamos display:none quando oculto */
}

.modal-overlay.hidden {
  display: none; /* Remove completamente do DOM visual e de eventos */
}

.onboarding-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-2xl);
  width: 92%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 55px -12px rgba(15, 23, 42, 0.12);
  animation: fade-in 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  overflow: hidden;
}

.onboarding-header {
  padding: 32px 40px 24px 40px;
  text-align: center;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* Logo B3 como elemento hero — protagonismo total */
.onboarding-b3-logo-hero {
  height: 64px;
  width: auto;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

/* Tati — linha compacta e profissional */
.onboarding-tati-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 48px;
  padding: 8px 20px 8px 8px;
  box-shadow: 0 1px 4px rgba(0,87,184,0.07);
}

.onboarding-tati-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--color-b3-blue);
  background: #EEF6FF;
}

.onboarding-tati-intro {
  display: flex;
  flex-direction: column;
  gap: 1px;
  text-align: left;
}

.onboarding-tati-name {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 700;
  color: var(--color-b3-dark);
}

.onboarding-tati-desc {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

/* Avatar da Tati como <img> nos capítulos e drawer */
.tati-avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}



.tati-avatar-container.large {
  width: 90px;
  height: 90px;
  margin: 0 auto 16px auto;
}

.tati-svg {
  width: 100%;
  height: 100%;
}

.onboarding-header h2 {
  font-family: var(--font-heading);
  color: var(--color-b3-dark);
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 6px;
}

.onboarding-header .tagline {
  font-size: 14px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 600;
}

.onboarding-body {
  padding: 30px 40px;
  overflow-y: auto;
  flex: 1;
}

.onboarding-body .instruction {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  text-align: center;
}

.onboarding-dialogue {
  background: var(--bg-tati-bubble);
  border: 1px solid #D0E4FF;
  border-radius: var(--radius-xl);
  padding: 18px 20px;
  margin-bottom: 20px;
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.5;
}

.onboarding-dialogue p + p {
  margin-top: 8px;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.profile-card {
  background: var(--bg-primary);
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  cursor: pointer;
  text-align: left;
  transition: var(--transition-smooth);
}

.profile-card:hover {
  background: #F8FAFC;
  border-color: #CBD5E1;
  transform: translateY(-2px);
}

.profile-card.active {
  background: #EEF6FF;
  border-color: var(--color-b3-blue);
  box-shadow: 0 4px 12px rgba(0, 87, 184, 0.08);
}

.profile-icon {
  background: var(--bg-secondary);
  color: var(--color-b3-blue);
  border-radius: var(--radius-md);
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.02);
  transition: var(--transition-smooth);
}

.profile-card.active .profile-icon {
  background: var(--color-b3-blue);
  color: var(--bg-secondary);
}

.profile-info {
  display: flex;
  flex-direction: column;
}

.profile-title {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 15px;
  color: var(--color-b3-dark);
  margin-bottom: 4px;
}

.profile-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.onboarding-footer {
  padding: 24px 40px 40px 40px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: center;
}

/* ==========================================================================
   APP STRUCTURE & HEADER
   ========================================================================== */
.app-container {
  /* Desktop: ocupa a viewport inteira em flex column */
  height: 100dvh;
  display: flex;
  flex-direction: column;
  animation: fade-in 0.4s ease-out forwards;
  overflow: hidden;
}

.app-container.hidden {
  display: none !important;
}

.app-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 16px 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 14px;
  width: fit-content; /* não expande para não cobrir os controles */
  flex-shrink: 0;
}

/* Logo oficial da B3 no header */
.b3-logo-img {
  height: 38px;
  width: auto;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.08));
  flex-shrink: 0;
}

/* Wrapper do texto h1 + subtitle (desktop) */
.logo-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.logo-area h1 {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  color: var(--color-b3-dark);
}

.logo-area .subtitle {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

/* Nome curto do app para mobile — oculto no desktop */
.logo-mobile-name {
  display: none;
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 700;
  color: var(--color-b3-dark);
  white-space: nowrap;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 20px;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-toggle-group {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 3px;
  display: flex;
}

.toggle-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.toggle-btn.active {
  background: var(--bg-secondary);
  color: var(--color-b3-blue);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.custom-select {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  outline: none;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.custom-select:hover {
  border-color: #CBD5E1;
}

/* ==========================================================================
   STEPPER DECK NAVIGATION
   ========================================================================== */
.deck-stepper {
  background: var(--bg-secondary);
  padding: 12px 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  gap: 10px;
}

.step-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0.5;
  transition: var(--transition-smooth);
  cursor: pointer;
}

.step-indicator.active {
  opacity: 1;
}

.step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-primary);
  border: 1.5px solid var(--border-color);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-heading);
}

.step-indicator.active .step-num {
  background: var(--color-b3-blue);
  border-color: var(--color-b3-blue);
  color: #FFFFFF;
}

.step-indicator.completed .step-num {
  background: #E2E8F0;
  border-color: #E2E8F0;
  color: var(--text-secondary);
}

.step-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.step-indicator.active .step-label {
  color: var(--color-b3-dark);
}

.step-line {
  flex: 1;
  height: 2px;
  background: var(--border-color);
}

.step-indicator.completed + .step-line,
.step-indicator.active + .step-line {
  background: #CBD5E1;
}

/* ==========================================================================
   MAIN WORKSPACE & DECK PAGES
   ========================================================================== */
.app-content {
  flex: 1;
  position: relative;
  overflow-y: auto;
  padding: 40px;
  display: flex;
  flex-direction: column;
}

.chapter-deck-container {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.deck-slide {
  display: none;
  flex-direction: column;
  flex: 1;
  animation: fade-in 0.4s ease-out forwards;
}

.deck-slide.active {
  display: flex;
}

.slide-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 32px;
  align-items: start;
  flex: 1;
}

.slide-main-content {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.chapter-question {
  font-family: var(--font-heading);
  font-size: 32px;
  font-weight: 700;
  color: var(--color-b3-dark);
  line-height: 1.2;
}

.chapter-intro {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.tati-lead-card {
  background: linear-gradient(180deg, #FFFFFF 0%, #F7FBFF 100%);
  border: 1px solid #D0E4FF;
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: var(--shadow-soft);
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 16px;
  align-items: start;
}

.tati-lead-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--color-b3-blue);
  background: #EEF6FF;
}

.tati-lead-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tati-lead-kicker {
  color: var(--color-b3-blue);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tati-lead-content p {
  color: var(--color-b3-dark);
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 650;
  line-height: 1.35;
}

.tati-choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.story-choice-btn {
  background: #FFFFFF;
  color: var(--color-b3-blue);
  border: 1px solid #BBD7FF;
  border-radius: 999px;
  padding: 8px 13px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.story-choice-btn:hover {
  background: #EEF6FF;
  color: var(--color-b3-dark);
  transform: translateY(-1px);
}

.focus-pulse {
  animation: pulse-light 1s ease-out 1;
}

.loading-value {
  font-size: 32px;
  color: var(--text-muted);
}

/* ==========================================================================
   EDITORIAL COMPONENT CARDS
   ========================================================================== */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: var(--shadow-soft);
  transition: var(--transition-smooth);
}

.card:hover {
  box-shadow: var(--shadow-hover);
}

.card-meta {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-b3-blue);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  display: block;
  margin-bottom: 12px;
}

.card-meta.human-meta {
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
}

.story-reveal {
  display: none !important;
}

.story-reveal.is-revealed {
  display: block !important;
  animation: fade-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.story-reveal.metric-highlight-container.is-revealed,
.story-reveal.map-card.is-revealed {
  display: flex !important;
}

.story-reveal.comparison-grid.is-revealed,
.story-reveal.impact-cards-container.is-revealed {
  display: grid !important;
}

/* Specific editorial card styles */
.short-answer-card {
  border-left: 4px solid var(--color-b3-blue);
}

.short-answer-card p {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-b3-dark);
  line-height: 1.4;
}

.metric-highlight-container {
  display: flex;
  flex-direction: column;
  padding: 20px 0;
}

.metric-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.metric-value-huge {
  font-family: var(--font-heading);
  font-size: 56px;
  font-weight: 800;
  color: var(--color-b3-blue);
  line-height: 1.1;
}

.explanation-card {
  line-height: 1.6;
  font-size: 15px;
  color: var(--text-primary);
}

.explanation-card p {
  margin-bottom: 16px;
}

.explanation-card p:last-child {
  margin-bottom: 0;
}

/* ==========================================================================
   TATI CARD SIDEBAR
   ========================================================================== */
.tati-side-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.tati-card {
  background: var(--bg-tati-bubble);
  border: 1px solid #D0E4FF;
  border-radius: var(--radius-xl);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tati-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tati-avatar-small {
  width: 44px;
  height: 44px;
}

.tati-avatar-svg {
  width: 100%;
  height: 100%;
}

.tati-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 16px;
  color: var(--color-b3-dark);
  display: block;
}

.tati-status {
  font-size: 11px;
  color: var(--color-b3-blue);
  font-weight: 600;
  display: block;
}

.tati-narrative-chapter {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.5;
}

.tati-points {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tati-point {
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.4;
}

.tati-point.positive {
  background: var(--color-positive-bg);
  border: 1px solid #D1FAE5;
  color: var(--text-primary);
}

.tati-point.attention {
  background: var(--color-warning-bg);
  border: 1px solid #FEF3C7;
  color: var(--text-primary);
}

.point-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.point-tag.positive {
  color: var(--color-positive);
}

.point-tag.attention {
  color: var(--color-warning);
}

.tati-action-box {
  border-top: 1px dashed rgba(0, 87, 184, 0.2);
  padding-top: 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-b3-dark);
  line-height: 1.4;
}

/* Suggested questions card in sidebar */
.suggested-questions-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.suggested-questions-card h4 {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.contextual-questions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.suggested-question-btn {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  line-height: 1.3;
  transition: var(--transition-smooth);
}

.suggested-question-btn:hover {
  background: #EEF6FF;
  border-color: var(--color-b3-accent);
  color: var(--color-b3-blue);
  transform: translateX(3px);
}

/* ==========================================================================
   INTERACTIVE B3 MOTORS SVG MAP (CAPÍTULO 2)
   ========================================================================== */
.map-card {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.map-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.map-title-row h3 {
  font-family: var(--font-heading);
  font-size: 16px;
  color: var(--color-b3-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

.interactive-tip {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.map-svg-container {
  width: 100%;
  max-width: 580px;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  aspect-ratio: 540 / 320;
}

.b3-motors-svg {
  width: 100%;
  height: auto;
}

.motor-node {
  cursor: pointer;
}

.motor-node rect {
  transition: var(--transition-smooth);
}

.motor-node:hover rect {
  stroke: var(--color-b3-blue);
  stroke-width: 2.5px;
  filter: drop-shadow(0px 8px 16px rgba(0, 87, 184, 0.15));
}

.motor-node.active rect {
  fill: #EEF6FF;
  stroke: var(--color-b3-blue);
  stroke-width: 3px;
  filter: drop-shadow(0px 8px 20px rgba(0, 87, 184, 0.15));
}

/* Connection lines animation */
.connect-line {
  stroke-dasharray: 6, 6;
  animation: dash 30s linear infinite;
}

@keyframes dash {
  to {
    stroke-dashoffset: -1000;
  }
}

/* Details Panel below SVG */
.motor-details-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: var(--shadow-soft);
  animation: fade-in 0.3s ease-out;
}

.motor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.motor-header h4 {
  font-family: var(--font-heading);
  font-size: 18px;
  color: var(--color-b3-dark);
}

.badge {
  background: #EEF6FF;
  color: var(--color-b3-blue);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
}

.motor-stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.motor-stat-item {
  display: flex;
  flex-direction: column;
}

.motor-stat-lbl {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 4px;
}

.motor-stat-val {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.motor-stat-val.positive {
  color: var(--color-positive);
}

.motor-stat-val.negative {
  color: var(--color-danger);
}

.motor-narrative-box {
  background: var(--bg-primary);
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 16px;
}

.motor-attention-box {
  background: #FFF7ED;
  border: 1px solid #FED7AA;
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.motor-story-label {
  display: block;
  color: var(--color-b3-blue);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

/* ==========================================================================
   COMPARATIVE 1T26 VS 4T25 (CAPÍTULO 3)
   ========================================================================== */
.comparison-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

.comparison-table-wrapper {
  overflow-x: auto;
  margin-top: 10px;
}

.comparison-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.comparison-table th,
.comparison-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  font-size: 13px;
}

.comparison-table th {
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
}

.comparison-table tr:last-child td {
  border-bottom: none;
}

.comparison-table td:first-child {
  font-weight: 600;
  color: var(--color-b3-dark);
}

.comparison-table td.cell-value {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 500;
}

.val-4T25 {
  color: var(--text-secondary);
}

.val-1T26 {
  color: var(--color-b3-blue);
  font-weight: 600 !important;
}

.comp-evolution {
  font-weight: 700;
}

.comp-evolution.positive {
  color: var(--color-positive);
}

.comp-evolution.negative {
  color: var(--color-danger);
}

/* CSLL warning block styling */
.warning-card {
  background: var(--color-danger-bg);
  border: 1px solid #FEE2E2;
}

.warning-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.warning-icon {
  color: var(--color-danger);
}

.warning-header h4 {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 700;
  color: #991B1B;
}

.warning-desc {
  font-size: 13px;
  color: #7F1D1D;
  line-height: 1.5;
}

/* ==========================================================================
   PROFILE CUSTOM CUTOUTS (CAPÍTULO 4)
   ========================================================================== */
.impact-cards-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.impact-metric-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border-color);
}

.impact-metric-badge {
  background: #EEF6FF;
  color: var(--color-b3-blue);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 16px;
  box-shadow: 0 2px 8px rgba(0, 87, 184, 0.05);
}

.impact-metric-lbl {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}

/* ==========================================================================
   QUIZ COMPONENT (CAPÍTULO 5)
   ========================================================================== */
.quiz-card {
  min-height: 380px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.quiz-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--text-secondary);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border-color);
  border-top-color: var(--color-b3-blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.quiz-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: fade-in 0.3s ease-out;
}

.quiz-progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.question-counter {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  white-space: nowrap;
}

.quiz-progress-bar-bg {
  flex: 1;
  height: 6px;
  background: var(--bg-primary);
  border-radius: 10px;
  overflow: hidden;
}

.quiz-progress-fill {
  height: 100%;
  background: var(--color-b3-accent);
  transition: width 0.3s ease;
}

.quiz-question {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  color: var(--color-b3-dark);
  line-height: 1.4;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quiz-option {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  transition: var(--transition-smooth);
}

.quiz-option:hover {
  background: #F8FAFC;
  border-color: #CBD5E1;
}

.quiz-option.selected {
  border-color: var(--color-b3-blue);
  background: #EEF6FF;
}

.quiz-option.correct {
  background: var(--color-positive-bg) !important;
  border-color: var(--color-positive) !important;
  color: #065F46 !important;
}

.quiz-option.incorrect {
  background: var(--color-danger-bg) !important;
  border-color: var(--color-danger) !important;
  color: #991B1B !important;
}

.quiz-feedback-box {
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  font-size: 13px;
  line-height: 1.5;
  margin-top: 10px;
  animation: fade-in 0.3s ease-out;
}

.quiz-feedback-box.correct {
  background: var(--color-positive-bg);
  border: 1px solid #A7F3D0;
  color: #065F46;
}

.quiz-feedback-box.incorrect {
  background: var(--color-danger-bg);
  border: 1px solid #FCA5A5;
  color: #991B1B;
}

.feedback-indicator {
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

/* Completed State display */
.quiz-completed-screen {
  text-align: center;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  animation: fade-in 0.5s ease-out;
}

.badge-icon {
  background: #FEF3C7;
  color: var(--color-warning);
  width: 70px;
  height: 70px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
}

.quiz-completed-screen h3 {
  font-family: var(--font-heading);
  font-size: 22px;
  color: var(--color-b3-dark);
}

.score-p {
  font-size: 14px;
  color: var(--text-secondary);
}

.score-display {
  font-family: var(--font-heading);
  font-size: 28px;
  font-weight: 800;
  color: var(--color-b3-blue);
  background: #EEF6FF;
  padding: 12px 24px;
  border-radius: var(--radius-lg);
  margin: 10px 0;
}

/* ==========================================================================
   CHAT SYSTEM (CAPÍTULO 6)
   ========================================================================== */
.chat-box-card {
  height: 480px;
  display: flex;
  flex-direction: column;
  padding: 0 !important;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-msg {
  max-width: 80%;
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  font-size: 13.5px;
  line-height: 1.5;
  animation: fade-in 0.3s ease-out;
}

.chat-msg.user {
  background: var(--color-b3-blue);
  color: #FFFFFF;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.chat-msg.tati {
  background: var(--bg-tati-bubble);
  border: 1px solid #D0E4FF;
  color: var(--text-primary);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.chat-msg-meta {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 4px;
  display: block;
}

.chat-msg.user .chat-msg-meta {
  color: rgba(255, 255, 255, 0.7);
}

.chat-msg-sources {
  font-size: 11px;
  color: var(--color-b3-blue);
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(0, 87, 184, 0.1);
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.source-badge {
  background: rgba(0, 87, 184, 0.05);
  border: 1px solid rgba(0, 87, 184, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}

.chat-suggested-pills-row {
  border-top: 1px solid var(--border-color);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #F8FAFC;
}

.chat-suggested-pills-row span {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  white-space: nowrap;
}

.chat-pills-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  width: 100%;
}

.chat-pills-list::-webkit-scrollbar {
  height: 3px;
}

.chat-pill {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition-smooth);
}

.chat-pill:hover {
  background: #EEF6FF;
  border-color: var(--color-b3-blue);
  color: var(--color-b3-blue);
}

.chat-input-row {
  border-top: 1px solid var(--border-color);
  padding: 16px 24px;
  display: flex;
  gap: 12px;
  background: var(--bg-secondary);
}

.chat-input-row input {
  flex: 1;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 13.5px;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  outline: none;
  transition: var(--transition-smooth);
}

.chat-input-row input:focus {
  border-color: var(--color-b3-blue);
  background: var(--bg-secondary);
}

.send-btn {
  background: var(--color-b3-blue);
  color: #FFFFFF;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.send-btn:hover {
  background: var(--color-b3-dark);
  transform: scale(1.03);
}

/* ==========================================================================
   BRIEFING GENERATOR COMPONENT (CHAPTER 6 SIDEBAR)
   ========================================================================== */
.briefing-generator-card {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.briefing-generator-card h3 {
  font-family: var(--font-heading);
  font-size: 15px;
  color: var(--color-b3-dark);
  display: flex;
  align-items: center;
  gap: 8px;
}

.briefing-info {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.briefing-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-group label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.briefing-output-box {
  border: 1px solid #D0E4FF;
  background: #F8FAFC;
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-top: 14px;
  animation: fade-in 0.3s ease-out;
}

.output-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
  margin-bottom: 10px;
}

.output-header span {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-b3-blue);
  text-transform: uppercase;
}

.briefing-markdown-content {
  font-size: 12.5px;
  color: var(--text-primary);
  line-height: 1.5;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
}

.briefing-markdown-content h2,
.briefing-markdown-content h3 {
  font-family: var(--font-heading);
  color: var(--color-b3-dark);
  margin-top: 12px;
  margin-bottom: 6px;
}

.briefing-markdown-content p {
  margin-bottom: 8px;
}

/* ==========================================================================
   GLOSSARY contextual links & SPAN styling
   ========================================================================== */
.glossary-term {
  color: var(--color-b3-blue);
  border-bottom: 1.5px dashed var(--color-b3-blue);
  font-weight: 600;
  cursor: pointer;
  padding: 0 2px;
  transition: var(--transition-smooth);
}

.glossary-term:hover {
  background: #EEF6FF;
  color: var(--color-b3-dark);
}

/* Segurança: glossary-term dentro da bolha azul do usuário deve ser legível */
.chat-msg.user .glossary-term {
  color: #FFFFFF;
  border-bottom-color: rgba(255,255,255,0.6);
  background: transparent;
}

/* ==========================================================================
   DECK CONTROLS FOOTER
   ========================================================================== */
.deck-navigation-bar {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 16px 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
}

.deck-indicator-progress {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
  max-width: 320px;
}

#deck-progress-text {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* Nome do capítulo no footer — visível no mobile */
.deck-chapter-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-b3-blue);
  display: none; /* oculto no desktop, visível no mobile via media query */
}

/* Botão de chat da Tati no footer mobile */
.mobile-chat-footer-btn {
  display: none; /* oculto no desktop */
  align-items: center;
  gap: 6px;
  background: var(--bg-primary);
  border: 1.5px solid var(--color-b3-blue);
  border-radius: 24px;
  padding: 6px 12px 6px 6px;
  cursor: pointer;
  color: var(--color-b3-blue);
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-heading);
  transition: var(--transition-smooth);
}

.mobile-chat-footer-btn:hover {
  background: #EEF6FF;
}

.mobile-chat-tati-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--color-b3-blue);
}

.progress-bar-container {
  width: 100%;
  height: 4px;
  background: var(--bg-primary);
  border-radius: 10px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--color-b3-blue);
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   BUTTONS & FORM COMPONENTS
   ========================================================================== */
.primary-btn {
  background: var(--color-b3-blue);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 20px;
  font-family: var(--font-heading);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition-smooth);
}

.primary-btn:hover {
  background: var(--color-b3-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 87, 184, 0.15);
}

.primary-btn:disabled {
  background: #CBD5E1;
  color: #94A3B8;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.primary-btn-outline {
  background: transparent;
  border: 1.5px solid var(--color-b3-blue);
  color: var(--color-b3-blue);
  border-radius: var(--radius-md);
  padding: 9px 18px;
  font-family: var(--font-heading);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition-smooth);
}

.primary-btn-outline:hover {
  background: #EEF6FF;
  border-color: var(--color-b3-dark);
  color: var(--color-b3-dark);
}

.secondary-btn {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  padding: 10px 20px;
  font-family: var(--font-heading);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition-smooth);
}

.secondary-btn:hover {
  background: #F1F5F9;
  border-color: #CBD5E1;
  color: var(--text-primary);
}

.secondary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.icon-btn {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.icon-btn:hover {
  background: #EEF6FF;
  border-color: var(--color-b3-blue);
  color: var(--color-b3-blue);
}

.full-width {
  width: 100% !important;
  justify-content: center;
}

/* ==========================================================================
   POPOVER STYLING (FLOATING CHAT DRAWER & GLOSSARY POPOVER)
   ========================================================================== */
/* Reset default popover styling */
[popover] {
  margin: unset;
  border: none;
  padding: 0;
  background: transparent;
  overflow: visible;
  /* Popover fechado: sem interação e sem dimensões que bloqueiem */
  pointer-events: none;
}

/* Quando popover está aberto: restaura interação */
:popover-open {
  pointer-events: auto;
}

/* Floating Drawer Chat: popover drawer slides in from the right */
.chat-drawer {
  position: fixed;
  inset-block: 0;
  inset-inline-end: 0;
  width: min(100%, 440px); /* nunca maior que a viewport */
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  box-shadow: -10px 0 40px rgba(15, 23, 42, 0.08);
  flex-direction: column;
  height: 100dvh;
  margin: 0;
  padding: 0;
  border: none;

  /* Slide-in animation: inicia fora da tela (sem ocupar espaço de toque) */
  translate: 100% 0;
  transition: translate 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              overlay 0.3s allow-discrete,
              display 0.3s allow-discrete;
}

/* Só exibe como flex quando a popover está aberta */
.chat-drawer:popover-open {
  display: flex;
  translate: 0 0;
}

@starting-style {
  .chat-drawer:popover-open {
    translate: 100% 0;
  }
}

/* Drawer backdrop styling */
.chat-drawer::backdrop {
  background: rgba(15, 23, 42, 0.15);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s ease,
              overlay 0.3s allow-discrete,
              display 0.3s allow-discrete;
}

.chat-drawer:popover-open::backdrop {
  opacity: 1;
}

@starting-style {
  .chat-drawer:popover-open::backdrop {
    opacity: 0;
  }
}

.drawer-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tati-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tati-avatar-mini {
  width: 36px;
  height: 36px;
}

.tati-info h4 {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 700;
  color: var(--color-b3-dark);
}

.status-indicator {
  font-size: 10px;
  color: var(--color-positive);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  background: var(--color-positive);
  border-radius: 50%;
  display: inline-block;
  animation: pulse-dot 1.5s infinite;
}

@keyframes pulse-dot {
  0% { transform: scale(0.9); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.5; }
  100% { transform: scale(0.9); opacity: 1; }
}

.close-drawer-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.close-drawer-btn:hover {
  color: var(--text-primary);
}

.drawer-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--bg-primary);
}

.drawer-suggestions {
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drawer-input-row {
  border-top: 1px solid var(--border-color);
  padding: 16px 20px;
  display: flex;
  gap: 10px;
  background: var(--bg-secondary);
}

.drawer-input-row input {
  flex: 1;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 13px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  outline: none;
  transition: var(--transition-smooth);
}

.drawer-input-row input:focus {
  border-color: var(--color-b3-blue);
  background: var(--bg-secondary);
}

/* Glossary Popover Card styling (Floating context card) */
.glossary-popover-card {
  position: absolute;
  width: 290px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.1);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  
  /* Transition animation */
  opacity: 0;
  scale: 0.95;
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1),
              scale 0.2s cubic-bezier(0.16, 1, 0.3, 1),
              overlay 0.2s allow-discrete,
              display 0.2s allow-discrete;
}

.glossary-popover-card:popover-open {
  opacity: 1;
  scale: 1;
}

@starting-style {
  .glossary-popover-card:popover-open {
    opacity: 0;
    scale: 0.95;
  }
}

.popover-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}

.popover-header h4 {
  font-family: var(--font-heading);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--color-b3-dark);
}

.close-popover-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
}

.popover-body {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.popover-footer {
  margin-top: 4px;
}

/* ==========================================================================
   LOCKED COMPLIANCE WARNING PAGE (RI GOVERNANCE OVERLAY)
   ========================================================================== */
.locked-container {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px;
  background: #F6F8FB;
}

.locked-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-2xl);
  padding: 48px;
  max-width: 520px;
  text-align: center;
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.lock-icon {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}

.locked-card h2 {
  font-family: var(--font-heading);
  font-size: 22px;
  color: var(--color-b3-dark);
  font-weight: 700;
}

.locked-card p {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.governance-badge {
  background: #EEF6FF;
  color: var(--color-b3-blue);
  font-size: 11px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.admin-only-tip {
  font-size: 11px !important;
  color: var(--text-muted) !important;
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
  width: 100%;
}

.space-break {
  height: 12px;
}
.markdown-list {
  padding-left: 20px;
  margin-bottom: 12px;
}
.markdown-list li {
  margin-bottom: 4px;
  font-size: 14px;
  color: var(--text-primary);
}

/* ==========================================================================
   RESPONSIVE DESIGN ADAPTATIONS
   ========================================================================== */
/* ==========================================================================
   RESPONSIVIDADE — TABLET (≤ 992px)
   ========================================================================== */
@media (max-width: 992px) {
  .slide-grid {
    grid-template-columns: 1fr;
  }

  .tati-side-panel {
    grid-row: 1;
  }

  .app-content {
    padding: 28px 24px;
  }

  .chapter-question {
    font-size: 26px;
  }
}

/* ==========================================================================
   RESPONSIVIDADE — MOBILE (≤ 640px)
   ========================================================================== */
@media (max-width: 640px) {

  /* --- LAYOUT DE APP NATIVO ---
     position:fixed + inset:0 trava o container na tela toda.
     A barra do Safari (inferior/superior) fica FORA do app. */
  .app-container {
    position: fixed;
    inset: 0;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  /* --- HEADER MOBILE --- */
  .app-header {
    padding: 12px 16px;
    /* Empurra o conteúdo abaixo do notch/Dynamic Island */
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 0;
    position: relative; /* Não precisa de sticky com o container fixed */
    z-index: 100;
    flex-shrink: 0; /* nunca encolhe */
  }

  /* CORREÇÃO: oculta o CONTAINER inteiro (.logo-text) em vez dos filhos
     individualmente — evita o div fantasma que cobria os botões */
  .logo-text {
    display: none;
  }

  /* Mostra o nome compacto do app no mobile */
  .logo-mobile-name {
    display: block;
  }

  .b3-logo-img {
    height: 28px;
  }

  /* Logo-area: tamanho exato, sem expandir */
  .logo-area {
    gap: 8px;
    flex: 0 0 auto;
    max-width: 50%; /* nunca ocupa mais que metade da largura */
  }

  /* Controles: posição relativa, z-index alto para garantir cliques */
  .header-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    position: relative;
    z-index: 101; /* sempre acima do header */
    flex: 0 0 auto;
  }

  /* Oculta labels */
  .control-group label {
    display: none;
  }

  .control-group {
    gap: 4px;
  }

  .btn-toggle-group {
    padding: 2px;
  }

  /* Touch targets mínimos de 44px para todos os botões interativos */
  .toggle-btn {
    padding: 5px 10px;
    font-size: 11px;
    min-height: 36px;
    min-width: 36px;
  }

  .custom-select {
    font-size: 12px;
    padding: 6px 8px;
    max-width: 120px;
  }

  /* Botão "Perguntar à Tati" no header — oculto no mobile (usa o FAB) */
  #global-chat-btn {
    display: none;
  }

  /* --- STEPPER MOBILE --- */
  .deck-stepper {
    padding: 4px 16px;
    gap: 4px;
    overflow-x: hidden;
    flex-shrink: 0; /* nunca encolhe no layout fixed */
  }

  /* Step-indicator: área tocável mínima de 44px */
  .step-indicator {
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    touch-action: manipulation;
  }

  .step-label {
    display: none;
  }

  .step-num {
    width: 24px;
    height: 24px;
    font-size: 11px;
  }

  .step-line {
    min-width: 8px;
    flex: 1;
    min-height: 2px; /* não expande a linha verticalmente */
    align-self: center;
  }

  /* --- CONTEÚDO PRINCIPAL: única área que scrolla --- */
  .app-content {
    flex: 1 1 auto;           /* ocupa todo espaço entre header e footer */
    overflow-y: auto;         /* scroll só aqui */
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch; /* scroll inercial iOS */
    overscroll-behavior-y: contain;    /* impede bounce afetar o body */
    padding: 16px;
    min-height: 0;            /* flex-shrink não quebra o layout */
  }

  /* Título do capítulo menor no mobile */
  .chapter-question {
    font-size: 20px;
    line-height: 1.3;
  }

  .chapter-intro {
    font-size: 14px;
  }

  .tati-lead-card {
    grid-template-columns: 44px 1fr;
    padding: 16px;
    gap: 12px;
  }

  .tati-lead-avatar {
    width: 44px;
    height: 44px;
  }

  .tati-lead-content p {
    font-size: 16px;
  }

  .story-choice-btn {
    width: 100%;
    text-align: left;
    border-radius: 12px;
  }

  /* Métricas em coluna única no mobile */
  .metrics-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Cards de métricas mais compactos */
  .metric-card {
    padding: 16px;
  }

  .metric-value {
    font-size: 22px;
  }

  .metric-label {
    font-size: 11px;
  }

  /* --- TABELA COMPARATIVA — scroll horizontal --- */
  .comparison-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -4px;
  }

  /* =================================================================
     TABELA COMPARATIVO → CARDS MOBILE
     Cada <tr> vira um card; thead oculto; data-label via CSS ::before
     ================================================================= */
  .comparison-table-wrapper {
    overflow: visible; /* sem scroll horizontal */
  }

  .comparison-table {
    min-width: unset;  /* remove o min-width que quebrava */
    width: 100%;
    font-size: 13px;
    display: block;    /* sai do modo table */
  }

  /* Oculta cabeçalho — os labels ficam nos cards */
  .comparison-table thead {
    display: none;
  }

  /* tbody vira uma lista de cards */
  .comparison-table tbody {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  /* Cada linha vira um card */
  .comparison-table tr {
    display: grid;
    grid-template-columns: 1fr auto 1fr; /* 4T25 | Evolução | 1T26 */
    grid-template-rows: auto auto;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 14px;
    background: var(--bg-primary);
    gap: 4px 8px;
    border-bottom: 1px solid var(--border-color) !important;
  }

  /* Nome da métrica: ocupa toda a largura no topo */
  .comparison-table td:first-child {
    grid-column: 1 / -1; /* span all 3 cols */
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 0 0 6px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 4px;
  }

  /* Célula 4T25 — esquerda */
  .comparison-table .val-4T25 {
    grid-column: 1;
    text-align: left;
    padding: 0;
    border: none;
    font-size: 13px;
  }
  .comparison-table .val-4T25::before {
    content: '4T25';
    display: block;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 2px;
  }

  /* Evolução (QoQ) — centro */
  .comparison-table .comp-evolution {
    grid-column: 2;
    text-align: center;
    padding: 0 6px;
    border: none;
    font-size: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
  }
  .comparison-table .comp-evolution::before {
    content: 'QoQ';
    display: block;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 2px;
  }

  /* 1T26 — direita */
  .comparison-table .val-1T26 {
    grid-column: 3;
    text-align: right;
    padding: 0;
    border: none;
    font-size: 15px;
    font-weight: 700 !important;
  }
  .comparison-table .val-1T26::before {
    content: '1T26';
    display: block;
    font-size: 10px;
    font-weight: 600;
    color: var(--color-b3-blue);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 2px;
  }

  /* Remove padding/border genérico das células no mobile */
  .comparison-table th,
  .comparison-table td {
    padding: 0;
    border-bottom: none;
  }

  /* --- TATI SIDE PANEL --- */
  .tati-side-panel {
    padding: 16px;
  }

  .tati-bubble-header {
    font-size: 12px;
  }

  /* --- CAPÍTULO 2: MAPA DOS MOTORES — empilha no mobile --- */
  .motors-layout {
    flex-direction: column;
    gap: 16px;
  }

  .motors-map-container {
    min-height: 220px;
  }

  /* --- PERFIS DO CAPÍTULO 4 --- */
  .impact-profiles-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* --- QUIZ CAPÍTULO 5 --- */
  .quiz-options-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* --- CAPÍTULO 6: CHAT FULL SCREEN --- */
  .chapter-6-chat-container {
    height: calc(100dvh - 180px);
  }

  .ch6-chat-messages {
    padding: 12px;
  }

  /* --- CHAT DRAWER (Tati flutuante) --- */
  .chat-drawer {
    width: 100vw;
    height: 85dvh;
    bottom: 0;
    right: 0;
    left: 0;
    top: auto;
    border-radius: 20px 20px 0 0;
    border: none;
    border-top: 1px solid var(--border-color);
  }

  /* --- FAB: oculto no mobile (substituído pelo botão no footer) --- */
  .floating-chat-fab {
    display: none !important;
  }

  /* --- FOOTER MOBILE: fixo no fundo, respeita safe area ---
     env(safe-area-inset-bottom) é a altura da home bar do iPhone
     e também da barra inferior do Safari.
     Resultado: botões sempre visíveis e acima de qualquer UI do browser */
  .deck-navigation-bar {
    padding: 8px 12px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    gap: 6px;
    justify-content: space-between;
    flex-shrink: 0; /* nunca encolhe */
    position: relative;
    z-index: 50;
  }

  /* Botões prev/next: só ícone no mobile */
  .deck-navigation-bar .secondary-btn,
  .deck-navigation-bar .primary-btn {
    padding: 10px 12px;
    font-size: 13px;
    gap: 0;
    min-width: 44px;
    justify-content: center;
  }

  /* Oculta textos, mantém ícones */
  .deck-navigation-bar .secondary-btn span,
  .deck-navigation-bar .primary-btn span {
    display: none;
  }

  /* Botão da Tati no footer — visível só no mobile */
  .mobile-chat-footer-btn {
    display: flex;
  }

  /* Indicador central mais compacto */
  .deck-indicator-progress {
    flex: 1;
    text-align: center;
    max-width: none;
  }

  /* Nome do capítulo aparece no mobile */
  .deck-chapter-name {
    display: block;
  }

  #deck-progress-text {
    font-size: 10px;
  }

  /* --- ONBOARDING MOBILE --- */
  .onboarding-card {
    width: 100vw;
    height: 100dvh;
    max-width: 100vw;
    max-height: 100dvh;
    border-radius: 0;
    margin: 0;
  }

  .onboarding-header {
    padding: 20px 20px 16px;
  }

  .onboarding-b3-logo {
    height: 32px;
    margin-bottom: 12px;
  }

  .onboarding-header h2 {
    font-size: 20px;
  }

  .onboarding-body {
    padding: 16px 20px;
  }

  .profile-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .profile-card {
    padding: 12px 14px;
  }

  .tati-avatar-container.large {
    width: 72px;
    height: 72px;
    margin-bottom: 12px;
  }

  /* --- LOCKED SCREEN --- */
  .locked-card {
    padding: 32px 20px;
    margin: 20px;
  }

  /* --- GLOSSÁRIO POPOVER --- */
  .glossary-popover-card {
    width: calc(100vw - 32px);
    max-width: calc(100vw - 32px);
    left: 16px !important;
    right: 16px !important;
  }
}

/* Botões de nav com ícone sempre visível */
@media (max-width: 640px) {
  .deck-navigation-bar .secondary-btn {
    min-width: 44px;
    justify-content: center;
  }

  .deck-navigation-bar .primary-btn {
    min-width: 44px;
    justify-content: center;
  }
}


/* Floating Chat FAB */
.floating-chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background-color: var(--color-b3-blue);
  color: #FFFFFF;
  border: none;
  box-shadow: 0 4px 16px rgba(0, 87, 184, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 999;
  transition: transform 0.2s ease, background-color 0.2s ease, opacity 0.2s ease;
}

.floating-chat-fab:hover {
  transform: scale(1.05);
  background-color: var(--color-b3-dark);
}

.floating-chat-fab:active {
  transform: scale(0.95);
}

.floating-chat-fab.hidden {
  display: none !important;
}

.floating-chat-fab i {
  width: 24px;
  height: 24px;
}
