/* Presupuesto — mobile-first.
   Colour carries meaning: teal = joint (household), violet = personal, bougainvillea = needs you. */
:root {
  --bg: #F1F5F3;          /* sea-foam paper */
  --surface: #FFFFFF;
  --ink: #1C2B2A;         /* basalt green */
  --muted: #5E6E6C;
  --line: #D9E2DF;
  --joint: #0E6E73;       /* Atlantic teal */
  --joint-soft: #DCEEEE;
  --mine: #6B4FA0;        /* tajinaste violet */
  --mine-soft: #ECE6F5;
  --attention: #B8336A;   /* bougainvillea */
  --attention-soft: #F7E1EA;
  --good: #2F7D55;
  --radius-lg: 18px;
  --radius-sm: 10px;
  --tabbar: 64px;
  --composer: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: "Schibsted Grotesk", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-size: 16px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--joint) 55%, white); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.neg { color: var(--ink); }
.pos { color: var(--good); }

/* ---------- shell ---------- */
#app { max-width: 560px; margin: 0 auto; padding: 18px 18px calc(var(--tabbar) + var(--composer) + var(--safe-b) + 28px); }
header.top { display: flex; align-items: baseline; justify-content: space-between; margin: 4px 2px 18px; }
header.top h1 small { display: block; font-size: 15px; font-weight: 600; color: var(--muted); letter-spacing: 0; margin-top: 2px; }
header.top h1 { font-size: 30px; line-height: 1.1; font-weight: 800; letter-spacing: -0.02em; margin: 0; }
header.top .who { font-size: 14px; color: var(--muted); background: none; border: 0; padding: 6px 0; }
h2 { font-size: 19px; font-weight: 700; margin: 26px 2px 10px; letter-spacing: -0.01em; }
section + section { margin-top: 8px; }

nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--tabbar) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
}
nav.tabs button {
  background: none; border: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; font-size: 12px; font-weight: 600; color: var(--muted); position: relative;
}
nav.tabs button svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.8; }
nav.tabs button[aria-current="page"] { color: var(--joint); }
nav.tabs .badge {
  position: absolute; top: 7px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--attention); color: #fff; font-size: 11px; line-height: 18px; text-align: center;
}

