/* =========================================================
   Finanças — estilos
   ========================================================= */

/* ---------- Tema claro (padrão) ---------- */
:root {
  color-scheme: light;

  --bg: #FAFAF8;
  --surface: #FFFFFF;
  --surface-2: #FAFAF8;
  --ink: #121316;
  --on-ink: #FFFFFF;
  --ink-2: #4A4E57;
  --muted: #8B9099;
  --placeholder: #B5B8BE;
  --line: #ECECE7;
  --line-2: #F3F3EF;
  --line-strong: #D6D6D0;
  --topbar: rgba(255, 255, 255, .86);

  --ok: #2FAE7A;
  --warn: #E3A440;
  --danger: #E5484D;
  --danger-soft: #FDF1F1;

  /* Categorias */
  /* Paleta validada para daltonismo (ordem: contas, compras, alimentação,
     assinaturas, online, veículo, lazer, transporte, fatura) */
  --c-contas: #2A78D6;
  --c-compras: #EB6834;
  --c-alimentacao: #1BAF7A;
  --c-assinaturas: #EDA100;
  --c-online: #E87BA4;
  --c-veiculo: #008300;
  --c-lazer: #6250D6;
  --c-transporte: #E34948;
  --c-fatura: #4A4A48;
  --c-save: #3B6FD8;

  /* Cartões coloridos */
  --income-bg: linear-gradient(135deg, #F3FBF6 0%, #DDF3E6 100%);
  --income-border: #CFEBDB;
  --income-ink: #17633F;
  --income-sub: #4F8A6B;

  --expense-bg: linear-gradient(135deg, #FEF5F5 0%, #FBE1E1 100%);
  --expense-border: #F5D3D3;
  --expense-ink: #A3292D;
  --expense-sub: #B0605F;

  --save-bg: linear-gradient(135deg, #F4F8FF 0%, #DFE9FD 100%);
  --save-border: #D3E1FB;
  --save-ink: #1E4FA3;
  --save-sub: #5B7DB8;
  --save-btn: #EAF1FE;
  --save-btn-hover: #DCE7FD;

  --help-bg: #2A78D6;
  --help-ink: #FFFFFF;

  --chip-bg: rgba(255, 255, 255, .7);
  --chip-bg-hover: #FFFFFF;

  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(18, 19, 22, .03), 0 12px 32px -16px rgba(18, 19, 22, .10);
  --shadow-lg: 0 24px 64px -20px rgba(18, 19, 22, .28);
  --backdrop: rgba(18, 19, 22, .28);

  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

/* ---------- Tema escuro ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0E0F11;
  --surface: #17181B;
  --surface-2: #1D1F23;
  --ink: #F2F2EF;
  --on-ink: #121316;
  --ink-2: #B9BCC3;
  --muted: #80858F;
  --placeholder: #5E626B;
  --line: #2A2C31;
  --line-2: #222428;
  --line-strong: #3A3D44;
  --topbar: rgba(14, 15, 17, .82);

  --danger-soft: rgba(229, 72, 77, .14);

  --c-contas: #3987E5;
  --c-compras: #D95926;
  --c-alimentacao: #199E70;
  --c-assinaturas: #C98500;
  --c-online: #D55181;
  --c-veiculo: #008300;
  --c-lazer: #9085E9;
  --c-transporte: #E66767;
  --c-fatura: #C8C7C2;
  --c-save: #6E9BF0;

  --income-bg: linear-gradient(135deg, #12211A 0%, #173527 100%);
  --income-border: #1F4433;
  --income-ink: #7EDDAC;
  --income-sub: #6FA88B;

  --expense-bg: linear-gradient(135deg, #251416 0%, #3A1B1E 100%);
  --expense-border: #4A2427;
  --expense-ink: #F59A9C;
  --expense-sub: #C07A7B;

  --save-bg: linear-gradient(135deg, #131B2B 0%, #1A2A48 100%);
  --save-border: #24375C;
  --save-ink: #9DBDF7;
  --save-sub: #7891BF;
  --save-btn: #18243A;
  --save-btn-hover: #1F2F4C;

  --help-bg: #3987E5;
  --help-ink: #FFFFFF;

  --chip-bg: rgba(255, 255, 255, .08);
  --chip-bg-hover: rgba(255, 255, 255, .16);

  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px -16px rgba(0, 0, 0, .6);
  --shadow-lg: 0 24px 64px -20px rgba(0, 0, 0, .8);
  --backdrop: rgba(0, 0, 0, .55);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background .3s, color .3s;
}

main { flex: 1; }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select { font: inherit; color: inherit; }
ul, ol { list-style: none; }
[hidden] { display: none !important; }

.container { width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 24px; }

.eyebrow {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--topbar);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.topbar__inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: 68px;
  gap: 16px;
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -.01em; font-size: 16px; }

.brand__mark {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: conic-gradient(
    var(--c-alimentacao) 0 38%,
    var(--c-contas) 38% 66%,
    var(--c-lazer) 66% 86%,
    var(--c-assinaturas) 86% 100%
  );
  -webkit-mask: radial-gradient(circle, transparent 5px, #000 5.5px);
          mask: radial-gradient(circle, transparent 5px, #000 5.5px);
}

.tabs {
  display: inline-flex;
  padding: 4px;
  background: var(--line-2);
  border-radius: 999px;
}

.tab {
  padding: 7px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  transition: color .2s, background .2s, box-shadow .2s;
}
.tab:hover { color: var(--ink); }
.tab.is-active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }

.topbar__right { justify-self: end; display: flex; align-items: center; gap: 8px; }

.month-picker { display: flex; align-items: center; gap: 4px; }
.month-picker__label { min-width: 128px; text-align: center; font-weight: 500; font-size: 14px; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--ink-2);
  transition: background .2s, color .2s;
}
.icon-btn:hover { background: var(--line-2); color: var(--ink); }

.icon-btn--ring { position: relative; border: 1px solid var(--line); }
.icon-btn--sm { width: 30px; height: 30px; }
.badge-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 2px var(--surface);
}
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: transform .15s, box-shadow .2s, background .2s;
}
.btn--primary { background: var(--ink); color: var(--on-ink); }
.btn--primary:hover { transform: translateY(-1px); box-shadow: 0 10px 24px -10px rgba(0, 0, 0, .55); }
.btn--ghost { background: var(--surface); border: 1px solid var(--line); color: var(--ink); }
.btn--ghost:hover { background: var(--line-2); }
.btn--save { background: var(--save-btn); color: var(--save-ink); border: 1px solid var(--save-border); }
.btn--save:hover { background: var(--save-btn-hover); }

.page-head__actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Views ---------- */
.view { display: none; padding-bottom: 48px; }
.view.is-active { display: block; animation: fadeUp .4s ease both; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 44px 0 28px;
}

h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.1;
  letter-spacing: -.02em;
}

h2 { font-size: 15px; font-weight: 600; letter-spacing: -.005em; }

/* ---------- KPIs ---------- */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.kpi {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}

.kpi__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi__actions { display: flex; gap: 6px; }
.kpi__label { font-size: 13px; color: var(--muted); }

.kpi__value {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(26px, 3vw, 34px);
  letter-spacing: -.02em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.kpi__value.is-negative { color: var(--danger); }

.kpi__hint { font-size: 13px; color: var(--muted); }

.kpi--income { background: var(--income-bg); border-color: var(--income-border); }
.kpi--income .kpi__value, .kpi--income .kpi__action { color: var(--income-ink); }
.kpi--income .kpi__label, .kpi--income .kpi__hint { color: var(--income-sub); }

.kpi--expense { background: var(--expense-bg); border-color: var(--expense-border); }
.kpi--expense .kpi__value { color: var(--expense-ink); }
.kpi--expense .kpi__label, .kpi--expense .kpi__hint { color: var(--expense-sub); }

.kpi--save { background: var(--save-bg); border-color: var(--save-border); }
.kpi--save .kpi__value, .kpi--save .kpi__action { color: var(--save-ink); }
.kpi--save .kpi__label, .kpi--save .kpi__hint { color: var(--save-sub); }

.kpi__action {
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--chip-bg);
  transition: background .2s;
}
.kpi__action:hover { background: var(--chip-bg-hover); }
.kpi__label, .kpi__action { white-space: nowrap; }
.kpi__action--icon { display: grid; place-items: center; width: 28px; height: 26px; padding: 0; }

.progress {
  height: 6px;
  background: var(--line-2);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 4px;
}
.progress__bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--ink);
  transition: width .6s cubic-bezier(.2, .8, .2, 1), background .3s;
}
.progress__bar[data-nivel="warn"] { background: var(--warn); }
.progress__bar[data-nivel="danger"] { background: var(--danger); }

/* ---------- Cards / Grid ---------- */
.grid {
  display: grid;
  grid-template-columns: 5fr 7fr;
  gap: 16px;
  align-items: start;
}
.grid--even { grid-template-columns: 1fr 1fr; }
.stack { display: grid; gap: 16px; min-width: 0; }
.card--rec .card__note { display: block; margin-top: 4px; }
.item__rec { display: inline-flex; align-items: center; gap: 3px; vertical-align: -2px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  min-width: 0;
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

/* ---------- Gráfico ---------- */
.chart-wrap {
  position: relative;
  width: 100%;
  max-width: 280px;
  height: 280px;
  margin: 4px auto 24px;
}

.chart-center, .chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  text-align: center;
}
.chart-center span { font-size: 12px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.chart-center strong {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 26px;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}

.chart-empty__ring {
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  border: 30px solid var(--line-2);
}
.chart-empty p { font-size: 13px; color: var(--muted); }

.legend { display: grid; gap: 2px; }
.legend li {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid var(--line-2);
  font-size: 14px;
}
.legend li:first-child { border-top: 0; }
.legend__pct { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.legend__val { font-weight: 500; font-variant-numeric: tabular-nums; min-width: 96px; text-align: right; }

.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }

/* ---------- Select ---------- */
.select { position: relative; }
.select::after {
  content: '';
  position: absolute;
  right: 14px;
  top: 50%;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--ink-2);
  border-bottom: 1.5px solid var(--ink-2);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.select select {
  appearance: none;
  -webkit-appearance: none;
  height: 36px;
  padding: 0 36px 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
  cursor: pointer;
  transition: border-color .2s;
}
.select select:hover, .select select:focus { border-color: var(--line-strong); outline: none; }

/* ---------- Lista ---------- */
.list { display: flex; flex-direction: column; max-height: 600px; overflow-y: auto; margin: 0 -8px; }

.item {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 14px;
  padding: 12px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s;
  animation: fadeUp .3s ease both;
}
.item + .item { box-shadow: inset 0 1px 0 var(--line-2); }
.item:hover { background: var(--surface-2); }

.item__icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--c) 14%, var(--surface));
  color: var(--c);
  font-weight: 600;
  font-size: 14px;
}

