/* ============================================================
   PRÓXIMAINVEST — Mobile PWA polish (clean, fast, modern)
   Carregar DEPOIS de app.css
   ============================================================ */

/* —— Base performance & touch —— */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  overscroll-behavior-y: contain;
}
button, a, [role="button"], input, select, textarea {
  touch-action: manipulation;
}
img, svg {
  max-width: 100%;
  height: auto;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* —— Safe areas (notch / home indicator) —— */
@supports (padding: env(safe-area-inset-top)) {
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
  .site-header {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
  #modalTerminal .modal-content,
  .cal-modal-sheet,
  .meu-plano-drawer,
  #meuPlanoDrawer {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
}

/* —— Header denser on mobile —— */
@media (max-width: 720px) {
  .site-header {
    min-height: 52px;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }
  .logo-text {
    font-size: 0.78rem !important;
    letter-spacing: 0.04em;
  }
  .logo-img {
    width: 28px !important;
    height: 28px !important;
  }
  .nav-mp-label {
    font-size: 0.72rem;
  }
  .header-end {
    gap: 4px !important;
  }
}

/* —— Hero: less vertical bulk —— */
@media (max-width: 720px) {
  .hero, .hero-platform {
    padding-top: 1.5rem !important;
    padding-bottom: 1.25rem !important;
  }
  .hero-title {
    font-size: clamp(1.35rem, 6.5vw, 1.85rem) !important;
    line-height: 1.2 !important;
    letter-spacing: -0.03em;
  }
  .hero-lead {
    font-size: 0.88rem !important;
    line-height: 1.5 !important;
    max-width: 36ch;
  }
  .ticker-track {
    font-size: 0.7rem;
  }
}

/* —— Tools grid: clean cards —— */
@media (max-width: 720px) {
  .tools-section {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
    padding-top: 1.5rem !important;
    padding-bottom: 1.5rem !important;
  }
  .tools-grid {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }
  @media (min-width: 420px) {
    .tools-grid {
      grid-template-columns: 1fr 1fr !important;
    }
  }
  .tool-card {
    padding: 9px 10px !important;
    border-radius: 8px !important;
    gap: 3px !important;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease !important;
  }
  .tool-card:active {
    transform: scale(0.985);
  }
  .tool-card h3 {
    font-size: 0.7rem !important;
    letter-spacing: 0.02em !important;
    margin-bottom: 1px !important;
  }
  .tool-card p {
    font-size: 0.62rem !important;
    line-height: 1.25 !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .tools-group-head {
    margin-bottom: 0.75rem !important;
  }
  .tools-group {
    margin-bottom: 1.5rem !important;
  }
}

/* —— Terminal modal: full-bleed mobile sheet —— */
@media (max-width: 720px) {
  #modalTerminal.modal.active {
    align-items: stretch !important;
    padding: 0 !important;
  }
  #modalTerminal .modal-content {
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: column !important;
  }
  #modalTerminal .modal-header {
    flex-shrink: 0;
    padding: 12px 14px !important;
    padding-top: max(12px, env(safe-area-inset-top)) !important;
  }
  #modalTerminal .modal-body {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 12px 14px 24px !important;
  }
  #modalTerminal .modal-header-title {
    font-size: 0.95rem !important;
  }
  /* Charts: fixed comfortable height, interactive */
  #modalTerminal .chart-plot,
  #modalTerminal .chart-wrap,
  #modalTerminal #mainChart,
  #modalTerminal canvas {
    max-width: 100% !important;
  }
  #modalTerminal .chart-plot {
    height: 220px !important;
    min-height: 200px !important;
    max-height: 260px !important;
    border-radius: 12px !important;
    overflow: hidden;
  }
  #modalTerminal input[type="number"],
  #modalTerminal input[type="text"],
  #modalTerminal input[type="search"],
  #modalTerminal input:not([type]),
  #modalTerminal select {
    font-size: 16px !important; /* evita zoom iOS */
    min-height: 44px;
    border-radius: 10px !important;
  }
  #modalTerminal input[type="radio"],
  #modalTerminal input[type="checkbox"] {
    width: 18px !important;
    height: 18px !important;
    min-width: 18px !important;
    min-height: 18px !important;
    max-width: 18px !important;
    max-height: 18px !important;
    margin: 0 !important;
    accent-color: var(--gold, #D4AF37);
  }
  #modalTerminal button.btn,
  #modalTerminal .btn-primary,
  #modalTerminal [type="submit"] {
    min-height: 46px;
    border-radius: 12px !important;
    font-weight: 600;
  }
}

/* —— Resources / footer less padding —— */
@media (max-width: 720px) {
  .resources-section,
  .home-slots {
    padding: 2rem 1rem !important;
  }
  #footer, footer {
    padding: 2rem 1rem !important;
    padding-bottom: max(2rem, env(safe-area-inset-bottom)) !important;
  }
  .footer-grid {
    gap: 1.25rem !important;
  }
}

/* —— PWA install banner —— */
.pwa-install {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 99990;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(12, 14, 18, 0.96);
  border: 1px solid rgba(212, 175, 55, 0.25);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: pwaIn 0.28s ease;
}
.pwa-install[hidden] { display: none !important; }
@keyframes pwaIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.pwa-install-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
}
.pwa-install-text {
  flex: 1;
  min-width: 0;
}
.pwa-install-text strong {
  display: block;
  font-size: 0.82rem;
  color: var(--text-main, #fff);
  margin-bottom: 2px;
}
.pwa-install-text span {
  font-size: 0.72rem;
  color: var(--text-dim, #888);
  line-height: 1.3;
}
.pwa-install-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}
.pwa-install-actions button {
  border: none;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}
.pwa-install-go {
  background: var(--gold, #D4AF37);
  color: #0a0a0a;
}
.pwa-install-later {
  background: transparent;
  color: var(--text-dim, #888);
}

/* —— Chart container polish —— */
.chart-plot, .chart-wrap {
  position: relative;
  touch-action: manipulation;
}
#modalTerminal .chart-plot,
#modalTerminal .chart-wrap {
  touch-action: pan-x pan-y pinch-zoom;
  -webkit-user-select: none;
  user-select: none;
}
.chart-skeleton {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,0.02);
  border-radius: 12px;
  color: var(--text-dim, #888);
  font-size: 0.75rem;
  pointer-events: none;
}

/* —— Standalone PWA (installed) —— */
@media (display-mode: standalone) {
  .site-header {
    padding-top: max(8px, env(safe-area-inset-top));
  }
  .pwa-install { display: none !important; }
}

/* —— Light theme mobile —— */
html[data-theme="light"] .pwa-install {
  background: rgba(255,255,255,0.97);
  border-color: rgba(166,124,0,0.25);
  box-shadow: 0 12px 32px rgba(15,23,42,0.12);
}
html[data-theme="light"] .pwa-install-text strong { color: #0f172a; }


/* Favorite star — always mini */
.tool-fav {
  width: 22px !important;
  height: 22px !important;
  top: 10px !important;
  right: 10px !important;
  font-size: 0.65rem !important;
  background: transparent !important;
  opacity: 1 !important;
}
.tool-fav i {
  font-size: 0.65rem !important;
  width: auto !important;
  height: auto !important;
  margin: 0 !important;
  border: none !important;
  background: none !important;
  box-shadow: none !important;
  color: inherit !important;
  transform: none !important;
}
@media (max-width: 720px) {
  .tool-fav {
    width: 20px !important;
    height: 20px !important;
    top: 8px !important;
    right: 8px !important;
    font-size: 0.6rem !important;
  }
  .tool-fav i { font-size: 0.6rem !important; }
}

/* ============================================================
   FX — ícone, FAB, bandeiras, painel profissional
   ============================================================ */

.nav-fx-btn {
  width: 36px;
  height: 36px;
}
.nav-fx-stack,
.fx-fab-flags {
  position: relative;
  display: inline-block;
  width: 22px;
  height: 16px;
}
.nav-fx-f,
.fx-fab-f,
.fx-mini-flag {
  position: absolute;
  font-size: 0.72rem;
  line-height: 1;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.35));
}
.nav-fx-f { left: 0; top: 0; }
.nav-fx-f2,
.fx-fab-f2,
.fx-mini-flag-2 {
  left: 8px;
  top: 4px;
  font-size: 0.68rem;
  z-index: 1;
}

.fx-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
}
.fx-header-icon {
  position: relative;
  width: 28px;
  height: 20px;
  display: inline-block;
}
.fx-mini-flag { left: 0; top: 0; font-size: 0.85rem; }
.fx-mini-flag-2 { left: 10px; top: 5px; font-size: 0.8rem; }

