/* ==========================================================
   Componentes reutilizáveis
   ========================================================== */

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: 40px; padding: 0 var(--sp-4);
  border-radius: var(--radius-sm); border: 1px solid transparent;
  font-size: var(--fs-sm); font-weight: 600; text-decoration: none; white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); color: var(--on-primary); }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); color: var(--text); }

.btn-ghost { color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-danger { background: var(--expense); color: #fff; }
.btn-danger:hover { filter: brightness(.92); color: #fff; }

.btn-block { width: 100%; min-height: 44px; }

.icon-btn {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  display: inline-grid; place-items: center; color: var(--text-muted);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--on-primary); border-right-color: transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Formulários ---------- */
.form { display: grid; gap: var(--sp-5); }
.field { display: grid; gap: var(--sp-2); }
.field label { font-size: var(--fs-sm); font-weight: 600; }
.field-row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-2); }
.field-row a { font-size: var(--fs-sm); }

.input, .select, .textarea {
  width: 100%; min-height: 44px;
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.textarea { min-height: 96px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--text-muted); opacity: .8; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-muted); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent);
}
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--expense); }

.input-group { position: relative; }
.input-group .input { padding-right: 48px; }
.input-group .icon-btn { position: absolute; right: 2px; top: 2px; }

.field-hint  { font-size: var(--fs-xs); color: var(--text-muted); }
.field-error { font-size: var(--fs-xs); color: var(--expense); font-weight: 500; }
.field-error:empty { display: none; }

.form-alert {
  padding: var(--sp-3) var(--sp-4); border-radius: var(--radius-sm);
  background: var(--expense-soft); color: var(--expense); font-size: var(--fs-sm); font-weight: 500;
}
.form-alert.is-info { background: var(--info-soft); color: var(--info); }
.form-alert:empty { display: none; }

/* ---------- Painéis ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
  box-shadow: var(--shadow-sm);
}
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.panel-header h2 { font-size: var(--fs-lg); }

.grid { display: grid; gap: var(--sp-5); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* ---------- Estado vazio ---------- */
.empty {
  display: grid; justify-items: center; text-align: center; gap: var(--sp-3);
  padding: var(--sp-12) var(--sp-6);
  border: 1px dashed var(--border-strong); border-radius: var(--radius-lg);
  background: var(--surface);
}
.empty-icon {
  width: 56px; height: 56px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--info-soft); color: var(--info);
}
.empty h2 { font-size: var(--fs-lg); }
.empty p  { color: var(--text-muted); max-width: 46ch; }
.empty .btn { margin-top: var(--sp-2); }

/* ---------- Boas-vindas (passo a passo do primeiro acesso) ---------- */
.welcome {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--sp-8);
  box-shadow: var(--shadow-sm);
}
.welcome h2 { font-size: var(--fs-xl); }
.welcome > p { color: var(--text-muted); margin-top: var(--sp-2); }
.steps { list-style: none; padding: 0; margin-top: var(--sp-6); display: grid; gap: var(--sp-3); counter-reset: step; }
.step {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: var(--sp-4);
  padding: var(--sp-4); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-2);
  counter-increment: step;
}
.step::before {
  content: counter(step);
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--navy-800); color: #fff; font-weight: 700; font-size: var(--fs-sm);
}
.step h3 { font-size: var(--fs-md); }
.step p { font-size: var(--fs-sm); color: var(--text-muted); }

