/* ==========================================================================
   FinanKey 4.0 - Componentes
   ========================================================================== */

/* --------------------------------------------------------------------------
   Card
   -------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  box-shadow: var(--shadow-sm);
}

.card--flat {
  box-shadow: none;
  background: var(--surface-2);
}

.card--inset {
  background: var(--surface-inset);
  border-color: transparent;
  box-shadow: none;
}

.card--pad-sm {
  padding: var(--sp-3);
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}

/* --------------------------------------------------------------------------
   Botoes
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 2.75rem;
  padding: 0 var(--sp-4);
  border-radius: var(--r-md);
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.01em;
  border: 1px solid transparent;
  transition: background var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out), opacity var(--dur-fast);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  text-align: center;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

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

.btn--primary {
  background: var(--accent);
  color: var(--accent-contrast);
}
.btn--secondary {
  background: var(--surface-3);
  color: var(--text);
  border-color: var(--border);
}
.btn--ghost {
  background: transparent;
  color: var(--text-2);
}
.btn--danger {
  background: var(--negative);
  color: #fff;
}
.btn--danger-soft {
  background: var(--negative-soft);
  color: var(--negative-text);
}
.btn--block {
  width: 100%;
}
.btn--sm {
  min-height: 2.125rem;
  padding: 0 var(--sp-3);
  font-size: var(--fs-sm);
  border-radius: var(--r-sm);
}

@media (hover: hover) {
  .btn--primary:hover:not(:disabled) {
    background: var(--accent-hover);
  }
  .btn--secondary:hover:not(:disabled) {
    background: var(--surface-inset);
  }
  .btn--ghost:hover:not(:disabled) {
    background: var(--surface-3);
  }
}

/* Botao so de icone */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--r-md);
  color: var(--text-2);
  flex: none;
  transition: background var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.icon-btn svg {
  width: 20px;
  height: 20px;
}
@media (hover: hover) {
  .icon-btn:hover {
    background: var(--surface-3);
    color: var(--text);
  }
}
.icon-btn:active {
  background: var(--surface-inset);
}

/* --------------------------------------------------------------------------
   Chips e badges
   -------------------------------------------------------------------------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  height: 2rem;
  padding: 0 var(--sp-3);
  border-radius: var(--r-full);
  background: var(--surface-3);
  border: 1px solid transparent;
  color: var(--text-2);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}
.chip[aria-pressed="true"],
.chip.is-active {
  background: var(--accent-soft);
  color: var(--accent-text);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px var(--sp-2);
  border-radius: var(--r-full);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.02em;
  background: var(--neutral-soft);
  color: var(--text-2);
  white-space: nowrap;
}
.badge--pos {
  background: var(--positive-soft);
  color: var(--positive-text);
}
.badge--neg {
  background: var(--negative-soft);
  color: var(--negative-text);
}
.badge--warn {
  background: var(--warning-soft);
  color: var(--warning-text);
}
.badge--accent {
  background: var(--accent-soft);
  color: var(--accent-text);
}

/* --------------------------------------------------------------------------
   Segmented control (abas)
   -------------------------------------------------------------------------- */
.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 2px;
  padding: 3px;
  background: var(--surface-inset);
  border-radius: var(--r-md);
}

.segmented__item {
  min-height: 2.25rem;
  padding: 0 var(--sp-2);
  border-radius: calc(var(--r-md) - 3px);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-2);
  transition: background var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.segmented__item[aria-selected="true"] {
  background: var(--surface);
  color: var(--text);
  font-weight: var(--fw-semibold);
  box-shadow: var(--shadow-sm);
}

/* --------------------------------------------------------------------------
   Campos de formulario
   -------------------------------------------------------------------------- */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.field__label {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-2);
}

.field__hint {
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.field__error {
  font-size: var(--fs-xs);
  color: var(--negative-text);
  font-weight: var(--fw-medium);
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 2.875rem;
  padding: var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: var(--fs-base);
  transition: border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out);
  /* 16px evita o zoom automatico do iOS ao focar */
}

.textarea {
  min-height: 5rem;
  resize: vertical;
  line-height: var(--lh-normal);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-3);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

.input[aria-invalid="true"],
.select[aria-invalid="true"] {
  border-color: var(--negative);
}

/*
 * Select compacto, para listas com um por linha (revisao da importacao).
 * Reduz ALTURA, nunca a fonte: abaixo de 16px o iOS da zoom sozinho ao
 * focar, e recuperar dali estraga o resto da tela.
 */
