/* Upwork-style: grey sidebar, white content panel, flat grey blocks instead of outlined cards,
   faint dividers, green for actions, one black feature card, one soft lime gradient for reminders. */
:root {
  --ink: #181818;
  --ink-2: #3d3d3d;
  --muted: #6b6b6b;
  --faint: #9a9a9a;
  --line: #ececec;
  --line-2: #e0e0e0;
  --side: #f2f4f5;
  --panel: #f7f7f7;
  --track: #e8e8e8;
  --white: #ffffff;
  --green: #108a00;
  --green-hover: #0c7300;
  --green-soft: #e6f4e2;
  --green-ink: #0b6b00;
  --red: #c4291c;
  --red-soft: #fcebe9;
  --amber-soft: #fbf1d5;
  --amber-ink: #7d5400;
  --blue-soft: #e8eefb;
  --blue-ink: #1f4fa3;
  --black: #121212;
  --lime: linear-gradient(100deg, #e2f4dc 0%, #e8f6cc 55%, #eef8b9 100%);
  --radius: 20px;
  --font: "Neue Montreal", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Segoe UI", Arial, sans-serif;
  --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23181818' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--side); -webkit-font-smoothing: antialiased; }
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 500; letter-spacing: -0.02em; }
h1 { font-size: 32px; line-height: 1.15; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
p { margin: 0; }
small, .muted { color: var(--muted); }
b, strong { font-weight: 600; }
hr { border: 0; border-top: 1px solid var(--line-2); margin: 10px 8px; }
.ic { flex: none; display: block; }
.num { font-variant-numeric: tabular-nums; }
.green { color: var(--green-ink); }
.red { color: var(--red); }

/* ---------- Shell: sidebar + white content panel ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 264px; flex: none; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 14px 12px 14px; overflow-y: auto; background: var(--side); }
.side-top { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 14px; }
.logo { font-size: 28px; font-weight: 700; color: var(--ink); letter-spacing: -0.06em; text-decoration: none !important; line-height: 1; }
.sidebar .side-close { display: none; }
.profile { display: flex; align-items: center; gap: 12px; padding: 10px 8px 16px; border-bottom: 1px solid var(--line-2); margin-bottom: 14px; color: var(--ink); text-decoration: none !important; }
.avatar { width: 40px; height: 40px; border-radius: 999px; background: var(--black); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 16px; flex: none; }
.profile-text { flex: 1; display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.profile-text b { font-weight: 500; font-size: 15.5px; }
.profile-text small { font-size: 13px; }
.profile-chev { color: var(--muted); }
.add-menu { position: relative; margin: 0 4px 12px; }
.add-btn { width: 100%; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a { display: flex; align-items: center; gap: 14px; padding: 10px 12px; border-radius: 10px; color: var(--ink); font-size: 16px; text-decoration: none; }
.side-nav a .ic { color: var(--ink-2); }
.side-nav a:hover { background: #e8ecee; }
.side-nav a.active { background: #dfe4e8; font-weight: 500; }
.side-bottom { margin-top: auto; padding-top: 10px; }
.dropdown { position: absolute; left: 0; right: 0; top: calc(100% + 6px); background: #fff; border-radius: 14px; box-shadow: 0 10px 34px rgba(0, 0, 0, .14); padding: 6px; z-index: 30; }
.dropdown button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 10px 12px; border-radius: 9px; font: inherit; color: var(--ink); cursor: pointer; }
.dropdown button:hover { background: var(--panel); }
/* White page sits flush top/right with one big rounded corner against the sidebar */
.main-wrap { flex: 1; min-width: 0; padding: 8px 0 0 0; }
.page { background: var(--white); border-radius: 40px 0 0 0; min-height: calc(100vh - 8px); padding: 40px 48px 80px; box-shadow: -1px 0 0 rgba(0, 0, 0, .03); }
.page > * { max-width: 1240px; margin-left: auto; margin-right: auto; }
.mobile-bar { display: none; }
.scrim { display: none; }
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0, 0, 0, .15); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .3); z-index: 35; }
  .sidebar .side-close { display: grid; }
  .main-wrap { padding: 0; }
  .mobile-bar { display: flex; align-items: center; gap: 10px; padding: max(12px, env(safe-area-inset-top)) 16px 12px; position: sticky; top: 0; background: var(--side); z-index: 20; }
  .sidebar { padding-top: max(14px, env(safe-area-inset-top)); }
  .mobile-bar .logo { font-size: 24px; }
  .page { border-radius: 0; padding: 22px 16px calc(60px + env(safe-area-inset-bottom)); }
}