/* ---------- Selos ---------- */
.badge {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  padding: 2px var(--sp-2); border-radius: var(--radius-pill);
  font-size: var(--fs-xs); font-weight: 600;
  background: var(--surface-2); color: var(--text-muted);
}
.badge-income  { background: var(--income-soft);  color: var(--income); }
.badge-expense { background: var(--expense-soft); color: var(--expense); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-info    { background: var(--info-soft);    color: var(--info); }

/* ---------- Esqueleto de carregamento ---------- */
.skeleton {
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
  min-height: 1em;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- Toasts ---------- */
.toast-region {
  position: fixed; z-index: 100; right: var(--sp-5); bottom: var(--sp-5);
  display: grid; gap: var(--sp-2); width: min(380px, calc(100vw - 2 * var(--sp-4)));
  pointer-events: none;
}
.toast {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-4);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-left: 4px solid var(--info);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm);
  pointer-events: auto;
  animation: toast-in var(--dur) var(--ease);
}
.toast .icon { margin-top: 1px; color: var(--info); }
.toast-success { border-left-color: var(--income); }
.toast-success .icon { color: var(--income); }
.toast-error { border-left-color: var(--expense); }
.toast-error .icon { color: var(--expense); }
.toast .icon-btn { width: 28px; height: 28px; margin: -4px -4px 0 0; }
.toast.is-leaving { animation: toast-out var(--dur) var(--ease) forwards; }
@keyframes toast-in  { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-out { to   { opacity: 0; transform: translateY(8px); } }

/* ---------- Diálogo de confirmação ---------- */
.dialog {
  width: min(440px, calc(100vw - 2 * var(--sp-4)));
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.dialog::backdrop { background: var(--backdrop); }
.dialog[open] { animation: dialog-in var(--dur) var(--ease); }
@keyframes dialog-in { from { opacity: 0; transform: scale(.97); } }
.dialog-body { padding: var(--sp-6); }
.dialog-body h2 { font-size: var(--fs-lg); }
.dialog-body p { color: var(--text-muted); margin-top: var(--sp-2); }
.dialog-actions {
  display: flex; justify-content: flex-end; gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-6); border-top: 1px solid var(--border); background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ---------- Utilitários de espaçamento ---------- */
.stack > * + * { margin-top: var(--sp-4); }
.stack > .panel-header + * { margin-top: 0; }
.mt { margin-top: var(--sp-4); }
.divider { border: 0; border-top: 1px solid var(--border); margin-block: var(--sp-6) !important; }

/* Página centralizada simples (início e 404) */
.center-page {
  min-height: 100dvh; display: grid; place-items: center; padding: var(--sp-6);
}
.center-page .empty { max-width: 520px; }

/* Conteúdo das páginas internas só aparece depois de confirmar o login */
body.app:not(.is-ready) .content { visibility: hidden; }
body.app:not(.is-ready)::after {
  content: ""; position: fixed; left: 50%; top: 50%; width: 28px; height: 28px; margin: -14px 0 0 -14px;
  border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--primary);
  animation: spin .8s linear infinite;
}

.panel-danger { border-color: color-mix(in srgb, var(--expense) 35%, var(--border)); }
.panel-danger h2 { color: var(--expense); }
.btn-secondary.is-loading::after { border-color: var(--text); border-right-color: transparent; }
.btn-danger.is-loading::after { border-color: #fff; border-right-color: transparent; }

/* ==========================================================
   Etapa 4 — dados reais
   ========================================================== */
.text-xs { font-size: var(--fs-xs); }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.section-title { font-size: var(--fs-lg); margin: var(--sp-8) 0 var(--sp-4); }
.sidebar-balance-value.is-negative { color: #F2A29B; }

/* Selects com seta própria (aparência consistente entre navegadores) */
.select {
  appearance: none; -webkit-appearance: none;
  padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.select:disabled, .input:disabled, .input[readonly] { background-color: var(--surface-2); color: var(--text-muted); cursor: not-allowed; }

.icon-btn.is-danger:hover { color: var(--expense); background: var(--expense-soft); }
.icon-btn.is-success:hover { color: var(--income); background: var(--income-soft); }

.color-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; display: inline-block; }

/* ---------- Formulários em diálogo ---------- */
.dialog-form-wrap { width: min(560px, calc(100vw - 2 * var(--sp-4))); max-height: calc(100dvh - 2 * var(--sp-4)); }
.dialog-form { display: flex; flex-direction: column; max-height: calc(100dvh - 2 * var(--sp-4)); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-4) var(--sp-4) var(--sp-4) var(--sp-6); border-bottom: 1px solid var(--border); }
.dialog-head h2 { font-size: var(--fs-lg); }
.dialog-form .dialog-body { overflow-y: auto; gap: var(--sp-4); }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); }
.form-row > .field { min-width: 0; }

.segmented { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; padding: 4px; border: 0; border-radius: var(--radius-sm); background: var(--surface-2); }
.segmented-option { position: relative; }
.segmented-option input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.segmented-option span { display: grid; place-items: center; min-height: 38px; border-radius: 5px; font-weight: 600; font-size: var(--fs-sm); color: var(--text-muted); transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease); }
.segmented-option input:checked + span { background: var(--surface); box-shadow: var(--shadow-sm); color: var(--text); }
.segmented-option.is-expense input:checked + span { color: var(--expense); }
.segmented-option.is-income input:checked + span { color: var(--income); }
.segmented-option input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