.select--sm {
  min-height: 2.25rem;
  padding-top: var(--sp-2);
  padding-bottom: var(--sp-2);
}

.select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: var(--sp-10);
  color: var(--text);
}

/* Campo de dinheiro */
.money-field {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding-inline: var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  transition: border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out);
}
.money-field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}
.money-field__prefix {
  color: var(--text-3);
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  flex: none;
}
.money-field .input {
  border: none;
  background: none;
  padding-inline: 0;
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
}
.money-field .input:focus {
  box-shadow: none;
}

/* Switch */
.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  min-height: 2.75rem;
  width: 100%;
}
.switch__track {
  position: relative;
  width: 2.75rem;
  height: 1.625rem;
  border-radius: var(--r-full);
  background: var(--border-strong);
  flex: none;
  transition: background var(--dur-base) var(--ease-out);
}
.switch__track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 1.125rem;
  height: 1.125rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur-base) var(--ease-out);
}
.switch[aria-checked="true"] .switch__track {
  background: var(--accent);
}
.switch[aria-checked="true"] .switch__track::after {
  transform: translateX(1.125rem);
}

/* --------------------------------------------------------------------------
   Lista de itens (lancamentos, parcelas, dividas)
   -------------------------------------------------------------------------- */
.list {
  display: flex;
  flex-direction: column;
}

.list__item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border);
  text-align: left;
  width: 100%;
  transition: background var(--dur-fast) var(--ease-out);
}
.list__item:last-child {
  border-bottom: none;
}
.list__item:active {
  background: var(--surface-2);
}

.list__icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  flex: none;
  background: var(--neutral-soft);
  color: var(--text-2);
}
.list__icon svg {
  width: 18px;
  height: 18px;
}
.list__icon--pos {
  background: var(--positive-soft);
  color: var(--positive-text);
}
.list__icon--neg {
  background: var(--negative-soft);
  color: var(--negative-text);
}
.list__icon--accent {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.list__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.list__title {
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list__meta {
  font-size: var(--fs-xs);
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.list__amount {
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
  flex: none;
  text-align: right;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Estados vazios
   -------------------------------------------------------------------------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--sp-3);
  padding: var(--sp-8) var(--sp-4);
  color: var(--text-3);
}
.empty__icon {
  width: 3rem;
  height: 3rem;
  border-radius: var(--r-lg);
  display: grid;
  place-items: center;
  background: var(--surface-3);
  color: var(--text-3);
}
.empty__icon svg {
  width: 24px;
  height: 24px;
}
.empty__title {
  font-size: var(--fs-base);
  font-weight: var(--fw-semibold);
  color: var(--text-2);
}
.empty__text {
  font-size: var(--fs-sm);
  max-width: 26ch;
}

/* --------------------------------------------------------------------------
   Sheet (modal deslizante)
   -------------------------------------------------------------------------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-sheet);
  background: var(--overlay);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fk-fade var(--dur-base) var(--ease-out);
}

.sheet {
  width: 100%;
  max-width: var(--shell-max);
  max-height: 92dvh;
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: fk-slide-up var(--dur-slow) var(--ease-out);
}

.sheet__handle {
  width: 2.25rem;
  height: 4px;
  border-radius: var(--r-full);
  background: var(--border-strong);
  margin: var(--sp-3) auto var(--sp-1);
  flex: none;
  position: relative;
  cursor: grab;
}

/* 4px de altura é impossível de acertar com o dedo. O pseudo-elemento estica
   a área de toque para 44px sem mudar o desenho da barrinha. */
.sheet__handle::after {
  content: "";
  position: absolute;
  inset: -20px -40px;
}

/* touch-action: none nas zonas de arrasto, senão o navegador tenta rolar a
   página no mesmo gesto e a folha só treme. */
.sheet__handle,
.sheet__head {
  touch-action: none;
}

.sheet--arrastando {
  cursor: grabbing;
  /* Sem transição durante o arrasto: a folha tem que colar no dedo. */
  transition: none !important;
}
.sheet--arrastando .sheet__handle {
  cursor: grabbing;
  background: var(--text-muted);
}

.sheet__head {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4) var(--sp-3);
  border-bottom: 1px solid var(--border);
  flex: none;
}

.sheet__titles {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sheet__title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.02em;
  line-height: var(--lh-snug);
}

.sheet__subtitle {
  font-size: var(--fs-sm);
  color: var(--text-3);
  line-height: var(--lh-snug);
}

.sheet__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.sheet__foot {
  flex: none;
  padding: var(--sp-3) var(--sp-4);
  padding-bottom: calc(var(--sp-3) + var(--safe-bottom));
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  gap: var(--sp-3);
}
.sheet__foot .btn {
  flex: 1;
}

@keyframes fk-fade {
  from {
    opacity: 0;
  }
}
@keyframes fk-slide-up {
  from {
    transform: translateY(100%);
  }
}

/* --------------------------------------------------------------------------
   Toast
   -------------------------------------------------------------------------- */
.toast-host {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--nav-h) + var(--safe-bottom) + var(--sp-3));
  z-index: var(--z-toast);
  width: min(calc(100% - var(--sp-8)), 26rem);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--text);
  color: var(--bg);
  font-size: var(--fs-md);
  font-weight: var(--fw-medium);
  box-shadow: var(--shadow-lg);
  animation: fk-toast-in var(--dur-base) var(--ease-out);
  pointer-events: auto;
}
.toast svg {
  width: 18px;
  height: 18px;
  flex: none;
}
.toast--error {
  background: var(--negative);
  color: #fff;
}
.toast--success {
  background: var(--positive);
  color: #fff;
}
.toast__action {
  margin-left: auto;
  font-weight: var(--fw-semibold);
  text-decoration: underline;
  flex: none;
  color: inherit;
}

