/* ---------- tokens ---------- */
:root {
  color-scheme: light;
  --bg: #f4f4f1;
  --surface: #ffffff;
  --surface-2: #f3f3ef;
  --surface-3: #e9e8e3;
  --border: #e4e3de;
  --text: #171716;
  --text-2: #55544f;
  --muted: #8a8983;
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --accent-soft: #e6f0fc;
  --series-1: #2a78d6;
  --good: #0ca30c;
  --good-text: #13793a;
  --good-soft: #e5f5e8;
  --critical: #d03b3b;
  --critical-text: #b42c2c;
  --critical-soft: #fbeaea;
  --warning: #fab219;
  --warning-soft: #fdf3dc;
  --warning-text: #8a5a00;
  --shadow: 0 1px 2px rgb(20 20 15 / 0.04), 0 2px 8px rgb(20 20 15 / 0.04);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111110;
    --surface: #1a1a19;
    --surface-2: #222220;
    --surface-3: #2c2c29;
    --border: #2f2f2c;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #8f8e86;
    --accent: #3987e5;
    --accent-ink: #86b6ef;
    --accent-soft: #17304f;
    --series-1: #3987e5;
    --good-text: #4cc46a;
    --good-soft: #15301d;
    --critical-text: #ef7b7b;
    --critical-soft: #3a1c1c;
    --warning-soft: #3a2e12;
    --warning-text: #f5c35a;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111110; --surface: #1a1a19; --surface-2: #222220; --surface-3: #2c2c29; --border: #2f2f2c;
  --text: #f0efec; --text-2: #c3c2b7; --muted: #8f8e86; --accent: #3987e5; --accent-ink: #86b6ef; --accent-soft: #17304f;
  --series-1: #3987e5; --good-text: #4cc46a; --good-soft: #15301d; --critical-text: #ef7b7b; --critical-soft: #3a1c1c;
  --warning-soft: #3a2e12; --warning-text: #f5c35a; --shadow: none;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 13px; font-weight: 600; color: var(--text-2); }
p { margin: 0; }
.num, .val, .amount, .right { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pos { color: var(--good-text); }
.neg { color: var(--critical-text); }
.error { color: var(--critical-text); min-height: 1em; margin: 8px 0 0; font-size: 13px; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- topo e navegação ---------- */
.top { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.top-inner { max-width: 1080px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 16px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; white-space: nowrap; }
.logo { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); color: #fff; display: grid; place-items: center; }
.logo svg { width: 17px; height: 17px; stroke-width: 2.4; }
#tabs { display: flex; gap: 2px; flex: 1; justify-content: center; }
#tabs button {
  display: flex; align-items: center; gap: 7px; background: none; border: 0; border-radius: 9px; color: var(--text-2);
  padding: 8px 12px; font: inherit; font-size: 14px; cursor: pointer; white-space: nowrap;
}
#tabs button svg { width: 17px; height: 17px; }
#tabs button:hover { background: var(--surface-2); color: var(--text); }
#tabs button.on { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.lancar { display: inline-flex; align-items: center; gap: 6px; }
.lancar svg { width: 16px; height: 16px; stroke-width: 2.4; }

main { max-width: 1080px; margin: 0 auto; padding: 20px 16px 48px; }

@media (max-width: 720px) {
  .top-inner { height: 54px; justify-content: space-between; }
  #tabs {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; background: var(--surface); border-top: 1px solid var(--border);
    justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  #tabs button { flex-direction: column; gap: 3px; font-size: 11px; padding: 6px 4px; flex: 1; }
  #tabs button.on { background: none; }
  #tabs button svg { width: 21px; height: 21px; }
  #tabs button { min-width: 0; }
  #tabs button { padding: 6px 0; font-size: 10.5px; letter-spacing: -0.01em; }
  #tabs button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .top .lancar { display: none; }
  /* lançar fica no centro da barra inferior, sem cobrir o conteúdo */
  #tabs .tab-lancar { display: flex; color: var(--accent-ink); font-weight: 600; }
  .tab-lancar .fab {
    width: 44px; height: 44px; margin: -20px 0 -2px; border-radius: 50%; background: var(--accent); color: #fff;
    display: grid; place-items: center; box-shadow: 0 4px 12px rgb(20 20 15 / 0.25); border: 3px solid var(--surface);
  }
  #tabs .tab-lancar .fab svg { width: 22px; height: 22px; stroke-width: 2.4; }
  #tabs .tab-lancar:active .fab { filter: brightness(1.1); transform: scale(0.96); }
  main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
}
@media (min-width: 721px) { #tabs .tab-lancar { display: none; } }

/* ---------- blocos ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card.destaque { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.card-head .eyebrow { font-size: 12px; font-weight: 600; color: var(--accent-ink); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 2px; }
.card-head .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.card-head .actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 28px 0 12px; }
.section-title:first-child { margin-top: 0; }
.section-title h2 { font-size: 20px; font-weight: 700; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin-bottom: 16px; }
.grid-cards > .card { margin: 0; }
@media (max-width: 720px) { .grid2 { grid-template-columns: 1fr; } }
@media (max-width: 560px) {
  .card { padding: 16px 14px; }
  /* sem espaço, os botões do cabeçalho descem para baixo do título em vez de espremer o texto */
  .card-head { flex-wrap: wrap; gap: 8px 12px; }
  .card-head > div:first-child { flex: 1 1 200px; min-width: 0; }
  .section-title h2, .toolbar h2 { font-size: 18px; }
  .mesnav strong { min-width: 0; padding: 0 4px; }
  .toolbar > .mesnav { flex: 1; justify-content: space-between; }
}
.note { font-size: 13px; color: var(--text-2); background: var(--surface-2); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }
.callout { display: flex; gap: 10px; align-items: flex-start; border-radius: 10px; padding: 12px 14px; font-size: 14px; }
.callout svg { margin-top: 1px; }
.callout.ok { background: var(--good-soft); color: var(--good-text); }
.callout.warn { background: var(--warning-soft); color: var(--warning-text); }
.callout.bad { background: var(--critical-soft); color: var(--critical-text); }
.callout strong { font-variant-numeric: tabular-nums; }

/* ---------- números de destaque ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stats.inner { margin: 0 0 14px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stats.inner .stat { background: var(--surface-2); border: 0; box-shadow: none; }
.stat .lbl { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.stat .lbl svg { width: 15px; height: 15px; color: var(--muted); }
.stat .val { font-size: 22px; font-weight: 700; margin-top: 4px; letter-spacing: -0.02em; }
.stat .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat.big .val { font-size: 28px; }
.stat.link { cursor: pointer; transition: border-color .15s; }
.stat.link:hover { border-color: var(--accent); }
.amount { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.amount small { font-size: 15px; font-weight: 500; color: var(--muted); letter-spacing: 0; white-space: nowrap; display: inline-block; }
.stat { min-width: 0; }
.stat .val { overflow-wrap: anywhere; }
@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 12px 13px; }
  .stat .lbl { font-size: 12.5px; }
  .stat .val { font-size: clamp(16px, 4.8vw, 20px); white-space: nowrap; overflow-wrap: normal; }
  .stat.big { grid-column: 1 / -1; }
  .stat.big .val { font-size: 26px; }
  .stats:not(:has(> .big:first-child)) > .stat:last-child:nth-child(odd),
  .stats:has(> .big:first-child) > .stat:last-child:nth-child(even):not(.big) { grid-column: 1 / -1; }
  /* blocos internos (próximo mês, financiamento) viram linhas rótulo → valor */
  .stats.inner { grid-template-columns: 1fr; gap: 0; background: var(--surface-2); border-radius: 12px; padding: 2px 12px; }
  .stats.inner .stat { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 10px; align-items: baseline; padding: 9px 0; border-radius: 0; background: none; }
  .stats.inner .stat + .stat { border-top: 1px solid var(--border); }
  .stats.inner .stat .lbl { font-size: 13.5px; color: var(--text); }
  .stats.inner .stat .val { margin: 0; font-size: 16px; grid-row: 1 / 3; grid-column: 2; align-self: center; }
  .stats.inner .stat .sub { grid-column: 1; margin-top: 1px; }
  .amount { font-size: 28px; }
}

/* ---------- listas ---------- */
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); min-height: 52px; }
.item:last-child { border-bottom: 0; }
.item .ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); flex: none; }
.item .ico svg { width: 17px; height: 17px; }
.item .ico.in { background: var(--good-soft); color: var(--good-text); }
.item .ico.out { background: var(--critical-soft); color: var(--critical-text); }
.item .ico.mv { background: var(--accent-soft); color: var(--accent-ink); }
.item .main { flex: 1; min-width: 0; }
.item .t { font-weight: 550; overflow: hidden; text-overflow: ellipsis; }
.item .meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.item .right { text-align: right; white-space: nowrap; font-weight: 600; }
.item .right .of { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
.item .acts { display: flex; gap: 2px; align-items: center; }
.item.done .t { color: var(--text-2); }
.item.dim { opacity: 0.6; }
.group-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 0 6px; border-bottom: 1px solid var(--border); }
.group-head:first-child { padding-top: 0; }
.group-head .t { font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-2); }
.group-head .v { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.total-row { display: flex; justify-content: space-between; padding: 12px 0 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--muted); padding: 22px 8px; font-size: 14px; }
@media (max-width: 560px) {
  /* valor em cima e ações embaixo, à direita: sem uma linha extra só para os botões */
  .item { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "main right" "main acts"; column-gap: 10px; row-gap: 2px; }
  .item .main { grid-area: main; align-self: center; }
  .item .right { grid-area: right; align-self: end; }
  .item .acts { grid-area: acts; justify-self: end; align-self: start; margin-right: -6px; }
  .item:not(:has(.right)) .acts { grid-row: 1 / 3; align-self: center; }
  .item .ico { display: none; }
  .item .t { overflow-wrap: anywhere; }
  .item .acts .btn.sm { padding: 4px 10px; }
}

