:root {
    --bg: #f2f4f6;
    --panel: #ffffff;
    --line: #e1e5ea;
    --ink: #14202b;
    --muted: #5b6875;
    --accent: #14664a;
    --accent-soft: #e3f1ea;
    --in: #1c7f53;
    --out: #b8364a;
    --warn: #b7791f;
    --radius: 10px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.5; }
a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0 0 .75rem; letter-spacing: -.01em; }
h2 { font-size: 1rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 1rem 0 .5rem; }
.num, .value, td.num, .share { font-variant-numeric: tabular-nums; }
.muted, .hint { color: var(--muted); }
.hint { font-size: .85rem; display: block; margin-top: .25rem; }
.lede { color: var(--muted); max-width: 62ch; }
.in { color: var(--in); }
.out { color: var(--out); }

.boot { min-height: 100vh; display: grid; place-content: center; text-align: center; gap: .25rem; color: var(--muted); }
.boot strong { font-size: 1.5rem; color: var(--ink); }

.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
    display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 2rem;
    padding: .9rem clamp(16px, 4vw, 40px); background: var(--ink); color: #fff;
}
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.2rem; display: flex; align-items: baseline; gap: .5rem; }
.brand span { font-weight: 400; font-size: .8rem; color: #9fb0bf; }
.tabs { display: flex; gap: .25rem; overflow-x: auto; max-width: 100%; }
.tabs a { color: #c9d4de; text-decoration: none; padding: .4rem .75rem; border-radius: 6px; white-space: nowrap; font-size: .92rem; }
.tabs a:hover { color: #fff; background: rgba(255,255,255,.08); }
.tabs a.active { color: #fff; background: rgba(255,255,255,.14); }

.banner { padding: .6rem clamp(16px, 4vw, 40px); background: var(--accent-soft); font-size: .9rem; }
.banner.warn { background: #fdf1dc; }
.content { flex: 1; width: 100%; max-width: 1120px; margin: 0 auto; padding: 1.5rem clamp(16px, 4vw, 40px) 3rem; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 1rem 16px 1.5rem; }

.pagehead { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: 1rem; }
.pagehead h1 { margin: 0; }
.monthnav { display: flex; align-items: center; gap: .25rem; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: .15rem; }
.monthnav .month { min-width: 11rem; text-align: center; font-weight: 600; font-size: .92rem; }
.icon { border: 0; background: transparent; width: 2rem; height: 2rem; border-radius: 999px; font-size: 1.2rem; cursor: pointer; color: var(--ink); }
.icon:hover { background: var(--bg); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .6rem 1.1rem; border-radius: 8px; border: 1px solid var(--line); background: var(--panel);
    color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: #c5ccd4; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #0f553d; }
.btn.danger { background: var(--out); border-color: var(--out); color: #fff; }
.link { border: 0; background: none; color: var(--accent); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }
.link.danger { color: var(--out); font-size: .85rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.empty { max-width: 640px; margin: 3rem auto; text-align: center; }
.empty h1 { font-size: 2rem; }
.empty p { color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .75rem; margin-top: 1.5rem; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.card, .panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; }
.card .label { color: var(--muted); font-size: .85rem; display: block; }
.card .value { font-size: 1.6rem; display: block; margin: .15rem 0; }
.delta { font-size: .8rem; font-weight: 600; }
.delta.good { color: var(--in); }
.delta.bad { color: var(--out); }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 1rem; margin-bottom: 1rem; }
.panelhead { display: flex; justify-content: space-between; align-items: baseline; }
.panelhead a { font-size: .85rem; }
.panel + .panel { margin-top: 1rem; }
.grid2 .panel + .panel { margin-top: 0; }

.chart { margin: 0; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); }
.chart .axis { fill: var(--muted); font-size: 11.5px; }
.bar-in { fill: var(--in); }
.bar-out { fill: var(--out); }
.legend { display: flex; gap: 1rem; font-size: .8rem; color: var(--muted); margin-top: .25rem; }
.dot { display: inline-block; width: .65rem; height: .65rem; border-radius: 3px; margin-right: .4rem; vertical-align: middle; }
.dot.in { background: var(--in); }
.dot.out { background: var(--out); }

.donut { display: grid; grid-template-columns: minmax(140px, 190px) 1fr; gap: 1rem; align-items: center; }
.donut svg { width: 100%; height: auto; }
.donut-label { fill: var(--muted); font-size: 12px; }
.donut-total { fill: var(--ink); font-size: 15px; font-weight: 700; }
.donut-legend { list-style: none; margin: 0; padding: 0; font-size: .85rem; }
.donut-legend li { display: grid; grid-template-columns: auto 1fr auto 3rem; align-items: center; gap: .35rem; padding: .2rem 0; }
.donut-legend .share { color: var(--muted); text-align: right; }
@media (max-width: 520px) { .donut { grid-template-columns: 1fr; } .donut svg { max-width: 200px; margin: 0 auto; } }

.budget { margin-bottom: .9rem; }
.row { display: flex; justify-content: space-between; gap: .75rem; font-size: .9rem; }
.bar { height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; margin-top: .3rem; }
.fill { height: 100%; border-radius: 999px; background: var(--in); }
.fill.atencao { background: var(--warn); }
.fill.estourado { background: var(--out); }

.filters { display: flex; flex-wrap: wrap; gap: .75rem 1.25rem; align-items: center; margin-bottom: 1rem; }
input, select { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .65rem; min-width: 0; }
input[type=search] { flex: 1 1 260px; }
.check { display: flex; align-items: center; gap: .4rem; font-size: .9rem; }
.check input { width: auto; }

.tablewrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.txs { width: 100%; border-collapse: collapse; font-size: .9rem; }
.txs th { text-align: left; font-weight: 600; color: var(--muted); font-size: .8rem; padding: .6rem .75rem; border-bottom: 1px solid var(--line); }
.txs td { padding: .5rem .75rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.txs tr:last-child td { border-bottom: 0; }
.txs .num { text-align: right; white-space: nowrap; }
.txs .date { color: var(--muted); white-space: nowrap; }
.txs .desc { min-width: 220px; }
.txs select { padding: .3rem .4rem; font-size: .85rem; max-width: 190px; }
.txs select.unset { border-style: dashed; color: var(--muted); }
.tag { font-size: .7rem; color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: 0 .3rem; margin-left: .35rem; }
.toast { background: var(--accent-soft); border: 1px solid #bfe0cf; padding: .6rem .9rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem; }

.drop {
    display: grid; place-items: center; gap: .25rem; padding: 2.5rem 1rem; margin: 1rem 0;
    border: 2px dashed #c3ccd5; border-radius: var(--radius); background: var(--panel); cursor: pointer; text-align: center;
}
.drop:hover { border-color: var(--accent); }
.drop input { max-width: 100%; }
.drop span { color: var(--muted); font-size: .85rem; }
.result h2 { word-break: break-all; }
.stats { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; }
.stats strong { font-size: 1.3rem; }
.errors { font-size: .85rem; color: var(--out); }

.limits { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: .5rem 1.5rem; }
.limit { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .35rem 0; border-bottom: 1px solid var(--line); }
.money { display: flex; align-items: center; gap: .35rem; color: var(--muted); }
.money input { width: 8.5rem; text-align: right; }
.goal { padding: .75rem 0; border-bottom: 1px solid var(--line); }
.inline { display: flex; align-items: center; gap: .5rem; font-size: .9rem; flex-wrap: wrap; }
.inline input { width: 8rem; }
.goalform, .ruleform { display: grid; gap: .75rem; max-width: 420px; }
.goalform label, .ruleform label { display: grid; gap: .3rem; font-size: .9rem; }
.ruleform { max-width: none; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); align-items: end; }

.rules { list-style: none; margin: 0; padding: 0; columns: 2 280px; column-gap: 2rem; }
.rules li { display: flex; align-items: center; gap: .5rem; padding: .3rem 0; break-inside: avoid; font-size: .9rem; }
.rules code { background: var(--bg); padding: .05rem .4rem; border-radius: 4px; }
.rules .arrow { color: var(--muted); }
.rules .link { margin-left: auto; }
.count { color: var(--muted); font-weight: 400; font-size: .85rem; }
.danger-zone { border-color: #f0c9cf; }

#blazor-error-ui { background: #fff4d6; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2); display: none; left: 0; padding: .6rem 1.25rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Celular: cada lançamento vira um cartão em vez de linha de tabela larga. */
@media (max-width: 640px) {
    .txs thead { display: none; }
    .txs, .txs tbody { display: block; }
    .txs tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .35rem .75rem; padding: .7rem .8rem; border-bottom: 1px solid var(--line); }
    .txs tr:last-child { border-bottom: 0; }
    .txs td { display: block; padding: 0; border: 0; }
    .txs td.desc { grid-column: 1; grid-row: 1; min-width: 0; font-weight: 600; }
    .txs td.num { grid-column: 2; grid-row: 1; }
    .txs td:nth-child(3) { grid-column: 1; grid-row: 2; }
    .txs td.date { grid-column: 2; grid-row: 2; text-align: right; align-self: center; }
    .txs select { max-width: 100%; }
}
