/* Paleta hermana de Gastos: fondo celeste pálido, recuadros blancos con borde azul marino */
:root {
  --page: #e8eefb;
  --ink: #1b2a4a;
  --card: #ffffff;
  --field: #f0f3fa;
  --text: #1b2a4a;
  --muted: #6b7591;
  --line: #e3e8f2;
  --accent: #1b2a4a;
  --on-accent: #ffffff;
  --pop: #8fb3f5;
  --today: #fde7a8;
  --over: #d23f5a;
  --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; }
[hidden] { display: none !important; }

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; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.empty { color: var(--muted); text-align: center; padding: 14px 8px; margin: 0; }

/* cabecera */
.top { padding: 20px 0 12px; }
.top p { margin: 2px 0 0; color: var(--muted); }
.top p::first-letter, .day::first-letter, .nav span::first-letter { text-transform: uppercase; }
.nav { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 0 0 14px; }
.nav span { font-weight: 700; min-width: 170px; text-align: center; }
.nav 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); }
.nav .link { width: auto; height: auto; background: none; box-shadow: none; color: var(--accent); font-size: 14px; }

/* recuadros */
.card, .sheet { background: var(--card); color: var(--text); }
.card { border: 1.5px solid var(--ink); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px; }
.card.today { background: #fffaf0; }
.link { color: var(--accent); font-size: 15px; }
.link.strong { font-weight: 600; }

/* escribir */
.composer textarea { min-height: 76px; resize: none; margin-bottom: 10px; }
.composer .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* días y cosas */
.day { display: block; margin: 0 0 6px; font-size: 15px; font-weight: 700; }
.day small { font-weight: 400; color: var(--muted); margin-left: 6px; }
.item { display: flex; align-items: flex-start; gap: 12px; width: 100%; padding: 10px 0; border-top: 1px solid var(--line); }
.day + .item { border-top: 0; }
.item .when { width: 58px; flex: none; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 15px; padding-top: 1px; }
.item .when small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.item .what { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.item .what b { font-weight: 600; }
.item .meta { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.item.past { opacity: .5; }
.nothing { color: var(--muted); font-size: 14px; margin: 0; }

/* mes */
.month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.month .wd { text-align: center; font-size: 12px; color: var(--muted); padding-bottom: 4px; }
.month .cell { height: 46px; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-variant-numeric: tabular-nums; }
.month .cell.out { visibility: hidden; }
.month .cell.today { background: var(--today); font-weight: 700; }
.month .cell.sel { background: var(--ink); color: #fff; }
.month .dots { display: flex; gap: 2px; height: 5px; }
.month .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--pop); }
.month .cell.sel .dots i { background: #fff; }

/* formularios */
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, textarea::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; }
label.check { flex-direction: row; align-items: center; gap: 10px; color: var(--text); font-size: 16px; }
.field-label { font-size: 14px; color: var(--muted); margin: 6px 0 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.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:active { transform: scale(.97); }
.hint { font-size: 13px; color: var(--muted); margin: -6px 0 12px; }

.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 16px; font-size: 14px; flex: none; }
.btn:disabled { opacity: .45; }
.save-bottom { margin-top: 18px; }
.danger { display: block; width: 100%; text-align: center; padding: 13px; margin-top: 10px; color: var(--over); font-weight: 600; }

/* propuesta de lo que entendió */
.proposal { background: var(--field); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; display: flex; gap: 12px; align-items: flex-start; }
.proposal .what { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.proposal .meta { font-size: 13px; color: var(--muted); }

/* 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: var(--pop); 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; max-height: 92dvh; border-radius: 22px 22px 0 0; border-top: 2px solid var(--ink); 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); }
/* min-height: 0 deja que el contenido se achique y scrollee dentro de la hoja (si no, se corta abajo) */
.sheet-body { flex: 1; min-height: 0; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain; }

/* 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); }