@keyframes fk-toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* --------------------------------------------------------------------------
   Barra de progresso / medidor
   -------------------------------------------------------------------------- */
.meter {
  height: 8px;
  border-radius: var(--r-full);
  background: var(--surface-inset);
  overflow: hidden;
}
.meter__fill {
  height: 100%;
  border-radius: var(--r-full);
  background: var(--accent);
  transition: width var(--dur-slow) var(--ease-out);
}
.meter__fill--pos {
  background: var(--positive);
}
.meter__fill--warn {
  background: var(--warning);
}
.meter__fill--neg {
  background: var(--negative);
}

/* --------------------------------------------------------------------------
   Skeleton
   -------------------------------------------------------------------------- */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface-3) 25%,
    var(--surface-inset) 37%,
    var(--surface-3) 63%
  );
  background-size: 400% 100%;
  animation: fk-shimmer 1.4s ease infinite;
  border-radius: var(--r-sm);
}
@keyframes fk-shimmer {
  from {
    background-position: 100% 50%;
  }
  to {
    background-position: 0 50%;
  }
}

/* --------------------------------------------------------------------------
   Divisor rotulado
   -------------------------------------------------------------------------- */
.divider {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  color: var(--text-3);
  font-size: var(--fs-xs);
}
.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ==========================================================================
   Gráficos
   ========================================================================== */

.donut {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
}

.donut > svg {
  display: block;
  /* Sombra suave por baixo do anel, para ele descolar da superfície */
  filter: drop-shadow(0 2px 4px rgba(16, 24, 40, 0.12));
}

.donut__center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  pointer-events: none;
  text-align: center;
  padding: 0 var(--sp-6);
}

.donut__value {
  font-size: var(--fs-base);
  font-weight: var(--fw-bold);
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--text);
}

/* ---- Legenda ---- */
.legend {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  min-width: 0;
  flex: 1;
}

.legend__item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
  padding: 2px 0;
}

.legend__swatch {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  flex: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 1px 1px rgba(16, 24, 40, 0.15);
}

.legend__name {
  flex: 1;
  min-width: 0;
  font-size: var(--fs-sm);
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend__value {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text);
  flex: none;
}

.legend__share {
  font-size: var(--fs-2xs);
  color: var(--text-3);
  width: 2.25rem;
  text-align: right;
  flex: none;
  font-variant-numeric: tabular-nums;
}

.legend--inline {
  flex-direction: row;
  justify-content: center;
  gap: var(--sp-4);
  flex: none;
}

.legend__chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  color: var(--text-2);
  font-weight: var(--fw-medium);
}

/* ---- Sparkline ---- */
.sparkline {
  width: 100%;
  line-height: 0;
}

/* ---- Barra de participação ---- */
.share-bar {
  display: flex;
  height: 10px;
  border-radius: var(--r-full);
  overflow: hidden;
  background: var(--surface-inset);
  box-shadow: var(--inset-1);
  gap: 2px;
  padding: 0;
}

.share-bar__seg {
  display: block;
  height: 100%;
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0));
  transition: width var(--dur-slow) var(--ease-out);
}
.share-bar__seg:first-child {
  border-radius: var(--r-full) 0 0 var(--r-full);
}
.share-bar__seg:last-child {
  border-radius: 0 var(--r-full) var(--r-full) 0;
}