.fx-flag-badge {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  font-size: 1.05rem;
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  line-height: 1;
}

.fx-box-row {
  display: flex !important;
  align-items: center;
  gap: 8px !important;
}
.fx-box-row input {
  flex: 1 1 auto;
  min-width: 0 !important;
}
.fx-box-row select {
  flex: 0 1 42%;
  max-width: 48% !important;
  min-width: 0;
  font-size: 0.78rem !important;
  cursor: pointer;
}

.fx-converter-header h4 {
  text-transform: none !important;
  letter-spacing: 0.02em !important;
  font-size: 0.95rem !important;
}

/* FAB câmbio — acima do chat, clean */
.fx-fab {
  display: none;
  position: fixed;
  right: max(12px, env(safe-area-inset-right));
  bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  z-index: 9000;
  width: auto;
  min-width: 52px;
  height: 52px;
  padding: 0 12px 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(212, 175, 55, 0.35);
  background: rgba(12, 14, 18, 0.94);
  color: var(--gold, #D4AF37);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.fx-fab-flags {
  width: 24px;
  height: 18px;
}
.fx-fab-f { font-size: 0.85rem; left: 0; top: 0; }
.fx-fab-f2 { font-size: 0.8rem; left: 9px; top: 5px; }
.fx-fab-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-main, #fff);
}
@media (max-width: 720px) {
  .fx-fab { display: inline-flex; }
}
@media (min-width: 721px) {
  .fx-fab { display: none !important; }
}

/* Evita sobrepor chat FAB demais */
@media (max-width: 720px) {
  #chatbotFab, .chatbot-fab, #fxFabBtn.fx-fab {
    /* câmbio fica um pouco mais alto */
  }
  .fx-fab {
    bottom: calc(100px + env(safe-area-inset-bottom, 0px));
    right: max(14px, env(safe-area-inset-right));
  }
}