.swatches { border: 0; padding: 0; }
.swatches legend { font-size: var(--fs-sm); font-weight: 600; margin-bottom: var(--sp-2); }
.swatch-list { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.swatch-option { position: relative; }
.swatch-option input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.swatch { display: block; width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong); }
.swatch-option input:checked + .swatch { box-shadow: 0 0 0 2px var(--text); }
.swatch-option input:focus-visible + .swatch { outline: 2px solid var(--focus); outline-offset: 3px; }

/* ---------- Esqueleto ---------- */
.skeleton-list { display: grid; gap: var(--sp-3); }
.skeleton-row { height: 56px; border-radius: var(--radius-md); }

/* ---------- Faixa de resumo e indicadores ---------- */
.summary-strip { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-6); padding-bottom: var(--sp-5); border-bottom: 1px solid var(--border); }
.summary-strip > div { display: grid; }
.summary-value { font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -0.02em; }

.period-caption { margin: calc(-1 * var(--sp-5)) 0 var(--sp-5); }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--sp-4); margin-bottom: var(--sp-5); }
.kpi { display: grid; gap: var(--sp-1); padding: var(--sp-5); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.kpi:first-child { background: var(--navy-800); border-color: var(--navy-800); color: var(--on-navy); }
.kpi:first-child .kpi-label, .kpi:first-child .kpi-sub { color: var(--on-navy-muted); }
.kpi:first-child .money-expense { color: #F2A29B; }
.kpi-label { font-size: var(--fs-sm); color: var(--text-muted); font-weight: 500; }
.kpi-value { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -0.02em; }
.kpi-sub { font-size: var(--fs-xs); color: var(--text-muted); }

.stat-strip { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-8); align-items: baseline; padding: var(--sp-4) 0; margin-bottom: var(--sp-4); border-block: 1px solid var(--border); }
.stat { display: grid; gap: 2px; }
.stat .money { font-weight: 700; font-size: var(--fs-lg); }
.stat-label { font-size: var(--fs-xs); color: var(--text-muted); }
.stat-muted { margin-left: auto; text-align: right; font-size: var(--fs-sm); }

/* ---------- Painel ---------- */
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-5); }
.panel-wide { grid-column: 1 / -1; }
.chart-box { position: relative; height: 260px; }
.donut-layout { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: var(--sp-5); align-items: center; }
.chart-box-donut { height: 160px; }
.legend { list-style: none; padding: 0; display: grid; gap: var(--sp-2); font-size: var(--fs-sm); }
.legend li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto auto; gap: var(--sp-2); align-items: center; }
.legend-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-pct { font-variant-numeric: tabular-nums; }

.figures { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-3); margin-bottom: var(--sp-5); }
.figures > div { padding: var(--sp-3); border-radius: var(--radius-md); background: var(--surface-2); }
.figures dt { font-size: var(--fs-xs); color: var(--text-muted); }
.figures dd { margin: 2px 0 0; font-weight: 700; }
.figures .is-alert { background: var(--expense-soft); }
.figures .is-alert dt, .figures .is-alert .money { color: var(--expense); }
.list-title { font-size: var(--fs-sm); color: var(--text-muted); font-weight: 600; margin-bottom: var(--sp-2); }