.item__body { display: flex; flex-direction: column; min-width: 0; }
.item__body strong { font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item__body span { font-size: 12.5px; color: var(--muted); }

.item__val { font-weight: 500; font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.item__val--save { color: var(--save-ink); }
.item__val--income { color: var(--income-ink); }

.item__del {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: var(--muted);
  opacity: .35;
  transition: opacity .2s, background .2s, color .2s;
}
.item:hover .item__del { opacity: 1; }
.item__del:hover { background: var(--danger-soft); color: var(--danger); }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  padding: 48px 16px;
  color: var(--muted);
  font-size: 14px;
}
.empty strong { color: var(--ink); font-weight: 500; font-size: 15px; }
.empty .btn { margin-top: 14px; }

/* ---------- Resumo ---------- */
.hero { padding: 36px; margin-bottom: 16px; }
.hero__top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.hero__period { font-size: 13px; color: var(--muted); }

.hero__statement {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(22px, 2.6vw, 30px);
  line-height: 1.35;
  letter-spacing: -.015em;
  max-width: 820px;
}
.hero__statement b { font-weight: 500; }

.insights { margin-top: 24px; display: grid; gap: 10px; }
.insights li {
  position: relative;
  padding-left: 22px;
  color: var(--ink-2);
  font-size: 14.5px;
}
.insights li b { color: var(--ink); font-weight: 600; }
.insights li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--muted);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  --s: var(--ok);
  background: color-mix(in srgb, var(--s) 12%, var(--surface));
  color: color-mix(in srgb, var(--s) 75%, var(--ink));
}
.status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--s); }
.status[data-nivel="warn"] { --s: var(--warn); }
.status[data-nivel="danger"] { --s: var(--danger); }
.status[data-nivel="neutral"] { --s: var(--muted); }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}
.stat {
  padding: 22px 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}