html[data-theme="light"] .fx-fab {
  background: rgba(255,255,255,0.96);
  border-color: rgba(166,124,0,0.3);
  box-shadow: 0 8px 24px rgba(15,23,42,0.12);
}
html[data-theme="light"] .fx-fab-label { color: #0f172a; }
html[data-theme="light"] .fx-flag-badge {
  background: rgba(15,23,42,0.04);
  border-color: rgba(15,23,42,0.08);
}

.fx-nav-btn .nav-fx-stack {
  width: 22px;
  height: 16px;
  margin-right: 2px;
}

/* ============================================================
   THEME PALETTE (site + modais) + BOTTOM NAV mobile
   ============================================================ */

.theme-palette-wrap {
  position: relative;
}
.theme-palette-btn .theme-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: block;
  border: 2px solid rgba(255,255,255,0.35);
  background: conic-gradient(var(--gold, #D4AF37) 0 50%, #0a0a0a 50% 100%);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.35);
}
.theme-swatch-classico { background: conic-gradient(var(--gold, #D4AF37) 0 50%, #0a0a0a 50% 100%) !important; }
.theme-swatch-grafite { background: conic-gradient(#9ca3af 0 50%, #1a1d24 50% 100%) !important; }
.theme-swatch-platina { background: conic-gradient(#c0c7d1 0 50%, #12141a 50% 100%) !important; }
.theme-swatch-carvao { background: conic-gradient(#eab308 0 50%, #0c0c0c 50% 100%) !important; }
.theme-swatch-escuro { background: #050507 !important; border-color: #333 !important; }
.theme-swatch-claro { background: conic-gradient(#a67c00 0 50%, #f5f6f8 50% 100%) !important; border-color: #ccc !important; }
.theme-swatch-oceano { background: conic-gradient(#38bdf8 0 50%, #0b1220 50% 100%) !important; }
.theme-swatch-esmeralda { background: conic-gradient(#34d399 0 50%, #0a1210 50% 100%) !important; }

.theme-palette-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 100060;
  min-width: 188px;
  padding: 6px;
  border-radius: 14px;
  background: var(--surface-2, #0c0e12);
  border: 1px solid var(--border-strong, rgba(255,255,255,0.12));
  box-shadow: 0 16px 40px rgba(0,0,0,0.45);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.theme-palette-menu[hidden] { display: none !important; }
.theme-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-main, #fff);
  font-size: 0.82rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}
.theme-opt:hover { background: rgba(255,255,255,0.05); }
.theme-opt.is-active {
  background: rgba(255,255,255,0.08);
  outline: 1px solid rgba(255,255,255,0.12);
}
.theme-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.2);
}
.theme-dot-classico { background: conic-gradient(var(--gold, #D4AF37) 0 50%, #111 50%); }
.theme-dot-grafite { background: conic-gradient(#9ca3af 0 50%, #1a1d24 50%); }
.theme-dot-platina { background: conic-gradient(#c0c7d1 0 50%, #12141a 50%); }
.theme-dot-carvao { background: conic-gradient(#eab308 0 50%, #0c0c0c 50%); }
.theme-dot-escuro { background: #050507; }
.theme-dot-claro { background: conic-gradient(#a67c00 0 50%, #f4f5f7 50%); }
.theme-dot-oceano { background: conic-gradient(#38bdf8 0 50%, #0b1220 50%); }
.theme-dot-esmeralda { background: conic-gradient(#34d399 0 50%, #0a1210 50%); }

/* —— Theme tokens (aplicam em body, modais, cards, bottom nav) —— */
html[data-theme="classico"] {
  --bg: #000000;
  --surface: #0a0a0a;
  --surface-2: #0c0e12;
  --surface-3: #111318;
  --gold: #D4AF37;
  --gold-dark: #b8941f;
  --gold-soft: #e0c04a;
  --gold-glow: rgba(212, 175, 55, 0.35);
  --border: rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.14);
  --text-main: #ffffff;
  --text-body: #c5cad3;
  --text-dim: #888888;
  --text-muted: #6b7280;
  color-scheme: dark;
}
html[data-theme="grafite"] {
  --bg: #12141a;
  --surface: #181b22;
  --surface-2: #1c2028;
  --surface-3: #242933;
  --gold: #c4c9d4;
  --gold-dark: #9aa3b2;
  --border: rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.14);
  --text-main: #f1f3f7;
  --text-body: #c5cad3;
  --text-dim: #8b93a3;
  --text-muted: #6b7280;
  color-scheme: dark;
}
html[data-theme="platina"] {
  --bg: #0e1014;
  --surface: #151820;
  --surface-2: #1a1e28;
  --surface-3: #222733;
  --gold: #a8b0bd;
  --gold-dark: #8b95a5;
  --border: rgba(255,255,255,0.09);
  --border-strong: rgba(255,255,255,0.15);
  --text-main: #eef1f6;
  --text-body: #c8ced8;
  --text-dim: #8e97a8;
  --text-muted: #6b7280;
  color-scheme: dark;
}
html[data-theme="carvao"] {
  --bg: #0a0a0a;
  --surface: #101010;
  --surface-2: #141414;
  --surface-3: #1a1a1a;
  --gold: #eab308;
  --gold-dark: #ca9a06;
  --border: rgba(255,255,255,0.07);
  --border-strong: rgba(255,255,255,0.12);
  --text-main: #fafafa;
  --text-body: #d4d4d4;
  --text-dim: #a3a3a3;
  --text-muted: #737373;
  color-scheme: dark;
}
html[data-theme="escuro"] {
  --bg: #030304;
  --surface: #0a0a0e;
  --surface-2: #0e0e12;
  --surface-3: #14141a;
  --gold: #D4AF37;
  --gold-dark: #b8941f;
  --gold-soft: #e0c04a;
  --gold-glow: rgba(212, 175, 55, 0.35);
  --border: rgba(255,255,255,0.1);
  --border-strong: rgba(255,255,255,0.16);
  --text-main: #f2f2f5;
  --text-body: #c8cad2;
  --text-dim: #9a9eaa;
  --text-muted: #6e7280;
  color-scheme: dark;
}
html[data-theme="claro"],
html[data-theme="light"] {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #ffffff;
  --surface-3: #eef0f4;
  --gold: #a67c00;
  --gold-dark: #8a6800;
  --border: rgba(15,23,42,0.08);
  --border-strong: rgba(15,23,42,0.14);
  --text-main: #0f172a;
  --text-body: #334155;
  --text-dim: #64748b;
  --text-muted: #94a3b8;
  color-scheme: light;
}
html[data-theme="oceano"] {
  --bg: #070d16;
  --surface: #0b1220;
  --surface-2: #0f172a;
  --surface-3: #152238;
  --gold: #38bdf8;
  --gold-dark: #0ea5e9;
  --border: rgba(56,189,248,0.12);
  --border-strong: rgba(56,189,248,0.22);
  --text-main: #e8f4ff;
  --text-body: #b6c9de;
  --text-dim: #7f96b0;
  --text-muted: #5c738c;
  color-scheme: dark;
}
html[data-theme="esmeralda"] {
  --bg: #060e0c;
  --surface: #0a1411;
  --surface-2: #0d1a16;
  --surface-3: #12241e;
  --gold: #34d399;
  --gold-dark: #10b981;
  --border: rgba(52,211,153,0.12);
  --border-strong: rgba(52,211,153,0.22);
  --text-main: #e8fff6;
  --text-body: #b5d4c6;
  --text-dim: #7fa394;
  --text-muted: #5c7a6e;
  color-scheme: dark;
}

/* Apply tokens broadly (modais inclusos) */
html[data-theme] body {
  background: var(--bg) !important;
  color: var(--text-body);
}
html[data-theme] .site-header,
html[data-theme] .fx-converter,
html[data-theme] .cal-modal-sheet,
html[data-theme] .theme-palette-menu,
html[data-theme] .bottom-nav,
html[data-theme] #modalTerminal .modal-content,
html[data-theme] .tool-card,
html[data-theme] .cal-card,
html[data-theme] .pi-toast {
  background-color: var(--surface-2);
  border-color: var(--border);
  color: var(--text-main);
}
html[data-theme] .tool-card h3,
html[data-theme] .cal-card-date,
html[data-theme] .logo-text,
html[data-theme] .bn-item.is-active {
  color: var(--gold) !important;
}
html[data-theme="claro"] .site-header,
html[data-theme="light"] .site-header {
  background: rgba(255,255,255,0.92) !important;
}
html[data-theme="claro"] body,
html[data-theme="light"] body {
  background: var(--bg) !important;
  color: var(--text-body);
}

/* —— Bottom nav Investing-style —— */
.bottom-nav {
  /* display controlled by mobile-chrome.css / inline critical */
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9500;
  height: calc(58px + env(safe-area-inset-bottom, 0px));
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
  background: rgba(10, 10, 12, 0.94);
  border-top: 1px solid var(--border, rgba(255,255,255,0.08));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  grid-template-columns: repeat(5, 1fr);
  align-items: flex-start;
  justify-items: center;
  box-sizing: border-box;
}
@media (max-width: 1024px) {
  .bottom-nav { display: grid !important; }
  body {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }
  /* sobe FABs acima da barra */
  .fx-fab {
    bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
  }
  #chatbotFab, .chatbot-fab, [id*="chatbotFab"] {
    bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
  }
}
.bn-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 100%;
  max-width: 72px;
  padding: 4px 2px;
  border: none;
  background: transparent;
  color: var(--text-dim, #888);
  text-decoration: none;
  font-size: 0.62rem;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.bn-item i {
  font-size: 1.05rem;
  line-height: 1;
}
.bn-item.is-active {
  color: var(--gold, #D4AF37);
}
.bn-item-center .bn-center-icon {
  position: relative;
  width: 28px;
  height: 20px;
  display: block;
}
.bn-f {
  position: absolute;
  font-size: 0.75rem;
  left: 0;
  top: 0;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.3));
}
.bn-f2 {
  left: 10px;
  top: 4px;
  font-size: 0.7rem;
  z-index: 1;
}

html[data-theme="claro"] .bottom-nav,
html[data-theme="light"] .bottom-nav {
  background: rgba(255,255,255,0.94);
  border-top-color: rgba(15,23,42,0.08);
}
html[data-theme="oceano"] .bottom-nav {
  background: rgba(11, 18, 32, 0.95);
}
html[data-theme="esmeralda"] .bottom-nav {
  background: rgba(10, 20, 17, 0.95);
}

@media (min-width: 1025px) {
  /* nav: mobile-chrome.css */
}

/* ============================================================
   FIX: Recursos / tabs / cards seguem o tema
   ============================================================ */
html[data-theme] .resources-section,
html[data-theme] .home-slots {
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, color-mix(in srgb, var(--gold) 8%, transparent), transparent 55%),
    linear-gradient(180deg, var(--bg) 0%, var(--surface) 100%) !important;
  border-top-color: var(--border) !important;
}
html[data-theme] .resources-section h2,
html[data-theme] .home-slots h2,
html[data-theme] #recursosHeading,
html[data-theme] #novidadesHeading,
html[data-theme] #parceirosHeading {
  color: var(--text-main) !important;
}
html[data-theme] .resources-subtitle,
html[data-theme] .section-lead,
html[data-theme] .home-slots p {
  color: var(--text-dim) !important;
}
html[data-theme] .resource-card,
html[data-theme] .resources-section .res-card,
html[data-theme] .res-card {
  background: var(--surface-2) !important;
  border-color: var(--border) !important;
  color: var(--text-body) !important;
}
html[data-theme] .resource-card h3,
html[data-theme] .resources-section .res-card h3,
html[data-theme] .res-card h3 {
  color: var(--text-main) !important;
}
html[data-theme] .resource-card > p,
html[data-theme] .res-card p {
  color: var(--text-dim) !important;
}
html[data-theme] .resource-card.resource-featured {
  border-color: color-mix(in srgb, var(--gold) 40%, transparent) !important;
  background:
    linear-gradient(165deg, color-mix(in srgb, var(--gold) 12%, transparent) 0%, transparent 42%),
    var(--surface-2) !important;
}
html[data-theme] .resource-card:hover,
html[data-theme] .res-card:hover {
  border-color: color-mix(in srgb, var(--gold) 35%, transparent) !important;
}
html[data-theme] .resource-card .resource-icon {
  background: color-mix(in srgb, var(--gold) 12%, transparent) !important;
  color: var(--gold) !important;
  border: 1px solid color-mix(in srgb, var(--gold) 20%, transparent);
}
html[data-theme] .resource-card .resource-level,
html[data-theme] .resource-card .resource-category {
  color: var(--text-dim) !important;
}
html[data-theme] .tab-btn,
html[data-theme] .resources-section .tab-btn,
html[data-theme] .resources-section .tabs-container button {
  background: var(--surface-3) !important;
  color: var(--text-dim) !important;
  border-color: var(--border) !important;
}
html[data-theme] .tab-btn.active,
html[data-theme] .tab-btn:hover,
html[data-theme] .resources-section .tab-btn.active,
html[data-theme] .resources-section .tabs-container button.active {
  background: color-mix(in srgb, var(--gold) 16%, transparent) !important;
  color: var(--gold) !important;
  border-color: color-mix(in srgb, var(--gold) 40%, transparent) !important;
}
html[data-theme] .search-box,
html[data-theme] #searchInput {
  background: var(--surface-3) !important;
  color: var(--text-main) !important;
  border-color: var(--border) !important;
}
html[data-theme] .search-box input::placeholder {
  color: var(--text-muted) !important;
}

/* Hero / journey / footer also track theme */
html[data-theme] .hero,
html[data-theme] .hero-platform {
  background: transparent !important;
}
html[data-theme] .hero-title,
html[data-theme] .hero-line {
  color: var(--text-main) !important;
}
html[data-theme] .hero-lead {
  color: var(--text-dim) !important;
}
html[data-theme] #footer,
html[data-theme] footer {
  background: var(--surface) !important;
  border-top: 1px solid var(--border) !important;
  color: var(--text-body) !important;
}
html[data-theme] .journey-card,
html[data-theme] .lab-card {
  background: var(--surface-2) !important;
  border-color: var(--border) !important;
}

/* ============================================================
   FX icons modernos (SVG)
   ============================================================ */
.fx-icon-svg {
  display: block;
  color: var(--gold, #D4AF37);
  flex-shrink: 0;
}
.nav-fx-btn .fx-icon-svg {
  width: 17px;
  height: 17px;
}
.fx-nav-btn {
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
}
.fx-nav-btn .fx-icon-svg {
  width: 16px;
  height: 16px;
}
.fx-fab {
  gap: 8px !important;
}
.fx-fab .fx-icon-svg {
  width: 20px;
  height: 20px;
  color: var(--gold);
}

/* Bottom nav center bubble */
.bn-center-bubble {
  width: 36px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: color-mix(in srgb, var(--gold) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--gold) 30%, transparent);
}
.bn-center-bubble .fx-icon-svg {
  width: 16px;
  height: 16px;
  color: var(--gold);
}
.bn-item-center.is-active .bn-center-bubble {
  background: color-mix(in srgb, var(--gold) 22%, transparent);
}

/* Theme swatch button polish */
.theme-palette-btn {
  position: relative;
}
.theme-palette-btn::after {
  content: '';
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 1.5px var(--surface-2, #0c0e12);
  opacity: 0.9;
}

/* Ensure modal terminal uses theme surfaces */
html[data-theme] #modalTerminal .modal-content,
html[data-theme] #modalTerminal.modal .modal-content {
  background: var(--surface-2) !important;
  color: var(--text-main) !important;
  border-color: var(--border) !important;
}
html[data-theme] #modalTerminal .modal-header {
  background: var(--surface-3) !important;
  border-bottom-color: var(--border) !important;
}
html[data-theme] #modalTerminal input[type="number"],
html[data-theme] #modalTerminal input[type="text"],
html[data-theme] #modalTerminal input[type="search"],
html[data-theme] #modalTerminal input:not([type]),
html[data-theme] #modalTerminal select {
  background: var(--surface-3) !important;
  color: var(--text-main) !important;
  border-color: var(--border) !important;
}
html[data-theme] #modalTerminal input[type="radio"]:not(:checked),
html[data-theme] #modalTerminal input[type="checkbox"]:not(:checked) {
  background: transparent !important;
  width: 18px !important;
  height: 18px !important;
  min-height: 18px !important;
}
html[data-theme] #modalTerminal input[type="radio"]:checked,
html[data-theme] #modalTerminal input[type="checkbox"]:checked {
  background: var(--gold, #D4AF37) !important;
  border-color: var(--gold, #D4AF37) !important;
  width: 18px !important;
  height: 18px !important;
  min-height: 18px !important;
}

/* ============================================================
   REFATORAÇÃO v1.4.6 — menu mobile, modal scroll, paleta, FX único
   ============================================================ */

/* Forçar bottom nav no mobile (evitar CSS antigo sobrescrever) */
@media (max-width: 1024px) {
  .bottom-nav#bottomNav {
    display: grid !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 100100 !important;
    height: calc(56px + env(safe-area-inset-bottom, 0px)) !important;
    padding-bottom: env(safe-area-inset-bottom, 0px) !important;
    background: color-mix(in srgb, var(--surface-2, #0c0e12) 92%, transparent) !important;
    border-top: 1px solid var(--border, rgba(255,255,255,0.1)) !important;
    backdrop-filter: blur(18px) !important;
    -webkit-backdrop-filter: blur(18px) !important;
  }
  body {
    padding-bottom: calc(62px + env(safe-area-inset-bottom, 0px)) !important;
  }
}

@media (min-width: 1025px) {
  /* nav: mobile-chrome.css */
}

/* FAB câmbio clássico — só mobile, acima da barra */
.fx-fab {
  width: 48px !important;
  height: 48px !important;
  min-width: 48px !important;
  padding: 0 !important;
  border-radius: 50% !important;
}
.fx-fab .fx-fab-label { display: none !important; }
.fx-fab i {
  font-size: 1.05rem !important;
  color: var(--gold, #D4AF37) !important;
}
@media (max-width: 860px) {
  .fx-fab#fxFabBtn {
    display: flex !important;
    bottom: calc(68px + env(safe-area-inset-bottom, 0px)) !important;
    right: max(14px, env(safe-area-inset-right)) !important;
  }
}
@media (min-width: 861px) {
  .fx-fab#fxFabBtn { display: none !important; }
}

/* Ícone paleta de pintor */
.palette-icon {
  display: block;
  color: var(--gold, #D4AF37);
  width: 18px;
  height: 18px;
}
.theme-palette-btn {
  color: var(--gold, #D4AF37);
}
.theme-palette-btn::after { display: none !important; }

/* Center bubble estrela */
.bn-center-bubble {
  width: 36px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: color-mix(in srgb, var(--gold) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--gold) 28%, transparent);
  color: var(--gold);
  font-size: 0.85rem;
}
.bn-item-center.is-active .bn-center-bubble {
  background: color-mix(in srgb, var(--gold) 24%, transparent);
}

/* —— Modal calculadoras: UMA rolagem só no mobile —— */
@media (max-width: 900px) {
  html.modal-open,
  body.modal-open,
  html:has(#modalTerminal.modal.active),
  body:has(#modalTerminal.modal.active) {
    overflow: hidden !important;
    height: 100% !important;
    overscroll-behavior: none;
    /* NÃO use touch-action:none no body — trava o scroll do formulário */
  }

  #modalTerminal.modal.active {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-height: 100dvh !important;
    padding: 0 !important;
    margin: 0 !important;
    display: flex !important;
    align-items: stretch !important;
    justify-content: stretch !important;
    overflow: hidden !important;
    z-index: 100200 !important;
    background: rgba(0,0,0,0.55) !important;
  }

  #modalTerminal.modal.active .modal-content {
    position: relative !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    border-radius: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    overscroll-behavior: contain;
  }

  #modalTerminal.modal.active .modal-header {
    flex: 0 0 auto !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 5 !important;
  }

  /* Único scroll: formulário + resultado em sequência */
  #modalTerminal.modal.active .modal-body {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: none !important;
    gap: 14px !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    touch-action: pan-y !important;
    padding: 12px 14px max(28px, env(safe-area-inset-bottom)) !important;
  }

  #modalTerminal.modal.active .control-panel,
  #modalTerminal.modal.active .results-container,
  #modalTerminal.modal.active .modal-body > .control-panel,
  #modalTerminal.modal.active .modal-body > .results-container {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-height: 0 !important;
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;
    flex: 0 0 auto !important;
    position: relative !important;
  }

  #modalTerminal.modal.active .chart-plot {
    height: min(220px, 36vh) !important;
    max-height: 240px !important;
    flex-shrink: 0;
  }

  /* inputs de texto/número confortáveis, sem zoom iOS — NÃO radio/checkbox */
  #modalTerminal.modal.active input[type="number"],
  #modalTerminal.modal.active input[type="text"],
  #modalTerminal.modal.active input[type="search"],
  #modalTerminal.modal.active input:not([type]),
  #modalTerminal.modal.active select {
    font-size: 16px !important;
    min-height: 44px;
  }
  #modalTerminal.modal.active input[type="radio"],
  #modalTerminal.modal.active input[type="checkbox"] {
    width: 18px !important;
    height: 18px !important;
    min-width: 18px !important;
    min-height: 18px !important;
    max-width: 18px !important;
    max-height: 18px !important;
    margin: 0 !important;
    padding: 0 !important;
    flex-shrink: 0 !important;
    accent-color: var(--gold, #D4AF37);
  }
}

/* Gesture hint */
.gesture-hint {
  position: fixed;
  left: 50%;
  bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 2147483001;
  max-width: min(340px, calc(100vw - 24px));
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(12,14,18,0.94);
  border: 1px solid rgba(212,175,55,0.25);
  color: #e8eaed;
  font-size: 0.72rem;
  text-align: center;
  line-height: 1.35;
  pointer-events: none;
  animation: ghIn .25s ease;
}
.gesture-hint.out { opacity: 0; transition: opacity .35s; }
@keyframes ghIn {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
html[data-theme="claro"] .gesture-hint,
html[data-theme="light"] .gesture-hint {
  background: rgba(255,255,255,0.96);
  color: #0f172a;
}

/* ============================================================
   PWA APP MODE — sensação de aplicativo nativo
   ============================================================ */

/* Base mobile sempre mais “app” */
@media (max-width: 900px) {
  html, body {
    overscroll-behavior-y: none;
    -webkit-tap-highlight-color: transparent;
  }
  body {
    min-height: 100dvh;
  }
  /* Header compacto tipo app bar */
  .site-header {
    min-height: 52px !important;
    padding-top: max(6px, env(safe-area-inset-top)) !important;
    backdrop-filter: blur(20px) saturate(1.2) !important;
    -webkit-backdrop-filter: blur(20px) saturate(1.2) !important;
  }
  /* Esconde ruído de marketing longo no mobile */
  .hero-platform {
    padding-top: 1.1rem !important;
    padding-bottom: 1rem !important;
  }
  .hero-cta .btn,
  .hero-cta a.btn {
    min-height: 46px;
    border-radius: 12px !important;
  }
  /* Cards mais “app list” */
  .tool-card {
    border-radius: 16px !important;
  }
  /* Ticker mais fino */
  .ticker-wrap, .market-ticker, [class*="ticker"] {
    font-size: 0.68rem;
  }
}

/* Quando instalado (standalone) */
html.pwa-app body,
body.pwa-app {
  /* sem “cara de site” */
  user-select: none;
  -webkit-user-select: none;
}
html.pwa-app input,
html.pwa-app textarea,
html.pwa-app [contenteditable] {
  user-select: text;
  -webkit-user-select: text;
}

@media (display-mode: standalone), (display-mode: fullscreen) {
  /* Status bar / safe area */
  body {
    padding-top: 0;
    min-height: 100dvh;
    background: var(--bg, #000) !important;
  }
  .site-header {
    padding-top: max(10px, env(safe-area-inset-top)) !important;
    border-bottom: 1px solid var(--border, rgba(255,255,255,0.06)) !important;
  }
  /* Bottom nav sempre presente e mais “tab bar” nativa */
  #bottomNav.bottom-nav {
    display: grid !important;
    height: calc(54px + env(safe-area-inset-bottom, 0px)) !important;
    background: color-mix(in srgb, var(--surface-2, #0c0e12) 94%, transparent) !important;
    box-shadow: 0 -8px 32px rgba(0,0,0,0.25);
  }
  #bottomNav .bn-item {
    font-size: 0.6rem !important;
    font-weight: 600 !important;
    letter-spacing: 0.01em;
  }
  #bottomNav .bn-item i {
    font-size: 1.15rem !important;
  }
  /* FAB câmbio alinhado à tab bar */
  .fx-fab#fxFabBtn {
    bottom: calc(64px + env(safe-area-inset-bottom, 0px)) !important;
    box-shadow: 0 6px 20px rgba(0,0,0,0.35) !important;
  }
  /* Cookie banner sobe acima da tab bar */
  #cookie-banner {
    bottom: calc(56px + env(safe-area-inset-bottom, 0px)) !important;
  }
  /* Menos “site”: esconde parceiros vazios se existirem */
  #parceiros.home-partners:empty {
    display: none !important;
  }
  /* Modal = tela cheia de app */
  #modalTerminal.modal.active .modal-content {
    border-radius: 0 !important;
  }
  /* Transições curtas tipo app */
  .tool-card,
  .bn-item,
  .nav-icon-btn {
    transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease !important;
  }
  .bn-item:active,
  .tool-card:active {
    transform: scale(0.97);
  }
}

/* Desktop PWA window (se instalar no desktop) */
@media (display-mode: standalone) and (min-width: 1025px) {
  body { padding-bottom: 0 !important; }
}

/* ============================================================
   HOME MOBILE ENXUTA — foco app
   ============================================================ */
@media (max-width: 900px) {
  /* Hero curto */
  .hero.hero-platform,
  #hero {
    padding: 0.85rem 1rem 0.75rem !important;
  }
  .hero-brand {
    font-size: 0.65rem !important;
    margin-bottom: 0.35rem !important;
  }
  .hero-title {
    font-size: clamp(1.25rem, 6vw, 1.65rem) !important;
    margin-bottom: 0.4rem !important;
  }
  .hero-lead {
    font-size: 0.82rem !important;
    line-height: 1.45 !important;
    margin-bottom: 0.75rem !important;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .hero-cta {
    gap: 8px !important;
  }

  /* Jornada em 2x2 compacta */
  .journey-section {
    padding: 1rem 1rem 0.5rem !important;
  }
  .journey-intro p {
    font-size: 0.78rem !important;
    margin-bottom: 0.6rem !important;
  }
  .journey-grid-4 {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }
  .journey-card {
    padding: 12px 10px !important;
    border-radius: 14px !important;
    min-height: 0 !important;
  }
  .journey-card .jc-desc {
    font-size: 0.65rem !important;
    line-height: 1.25 !important;
  }
  .journey-card .jc-title {
    font-size: 0.82rem !important;
  }

  /* Ferramentas: prioridade visual */
  .tools-section {
    padding-top: 1rem !important;
  }
  .tools-group {
    margin-bottom: 1.15rem !important;
  }
  .tools-group-head p {
    font-size: 0.75rem !important;
  }

  /* Agenda mais colada */
  .cal-section {
    padding-top: 1rem !important;
    padding-bottom: 0.75rem !important;
  }

  /* Novidades / parceiros: menos peso se genéricos */
  #novidades,
  #parceiros {
    padding: 1.25rem 1rem !important;
  }
  #novidades .section-tag,
  #parceiros .section-tag {
    font-size: 0.65rem;
  }
  #parceiros p {
    font-size: 0.78rem !important;
  }

  /* Footer mais compacto */
  #footer, footer {
    padding-top: 1.5rem !important;
    font-size: 0.78rem;
  }
  .footer-grid {
    gap: 1rem !important;
  }
}

/* PWA standalone: home ainda mais direta */
@media (display-mode: standalone) and (max-width: 900px) {
  .hero-lead {
    -webkit-line-clamp: 2;
  }
  /* ticker menos dominante */
  .ticker-live-badge {
    font-size: 0.65rem;
  }
}

/* ============================================================
   Agenda / cal-modal — centro da tela (mobile + desktop)
   ============================================================ */
.cal-modal,
.cal-modal.is-open {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100% !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  z-index: 2147483000 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 16px !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  pointer-events: auto !important;
  transform: none !important;
  filter: none !important;
  isolation: isolate;
}
.cal-modal[hidden],
.cal-modal:not(.is-open) {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}
.cal-modal-backdrop {
  position: absolute !important;
  inset: 0 !important;
  background: rgba(0, 0, 0, 0.65) !important;
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}
.cal-modal-sheet {
  position: relative !important;
  z-index: 1 !important;
  width: min(420px, calc(100vw - 32px)) !important;
  max-width: 420px !important;
  margin: 0 auto !important;
  padding: 1.3rem 1.2rem max(1.1rem, env(safe-area-inset-bottom, 0px)) !important;
  border-radius: 16px !important;
  max-height: min(78vh, 560px) !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55) !important;
  transform: none !important;
}
html.cal-modal-open,
body.cal-modal-open {
  overflow: hidden !important;
  overscroll-behavior: none;
}
html.cal-modal-open .cal-modal-backdrop {
  touch-action: none;
}
html.cal-modal-open .cal-modal-sheet {
  touch-action: pan-y;
}

/* Cards da agenda — grid legível no mobile */
@media (max-width: 900px) {
  .cal-section {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }
  .cal-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }
  .cal-card {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 4px !important;
    min-height: 72px !important;
    padding: 10px 11px !important;
    border-radius: 12px !important;
    border: 1px solid var(--border, rgba(255,255,255,0.1)) !important;
    background: var(--surface-2, #0c0e12) !important;
    width: 100% !important;
    cursor: pointer !important;
    -webkit-tap-highlight-color: rgba(212, 175, 55, 0.18);
    touch-action: manipulation;
  }
  .cal-card:active {
    transform: scale(0.98);
  }
  .cal-card-date {
    display: block !important;
    font-size: 0.62rem !important;
  }
  .cal-card-title {
    display: block !important;
    font-size: 0.78rem !important;
    font-weight: 600 !important;
  }
  .cal-card-tag {
    display: inline-block !important;
    margin-top: auto !important;
  }
}

/* Estrelas de favoritos removidas — esconde resíduo se existir */
.tool-fav,
#btnFavorites,
#favBadge {
  display: none !important;
  pointer-events: none !important;
}


/* ============================================================
   TOUCH OPTIMIZATION — resposta rápida, sem delay 300ms
   ============================================================ */
@media (hover: none), (pointer: coarse) {
  button,
  a,
  [role="button"],
  .tool-card,
  .cal-card,
  .bn-item,
  .nav-icon-btn,
  .nav-mp,
  input[type="button"],
  input[type="submit"] {
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(212, 175, 55, 0.12);
  }

  /* Alvos de toque confortáveis */
  .bn-item,
  .cal-card,
  .tool-card {
    min-height: 44px;
  }

  /* Ranges e formulários: pan-y para não competir com gestos */
  #modalTerminal input,
  #modalTerminal select,
  #modalTerminal textarea,
  #modalTerminal input[type="range"] {
    touch-action: manipulation;
  }

  #modalTerminal .modal-body {
    touch-action: pan-y !important;
  }

  /* Bottom nav: toque imediato */
  #bottomNav .bn-item {
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
  }
}



/* ============================================================
   FORM CONTROLS MOBILE — bolinha simples (modelo foto/original)
   ============================================================ */
@media (max-width: 900px) {
  #modalTerminal .radio-group,
  #modalTerminal .checkbox-group,
  #modalTerminal .input-group > div[style*="display:flex"] {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    gap: 8px 12px !important;
    margin-top: 8px !important;
  }

  #modalTerminal .radio-group label,
  #modalTerminal .checkbox-group label,
  #modalTerminal .input-group label,
  #modalTerminal .input-group > div[style*="display:flex"] label {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 6px !important;
    margin: 0 !important;
    padding: 2px 0 !important;
    min-height: 0 !important;
    width: auto !important;
    border: none !important;
    background: transparent !important;
    border-radius: 0 !important;
    font-size: 0.8rem !important;
    color: #c5cad3 !important;
    box-shadow: none !important;
  }

  #modalTerminal .radio-group label:has(input:checked),
  #modalTerminal .checkbox-group label:has(input:checked),
  #modalTerminal .input-group label:has(input:checked) {
    border: none !important;
    background: transparent !important;
    color: #f0f2f5 !important;
  }

  #modalTerminal input[type="radio"],
  #modalTerminal input[type="checkbox"],
  #modalTerminal .control-panel input[type="radio"],
  #modalTerminal .control-panel input[type="checkbox"] {
    -webkit-appearance: none !important;
    appearance: none !important;
    width: 16px !important;
    height: 16px !important;
    min-width: 16px !important;
    min-height: 16px !important;
    max-width: 16px !important;
    max-height: 16px !important;
    margin: 0 !important;
    padding: 0 !important;
    flex: 0 0 16px !important;
    border: 2px solid rgba(255,255,255,0.4) !important;
    background: transparent !important;
    border-radius: 50% !important;
    box-shadow: none !important;
  }

  #modalTerminal input[type="radio"]:checked,
  #modalTerminal input[type="checkbox"]:checked {
    border-color: var(--gold, #D4AF37) !important;
    background: var(--gold, #D4AF37) !important;
    background-color: var(--gold, #D4AF37) !important;
    position: relative !important;
  }

  #modalTerminal input[type="radio"]:checked::after {
    content: "" !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    width: 6px !important;
    height: 6px !important;
    margin: -3px 0 0 -3px !important;
    border-radius: 50% !important;
    background: #0a0a0a !important;
  }

  #modalTerminal input[type="checkbox"]:checked::after {
    content: "" !important;
    position: absolute !important;
    top: 1px !important;
    left: 4px !important;
    width: 4px !important;
    height: 8px !important;
    border: solid #0a0a0a !important;
    border-width: 0 2px 2px 0 !important;
    transform: rotate(45deg) !important;
    background: transparent !important;
  }

  #modalTerminal .dual-input {
    min-height: 44px !important;
  }
  #modalTerminal .dual-input input[type="number"],
  #modalTerminal .dual-input input[type="text"] {
    min-height: 42px !important;
    width: auto !important;
    flex: 1 1 auto !important;
  }
  #modalTerminal input[type="range"] {
    width: 100% !important;
    height: 28px !important;
    min-height: 28px !important;
    margin: 6px 0 2px !important;
  }
}


/* ============================================================
   FX CENTER OVERRIDE — meio da tela (mobile + desktop)
   ============================================================ */
#fxConverter.fx-converter.open,
.fx-converter.open {
  position: fixed !important;
  left: 50% !important;
  top: 50% !important;
  right: auto !important;
  bottom: auto !important;
  transform: translate(-50%, -50%) !important;
  width: min(380px, calc(100vw - 28px)) !important;
  max-width: calc(100vw - 28px) !important;
  max-height: min(88dvh, 640px) !important;
  border-radius: 16px !important;
  z-index: 2147482000 !important;
  margin: 0 !important;
}


/* ============================================================
   CHART FLUID MOBILE + expand + install
   ============================================================ */
#modalTerminal .header-icon-chart {
  display: inline-flex !important;
  visibility: visible !important;
  opacity: 1 !important;
}

