/* Rumo — tokens, temas e componentes */

:root {
  --bg: #F0F1ED;
  --surface: #FFFFFF;
  --soft: #F5F6F3;
  --soft-2: #ECEEE9;
  --line: #E2E4DF;
  --line-2: #D5D8D2;
  --text: #15181C;
  --text-2: #3D434A;
  --muted: #5B6168;
  --faint: #6B7178;
  --income: #1F7A52;
  --income-soft: #E2F2EA;
  --expense: #D02B2B;
  --expense-soft: #FDE6E6;
  --warn: #8A5A00;
  --warn-soft: #FCF1D6;
  --danger: #A82E2E;
  --danger-soft: #F9E3E3;
  --overlay: rgba(21, 24, 28, 0.5);
  --shadow-1: 0 1px 2px rgba(21, 24, 28, 0.06), 0 2px 8px rgba(21, 24, 28, 0.06);
  --shadow-2: 0 24px 64px rgba(21, 24, 28, 0.28);
  --ink-btn: #15181C;
  --ink-btn-text: #FFFFFF;

  /* paleta padrão: Pinho & Índigo */
  --fin: #1F5C4A;
  --fin-on: #FFFFFF;
  --fin-soft: #E3EFEA;
  --fin-text: #1F5C4A;
  --fin-2: #4E9C7E;
  --pes: #3B4CCA;
  --pes-on: #FFFFFF;
  --pes-soft: #E8EAFB;
  --pes-text: #2F3DA8;

  --font-display: 'Bricolage Grotesque', 'Figtree', system-ui, sans-serif;
  --font-body: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-num: 'Geist Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 24px;
  color-scheme: light;
}

