/* Easy finance — diseño minimalista: poco color, mucho aire, tipografía grande. */
:root {
  color-scheme: light;
  --bg: #f6f6f3;
  --surface: #ffffff;
  --line: #e8e8e3;
  --text: #1c1e22;
  --muted: #80858d;
  --soft: #efefea;
  --accent: #1c1e22;
  --on-accent: #ffffff;
  --personal: #4a86a8;
  --negocio: #c08a2e;
  --danger: #c2453f;
  --ok: #2f8a5d;
  --radius: 18px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121315; --surface: #1b1c1f; --line: #2a2b2f; --text: #ececea; --muted: #8d9198;
    --soft: #232428; --accent: #ececea; --on-accent: #121315;
    --personal: #78aecb; --negocio: #dcae62; --danger: #e5837d; --ok: #6cc497;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121315; --surface: #1b1c1f; --line: #2a2b2f; --text: #ececea; --muted: #8d9198;
  --soft: #232428; --accent: #ececea; --on-accent: #121315;
  --personal: #78aecb; --negocio: #dcae62; --danger: #e5837d; --ok: #6cc497;
}

html { font-size: 17px; -webkit-text-size-adjust: 100%; }
html[data-fs="1"] { font-size: 19.5px; }
html[data-fs="2"] { font-size: 22px; }
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 1rem/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.noscroll { overflow: hidden; }
h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; cursor: pointer; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hint { color: var(--muted); font-size: .85rem; margin: 8px 0 0; }

