:root {
  --bg: #f4f6f5; --card: #fff; --text: #14201e; --muted: #6b7b78; --line: #e3e9e7;
  --brand: #0f766e; --income: #15803d; --expense: #b91c1c; --bar: #99d3cc;
  --u0: #2f6fdb; --u1: #d9822b; /* cor de cada pessoa */
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0e1514; --card: #172120; --text: #e8f0ee; --muted: #8fa3a0; --line: #26332f;
    --brand: #2dd4bf; --income: #4ade80; --expense: #f87171; --bar: #1f5e58;
    --u0: #6ea8fe; --u1: #f0b35a; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif; }
#app { max-width: 560px; margin: 0 auto; min-height: 100dvh; padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 96px); }
h1 { font-size: 1.4rem; margin: 8px 0 16px; }
h2 { font-size: 1rem; margin: 20px 0 8px; color: var(--muted); font-weight: 600; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.muted { color: var(--muted); font-size: .85rem; }
.income { color: var(--income); } .expense { color: var(--expense); }

label { display: block; font-size: .85rem; color: var(--muted); margin: 12px 0 4px; }
input, select, button { font: inherit; }
input, select { width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); }
input[type=date] { min-height: 46px; }
button { border: 0; border-radius: 10px; padding: 12px 16px; background: var(--brand); color: #fff; font-weight: 600; cursor: pointer; }
button.ghost { background: transparent; color: var(--brand); padding: 8px 10px; }
button.danger { background: transparent; color: var(--expense); padding: 8px 10px; }
button.full { width: 100%; margin-top: 16px; }
.err { color: var(--expense); font-size: .9rem; margin-top: 10px; min-height: 1.2em; }

.monthbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.monthbar strong { text-transform: capitalize; }
.balance { text-align: center; }
.balance .big { font-size: 2rem; font-weight: 700; margin: 4px 0; }
.split { display: flex; gap: 12px; margin-top: 8px; }
.split > div { flex: 1; text-align: center; }

.row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .ic { font-size: 1.4rem; width: 32px; text-align: center; }
.row .mid { flex: 1; min-width: 0; }
.row .mid div:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .val { font-weight: 600; white-space: nowrap; }

.top { display: flex; justify-content: space-between; align-items: baseline; }
.person { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; font-size: .92rem; }
.person + .person { border-top: 1px solid var(--line); }
.card > .muted + .person { margin-top: 6px; }
.chart { display: flex; gap: 4px; align-items: flex-end; height: 140px; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.chart .pair { display: flex; gap: 1px; align-items: flex-end; height: 110px; }
.chart .pair i { width: 6px; border-radius: 2px 2px 0 0; }
.chart span { font-size: .62rem; color: var(--muted); margin-top: 4px; }
.chart .cur span { color: var(--text); font-weight: 700; }
.bi { background: var(--income); } .be { background: var(--expense); }
.legend { display: flex; justify-content: center; gap: 16px; margin-top: 10px; font-size: .8rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; }
.icons { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.icons button { background: var(--card); border: 1px solid var(--line); font-size: 1.3rem; padding: 8px 0; }
.seg.view button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.seg.view button { padding: 9px 12px; font-size: .9rem; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: baseline; }
.persons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.persons .pc { margin-bottom: 0; }
.pc .pn { font-weight: 600; margin-bottom: 6px; }
.pc .muted { margin-top: 4px; }
.pc strong { display: block; }
.chips { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.chips button { background: var(--card); color: var(--text); border: 1px solid var(--line); padding: 7px 12px; font-size: .88rem; border-radius: 999px; }
.chips button.on { border-color: var(--brand); color: var(--brand); }
.chart .pair.thin { gap: 1px; }
.chart .pair.thin i { width: 5px; }
.chart .pair i.ex, .legend .sw.ex { opacity: .4; }
.legend .sw:not(.bi):not(.be) { background: var(--muted); }
.legend { flex-wrap: wrap; }
.legend .dot { border-radius: 50%; margin-right: 6px; }
form[hidden], button[hidden] { display: none; }
.bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; margin-top: 4px; }
.bar > i { display: block; height: 100%; background: var(--bar); }
.cat { margin: 10px 0; }
.cat .top { display: flex; justify-content: space-between; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs button { flex: 1; background: none; color: var(--muted); border-radius: 0; padding: 12px 0 10px; font-size: .8rem; }
.tabs button.on { color: var(--brand); }
.fab { position: fixed; right: 18px; bottom: calc(env(safe-area-inset-bottom) + 70px); width: 58px; height: 58px;
  border-radius: 50%; font-size: 2rem; line-height: 1; padding: 0; box-shadow: 0 4px 14px rgba(0,0,0,.25); }

.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet { background: var(--bg); width: 100%; max-width: 560px; border-radius: 18px 18px 0 0; padding: 16px 16px calc(env(safe-area-inset-bottom) + 16px); max-height: 92dvh; overflow: auto; }
.seg { display: flex; gap: 8px; }
.seg button { flex: 1; background: var(--card); color: var(--text); border: 1px solid var(--line); }
.seg button.on.expense { background: var(--expense); color: #fff; border-color: var(--expense); }
.seg button.on.income { background: var(--income); color: #fff; border-color: var(--income); }
.amount { font-size: 1.8rem; font-weight: 700; text-align: center; }

#toast { position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 12px); transform: translateX(-50%) translateY(-80px);
  background: #111; color: #fff; padding: 10px 16px; border-radius: 10px; transition: transform .25s; z-index: 20; }
#toast.show { transform: translateX(-50%) translateY(0); }
.center { text-align: center; padding-top: 12vh; }
