@font-face {
  font-family: 'Nunito';
  src: url(vendor/nunito-latin.woff2) format('woff2');
  font-weight: 400 800;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #fff7f3;
  --card: #fff;
  --ink: #4b4560;
  --muted: #8e88a3;
  --line: #f1e9ef;
  --accent: #8f76d9;
  --pink: #ffd9e4;
  --lilac: #e6dcff;
  --mint: #d4f3e6;
  --sky: #d8ecff;
  --butter: #fff2c2;
  --peach: #ffe2d3;
  --shadow: 0 6px 20px rgba(143, 118, 217, .12);
  --r: 22px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 'Nunito', system-ui, sans-serif;
}
h1, h2, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }

/* Pantallas de entrada */
.screen {
  min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 32px 24px; text-align: center;
  background: linear-gradient(160deg, var(--pink), var(--lilac) 70%);
}
.screen p { color: var(--muted); max-width: 320px; }
.screen h1 { font-size: 1.8rem; }
.logo { font-size: 4.5rem; }
img.logo { width: 104px; height: 104px; border-radius: 28px; box-shadow: 0 10px 28px rgba(143, 118, 217, .3); }
.mark { width: 28px; height: 28px; border-radius: 8px; vertical-align: -6px; margin-right: 4px; }

/* Consentimiento y cuenta */
.consent { justify-content: flex-start; padding-top: calc(28px + env(safe-area-inset-top)); overflow-y: auto; }
.consent .logo { font-size: 3rem; }
.consent img.logo { width: 72px; height: 72px; border-radius: 20px; }
.consent-box { display: flex; flex-direction: column; gap: 12px; max-width: 360px; width: 100%; text-align: left; }
.consent-box .check {
  align-items: flex-start; margin: 0; padding: 12px 14px; background: #fff; border-radius: 16px;
  box-shadow: var(--shadow); font-weight: 600; font-size: .88rem; line-height: 1.4; color: var(--ink);
}
.consent-box .check input { margin-top: 2px; }
.consent-box a { color: var(--accent); }
.consent-box .btn { align-self: stretch; text-align: center; }
.consent-box .btn:disabled { opacity: .45; cursor: not-allowed; }
.acct { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.acct .btn { text-align: center; text-decoration: none; display: block; }
.muted { color: var(--muted); font-size: .85rem; }

/* Layout */
#app { height: 100dvh; display: flex; flex-direction: column; }
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 20px 16px;
  background: linear-gradient(135deg, var(--pink), var(--lilac));
  border-radius: 0 0 28px 28px;
  box-shadow: var(--shadow);
}
.top h1 { font-size: 1.35rem; font-weight: 800; }
.top-r { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; overflow: hidden;
  background: #fff; font-weight: 800; color: var(--accent);
}
.avatar img { width: 100%; height: 100%; display: block; }
.badge {
  font-size: .75rem; font-weight: 700; padding: 4px 10px; border-radius: 99px;
  background: var(--butter);
}
button.badge { background: #fff; color: var(--accent); }
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 20; max-width: calc(100% - 32px); padding: 12px 20px; border-radius: 99px;
  background: var(--ink); color: #fff; font-weight: 700; font-size: .9rem; text-align: center;
  box-shadow: 0 8px 24px rgba(75, 69, 96, .3);
}

main {
  flex: 1; overflow-y: auto; padding: 18px 16px calc(150px + env(safe-area-inset-bottom));
  max-width: 640px; width: 100%; margin: 0 auto;
}

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; gap: 4px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: #fff; border-radius: 26px 26px 0 0;
  box-shadow: 0 -6px 24px rgba(143, 118, 217, .14);
}
.tabs button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0; border-radius: 18px; font-size: .75rem; font-weight: 700; color: var(--muted);
}
.tabs i { font-style: normal; font-size: 1.35rem; }
.tabs button.on { background: var(--lilac); color: var(--accent); }

.fab {
  position: fixed; right: 18px; bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 6;
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 2rem; line-height: 1;
  box-shadow: 0 8px 20px rgba(143, 118, 217, .4);
}