:root[data-palette="magenta"] { --fin: #D6246E; --fin-on: #FFFFFF; --fin-soft: #FCE4EE; --fin-text: #B81D5C; --fin-2: #F07AA8; --pes: #4F46E5; --pes-on: #FFFFFF; --pes-soft: #E6E5FC; --pes-text: #3F37C9; }
:root[data-palette="tangerina"] { --fin: #F26B1D; --fin-on: #15181C; --fin-soft: #FDE8DA; --fin-text: #B04A0C; --fin-2: #F8A56E; --pes: #2563EB; --pes-on: #FFFFFF; --pes-soft: #E1EAFD; --pes-text: #1D4FC4; }
:root[data-palette="lima"] { --fin: #A3E635; --fin-on: #15181C; --fin-soft: #EEF9D6; --fin-text: #3F6212; --fin-2: #6E9E1E; --pes: #6D28D9; --pes-on: #FFFFFF; --pes-soft: #EDE4FB; --pes-text: #5B21B6; }

:root[data-theme="escuro"] {
  --bg: #111215;
  --surface: #1C1E22;
  --soft: #24272C;
  --soft-2: #2A2D33;
  --line: #2C2F35;
  --line-2: #3A3E45;
  --text: #F2F3F0;
  --text-2: #D0D3CE;
  --muted: #A3A8B0;
  --faint: #8A9098;
  --income: #5BD08F;
  --income-soft: #183326;
  --expense: #FF6B6B;
  --expense-soft: #3D1A1A;
  --warn: #F2C266;
  --warn-soft: #3A2E12;
  --danger: #FF9C9C;
  --danger-soft: #3A1A1A;
  --overlay: rgba(0, 0, 0, 0.6);
  --shadow-1: none;
  --ink-btn: #F2F3F0;
  --ink-btn-text: #15181C;
  --fin-soft: #1E302A;
  --fin-text: #7FD1B0;
  --pes-soft: #23264A;
  --pes-text: #A5ADFF;
  color-scheme: dark;
}
:root[data-theme="escuro"][data-palette="magenta"] { --fin-soft: #3A1526; --fin-text: #FF7AAE; --pes-soft: #1F1D4A; --pes-text: #A5A0FF; }
:root[data-theme="escuro"][data-palette="tangerina"] { --fin-soft: #3B2114; --fin-text: #FF9A5C; --pes-soft: #14234A; --pes-text: #8AB0FF; }
:root[data-theme="escuro"][data-palette="lima"] { --fin-soft: #26331A; --fin-text: #C2F062; --pes-soft: #2A1A47; --pes-text: #B794F6; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--fin-text); }
:focus-visible { outline: 3px solid var(--pes); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.income { color: var(--income); }
.expense { color: var(--expense); }
.danger-text { color: var(--danger); font-weight: 600; }
.warn-text { color: var(--warn); font-weight: 600; }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 252px; flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 22px 14px;
  display: flex; flex-direction: column; gap: 20px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; font-family: var(--font-display); font-weight: 700; font-size: 21px; text-decoration: none; color: var(--text); }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: #15181C; border: 1px solid #3D434A; display: flex; align-items: center; justify-content: center; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label { display: flex; align-items: center; gap: 8px; padding: 0 12px 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.nav-label.fin { color: var(--fin-text); }
.nav-label.pes { color: var(--pes-text); }
.nav-label i { width: 8px; height: 8px; border-radius: 3px; display: block; }
.nav-label.fin i { background: var(--fin); }
.nav-label.pes i { background: var(--pes); }
.nav-link { display: flex; align-items: center; gap: 12px; min-height: 42px; padding: 0 12px; border-radius: 10px; text-decoration: none; color: var(--text-2); font-weight: 500; }
.nav-link:hover { background: var(--soft); }
.nav-link .dot { width: 6px; height: 6px; border-radius: 999px; background: var(--line-2); }
.nav-link.fin[aria-current="page"] { background: var(--fin-soft); color: var(--fin-text); font-weight: 700; }
.nav-link.fin[aria-current="page"] .dot { background: var(--fin); }
.nav-link.pes[aria-current="page"] { background: var(--pes-soft); color: var(--pes-text); font-weight: 700; }
.nav-link.pes[aria-current="page"] .dot { background: var(--pes); }
.nav-home { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 10px; text-decoration: none; color: var(--text); font-weight: 600; border: 1px solid var(--line); }
.nav-home[aria-current="page"] { background: var(--ink-btn); color: var(--ink-btn-text); border-color: var(--ink-btn); }
.nav-user { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 14px; background: var(--soft); text-decoration: none; color: var(--text); }
.nav-user[aria-current="page"] { background: var(--soft-2); }
.topbar { display: none; }

.main { flex: 1; min-width: 0; padding: 32px clamp(16px, 4vw, 48px) 64px; }
.page { max-width: 1180px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }

@media (max-width: 900px) {
  .app { flex-direction: column; }
  .topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
  .sidebar { position: fixed; z-index: 40; left: 0; top: 0; bottom: 0; transform: translateX(-105%); transition: transform .2s ease; box-shadow: var(--shadow-2); }
  body.menu-open .sidebar { transform: none; }
  body.menu-open .scrim { position: fixed; inset: 0; background: var(--overlay); z-index: 30; }
  .main { padding: 20px 16px 48px; }
}

/* ---------- headings ---------- */
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; }
.page-head .titles { display: flex; flex-direction: column; gap: 6px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.eyebrow.fin { color: var(--fin-text); }
.eyebrow.pes { color: var(--pes-text); }
h1 { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: clamp(30px, 4vw, 40px); letter-spacing: -0.02em; line-height: 1.1; }
h2 { margin: 0; font-size: 20px; font-weight: 700; }
h3 { margin: 0; font-size: 17px; font-weight: 700; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border-radius: var(--r-xl); padding: 22px; display: flex; flex-direction: column; gap: 16px; min-width: 0; border: 1px solid transparent; }
:root[data-theme="escuro"] .card { border-color: var(--line); }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }
.card-title { display: flex; align-items: center; gap: 10px; }
.card-title i { width: 10px; height: 10px; border-radius: 3px; display: block; }
.card-title i.fin { background: var(--fin); }
.card-title i.pes { background: var(--pes); }
.grid { display: grid; gap: 16px; }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 20px; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.row-wrap { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.col-main { flex: 3 1 520px; min-width: 0; }
.col-side { flex: 2 1 320px; min-width: 0; }
@media (max-width: 480px) { .grid-2 { grid-template-columns: 1fr; } }

.kpi { background: var(--surface); border-radius: 20px; padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; min-width: 0; border: 1px solid transparent; }
:root[data-theme="escuro"] .kpi { border-color: var(--line); }
.kpi .label { font-size: 13px; color: var(--muted); }
.kpi .value { font-family: var(--font-num); font-size: 23px; font-weight: 500; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi .hint { font-size: 13px; color: var(--muted); }
.kpi.fin { background: var(--fin); color: var(--fin-on); border-color: var(--fin); }
.kpi.pes { background: var(--pes); color: var(--pes-on); border-color: var(--pes); }
.kpi.ink { background: #15181C; color: #FFFFFF; border-color: #15181C; }
.kpi.fin .label, .kpi.fin .hint, .kpi.pes .label, .kpi.pes .hint, .kpi.ink .label, .kpi.ink .hint { color: inherit; opacity: 0.82; }
.tile { background: var(--soft); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }

/* ---------- buttons ---------- */
.btn { min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text); font-weight: 600; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--soft); }
.btn.fin { background: var(--fin); color: var(--fin-on); border-color: var(--fin); }
.btn.pes { background: var(--pes); color: var(--pes-on); border-color: var(--pes); }
.btn.dark { background: var(--ink-btn); color: var(--ink-btn-text); border-color: var(--ink-btn); }
.btn.fin:hover, .btn.pes:hover, .btn.dark:hover { filter: brightness(1.08); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--soft); }
.btn.sm { min-height: 36px; padding: 0 14px; font-size: 14px; }
.btn.danger { color: var(--danger); border-color: var(--danger-soft); }
.btn[disabled] { opacity: 0.5; cursor: default; filter: none; }
.icon-btn { width: 44px; height: 44px; flex-shrink: 0; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); display: inline-flex; align-items: center; justify-content: center; }
.icon-btn.sm { width: 36px; height: 36px; }
.icon-btn:hover { background: var(--soft); }
.link-btn { border: none; background: none; padding: 6px 4px; color: var(--fin-text); font-weight: 600; font-size: 14px; text-decoration: none; }
.link-btn.pes { color: var(--pes-text); }

.month-nav { display: inline-flex; align-items: center; gap: 4px; background: var(--ink-btn); color: var(--ink-btn-text); border-radius: 999px; padding: 4px; }
.month-nav button { width: 36px; height: 36px; border-radius: 999px; border: none; background: transparent; color: inherit; display: flex; align-items: center; justify-content: center; }
.month-nav button:hover { background: rgba(127,127,127,0.25); }
.month-nav span { min-width: 120px; text-align: center; font-weight: 600; }

/* ---------- pills, tabs, chips ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.tab { min-height: 42px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--surface); background: var(--surface); color: var(--text-2); font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
.tab[aria-selected="true"], .tab[aria-checked="true"], .tab[aria-pressed="true"] { background: var(--ink-btn); color: var(--ink-btn-text); border-color: var(--ink-btn); }
.tab .count { min-width: 24px; height: 24px; padding: 0 6px; border-radius: 999px; background: var(--soft-2); color: var(--text-2); font-family: var(--font-num); font-size: 12px; display: inline-flex; align-items: center; justify-content: center; }
.tab[aria-selected="true"] .count { background: rgba(127,127,127,0.3); color: inherit; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: var(--soft-2); border-radius: 14px; }
.seg button { min-height: 40px; border: none; border-radius: 10px; background: transparent; color: var(--muted); font-weight: 600; font-size: 14px; padding: 0 10px; }
.seg button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(21,24,28,0.14); }
.seg.inline { display: inline-grid; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text-2); font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 8px; }
.chip[aria-checked="true"], .chip[aria-pressed="true"] { background: var(--ink-btn); color: var(--ink-btn-text); border-color: var(--ink-btn); }
.chip.dashed { border-style: dashed; color: var(--pes-text); border-color: var(--pes); }
.chip.person { padding-left: 5px; border-width: 2px; border-color: var(--line); }
.chip.person[aria-pressed="true"], .chip.person[aria-checked="true"] { background: var(--pes-soft); color: var(--pes-text); border-color: var(--pes); }
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--soft-2); color: var(--text-2); }
.tag.ok { background: var(--income-soft); color: var(--income); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.late { background: var(--danger-soft); color: var(--danger); }
.tag.fin { background: var(--fin-soft); color: var(--fin-text); }
.tag.pes { background: var(--pes-soft); color: var(--pes-text); }
.tag.outline { background: transparent; border: 1px solid var(--line-2); }
button.tag { border: none; min-height: 28px; }
.cat-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 4px; border-radius: 999px; background: var(--soft-2); font-size: 13px; font-weight: 600; white-space: nowrap; }
.cat-chip .emo { width: 24px; height: 24px; border-radius: 999px; background: var(--surface); display: inline-flex; align-items: center; justify-content: center; font-size: 13px; }

.avatar { width: 28px; height: 28px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.avatar.lg { width: 36px; height: 36px; font-size: 14px; }
.avatars { display: inline-flex; }
.avatars .avatar { border: 2px solid var(--surface); }
.avatars .avatar + .avatar { margin-left: -9px; }
.av0 { background: #E8EAFB; color: #2F3DA8; }
.av1 { background: #FBE9E1; color: #93391A; }
.av2 { background: #E3EFEA; color: #1F5C4A; }
.av3 { background: #FCF1D6; color: #8A5A00; }
.av4 { background: #F3E3F5; color: #7A2E86; }

/* ---------- progress ---------- */
.bar { height: 8px; border-radius: 999px; background: var(--soft-2); overflow: hidden; display: flex; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: var(--fin); }
.bar.pes > span { background: var(--pes); }
.bar > span.over { background: var(--danger); }
.bar.thick { height: 12px; }
.ring { width: 72px; height: 72px; border-radius: 999px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.ring > span { width: 56px; height: 56px; border-radius: 999px; background: var(--surface); display: flex; align-items: center; justify-content: center; font-family: var(--font-num); font-size: 14px; font-weight: 600; }

/* ---------- lists ---------- */
.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); min-width: 0; }
.list-row:first-child { border-top: none; }
.list-row .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.list-row .t { font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
.list-row .s { font-size: 13px; color: var(--muted); }
.date-box { width: 46px; height: 46px; flex-shrink: 0; border-radius: 12px; background: var(--soft); display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
.date-box b { font-family: var(--font-num); font-size: 16px; }
.date-box small { font-size: 10px; font-weight: 700; text-transform: uppercase; }
.date-box.late { background: var(--danger-soft); color: var(--danger); }
.date-box.warn { background: var(--warn-soft); color: var(--warn); }
.check { width: 26px; height: 26px; flex-shrink: 0; border-radius: 8px; border: 2px solid var(--faint); background: var(--surface); padding: 0; display: inline-flex; align-items: center; justify-content: center; color: #FFFFFF; }
.check[aria-pressed="true"], .check[aria-checked="true"] { background: var(--pes); border-color: var(--pes); color: var(--pes-on); }
.done-text { text-decoration: line-through; color: var(--faint) !important; }
.empty { padding: 28px 12px; text-align: center; color: var(--muted); }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-lg); }
table.tbl { width: 100%; min-width: 980px; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; background: var(--soft); color: var(--muted); font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; font-weight: 600; padding: 12px; white-space: nowrap; }
.tbl td { padding: 12px; border-top: 1px solid var(--line); vertical-align: middle; }
.tbl tr:hover td { background: var(--soft); }
.tbl .r { text-align: right; }
.tbl .t { font-weight: 600; font-size: 15px; }
.tbl .s { font-size: 12px; color: var(--muted); }
.totals { display: flex; flex-wrap: wrap; gap: 10px 26px; padding: 14px 18px; border-radius: var(--r-lg); background: var(--soft); font-size: 14px; }
.totals span { display: inline-flex; align-items: center; gap: 8px; }
.totals i { width: 8px; height: 8px; border-radius: 999px; display: block; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .label { font-size: 14px; font-weight: 600; }
.field .hint { font-size: 13px; color: var(--muted); }
.input, .field input[type="text"], .field input[type="date"], .field input[type="time"], .field input[type="number"], .field input[type="search"], .field input[type="email"], .field input[type="password"], .field select, .field textarea {
  min-height: 48px; width: 100%; padding: 0 14px; border: 1px solid var(--line-2); border-radius: 14px; background: var(--surface); font-size: 15px; color: var(--text);
}
.field textarea { padding: 12px 14px; min-height: 80px; resize: vertical; }
.field input.big { min-height: 52px; font-size: 18px; font-weight: 600; }
.money-input { display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: 14px; background: var(--surface); }
.money-input span { font-family: var(--font-num); color: var(--muted); }
.field .money-input input, .money-input input { border: none; outline: none; flex: 1; min-width: 0; min-height: 0; padding: 0; border-radius: 0; font-family: var(--font-num); font-size: 19px; background: transparent; }
.money-input:focus-within { outline: 3px solid var(--pes); outline-offset: 1px; }
.fields-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.fields-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 520px) { .fields-2, .fields-3 { grid-template-columns: 1fr; } }
.box { padding: 14px 16px; border-radius: var(--r-lg); background: var(--soft); display: flex; flex-direction: column; gap: 12px; }
.box.outline { background: transparent; border: 1px solid var(--line); }
.note { padding: 12px 14px; border-radius: var(--r-md); font-size: 14px; line-height: 1.5; display: block; }
.note.fin { background: var(--fin-soft); color: var(--fin-text); }
.note.pes { background: var(--pes-soft); color: var(--pes-text); }
.note.err { background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch-row .lbl { display: flex; flex-direction: column; gap: 2px; }
.switch-row .lbl b { font-size: 15px; }
.switch { width: 50px; height: 30px; border-radius: 999px; border: none; padding: 3px; flex-shrink: 0; display: flex; align-items: center; justify-content: flex-start; background: var(--line-2); }
.switch::after { content: ''; width: 24px; height: 24px; border-radius: 999px; background: #FFFFFF; box-shadow: 0 1px 3px rgba(21,24,28,0.3); }
.switch[aria-checked="true"] { background: var(--fin); justify-content: flex-end; }
.switch.pes[aria-checked="true"] { background: var(--pes); }
.divider { height: 1px; background: var(--line); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
.emoji-grid button { aspect-ratio: 1; min-height: 40px; border-radius: 10px; border: 2px solid var(--soft); background: var(--soft); font-size: 20px; padding: 0; }
.emoji-grid button[aria-checked="true"] { border-color: var(--fin); background: var(--fin-soft); }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.cat-btn { min-height: 46px; padding: 0 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); display: flex; align-items: center; gap: 8px; text-align: left; font-weight: 600; font-size: 14px; }
.cat-btn span { font-size: 18px; }
.cat-btn[aria-checked="true"] { border-color: var(--fin); background: var(--fin-soft); color: var(--fin-text); }

/* ---------- modal ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; background: var(--overlay); overflow-y: auto; padding: 40px 16px; display: flex; justify-content: center; align-items: flex-start; }
.dialog { width: 100%; max-width: 580px; background: var(--surface); border-radius: 28px; box-shadow: var(--shadow-2); display: flex; flex-direction: column; }
.dlg-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 24px 28px 8px; }
.dlg-head h2 { font-family: var(--font-display); font-size: 26px; }
.dlg-title-wrap { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dlg-body { padding: 12px 28px 8px; display: flex; flex-direction: column; gap: 18px; }
.dlg-foot { display: flex; justify-content: flex-end; align-items: center; gap: 10px; padding: 16px 28px 24px; border-top: 1px solid var(--line); margin-top: 12px; flex-wrap: wrap; }
.dlg-foot .left { margin-right: auto; }
@media (max-width: 520px) { .overlay { padding: 12px 8px; } .dlg-head, .dlg-body, .dlg-foot { padding-left: 18px; padding-right: 18px; } }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink-btn); color: var(--ink-btn-text); padding: 12px 18px; border-radius: 999px; font-weight: 600; z-index: 60; box-shadow: var(--shadow-2); }

/* ---------- charts ---------- */
.donut { width: 210px; height: 210px; border-radius: 999px; flex-shrink: 0; margin: 0 auto; display: flex; align-items: center; justify-content: center; }
.donut > div { width: 144px; height: 144px; border-radius: 999px; background: var(--surface); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-align: center; }
.bars { display: grid; gap: 10px; align-items: end; height: 200px; border-bottom: 1px solid var(--line); }
.bars .col { height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; }
.bars .col i { display: block; width: 100%; max-width: 38px; border-radius: 8px 8px 0 0; }
.bars-labels { display: grid; gap: 10px; padding-top: 8px; font-size: 12px; font-weight: 600; color: var(--muted); text-align: center; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 13px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: block; }

/* ---------- calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal .wd { text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); padding: 6px 0; }
.cal .day { min-height: 92px; border-radius: 14px; padding: 8px; border: 2px solid var(--soft); background: var(--soft); display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; min-width: 0; }
.cal .day.blank { background: transparent; border-color: transparent; }
.cal .day[aria-pressed="true"] { border-color: var(--pes); background: var(--pes-soft); }
.cal .day .n { font-family: var(--font-num); font-size: 14px; font-weight: 600; width: 26px; height: 26px; border-radius: 999px; display: flex; align-items: center; justify-content: center; }
.cal .day.today .n { background: var(--ink-btn); color: var(--ink-btn-text); }
.cal .ev { display: block; width: 100%; font-size: 11px; font-weight: 600; padding: 2px 6px; border-radius: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal .ev.pes { background: var(--pes); color: var(--pes-on); }
.cal .ev.fin { background: var(--fin-soft); color: var(--fin-text); }
@media (max-width: 640px) { .cal .day { min-height: 56px; padding: 4px; } .cal .ev { font-size: 0; height: 6px; padding: 0; } }

/* ---------- settings ---------- */
.choice { padding: 14px; border-radius: var(--r-lg); border: 2px solid var(--line); background: var(--surface); display: flex; flex-direction: column; gap: 10px; align-items: flex-start; text-align: left; color: var(--text); }
.choice[aria-checked="true"] { border-color: var(--text); }
.choice .sw { display: flex; gap: 6px; }
.choice .sw i { width: 30px; height: 30px; border-radius: 9px; display: block; }
.theme-prev { width: 100%; height: 64px; border-radius: 10px; border: 1px solid var(--line); padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.theme-prev i { height: 9px; border-radius: 4px; display: block; }
.tile .num { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .value { overflow-wrap: anywhere; }

/* ---------- bancos ---------- */
.bank-logo { position: relative; flex-shrink: 0; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; overflow: hidden; font-weight: 800; }
.bank-logo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .15s; image-rendering: auto; }
.bank-logo { box-shadow: inset 0 0 0 1px rgba(0,0,0,0.06); }
.bank-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; max-height: 240px; overflow-y: auto; padding: 2px; }
.bank-btn { min-height: 46px; padding: 0 10px; border-radius: 12px; border: 2px solid var(--line); background: var(--surface); display: flex; align-items: center; gap: 8px; text-align: left; font-weight: 600; font-size: 13px; }
.bank-btn[aria-checked="true"] { border-color: var(--text); background: var(--soft); }
.click-card { cursor: pointer; text-align: left; font: inherit; color: inherit; padding: 0; background: none; border: none; width: 100%; }
.click-card:hover .hover-ring { box-shadow: 0 0 0 2px var(--line-2); }

/* ---------- filtros da tabela ---------- */
.tbl .filters th { background: var(--surface); padding: 6px 8px; text-transform: none; letter-spacing: 0; }
.tbl .filters select { width: 100%; min-height: 34px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); font-size: 13px; padding: 0 6px; font-weight: 500; color: var(--text); }
.tbl .filters select.on { border-color: var(--fin); background: var(--fin-soft); color: var(--fin-text); font-weight: 700; }
.th-sort { border: none; background: none; padding: 0; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; display: inline-flex; gap: 4px; align-items: center; cursor: pointer; }

/* ---------- etapas (checklist editável) ---------- */
.steps-edit { display: flex; flex-direction: column; gap: 6px; }
.step-row { display: flex; align-items: center; gap: 10px; }
.step-row input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--pes); flex-shrink: 0; margin: 0; }
.field .step-row input[type="text"] { min-height: 42px; border-radius: 10px; flex: 1; }

/* ---------- tarefa compacta ---------- */
.task-compact { align-items: flex-start; }
.task-compact .meta-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; }
.task-compact .check { margin-top: 2px; }

/* ---------- cores das áreas ---------- */
.tag.c-cinza { background: var(--soft-2); color: var(--text-2); }
.tag.c-verde { background: #E2F2EA; color: #1F6B47; }
.tag.c-azul { background: #E1EAFD; color: #1D4FC4; }
.tag.c-roxo { background: #EDE4FB; color: #5B21B6; }
.tag.c-rosa { background: #FCE4EE; color: #A3174F; }
.tag.c-laranja { background: #FDE8DA; color: #A6450C; }
.tag.c-amarelo { background: #FCF1D6; color: #7A5200; }
:root[data-theme="escuro"] .tag.c-verde { background: #183326; color: #7FD1A6; }
:root[data-theme="escuro"] .tag.c-azul { background: #14234A; color: #8AB0FF; }
:root[data-theme="escuro"] .tag.c-roxo { background: #2A1A47; color: #C4A6FA; }
:root[data-theme="escuro"] .tag.c-rosa { background: #3A1526; color: #FF8AB8; }
:root[data-theme="escuro"] .tag.c-laranja { background: #3B2114; color: #FFA36B; }
:root[data-theme="escuro"] .tag.c-amarelo { background: #3A2E12; color: #F2C266; }
.color-dot { width: 26px; height: 26px; border-radius: 999px; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line-2); padding: 0; flex-shrink: 0; }
.color-dot.c-cinza { background: #A3A8A0; } .color-dot.c-verde { background: #2E9D66; } .color-dot.c-azul { background: #2563EB; } .color-dot.c-roxo { background: #7C3AED; } .color-dot.c-rosa { background: #DB2777; } .color-dot.c-laranja { background: #EA580C; } .color-dot.c-amarelo { background: #D9A441; }

/* ---------- validação de despesas ---------- */
.av-wrap { position: relative; display: inline-flex; }
.avatars .av-wrap + .av-wrap { margin-left: -9px; }
.avatars .av-wrap .avatar { border: 2px solid var(--surface); }
.av-badge { position: absolute; right: -4px; bottom: -4px; width: 16px; height: 16px; border-radius: 999px; font-size: 9px; font-style: normal; display: flex; align-items: center; justify-content: center; border: 2px solid var(--surface); }
.av-badge.pend { background: var(--warn-soft); }
.av-badge.ref { background: var(--danger); color: #FFFFFF; font-weight: 700; }
.banner { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding: 14px 18px; border-radius: var(--r-lg); background: var(--warn-soft); color: var(--text); border: 1px solid transparent; }
.banner .grow { flex: 1 1 240px; display: flex; flex-direction: column; gap: 2px; }
.nav-badge { margin-left: auto; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--danger); color: #FFFFFF; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.viewer { display: flex; flex-direction: column; gap: 4px; padding: 0 4px; }
.viewer select { min-height: 38px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); padding: 0 8px; font-size: 14px; }

/* ---------- lista reordenável ---------- */
.sort-list { display: flex; flex-direction: column; gap: 8px; }
.sort-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 14px; background: var(--soft); border: 2px solid transparent; }
.sort-row.dragging { opacity: .45; }
.sort-row.drop-target { border-color: var(--pes); background: var(--pes-soft); }
.sort-row .handle { cursor: grab; color: var(--faint); font-weight: 700; letter-spacing: -2px; padding: 0 2px; user-select: none; }
.sort-row .sort-input { flex: 1; min-width: 0; min-height: 40px; border: 1px solid transparent; border-radius: 10px; background: var(--surface); padding: 0 12px; font-size: 15px; font-weight: 600; }
.sort-row .sort-input:focus { border-color: var(--pes); outline: none; }
.sort-row .sort-meta { white-space: nowrap; }
.sort-btns { display: inline-flex; gap: 4px; }
.sort-btns .icon-btn { width: 34px; height: 34px; }
.sort-btns .icon-btn[disabled] { opacity: .35; cursor: default; }
.emoji-btn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-size: 20px; padding: 0; flex-shrink: 0; }
@media (max-width: 520px) { .sort-row { flex-wrap: wrap; } .sort-row .sort-input { flex-basis: 60%; } .sort-meta { display: none; } }

/* ---------- filtro de coluna (tipo Excel) ---------- */
.th-btn { border: none; background: none; padding: 4px 6px; margin: -4px -6px; border-radius: 8px; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; display: inline-flex; gap: 6px; align-items: center; cursor: pointer; white-space: nowrap; }
.th-btn:hover { background: var(--soft-2); color: var(--text); }
.th-btn.on { color: var(--fin-text); background: var(--fin-soft); }
.th-btn svg { opacity: .7; }
#pop-root .pop { position: fixed; z-index: 45; width: 290px; max-height: min(460px, calc(100vh - 24px)); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-2); display: flex; flex-direction: column; overflow: hidden; }
.pop-sec { padding: 8px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.pop-item { min-height: 38px; padding: 0 10px; border-radius: 8px; border: none; background: none; text-align: left; display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 500; color: var(--text); }
.pop-item:hover, .pop-item[aria-pressed="true"] { background: var(--soft); }
.pop-item[aria-pressed="true"] { font-weight: 700; }
.pop-list { overflow-y: auto; padding: 6px 8px; flex: 1; }
.pop-list label { min-height: 36px; padding: 0 8px; border-radius: 8px; display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.pop-list label:hover { background: var(--soft); }
.pop-list input { width: 18px; height: 18px; accent-color: var(--fin); margin: 0; }
.pop-search { margin: 8px 8px 0; min-height: 38px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface); padding: 0 10px; font-size: 14px; }
.pop-foot { display: flex; justify-content: space-between; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }

/* ---------- subcategorias ---------- */
.chip.removable { padding-right: 6px; }
.chip.removable .x { width: 24px; height: 24px; border-radius: 999px; border: none; background: var(--soft-2); display: inline-flex; align-items: center; justify-content: center; padding: 0; color: var(--text-2); }

/* ---------- mobile ---------- */
@media (max-width: 640px) {
  h1 { font-size: 28px; }
  .page { gap: 16px; }
  .page-head { align-items: stretch; }
  .page-head .actions { width: 100%; }
  .page-head .actions .month-nav { flex: 1; justify-content: space-between; }
  .page-head .actions > .btn { flex: 1 1 auto; }
  .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px; border-radius: 16px; }
  .kpi .value { font-size: 18px; }
  .card { padding: 16px; border-radius: 20px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .dialog { border-radius: 22px; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex-shrink: 0; }
  .donut { width: 170px; height: 170px; }
  .donut > div { width: 116px; height: 116px; }
  .list-row { flex-wrap: wrap; }
  .totals { gap: 8px 16px; }
}
.card > *, .page > * { min-width: 0; max-width: 100%; }

/* ---------- barra inferior (celular) ---------- */
.bottom-nav { display: none; }
@media (max-width: 900px) {
  .bottom-nav { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
  .bottom-nav a, .bottom-nav button { min-height: 52px; border: none; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--muted); text-decoration: none; border-radius: 12px; }
  .bottom-nav [aria-current="page"] { color: var(--text); background: var(--soft); }
  .bottom-nav .plus { color: var(--fin-on); }
  .bottom-nav .plus span { width: 48px; height: 48px; border-radius: 16px; background: var(--fin); display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-1); }
  .main { padding-bottom: 110px; }
  .toast { bottom: 96px; }
}
.quick-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.quick-grid button { min-height: 92px; border-radius: 18px; border: 1px solid var(--line); background: var(--soft); display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; padding: 14px; text-align: left; font-weight: 700; font-size: 15px; }
.quick-grid button span { font-size: 24px; }

/* ---------- registros em cartões (celular) ---------- */
.reg-cards { display: flex; flex-direction: column; }
.reg-card { display: flex; gap: 12px; align-items: center; padding: 12px 2px; border-top: 1px solid var(--line); min-width: 0; }
.reg-card:first-child { border-top: none; }
.reg-card .emo { width: 40px; height: 40px; border-radius: 12px; background: var(--soft); display: flex; align-items: center; justify-content: center; font-size: 19px; flex-shrink: 0; }
.reg-card .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.reg-card .body .t { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reg-card .body .s { font-size: 12px; color: var(--muted); }
.reg-card .right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.filter-bar { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.filter-bar::-webkit-scrollbar { display: none; }
.filter-bar .chip { flex-shrink: 0; min-height: 36px; font-size: 13px; }
.filter-bar .chip.on { background: var(--fin-soft); color: var(--fin-text); border-color: var(--fin); }

@media (max-width: 640px) {
  .grid.tiles3 { grid-template-columns: 1fr !important; gap: 8px !important; }
  .grid.tiles3 .tile { flex-direction: row; justify-content: space-between; align-items: center; }
  .page-head .actions > .btn { flex: 1 1 140px; }
  .card-head > .tabs { width: 100%; }
}

.reg-date { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: 14px; font-weight: 600; color: var(--text); line-height: 1.4; }
.reg-date.late { color: var(--danger); }

/* ---------- seleção múltipla ---------- */
.sel-box { width: 18px; height: 18px; accent-color: var(--fin); margin: 0; cursor: pointer; flex-shrink: 0; }
.tbl tr.selected td { background: var(--fin-soft); }
.reg-card.selected { background: var(--fin-soft); border-radius: 12px; }
.bulk-bar { position: sticky; top: 8px; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 10px 12px 10px 16px; margin-bottom: 12px; border-radius: 16px; background: var(--ink-btn); color: var(--ink-btn-text); box-shadow: var(--shadow-2); }
.bulk-bar .actions { margin-left: auto; }
.bulk-bar .btn:not(.fin) { background: transparent; color: inherit; border-color: rgba(127,127,127,0.5); }
.bulk-bar .btn.danger { color: #FF8A8A; border-color: rgba(255,120,120,0.5); }
@media (max-width: 900px) { .bulk-bar { top: 70px; } .bulk-bar .actions { margin-left: 0; width: 100%; } }

.saldo-line { display: flex; flex-direction: column; gap: 2px; padding: 2px 2px 14px; border-bottom: 1px solid var(--line); }
.saldo-value { font-size: 30px; font-weight: 500; letter-spacing: -0.02em; color: var(--text); }

/* ---------- entrada (login) ---------- */
#auth-root:empty { display: none; }
.auth-screen { position: fixed; inset: 0; z-index: 70; background: var(--bg); overflow-y: auto; display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px 40px; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: 28px; padding: 28px; display: flex; flex-direction: column; gap: 16px; box-shadow: var(--shadow-1); border: 1px solid var(--line); }
.auth-card .choice { width: 100%; }
.cloud-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--income-soft); color: var(--income); }
.cloud-badge.salvando { background: var(--soft-2); color: var(--text-2); }
.cloud-badge.erro { background: var(--warn-soft); color: var(--warn); }

.row-link { border: none; background: none; padding: 0; text-align: left; color: inherit; font: inherit; cursor: pointer; border-radius: 8px; }
.row-link:hover .t { text-decoration: underline; text-underline-offset: 3px; }