.stat span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.stat strong {
  display: block;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 26px;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat small { display: block; margin-top: 4px; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.breakdown { display: grid; gap: 20px; }
.bd__row { display: grid; gap: 10px; }
.bd__top { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.bd__name { flex: 1; font-weight: 500; }
.bd__count { color: var(--muted); font-size: 12.5px; }
.bd__val { font-weight: 500; font-variant-numeric: tabular-nums; }
.bd__track { height: 8px; background: var(--line-2); border-radius: 999px; overflow: hidden; }
.bd__fill {
  height: 100%;
  width: var(--w);
  background: var(--c);
  border-radius: inherit;
  transition: width .6s cubic-bezier(.2, .8, .2, 1);
}
.bd__pct { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 44px; text-align: right; }

.ranking { display: flex; flex-direction: column; counter-reset: rank; }
.ranking li {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  counter-increment: rank;
}
.ranking li + li { border-top: 1px solid var(--line-2); }
.ranking li::before {
  content: counter(rank, decimal-leading-zero);
  font-family: var(--serif);
  color: var(--muted);
  font-size: 15px;
}

/* ---------- Modal ---------- */
.dialog {
  margin: auto;
  width: min(460px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
}
.dialog[open] { animation: pop .22s cubic-bezier(.2, .8, .2, 1); }
.dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }

@keyframes pop {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: none; }
}

.dialog form, .dialog__body { display: flex; flex-direction: column; gap: 18px; padding: 28px; }
.dialog__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dialog__head h3 { font-family: var(--serif); font-weight: 400; font-size: 26px; letter-spacing: -.02em; line-height: 1.2; }
.dialog__head .icon-btn { margin: -6px -8px 0 0; }
.dialog__text { color: var(--ink-2); font-size: 14px; margin-top: -6px; }
.dialog__foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
#backupMain, #backupConfirm { display: flex; flex-direction: column; gap: 18px; }

.field { display: flex; flex-direction: column; gap: 8px; border: 0; min-width: 0; }
.field > span, .field > legend { font-size: 13px; font-weight: 500; color: var(--ink-2); padding: 0; margin-bottom: 0; }
fieldset.field > legend { margin-bottom: 8px; }
.field__opt { font-style: normal; font-weight: 400; color: var(--muted); }

.field input {
  height: 48px;
  width: 100%;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 15px;
  transition: border-color .2s, box-shadow .2s;
}
.field input::placeholder { color: var(--placeholder); }
.field input:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ink) 8%, transparent);
}

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.input-money { position: relative; }
.input-money > span {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 14px;
  pointer-events: none;
}
.input-money input { padding-left: 42px; font-variant-numeric: tabular-nums; }