.chart {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  min-width: 0;
}

/* SVG dimensionado por CSS: o atributo height não aceita "auto". */
.chart > svg {
  display: block;
  width: 100%;
  height: auto;
}

.sparkline > svg {
  display: block;
  width: 100%;
  height: 44px;
}

/* Nome da categoria tem prioridade sobre o valor na legenda. */
.legend__value {
  font-size: var(--fs-xs);
}
.legend__name {
  flex: 1 1 auto;
}

/* --------------------------------------------------------------------------
   Grade de ações

   Oito botões do mesmo tamanho empilhados viravam uma parede: nada se
   destacava e era preciso ler todos para achar o que se queria. A ação
   principal fica sozinha, larga; o resto vira azulejo de dois em dois.
   -------------------------------------------------------------------------- */
.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-2);
}

.action-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 5.25rem;
  padding: var(--sp-3) var(--sp-2);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  text-align: center;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}
.action-tile:active {
  transform: scale(0.97);
  background: var(--surface-3, var(--surface-2));
}
.action-tile__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--r-full);
  background: var(--surface);
  color: var(--text-muted);
  flex: none;
}
.action-tile__label {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  line-height: var(--lh-tight, 1.2);
  /* Rótulo de duas linhas no máximo: "Duplicar para hoje" não pode empurrar
     a altura do azulejo e desalinhar a grade. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Botão com rótulo em duas alturas: título e a explicação do número. */
.btn__stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  line-height: var(--lh-tight, 1.2);
}
.btn__sub {
  font-size: var(--fs-xs);
  font-weight: var(--fw-regular, 400);
  opacity: 0.72;
}
/* O botão cresce quando tem duas linhas — sem isso o texto encosta na borda. */
.btn--block:has(.btn__stack) {
  min-height: 3.5rem;
  padding-block: var(--sp-2);
}

/* ==========================================================================
   Feixe de luz na borda

   Aquela borda colorida que gira, do tipo que a Meta e a OpenAI usam para
   dizer "tem inteligencia trabalhando aqui". Em CSS puro de proposito: a
   versao pronta que existe por ai e um componente React, e trazer React
   inteiro para um app que nao tem React sairia mais caro que a animacao.

   COMO ELE GIRA, e por que nao do jeito obvio

   O jeito elegante seria animar o angulo de um conic-gradient. So que angulo
   guardado em variavel nao interpola: ele pula de 0 para 360 e a borda fica
   parada. Para interpolar, a variavel precisa ser registrada com tipo -- e
   nem todo navegador que aceita registrar pela API em JS aceita a regra
   @property no CSS. O efeito sumia sem qualquer aviso.

   Entao aqui o que gira e um ELEMENTO, com transform. Isso funciona em tudo,
   e da para ver se esta funcionando.

   A montagem tem tres camadas:
     ::before  quadrado colorido girando, maior que o cartao
     ::after   o miolo por cima dele, deixando so a moldura a mostra
     conteudo  o botao normal, acima de tudo
   ========================================================================== */

.beam {
  position: relative;
  isolation: isolate;
  /*
   * `clip`, e nao `hidden`.
   *
   * Os dois escondem o quadrado girante, mas `hidden` transforma o elemento
   * num CONTAINER DE ROLAGEM: o quadrado de 240% vira area rolavel invisivel,
   * e o navegador passa a mostrar barra de rolagem que nao leva a lugar
   * nenhum -- a barra anda e a tela fica parada. `clip` corta pelo mesmo
   * lugar sem criar rolagem.
   *
   * Este app ja tinha sido mordido por isso antes, num `overflow-x: hidden`
   * que quebrou o scroll de toque da pagina inteira.
   */
  overflow: hidden;      /* reserva para navegador antigo */
  overflow: clip;
}

.beam::before {
  content: "";
  position: absolute;
  z-index: -2;
  left: 50%;
  top: 50%;
  width: 240%;
  aspect-ratio: 1;
  translate: -50% -50%;
  background: conic-gradient(
    #4f9cff, #6f7cff, #a06bff, #e05fd0, #ff5fa2, #ff8a5f, #ffb545, #7cc4ff, #4f9cff
  );
  animation: fk-beam-girar 3.4s linear infinite;
  pointer-events: none;
}

