/* WJ Finanças */
:root {
  --ink: #15201b; --ink-2: #3d4a43; --muted: #77827c; --line: #e1e5e0; --bg: #edf0ec; --panel: #fff;
  --brass: #b08a3e; --brass-soft: #f4ecdb; --pos: #1f7a52; --neg: #b23a2e; --warn: #9c6411; --blue: #3b5fa8;
  --r: 14px; --shadow: 0 1px 2px rgba(21, 32, 27, .05), 0 8px 24px rgba(21, 32, 27, .05);
  font-family: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); font-size: 14.5px; line-height: 1.45; min-height: 100vh; }
[hidden] { display: none !important; }
a { color: var(--blue); }
h1, h2 { margin: 0; letter-spacing: -.01em; }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--pos); } .neg { color: var(--neg); }
body.hide-values .money { filter: blur(7px); user-select: none; }

/* topo */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px; padding: 10px 22px; background: var(--ink); color: #e9ece8; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #fff; font-weight: 800; font-size: 17px; }
.mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--brass); color: var(--ink); font-family: Georgia, serif; font-size: 15px; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { display: flex; align-items: center; gap: 7px; padding: 8px 12px; border-radius: 9px; color: #b9c2bd; text-decoration: none; font-weight: 600; font-size: 14px; }
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav a.on { background: rgba(176, 138, 62, .18); color: #e8c983; }
.nav svg, .eye svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.eye { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, .15); background: none; color: #e9ece8; cursor: pointer; }
.eye[aria-pressed="true"] { background: var(--brass); color: var(--ink); border-color: var(--brass); }
.out { margin: 0; }
.out button { background: none; border: 0; color: #b9c2bd; font: inherit; cursor: pointer; text-decoration: underline; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 22px 22px 90px; }

/* botões e campos */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { border-color: #c9cfc9; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #22332b; }
.btn.danger { color: var(--neg); }
.btn.ghost { border-color: transparent; background: none; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; padding: 0; color: var(--blue); font: inherit; font-weight: 700; cursor: pointer; }
.link.sm { font-size: 12.5px; font-weight: 600; }
label { display: block; font-weight: 600; font-size: 13px; color: var(--ink-2); margin-bottom: 12px; }
input:not([type=checkbox]):not([type=radio]), select, textarea { display: block; width: 100%; margin-top: 5px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font: inherit; color: var(--ink); font-weight: 500; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brass); outline-offset: -1px; border-color: transparent; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 12px; }
.row3 > [hidden] + *, .row3:has(> [hidden]) { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }

/* barra do mês */
.monthbar { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.month-t { display: flex; flex-direction: column; align-items: flex-start; min-width: 220px; }
.month-t h1 { font-size: 30px; font-weight: 800; }
.nav-m { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: #fff; font-size: 24px; line-height: 1; cursor: pointer; color: var(--ink); }
.nav-m:hover { border-color: var(--brass); }
.monthbar .add { margin-left: auto; }

/* resumo */
.ledger { background: var(--panel); border-radius: var(--r); box-shadow: var(--shadow); padding: 20px 22px 16px; margin-bottom: 18px; }
.ledger-main { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.ledger-main > div { display: flex; flex-direction: column; }
.ledger span { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.ledger-main b { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin: 2px 0; }
.ledger-main small { color: var(--muted); font-size: 12.5px; min-height: 18px; }
.ledger-main .sobra { border-left: 1px solid var(--line); padding-left: 18px; }
.ratio { height: 8px; border-radius: 99px; background: #dcefe4; margin: 14px 0 14px; overflow: hidden; }
.ratio i { display: block; height: 100%; background: var(--brass); border-radius: 99px; transition: width .4s; }
.ratio i.over { background: var(--neg); }
.ledger-side { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; border-top: 1px solid var(--line); padding-top: 12px; }
.ledger-side > div { display: flex; flex-direction: column; }
.ledger-side b { font-size: 17px; font-weight: 800; }
.alert-v.zero b { color: var(--muted); }

/* painéis */
.grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.grid .span2 { grid-row: span 3; }
.grid > .panel:last-child { grid-column: 1 / -1; }
.panel { background: var(--panel); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px 18px; min-width: 0; }
.ph { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.ph h2 { font-size: 17px; font-weight: 800; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filters select, .filters input { width: auto; margin: 0; padding: 7px 10px; font-size: 13px; }
.filters input { width: 140px; }
.empty { color: var(--muted); text-align: center; padding: 22px 8px; margin: 0; }

/* linhas */
.row { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 11px 6px; border-bottom: 1px solid #eef0ed; cursor: pointer; border-radius: 8px; }
.row:last-child { border-bottom: 0; }
.row:hover { background: #f6f8f5; }
.row.cancelled { opacity: .5; }
.row.cancelled b { text-decoration: line-through; }
.pay { width: 28px; height: 28px; border-radius: 8px; border: 2px solid #c9cfc9; background: #fff; color: #fff; font-weight: 900; cursor: pointer; }
.pay:hover { border-color: var(--pos); }
.pay.on { background: var(--pos); border-color: var(--pos); }
.s-vencida .pay { border-color: #e3a49d; }
.r-main b { display: block; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-sub { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 3px; font-size: 12px; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 700; color: var(--ink-2); background: color-mix(in srgb, var(--c, #8a8f98) 14%, white); }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c, #8a8f98); }
.chip.card { --c: #3730a3; }
.chip.plain::before { display: none; }
.chip.plain { background: #eef0ed; }
.inst { font-weight: 700; color: var(--ink-2); }
.inst.warn { color: var(--warn); }
.r-val { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; font-weight: 800; font-size: 15px; }
.st { font-size: 11px; font-weight: 800; padding: 1px 8px; border-radius: 99px; white-space: nowrap; }
.st-venc { background: #fbe4e1; color: var(--neg); }
.st-pend { background: #fbf0d9; color: var(--warn); }
.st-paga { background: #ddf2e6; color: var(--pos); }
.st-canc { background: #eef0ed; color: var(--muted); }

/* cartões e contas */
.ccard { display: flex; flex-direction: column; gap: 4px; width: 100%; text-align: left; padding: 13px 14px; margin-bottom: 10px; border-radius: 12px; border: 1px solid var(--line); background: linear-gradient(135deg, #fff 0%, #f6f4ee 100%); cursor: pointer; font: inherit; color: inherit; }
.ccard:hover { border-color: var(--brass); }
.cc-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.cc-val { font-size: 20px; font-weight: 800; }
.cc-sub { font-size: 12.5px; color: var(--muted); }
.bar { position: relative; height: 7px; border-radius: 99px; background: #eceee9; overflow: visible; margin-top: 4px; }
.bar i { display: block; height: 100%; border-radius: 99px; background: var(--blue); }
.bar.over i { background: var(--neg) !important; }
.bar em { position: absolute; top: -3px; width: 2px; height: 13px; background: var(--ink); border-radius: 2px; }
.acc { display: flex; justify-content: space-between; gap: 10px; width: 100%; text-align: left; padding: 10px 4px; border: 0; border-bottom: 1px solid #eef0ed; background: none; font: inherit; color: inherit; cursor: pointer; }
.acc:last-child { border-bottom: 0; }
.acc small { display: block; color: var(--muted); font-size: 12px; }
.acc-v { text-align: right; font-weight: 800; }

/* gráfico */
.seg { display: flex; background: #eef0ed; border-radius: 9px; padding: 3px; }
.seg button { border: 0; background: none; padding: 5px 11px; border-radius: 7px; font: inherit; font-size: 13px; font-weight: 700; color: var(--ink-2); cursor: pointer; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
#chart { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px 28px; }
.bar-row small { color: var(--muted); font-size: 12px; }
.bar-l { display: flex; justify-content: space-between; gap: 10px; font-weight: 700; font-size: 13.5px; }

/* diálogos */
.dlg { border: 0; padding: 0; border-radius: 18px; width: min(560px, calc(100vw - 24px)); box-shadow: 0 30px 80px rgba(0, 0, 0, .3); }
.dlg.sm { width: min(440px, calc(100vw - 24px)); }
.dlg.wide { width: min(760px, calc(100vw - 24px)); }
.dlg::backdrop { background: rgba(21, 32, 27, .45); }
.dlg > form, .dlg > div { padding: 22px; }
.dlg h2 { font-size: 20px; font-weight: 800; margin-bottom: 14px; }
.actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.actions .sp { flex: 1; }
.tabs { display: flex; gap: 4px; background: #eef0ed; border-radius: 11px; padding: 4px; margin-bottom: 16px; }
.tabs button { flex: 1; border: 0; background: none; padding: 8px 6px; border-radius: 8px; font: inherit; font-weight: 700; font-size: 13.5px; color: var(--ink-2); cursor: pointer; }
.tabs button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.choices { display: grid; gap: 8px; margin-bottom: 12px; }
.choice { display: flex; gap: 12px; align-items: flex-start; margin: 0; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px; cursor: pointer; font-weight: 500; color: var(--ink); }
.choice:has(input:checked) { border-color: var(--ink); background: #f6f8f5; }
.choice.danger:has(input:checked) { border-color: var(--neg); background: #fdf3f2; }
.choice input { margin-top: 3px; }
.choice b { display: block; font-size: 14.5px; }
.choice small { display: block; color: var(--muted); }
.x { border: 0; background: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); }
.batch-head, .batch-row { display: grid; grid-template-columns: 2fr 1.3fr 1fr .6fr 1.2fr; gap: 6px; }
.batch-head { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.batch-row { margin-bottom: 6px; }
.batch-row input, .batch-row select { margin: 0 !important; padding: 8px !important; font-size: 13.5px; }
.inv .list .row { cursor: pointer; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); max-width: calc(100vw - 32px); }
.toast.error { background: var(--neg); }

/* páginas simples */
.page { max-width: 980px; margin: 0 auto; padding: 24px 22px 60px; }
.page h1 { font-size: 26px; font-weight: 800; margin-bottom: 6px; }
.card { background: var(--panel); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px; }
.alert { padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; }
.alert.ok { background: #ddf2e6; color: #155c3c; } .alert.error { background: #fbe4e1; color: #8c2a22; } .alert.info { background: var(--brass-soft); color: #6d5420; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 9px 10px; border-bottom: 1px solid #eef0ed; }
.table .n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tfoot td { font-weight: 800; border-top: 2px solid var(--line); }
.scroll-x { overflow-x: auto; }
.auth { display: grid; place-items: center; min-height: 100vh; padding: 20px; background: radial-gradient(circle at 20% 0%, #24362d 0, var(--ink) 60%); }
.auth-card { width: min(400px, 100%); background: #fff; border-radius: 18px; padding: 30px 28px; box-shadow: 0 30px 80px rgba(0, 0, 0, .35); }
.auth-card .brand { color: var(--ink); margin-bottom: 18px; }

@media (max-width: 980px) {
  .grid { grid-template-columns: 1fr; }
  .grid .span2 { grid-row: auto; }
  .ledger-side { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
  .tabs { display: grid; grid-template-columns: 1fr 1fr; }
  .tabs button { white-space: nowrap; }
  body { font-size: 15px; }
  .top { padding: 8px 12px; gap: 8px; }
  .brand-t, .nav span { display: none; }
  .nav { justify-content: center; }
  .nav a { padding: 8px 10px; }
  .wrap { padding: 14px 12px 96px; }
  .monthbar { gap: 8px; }
  .month-t { min-width: 0; flex: 1; align-items: center; }
  .month-t h1 { font-size: 22px; }
  .monthbar .add { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 30; height: 52px; border-radius: 26px; padding: 0 22px; box-shadow: 0 10px 30px rgba(21, 32, 27, .35); }
  .ledger { padding: 16px; }
  .ledger-main { grid-template-columns: 1fr 1fr; }
  .ledger-main .sobra { grid-column: 1 / -1; border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 10px; }
  .ledger-main b { font-size: 23px; }
  .ledger-side { grid-template-columns: 1fr 1fr; }
  .filters input { width: 100%; }
  .row2, .row3 { grid-template-columns: 1fr; }
  .batch-head { display: none; }
  .batch-row { grid-template-columns: 1fr 1fr; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
  .batch-row .b-desc { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