/* Seletor Guardar / Resgatar */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  background: var(--line-2);
  border-radius: 999px;
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
  display: grid;
  place-items: center;
  height: 36px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: background .2s, color .2s, box-shadow .2s;
}
.segmented input:checked + label { background: var(--surface); color: var(--save-ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
.segmented input:focus-visible + label { outline: 2px solid var(--ink); outline-offset: 2px; }

/* Seletor de período (no cabeçalho da página) */
.segmented--inline { min-width: 220px; }

/* Select dentro de formulário */
.select--field select {
  width: 100%;
  height: 48px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  padding-left: 14px;
}

/* Seletor de categoria */
.cat-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cat-option { position: relative; }
.cat-option input { position: absolute; opacity: 0; pointer-events: none; }
.cat-option label {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.cat-option label:hover { border-color: var(--line-strong); }
.cat-option input:checked + label {
  border-color: var(--c);
  background: color-mix(in srgb, var(--c) 8%, var(--surface));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 16%, transparent);
}
.cat-option input:focus-visible + label { outline: 2px solid var(--ink); outline-offset: 2px; }

/* Opção "Repetir todo mês" */
.check {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.check:hover { border-color: var(--line-strong); }
.check:has(input:checked) { border-color: var(--ink); background: var(--surface-2); }
.check input { width: 18px; height: 18px; margin: 1px 0 0; flex: none; accent-color: var(--ink); cursor: pointer; }
.check strong { display: block; font-size: 14px; font-weight: 500; }
.check small { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }

.dialog__note {
  font-size: 13px;
  color: var(--ink-2);
  background: var(--surface-2);
  padding: 10px 14px;
  border-radius: 10px;
}

.form-error {
  font-size: 13px;
  color: var(--danger);
  background: var(--danger-soft);
  padding: 10px 14px;
  border-radius: 10px;
}

/* ---------- Histórico ---------- */
.card__note { font-size: 12.5px; color: var(--muted); }

.bar-wrap { position: relative; height: 320px; margin-bottom: 18px; }

.legend-inline { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 13px; color: var(--ink-2); }
.legend-inline li { display: inline-flex; align-items: center; gap: 8px; }
.line-swatch { width: 18px; height: 0; border-top: 2px dashed var(--ink); }

.card--table { margin-top: 16px; padding-bottom: 12px; }
.table-wrap { overflow-x: auto; margin: 0 -8px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; white-space: nowrap; }
.table th {
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  padding: 0 8px 10px;
  border-bottom: 1px solid var(--line);
}
.table td { padding: 13px 8px; border-bottom: 1px solid var(--line-2); font-variant-numeric: tabular-nums; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }
.table tbody tr { cursor: pointer; transition: background .15s; }
.table tbody tr:hover, .table tbody tr:focus-visible { background: var(--surface-2); outline: none; }
.table tbody tr.is-current td:first-child { font-weight: 600; }
.table tbody tr.is-current td:first-child::after { content: ' ·  atual'; font-weight: 400; color: var(--muted); font-size: 12px; }
.table tr.is-empty td:first-child { color: var(--muted); }
.table .is-negative { color: var(--danger); }
.muted { color: var(--muted); }
.delta { font-weight: 500; }
.delta[data-dir="up"] { color: var(--expense-ink); }
.delta[data-dir="down"] { color: var(--income-ink); }

/* ---------- Metas ---------- */
.goals-summary { margin: -12px 0 20px; color: var(--ink-2); font-size: 14px; }
.goals-summary b { color: var(--ink); font-weight: 600; }

.goals { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }

.goal {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: fadeUp .3s ease both;
}
.goal__head { display: flex; justify-content: space-between; gap: 12px; }
.goal__head h3 { font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.goal__meta { font-size: 12.5px; color: var(--muted); }
.goal__tools { display: flex; gap: 2px; margin: -4px -6px 0 0; }
.goal__tools .icon-btn { color: var(--muted); }
.goal__values { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.goal__values strong {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 30px;
  letter-spacing: -.02em;
  color: var(--save-ink);
}
.goal__values span { color: var(--muted); font-size: 14px; }
.goal__track { height: 10px; background: var(--line-2); border-radius: 999px; overflow: hidden; }
.goal__fill {
  height: 100%;
  width: var(--w);
  background: var(--c-save);
  border-radius: inherit;
  transition: width .6s cubic-bezier(.2, .8, .2, 1);
}
.goal.is-done .goal__fill { background: var(--ok); }
.goal.is-done .goal__values strong { color: var(--income-ink); }
.goal__foot { display: flex; align-items: center; gap: 12px; font-size: 13.5px; color: var(--ink-2); }
.goal__foot b { color: var(--ink); font-weight: 600; }
.goal__pct { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; flex: none; }
.goal__cta { align-self: flex-start; height: 38px; padding: 0 16px; font-size: 13px; margin-top: 2px; }

/* ---------- Backup ---------- */
.backup-status { font-size: 13.5px; color: var(--muted); margin-top: -6px; }
.backup-status b { color: var(--ink); font-weight: 500; }
.backup-actions { display: grid; gap: 10px; }
.backup-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  text-align: left;
  transition: border-color .2s, background .2s;
}
.backup-option:hover { border-color: var(--line-strong); background: var(--surface-2); }
.backup-option strong { display: block; font-size: 14px; font-weight: 600; }
.backup-option small { display: block; font-size: 12.5px; color: var(--muted); }
.backup-option__icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 12px;
  background: var(--save-btn);
  color: var(--save-ink);
}
.backup-summary { display: grid; gap: 8px; padding: 14px 16px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); font-size: 14px; color: var(--ink-2); }
.backup-summary b { color: var(--ink); font-weight: 600; }

.link { color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; font-size: inherit; }
.link:hover { color: var(--ink); }

/* ---------- Ajuda ---------- */
.help-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px 0 10px;
  border-radius: 999px;
  background: var(--help-bg);
  color: var(--help-ink);
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 6px 16px -8px var(--help-bg);
  transition: transform .15s, box-shadow .2s, filter .2s;
}
.help-btn:hover { transform: translateY(-1px); filter: brightness(1.06); box-shadow: 0 10px 22px -10px var(--help-bg); }
.help-btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.help-btn__pulse {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 2px var(--surface);
}
.help-btn__pulse::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--warn);
  animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse {
  from { transform: scale(1); opacity: .7; }
  to { transform: scale(2.6); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .help-btn__pulse::after { animation: none; }
}

.help-hint {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  margin-top: -6px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--save-btn);
  color: var(--save-ink);
  font-size: 13px;
  font-weight: 500;
  transition: background .2s;
}
.help-hint:hover { background: var(--save-btn-hover); }

