/*
 * Cousner — identidade visual
 * Fundo azul-marinho, um único destaque dourado, fonte Poppins.
 * Para trocar uma cor do site inteiro, mude só as variáveis abaixo.
 */
:root {
  --bg: #F5F7F6;          /* fundo */
  --bg-2: #F5F7F6;
  --glow: #FFFFFF;        /* brilho no topo */
  --glow-2: #F9FBFA;
  --card: #FFFFFF;        /* cartões e caixas */
  --line: #D3DCD7;        /* bordas */
  --accent: #139A49;      /* verde Cousner */
  --accent-light: #22B35C;
  --accent-dark: #0C7A38;
  --brand-red: #D42B35;   /* vermelho Cousner */
  --brand-red-dark: #A71E27;
  --text: #14201A;
  --muted: #55635B;       /* texto secundário */
  --steel: #7B8780;       /* cinza-esverdeado */
  --footer: #6B7770;
  --track: #E8EEEA;
  --good: #137C3C;
  --bad: #D42B35;
  --font: "Poppins", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  background-color: #fff;
  background-image: radial-gradient(ellipse 70% 55% at 50% 0%, var(--glow) 0%, var(--glow-2) 18%, var(--bg-2) 45%, var(--bg) 75%);
  background-repeat: no-repeat;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 { font-family: var(--font); letter-spacing: -0.03em; text-wrap: balance; }
.num { font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.container { width: 100%; max-width: 1152px; margin: 0 auto; padding-inline: 20px; }
.narrow { max-width: 768px; }
main { flex: 1; }

/* ---------- cabeçalho ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  border-bottom: 1px solid rgba(24, 56, 40, 0.11);
  background: rgba(255, 255, 255, .9);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
}
.bar { height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; min-width: 0; }
.brand img { height: 34px; width: auto; display: block; }
.brand span { font-weight: 600; font-size: 17px; letter-spacing: .28em; text-transform: uppercase; white-space: nowrap; }
.brand b { color: var(--accent-dark); font-weight: 600; }
nav.menu { display: flex; align-items: center; gap: 4px; }
nav.menu a { color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500; padding: 8px 16px; border-radius: 999px; transition: color .15s; }
nav.menu a:hover { color: var(--text); }
nav.menu a[aria-current="page"] { background: var(--track); color: var(--text); }
.menu-btn { display: none; background: transparent; border: 0; color: var(--text); padding: 8px; margin-right: -8px; cursor: pointer; border-radius: 10px; }
.menu-btn svg { width: 26px; height: 26px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }
.menu-btn .x { display: none; }
.menu-btn[aria-expanded="true"] .x { display: block; }
.menu-btn[aria-expanded="true"] .burger { display: none; }

/* ---------- topo da página ---------- */
.hero { text-align: center; padding-block: 56px 0; }
h1 { margin: 0; font-size: clamp(30px, 6vw, 48px); line-height: 1.1; font-weight: 700; }
h1 em { font-style: normal; color: var(--accent-dark); }
.lead { margin: 16px auto 0; max-width: 36em; font-size: 18px; color: var(--muted); }

/* ---------- escolha do tipo de cálculo ---------- */
.pick-title { margin: 44px 0 20px; text-align: center; font-size: 20px; font-weight: 600; }
.modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.mode {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start;
  text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: 26px; padding: 28px;
  box-shadow: 0 1px 2px rgba(20, 40, 30, .07), 0 8px 24px -8px rgba(20, 40, 30, .12);
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.mode:hover { transform: translateY(-3px); box-shadow: 0 20px 50px -20px rgba(19, 154, 73, .22); }
.mode.main { border-color: var(--accent); }
.mode h3 { margin: 20px 0 0; font-size: 20px; font-weight: 600; }
.mode p { margin: 8px 0 0; color: var(--muted); }
.mode .go { display: inline-block; margin-top: 20px; color: var(--accent-dark); font-weight: 600; font-size: 14px; }
.mode:hover .go { text-decoration: underline; }
.ico { width: 56px; height: 56px; border-radius: 18px; background: var(--track); display: grid; place-items: center; }
.ico svg { width: 28px; height: 28px; stroke: var(--accent); fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.back { display: inline-flex; align-items: center; gap: 6px; margin: 40px 0 16px; padding: 0; background: none; border: 0; cursor: pointer; color: var(--muted); font: 500 14px var(--font); }
.back:hover { color: var(--text); }
.back svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- formulário ---------- */
form { display: flex; flex-direction: column; gap: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.block {
  background: var(--card); border: 1px solid rgba(24, 56, 40, 0.14); border-radius: 20px; padding: 24px; min-width: 0;
  box-shadow: 0 1px 2px rgba(20, 40, 30, .07), 0 8px 24px -8px rgba(20, 40, 30, .12);
}
.block h3 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.hint { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.stack { margin-top: 16px; display: flex; flex-direction: column; gap: 14px; }
.stack > .hint { margin: 0; }
.block > .field, .block > .stack, .block > .row { margin-top: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.field { flex: 1 1 200px; min-width: 0; }
.input {
  display: flex; align-items: center; gap: 8px; height: 56px; padding: 0 16px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 14px; transition: border-color .15s, box-shadow .15s;
}
.input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(19, 154, 73, .12); }
.input.err { border-color: var(--bad); }
.input span { color: var(--muted); font-size: 14px; white-space: nowrap; }
.input input {
  flex: 1; min-width: 0; width: 100%; border: 0; outline: 0; background: transparent; color: var(--text);
  font: 600 18px var(--font); font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
}
.input input::placeholder { color: var(--steel); font-weight: 400; }
.msg { margin: 6px 0 0; color: var(--bad); font-size: 13px; }
.msg:empty { display: none; }
.note { margin: 12px 0 0; color: var(--muted); font-size: 12px; }

.seg { display: inline-flex; background: var(--track); border-radius: 14px; padding: 4px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; color: var(--muted); font: 500 14px var(--font); padding: 10px 16px; border-radius: 10px; cursor: pointer; transition: color .15s; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(20, 40, 30, .12); }
.row > .seg { align-self: flex-start; }

.presets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.preset { text-align: left; padding: 12px; font: 600 14px var(--font); color: var(--text); background: transparent; border: 1px solid rgba(24, 56, 40, 0.14); border-radius: 14px; cursor: pointer; transition: border-color .15s; }
.preset:hover { border-color: var(--line); }
.preset.on { border-color: var(--accent); background: var(--track); }

.calc {
  margin-top: 4px; width: 100%; height: 64px; border: 0; border-radius: 18px; cursor: pointer;
  font: 700 16px var(--font); letter-spacing: .22em; color: #fff;
  background: linear-gradient(135deg, var(--accent-light), var(--accent) 55%, var(--accent-dark));
  box-shadow: 0 20px 50px -20px rgba(19, 154, 73, .22);
  transition: transform .15s;
}
.calc:hover { transform: translateY(-2px); }
.calc:active { transform: translateY(0); }

/* ---------- resultados ---------- */
#results { padding-top: 24px; scroll-margin-top: 80px; }
#results h2 { margin: 0 0 24px; font-size: clamp(22px, 4vw, 30px); font-weight: 700; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stats.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat { background: var(--card); border: 1px solid rgba(24, 56, 40, 0.14); border-radius: 18px; padding: 20px; min-width: 0; box-shadow: 0 1px 2px rgba(20, 40, 30, .07), 0 8px 24px -8px rgba(20, 40, 30, .12); }
.stat .l { color: var(--muted); font-size: 14px; }
.stat .v { margin-top: 8px; font-size: clamp(20px, 2.6vw, 28px); font-weight: 700; overflow-wrap: anywhere; line-height: 1.2; }
.stat .h { margin-top: 4px; color: var(--muted); font-size: 12px; }
.stat.hero-stat { background: linear-gradient(135deg, var(--accent-light), var(--accent) 55%, var(--accent-dark)); border-color: transparent; color: #fff; box-shadow: 0 20px 50px -20px rgba(19, 154, 73, .22); }
.stat.hero-stat .l, .stat.hero-stat .h { color: rgba(255, 255, 255, .88); }
.stack-lg { display: flex; flex-direction: column; gap: 24px; }
.rate-line { margin: 0; color: var(--muted); font-size: 14px; }
.rate-line b { color: var(--text); font-weight: 600; }

.banner { display: flex; gap: 12px; padding: 20px; border-radius: 18px; border: 1px solid; }
.banner svg { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.banner.ok { border-color: rgba(19, 154, 73, .22); background: rgba(19, 154, 73, .1); color: var(--good); }
.banner.warn { border-color: rgba(19, 154, 73, .4); background: rgba(19, 154, 73, .1); color: var(--accent-dark); }
.banner .t { color: var(--text); font-weight: 600; }
.banner .d { margin-top: 4px; color: var(--muted); font-size: 14px; }

.panel { background: var(--card); border: 1px solid rgba(24, 56, 40, 0.14); border-radius: 26px; padding: 32px; min-width: 0; box-shadow: 0 1px 2px rgba(20, 40, 30, .07), 0 8px 24px -8px rgba(20, 40, 30, .12); }
.panel h3 { margin: 0 0 20px; font-size: 18px; font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-bottom: 16px; color: var(--muted); font-size: 14px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; }

.chart-host { position: relative; width: 100%; }
.chart-host svg { display: block; width: 100%; touch-action: pan-y; overflow: visible; }
.tip {
  position: absolute; top: 8px; z-index: 5; pointer-events: none; min-width: 190px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; font-size: 13px;
  box-shadow: 0 8px 24px rgba(20, 40, 30, 0.14);
}
.tip .tt { margin-bottom: 8px; font-weight: 600; }
.tip .tr { display: flex; justify-content: space-between; gap: 20px; padding: 2px 0; }
.tip .tr span:first-child { color: var(--muted); display: flex; align-items: center; gap: 8px; }
.tip .tr i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.tip .tr b { font-weight: 600; font-variant-numeric: tabular-nums; }

.scroll { max-height: 480px; overflow: auto; border: 1px solid rgba(24, 56, 40, 0.14); border-radius: 14px; }
table { width: 100%; min-width: 600px; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
th { position: sticky; top: 0; background: var(--track); color: var(--muted); font-weight: 500; text-align: right; padding: 12px 16px; white-space: nowrap; }
td { padding: 10px 16px; text-align: right; border-top: 1px solid rgba(24, 56, 40, 0.08); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; font-weight: 500; }
tbody tr:hover { background: var(--track); }
td.up { color: var(--good); }
td.tot { font-weight: 600; }

/* ---------- páginas de texto ---------- */
.page { padding-block: 64px 0; }
.page h1 { font-size: clamp(30px, 6vw, 40px); }
.page .lead { margin: 12px 0 0; max-width: none; }
.page p.body { margin: 16px 0 0; color: var(--muted); font-size: 17px; }
.steps { margin-top: 40px; display: flex; flex-direction: column; gap: 16px; }
.step { display: flex; gap: 16px; background: var(--card); border: 1px solid rgba(24, 56, 40, 0.14); border-radius: 18px; padding: 24px; box-shadow: 0 1px 2px rgba(20, 40, 30, .07), 0 8px 24px -8px rgba(20, 40, 30, .12); }
.step .n { flex: none; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: var(--track); color: var(--accent-dark); font-weight: 700; }
.step h2 { margin: 0; font-size: 18px; font-weight: 600; }
.step p { margin: 4px 0 0; color: var(--muted); }
.step code { color: var(--text); background: var(--track); padding: 1px 6px; border-radius: 6px; font-size: .92em; }

/* ---------- rodapé ---------- */
.site-footer { margin-top: 96px; border-top: 1px solid rgba(24, 56, 40, 0.11); }
.site-footer p { margin: 0; padding-block: 32px; color: var(--footer); font-size: 14px; }

/* ---------- celular ---------- */
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats .hero-stat { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .container { padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px)); }
  .menu-btn { display: block; }
  nav.menu {
    display: none; position: absolute; left: 0; right: 0; top: 100%; flex-direction: column; align-items: stretch; gap: 2px;
    padding: 12px max(16px, env(safe-area-inset-left, 0px)); background: var(--bg); border-bottom: 1px solid rgba(24, 56, 40, 0.11);
  }
  nav.menu.open { display: flex; }
  nav.menu a { padding: 14px 12px; border-radius: 12px; }
  .brand span { font-size: 14px; letter-spacing: .22em; }
  .brand img { height: 28px; }
  .hero { padding-top: 40px; }
  .lead { font-size: 16px; }
  .modes, .grid2 { grid-template-columns: 1fr; }
  .presets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .block { padding: 20px; }
  .panel { padding: 20px; border-radius: 22px; }
  .page { padding-top: 40px; }
  .site-footer { margin-top: 64px; }
}
@media (max-width: 720px) {
  .stat .v { font-size: 18px; overflow-wrap: normal; white-space: nowrap; }
  .stats .hero-stat .v { font-size: 24px; }
}
@media (max-width: 380px) {
  .stats, .stats.three { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .stat { padding: 16px; }
  .tip { min-width: 170px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* =====================================================================
   Calculadora de Gastos
   ===================================================================== */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.g-wrap { display: flex; flex-direction: column; gap: 24px; padding-top: 32px; }
.sec-title { margin: 0 0 12px; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.sec-sub { margin: -6px 0 16px; color: var(--muted); font-size: 14px; }
.opt { color: var(--steel); font-weight: 400; }
.body-text { margin: 0; color: var(--muted); font-size: 15px; }
.lbl { display: block; margin-bottom: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
.field label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }

/* botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  font: 600 14px var(--font); color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 14px; cursor: pointer;
  transition: transform .15s, border-color .15s, background .15s; text-decoration: none;
}
.btn:hover { border-color: var(--accent); }
.btn.gold { color: #fff; border-color: transparent; background: linear-gradient(135deg, var(--accent-light), var(--accent) 55%, var(--accent-dark)); }
.btn.gold:hover { transform: translateY(-1px); }
.btn.danger { color: #fff; background: var(--bad); border-color: transparent; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn[disabled]:hover { border-color: var(--line); }
.linklike { background: none; border: 0; padding: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.linklike:hover { color: var(--accent-dark); text-decoration: underline; }

/* barra de período */
.toolbar { display: flex; flex-direction: column; gap: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 38px; padding: 0 14px; font: 500 13px var(--font); color: var(--muted); background: transparent; border: 1px solid rgba(24, 56, 40, 0.16); border-radius: 999px; cursor: pointer; white-space: nowrap; transition: color .15s, border-color .15s; }
.chip:hover { color: var(--text); border-color: var(--line); }
.chip.on { color: #fff; background: var(--accent); border-color: var(--accent); font-weight: 600; }
.range { display: grid; grid-template-columns: repeat(2, minmax(0, 220px)); gap: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.input select, .input textarea { flex: 1; min-width: 0; width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font: 500 15px var(--font); }
.input select option { background: var(--card); color: var(--text); }
.input input[type="date"] { font-size: 15px; font-weight: 500; }
.input:has(textarea) { height: auto; padding: 12px 16px; }
.input textarea { resize: vertical; min-height: 52px; line-height: 1.4; }
.input.sm { height: 44px; border-radius: 12px; padding: 0 12px; }
.input.sm input, .input.sm select { font-size: 14px; font-weight: 500; }

.storage-note { margin: 0; color: var(--muted); font-size: 12px; }
.banner.err { border-color: rgba(212, 43, 53, .45); background: rgba(212, 43, 53, .1); color: var(--bad); }
.alerts { display: flex; flex-direction: column; gap: 12px; }

/* números */
.stats.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.stats.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat .cmp { margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, .35); font-size: 12px; font-weight: 500; }
.stat.sep { border-style: dashed; border-color: var(--line); background: transparent; box-shadow: none; }
.stat .v.small { font-size: clamp(16px, 2vw, 22px); }
.note-line { margin: 12px 0 0; color: var(--muted); font-size: 13px; }

/* painéis */
.g-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 24px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.panel-head h2 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.panel-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.empty { margin: 0; padding: 28px 16px; text-align: center; color: var(--muted); border: 1px dashed rgba(24, 56, 40, 0.16); border-radius: 16px; font-size: 14px; }
.empty b { display: block; margin-bottom: 4px; color: var(--text); font-weight: 600; }
.empty .btn { margin-top: 14px; }

/* orçamento */
.budget-list { display: flex; flex-direction: column; gap: 18px; }
.bud-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; font-size: 14px; }
.bud-top b { font-weight: 600; }
.bud-top span { color: var(--muted); font-variant-numeric: tabular-nums; }
.track { height: 12px; margin-top: 8px; border-radius: 999px; background: var(--track); overflow: hidden; }
.track i { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.track.warn i { background: #C46A0C; }
.track.over i { background: var(--bad); }
.bud-bot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 6px; color: var(--muted); font-size: 12px; }
.tag-s { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; border: 1px solid; }
.tag-s.ok { color: var(--good); border-color: rgba(19, 154, 73, .5); }
.tag-s.warn { color: #C46A0C; border-color: rgba(245, 158, 74, .6); }
.tag-s.over { color: var(--bad); border-color: rgba(212, 43, 53, .6); }

/* rosca */
.donut-wrap { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px; align-items: center; }
.donut-wrap svg { display: block; width: 220px; height: 220px; }
.donut-wrap path { cursor: pointer; transition: opacity .15s; fill: none; }
.donut-wrap path:focus-visible { outline: none; stroke: #fff; }
.donut-wrap.has-sel path:not(.sel) { opacity: .4; }
.catlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.catlist button { width: 100%; display: grid; grid-template-columns: 12px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 8px 10px; background: transparent; border: 1px solid transparent; border-radius: 12px; color: inherit; font: 500 14px var(--font); text-align: left; cursor: pointer; }
.catlist .static-row { width: 100%; display: grid; grid-template-columns: 12px minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 8px 10px; color: var(--text); font: inherit; }
.catlist button:hover { background: var(--track); }
.catlist button.sel { border-color: var(--accent); background: var(--track); }
.catlist i { width: 12px; height: 12px; border-radius: 4px; display: block; }
.catlist .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.catlist .vl { font-variant-numeric: tabular-nums; font-weight: 600; }
.catlist .pc { min-width: 52px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.detail-box { margin-top: 20px; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: rgba(24, 56, 40, .06); }
.detail-box h3 { margin: 0 0 10px; font-size: 15px; font-weight: 600; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.mini { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.mini li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px solid rgba(24, 56, 40, 0.08); }
.mini li:first-child { border-top: 0; }
.mini .d { color: var(--muted); font-size: 12px; }
.mini .nm { min-width: 0; overflow-wrap: anywhere; }
.mini .vl { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* fixas x variáveis */
.fv-bar { display: flex; height: 36px; border-radius: 12px; overflow: hidden; background: var(--track); }
.fv-bar span { display: block; height: 100%; min-width: 0; }
.fv-rows { margin-top: 18px; display: flex; flex-direction: column; gap: 12px; }
.fv-row { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 14px; }
.fv-row i { width: 14px; height: 14px; border-radius: 4px; display: block; }
.fv-row small { display: block; color: var(--muted); font-size: 12px; }
.fv-row b { font-variant-numeric: tabular-nums; text-align: right; }

/* evolução */
.seg.gran { margin-bottom: 14px; }
.dt { margin-top: 14px; }
.dt summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.dt .scroll { margin-top: 10px; max-height: 280px; }
.dt table { min-width: 0; }

/* ranking */
.rank { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; counter-reset: r; }
.rank li { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.rank .pos { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: var(--track); color: var(--accent-dark); font-weight: 700; font-size: 13px; }
.rank .nm { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.rank .sub { color: var(--muted); font-size: 12px; }
.rank .vl { font-weight: 700; font-variant-numeric: tabular-nums; }
.rank .rbar { grid-column: 2 / 4; height: 6px; border-radius: 999px; background: var(--track); overflow: hidden; }
.rank .rbar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

/* análise */
.ana { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.ana li { display: grid; grid-template-columns: 12px minmax(0, 1fr); gap: 12px; font-size: 15px; line-height: 1.5; }
.ana li::before { content: ""; width: 10px; height: 10px; margin-top: 7px; border-radius: 50%; background: var(--accent); }
.ana li.up::before { background: var(--bad); }
.ana li.down::before { background: var(--good); }
.ana li.warn::before { background: #C46A0C; }
.ana li.tip::before { background: #5BA8F5; }
.ana li.empty::before { background: var(--steel); }
.ana-tag { display: inline-block; margin-right: 6px; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }

/* histórico */
.filters { display: grid; grid-template-columns: minmax(0, 2fr) repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.hist td, .hist th { text-align: left; }
.hist th.r, .hist td.r { text-align: right; }
.hist { min-width: 760px; }
.hist tbody tr { cursor: pointer; }
.hist .nm { font-weight: 600; white-space: normal; overflow-wrap: anywhere; }
.hist .cat { display: flex; align-items: center; gap: 6px; margin-top: 2px; color: var(--muted); font-size: 12px; font-weight: 400; }
.hist .cat i { width: 8px; height: 8px; border-radius: 3px; display: inline-block; }
.hist td.acts { text-align: right; white-space: nowrap; }
.hist .acts .btn { margin-left: 6px; }
.badge { display: inline-block; margin-left: 6px; padding: 0 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 11px; font-weight: 500; vertical-align: middle; }
.list-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 14px; color: var(--muted); font-size: 13px; }
.data-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

/* janelas */
dialog { width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); padding: 0; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 24px; box-shadow: 0 30px 80px rgba(20, 40, 30, 0.17); overflow: hidden; }
dialog[open] { display: flex; flex-direction: column; }
dialog > form { display: flex; flex-direction: column; min-height: 0; flex: 1; gap: 0; }
dialog::backdrop { background: rgba(20, 32, 26, .5); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 24px 12px; }
.dlg-head h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.x-btn { width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent; color: var(--muted); font-size: 26px; line-height: 1; cursor: pointer; }
.x-btn:hover { background: var(--track); color: var(--text); }
.dlg-body { padding: 8px 24px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.dlg-foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; padding: 14px 24px 20px; border-top: 1px solid rgba(24, 56, 40, 0.10); }
.dlg-foot:empty { display: none; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.two > .field { flex: none; }
.newcat { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px; margin-top: 10px; }
.newcat .input { flex: 1 1 200px; }
.newcat .msg { flex-basis: 100%; margin: 0; }
.check { display: flex; align-items: center; gap: 10px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.check label { font-size: 15px; cursor: pointer; }
.seg { position: relative; }
.seg input[type="radio"] { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.seg label { display: block; margin: 0; padding: 12px 18px; border-radius: 10px; color: var(--muted); font: 500 14px var(--font); cursor: pointer; }
.seg input:checked + label { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(20, 40, 30, 0.11); }
.seg input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }
dl.det { margin: 0; display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 10px 14px; font-size: 14px; }
dl.det dt { color: var(--muted); }
dl.det dd { margin: 0; overflow-wrap: anywhere; }
dl.det dd.big { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.bd-row { display: grid; grid-template-columns: minmax(0, 1fr) 160px; gap: 12px; align-items: center; }
.bd-row label { margin: 0; font-size: 14px; color: var(--text); }
.bd-sec { margin: 6px 0 0; font-size: 14px; font-weight: 600; }
.bd-cats { display: flex; flex-direction: column; gap: 10px; }
.cc-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; }

/* avisos rápidos */
.toasts { position: fixed; z-index: 100; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 16px max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-right, 0px)); pointer-events: none; }
.toast { max-width: 520px; padding: 12px 18px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--text); font-size: 14px; box-shadow: 0 12px 40px rgba(20, 40, 30, 0.15); pointer-events: auto; }
.toast.ok { border-color: rgba(19, 154, 73, .6); }
.toast.warn { border-color: rgba(245, 158, 74, .7); }
.toast.err { border-color: rgba(212, 43, 53, .7); }

@media (max-width: 1000px) {
  .stats.five { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-grid { grid-template-columns: 1fr; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters .input:first-child { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .g-wrap { gap: 20px; padding-top: 24px; }
  .stats.five { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats.five .stat:last-child { grid-column: 1 / -1; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin-inline: -16px; padding-inline: 16px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .range { grid-template-columns: 1fr 1fr; }
  .donut-wrap { grid-template-columns: 1fr; justify-items: center; }
  .donut-wrap .catlist { width: 100%; }
  .two { grid-template-columns: 1fr; }
  .dlg-head, .dlg-body, .dlg-foot { padding-inline: 18px; }
  .dlg-foot .btn { flex: 1; }
  dl.det { grid-template-columns: 1fr; gap: 2px; }
  dl.det dd { margin-bottom: 10px; }
  .bd-row { grid-template-columns: 1fr; gap: 6px; }
  .stats .stat .v.small { font-size: 16px; white-space: normal; }

  /* Histórico no celular: cada despesa vira um cartão e o valor fica sempre visível (sem rolar para o lado). */
  #histBody .scroll { border: 0; max-height: none; overflow: visible; }
  .hist { min-width: 0; }
  .hist thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .hist, .hist tbody { display: block; }
  .hist tbody tr {
    display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px;
    padding: 14px 16px; margin-bottom: 10px; background: var(--bg);
    border: 1px solid rgba(24, 56, 40, 0.14); border-radius: 16px;
  }
  .hist td { display: block; padding: 0; border: 0; white-space: normal; }
  .hist td:nth-child(1) { order: 1; flex: 1 1 50%; min-width: 0; }
  .hist td:nth-child(5) { order: 2; margin-left: auto; font-size: 17px; text-align: right; white-space: nowrap; }
  .hist td:nth-child(2), .hist td:nth-child(3), .hist td:nth-child(4) { order: 3; font-size: 12px; color: var(--muted); }
  .hist td:nth-child(3)::before, .hist td:nth-child(4)::before { content: "·"; margin-right: 10px; }
  .hist td.acts { order: 4; flex: 0 0 100%; text-align: right; padding-top: 6px; }
  .hist tbody tr:hover { background: var(--bg); }
}
@media (max-width: 380px) {
  .stats.five, .stats.cols-4 { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr; }
}
.detail-box .sq { display: inline-block; width: 10px; height: 10px; margin-right: 8px; border-radius: 3px; }

/* =====================================================================
   Metas e cofrinhos
   ===================================================================== */




dialog code { padding: 1px 6px; border-radius: 6px; background: var(--track); font-size: .92em; }

/* metas */
.goals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.goal { min-width: 0; padding: 24px; background: var(--card); border: 1px solid rgba(24, 56, 40, 0.14); border-radius: 22px; box-shadow: 0 1px 2px rgba(20, 40, 30, .07), 0 8px 24px -8px rgba(20, 40, 30, .12); }
.goal-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.goal-top h3 { margin: 0; font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.goal-top .tag-s { flex: none; }
.goal-nums { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; margin-top: 14px; }
.goal-nums b { font-size: 22px; font-weight: 700; }
.goal-nums span { color: var(--muted); font-size: 14px; }
.goal-nums .pc { margin-left: auto; color: var(--accent-dark); font-weight: 700; font-size: 16px; }
.track.done i { background: var(--good); }
.goal-info { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 14px; }
.goal-info b { color: var(--text); font-weight: 600; }
.goal-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }


/* menu em formato de celular a partir de 1000px (agora há mais itens) */
@media (max-width: 1000px) {
  .menu-btn { display: block; }
  nav.menu {
    display: none; position: absolute; left: 0; right: 0; top: 100%; flex-direction: column; align-items: stretch; gap: 2px;
    padding: 12px max(16px, env(safe-area-inset-left, 0px)); background: var(--bg); border-bottom: 1px solid rgba(24, 56, 40, 0.11);
  }
  nav.menu.open { display: flex; }
  nav.menu a { padding: 14px 12px; border-radius: 12px; }
}
@media (max-width: 720px) {
  .goals { grid-template-columns: 1fr; }
}


/* =====================================================================
   Ganhos e saldo
   ===================================================================== */
.pos { color: var(--good); }
.neg { color: var(--bad); }
.inc-list li { flex-wrap: wrap; align-items: center; }
.inc-list .vl { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.inc-list .vl b { font-weight: 600; }

@media (max-width: 900px) { .inc-stats .stat:last-child { grid-column: 1 / -1; } }


.chart-legend { display: flex; gap: 18px; flex-wrap: wrap; margin: 4px 0 8px; color: var(--muted); font-size: 13px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 8px; }
.chart-legend i { width: 12px; height: 12px; border-radius: 4px; display: block; }