/* ---------- etiquetas, barras ---------- */
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 550; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.chip svg { width: 12px; height: 12px; stroke-width: 2.6; }
.chip.ok { background: var(--good-soft); color: var(--good-text); }
.chip.bad { background: var(--critical-soft); color: var(--critical-text); }
.chip.warn { background: var(--warning-soft); color: var(--warning-text); }
.chip.info { background: var(--accent-soft); color: var(--accent-ink); }
.bar { height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; min-width: 60px; flex: 1; }
.bar > i { display: block; height: 100%; background: var(--series-1); border-radius: 3px; }
.bar.over > i { background: var(--critical); }
.bar.full > i { background: var(--good); }
.bar.lg { height: 10px; border-radius: 5px; }
.bar.lg > i { border-radius: 5px; }
.barline { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.barline .pct { font-size: 12px; color: var(--muted); min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px 24px; margin-top: 16px; }
.groups .g .row1 { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; }
.groups .g .row1 span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.groups .g .row1 span:last-child { white-space: nowrap; }
.groups .g .row1 span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12.5px; }

/* ---------- botões ---------- */
.btn {
  font: inherit; font-size: 14px; font-weight: 550; border-radius: 9px; padding: 7px 14px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.soft { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.btn.ghost { border-color: transparent; background: none; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { font-size: 13px; padding: 5px 10px; border-radius: 8px; }
.btn[data-armed], .ibtn[data-armed] { background: var(--critical); border-color: var(--critical); color: #fff; width: auto; padding: 0 10px; font-size: 12px; font-weight: 600; }
.ibtn { width: 32px; height: 32px; border-radius: 8px; border: 0; background: none; color: var(--muted); display: inline-grid; place-items: center; cursor: pointer; }
.ibtn svg { width: 16px; height: 16px; }
.ibtn:hover { background: var(--surface-2); color: var(--text); }
.ibtn.danger:hover { color: var(--critical-text); background: var(--critical-soft); }
.mesnav { display: inline-flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 11px; padding: 3px; }
.mesnav strong { min-width: 150px; text-align: center; font-size: 15px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; font: inherit; font-size: 13px; padding: 5px 12px; border-radius: 8px; cursor: pointer; color: var(--text-2); }
.seg button.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }

/* ---------- detalhes recolhíveis ---------- */
details.more { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 10px; }
details.more summary { cursor: pointer; font-size: 13.5px; font-weight: 550; color: var(--accent-ink); list-style: none; display: flex; align-items: center; gap: 6px; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary svg { width: 15px; height: 15px; transition: transform .15s; }
details.more[open] summary svg { transform: rotate(90deg); }
details.more > div { margin-top: 10px; }

/* ---------- tabelas (poucas) ---------- */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; }
th, td { padding: 8px; border-bottom: 1px solid var(--border); }
td.v, th.v { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) {
  .tablewrap { margin: 0 -14px; padding: 0 14px; }
  .tablewrap table { font-size: 13px; }
  .tablewrap th, .tablewrap td { padding: 7px 6px; }
  .tablewrap td:first-child { white-space: nowrap; }
  /* projeção: o início do mês é o fim do anterior; some no celular para a tabela caber */
  table.proj th:nth-child(2), table.proj td:nth-child(2) { display: none; }
  table.proj { font-size: 12.5px; }
  table.proj .small { font-size: 11px; white-space: normal; min-width: 80px; }
  table.proj th, table.proj td { padding: 7px 4px; }
}

/* ---------- investimentos ---------- */
.inv .head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.inv .name { font-weight: 650; font-size: 15px; }
.inv .meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.inv .chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 12px; }
.inv .kv { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.inv .kv div span { display: block; font-size: 11.5px; color: var(--muted); }
.inv .kv div b { font-size: 14px; font-variant-numeric: tabular-nums; }
.inv .foot { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; align-items: center; }
.inv .foot .sp { flex: 1; }

/* ---------- gráfico ---------- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; stroke: none; }
.chart .axis { stroke: var(--border); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 11px; }
.chart text.lbl { fill: var(--text); font-weight: 650; }
.chart .b { fill: var(--series-1); }
.chart .hit { fill: transparent; }
.chart .hl.on { fill: var(--surface-2); }
.tip {
  position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; font-size: 12.5px; box-shadow: 0 6px 20px rgb(0 0 0 / 0.14);
  min-width: 200px; display: none; z-index: 3;
}
.tip .t { font-weight: 650; margin-bottom: 4px; }
.tip .l { display: flex; justify-content: space-between; gap: 12px; padding: 1px 0; font-variant-numeric: tabular-nums; }

/* ---------- modal ---------- */
dialog { border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text); padding: 0; width: min(480px, calc(100vw - 32px)); max-height: calc(100vh - 48px); }
dialog::backdrop { background: rgb(10 10 8 / 0.45); backdrop-filter: blur(2px); }
#modal-form { padding: 18px 20px 20px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h2 { font-size: 18px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 13px; font-weight: 550; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); }
input, select {
  font: inherit; font-size: 15px; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; background: var(--surface); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.chooser { display: grid; gap: 8px; }
.chooser .btn { font-size: 15px; padding: 12px 14px; justify-content: flex-start; }
.chooser .btn svg { width: 18px; height: 18px; }
@media (max-width: 560px) {
  dialog { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 18px 18px 0 0; max-height: 92vh; }
  #modal-form { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
}

#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(8px); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 20;
}
#toast.on { opacity: 1; transform: translateX(-50%); }
@media (max-width: 720px) { #toast { bottom: calc(88px + env(safe-area-inset-bottom)); max-width: calc(100vw - 32px); } }

/* ---------- primeiros passos ---------- */
.steps { counter-reset: s; }
.steps .item .ico { font-weight: 700; font-size: 13px; }

/* ---------- complementos ---------- */
.note.flex { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 6px 6px 6px 12px; }
.note svg, p.small svg { width: 14px; height: 14px; vertical-align: -2px; }
.cols { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.cols > .card, .cols > div > .card:last-child { margin-bottom: 0; }
.cols > div > .card { margin-bottom: 16px; }
@media (max-width: 860px) { .cols { grid-template-columns: 1fr; } .cols > div > .card:last-child { margin-bottom: 16px; } }
.item.link { cursor: pointer; border-radius: 8px; margin: 0 -8px; padding-left: 8px; padding-right: 8px; }
.item.link:hover { background: var(--surface-2); }
.item.sel .t { color: var(--accent-ink); }
.item.sel { background: var(--accent-soft); }
.toolbar h2 { font-size: 20px; font-weight: 700; }
.grid2 h3 { margin-bottom: 4px; }

/* ---------- salário bruto → líquido ---------- */
.srow { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 0.9fr) auto auto 32px; gap: 6px; align-items: center; margin-bottom: 6px; }
.srow input, .srow select { font-size: 14px; padding: 7px 9px; }
.ck { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
.ck input { width: auto; }
.calc { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; font-size: 14px; }
.calc .l { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; font-variant-numeric: tabular-nums; }
.calc .l.tot { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 8px; font-size: 15px; }
dialog:has(.srow), dialog:has(#sal-itens) { width: min(760px, calc(100vw - 32px)); }
@media (max-width: 640px) {
  .srow { grid-template-columns: 1fr 1fr; padding: 8px; background: var(--surface-2); border-radius: 10px; }
  .srow [name=descricao] { grid-column: 1 / -1; }
  .srow .ibtn { justify-self: end; }
}

/* ---------- assistente ---------- */
.chat-open { display: inline-flex; align-items: center; gap: 6px; }
.chat-open svg { width: 16px; height: 16px; }
.chat-open[aria-expanded="true"] { background: var(--accent-soft); color: var(--accent-ink); }
#chat {
  position: fixed; top: 60px; right: 0; bottom: 0; width: min(420px, 100vw); z-index: 9;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: -8px 0 24px rgb(20 20 15 / 0.08);
  display: flex; flex-direction: column;
}
#chat[hidden] { display: none; }
@media (min-width: 1400px) { body.chat-on main { margin-right: 436px; } }
.chat-head { display: flex; align-items: center; gap: 4px; padding: 14px 12px 12px 18px; border-bottom: 1px solid var(--border); }
.chat-head > div { flex: 1; min-width: 0; }
.chat-head h2 { margin: 0; font-size: 16px; }
.chat-head p { margin: 2px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#chat-log { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; overscroll-behavior: contain; }
.chat-empty p { margin: 0 0 12px; font-size: 14px; }
.chat-sug { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.chat-sug .btn { white-space: normal; text-align: left; }
.msg { max-width: 92%; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.msg > :first-child { margin-top: 0; }
.msg > :last-child { margin-bottom: 0; }
.msg p, .msg ul, .msg ol { margin: 0 0 8px; }
.msg ul, .msg ol { padding-left: 20px; }
.msg li { margin: 2px 0; }
.msg h4 { margin: 10px 0 4px; font-size: 14px; }
.msg code { font-size: 12.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.msg strong { font-variant-numeric: tabular-nums; }
.msg.eu { align-self: flex-end; background: var(--accent); color: #fff; padding: 9px 13px; border-radius: 14px 14px 4px 14px; }
.msg.ia { align-self: flex-start; background: var(--surface-2); padding: 10px 14px; border-radius: 14px 14px 14px 4px; }
.msg.ia.erro:not(:has(p:not(.error))) { background: var(--critical-soft); }
.msg .error { margin: 6px 0 0; color: var(--critical-text); }
.chat-table { overflow-x: auto; margin: 0 0 8px; }
.chat-table table { border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.chat-table th, .chat-table td { border-bottom: 1px solid var(--border); padding: 4px 8px; text-align: left; white-space: nowrap; }
.chat-table th { color: var(--text-2); font-weight: 600; }
.digitando { display: inline-flex; gap: 4px; padding: 4px 0; }
.digitando i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: pisca 1.2s infinite ease-in-out; }
.digitando i:nth-child(2) { animation-delay: .15s; }
.digitando i:nth-child(3) { animation-delay: .3s; }
@keyframes pisca { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .digitando i { animation: none; opacity: .6; } }
#chat-form { display: flex; gap: 8px; align-items: flex-end; padding: 12px 14px 4px; border-top: 1px solid var(--border); }
#chat-input {
  flex: 1; resize: none; font: inherit; font-size: 15px; line-height: 1.4; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); max-height: 140px;
}
#chat-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
#chat-send { padding: 9px 11px; }
#chat-send svg { width: 18px; height: 18px; }
#chat-send:disabled { opacity: .5; cursor: default; }
.chat-note { margin: 0; padding: 6px 16px calc(12px + env(safe-area-inset-bottom)); font-size: 11.5px; }

@media (max-width: 720px) {
  .chat-open span { display: none; }
  .chat-open { padding: 7px 9px; margin-left: auto; }
  #chat { top: 0; width: 100vw; z-index: 30; border-left: 0; box-shadow: none; }
  body.chat-on { overflow: hidden; }
}
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent-ink); text-decoration: underline; cursor: pointer; }
dialog:has(.relatorio) { width: min(820px, calc(100vw - 32px)); }
.relatorio { margin: 0; max-height: 65vh; overflow: auto; background: var(--surface-2); border-radius: 10px; padding: 12px 14px; font-size: 12px; line-height: 1.5; white-space: pre; }

/* ---------- login e conta ---------- */
body.deslogado #tabs, body.deslogado .lancar, body.deslogado .chat-open, body.deslogado .conta-btn { display: none; }
.auth { max-width: 380px; margin: 48px auto; padding: 28px; }
.auth .logo { width: 40px; height: 40px; border-radius: 12px; margin-bottom: 14px; }
.auth .logo svg { width: 22px; height: 22px; }
.auth h1 { margin: 0 0 6px; font-size: 22px; }
.auth form { margin-top: 18px; }
.auth .field input { width: 100%; box-sizing: border-box; }
.auth .btn.primary { width: 100%; justify-content: center; padding: 10px 14px; margin-top: 4px; }
.auth .error:empty { display: none; }
.conta-btn { display: inline-flex; align-items: center; gap: 6px; max-width: 160px; }
.conta-btn svg { width: 16px; height: 16px; flex: none; }
.conta-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conta-sec { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 14px; }
.conta-sec h3 { margin: 0 0 4px; font-size: 15px; }
.conta-sec .acts { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 720px) {
  .conta-btn span { display: none; }
  .conta-btn { padding: 7px 9px; }
  .auth { margin: 24px auto; padding: 22px 18px; }
}

/* propostas de mudança do assistente */
.ia-acao { margin-top: 8px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 10px; font-size: 13px; }
.ia-acao.perigo { border-left-color: var(--critical); }
.ia-acao.aplicada { border-left-color: var(--good); }
.ia-acao.descartada, .ia-acao.erro { border-left-color: var(--surface-3); }
.ia-acao.descartada .ia-acao-l { text-decoration: line-through; color: var(--muted); }
.ia-acao-t { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.ia-acao-l { color: var(--text-2); line-height: 1.45; overflow-wrap: anywhere; }
.ia-acao .acts, .msg.ia > .acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.btn.perigo { background: var(--critical); border-color: var(--critical); color: #fff; }
.btn.perigo:hover { filter: brightness(1.08); background: var(--critical); }
