/* FinanKey 1.5.10 — switch visual e previsão mobile progressiva. */
.theme-toggle {
  position: relative !important;
  width: 40px !important;
  min-width: 40px !important;
  height: 40px !important;
  min-height: 40px !important;
  padding: 0 !important;
  overflow: hidden;
  isolation: isolate;
}

.theme-toggle > svg {
  position: absolute;
  width: 1px !important;
  height: 1px !important;
  opacity: 0;
  pointer-events: none;
}

.theme-toggle::before {
  content: "";
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 50%;
  width: 28px;
  height: 16px;
  border: 1px solid rgba(229, 201, 121, 0.52);
  border-radius: 999px;
  background: rgba(229, 201, 121, 0.14);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.025);
  transform: translate(-50%, -50%);
  transition: background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.theme-toggle::after {
  content: "";
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 9px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e5c979;
  box-shadow: 0 0 7px rgba(229, 201, 121, 0.42);
  transform: translateY(-50%);
  transition: transform 180ms cubic-bezier(.2, .8, .2, 1), background-color 160ms ease, box-shadow 160ms ease;
}

html[data-theme="light"] .theme-toggle::before {
  border-color: #090909;
  background: #090909;
  box-shadow: none;
}

html[data-theme="light"] .theme-toggle::after {
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.28);
  transform: translate(12px, -50%);
}

/* Seleção escura neutra: cinza de cimento queimado, sem bloco marrom. */
html[data-theme="dark"] .sidebar nav button.active,
html[data-theme="dark"] .bottom-nav button.active {
  color: #f1f0ec !important;
  background:
    radial-gradient(circle at 18% 16%, rgba(255, 255, 255, 0.075), transparent 34%),
    linear-gradient(145deg, rgba(72, 72, 69, 0.78), rgba(35, 35, 34, 0.92)) !important;
  border-color: rgba(255, 255, 255, 0.15) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.055), 0 7px 18px rgba(0, 0, 0, 0.18) !important;
}

html[data-theme="dark"] .sidebar nav button.active svg,
html[data-theme="dark"] .bottom-nav button.active svg {
  color: #e5c979 !important;
}

/* Tipografia consistente nas escolhas: firme, legível e sem alterar as caixas. */
:where(
  .bill-filter-tabs button,
  .filter-chips button,
  .history-scope-button,
  .type-selector button,
  .entry-kind-selector button,
  .recurrence-options button,
  .bulk-kind-selector button,
  .bulk-payment-selector button,
  .installment-picker-heading button
) {
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif !important;
  font-size: 12px !important;
  font-weight: 640 !important;
  line-height: 1 !important;
  letter-spacing: -0.012em !important;
  text-rendering: geometricPrecision;
  font-variant-numeric: tabular-nums;
}

:where(
  .bill-filter-tabs button.active,
  .filter-chips button.active,
  .history-scope-button.active,
  .type-selector button.active,
  .entry-kind-selector button.active,
  .recurrence-options button.active,
  .bulk-kind-selector button.active,
  .bulk-payment-selector button.active
) {
  font-weight: 760 !important;
  letter-spacing: -0.018em !important;
}

.bill-filter-tabs b {
  display: inline-grid !important;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 11px !important;
  font-weight: 780 !important;
  line-height: 1 !important;
  font-variant-numeric: tabular-nums;
}

:where(.field-label select, .forecast-action select) {
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif !important;
  font-weight: 610 !important;
  letter-spacing: -0.01em;
}

/* Caixa preta no tema claro: todo o conteúdo acompanha o contraste do fundo. */
html[data-theme="light"] .quick-actions button:is(:hover, :active, :focus-visible) {
  color: #fff !important;
  background: #090909 !important;
  border-color: #090909 !important;
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.08) !important;
}

html[data-theme="light"] .quick-actions button:is(:hover, :active, :focus-visible) :where(strong, small, svg) {
  color: #fff !important;
}

html[data-theme="light"] .quick-actions button:is(:hover, :active, :focus-visible) small {
  color: rgba(255, 255, 255, 0.70) !important;
}

html[data-theme="light"] .quick-actions button:is(:hover, :active, :focus-visible) .quick-icon {
  color: #fff !important;
  background: rgba(255, 255, 255, 0.08) !important;
  border-color: rgba(255, 255, 255, 0.18) !important;
}

/* Contraste global: toda seleção/ação que vira preta no tema claro usa conteúdo branco. */
html[data-theme="light"] :is(
  .type-selector button.active,
  .entry-kind-selector button.active,
  .recurrence-options button.active,
  .filter-chips button.active,
  .history-scope-button.active,
  .bill-filter-tabs button.active,
  .bulk-row-head > div button.active
) {
  color: #fff !important;
  background: #090909 !important;
  border-color: #090909 !important;
  box-shadow: 0 9px 22px rgba(0, 0, 0, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.08) !important;
}

html[data-theme="light"] :is(
  .sidebar nav button.active,
  .sidebar-add,
  .bottom-nav button.active,
  .bottom-add,
  .primary-button,
  .type-selector button.active,
  .entry-kind-selector button.active,
  .recurrence-options button.active,
  .filter-chips button.active,
  .history-scope-button.active,
  .bill-filter-tabs button.active,
  .bulk-row-head > div button.active,
  .bill-status-toggle.is-pending,
  .series-status.active,
  .quick-actions button:is(:hover, :active, :focus-visible),
  .forecast-account-row:hover .forecast-account-summary
) {
  color: #fff !important;
}

