/* Seletor global de aparência. Carregado por último para cobrir Jinja e React. */
.theme-switcher {
  position: fixed;
  z-index: 1000;
  right: 18px;
  bottom: 18px;
  display: inline-flex;
  gap: 3px;
  padding: 4px;
  color: #d9e7ef;
  background: rgba(7, 31, 45, .92);
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(4, 18, 27, .25);
  backdrop-filter: blur(14px);
}

.theme-switcher .theme-option,
.ui-modern .theme-switcher .theme-option {
  width: auto;
  min-width: 0;
  min-height: 34px;
  margin: 0;
  padding: 7px 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #bdced8;
  background: transparent;
  border: 0;
  border-radius: 999px;
  box-shadow: none;
  font: 700 11px/1 "Segoe UI", system-ui, sans-serif;
  letter-spacing: .01em;
  transform: none;
}

.theme-switcher .theme-option:hover,
.ui-modern .theme-switcher .theme-option:hover {
  color: #fff;
  background: rgba(255, 255, 255, .1);
  box-shadow: none;
  transform: none;
}

.theme-switcher .theme-option.is-active,
.ui-modern .theme-switcher .theme-option.is-active {
  color: #082f49;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
}

.theme-switcher svg {
  width: 15px;
  height: 15px;
  flex: none;
  stroke: currentColor;
}

/* Paleta escura compartilhada pelas páginas históricas e pelo shell atual. */
html[data-theme="dark"] {
  color-scheme: dark;
  --tinta: #e7eef3;
  --tinta-suave: #d1dbe1;
  --pinho: #39a9d6;
  --pinho-escuro: #1886b3;
  --pinho-claro: #172d39;
  --papel: #0a141b;
  --branco: #111f28;
  --superficie-suave: #15252f;
  --fio: #293c48;
  --fio-forte: #405763;
  --cinza: #bcc9d1;
  --ambar: #f0c66e;
  --ambar-fundo: #302713;
  --ambar-fio: #66522a;
  --tijolo: #f2a39a;
  --tijolo-fundo: #321c1d;
  --tijolo-fio: #70403d;
  --ok: #7ddbb8;
  --ok-fundo: #153127;
  --ok-fio: #315f4e;
  --sombra: 0 1px 2px rgba(0, 0, 0, .2), 0 12px 34px rgba(0, 0, 0, .18);
  --ui-ink: #e7eef3;
  --ui-muted: #bcc9d1;
  --ui-line: #293e4a;
  --ui-surface: #111f28;
  --ui-canvas: #09131a;
  --ui-shadow-sm: 0 2px 10px rgba(0, 0, 0, .22);
  --ui-shadow: 0 18px 50px rgba(0, 0, 0, .3);
}

html[data-theme="dark"] body,
html[data-theme="dark"] .ui-modern {
  color: var(--tinta);
  background: radial-gradient(circle at 76% 4%, rgba(32, 199, 217, .07), transparent 30rem), #09131a;
}