@media (max-width: 900px) {
  #modalTerminal .chart-plot {
    height: min(240px, 38vh) !important;
    min-height: 180px !important;
    max-height: 280px !important;
    border-radius: 12px !important;
    touch-action: pan-x pan-y pinch-zoom !important;
  }
  #modalTerminal .results-container.expanded-chart .chart-plot {
    height: min(52vh, 420px) !important;
    max-height: 52vh !important;
    min-height: 240px !important;
  }
  #modalTerminal .results-container.expanded-chart .chart-wrap {
    flex: 1 1 auto !important;
  }
  /* Esconde blocos secundários no expand, mantém gráfico grande */
  #modalTerminal .results-container.expanded-chart .res-display,
  #modalTerminal .results-container.expanded-chart .stats-grid,
  #modalTerminal .results-container.expanded-chart .stats-grid-extra,
  #modalTerminal .results-container.expanded-chart .modal-edu-note,
  #modalTerminal .results-container.expanded-chart .projection-limits {
    display: none !important;
  }
}

.pwa-install,
.pwa-install.show {
  z-index: 2147482500 !important;
  pointer-events: auto !important;
}
.pwa-install[hidden],
.pwa-install:not(.show) {
  display: none !important;
  pointer-events: none !important;
}
body.modal-open .pwa-install,
html.modal-open .pwa-install,
body:has(#modalTerminal.modal.active) .pwa-install {
  display: none !important;
  pointer-events: none !important;
}

