/* Contas em Família — mesma base visual dos apps financeiros (tokens dataviz) */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #1f7a5c;
  --accent-ink: #fff;
  --good: #006300;
  --warn: #b26a00;
  --danger: #d03b3b;
  --s0: #898781;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
  --bia: #e87ba4;      /* magenta — Beatriz */
  --pai: #2a78d6;      /* azul — Pai */
  --shadow: 0 1px 3px rgba(11,11,11,.08), 0 6px 24px rgba(11,11,11,.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #2f9d78;
    --good: #0ca30c;
    --warn: #e0a030;
    --danger: #e66767;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --bia: #d55181;
    --pai: #3987e5;
    --shadow: none;
  }
}

* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
}
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; }
input, select, textarea {
  font: inherit; color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--baseline);
  border-radius: 12px; padding: 12px 14px; width: 100%; font-size: 17px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--ink-2); margin: 10px 0; }
.lbl { font-size: 14px; color: var(--ink-2); display: block; margin: 10px 0 4px; }
.err { color: var(--danger); font-size: 14px; min-height: 1em; margin-top: 6px; }
.hint { font-size: 13px; color: var(--muted); line-height: 1.4; }
.hint b { color: var(--ink-2); }

/* ===== login ===== */
.login {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(120% 80% at 50% 0%, color-mix(in srgb, var(--accent) 22%, var(--page)), var(--page) 70%);
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 22px;
  box-shadow: var(--shadow); padding: 32px 24px; text-align: center;
}
.login-logo { font-size: 48px; }
.login-card h1 { font-size: 27px; line-height: 1.15; margin: 8px 0 4px; }
.login-sub { color: var(--muted); margin-bottom: 22px; }
.user-pills { display: flex; gap: 10px; margin-bottom: 14px; }
.pill {
  flex: 1; padding: 16px 10px; border-radius: 14px; border: 1px solid var(--baseline);
  background: var(--surface); color: var(--ink); font-weight: 700; font-size: 17px;
}
.pill.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
#login-pass { margin-bottom: 12px; text-align: center; font-size: 22px; letter-spacing: .1em; }
.btn-primary {
  width: 100%; background: var(--accent); color: var(--accent-ink);
  border: 0; border-radius: 14px; padding: 15px 18px; font-weight: 700; font-size: 17px;
}
.btn-primary:disabled { opacity: .5; cursor: default; }
.btn-secondary {
  width: 100%; background: var(--surface); color: var(--ink);
  border: 1px solid var(--baseline); border-radius: 14px; padding: 14px 18px; font-weight: 700; font-size: 16px;
}
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); border-radius: 14px; padding: 14px 18px; font-weight: 600; }
.btn-big {
  display: flex; align-items: center; gap: 14px; width: 100%;
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 18px;
  padding: 18px 20px; font-weight: 700; font-size: 18px; text-align: left; box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.btn-big span.ic { font-size: 28px; line-height: 1; }
.btn-big small { display: block; font-weight: 500; font-size: 13px; opacity: .85; margin-top: 2px; }
.btn-big.alt { background: var(--surface); color: var(--ink); border: 1px solid var(--baseline); }
.btn-big:disabled { opacity: .55; }

/* ===== shell ===== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(env(safe-area-inset-top) + 14px) 18px 12px;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(10px);
  font-weight: 700; font-size: 19px;
  border-bottom: 1px solid var(--border);
}
.topbar-user { font-size: 13px; font-weight: 500; color: var(--muted); }
main { padding: 16px 16px 110px; max-width: 640px; margin: 0 auto; }
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 9px 0 11px; border: 0; background: none; color: var(--muted);
  font-size: 12px; font-weight: 600;
}
.nav-btn span { font-size: 22px; }
.nav-btn.active { color: var(--accent); }

/* ===== cards & tiles ===== */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.card h3 { font-size: 14px; color: var(--ink-2); font-weight: 600; margin-bottom: 10px; text-transform: uppercase; letter-spacing: .04em; }
.card h2 { font-size: 18px; margin-bottom: 8px; }
.card p { font-size: 15px; line-height: 1.45; }
.card.mod-loan { border-left: 5px solid var(--accent); }
.card.mod-ledger { border-left: 5px solid var(--s4); }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 14px; box-shadow: var(--shadow);
}
.tile .t-label { font-size: 12.5px; color: var(--muted); }
.tile .t-value { font-size: 21px; font-weight: 750; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .t-sub { font-size: 12.5px; color: var(--ink-2); margin-top: 3px; line-height: 1.35; }
.tile.wide { grid-column: 1 / -1; }
.hero { text-align: center; padding: 22px 16px; }
.hero .h-label { font-size: 14px; color: var(--muted); }
.hero .h-value { font-size: 38px; font-weight: 800; margin: 4px 0 2px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.hero .h-sub { font-size: 14px; color: var(--ink-2); line-height: 1.4; }
.hero.bia .h-value { color: var(--bia); }
.hero.pai .h-value { color: var(--pai); }
.hero.ok .h-value { color: var(--good); }
.who { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; color: #fff; }
.who.bia { background: var(--bia); }
.who.pai { background: var(--pai); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; background: var(--grid); color: var(--ink-2); }
.badge.good { background: color-mix(in srgb, var(--good) 15%, var(--surface)); color: var(--good); }
.badge.warn { background: color-mix(in srgb, var(--warn) 15%, var(--surface)); color: var(--warn); }
.badge.danger { background: color-mix(in srgb, var(--danger) 15%, var(--surface)); color: var(--danger); }
.badge.accent { background: color-mix(in srgb, var(--accent) 15%, var(--surface)); color: var(--accent); }

/* ===== filtros de período ===== */
.filters { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 8px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip {
  white-space: nowrap; border: 1px solid var(--baseline); background: var(--surface);
  color: var(--ink-2); border-radius: 999px; padding: 8px 15px; font-size: 14px; font-weight: 600;
}
.chip.on { background: var(--ink); color: var(--page); border-color: var(--ink); }

/* ===== listas ===== */
.month-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 18px 4px 8px; font-weight: 700; font-size: 15px;
}
.month-head small { color: var(--muted); font-weight: 600; }
.tx {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 12px 14px; margin-bottom: 8px; cursor: pointer;
}
.tx .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.tx .tx-main { flex: 1; min-width: 0; }
.tx .tx-desc { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx .tx-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; line-height: 1.35; }
.tx .tx-right { text-align: right; }
.tx .tx-val { font-weight: 750; font-size: 15px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tx .tx-val.bia { color: var(--bia); }
.tx .tx-val.pai { color: var(--pai); }
.tx .tx-sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.tx.comp { border-style: dashed; }

/* ===== gráficos ===== */
.chart-wrap { position: relative; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--ink); color: var(--page);
  border-radius: 8px; padding: 6px 10px; font-size: 12px; line-height: 1.35;
  transform: translate(-50%, calc(-100% - 8px)); white-space: nowrap;
  opacity: 0; transition: opacity .1s;
}
.chart-tip b { display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; }
.legend .li { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); }
.legend .sw { width: 14px; height: 3px; border-radius: 3px; flex: none; }
svg text { font-family: inherit; }

/* ===== barras ===== */
.progress { background: var(--grid); border-radius: 999px; height: 12px; overflow: hidden; margin: 8px 0 4px; }
.progress > div { height: 100%; border-radius: 999px; background: var(--accent); }
.prog-row { margin-bottom: 12px; }
.prog-row .p-head { display: flex; justify-content: space-between; font-size: 14px; }
.prog-row .p-sub { font-size: 12.5px; color: var(--muted); }

/* ===== tabelas ===== */
.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: right; color: var(--muted); font-weight: 600;
  border-bottom: 1px solid var(--grid); padding: 6px 8px; white-space: nowrap;
}
table.data td { text-align: right; padding: 7px 8px; border-bottom: 1px solid var(--grid); font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; }
.mrow { padding: 10px 0; border-bottom: 1px solid var(--grid); }
.mrow:last-child { border-bottom: 0; }
.mrow-head { font-size: 14px; color: var(--ink-2); margin-bottom: 6px; }
.mrow-head b { color: var(--ink); }
.mrow-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.mrow-grid div { display: flex; justify-content: space-between; font-size: 13.5px; }
.mrow-grid span { color: var(--muted); }
.mrow-grid b { font-variant-numeric: tabular-nums; font-weight: 650; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--grid); font-size: 15px; }
.kv:last-child { border-bottom: 0; }
.kv b { font-variant-numeric: tabular-nums; }
.kv .k { color: var(--ink-2); }