/* ---------- Cabecera ---------- */
.top, .bar, main { max-width: 640px; margin: 0 auto; padding-left: 20px; padding-right: 20px; }
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-top: calc(16px + env(safe-area-inset-top)); padding-bottom: 6px;
}
.month { display: flex; align-items: center; gap: 4px; min-width: 0; }
.month h1 { font-size: 1.35rem; font-weight: 700; letter-spacing: -.02em; white-space: nowrap; padding: 0 4px; }
.nav-btn { width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent; font-size: 1.6rem; line-height: 1; color: var(--muted); }
.nav-btn:hover { background: var(--soft); color: var(--text); }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--soft); color: var(--text);
  font-weight: 700; padding: 0; overflow: hidden; flex: none; font-size: 1.05rem;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.bar {
  position: sticky; top: 0; z-index: 20; background: var(--bg);
  padding-top: 8px; padding-bottom: 10px; display: flex; flex-direction: column; gap: 10px;
}
.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--line); }
.tabs button {
  border: 0; background: none; padding: 8px 0 10px; font-size: 1.05rem; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button.on { color: var(--text); border-bottom-color: var(--text); }
.scope { display: flex; gap: 8px; }
.scope button {
  border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 0 16px; min-height: 38px;
  font-size: .92rem; color: var(--muted); font-weight: 500;
}
.scope button.on { background: var(--text); border-color: var(--text); color: var(--bg); }
body[data-view="ajustes"] .bar { display: none; }

main { padding-top: 8px; padding-bottom: calc(120px + env(safe-area-inset-bottom)); }
.view { display: none; }
.view.active { display: block; }

/* ---------- Totales ---------- */
.hero { display: flex; flex-direction: column; gap: 2px; padding: 18px 0 14px; }
.hero .label { color: var(--muted); font-size: .95rem; }
.hero .amt { font-size: 2.5rem; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.15; overflow-wrap: anywhere; }
.progress { height: 6px; background: var(--soft); border-radius: 99px; overflow: hidden; margin: 10px 0 6px; }
.progress span { display: block; height: 100%; background: var(--ok); border-radius: 99px; transition: width .3s; }
.tip { margin: 0 0 6px; }

.split { margin-bottom: 8px; }
.bar2 { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: var(--soft); gap: 2px; }
.bar2 .p { background: var(--personal); }
.bar2 .n { background: var(--negocio); }
.split-row { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-top: 10px; color: var(--muted); font-size: .92rem; }
.split-row b { color: var(--text); font-weight: 600; margin-left: 4px; font-variant-numeric: tabular-nums; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; flex: none; }
.dot.p { background: var(--personal); }
.dot.n { background: var(--negocio); }

.sec { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; margin: 26px 0 10px; }
.cat { display: grid; grid-template-columns: minmax(0, 8.5rem) 1fr auto; gap: 12px; align-items: center; padding: 6px 0; font-size: .95rem; }
.cat .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat .track { height: 6px; background: var(--soft); border-radius: 99px; overflow: hidden; }
.cat .track span { display: block; height: 100%; background: var(--text); opacity: .75; border-radius: 99px; }
.cat .val { font-variant-numeric: tabular-nums; color: var(--muted); }

/* ---------- Listas ---------- */
.day { background: var(--surface); border-radius: var(--radius); padding: 4px 16px; margin-bottom: 12px; }
.day-h { display: flex; justify-content: space-between; padding: 12px 0 6px; font-size: .85rem; color: var(--muted); font-weight: 600; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 0; border: 0; background: none; text-align: left;
  border-top: 1px solid var(--line);
}
.day-h + .row { border-top: 0; }
.row .txt { flex: 1; min-width: 0; display: flex; flex-direction: column; border: 0; background: none; padding: 0; text-align: left; }
.row .t1 { font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.row .t2 { color: var(--muted); font-size: .85rem; }
.row .amt { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
button.row:active, .row .txt:active { opacity: .6; }

.row.fixed .check {
  width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--line); background: transparent; flex: none;
  display: grid; place-items: center; font-size: .95rem; font-weight: 700; color: var(--on-accent); padding: 0;
}
.row.fixed .check:hover { border-color: var(--muted); }
.row.fixed.paid .check { background: var(--ok); border-color: var(--ok); color: #fff; }
.row.fixed.paid .t1, .row.fixed.paid .amt { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.late, .soon { display: inline-block; font-size: .75rem; font-weight: 600; padding: 1px 8px; border-radius: 99px; margin-left: 6px; vertical-align: 1px; text-decoration: none; }
.late { color: var(--danger); background: color-mix(in srgb, var(--danger) 13%, transparent); }
.soon { color: var(--negocio); background: color-mix(in srgb, var(--negocio) 15%, transparent); }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); display: flex; flex-direction: column; gap: 16px; align-items: center; }

/* ---------- Botones y campos ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 0 22px;
  border-radius: 14px; border: 1px solid transparent; font-weight: 600; background: none; text-align: center;
}
.btn.full { width: 100%; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:active { opacity: .85; }
.btn.ghost { border-color: var(--line); background: var(--surface); }
.btn.ghost:hover { background: var(--soft); }
.btn.text { color: var(--muted); min-height: 44px; }
.btn.danger { color: var(--danger); }
#addFixed { margin-top: 4px; }

input, select {
  width: 100%; min-height: 50px; padding: 0 14px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--text); font-size: 1rem;
}
input:focus, select:focus { outline: none; border-color: var(--text); }
.field-l { display: block; color: var(--muted); font-size: .85rem; font-weight: 500; margin: 14px 0 8px; }
.inline-l { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: .85rem; font-weight: 500; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.seg { display: flex; background: var(--soft); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 11px; min-height: 44px; color: var(--muted); font-weight: 600; padding: 0 6px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 0 14px; min-height: 40px; font-size: .92rem; display: inline-flex; align-items: center; gap: 4px; }
.chip.on { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip.static { cursor: default; padding-right: 4px; }
.chip.static button { border: 0; background: none; color: var(--muted); font-size: 1.15rem; width: 30px; height: 30px; border-radius: 50%; }
.chip.static button:hover { color: var(--danger); background: var(--soft); }

/* ---------- Botón + ---------- */
.fab {
  position: fixed; right: max(20px, calc(50% - 300px)); bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 30;
  width: 62px; height: 62px; border-radius: 50%; border: 0; background: var(--accent); color: var(--on-accent);
  font-size: 2.1rem; line-height: 1; box-shadow: 0 8px 22px rgba(0,0,0,.22); padding: 0 0 4px;
}
.fab:active { transform: scale(.95); }
body[data-view="ajustes"] .fab { display: none; }

/* ---------- Hoja inferior ---------- */
.sheet-bg { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; justify-content: center; animation: fadein .15s ease; }
.sheet {
  background: var(--bg); width: 100%; max-width: 560px; border-radius: 24px 24px 0 0;
  padding: 18px 20px calc(20px + env(safe-area-inset-bottom)); max-height: 94vh; overflow-y: auto; animation: up .2s ease;
}
.sheet form { display: flex; flex-direction: column; gap: 14px; }
.sheet-h { display: flex; align-items: center; justify-content: space-between; }
.sheet-h h2 { font-size: 1.15rem; }
.x { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--soft); color: var(--muted); font-size: 1rem; }
.big-amt { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 0; }
.big-amt span { font-size: 2rem; color: var(--muted); font-weight: 600; }
.big-amt input { border: 0; background: none; font-size: 2.6rem; font-weight: 700; text-align: center; width: 100%; max-width: 12ch; min-height: 64px; padding: 0; letter-spacing: -.02em; }
.big-amt input:focus { border: 0; }
.sheet .field-l { margin: 4px 0 -4px; }
.more summary { color: var(--muted); font-weight: 500; cursor: pointer; padding: 6px 0; }
.more .two { margin-top: 10px; }
@keyframes up { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@media (min-width: 700px) { .sheet-bg { align-items: center; } .sheet { border-radius: 24px; } }

/* ---------- Ajustes ---------- */
.page-h { display: flex; align-items: center; justify-content: space-between; padding: 14px 0 8px; }
.page-h h2 { font-size: 1.6rem; letter-spacing: -.02em; }
.group { background: var(--surface); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 10px; }
.group h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.group .field-l { margin: 6px 0 0; }
.sync { text-transform: none; letter-spacing: 0; font-weight: 500; }
.sync.ok { color: var(--ok); }
.sync.busy { color: var(--negocio); }
.sync.off { color: var(--danger); }
.sync.login { color: var(--text); text-decoration: underline; cursor: pointer; }
.acc { display: flex; align-items: center; gap: 12px; }
.acc .t1 { font-weight: 600; }
.acc .t2 { color: var(--muted); font-size: .85rem; word-break: break-all; }
.avatar-l { width: 46px; height: 46px; border-radius: 50%; background: var(--soft); display: grid; place-items: center; font-weight: 700; overflow: hidden; flex: none; }
.avatar-l img { width: 100%; height: 100%; object-fit: cover; }
.cat-editor { display: flex; flex-direction: column; gap: 18px; }
.cat-col h3 { font-size: .95rem; text-transform: none; letter-spacing: 0; color: var(--text); margin-bottom: 10px; }
.add-cat { display: flex; gap: 8px; margin-top: 10px; }
.add-cat .btn { flex: none; }

/* ---------- Acceso ---------- */
.gate { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; background: var(--bg); padding: 24px; }
body.locked .gate { display: flex; }
body.locked .top, body.locked .bar, body.locked main, body.locked .fab { display: none !important; }
.gate-in { max-width: 360px; width: 100%; text-align: center; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.gate-in h1 { font-size: 1.8rem; letter-spacing: -.02em; }
.mark { width: 72px; height: 72px; border-radius: 22px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-size: 2.2rem; font-weight: 700; margin-bottom: 6px; }

/* ---------- Aviso ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); z-index: 120;
  transform: translateX(-50%) translateY(12px); opacity: 0; transition: .2s ease; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-weight: 500;
  max-width: calc(100% - 40px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%); }

@media (max-width: 380px) {
  .top, .bar, main { padding-left: 16px; padding-right: 16px; }
  .month h1 { font-size: 1.15rem; }
  .hero .amt { font-size: 2.1rem; }
  .scope button { padding: 0 12px; }
}