.dialog--wide { width: min(680px, calc(100% - 32px)); max-height: min(86vh, 860px); }
.dialog--wide .dialog__body { max-height: inherit; }

.faqs { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 0; margin: 0 -6px; padding: 0 6px 4px; }

.faqs:focus { outline: none; }
.faq {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  transition: border-color .2s, background .2s;
}
.faq[open] { border-color: var(--line-strong); background: var(--surface-2); }
.faq summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
  font-size: 14.5px;
  font-weight: 600;
  border-radius: 14px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary span:not(.faq__icon) { flex: 1; }
.faq summary:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.faq__icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 10px;
  background: var(--save-btn);
  color: var(--save-ink);
}
.faq__chevron { color: var(--muted); transition: transform .2s; flex: none; }
.faq[open] .faq__chevron { transform: rotate(180deg); }

.faq__body {
  display: grid;
  gap: 10px;
  padding: 2px 16px 16px 60px;
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.6;
}
.faq__body b { color: var(--ink); font-weight: 600; }
.faq__body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--line-2);
  color: var(--ink);
  word-break: break-all;
}

.steps { list-style: none; counter-reset: passo; display: grid; gap: 8px; }
.steps li { position: relative; padding-left: 32px; counter-increment: passo; }
.steps li::before {
  content: counter(passo);
  position: absolute;
  left: 0;
  top: 1px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--on-ink);
  font-size: 12px;
  font-weight: 600;
}