.tx-lines { list-style: none; padding: 0; display: grid; }
.tx-line { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto auto; align-items: center; gap: var(--sp-3); padding: var(--sp-3) 0; border-top: 1px solid var(--border); }
.tx-line:first-child { border-top: 0; }
.tx-line-main { display: grid; min-width: 0; }
.tx-line-desc { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-line .money { font-weight: 600; font-size: var(--fs-sm); }
.tx-meta { font-size: var(--fs-xs); color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.step.is-done { opacity: .7; }
.step.is-done::before { content: "✓"; background: var(--income); }

/* ---------- Barra de filtros ---------- */
.toolbar { display: grid; gap: var(--sp-3); margin-bottom: var(--sp-5); }
.toolbar-row { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; }
.toolbar-filters .select { width: auto; min-width: 150px; flex: 1 1 150px; }
.period-select { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.period-select > .select { width: auto; min-width: 190px; }
.period-custom { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.period-custom .input { width: auto; }
.search-box { position: relative; flex: 1 1 240px; }
.search-box .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.search-box .input { padding-left: 40px; }

/* ---------- Tabela de movimentações ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow-x: auto; }
.tx-table th { text-align: left; font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); background: var(--surface-2); }
.tx-table td { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); vertical-align: middle; font-size: var(--fs-sm); }
.tx-table tbody tr:last-child td { border-bottom: 0; }
.tx-table tbody tr:hover { background: var(--surface-2); }
.tx-table .col-date { white-space: nowrap; color: var(--text-muted); font-variant-numeric: tabular-nums; width: 1%; }
.tx-table .col-desc { min-width: 220px; }
.tx-desc { display: flex; align-items: center; gap: var(--sp-2); font-weight: 500; font-size: var(--fs-md); }
.tx-table .tx-meta { padding-left: 18px; }
.tx-table .col-amount { text-align: right; font-weight: 600; white-space: nowrap; }
.tx-table .col-actions { width: 1%; }
.tx-table .is-cancelled .tx-desc span, .tx-table .is-cancelled .col-amount { text-decoration: line-through; color: var(--text-muted); }
.row-actions { display: flex; justify-content: flex-end; gap: 2px; }
.row-actions .icon-btn { width: 34px; height: 34px; }

.pager { display: flex; align-items: center; justify-content: center; gap: var(--sp-4); margin-top: var(--sp-5); }
.empty-compact { padding: var(--sp-8) var(--sp-6); }

/* ---------- Contas ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--sp-4); }
.account-card {
  display: grid; gap: var(--sp-3); padding: var(--sp-5); padding-left: calc(var(--sp-5) + 4px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: inset 4px 0 0 var(--account-color);
}
.account-card.is-inactive { opacity: .7; }
.account-card-head { display: flex; justify-content: space-between; gap: var(--sp-2); align-items: flex-start; }
.account-card-head h3 { font-size: var(--fs-md); }
.account-card-balance { display: grid; }
.account-balance { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -0.02em; }
.card-actions { display: flex; gap: 2px; margin: 0 calc(-1 * var(--sp-2)) calc(-1 * var(--sp-2)); border-top: 1px solid var(--border); padding-top: var(--sp-2); }

/* ---------- Categorias ---------- */
.category-list { list-style: none; padding: 0; }
.category-row { display: flex; align-items: center; gap: var(--sp-3); min-height: 48px; border-top: 1px solid var(--border); }
.category-row:first-child { border-top: 0; }
.category-row.is-child { padding-left: var(--sp-6); }
.category-row.is-child .category-name { color: var(--text-muted); }
.category-row.is-inactive .category-name { color: var(--text-muted); text-decoration: line-through; }
.category-name { flex: 1; min-width: 0; }
.category-row .row-actions { opacity: .55; transition: opacity var(--dur-fast) var(--ease); }
.category-row:hover .row-actions, .category-row:focus-within .row-actions { opacity: 1; }
.figures dd { display: grid; }
.figure-note { font-size: var(--fs-xs); font-weight: 500; color: var(--text-muted); }
.figures .is-alert .figure-note { color: var(--expense); }

/* ==========================================================
   Etapa 5 — cartões e faturas
   ========================================================== */
.form-note { font-size: var(--fs-sm); color: var(--text-muted); background: var(--surface-2); border-radius: var(--radius-sm); padding: var(--sp-3) var(--sp-4); }
.form-note:empty { display: none; }
.icon-flip .icon { transform: scaleX(-1); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; background: none; }

.credit-card {
  position: relative; display: grid; gap: var(--sp-3); padding: var(--sp-5);
  border-radius: var(--radius-lg); color: #fff;
  background: linear-gradient(155deg, color-mix(in srgb, var(--card-color) 88%, #fff) 0%, var(--card-color) 55%, color-mix(in srgb, var(--card-color) 80%, #000) 100%);
  box-shadow: var(--shadow-md);
  outline: 3px solid transparent; outline-offset: 3px;
  transition: outline-color var(--dur-fast) var(--ease);
}
.credit-card.is-selected { outline-color: var(--focus); }
.credit-card.is-inactive { filter: grayscale(.7); opacity: .8; }
.credit-card-select { position: absolute; inset: 0; border-radius: inherit; z-index: 0; }
.credit-card-select:focus-visible { outline: 2px solid #fff; outline-offset: -4px; }
.credit-card > :not(.credit-card-select) { position: relative; z-index: 1; pointer-events: none; }
.credit-card .card-actions, .credit-card .card-actions * { pointer-events: auto; }
.credit-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-2); }
.credit-card h3 { font-size: var(--fs-md); }
.credit-card-muted { color: rgba(255, 255, 255, .78); }
.credit-card-available { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -0.02em; }
.credit-card .badge { background: rgba(255, 255, 255, .2); color: #fff; }
.credit-card .card-actions { border-top-color: rgba(255, 255, 255, .2); }
.credit-card .icon-btn { color: rgba(255, 255, 255, .85); }
.credit-card .icon-btn:hover { background: rgba(255, 255, 255, .15); color: #fff; }

.usage { height: 6px; border-radius: var(--radius-pill); background: rgba(255, 255, 255, .25); overflow: hidden; }
.usage-bar { display: block; height: 100%; width: 0; border-radius: inherit; background: #8FD3B4; }
.usage-bar.is-high { background: #F2A29B; }

.invoices-area { margin-top: var(--sp-6); }
.invoice-nav { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-5); }
.invoice-title { text-align: center; display: grid; }
.invoice-title h2 { font-size: var(--fs-xl); }
.invoice-summary { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--sp-4); padding: var(--sp-4) 0; border-block: 1px solid var(--border); margin-bottom: var(--sp-4); }
.invoice-summary > div { display: grid; gap: 4px; align-content: start; justify-items: start; }
.invoice-summary .money { font-weight: 700; }
.invoice-total { font-size: var(--fs-lg); }
.invoice-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-6); }
.invoice .tx-line { grid-template-columns: 10px minmax(0, 1fr) auto auto; }

/* ==========================================================
   Etapa 6 — recorrências, orçamentos e metas
   ========================================================== */
.tx-table .is-muted td { color: var(--text-muted); }
.reserved-note { color: var(--info); }

.month-nav { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-5); max-width: 420px; }
.month-label { font-size: var(--fs-xl); text-align: center; }
.budget-actions { margin-bottom: var(--sp-4); }

.budget-list { list-style: none; padding: 0; display: grid; gap: var(--sp-3); }
.budget-item { padding: var(--sp-4) var(--sp-5); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); display: grid; gap: var(--sp-3); }
.budget-item.is-over { border-color: color-mix(in srgb, var(--expense) 40%, var(--border)); }
.budget-head { display: flex; align-items: center; gap: var(--sp-3); }
.budget-name { display: flex; align-items: center; gap: var(--sp-2); font-weight: 600; flex: 1; min-width: 0; }
.budget-track, .goal-track { height: 8px; border-radius: var(--radius-pill); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); overflow: hidden; }
.budget-bar, .goal-bar { display: block; height: 100%; width: 0; border-radius: inherit; transition: width var(--dur) var(--ease); }
.budget-bar.is-ok { background: var(--income); }
.budget-bar.is-near { background: var(--warning); }
.budget-bar.is-over { background: var(--expense); }
.budget-figures { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--sp-2); font-size: var(--fs-sm); }
.budget-figures .money { font-weight: 600; }

.mini-bars { list-style: none; padding: 0; display: grid; gap: var(--sp-4); }
.mini-bar-head { display: flex; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-2); }
.mini-bar-name { display: flex; align-items: center; gap: var(--sp-2); font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.goal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--sp-4); }
.goal-card { display: grid; gap: var(--sp-4); align-content: start; padding: var(--sp-5); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.goal-card.is-paused, .goal-card.is-done { background: var(--surface-2); }
.goal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--sp-3); }
.goal-head h3 { font-size: var(--fs-lg); }
.goal-amounts { display: flex; align-items: baseline; gap: var(--sp-2); flex-wrap: wrap; }
.goal-saved { font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -0.02em; }
.goal-pct { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--primary); }
.goal-bar { background: var(--navy-500); }
.goal-bar.is-reached { background: var(--income); }
.goal-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-3); font-size: var(--fs-sm); }
.goal-facts dt { font-size: var(--fs-xs); color: var(--text-muted); }
.goal-facts dd { margin: 0; font-weight: 600; }
.goal-notes { list-style: none; padding: 0; display: grid; gap: var(--sp-1); font-size: var(--fs-sm); color: var(--text-muted); }
.goal-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); border-top: 1px solid var(--border); padding-top: var(--sp-3); }
.goal-actions .row-actions { margin-left: auto; }
.goal-history { border-top: 1px solid var(--border); padding-top: var(--sp-2); }
.goal-line { grid-template-columns: minmax(0, 1fr) auto auto auto; }
.badge { white-space: nowrap; }
.goal-line { grid-template-columns: max-content minmax(0, 1fr) auto auto; }
.goal-line .tx-line-desc { overflow: visible; }