/* ---------- Page layout ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.page-head p { color: var(--muted); margin-top: 6px; font-size: 15.5px; }
.page-head .actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1fr) 340px; gap: 32px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
@media (max-width: 1180px) { .grid-main { grid-template-columns: minmax(0, 1fr); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } h1 { font-size: 26px; } }

/* ---------- Blocks (no outlines: light grey panels) ---------- */
.card { background: var(--panel); border-radius: var(--radius); padding: 24px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head h3 { font-size: 18px; }
.card-head a { font-weight: 500; }
.card-flush { background: transparent; padding: 0; border-radius: 0; }
.card-flush .card-head { padding: 0 0 4px; }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .label { color: var(--muted); font-size: 14px; }
.stat .value { font-size: 28px; font-weight: 500; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat .sub { font-size: 13.5px; color: var(--muted); }
/* The one dark feature card per page */
.hero { background: var(--black); color: #fff; }
.hero .label, .hero .sub, .hero small, .hero .muted { color: rgba(255, 255, 255, .72); }
.hero .green { color: #8fe07f; }
a.card { color: inherit; text-decoration: none !important; transition: background .15s; }
a.card:hover { background: #f0f0f0; }
a.card.hero { color: #fff; }
a.card.hero:hover { background: #222; }
/* Soft lime gradient, only for reminders */
.callout { background: var(--lime); border-radius: 16px; padding: 16px 20px; color: var(--ink); }
.callout-amber { background: var(--amber-soft); }
.callout-red { background: var(--red-soft); }
.banner { display: flex; align-items: center; gap: 14px; background: var(--lime); border-radius: 16px; padding: 14px 18px; margin-bottom: 24px; }
.banner .ic { color: var(--green-ink); }
.banner .grow { flex: 1; min-width: 0; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 22px; border-radius: 999px; border: 0; font: inherit; font-weight: 500; font-size: 15px; cursor: pointer; white-space: nowrap; transition: background .15s, color .15s, box-shadow .15s; text-decoration: none !important; }
.btn-sm { height: 36px; padding: 0 18px; font-size: 14.5px; }
.btn-xs { height: 30px; padding: 0 14px; font-size: 13.5px; }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-hover); }
.btn-outline { background: #fff; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); }
.btn-outline:hover { background: var(--panel); }
.card .btn-outline { box-shadow: none; }
.hero .btn-outline { background: #fff; color: var(--ink); }
.btn-dark { background: var(--black); color: #fff; }
.btn-dark:hover { background: #2b2b2b; }
.btn-ghost { background: transparent; color: var(--green); padding: 0 12px; }
.btn-ghost:hover { background: var(--green-soft); }
.btn-danger-ghost { background: transparent; color: var(--red); }
.btn-danger-ghost:hover { background: var(--red-soft); }
.btn-whatsapp { background: #1fa855; color: #fff; }
.btn-whatsapp:hover { background: #178c46; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { border: 0; background: none; width: 40px; height: 40px; border-radius: 999px; cursor: pointer; color: var(--ink-2); display: grid; place-items: center; }
.icon-btn:hover { background: #e7e7e7; }
.link-btn { border: 0; background: none; padding: 0; font: inherit; color: var(--green); cursor: pointer; font-weight: 500; }
.link-btn:hover { text-decoration: underline; }

/* ---------- Chips ---------- */
.chip { display: inline-flex; align-items: center; height: 26px; padding: 0 11px; border-radius: 999px; font-size: 13px; font-weight: 500; background: #ececec; color: var(--ink-2); white-space: nowrap; }
.chip-green { background: var(--green-soft); color: var(--green-ink); }
.chip-amber { background: var(--amber-soft); color: var(--amber-ink); }
.chip-blue { background: var(--blue-soft); color: var(--blue-ink); }
.chip-red { background: var(--red-soft); color: var(--red); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.pill-toggle { display: inline-flex; background: var(--panel); border-radius: 999px; padding: 4px; }
.pill-toggle button { border: 0; background: none; font: inherit; font-size: 14.5px; padding: 7px 16px; border-radius: 999px; cursor: pointer; color: var(--ink-2); }
.pill-toggle button.on { background: #fff; color: var(--ink); font-weight: 500; box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }

/* ---------- Forms ---------- */
input, select, textarea { font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line-2); border-radius: 12px; padding: 0 14px; height: 44px; width: 100%; outline: none; transition: border-color .15s, box-shadow .15s; }
select { appearance: none; -webkit-appearance: none; background-image: var(--chev); background-repeat: no-repeat; background-position: right 14px center; background-size: 18px; padding-right: 42px; cursor: pointer; text-overflow: ellipsis; }
textarea { padding: 12px 14px; height: auto; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--green); flex: none; margin: 1px 0 0; border-radius: 6px; }
input[type=color] { padding: 4px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field label { font-weight: 500; font-size: 14.5px; }
.field small { font-size: 13px; }
.field.check { flex-direction: row; align-items: flex-start; gap: 12px; cursor: pointer; }
.field.check span { display: flex; flex-direction: column; font-size: 15px; }
.is-hidden { display: none !important; }
.form-preview { background: var(--panel); border-radius: 12px; padding: 12px 16px; font-size: 15px; }
.form-intro { color: var(--muted); }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 20px; }
.filters input, .filters select { width: auto; min-width: 170px; }
.filters input[type=search] { flex: 1; min-width: 240px; max-width: 420px; padding-left: 44px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23181818' stroke-width='1.75' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E") no-repeat 14px center / 19px; border-radius: 999px; }
.inline-input { width: 130px; height: 36px; }

/* ---------- Tables: no box, just faint dividers ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 13.5px; padding: 10px 14px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
td { padding: 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th:first-child, td:first-child { padding-left: 4px; }
th:last-child, td:last-child { padding-right: 4px; }
.card table th:first-child, .card table td:first-child { padding-left: 0; }
tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover td { background: #fafafa; }
td.right, th.right { text-align: right; }
td.amount { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.date, .table-wrap td:first-child { white-space: nowrap; }
td .sub { display: block; font-size: 13px; color: var(--muted); margin-top: 1px; }
tr.group-row td { background: var(--panel); font-weight: 600; font-size: 14px; color: var(--ink-2); padding: 9px 14px; border-bottom: 0; }
tr.group-row td:first-child { border-radius: 10px 0 0 10px; padding-left: 14px; }
tr.group-row td:last-child { border-radius: 0 10px 10px 0; padding-right: 14px; }
tfoot td { font-weight: 600; border-top: 1px solid var(--line-2); }

/* ---------- Lists ---------- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line-2); }
.card .list-item { border-bottom-color: #e6e6e6; }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .meta { font-size: 13.5px; color: var(--muted); }
.check-dot { width: 26px; height: 26px; border-radius: 999px; background: #fff; box-shadow: inset 0 0 0 1.5px #d4d4d4; display: grid; place-items: center; flex: none; font-size: 13px; color: #fff; }
.check-dot.done { background: var(--green); box-shadow: none; }

/* ---------- Bars, progress, charts ---------- */
.hbars { display: flex; flex-direction: column; gap: 14px; }
.hbar[data-action] { cursor: pointer; }
.hbar-top { display: flex; justify-content: space-between; gap: 10px; font-size: 14.5px; margin-bottom: 6px; }
.hbar-top b { font-variant-numeric: tabular-nums; font-weight: 500; }
.hbar-track { height: 8px; border-radius: 99px; background: var(--track); overflow: hidden; }
.hbar-track div { height: 100%; border-radius: 99px; }
.progress { height: 8px; border-radius: 99px; background: var(--track); overflow: hidden; }
.hero .progress { background: rgba(255, 255, 255, .18); }
.progress div { height: 100%; background: var(--green); border-radius: 99px; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: #e4e4e4; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.legend { display: flex; gap: 18px; font-size: 13.5px; color: var(--muted); margin-bottom: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.months-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; }
.month-cell { text-align: center; font-size: 11.5px; padding: 6px 0; border-radius: 8px; background: #ececec; color: var(--muted); }
.month-cell.ok { background: var(--green-soft); color: var(--green-ink); font-weight: 600; }
.month-cell.miss { background: var(--red-soft); color: var(--red); }
@media (max-width: 680px) { .months-grid { grid-template-columns: repeat(6, 1fr); } }

/* ---------- Accounts ---------- */
.acct { display: flex; flex-direction: column; gap: 12px; }
.acct-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.acct-name { font-weight: 500; font-size: 16.5px; }
.acct-bal { font-size: 26px; font-weight: 500; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.acct-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }

/* ---------- Report picker ---------- */
.tree { display: flex; flex-direction: column; gap: 2px; max-height: 540px; overflow: auto; padding-right: 4px; }
.tree .cat-line { display: flex; align-items: center; gap: 4px; padding: 4px 2px; border-radius: 10px; }
.tree .cat-line:hover { background: #efefef; }
.tree .cat-line label { flex: 1; }
.tree .caret { width: 26px; height: 26px; border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 10px; border-radius: 8px; transition: transform .15s; flex: none; }
.tree .caret:hover { background: #e7e7e7; }
.tree .cat-row.open .caret { transform: rotate(90deg); }
.tree .subs { padding: 2px 0 8px 58px; display: flex; flex-direction: column; gap: 6px; }
.tree label { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 15px; }
.tree .count { margin-left: auto; color: var(--muted); font-size: 13px; }

/* ---------- Modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .12s ease-out; }
.modal { background: #fff; border-radius: 24px; width: min(640px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 24px 70px rgba(0, 0, 0, .25); }
.modal-wide { width: min(920px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 24px 28px 8px; }
.modal-head h2 { font-size: 24px; }
.modal-body { padding: 14px 28px 20px; overflow: auto; }
.modal-foot { display: flex; align-items: center; gap: 10px; padding: 14px 28px 24px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }

/* ---------- Misc ---------- */
.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); background: var(--black); color: #fff; padding: 12px 22px; border-radius: 999px; opacity: 0; transition: all .25s; z-index: 60; font-size: 15px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-error { background: var(--red); }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 14px; }
.loading { padding: 80px; text-align: center; color: var(--muted); }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 9px 16px; font-size: 15px; }
.kv > :nth-child(even) { text-align: right; font-variant-numeric: tabular-nums; }
.kv .total { font-weight: 600; border-top: 1px solid var(--line-2); padding-top: 9px; }
.evidence { font-size: 14.5px; }
.evidence td { vertical-align: top; }
details.learn { background: var(--panel); border-radius: 16px; padding: 0 20px; }
details.learn > summary { cursor: pointer; padding: 16px 0; font-weight: 500; }
details.learn[open] > summary { border-bottom: 1px solid var(--line-2); margin-bottom: 12px; }
details.learn > div { padding-bottom: 18px; }
.tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--line-2); margin-bottom: 22px; overflow-x: auto; }
.tabs button { border: 0; background: none; font: inherit; font-weight: 500; font-size: 15.5px; padding: 10px 0; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--ink); border-color: var(--ink); }
.section-title { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 6px 0 12px; }
.price-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--muted); }

[hidden] { display: none !important; }

/* ---------- Lock screen ---------- */
.lock { position: fixed; inset: 0; z-index: 100; background: var(--side); display: grid; place-items: center; padding: 16px; }
.lock-card { background: #fff; border-radius: 28px; padding: 40px 36px 32px; width: min(380px, 100%); display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; box-shadow: 0 20px 60px rgba(0, 0, 0, .08); }
.lock-card .logo { font-size: 30px; margin-bottom: 8px; }
.lock-icon { width: 56px; height: 56px; border-radius: 999px; background: var(--black); color: #fff; display: grid; place-items: center; }
.lock-card h2 { font-size: 22px; }
.lock-card input { text-align: center; font-size: 26px; letter-spacing: .5em; height: 56px; border-radius: 14px; }
.lock-card .btn { width: 100%; }
.lock-error { color: var(--red); min-height: 20px; font-size: 14px; }
.lock-card small { font-size: 12.5px; }

.lock-remember { display: flex; align-items: center; gap: 10px; font-size: 14.5px; color: var(--ink-2); cursor: pointer; align-self: flex-start; text-align: left; }
.lock-remember input { width: 20px; height: 20px; flex: none; margin: 0; }

/* ---------- Phone ---------- */
.tabbar, .sheet, .sheet-scrim { display: none; }
.m-only { display: none; }
@media (max-width: 900px) {
  /* Bottom tabs with a big + in the middle (thumb reach), instead of the ☰ menu. */
  .mobile-bar #menuBtn { display: none; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); align-items: end; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: rgba(255, 255, 255, .96); backdrop-filter: saturate(1.8) blur(16px); -webkit-backdrop-filter: saturate(1.8) blur(16px);
    box-shadow: 0 -1px 0 rgba(0, 0, 0, .06); padding: 6px 6px max(8px, env(safe-area-inset-bottom)); }
  .tabbar a, .tabbar .tab-more { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0 2px; color: var(--muted); font-size: 11px; font-weight: 500; text-decoration: none !important; border: 0; background: none; font-family: inherit; line-height: 1.2; cursor: pointer; }
  .tabbar a.active, .tabbar .tab-more.active { color: var(--ink); }
  .tabbar a.active .ic { stroke-width: 2.2; }
  .tab-add { justify-self: center; width: 56px; height: 56px; margin-top: -22px; border-radius: 999px; border: 0; background: var(--green); color: #fff; display: grid; place-items: center; box-shadow: 0 6px 18px rgba(16, 138, 0, .35); cursor: pointer; }
  .tab-add:active { transform: scale(.96); }
  .page { padding-bottom: calc(110px + env(safe-area-inset-bottom)) !important; }

  /* "Add" sheet that slides up from the bottom */
  .sheet-scrim:not([hidden]) { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 44; animation: fade .15s; }
  .sheet:not([hidden]) { display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; background: #fff; border-radius: 24px 24px 0 0;
    padding: 8px 18px max(20px, env(safe-area-inset-bottom)); animation: rise .2s ease-out; }
  .sheet-grab { width: 40px; height: 5px; border-radius: 99px; background: #d9d9d9; margin: 4px auto 12px; }
  .sheet h3 { margin-bottom: 14px; }
  .sheet-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .sheet-grid button { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 6px; border: 0; border-radius: 16px; background: var(--panel); font: inherit; font-size: 13.5px; font-weight: 500; color: var(--ink); cursor: pointer; }
  .sheet-grid button:active { background: #ececec; }
  .sheet-grid .ic { color: var(--green-ink); }

  /* Forms and windows slide up as bottom sheets; Save is a big full-width button. */
  .overlay { place-items: end stretch; padding: 0; }
  .modal, .modal-wide { width: 100%; max-height: 92dvh; border-radius: 24px 24px 0 0; animation: rise .22s ease-out; }
  .modal-head { padding: 18px 20px 4px; }
  .modal-head h2 { font-size: 20px; }
  .modal-body { padding: 10px 20px 16px; }
  .modal-foot { padding: 10px 20px max(16px, env(safe-area-inset-bottom)); gap: 8px; box-shadow: 0 -1px 0 var(--line); }
  .modal-foot .spacer { display: none; }
  .modal-foot [data-close].btn { display: none; }
  .modal-foot .btn { height: 40px; padding: 0 14px; }
  .modal-foot .btn-primary, .modal-foot .btn-whatsapp { flex: 1 1 100%; height: 50px; font-size: 16px; order: 9; }
  .modal-foot .btn-ghost, .modal-foot .btn-danger-ghost, .modal-foot .btn-outline { flex: 1 1 auto; }
  /* iPhone zooms into any field with text under 16px — keep inputs at 16px on phones. */
  input:not([type=checkbox]):not([type=radio]), select, textarea { font-size: 16px; height: 46px; }
  textarea { height: auto; }
}
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }

@media (max-width: 640px) {
  .page-head { margin-bottom: 18px; align-items: center; }
  .page-head h1 { font-size: 26px; }
  .page-head p { display: none; }
  .page-head .actions .btn { height: 38px; padding: 0 16px; font-size: 14.5px; }
  .grid { gap: 10px; }
  .grid-main { gap: 18px; }
  .card { padding: 16px; border-radius: 18px; }
  .stat .value { font-size: 21px; }
  .stat .label { font-size: 13px; }
  .stat .sub { font-size: 12.5px; }
  /* Four stats as a 2×2 grid, with the dark "money you have" card on top */
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-4 > .hero { grid-column: 1 / -1; order: -1; }
  .grid-4:has(> .hero) > :nth-child(4):last-child:not(.hero) { grid-column: 1 / -1; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 > .hero { grid-column: 1 / -1; }
  /* Filters: search on its own line, the dropdowns share the next one */
  .filters { gap: 8px; }
  .filters input[type=search] { flex: 1 1 100%; max-width: none; min-width: 0; }
  .filters select { flex: 1 1 0; min-width: 0; padding-left: 12px; padding-right: 30px; background-position: right 8px center; font-size: 15px; height: 42px; }
  .form-grid { grid-template-columns: 1fr 1fr; gap: 14px 12px; }
  .form-grid .field { grid-column: 1 / -1; }
  .form-grid .field.m-half { grid-column: span 1; }
  .months-grid { grid-template-columns: repeat(6, 1fr); }
  .banner { flex-wrap: wrap; padding: 14px; }
  .banner .btn { flex: 1 1 100%; height: 44px; }
  .tabs { gap: 18px; }

  /* Wide tables become simple two-column lists: what on the left, amount on the right. */
  .m-only { display: inline; }
  table.m-list thead { display: none; }
  table.m-list tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; row-gap: 2px; padding: 12px 2px; border-bottom: 1px solid var(--line); }
  table.m-list td { display: block; padding: 0 !important; border: 0; min-width: 0; }
  table.m-list td .sub { margin-top: 0; }
  table.m-list .m1a { grid-row: 1; grid-column: 1; }
  table.m-list .m1b { grid-row: 1; grid-column: 2; text-align: right; }
  table.m-list .m2a { grid-row: 2; grid-column: 1; font-size: 13px; color: var(--muted); }
  table.m-list .m2b { grid-row: 2; grid-column: 2; text-align: right; font-size: 13px; color: var(--muted); }
  table.m-list .m3a { grid-row: 3; grid-column: 1 / -1; font-size: 13px; color: var(--muted); }
  table.m-list .mx { display: none !important; }
  table.m-list .m3a .sub { display: none; }
  table.m-list tr.group-row { display: flex; justify-content: space-between; padding: 0; border: 0; margin-top: 10px; border-radius: 10px; background: var(--panel); }
  table.m-list tr.group-row td { padding: 9px 12px !important; background: none !important; }
  table.m-list tfoot tr { border-top: 1px solid var(--line-2); }
  table.m-list tr.clickable:active { background: #f6f6f6; }
  table.m-list tbody tr.clickable:hover td { background: none; }
  table.m-list td.date, .table-wrap table.m-list td:first-child { white-space: normal; }
  table.m-list [data-label]::before { content: attr(data-label) ' '; color: var(--muted); }
}

@media print {
  .sidebar, .mobile-bar, .no-print, .filters, .btn, .tree { display: none !important; }
  body, .main-wrap { background: #fff; padding: 0; }
  .page { padding: 0; border-radius: 0; }
  .card { break-inside: avoid; }
  .grid-main { grid-template-columns: 1fr; }
}
