/* Paleta compartilhada: a preferência do dispositivo é o padrão. */
:root {
  color-scheme: light;
  --bg:#f6f7f2;
  --surface:#fff;
  --surface2:#f0f3ed;
  --border:#dce4da;
  --accent:#157a60;
  --accent2:#2563a8;
  --accent3:#df7448;
  --blue:#3976ad;
  --orange:#c75d30;
  --danger:#c84e55;
  --text:#18261f;
  --muted:#66766d;
  --body-text:#53665b;
  --nav-surface:rgba(255,255,255,.88);
  --soft-surface:#f7f9f5;
  --accent-soft:#e3f2e9;
  --accent-border:#c6e1d2;
  --on-accent:#fff;
  --strong-button:#173b31;
  --on-strong:#fff;
  --feature-surface:#173b31;
  --coral-soft:#ffebe5;
  --coral-text:#ad442b;
  --blue-soft:#e7eff9;
  --blue-text:#3975ae;
  --warning-soft:#fff7dc;
  --warning-text:#89631b;
  --warning-border:#ead79b;
  --danger-soft:#fff3f2;
  --danger-border:#efcecb;
  --chart-grid:rgba(31,57,45,.09);
  --chart-green:#157a60;
  --chart-blue:#3976ad;
  --chart-orange:#df7448;
  --chart-tooltip:#173b31;
  --chart-tooltip-text:#fff;
  --shadow:0 10px 32px rgba(27,52,40,.06);
  --hero-shadow:0 30px 70px rgba(27,52,40,.16);
  --overlay:rgba(16,29,22,.65);
  --heading-gradient:linear-gradient(112deg,#157a60 4%,#28a27e 46%,#2563a8 100%);
}

:root[data-theme="dark"] {
  color-scheme:dark;
  --bg:#0d1713;
  --surface:#15231c;
  --surface2:#1c2d24;
  --border:#30453a;
  --accent:#62d7b1;
  --accent2:#83b9ed;
  --accent3:#f6a079;
  --blue:#83b9ed;
  --orange:#f6a079;
  --danger:#ff959b;
  --text:#edf5ef;
  --muted:#a1b3a8;
  --body-text:#c1cfc5;
  --nav-surface:rgba(21,35,28,.94);
  --soft-surface:#19291f;
  --accent-soft:#203c30;
  --accent-border:#3b6652;
  --on-accent:#0c281e;
  --strong-button:#62d7b1;
  --on-strong:#0c281e;
  --feature-surface:#204335;
  --coral-soft:#3c2a22;
  --coral-text:#ffb193;
  --blue-soft:#213344;
  --blue-text:#9ac9f3;
  --warning-soft:#352e1b;
  --warning-text:#f4ce78;
  --warning-border:#665633;
  --danger-soft:#3a2428;
  --danger-border:#674048;
  --chart-grid:rgba(185,213,196,.13);
  --chart-green:#62d7b1;
  --chart-blue:#83b9ed;
  --chart-orange:#f6a079;
  --chart-tooltip:#223d30;
  --chart-tooltip-text:#edf5ef;
  --shadow:0 10px 32px rgba(0,0,0,.15);
  --hero-shadow:0 30px 70px rgba(0,0,0,.3);
  --overlay:rgba(3,10,6,.78);
  --heading-gradient:linear-gradient(112deg,#62d7b1 4%,#8ce4bc 46%,#83b9ed 100%);
}

/* Sem JavaScript, os tokens também respeitam o tema do sistema. */
@media (prefers-color-scheme:dark) {
  :root:not([data-theme]) {
    color-scheme:dark;
    --bg:#0d1713; --surface:#15231c; --surface2:#1c2d24; --border:#30453a;
    --accent:#62d7b1; --accent2:#83b9ed; --accent3:#f6a079;
    --blue:#83b9ed; --orange:#f6a079; --danger:#ff959b;
    --text:#edf5ef; --muted:#a1b3a8; --body-text:#c1cfc5;
    --nav-surface:rgba(21,35,28,.94); --soft-surface:#19291f;
    --accent-soft:#203c30; --accent-border:#3b6652; --on-accent:#0c281e;
    --strong-button:#62d7b1; --on-strong:#0c281e; --feature-surface:#204335;
    --coral-soft:#3c2a22; --coral-text:#ffb193; --blue-soft:#213344; --blue-text:#9ac9f3;
    --warning-soft:#352e1b; --warning-text:#f4ce78; --warning-border:#665633;
    --danger-soft:#3a2428; --danger-border:#674048;
    --chart-grid:rgba(185,213,196,.13); --chart-green:#62d7b1;
    --chart-blue:#83b9ed; --chart-orange:#f6a079;
    --chart-tooltip:#223d30; --chart-tooltip-text:#edf5ef;
    --shadow:0 10px 32px rgba(0,0,0,.15); --hero-shadow:0 30px 70px rgba(0,0,0,.3);
    --overlay:rgba(3,10,6,.78);
    --heading-gradient:linear-gradient(112deg,#62d7b1 4%,#8ce4bc 46%,#83b9ed 100%);
  }
}

/* Cápsula de ícones com seleção deslizante, sem menu suspenso. */
[data-theme-control] { flex:0 0 auto; }
.theme-control {
  --theme-button-size:34px;
  --theme-active-index:0;
  position:relative; display:grid;
  grid-template-columns:repeat(3,var(--theme-button-size)); gap:2px; padding:3px;
  width:max-content; border:1px solid var(--border); border-radius:14px;
  background:var(--surface2); box-shadow:inset 0 1px 2px rgba(0,0,0,.035);
}
.theme-control[data-active="light"] { --theme-active-index:1; }
.theme-control[data-active="dark"] { --theme-active-index:2; }
.theme-control::before {
  content:''; position:absolute; top:3px; left:3px;
  width:var(--theme-button-size); height:var(--theme-button-size); border-radius:10px;
  background:var(--surface); box-shadow:0 2px 6px rgba(0,0,0,.09),inset 0 0 0 1px var(--accent-border);
  transform:translateX(calc(var(--theme-active-index) * (var(--theme-button-size) + 2px)));
  transition:transform .24s cubic-bezier(.2,.8,.2,1),background .2s;
  pointer-events:none;
}
.theme-control__button {
  position:relative; display:grid; place-items:center;
  width:var(--theme-button-size); height:var(--theme-button-size); padding:0;
  border:0; border-radius:10px; background:transparent; color:var(--muted);
  cursor:pointer; -webkit-tap-highlight-color:transparent;
  transition:color .18s,background .18s;
}
.theme-control__button:hover { color:var(--text); background:color-mix(in srgb,var(--accent) 7%,transparent); }
.theme-control__button[aria-checked="true"] { color:var(--accent); }
.theme-control__button:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
.theme-control__button svg { display:block; pointer-events:none; transition:transform .2s; }
.theme-control__button:hover svg { transform:scale(1.08); }
.theme-control__button::after {
  content:attr(data-tooltip); position:absolute; top:calc(100% + 10px); left:50%;
  transform:translate(-50%,-3px); z-index:220; padding:6px 9px;
  border:1px solid var(--border); border-radius:7px;
  background:var(--surface); color:var(--text); box-shadow:var(--shadow);
  font:600 12px 'DM Sans',sans-serif; white-space:nowrap;
  opacity:0; visibility:hidden; pointer-events:none;
  transition:opacity .15s,transform .15s,visibility .15s;
}
.theme-control__button:hover::after, .theme-control__button:focus-visible::after {
  opacity:1; visibility:visible; transform:translate(-50%,0);
}
html .sidebar [data-theme-control] { margin:0; }
html .sidebar .theme-control__button::after { top:auto; bottom:calc(100% + 10px); }
html .sidebar { overflow-y:auto; }
html .theme-nav-actions { display:flex; align-items:center; gap:14px; }
html footer [data-theme-control] { display:flex; justify-content:center; margin-top:20px; }
html .payment-status [data-theme-control] { display:flex; justify-content:center; margin-top:28px; }

/* Estrutura, entradas e estados compartilhados. */
html nav:not(.menu) { background:var(--nav-surface); border-color:var(--border); }
html .logo, html .topbar h1, html .sec-h { color:var(--text); }
html .nav-links a, html .nav-back, html .back-btn, html .topbar .sub { color:var(--muted); }
html .sidebar { background:var(--nav-surface); border-color:var(--border); }
html .menu-label, html .side-user-copy span, html .stat-label { color:var(--muted); }
html .menu-item { color:var(--muted); }
html .menu-item:hover { background:var(--surface2); color:var(--text); }
html .menu-item.active { background:var(--accent-soft); border-color:var(--accent-border); color:var(--accent); box-shadow:inset 3px 0 0 var(--accent); }
html .menu-sep { background:var(--border); }
html .side-user, html .report-actions { border-color:var(--border); }
html .side-avatar, html .email-card .icon { background:var(--accent-soft); color:var(--accent); }
html .card, html .stat, html .email-card, html .report-card, html .downloads-card,
html .report-section { background:var(--surface); border-color:var(--border); box-shadow:var(--shadow); }
html .card-title, html .report-name, html .welcome-copy h2,
html .login-preview-head strong, html .login-preview-item span { color:var(--text); }
html .stat-val, html .stat-delta.down, html .report-arrow { color:var(--accent); }
html .card-sub, html .empty, html .report-meta, html .welcome-copy p,
html .login-note, html .email-card p, html .login-preview-head span,
html .login-preview-item small { color:var(--muted); }
html .welcome-banner, html .login-preview, html .preview-profile, html .report-header {
  background:linear-gradient(120deg,var(--accent-soft),var(--surface) 72%,var(--blue-soft));
  border-color:var(--accent-border);
}
html .welcome-label { color:var(--accent); }
html .welcome-actions a, html .panel-link, html .hamburger {
  background:var(--surface); border-color:var(--border); color:var(--text);
}
html .login-preview-item { background:var(--surface); border-color:var(--border); }
html .login-preview-item b { background:var(--accent-soft); color:var(--accent); }
html .email-input { background:var(--soft-surface); border-color:var(--border); }
html input::placeholder { color:var(--muted); }
html .report-card:hover { background:var(--soft-surface); border-color:var(--accent-border); }
html .report-card.pending, html .footer-disclaimer { background:var(--warning-soft); border-color:var(--warning-border); color:var(--warning-text); }
html .pending-badge { color:var(--warning-text); border-color:var(--warning-border); }
html .error-card { background:var(--danger-soft); border-color:var(--danger-border); }
html .error-card h2 { color:var(--danger); }
html .dl-item { background:var(--soft-surface); border-color:var(--border); }
html .dl-item-name { color:var(--text); }
html .dl-item-ext { color:var(--accent); }
html .new-report-btn, html .nav-primary { background:var(--strong-button); color:var(--on-strong); }
html .btn-primary, html .btn-next, html .btn-send, html .error-card .btn-retry, html .preview-cta-btn,
html .btn-download, html .cta, html .welcome-actions a.primary,
html .calc-nav .nav-cta, html .calc-btn, html .cta-card .cta-btn, html #cookieBanner button {
  background:var(--accent); color:var(--on-accent); border-color:var(--accent);
}
html .cta.ghost { background:var(--accent-soft); border-color:var(--accent-border); color:var(--accent); }
html .btn-secondary { background:var(--surface); border-color:var(--border); color:var(--text); }
html .btn-secondary:hover { background:var(--surface2); border-color:var(--accent-border); }
html .option-btn:hover, html .option-btn.selected { background:var(--accent-soft); }
html .preview-overlay, html .modal-overlay, html .scrim.show { background:var(--overlay); }
html .preview-modal, html .preview-header { background:var(--surface); border-color:var(--border); }
html .preview-stat, html .report-stat { background:var(--surface); border-color:var(--border); }
html .preview-section { border-color:var(--border); }
html .preview-section-head, html .preview-close { background:var(--surface2); }
html .preview-stat-val { color:var(--accent); }
html .preview-section-body p, html .preview-section-body li, html .preview-section-body td,
html .preview-blur-label, html .report-content, html .md-table td { color:var(--body-text); }
html .preview-section-body strong { color:var(--text); }
html .preview-section-body td, html .md-table td { border-color:var(--border); }
html .preview-section-body th { color:var(--accent); background:var(--accent-soft); border-color:var(--accent-border); }
html #cookieBanner { color:var(--body-text); box-shadow:var(--shadow); }
html footer { background:var(--surface2); }

/* Página inicial e prévia do painel. */
html .hero h1 em { background-image:var(--heading-gradient); }
html .hero p { color:var(--body-text); }
html .hero p strong, html .trust-strip b { color:var(--text); }
html .hero-proof, html .trust-strip span, html .section-sub { color:var(--muted); }
html .dashboard-mockup { background:var(--surface); border-color:var(--border); box-shadow:var(--hero-shadow); }
html .mock-topbar, html .mock-menu { background:var(--soft-surface); border-color:var(--border); }
html .mock-menu span, html .mock-heading small, html .mock-metrics span,
html .mock-metrics strong small, html .mock-chart-title small, html .mock-files small { color:var(--muted); }
html .mock-menu span.active, html .mock-user, html .floating-badge b { background:var(--accent-soft); color:var(--accent); }
html .mock-heading strong, html .mock-metrics strong, html .mock-chart-title span, html .mock-files strong { color:var(--text); }
html .mock-metrics > div, html .mock-chart-card, html .mock-files > div, html .floating-badge,
html .trust-strip > div { background:var(--surface); border-color:var(--border); }
html .mock-metrics em { color:var(--accent); }
html .mock-chart-card .grid-line { stroke:var(--chart-grid); }
html .mock-chart-card .line { stroke:var(--accent); }
html .mock-chart-card circle { fill:var(--surface); stroke:var(--accent); }
html .floating-badge span { color:var(--body-text); }
html .file-icon.pdf, html .experience-icon.coral { background:var(--coral-soft); color:var(--coral-text); }
html .file-icon.xlsx { background:var(--accent-soft); color:var(--accent); }
html .experience-icon.blue { background:var(--blue-soft); color:var(--blue-text); }
html .experience-card, html .testimonial-card, html .plan { background:var(--surface); border-color:var(--border); box-shadow:var(--shadow); }
html .experience-card h3, html .plan-name, html .plan-price, html .testimonial-text strong { color:var(--text); }
html .experience-card p, html .testimonial-text { color:var(--body-text); }
html .experience-card > span { color:var(--accent); }
html .experience-card.featured { background:var(--feature-surface); border-color:var(--accent-border); }
html .experience-card.featured h3 { color:#fff; }
html .experience-card.featured p { color:#c1d2ca; }
html .experience-card.featured > span { color:#8ce4bc; }
html .pdf-preview-section { background:linear-gradient(145deg,var(--surface2),var(--bg)); border-color:var(--border); }
html .format-pills span { background:var(--surface); border-color:var(--border); color:var(--muted); }
html .format-pills span.active { background:var(--accent-soft); border-color:var(--accent-border); color:var(--accent); }
html .pdf-page-card { border-color:var(--border); }
html .pdf-page-header[style], html .pdf-page-card:nth-child(2) .pdf-page-header,
html .sheet-header { background:var(--accent-soft)!important; }
html .pdf-page-card:nth-child(3) .pdf-page-header, html .sheet-header.blue { background:var(--blue-soft)!important; }
html .pdf-page-card:nth-child(4) .pdf-page-header { background:var(--coral-soft)!important; }
html .pdf-page-title { color:var(--text); }
html .pdf-page-chip, html .pdf-day-on { background:var(--accent-soft); color:var(--accent); }
html .pdf-line, html .sheet-row span { background:var(--border); }
html .pdf-metric { background:var(--surface2); }
html .pdf-metric strong { color:var(--accent); }
html .pdf-page-card:nth-child(4) .pdf-page-body > div > div { color:var(--muted)!important; }
html .sheet-row, html .mini-bars { border-color:var(--border); }
html .sheet-row strong { color:var(--body-text); }
html .sheet-title-row span { background:none; color:var(--accent); }
html .plan:hover { border-color:var(--accent-border); }
html .plan.featured { background:linear-gradient(155deg,var(--surface),var(--accent-soft)); border-color:var(--accent); }
html .plan-desc, html .plan-preview-link, html .plan-features li.off { color:var(--muted); }
html .plan-features { border-color:var(--border); }
html .plan-features li { color:var(--body-text); }
html .plan-btn { background:var(--surface2); border-color:var(--border); color:var(--text); }
html .plan.featured .plan-btn { background:var(--accent); border-color:var(--accent); color:var(--on-accent); }
html .pricing table { background:var(--surface); border-color:var(--border); }
html .pricing table td, html .pricing table th { border-color:var(--border)!important; }
html .pricing table td { color:var(--body-text)!important; }
html .pricing table tr:nth-child(even) { background:var(--surface2)!important; }
html #faq > div:last-child { background:var(--surface); border-color:var(--border)!important; }
html #faq .faq-body > div { color:var(--body-text)!important; }
html footer div[style*="background:rgba(255,255,255"] { background:var(--surface)!important; border-color:var(--border); }

/* Relatórios, termos e calculadoras. */
html .report-content em { color:var(--muted); }
html .w-box, html .w-metric-text { background:var(--soft-surface); }
html .w-metric-num { background:var(--accent-soft); }
html .w-metric-val { color:var(--text); }
html .w-scale-legend, html .w-metric-text, html .w-callout-text, html .w-checklist-text,
html .content-section p, html .content-section li, html .calc-table td,
html .calc-faq .faq-body, html .legal-page p, html .legal-page ul { color:var(--body-text); }
html .payment-ok { background:var(--accent-soft); border-color:var(--accent-border); }
html #upsellOffer, html #upsellWaiting, html #upsellDone { background:linear-gradient(135deg,var(--accent-soft),var(--surface))!important; border-color:var(--accent-border)!important; }
html #upsellOffer strong, html #upsellOffer > div > div:first-child,
html #upsellWaiting > div:nth-child(2) { color:var(--text)!important; }
html #upsellOffer div, html #upsellWaiting div, html #upsellDone div { color:var(--body-text); }
html #upsellBtn, html #upsellAccessBtn { background:var(--accent)!important; color:var(--on-accent)!important; }

@media (max-width:760px) {
  html body > nav { flex-wrap:wrap; gap:12px; }
  html body > nav:not(.calc-nav) .logo { font-size:17px; gap:7px; }
  html body > nav:not(.calc-nav) .logo img { width:25px; height:25px; }
  html .theme-nav-actions { flex-wrap:wrap; justify-content:flex-end; }
  html .theme-control { --theme-button-size:32px; }
  html .nav-actions, html .theme-nav-actions { gap:6px; }
  html .recovery-bar { background:var(--accent-soft); border-color:var(--accent-border); }
  html a.nav-right-btn, html a.nav-right-btn:visited { background:var(--accent-soft)!important; border-color:var(--accent-border)!important; color:var(--accent)!important; }
}
@media (prefers-reduced-motion:reduce) {
  .theme-control::before, .theme-control__button, .theme-control__button svg,
  .theme-control__button::after { transition:none; }
}
@media (max-width:400px) {
  html .app > nav { flex-wrap:wrap; gap:8px; }
  html .app > nav .logo { font-size:16px; gap:6px; }
  html .app > nav .logo-icon { width:25px; height:25px; }
  html .calc-nav .nav-cta { padding:8px; font-size:11px; }
  html .calc-nav .logo { font-size:14px; gap:5px; }
  html .theme-nav-actions { flex-wrap:wrap; justify-content:flex-end; }
}