/* ============================================================
   v1.5.12 — Chatbot visível com calculadora aberta (mobile)
   Modal terminal z-index 100200; chatbot precisa ficar acima
   ============================================================ */
@media (max-width: 900px) {
  body.terminal-open #chatbotRoot,
  body.terminal-open #chatbotRoot.chatbot-container,
  #modalTerminal.active ~ #chatbotRoot,
  #chatbotRoot.is-fab-visible {
    display: block !important;
    visibility: visible !important;
    pointer-events: auto !important;
    opacity: 1 !important;
    position: fixed !important;
    z-index: 100250 !important;
    bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
    right: max(12px, env(safe-area-inset-right, 0px)) !important;
    left: auto !important;
  }

  body.terminal-open #chatbotFab,
  body.terminal-open #chatbotRoot #chatbotFab,
  #chatbotRoot.is-fab-visible #chatbotFab {
    display: flex !important;
    visibility: visible !important;
    pointer-events: auto !important;
    opacity: 1 !important;
    width: 56px !important;
    height: 56px !important;
    border-radius: 50% !important;
    overflow: hidden !important;
    padding: 0 !important;
    z-index: 100251 !important;
  }

  body.terminal-open #mfpWindow.chatbot-window.is-open:not(.is-fullscreen):not(.is-minimized),
  body.terminal-open .chatbot-window.is-open:not(.is-fullscreen):not(.is-minimized) {
    z-index: 100260 !important;
    bottom: calc(70px + env(safe-area-inset-bottom, 0px)) !important;
    right: max(8px, env(safe-area-inset-right, 0px)) !important;
    left: max(8px, env(safe-area-inset-left, 0px)) !important;
    width: auto !important;
    max-width: min(400px, calc(100vw - 16px)) !important;
    height: min(58dvh, 480px) !important;
    max-height: calc(100dvh - 140px - env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Gráficos e touch no modal */
  #modalTerminal.modal.active .chart-plot,
  #modalTerminal.modal.active .chart-wrap,
  #modalTerminal.modal.active #mainChart {
    max-width: 100% !important;
    width: 100% !important;
    touch-action: none;
  }
  #modalTerminal.modal.active canvas {
    max-width: 100% !important;
    height: auto !important;
  }

  /* Inputs touch-friendly */
  #modalTerminal.modal.active input[type="range"] {
    min-height: 28px !important;
    touch-action: none;
  }
  #modalTerminal.modal.active .dual-input input,
  #modalTerminal.modal.active input[type="number"] {
    font-size: 16px !important; /* evita zoom iOS */
    min-height: 44px !important;
  }

  /* Bottom nav sempre acima do conteúdo, abaixo do chatbot quando terminal aberto */
  body.terminal-open #bottomNav {
    z-index: 100100 !important;
  }

  /* Menu home / header no mobile */
  .site-header {
    padding-left: max(12px, env(safe-area-inset-left)) !important;
    padding-right: max(12px, env(safe-area-inset-right)) !important;
  }
  #siteNav.open,
  .site-nav.is-open {
    max-height: calc(100dvh - 56px - env(safe-area-inset-bottom, 0px)) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
}

