/* Financeiro da Casa — tema M&G. Sem fontes externas. */
:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --ink: #14211d;
  --ink-2: #3c4a45;
  --muted: #7d847f;
  --line: #e9e5dc;
  --line-2: #f1eee7;
  --green: #2f6b55;
  --green-soft: #e7f1ec;
  --red: #b5573f;
  --red-soft: #f8ebe6;
  --gold: #b8904f;
  --gold-soft: #f6efe1;
  --blue: #43668a;
  --blue-soft: #e8eef5;
  --gray-soft: #efeee9;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 33, 29, .04), 0 8px 24px -12px rgba(20, 33, 29, .12);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
h1, h2 { font-family: var(--serif); font-weight: 500; letter-spacing: -.01em; }
h3 { font-size: 15px; font-weight: 600; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.eyebrow { font-size: 10.5px; letter-spacing: .16em; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.eyebrow.light { color: rgba(255, 255, 255, .55); }
.error { color: var(--red); font-size: 13px; min-height: 1em; margin: 10px 0 0; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--green); }
.neg { color: var(--red); }

/* ---------- botões ---------- */
.btn { border: 1px solid transparent; border-radius: 11px; padding: 10px 16px; background: var(--surface); cursor: pointer; font-weight: 600; font-size: 13.5px; transition: background .15s, box-shadow .15s, transform .05s; display: inline-flex; align-items: center; gap: 6px; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: wait; }
.btn.primary { background: var(--ink); color: #fff; }
.btn.primary:hover { background: #24362f; }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.ghost:hover { background: var(--line-2); }
.btn.danger-ghost { background: transparent; color: var(--red); border-color: #efd5cc; }
.btn.danger-ghost:hover { background: var(--red-soft); }
.btn.wide { width: 100%; justify-content: center; padding: 13px; margin-top: 22px; }
.btn.sm { padding: 6px 11px; font-size: 12.5px; border-radius: 9px; }
.icon-btn { border: 1px solid var(--line); background: var(--surface); width: 34px; height: 34px; border-radius: 10px; cursor: pointer; font-size: 18px; line-height: 1; display: grid; place-items: center; }
.icon-btn:hover { background: var(--line-2); }
.link { background: none; border: 0; padding: 0; cursor: pointer; color: var(--muted); font-size: 12.5px; text-decoration: underline; text-underline-offset: 3px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 12.5px; cursor: pointer; }
.chip:hover { background: var(--line-2); }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--surface); }
.login-art { background: var(--ink); color: #fff; padding: 9vh 9%; display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden; }
.login-mark { width: 64px; filter: invert(1); opacity: .9; margin-bottom: 40px; }
.login-art h1 { font-size: clamp(34px, 4.4vw, 56px); line-height: 1.12; margin: 18px 0 20px; }
.login-art h1 em { color: #d6b77f; font-style: italic; }
.login-art p { color: rgba(255, 255, 255, .62); font-size: 16px; max-width: 420px; }
.login-chart { color: #d6b77f; width: 100%; max-width: 460px; margin-top: 50px; }
.login form { width: 100%; max-width: 380px; margin: auto; padding: 40px 24px; }
.brand-logo { width: 78px; display: block; margin-bottom: 28px; }
.login h2 { font-size: 30px; margin: 8px 0 18px; }
label { display: grid; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-top: 14px; }
input, select, textarea { width: 100%; border: 1px solid var(--line); background: #fdfcfa; border-radius: 11px; padding: 10px 12px; font-weight: 400; font-size: 14px; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); background: #fff; }
textarea { resize: vertical; min-height: 90px; line-height: 1.55; }
.lock { display: block; margin-top: 26px; color: var(--muted); font-size: 11.5px; text-align: center; }

/* ---------- estrutura ---------- */
.sidebar { position: fixed; inset: 0 auto 0 0; width: 232px; background: var(--ink); color: #fff; display: flex; flex-direction: column; padding: 22px 14px; z-index: 5; }
.brand { display: flex; gap: 12px; align-items: center; text-decoration: none; padding: 4px 10px 26px; }
.brand img { width: 40px; height: 40px; filter: invert(1); }
.brand span { font-family: var(--serif); font-size: 20px; line-height: 1.05; }
.brand small { display: block; font-family: var(--sans); font-size: 10.5px; letter-spacing: .18em; text-transform: uppercase; color: rgba(255, 255, 255, .5); margin-top: 3px; }
#nav { display: grid; gap: 3px; }
#nav a { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 11px; text-decoration: none; color: rgba(255, 255, 255, .68); font-weight: 500; }
#nav a svg { width: 19px; height: 19px; fill: currentColor; stroke: currentColor; flex: none; }
#nav a svg path[fill="none"], #nav a svg rect, #nav a svg circle { fill: none; }
#nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
#nav a.active { background: rgba(255, 255, 255, .1); color: #fff; }
#nav a.active svg { color: #d6b77f; }
.sidebar-foot { margin-top: auto; display: grid; gap: 14px; }
.integrity { display: flex; gap: 9px; align-items: center; font-size: 12px; color: rgba(255, 255, 255, .7); padding: 10px 12px; border-radius: 11px; background: rgba(255, 255, 255, .05); cursor: pointer; }
.integrity .dot { width: 8px; height: 8px; border-radius: 50%; background: #9aa; flex: none; }
.integrity.ok .dot { background: #6fcf97; box-shadow: 0 0 0 4px rgba(111, 207, 151, .15); }
.integrity.bad { background: rgba(181, 87, 63, .25); color: #fff; }
.integrity.bad .dot { background: #ff8b6b; }
.me { display: flex; align-items: center; gap: 10px; padding: 0 10px; font-size: 13px; }
.me .link { color: rgba(255, 255, 255, .55); margin-left: auto; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: #d6b77f; color: var(--ink); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
main { margin-left: 232px; min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 4; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 34px; background: rgba(246, 244, 239, .88); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.month-nav { display: flex; align-items: center; gap: 8px; }
.month-label { position: relative; margin: 0; font-family: var(--serif); font-size: 22px; font-weight: 500; color: var(--ink); min-width: 190px; text-align: center; cursor: pointer; text-transform: capitalize; }
.month-label input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.top-actions { display: flex; align-items: center; gap: 16px; }
.content { padding: 28px 34px 70px; max-width: 1360px; }
.notice { margin: 18px 34px 0; padding: 12px 16px; border-radius: 12px; background: var(--gold-soft); color: #6d5326; font-size: 13px; border: 1px solid #ecdcbc; max-width: 1292px; }
.notice.bad { background: var(--red-soft); color: #7b3020; border-color: #efd0c5; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 32px; line-height: 1.15; }
.page-head p { color: var(--muted); margin-top: 6px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.panel-head h3 { font-size: 15px; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: 1.25fr 1fr; }
.grid.half { grid-template-columns: 1fr 1fr; }
.stack { display: grid; gap: 16px; }
.empty { text-align: center; padding: 34px 20px; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-family: var(--serif); font-size: 18px; font-weight: 500; margin-bottom: 4px; }

/* ---------- visão do mês ---------- */
.hero { display: grid; grid-template-columns: 1.2fr 2fr; gap: 16px; margin-bottom: 16px; }
.hero-main { background: var(--ink); color: #fff; border-radius: var(--radius); padding: 24px 26px; position: relative; overflow: hidden; }
.hero-main .eyebrow { color: rgba(255, 255, 255, .55); }
.hero-main .big { font-family: var(--serif); font-size: 44px; line-height: 1.1; margin: 10px 0 6px; }
.hero-main .big.neg { color: #ff9f86; }
.hero-main .formula { color: rgba(255, 255, 255, .62); font-size: 12.5px; line-height: 1.7; }
.hero-main .formula b { color: #fff; font-weight: 600; }
.hero-main svg.spark { position: absolute; right: -10px; bottom: -6px; width: 60%; opacity: .25; color: #d6b77f; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 15px 16px; box-shadow: var(--shadow); min-width: 0; }
.kpi .label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.kpi .label i { width: 8px; height: 8px; border-radius: 3px; display: inline-block; }
.kpi .value { font-size: 21px; font-weight: 650; margin-top: 6px; letter-spacing: -.01em; }
.kpi .hint { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.bar { height: 7px; border-radius: 9px; background: var(--line-2); overflow: hidden; margin-top: 10px; }
.bar > span { display: block; height: 100%; border-radius: 9px; background: var(--green); width: 0; transition: width .6s ease; }
.bar.red > span { background: var(--red); }
.legend { display: grid; gap: 9px; }
.legend-row { display: grid; grid-template-columns: 12px 1fr auto auto; gap: 10px; align-items: center; font-size: 13px; }
.legend-row i { width: 10px; height: 10px; border-radius: 3px; }
.legend-row .pct { color: var(--muted); font-size: 12px; width: 40px; text-align: right; }
.donut-wrap { display: grid; grid-template-columns: 170px 1fr; gap: 22px; align-items: center; }
.donut-wrap svg { width: 170px; height: 170px; }
.attention { display: grid; gap: 2px; }
.att-row { display: grid; grid-template-columns: 96px 1fr auto; gap: 12px; align-items: center; padding: 10px 8px; border-radius: 10px; cursor: pointer; }
.att-row:hover { background: var(--line-2); }
.att-row .when { font-size: 11.5px; color: var(--muted); }
.mini-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.chart-bars svg { width: 100%; height: 210px; display: block; }
.chart-bars text { font-size: 11px; fill: var(--muted); font-family: var(--sans); }

/* ---------- status ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; border: 0; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.s-criado { background: var(--gray-soft); color: #5f6762; }
.s-aguardando { background: var(--blue-soft); color: var(--blue); }
.s-incerto { background: var(--gold-soft); color: #8b6a2e; }
.s-atrasado { background: var(--red-soft); color: var(--red); }
.s-pago { background: var(--green-soft); color: var(--green); }
select.pill { width: auto; appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 12px; box-shadow: none; }
.pill.auto { outline: 1px dashed currentColor; outline-offset: 1px; }
.tag { font-size: 11px; color: var(--muted); background: var(--line-2); border-radius: 6px; padding: 2px 7px; white-space: nowrap; }
.tag.gold { background: var(--gold-soft); color: #8b6a2e; }

/* ---------- tabelas ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar input[type=search] { max-width: 260px; background: var(--surface); }
.toolbar select { width: auto; background: var(--surface); }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--ink); color: #fff; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tbody tr { cursor: pointer; transition: background .1s; }
tbody tr:hover { background: #fbfaf7; }
tr.synthetic { cursor: default; background: #fcfaf5; }
tr.synthetic td:first-child { border-left: 3px solid var(--gold); }
td.r, th.r { text-align: right; }
.desc { font-weight: 600; }
.desc small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 1px; }
.row-actions { opacity: 0; transition: opacity .15s; }
tr:hover .row-actions { opacity: 1; }
tfoot td { font-weight: 600; border-bottom: 0; padding-top: 14px; }
.table-wrap { overflow-x: auto; }
.section-title { display: flex; align-items: baseline; gap: 12px; margin: 6px 0 10px; }
.section-title h3 { font-family: var(--serif); font-size: 20px; font-weight: 500; }
.totals { display: flex; gap: 18px; font-size: 12.5px; color: var(--muted); margin-left: auto; flex-wrap: wrap; }
.totals b { color: var(--ink); }

/* ---------- cartões ---------- */
.credit { border-radius: 16px; padding: 18px; color: #fff; min-height: 150px; display: flex; flex-direction: column; justify-content: space-between; cursor: pointer; position: relative; overflow: hidden; box-shadow: 0 10px 24px -14px rgba(0, 0, 0, .5); }
.credit::after { content: ""; position: absolute; width: 180px; height: 180px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .18); right: -60px; top: -70px; }
.credit .c-name { font-weight: 600; font-size: 15px; }
.credit .c-owner { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; opacity: .7; }
.credit .c-total { font-family: var(--serif); font-size: 28px; }
.credit .c-meta { display: flex; justify-content: space-between; font-size: 12px; opacity: .8; }
.credit.t0 { background: linear-gradient(135deg, #14211d, #2f4a40); }
.credit.t1 { background: linear-gradient(135deg, #5b3a2c, #b5573f); }
.credit.t2 { background: linear-gradient(135deg, #2b3b52, #43668a); }
.credit.t3 { background: linear-gradient(135deg, #6c5428, #b8904f); }
.credit.add { background: transparent; border: 1.5px dashed #d8d2c4; color: var(--muted); box-shadow: none; align-items: center; justify-content: center; font-weight: 600; }
.credit.add::after { display: none; }
.owner-block { margin-bottom: 26px; }
.owner-block .section-title h3 span { color: var(--muted); font-size: 15px; font-family: var(--sans); }

/* ---------- histórico ---------- */
.timeline { display: grid; gap: 0; }
.ev { display: grid; grid-template-columns: 34px 1fr; gap: 14px; padding: 14px 4px; border-bottom: 1px solid var(--line-2); }
.ev .avatar { width: 34px; height: 34px; }
.ev-head { display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.ev-head b { font-weight: 600; }
.ev-head .when { color: var(--muted); font-size: 12px; margin-left: auto; }
.ev-reason { color: var(--ink-2); font-size: 13px; margin-top: 3px; font-style: italic; }
.diff { margin-top: 8px; display: grid; gap: 4px; font-size: 12.5px; }
.diff-row { display: grid; grid-template-columns: 140px 1fr; gap: 10px; }
.diff-row .k { color: var(--muted); }
.diff-row del { color: var(--red); background: var(--red-soft); text-decoration: line-through; padding: 0 4px; border-radius: 4px; }
.diff-row ins { color: var(--green); background: var(--green-soft); text-decoration: none; padding: 0 4px; border-radius: 4px; }
.hash { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; color: var(--muted); }
.act { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 2px 8px; border-radius: 6px; background: var(--line-2); color: var(--ink-2); }
.act.criar, .act.recorrência { background: var(--green-soft); color: var(--green); }
.act.editar { background: var(--blue-soft); color: var(--blue); }
.act.arquivar { background: var(--red-soft); color: var(--red); }
.seal { display: flex; gap: 14px; align-items: center; }
.seal .badge { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-size: 20px; background: var(--green-soft); color: var(--green); flex: none; }
.seal.bad .badge { background: var(--red-soft); color: var(--red); }
.item-history { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; max-height: 220px; overflow: auto; }
.item-history .ev { padding: 9px 0; grid-template-columns: 26px 1fr; gap: 10px; }
.item-history .avatar { width: 26px; height: 26px; font-size: 11px; }

/* ---------- formulário ---------- */
dialog { border: 0; border-radius: 20px; padding: 0; width: min(680px, 94vw); box-shadow: 0 30px 80px -20px rgba(20, 33, 29, .45); color: var(--ink); }
dialog::backdrop { background: rgba(20, 33, 29, .45); backdrop-filter: blur(3px); }
#editor { padding: 24px 26px; max-height: 90vh; overflow: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 4px; }
.modal-head h2 { font-size: 26px; margin-top: 3px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid label.check { display: flex; align-items: center; gap: 9px; font-weight: 500; margin-top: 18px; }
.form-grid label.check input { width: 18px; height: 18px; accent-color: var(--ink); }
.dir-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; grid-column: 1 / -1; margin-top: 12px; }
.dir-toggle button { border: 1.5px solid var(--line); background: #fdfcfa; padding: 11px; border-radius: 12px; cursor: pointer; font-weight: 600; color: var(--muted); }
.dir-toggle button.on.income { border-color: var(--green); background: var(--green-soft); color: var(--green); }
.dir-toggle button.on.expense { border-color: var(--red); background: var(--red-soft); color: var(--red); }
.money-input { position: relative; }
.money-input::before { content: "R$"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 13px; }
.money-input input { padding-left: 36px; font-weight: 600; }
.help { font-size: 11.5px; color: var(--muted); font-weight: 400; }
.modal-actions { display: flex; gap: 10px; align-items: center; margin-top: 20px; }
.spacer { flex: 1; }
.note-area { min-height: 380px; font-size: 15px; line-height: 1.7; background: #fffdf8; }
#toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 13.5px; box-shadow: var(--shadow); z-index: 50; max-width: 90vw; }
#toast.bad { background: var(--red); }

/* ---------- responsivo ---------- */
@media (max-width: 1100px) {
  .hero { grid-template-columns: 1fr; }
  .grid.two, .grid.half { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .login { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .sidebar { inset: auto 0 0 0; width: auto; height: 64px; flex-direction: row; padding: 6px; border-top: 1px solid rgba(255, 255, 255, .08); }
  .brand, .sidebar-foot { display: none; }
  #nav { grid-template-columns: repeat(6, 1fr); width: 100%; }
  #nav a { flex-direction: column; gap: 3px; padding: 6px 2px; font-size: 10px; justify-content: center; }
  #nav a span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  main { margin-left: 0; padding-bottom: 70px; }
  .topbar { padding: 10px 14px; flex-wrap: wrap; }
  .top-actions #updated { display: none; }
  .month-label { min-width: 0; font-size: 18px; }
  .content { padding: 18px 14px 40px; }
  .notice { margin: 12px 14px 0; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .donut-wrap { grid-template-columns: 1fr; justify-items: center; }
  .form-grid { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  .row-actions { opacity: 1; }
  .diff-row { grid-template-columns: 1fr; gap: 0; }
}
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.grid + .grid, .hero + .grid { margin-top: 16px; }
.kpi .btn { margin-top: 10px; }
.owner-block .mini-cards { margin-bottom: 14px; }
.panel-head .small { white-space: nowrap; }