.callout {
  padding: 10px 14px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--warn) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--warn) 35%, var(--surface));
  color: var(--ink);
}
.help-cta { justify-self: start; height: 40px; margin-top: 4px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 12px 12px 20px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--on-ink);
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  animation: fadeUp .25s ease both;
}
.toast button {
  padding: 6px 14px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--on-ink) 14%, transparent);
  font-size: 13px;
  font-weight: 500;
}
.toast button:hover { background: color-mix(in srgb, var(--on-ink) 24%, transparent); }

/* ---------- Rodapé ---------- */
.footer { padding: 24px 24px 40px; font-size: 12.5px; color: var(--muted); text-align: center; }

/* ---------- Responsivo ---------- */
@media (max-width: 1080px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 960px) {
  .grid, .grid--even { grid-template-columns: 1fr; }
  .topbar__inner {
    grid-template-columns: 1fr auto;
    grid-template-areas: "brand right" "tabs tabs";
    height: auto;
    padding-top: 12px;
    padding-bottom: 12px;
    row-gap: 12px;
  }
  .brand { grid-area: brand; }
  .topbar__right { grid-area: right; }
  .tabs { grid-area: tabs; justify-self: center; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 720px) {
  .container { padding: 0 16px; }
  .topbar__right { gap: 4px; }
  .help-btn { width: 36px; padding: 0; justify-content: center; }
  .help-btn__label { display: none; }
  .faq__body { padding-left: 16px; }
  .month-picker__label { min-width: 104px; }
  .tabs { justify-self: stretch; }
  .tab { flex: 1; padding: 7px 8px; }
  .bar-wrap { height: 260px; }
  .goals { grid-template-columns: 1fr; }
  .segmented--inline { width: 100%; }

  .page-head { margin: 28px 0 20px; flex-wrap: wrap; }
  .kpis { grid-template-columns: 1fr; gap: 12px; }
  .card { padding: 22px 18px; }
  .hero { padding: 26px 20px; }
  .stats { gap: 12px; }
  .stat { padding: 18px; }
  .stat strong { font-size: 22px; }
  .legend__val { min-width: 0; }
  .item__del { opacity: 1; }
}

@media (max-width: 420px) {
  .brand span:last-child { display: none; }
  .month-picker__label { min-width: 92px; font-size: 13px; }
  .tab { font-size: 13px; }
  .page-head__actions, .page-head .btn { width: 100%; }
  .field-row { grid-template-columns: 1fr; }
  .cat-picker { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
}

/* ---------- Impressão ---------- */
@media print {
  body { background: #fff; }
  .topbar, .footer, .toast, .page-head .btn { display: none !important; }
  .view { display: none !important; }
  #view-resumo { display: block !important; animation: none; }
  .card, .stat { box-shadow: none; break-inside: avoid; }
  .grid--even { grid-template-columns: 1fr 1fr; }
}