/* Desktop: chatbot acima do modal também (segurança) */
@media (min-width: 901px) {
  body.terminal-open #chatbotRoot {
    z-index: 100250 !important;
  }
}


/* --- superseded by css/mobile-chrome.css (v1.5.17) --- */
/* Do not re-add #bottomNav display rules here; mobile-chrome is source of truth */


/* ============================================================
   v1.5.27 — Chatbot mobile: padrão angular (igual ao site)
   ============================================================ */
@media (max-width: 900px) {
  body.terminal-open #mfpWindow.chatbot-window.is-open:not(.is-fullscreen):not(.is-minimized),
  body.terminal-open .chatbot-window.is-open:not(.is-fullscreen):not(.is-minimized),
  #mfpWindow.chatbot-window.is-open:not(.is-fullscreen):not(.is-minimized) {
    border-radius: var(--radius-md, 6px) !important;
  }
  #mfpWindow .chatbot-message,
  #mfpWindow .chat-chip,
  #mfpWindow .chat-ctrl-btn,
  #mfpWindow .chatbot-input input,
  #mfpWindow .chatbot-input button {
    border-radius: var(--radius, 2px) !important;
  }
  #mfpWindow .chatbot-input input {
    border-radius: var(--radius, 2px) 0 0 var(--radius, 2px) !important;
  }
  #mfpWindow .chatbot-input button {
    border-radius: 0 var(--radius, 2px) var(--radius, 2px) 0 !important;
  }
}