html[data-theme="light"] :is(
  .sidebar nav button.active,
  .sidebar-add,
  .bottom-nav button.active,
  .bottom-add,
  .primary-button,
  .type-selector button.active,
  .entry-kind-selector button.active,
  .recurrence-options button.active,
  .filter-chips button.active,
  .history-scope-button.active,
  .bill-filter-tabs button.active,
  .bulk-row-head > div button.active,
  .bill-status-toggle.is-pending,
  .series-status.active,
  .quick-actions button:is(:hover, :active, :focus-visible),
  .forecast-account-row:hover .forecast-account-summary
) :where(strong, span, small, b, svg, i) {
  color: #fff !important;
}

html[data-theme="light"] :is(
  .type-selector button.active,
  .entry-kind-selector button.active,
  .recurrence-options button.active,
  .filter-chips button.active,
  .history-scope-button.active,
  .bill-filter-tabs button.active,
  .quick-actions button:is(:hover, :active, :focus-visible)
) small {
  color: #fff !important;
}

html[data-theme="light"] :is(.filter-chips button.active, .bill-filter-tabs button.active) b {
  color: #fff !important;
  background: rgba(255, 255, 255, 0.15) !important;
}

/* A conta da Previsão escurece ao toque; os campos internos permanecem claros e legíveis. */
html[data-theme="light"] .forecast-account-row:hover .forecast-account-summary {
  color: #fff !important;
}

html[data-theme="light"] .forecast-account-row:hover :where(
  .forecast-account-copy strong,
  .forecast-account-copy small,
  .forecast-account-summary-value span,
  .forecast-account-summary-value strong,
  .forecast-account-summary-value svg,
  .forecast-account-details > label > span,
  .forecast-account-total > span,
  .forecast-account-total > strong,
  .forecast-account-tools svg
) {
  color: #fff !important;
}

/* Ícones alojados permanentemente em pequenos blocos pretos. */
html[data-theme="light"] :where(.brand-mark, .quick-icon.plan, .kpi-icon, .hero-rate > span) {
  color: #fff !important;
}

html[data-theme="light"] :where(.brand-mark, .quick-icon.plan, .kpi-icon, .hero-rate > span) :where(span, strong, small, svg) {
  color: #fff !important;
}

.theme-toggle:hover::before {
  border-color: #e5c979;
}

.theme-toggle:focus-visible {
  outline: 2px solid #e5c979 !important;
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .theme-toggle::before,
  .theme-toggle::after {
    transition: none;
  }
}

/* No desktop, os wrappers são transparentes para preservar o grid original. */
.forecast-account-summary,
.forecast-account-details {
  display: contents;
}

.forecast-account-summary-value {
  display: none;
}

.forecast-account-details > label {
  display: grid;
  min-width: 0;
  align-content: end;
  gap: 8px;
}

@media (max-width: 819px) {
  .forecast-account-row {
    grid-template-columns: minmax(0, 1fr) !important;
    min-height: 0 !important;
    padding: 0 !important;
    gap: 0 !important;
    overflow: hidden;
    align-items: stretch !important;
  }

  .forecast-account-summary {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    min-height: 86px;
    padding: 15px 14px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .forecast-account-summary:focus-visible {
    outline: 2px solid #e5c979;
    outline-offset: -3px;
    border-radius: 17px;
  }

  .forecast-account-summary-value {
    display: grid;
    grid-template-columns: auto 18px;
    align-items: center;
    justify-items: end;
    gap: 2px 8px;
    white-space: nowrap;
  }

  .forecast-account-summary-value span {
    grid-column: 1;
    color: #7f7f7a;
    font-size: 10px;
    line-height: 1;
  }

  .forecast-account-summary-value strong {
    grid-column: 1;
    color: var(--text-main, #fff);
    font-size: 15px;
    line-height: 1.2;
  }

  .forecast-account-summary-value svg {
    grid-column: 2;
    grid-row: 1 / 3;
    width: 17px;
    color: #e5c979;
    transform: rotate(90deg);
    transition: transform 180ms ease;
  }

  .forecast-account-row.is-expanded .forecast-account-summary-value svg {
    transform: rotate(-90deg);
  }

  .forecast-account-row.is-collapsed .forecast-account-tools {
    display: none !important;
  }

  .forecast-account-details {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 104px;
    gap: 15px 12px;
    padding: 16px 14px 15px;
    border-top: 1px solid color-mix(in srgb, var(--text-main, #fff) 9%, transparent);
    animation: forecast-details-in 160ms ease-out;
  }

  .forecast-account-row.is-collapsed .forecast-account-details {
    display: none !important;
  }

  .forecast-account-details .forecast-action,
  .forecast-account-details .forecast-extra,
  .forecast-account-details .forecast-account-total {
    grid-column: 1 / -1 !important;
  }

  .forecast-account-details .forecast-base-amount {
    grid-column: 1 !important;
  }

  .forecast-account-details .forecast-quantity {
    grid-column: 2 !important;
  }

  .forecast-account-details .forecast-account-total {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    justify-items: start !important;
    align-items: center;
    min-width: 0 !important;
    padding-top: 2px;
  }

  .forecast-account-details .forecast-account-total .forecast-settle-button {
    grid-column: 2;
    grid-row: 1 / 3;
  }
}

@keyframes forecast-details-in {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}