/* ---------- composer: the one bold element ---------- */
form.composer {
  position: fixed; left: 0; right: 0; z-index: 19;
  bottom: calc(var(--tabbar) + var(--safe-b));
  padding: 10px 14px; background: linear-gradient(to top, var(--bg) 70%, transparent);
}
form.composer .inner {
  max-width: 560px; margin: 0 auto; display: flex; gap: 8px; align-items: center;
  background: var(--ink); border-radius: 999px; padding: 6px 6px 6px 20px;
  box-shadow: 0 10px 28px -12px rgba(28, 43, 42, .55);
}
form.composer input {
  flex: 1; min-width: 0; border: 0; background: transparent; color: #fff; font-size: 17px; padding: 10px 0;
}
form.composer input::placeholder { color: #A9BAB7; }
form.composer input:focus { outline: none; }
form.composer button {
  border: 0; border-radius: 999px; height: 42px; padding: 0 16px; font-weight: 700;
  background: #fff; color: var(--ink);
}
form.composer button.plain { background: transparent; color: #CFE0DD; padding: 0 10px; font-weight: 600; }
form.composer button:disabled { opacity: .5; }

/* ---------- month summary ---------- */
.scope {
  background: var(--surface); border-radius: var(--radius-lg); padding: 16px 18px; margin-bottom: 10px;
  border-left: 6px solid var(--c);
}
.scope.joint { --c: var(--joint); --c-soft: var(--joint-soft); }
.scope.mine { --c: var(--mine); --c-soft: var(--mine-soft); }
.scope .label { font-weight: 700; color: var(--c); font-size: 15px; }
.scope .left { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; margin: 4px 0 2px; }
.scope .left small { display: block; font-size: 15px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.bar { height: 10px; border-radius: 5px; background: var(--c-soft, var(--line)); overflow: hidden; margin: 10px 0 6px; }
.bar > i { display: block; height: 100%; background: var(--c, var(--joint)); border-radius: 5px; }
.bar.over > i { background: var(--attention); }
.scope .foot { font-size: 14px; color: var(--muted); }

.notice {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; text-align: left;
  background: var(--attention-soft); color: var(--attention); border: 0; border-radius: var(--radius-lg);
  padding: 14px 18px; font-weight: 700; margin-bottom: 10px;
}
.notice.calm { background: var(--joint-soft); color: var(--joint); }

/* ---------- lists ---------- */
ul.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--radius-lg); }
ul.list li { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 16px; border-top: 1px solid var(--line); }
ul.list li:first-child { border-top: 0; }
ul.list li:has(> button.row) { display: block; padding: 0; }
ul.list li > button.row { all: unset; box-sizing: border-box; width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 16px; cursor: pointer; }
ul.list li > button.row:focus-visible { outline: 3px solid var(--joint); outline-offset: -3px; border-radius: var(--radius-lg); }
.payee { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.amount { font-weight: 700; text-align: right; }
.meta { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; min-width: 0; }
.meta > span.t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.dot { flex: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--c); }
.dot.joint { --c: var(--joint); } .dot.mine { --c: var(--mine); }
.empty { background: var(--surface); border-radius: var(--radius-lg); padding: 22px 18px; color: var(--muted); }
.empty strong { color: var(--ink); display: block; margin-bottom: 4px; }

/* ---------- review cards ---------- */
.review { background: var(--surface); border-radius: var(--radius-lg); padding: 16px; margin-bottom: 12px; }
.review .q { font-size: 15px; color: var(--attention); margin: 8px 0 12px; }
.review .head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.review .head .payee { font-size: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.chips-label { font-size: 13px; color: var(--muted); margin-top: 12px; }
.chip {
  border: 1.5px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 13px; font-size: 14px; font-weight: 600;
}
.chip[aria-pressed="true"] { background: var(--c, var(--joint)); border-color: var(--c, var(--joint)); color: #fff; }
.seg { display: inline-grid; grid-auto-flow: column; background: var(--bg); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 7px 16px; font-weight: 700; font-size: 14px; color: var(--muted); }
.seg button[aria-pressed="true"].joint { background: var(--joint); color: #fff; }
.seg button[aria-pressed="true"].mine { background: var(--mine); color: #fff; }
.seg button:disabled { opacity: .4; }
.actions { display: flex; gap: 8px; margin-top: 12px; }

/* ---------- forms & buttons ---------- */
.btn { border: 0; border-radius: 999px; padding: 12px 20px; font-weight: 700; background: var(--joint); color: #fff; }
.btn.secondary { background: var(--bg); color: var(--ink); }
.btn.danger { background: var(--attention-soft); color: var(--attention); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; }
label.field { display: block; margin: 12px 0; font-size: 14px; font-weight: 600; color: var(--muted); }
label.field input, label.field select, label.field textarea {
  display: block; width: 100%; margin-top: 6px; padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--line); background: var(--surface); font-size: 17px; color: var(--ink);
}
label.field input.big { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card { background: var(--surface); border-radius: var(--radius-lg); padding: 16px 18px; }

/* ---------- sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(28, 43, 42, .35); z-index: 40; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 92vh; overflow: auto;
  background: var(--bg); border-radius: 22px 22px 0 0; padding: 10px 18px calc(24px + var(--safe-b));
  animation: up .22s ease-out;
}
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 10px; }
.sheet h3 { font-size: 21px; margin: 6px 0 4px; }
@keyframes up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }

/* ---------- budget ---------- */
.month-nav { display: flex; align-items: center; justify-content: space-between; margin: 0 2px 12px; }
.month-nav button { border: 0; background: var(--surface); width: 40px; height: 40px; border-radius: 50%; font-size: 20px; }
.month-nav strong { font-size: 18px; }
.rta { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 18px; border-radius: var(--radius-lg); background: var(--c-soft); color: var(--c); font-weight: 700; margin-bottom: 12px; }
.rta.joint { --c: var(--joint); --c-soft: var(--joint-soft); } .rta.mine { --c: var(--mine); --c-soft: var(--mine-soft); }
.rta .num { font-size: 22px; }
.group-name { font-size: 14px; font-weight: 700; color: var(--muted); margin: 18px 4px 6px; }
.cat { background: var(--surface); padding: 12px 16px; border-top: 1px solid var(--line); }
.cat:first-of-type { border-radius: var(--radius-lg) var(--radius-lg) 0 0; border-top: 0; }
.cat:last-of-type { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.cat:only-of-type { border-radius: var(--radius-lg); }
.cat .line1 { display: flex; justify-content: space-between; gap: 10px; font-weight: 600; }
.cat .line2 { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.cat .avail.neg { color: var(--attention); font-weight: 700; }
.cat input.assign { width: 96px; text-align: right; border: 1.5px solid var(--line); border-radius: 8px; padding: 4px 8px; font-weight: 700; }

/* ---------- import ---------- */
.drop { display: block; cursor: pointer; border: 2px dashed var(--line); border-radius: var(--radius-lg); background: var(--surface); padding: 24px 18px; text-align: center; }
.drop strong { display: block; font-size: 18px; margin-bottom: 4px; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 10px 2px; font-size: 15px; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--joint); }
.recon li .ok { color: var(--good); font-weight: 700; }
.recon li .bad { color: var(--attention); font-weight: 700; }

/* ---------- login ---------- */
.login { min-height: 80vh; display: flex; flex-direction: column; justify-content: center; }
.login h1 { font-size: 40px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; margin: 0 0 8px; }
.login p { color: var(--muted); margin: 0 0 22px; }
.split { display: flex; height: 8px; border-radius: 4px; overflow: hidden; margin-bottom: 28px; width: 120px; }
.split i:first-child { flex: 3; background: var(--joint); } .split i:last-child { flex: 2; background: var(--mine); }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar) + var(--composer) + var(--safe-b) + 18px);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 15px; max-width: 92vw;
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 60;
}
#toast.show { opacity: 1; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- reports ---------- */
.pnl { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 8px; }
.pnl > div { background: var(--surface); border-radius: var(--radius-lg); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.pnl b { font-size: 22px; font-weight: 800; letter-spacing: -0.01em; }
.pnl .net { grid-column: 1 / -1; background: var(--c-soft); color: var(--c); }
.pnl.joint { --c: var(--joint); --c-soft: var(--joint-soft); } .pnl.mine { --c: var(--mine); --c-soft: var(--mine-soft); }
.pnl .net b { font-size: 34px; }
.pnl .net.neg { background: var(--attention-soft); color: var(--attention); }
.pnl .net small { font-size: 14px; font-weight: 600; }
.cmp { margin: 6px 4px 0; font-size: 15px; }
.groups { background: var(--surface); border-radius: var(--radius-lg); overflow: hidden; }
details.grp { border-top: 1px solid var(--line); }
details.grp:first-child { border-top: 0; }
details.grp summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 13px 16px; }
details.grp summary::-webkit-details-marker { display: none; }
details.grp .gname { font-weight: 700; }
details.grp .gamt { font-weight: 700; text-align: right; }
details.grp .bar { grid-column: 1 / -1; margin: 6px 0 2px; height: 8px; }
details.grp .gpct { font-size: 13px; grid-column: 1 / -1; }
details.grp[open] summary { background: var(--c-soft); }
.cats-list { list-style: none; margin: 0; padding: 4px 16px 12px; }
.cats-list li { display: grid; grid-template-columns: 1fr auto; padding: 8px 0; border-top: 1px solid var(--line); }
.cats-list li:first-child { border-top: 0; }
.cats-list .small, .small { font-size: 13px; }
.cats-list .small { grid-column: 1 / -1; }
.trend { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; background: var(--surface); border-radius: var(--radius-lg); padding: 14px 10px 8px; height: 170px; }
.trend .tm { all: unset; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; border-radius: 8px; }
.trend .tm.sel { background: var(--bg); }
.trend .tm:focus-visible { outline: 3px solid var(--joint); }
.trend .bars { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 2px; }
.trend .bars i { display: block; width: 38%; border-radius: 3px 3px 0 0; min-height: 1px; }
i.in { background: #9DB3B0; } i.out.joint { background: var(--joint); } i.out.mine { background: var(--mine); }
.trend .ml { font-size: 12px; color: var(--muted); text-transform: uppercase; }
.legend { display: flex; gap: 8px; align-items: center; font-size: 13px; margin: 8px 4px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.worth { background: var(--ink); color: #fff; border-radius: var(--radius-lg); padding: 18px; margin-bottom: 6px; }
.worth .muted { color: #A9BAB7; }
.worth > b { display: block; font-size: 38px; font-weight: 800; letter-spacing: -0.02em; margin: 2px 0 10px; }
.worth .split2 { display: flex; justify-content: space-between; gap: 10px; font-size: 15px; color: #CFE0DD; }
.worth .split2 b { color: #fff; }
h2.wh { display: flex; justify-content: space-between; align-items: baseline; }
h2.wh .num { font-size: 15px; font-weight: 600; }

/* ---------- settings ---------- */
.gh { display: flex; justify-content: space-between; align-items: baseline; }
button.link { background: none; border: 0; color: var(--joint); font-weight: 600; font-size: 14px; padding: 4px 0; }