/*
 * O miolo. `background: inherit` copia o fundo do proprio cartao, entao a
 * moldura funciona em botao claro, botao escuro e cartao interno sem precisar
 * saber a cor de cada um.
 */
.beam::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 1.5px;
  border-radius: inherit;
  background: inherit;
  pointer-events: none;
}

@keyframes fk-beam-girar {
  to { rotate: 360deg; }
}

/* Movimento reduzido: a moldura continua colorida, so para de girar. */
@media (prefers-reduced-motion: reduce) {
  :root:not([data-movimento="sempre"]) .beam::before {
    animation: none;
  }
}
:root[data-movimento="reduzido"] .beam::before {
  animation: none;
}

/* --------------------------------------------------------------------------
   A moldura numa FOLHA inteira

   O quadrado girante de 240% funciona num cartao largo e baixo. Numa folha
   alta ele fica enorme, e girar uma area dessas a cada quadro custa caro no
   celular. Aqui ele encolhe para 130% e roda mais devagar: numa altura dessas
   a luz percorre muito mais borda por volta, entao o mesmo tempo de animacao
   pareceria o dobro de rapido.

   A moldura tambem e mais grossa (2px contra 1,5px): numa superficie grande,
   um fio de 1,5px sumeria.
   -------------------------------------------------------------------------- */
.beam--folha::before {
  /*
   * Medido em vmax, e nao em % do elemento.
   *
   * O quadrado do cartao usa 240% da LARGURA. Numa folha alta isso da um
   * quadrado que cobre so uma faixa do meio: a cor aparecia num pedaco das
   * laterais e o resto da borda ficava apagado, parecendo defeito. Em vmax o
   * quadrado cobre a folha inteira em qualquer tela.
   */
  width: 160vmax;
  animation-duration: 7s;
  opacity: 0.95;
}

/* Moldura mais grossa: num painel deste tamanho, um fio de 1,5px some. */
.beam--folha::after {
  inset: 3px;
}

/*
 * A folha nasce com o cantinho de baixo reto (ela encosta na borda da tela).
 * Sem herdar isso, o miolo do ::after apareceria arredondado por baixo e
 * deixaria duas fatias coloridas nos cantos inferiores.
 */
.beam--folha {
  overflow: hidden;      /* reserva para navegador antigo */
  overflow: clip;
}

/* Variante discreta, para o cartao se identificar como sendo da leitura
   inteligente sem ficar chamando atencao o tempo todo. */
.beam--calmo::before {
  /* 2,25s. Comecou em 9s e foi dobrando: aos 9 nao dava para ver a luz andar,
     aos 4,5 dava, e aqui ela circula rapido o bastante para o botao chamar
     atencao sozinho no meio da tela. */
  animation-duration: 2.25s;
  opacity: 0.75;
}

/* ==========================================================================
   Esqueleto de carregamento

   Mostrado enquanto os dados nao chegaram do servidor. Existe porque o app
   pintava a tela com o estado vazio e a pessoa via "R$ 0,00" por um instante
   antes dos numeros reais aparecerem -- feio, e enganoso.
   ========================================================================== */

.esqueleto__barra {
  border-radius: var(--r-sm);

  /*
   * Duas camadas: um brilho que desliza por cima de um fundo sólido.
   *
   * A primeira versão calculava a cor do brilho com color-mix a partir dos
   * tokens do tema. Parecia elegante e não pintava nada: color-mix com var()
   * dentro falha na hora de resolver o valor em alguns navegadores, e quando
   * falha a declaração inteira some — a barra ficava invisível, sem erro
   * nenhum no console.
   *
   * Cinza translúcido resolve nos dois temas: clareia sobre fundo escuro e
   * escurece sobre fundo claro.
   */
  background-color: var(--surface-2);
  background-image: linear-gradient(
    90deg,
    rgba(128, 128, 128, 0) 0%,
    rgba(128, 128, 128, 0.22) 50%,
    rgba(128, 128, 128, 0) 100%
  );
  background-repeat: no-repeat;
  background-size: 220% 100%;

  animation: fk-esqueleto 1.4s ease-in-out infinite;
}

@keyframes fk-esqueleto {
  0%   { background-position: 120% 0; }
  100% { background-position: -20% 0; }
}

/* Sem movimento a barra fica parada, e continua dizendo 'ainda vem'. */
@media (prefers-reduced-motion: reduce) {
  :root:not([data-movimento="sempre"]) .esqueleto__barra {
    animation: none;
  }
}
:root[data-movimento="reduzido"] .esqueleto__barra {
  animation: none;
}
