/* Paleta: fondo rosa pálido, recuadros blancos con borde azul marino, detalles azul marino */
:root {
  --page: #fbe9ee;
  --ink: #1b2a4a;
  --card: #ffffff;
  --field: #f8f0f3;
  --text: #1b2a4a;
  --muted: #6b7591;
  --line: #ece2e6;
  --track: #f0e6ea;
  --accent: #1b2a4a;
  --on-accent: #ffffff;
  --ok: #1f9d6b;
  --pos: #1f9d6b;
  --warn: #d98a00;
  --warn-soft: #fff3dc;
  --over: #d23f5a;
  --over-soft: #ffe3e8;
  --ring-empty: #e6dce1;
  --shadow: 0 4px 14px rgba(27, 42, 74, .08);
  --radius: 20px;
  --tabs-h: 64px;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--page); color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) 0 calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px);
}
body.locked { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }

main { max-width: 560px; margin: 0 auto; padding: 0 16px; }
h1 { font-size: 30px; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 17px; margin: 0; text-align: center; }
h3 { font-size: 17px; margin: 0 0 10px; }
small { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.strong { font-weight: 700; }
.pos { color: var(--pos); }
.neg { color: var(--over); }
.warn { color: var(--warn); }
.empty { color: var(--muted); text-align: center; padding: 14px 8px; margin: 0; }

/* cabecera (sobre el rosa) */
.band { color: var(--ink); padding-bottom: 4px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 0 8px; }
.band-sub { margin: 0 0 12px; font-size: 14px; opacity: .75; }
.monthnav { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 2px 0 14px; }
.monthnav span { font-weight: 700; text-transform: capitalize; min-width: 150px; text-align: center; color: var(--ink); }
.monthnav button { width: 40px; height: 40px; border-radius: 50%; font-size: 24px; display: grid; place-items: center; background: var(--ink); color: #fff; box-shadow: var(--shadow); }
.monthnav button:disabled { opacity: .25; }

/* recuadros blancos con borde azul marino */
.hero, .card, .pill, .sheet { background: var(--card); color: var(--text); }
.hero, .card, .pill { border: 1.5px solid var(--ink); }
.sheet { border-top: 2px solid var(--ink); }
.hero { border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 18px 16px; margin-bottom: 12px; text-align: center; }
.hero.flat { box-shadow: none; padding: 4px 0 8px; background: none; border: 0; }
.hero .label { margin: 0; color: var(--muted); font-size: 15px; }
.hero .big { margin: 2px 0 4px; font-size: 40px; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.hero .hint { margin: 0 0 6px; color: var(--muted); font-size: 14px; }
.hero .bar { height: 10px; margin: 6px 0; }
.breakdown { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.breakdown.two { grid-template-columns: 1fr 1fr; }
.breakdown div, .breakdown .tap { display: flex; flex-direction: column; gap: 2px; align-items: center; text-align: center; }
.breakdown .tap { border-radius: 12px; padding: 4px 2px; margin: -4px -2px; }
.breakdown .tap:active { background: var(--field); }
.breakdown span { font-size: 13px; color: var(--muted); }
.breakdown b { font-size: 17px; font-variant-numeric: tabular-nums; }
.breakdown small { font-size: 12px; }

.card { border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.card-head h3 { margin: 0; }
.link { color: var(--accent); font-size: 15px; }
.link.strong { font-weight: 600; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; padding: 12px 0; border-top: 1px solid var(--line); }
.card > .row:first-child, .card-head + .row, .card h3 + .row { border-top: 0; }
.row span { display: flex; flex-direction: column; }
.row .withico { flex-direction: row; align-items: center; gap: 10px; }

/* anillo */
.donut { position: relative; width: 210px; max-width: 70%; margin: 4px auto 10px; aspect-ratio: 1; }
.donut svg { width: 100%; height: 100%; display: block; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-center b { font-size: 30px; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }

/* barras */
.bar { display: block; height: 9px; border-radius: 99px; background: var(--track); overflow: hidden; margin: 6px 0 4px; }
.bar i { display: block; height: 100%; border-radius: 99px; transition: width .4s; }
i.ok { background: var(--ok); }
i.warn { background: var(--warn); }
i.over { background: var(--over); }

/* categorías, movimientos y fijos */
.catrow, .txrow { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 0; border-top: 1px solid var(--line); }
.card-head + .catrow, .day + .txrow, .list > .txrow:first-child { border-top: 0; }
.catrow.over { background: var(--over-soft); border-radius: 14px; padding: 10px; margin: 4px -10px; width: calc(100% + 20px); border-top: 0; }
.catrow.over + .catrow { border-top: 0; }
.ico { width: 40px; height: 40px; flex: none; border-radius: 50%; display: grid; place-items: center; font-size: 19px; background: var(--field); }
.ico.sm { width: 32px; height: 32px; font-size: 16px; }
.ico.big { width: 68px; height: 68px; font-size: 34px; }
.grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.line { display: flex; justify-content: space-between; gap: 8px; }
.line b, .txrow > b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.desc { font-weight: 600; overflow-wrap: anywhere; }
.fulldesc { display: block; font-size: 11.5px; line-height: 1.3; overflow-wrap: anywhere; margin-top: 1px; }
.share { font-weight: 600; margin-left: 4px; }
.cmp { font-size: 12px; font-weight: 600; margin-top: 2px; }
.cmp.up { color: var(--over); }
.cmp.down { color: var(--ok); }
.cmp.eq { color: var(--muted); }
.day { margin: 14px 0 2px; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: capitalize; }

.fixedrow { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.card-head + .fixedrow { border-top: 0; }
.fixedrow .check { width: 30px; height: 30px; flex: none; border-radius: 50%; border: 2px solid var(--muted); display: grid; place-items: center; color: var(--on-accent); font-weight: 700; }
.fixedrow.done .check { background: var(--ok); border-color: var(--ok); }
.fixedrow.done .line span { color: var(--muted); }

.addbtn { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-size: 20px; display: grid; place-items: center; font-weight: 700; }

/* avisos (sobre el rosa) */
.alert { display: flex; gap: 10px; align-items: center; width: 100%; padding: 12px 14px; border-radius: 14px; margin: 0 0 10px; font-size: 15px; color: var(--ink); border-left: 5px solid; }
.alert.warn { background: #fff1d9; border-color: var(--warn); }
.alert.over { background: #ffdbe2; border-color: var(--over); }
.alert > span:first-child { font-size: 20px; }
.pill { display: flex; align-items: center; gap: 6px; width: 100%; padding: 12px 14px; border-radius: 14px; margin-bottom: 12px; box-shadow: var(--shadow); font-size: 15px; }
.pill span { margin-left: auto; color: var(--accent); font-weight: 600; white-space: nowrap; }

.welcome .step { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 0; border-top: 1px solid var(--line); font-weight: 500; }

/* ahorro */
.chart { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; align-items: end; height: 170px; }
.chart .col { display: flex; flex-direction: column; align-items: center; height: 100%; gap: 4px; }
.chart .col small { font-size: 11px; white-space: nowrap; }
.chart .track { flex: 1; width: 100%; max-width: 34px; display: flex; align-items: flex-end; }
.chart .track i { width: 100%; border-radius: 8px 8px 3px 3px; }
.chart .col > span { font-size: 12px; color: var(--muted); text-transform: capitalize; }
.chart .col.cur > span { color: var(--text); font-weight: 700; }
.goal { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.card-head + .goal { border-top: 0; }

/* banco */
.search { margin: 10px 0 4px; }
.txrow .sub { display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.tag { font-size: 12px; padding: 3px 9px; border-radius: 99px; background: var(--field); white-space: nowrap; }
.tag.todo { background: var(--accent); color: var(--on-accent); font-weight: 700; }
.pickrow { flex-direction: row; align-items: center; gap: 12px; padding: 10px 0; margin: 0; border-top: 1px solid var(--line); color: var(--text); font-size: 16px; }
.day + .pickrow { border-top: 0; }

/* formularios (dentro de recuadros marino) */
input, select, textarea {
  width: 100%; padding: 12px; border-radius: 12px; border: 1px solid transparent;
  background: var(--field); color: var(--text); font-size: 16px; outline: none; -webkit-appearance: none; appearance: none;
}
input::placeholder { color: var(--muted); opacity: .8; }
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input[type="checkbox"] { width: 22px; height: 22px; padding: 0; flex: none; accent-color: var(--accent); -webkit-appearance: checkbox; appearance: auto; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); margin-bottom: 12px; }
.field-label { font-size: 14px; color: var(--muted); margin: 6px 0 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.inline-save { display: flex; gap: 8px; }
.amount { font-size: 38px; font-weight: 700; text-align: center; border: 0; background: none; padding: 10px 0; margin: 4px 0 6px; font-variant-numeric: tabular-nums; }
.amount:focus { border: 0; }
details { margin-bottom: 12px; }
summary { color: var(--accent); font-size: 15px; padding: 6px 0 10px; cursor: pointer; }
.mt { margin-top: 14px; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--field); border-radius: 12px; padding: 3px; margin-bottom: 4px; }
.seg button { text-align: center; padding: 9px; border-radius: 10px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--accent); color: var(--on-accent); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip { padding: 9px 13px; border-radius: 99px; background: var(--field); font-size: 15px; }
.chip.on { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.chip.add { border: 1px dashed var(--muted); background: none; }
.chip:active { transform: scale(.97); }

.cat-preview { display: flex; justify-content: center; margin: 2px 0 12px; }
.icongrid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; margin-bottom: 14px; }
.iconpick { aspect-ratio: 1; border-radius: 50%; background: var(--field); display: grid; place-items: center; font-size: 20px; text-align: center; }
.iconpick.on { transform: scale(1.1); box-shadow: 0 0 0 2px var(--ink); }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--card); box-shadow: 0 0 0 1px var(--line); }
.swatch.on { box-shadow: 0 0 0 2px var(--ink); }

.btn { display: block; width: 100%; text-align: center; padding: 13px; border-radius: 14px; background: var(--accent); color: var(--on-accent); font-weight: 700; }
.btn.ghost { background: var(--field); color: var(--text); margin-top: 8px; font-weight: 600; }
.btn.small { width: auto; padding: 9px 14px; font-size: 14px; flex: none; }
.btn.light { box-shadow: var(--shadow); }
.btn.sticky { position: sticky; bottom: 0; margin-top: 12px; box-shadow: 0 -8px 16px var(--card); }
.btn:disabled { opacity: .45; }
.btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btns .btn.ghost { margin-top: 0; }
.danger { display: block; width: 100%; text-align: center; padding: 13px; margin-top: 18px; color: var(--over); font-weight: 600; }

.txcard { display: flex; flex-direction: column; align-items: center; gap: 2px; background: var(--field); border-radius: 16px; padding: 16px; margin-bottom: 10px; text-align: center; }
.txcard b { font-size: 30px; }

/* barra de pestañas */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--ink); color: #fff;
}
.tabs button { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: #aeb9d3; padding: 6px 0; }
.tabs button span { font-size: 21px; filter: grayscale(1); opacity: .55; }
.tabs button.on { color: #fff; font-weight: 600; }
.tabs button.on span { filter: none; opacity: 1; }
.tabs .fab { justify-self: center; width: 56px; height: 56px; border-radius: 50%; background: #f59ab0; color: var(--ink); font-size: 32px; font-weight: 400; justify-content: center; margin-top: -24px; border: 3px solid var(--page); box-shadow: 0 6px 18px rgba(27, 42, 74, .25); }

/* hoja modal */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(27, 42, 74, .45); display: flex; align-items: flex-end; justify-content: center; }
.modal[hidden] { display: none; }
.sheet { width: 100%; max-width: 560px; max-height: 92vh; border-radius: 22px 22px 0 0; display: flex; flex-direction: column; animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet header { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.sheet header .link:last-child { text-align: right; }
.sheet-body { padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); overflow-y: auto; }
.sheet .alert { margin-top: 8px; }

.fixed-total { display: flex; justify-content: space-between; align-items: baseline; background: var(--field); border-radius: 12px; padding: 10px 14px; margin: 8px 0 4px; }
.fixed-total b { font-size: 18px; }
.fixed-total + .fixedrow, .fixed-total + .row { border-top: 0; }
.income-types { background: var(--field); border-radius: 14px; padding: 4px 14px; margin-bottom: 8px; }
.income-types .row:first-child { border-top: 0; }
.hucha { display: flex; justify-content: space-between; align-items: baseline; background: #fdeef2; border-radius: 14px; padding: 14px; margin: 6px 0 4px; }
.hucha b { font-size: 24px; }
.savings-line { display: flex; gap: 4px; align-items: baseline; width: 100%; margin: 12px 0 0; padding: 10px 12px; border-radius: 12px; font-size: 14px; text-align: left; }
.savings-line span { margin-left: auto; font-weight: 600; white-space: nowrap; }
.hucha-month { display: flex; justify-content: space-between; align-items: baseline; margin-top: 14px; }
.hucha-month .day { margin: 0; }
.hucha-month b { font-size: 13px; }
.savings-line.out { background: var(--warn-soft); }
.savings-line.in { background: #e3f5ec; }

/* login */
.login { position: fixed; inset: 0; z-index: 40; background: var(--page); display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.login[hidden] { display: none; }
.login-box { width: 100%; max-width: 360px; background: var(--card); border: 1.5px solid var(--ink); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px 20px; text-align: center; }
.login-box h1 { margin-bottom: 14px; }
.login-box label { text-align: left; }
.login-logo { width: 64px; height: 64px; margin: 0 auto 10px; border-radius: 18px; background: var(--ink); display: grid; place-items: center; font-size: 32px; }
.login-error { color: var(--over); font-size: 14px; min-height: 1.2em; margin: 0 0 10px; }
.sync .link { font-size: 13px; margin-left: 4px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 14px); z-index: 30;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: .25s;
  background: var(--accent); color: var(--on-accent); font-weight: 600; padding: 11px 16px; border-radius: 14px; font-size: 14px;
  width: max-content; max-width: calc(100% - 32px); text-align: center; box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