/* zoom-pan restore v1.5.33 — permite pinça/arraste no gráfico */
#modalTerminal .chart-plot,
#modalTerminal #chartPlot,
#modalTerminal #mainChart,
#modalTerminal .chart-plot canvas {
  touch-action: none !important;
  pointer-events: auto !important;
}


/* ===== Agenda modal: fonte + ações organizadas (v1.5.38) ===== */
.cal-modal-source {
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  gap: 6px !important;
  margin: 14px 0 4px !important;
  padding: 12px 12px !important;
  border-radius: 8px !important;
  border: 1px solid rgba(255,255,255,0.08) !important;
  background: rgba(255,255,255,0.03) !important;
}
.cal-modal-source .cal-source-label,
.cal-modal-source > strong {
  display: block !important;
  font-size: 0.68rem !important;
  font-weight: 600 !important;
  letter-spacing: 0.04em !important;
  text-transform: uppercase !important;
  color: var(--text-dim, #8a919c) !important;
}
.cal-modal-source .cal-source-link,
.cal-modal-source a#calModalSourceLink,
.cal-modal-source a {
  display: block !important;
  font-size: 0.88rem !important;
  font-weight: 500 !important;
  line-height: 1.35 !important;
  color: var(--gold, #D4AF37) !important;
  text-decoration: none !important;
  word-break: break-word !important;
  max-width: 100% !important;
}
.cal-modal-source a:hover {
  text-decoration: underline !important;
}
.cal-modal-actions {
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: center !important;
  gap: 8px !important;
  margin-top: 16px !important;
  padding-top: 4px !important;
}
.cal-modal-actions .cal-action-primary,
.cal-modal-actions .cal-action-secondary,
.cal-modal-actions .cal-action-ghost,
.cal-modal-actions .cal-action-as-btn,
.cal-modal-actions a.cal-action-link {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  margin: 0 !important;
  text-decoration: none !important;
  white-space: nowrap !important;
  box-sizing: border-box !important;
}
.cal-modal-actions a.cal-action-as-btn,
.cal-modal-actions a.cal-action-secondary {
  padding: 8px 14px !important;
  font-size: 0.75rem !important;
  font-weight: 600 !important;
  border-radius: 99px !important;
  border: 1px solid rgba(212,175,55,0.4) !important;
  background: rgba(212,175,55,0.08) !important;
  color: var(--gold, #D4AF37) !important;
  text-decoration: none !important;
}
.cal-modal-actions a.cal-action-as-btn:hover {
  filter: brightness(1.08);
  text-decoration: none !important;
}

/* ============================================================
   PRÓXIMAINVEST v1.0 — Correção de rolagem da página
   Corrige: página só rolava pela barra lateral; roda do mouse
   e gesto touch não moviam o conteúdo.
   Causa típica: overflow-x:hidden no html/body + height:100%
   ============================================================ */

/* Base: permitir scroll vertical com roda do mouse e touch */
html {
  overflow-x: clip !important;
  overflow-y: scroll !important;
  height: auto !important;
  min-height: 100% !important;
  overscroll-behavior-y: auto !important;
}

body {
  overflow-x: clip !important;
  overflow-y: visible !important;
  height: auto !important;
  min-height: 100% !important;
  max-width: 100% !important;
  position: static !important;
  touch-action: pan-y pinch-zoom !important;
  -webkit-overflow-scrolling: touch !important;
  overscroll-behavior-y: auto !important;
}

/* Estado normal (sem modal): forçar página rolável */
html:not(.cal-modal-open):not(.modal-open),
body:not(.cal-modal-open):not(.modal-open):not(.plano-open):not(.mais-open) {
  overflow-y: scroll !important;
  overflow-x: clip !important;
  height: auto !important;
  max-height: none !important;
  position: static !important;
  touch-action: manipulation !important;
  overscroll-behavior-y: auto !important;
}

/* Garantir que o conteúdo principal recebe a roda do mouse */
body:not(.cal-modal-open):not(.modal-open) main,
body:not(.cal-modal-open):not(.modal-open) #app,
body:not(.cal-modal-open):not(.modal-open) .page,
body:not(.cal-modal-open):not(.modal-open) {
  touch-action: pan-y pinch-zoom !important;
  pointer-events: auto !important;
}

/* Imagens não estouram layout */
img, video, canvas, svg {
  max-width: 100%;
  height: auto;
}

/* Mobile / tablet */
@media screen and (max-width: 1024px) {
  html:not(.cal-modal-open):not(.modal-open),
  body:not(.cal-modal-open):not(.modal-open):not(.plano-open):not(.mais-open) {
    overflow-y: scroll !important;
    overflow-x: clip !important;
    height: auto !important;
    position: static !important;
    touch-action: manipulation !important;
  }

  body {
    padding-bottom: calc(62px + env(safe-area-inset-bottom, 0px));
  }
}

/* Quando um overlay está aberto: trava só o fundo (esperado) */
html.cal-modal-open,
body.cal-modal-open,
html.modal-open,
body.modal-open,
body.plano-open,
body.mais-open {
  overflow: hidden !important;
  overscroll-behavior: none !important;
}