/* Botones */
.btn {
  padding: 10px 18px; border-radius: 99px; font-weight: 700;
  background: var(--lilac); color: var(--accent);
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.soft { background: #fff; color: var(--accent); box-shadow: var(--shadow); }
.btn.danger { background: var(--pink); color: #c0486d; }
.btn.big { padding: 14px 28px; font-size: 1.05rem; }
.btn.sm { padding: 6px 12px; font-size: .85rem; }
.icon {
  width: 36px; height: 36px; border-radius: 50%; background: var(--bg); font-size: 1rem; flex: none;
}

/* Tarjetas */
.card {
  background: var(--card); border-radius: var(--r); padding: 14px;
  box-shadow: var(--shadow); margin-bottom: 12px;
  display: flex; gap: 12px; align-items: flex-start;
}
.card .body { flex: 1; min-width: 0; }
.card h3 { margin: 0; font-size: 1.05rem; overflow-wrap: anywhere; }
.card small, .meta { color: var(--muted); font-size: .85rem; }
.card p { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 4px; font-size: .92rem; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

.h2 { font-size: .85rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 18px 4px 10px; }
.h2:first-child { margin-top: 0; }
.empty { text-align: center; color: var(--muted); padding: 36px 20px; }
.empty b {
  display: grid; place-items: center; width: 92px; height: 92px; margin: 0 auto 14px;
  border-radius: 50%; background: var(--lilac); font-size: 2.6rem;
  box-shadow: 0 0 0 10px rgba(230, 220, 255, .45); animation: float 3.4s ease-in-out infinite;
}
.empty .btn { margin-top: 16px; }
@keyframes float { 50% { transform: translateY(-6px); } }

.date {
  width: 58px; flex: none; text-align: center; border-radius: 16px; padding: 8px 0;
  font-weight: 800; line-height: 1.1;
}
.date span { display: block; font-size: 1.5rem; }
.date small { color: inherit; opacity: .75; text-transform: uppercase; font-size: .7rem; }
.c0 { background: var(--pink); } .c1 { background: var(--sky); } .c2 { background: var(--mint); }
.c3 { background: var(--butter); } .c4 { background: var(--lilac); } .c5 { background: var(--peach); }

.chip {
  display: inline-block; padding: 5px 12px; border-radius: 99px; font-size: .82rem; font-weight: 700;
  background: var(--sky); color: #3d6f9e; text-decoration: none;
}
.chip.when { background: var(--butter); color: #8a6d00; }
.chip.cal { background: var(--mint); color: #2c7a58; }

details.past summary { cursor: pointer; font-weight: 800; color: var(--muted); font-size: .85rem; margin: 18px 4px 10px; text-transform: uppercase; letter-spacing: .06em; }
.past .card { opacity: .75; }

/* Compras */
.quick {
  display: flex; gap: 8px; padding: 14px 16px 0; max-width: 640px; width: 100%; margin: 0 auto;
}
.quick input { flex: 1; min-width: 0; }
.quick .btn { width: 48px; font-size: 1.5rem; padding: 0; }
.item { align-items: center; padding: 10px 14px; }
.tick {
  width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--lilac); flex: none;
  color: transparent; font-weight: 800; display: grid; place-items: center;
}
.done .tick { background: var(--mint); border-color: var(--mint); color: #2c7a58; }
.done .name { text-decoration: line-through; color: var(--muted); }
.item .name { flex: 1; overflow-wrap: anywhere; }

/* Notas */
.notes { columns: 2; column-gap: 12px; }
.note {
  break-inside: avoid; display: block; margin-bottom: 12px; padding: 14px;
  border-radius: var(--r); box-shadow: var(--shadow); cursor: pointer;
}
.note h3 { margin: 0 0 4px; font-size: 1rem; overflow-wrap: anywhere; }
.note p { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .9rem; }
.note .chip { margin-top: 8px; background: rgba(255, 255, 255, .7); }

/* Bebé */
.sub { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 16px; padding: 0 16px 4px; scrollbar-width: none; }
.sub::-webkit-scrollbar { display: none; }
.sub button {
  flex: none; padding: 8px 16px; border-radius: 99px; background: #fff; font-weight: 700;
  color: var(--muted); box-shadow: var(--shadow);
}
.sub button.on { background: var(--accent); color: #fff; }

.chart { flex-direction: column; gap: 4px; }
.chart-h { display: flex; justify-content: space-between; align-items: baseline; width: 100%; }
.chart-h span { font-weight: 800; color: var(--accent); }
.chart svg { width: 100%; height: auto; display: block; }

/* Formulario */
dialog {
  border: 0; padding: 0; width: 100%; max-width: 560px; margin: auto auto 0;
  border-radius: 28px 28px 0 0; background: #fff; color: var(--ink);
  max-height: 92dvh; overflow-y: auto;
  animation: up .22s ease-out;
}
dialog::backdrop { background: rgba(75, 69, 96, .4); }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
#form { padding: 22px 20px calc(20px + env(safe-area-inset-bottom)); }
#form h2 { font-size: 1.25rem; margin-bottom: 14px; }
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: .82rem; font-weight: 700; color: var(--muted); margin: 0 0 4px 6px; }
input:not([type=checkbox]), select, textarea {
  width: 100%; padding: 12px 16px; border-radius: 16px; border: 2px solid var(--line);
  background: var(--bg); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--lilac); background: #fff; }
textarea { resize: vertical; }
.check { display: flex; align-items: center; gap: 10px; margin: 4px 0 14px 4px; font-weight: 700; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }
.actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.actions .btn { padding: 12px 22px; }
.actions .btn.danger { margin-right: auto; }

@media (min-width: 700px) { .notes { columns: 3; } }

/* Aviso de vencimiento */
.aviso {
  display: block; width: calc(100% - 32px); max-width: 608px; margin: 12px auto 0; padding: 10px 14px;
  border-radius: 16px; text-align: left; font-weight: 700; font-size: .88rem; line-height: 1.35;
  background: var(--butter); color: #6b5300; box-shadow: var(--shadow);
}
.aviso.urgente { background: var(--peach); color: #8a3d1d; }
.aviso.gracia { background: var(--pink); color: #a23557; }
.aviso.proximo { background: var(--mint); color: #2c7a58; }
#expired .btn { text-decoration: none; }

/* Bienvenida */
.tour { position: fixed; inset: 0; z-index: 30; overflow-y: auto; padding-bottom: calc(32px + env(safe-area-inset-bottom)); }
.slides { display: grid; width: 100%; max-width: 340px; }
.slide { grid-area: 1 / 1; opacity: 0; visibility: hidden; transform: translateX(24px); transition: opacity .3s, transform .3s, visibility .3s; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.slide.on { opacity: 1; visibility: visible; transform: none; }
.slide h1 { font-size: 1.6rem; }
.slide p { color: var(--ink); max-width: 300px; }
.ill { display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; min-height: 96px; margin-bottom: 8px; }
.ill span:not(.badge), .ill .fabx { width: 68px; height: 68px; border-radius: 22px; display: grid; place-items: center; font-size: 2rem; box-shadow: var(--shadow); }
.ill .fabx { border-radius: 50%; background: var(--accent); color: #fff; font-size: 2.4rem; font-weight: 400; }
.ill .badge { font-size: .95rem; padding: 8px 16px; box-shadow: var(--shadow); }
.dots { display: flex; gap: 8px; }
.dots i { width: 8px; height: 8px; border-radius: 99px; background: rgba(143, 118, 217, .3); transition: width .25s, background .25s; }
.dots i.on { width: 24px; background: var(--accent); }

/* Animaciones */
main.enter > * { animation: rise .35s ease-out both; }
main.enter > :nth-child(n+3) { animation-delay: .05s; }
main.enter > :nth-child(n+5) { animation-delay: .1s; }
main.enter > :nth-child(n+7) { animation-delay: .15s; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
.btn, .tick, .fab, .tabs button, .sub button, .icon { transition: transform .12s; }
.btn:active, .tick:active, .fab:active, .tabs button:active, .sub button:active, .icon:active { transform: scale(.93); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