html[data-theme="dark"] a { color: #70cce9; }
html[data-theme="dark"] a:hover { color: #a4e5f4; }

/* O link genérico do tema não pode apagar o texto dos CTAs sobre fundo ciano. */
html[data-theme="dark"] .inicio-acao,
html[data-theme="dark"] .inicio-acao:hover {
  color: #061e2f;
}

html[data-theme="dark"] .inicio-acao.secundaria,
html[data-theme="dark"] .inicio-acao.secundaria:hover {
  color: #ffffff;
}

html[data-theme="dark"] .app-shell .site-header {
  background: linear-gradient(180deg, #123f5c 0%, #0c3048 52%, #081f30 100%);
  border-top-color: #061722;
}

html[data-theme="dark"] .app-shell .faixa-navegacao { background: #081f30; }

html[data-theme="dark"] .app-shell footer,
html[data-theme="dark"] footer {
  color: #91a5b1;
  background: #0c1820;
}

html[data-theme="dark"] .app-shell .cartao,
html[data-theme="dark"] .app-shell a.cartao-link,
html[data-theme="dark"] .ui-modern .cartao,
html[data-theme="dark"] .ui-modern .inicio-ferramentas a.cartao-link {
  color: var(--tinta);
  background: #111f28;
  border-color: var(--fio);
}

html[data-theme="dark"] .app-shell a.cartao-link h2,
html[data-theme="dark"] .app-shell .preco,
html[data-theme="dark"] .ui-modern .preco,
html[data-theme="dark"] .inicio-card-link {
  color: #70cce9;
}

html[data-theme="dark"] .app-shell label,
html[data-theme="dark"] .ui-modern label,
html[data-theme="dark"] .auth-shell label { color: #d4e0e7; }

html[data-theme="dark"] .app-shell input[type="text"],
html[data-theme="dark"] .app-shell input[type="email"],
html[data-theme="dark"] .app-shell input[type="password"],
html[data-theme="dark"] .app-shell input[type="date"],
html[data-theme="dark"] .app-shell input[type="number"],
html[data-theme="dark"] .app-shell select,
html[data-theme="dark"] .app-shell textarea,
html[data-theme="dark"] .ui-modern input[type="text"],
html[data-theme="dark"] .ui-modern input[type="email"],
html[data-theme="dark"] .ui-modern input[type="password"],
html[data-theme="dark"] .ui-modern input[type="date"],
html[data-theme="dark"] .ui-modern input[type="number"],
html[data-theme="dark"] .ui-modern select,
html[data-theme="dark"] .ui-modern textarea,
html[data-theme="dark"] .auth-shell input[type="text"],
html[data-theme="dark"] .auth-shell input[type="email"],
html[data-theme="dark"] .auth-shell input[type="password"] {
  color: #e7eef3;
  background: #0c1921;
  border-color: #405763;
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder { color: #a5b5bf; }

html[data-theme="dark"] .app-shell input[type="file"],
html[data-theme="dark"] .ui-modern input[type="file"],
html[data-theme="dark"] .app-shell input[type="file"]::file-selector-button,
html[data-theme="dark"] .ui-modern input[type="file"]::file-selector-button,
html[data-theme="dark"] .app-shell button.secundario,
html[data-theme="dark"] .ui-modern button.secundario {
  color: #b7deee;
  background: #15252f;
  border-color: #405763;
}

html[data-theme="dark"] .app-shell th,
html[data-theme="dark"] .ui-modern th {
  color: #b4c4ce;
  background: #172832;
  border-color: #344955;
}

html[data-theme="dark"] .app-shell td {
  color: #d8e3e9;
  background: #101e27;
  border-color: #293c48;
}

html[data-theme="dark"] .app-shell tbody tr:hover td,
html[data-theme="dark"] .app-shell table > tr:hover td,
html[data-theme="dark"] .ui-modern tbody tr:hover td,
html[data-theme="dark"] .ui-modern table > tr:hover td { background: #172832; }

html[data-theme="dark"] .ncm-sugestoes,
html[data-theme="dark"] .ncm-opcao,
html[data-theme="dark"] .app-shell code {
  color: #d8e3e9;
  background: #101e27;
}

html[data-theme="dark"] .ncm-opcao:hover,
html[data-theme="dark"] .ncm-opcao.ativa { background: #19303d; }

html[data-theme="dark"] .ui-topbar {
  color: var(--ui-ink);
  background: rgba(12, 27, 36, .92);
  border-bottom-color: rgba(70, 96, 110, .65);
}

html[data-theme="dark"] .ui-topbar-title small { color: #75d0eb; }
html[data-theme="dark"] .ui-topbar-account { color: #d2dde4; }
html[data-theme="dark"] .ui-modern footer,
html[data-theme="dark"] .app-shell .dica,
html[data-theme="dark"] .ui-modern main > .sub,
html[data-theme="dark"] .app-shell .cabecalho-pagina .sub,
html[data-theme="dark"] .app-shell .identificacao { color: #bcc9d1; }

html[data-theme="dark"] .app-shell .admin-consulta-receita {
  background: #132733;
  border-left-color: #39a9d6;
}

html[data-theme="dark"] .perfil-foto {
  color: #8edcf0;
  background: #17313e;
}

html[data-theme="dark"] .ui-modern input[type="file"] { background: #12232d; }
html[data-theme="dark"] .ui-modern button.secundario:hover { background: #1b3441; }

html[data-theme="dark"] .ui-auth-modern {
  background: radial-gradient(circle at 80% 10%, rgba(32, 199, 217, .08), transparent 28rem), #09131a;
}

html[data-theme="dark"] .ui-auth-modern .form-caixa {
  color: #e7eef3;
  background: #111f28;
  border-color: #314651;
  box-shadow: 0 26px 70px rgba(0, 0, 0, .32);
}

html[data-theme="dark"] .auth-shell .form-caixa .sub,
html[data-theme="dark"] .auth-shell .troca { color: #bdcad2; }

html[data-theme="dark"] .auth-shell .troca { border-color: #314651; }

html[data-theme="dark"] .perfil-grade input[readonly] {
  color: #bdcad2;
  background: #172832;
}

@media (max-width: 560px) {
  .theme-switcher {
    right: 12px;
    bottom: 12px;
  }

  .theme-switcher .theme-option,
  .ui-modern .theme-switcher .theme-option {
    min-height: 32px;
    padding: 7px 9px;
  }

  .theme-switcher .theme-option span { display: none; }
}

@media print {
  .theme-switcher { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  .theme-switcher *,
  html[data-theme] body { transition: none !important; }
}