/* ===== modal ===== */
.modal {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.45);
  display: grid; place-items: end center;
}
.modal-card {
  width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto;
  background: var(--page); border-radius: 22px 22px 0 0; padding: 18px 18px calc(env(safe-area-inset-bottom) + 18px);
}
@media (min-width: 640px) { .modal { place-items: center; } .modal-card { border-radius: 22px; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.modal-head h2 { font-size: 19px; }
.icon-btn { border: 0; background: var(--surface); border-radius: 50%; width: 36px; height: 36px; color: var(--ink-2); font-size: 16px; }
.seg { display: flex; gap: 8px; margin: 8px 0; }
.seg button {
  flex: 1; padding: 14px 8px; border-radius: 12px; border: 1px solid var(--baseline);
  background: var(--surface); color: var(--ink-2); font-weight: 700; font-size: 15px;
}
.seg button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.seg button.on.bia { background: var(--bia); border-color: var(--bia); }
.seg button.on.pai { background: var(--pai); border-color: var(--pai); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-actions { display: flex; gap: 10px; margin-top: 14px; }
.modal-actions .btn-primary { flex: 1; }
.receipt { white-space: pre-wrap; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; background: var(--page); border: 1px solid var(--grid); border-radius: 10px; padding: 10px; margin-top: 8px; color: var(--ink-2); }
details summary { cursor: pointer; font-size: 13px; color: var(--accent); font-weight: 600; margin-top: 6px; }

/* ===== misc ===== */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 90px);
  transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: var(--page);
  padding: 12px 20px; border-radius: 999px; font-size: 15px; font-weight: 600;
  box-shadow: var(--shadow); max-width: 92vw; text-align: center;
}
.empty { text-align: center; color: var(--muted); padding: 28px 12px; font-size: 15px; line-height: 1.45; }
.note {
  font-size: 13.5px; color: var(--ink-2); background: color-mix(in srgb, var(--s4) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--s4) 35%, transparent);
  border-radius: 12px; padding: 10px 12px; margin-bottom: 14px; line-height: 1.45;
}
.note.danger { background: color-mix(in srgb, var(--danger) 10%, var(--surface)); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.mais-list { display: flex; flex-direction: column; gap: 8px; }
.mais-item {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px; font-weight: 600; cursor: pointer; font-size: 16px;
}
.section-title { font-size: 13px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; margin: 18px 4px 8px; }
.split { display: flex; gap: 10px; }
.split > * { flex: 1; }
