:root {
  --bg: #f7f2ea;
  --card: #fffdf9;
  --ink: #3a3633;
  --muted: #8c857d;
  --line: #eee6da;
  --green: #5e8a63;
  --green-ink: #3f6b45;
  --green-soft: #dcebd6;
  --pink: #fbe1e1;
  --pink-ink: #e07a8b;
  --lav: #e2e1f6;
  --yellow: #fbf0cc;
  --mint: #d5eee3;
  --chip: #f1ebe1;
  --red: #d9605a;
  --shadow: 0 2px 12px rgba(90, 70, 40, .07);
  --r: 18px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { min-height: 100%; }
body {
  font-family: 'Nunito', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; text-align: left; }
a { color: inherit; text-decoration: none; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 14px) 16px calc(92px + env(safe-area-inset-bottom));
}

/* ---------- Barra inferior ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  max-width: 480px; margin: 0 auto;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
}
.nav a { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; color: var(--muted); padding: 2px 12px; border-radius: 12px; }
.nav a.on { color: var(--ink); font-weight: 700; }
.nav a.on svg { color: var(--green); background: var(--green-soft); border-radius: 8px; padding: 2px; width: 26px; height: 26px; margin: -2px; }
.nav svg circle { fill: currentColor; stroke: none; }

/* ---------- Comunes ---------- */
.topbar { display: flex; align-items: center; gap: 10px; margin: 2px 0 14px; min-height: 40px; }
.topbar h1 { font-size: 22px; font-weight: 800; flex: 1; display: flex; align-items: center; gap: 10px; }
.topbar .ic { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; }
.icon-btn { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; color: var(--ink); }
.icon-btn:active { background: var(--chip); }
.icon-btn.plus svg { width: 26px; height: 26px; }

.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 14px; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; margin: 2px 0 8px; }
.sec-head h3 { font-size: 17px; font-weight: 800; }
.sec-head .count, .link { font-size: 12px; color: var(--muted); }
.sec-title { font-size: 18px; font-weight: 800; margin: 18px 4px 8px; }

.tabs { display: flex; background: var(--chip); border-radius: 999px; padding: 4px; margin-bottom: 14px; }
.tabs button { flex: 1; text-align: center; padding: 8px 6px; border-radius: 999px; font-size: 13px; color: var(--muted); font-weight: 600; }
.tabs button.on { background: var(--green-soft); color: var(--green-ink); font-weight: 800; }

.empty { color: var(--muted); font-size: 14px; padding: 14px 0; text-align: center; }
.add-inline { display: block; width: 100%; padding: 10px 0 2px; color: var(--green); font-weight: 700; font-size: 14px; }

/* ---------- Filas ---------- */
.row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; padding: 2px 0; }
.row-title { font-size: 15px; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 12px; color: var(--muted); }
.row-sub.late { color: var(--red); font-weight: 700; }
.row-time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.heart { color: var(--pink-ink); }
.chev { color: var(--muted); }
.chev svg { width: 18px; height: 18px; }

.chk {
  width: 22px; height: 22px; flex: none; border-radius: 6px;
  border: 1.6px solid #cfc6ba; display: grid; place-items: center; background: #fff;
}
.chk svg { width: 15px; height: 15px; stroke: #fff; stroke-width: 3; }
.task.done .chk, .chk.on { background: var(--green); border-color: var(--green); }
.task.done .row-title { text-decoration: line-through; color: var(--muted); }

.cat-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

/* ---------- Inicio ---------- */
.home-head { position: relative; text-align: center; padding: 6px 0 10px; }
.home-head .corner { position: absolute; right: -6px; top: -4px; }
.script { font-family: 'Great Vibes', cursive; font-weight: 400; font-size: 58px; line-height: 1.05; }
.script .h { font-family: 'Nunito', sans-serif; font-size: 20px; vertical-align: middle; }
.home-head .title { font-size: 22px; font-weight: 600; margin-top: 2px; }
.home-head .tags { color: var(--muted); font-size: 13px; margin-top: 4px; }

.quote {
  position: relative; background: var(--yellow); border-radius: var(--r);
  padding: 16px 64px 16px 18px; text-align: center; font-size: 14px; margin: 8px 0 16px; min-height: 64px;
}
.quote .leaf { position: absolute; right: 12px; bottom: 6px; width: 36px; height: 54px; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; height: 74px; border-radius: 16px; font-size: 14px; font-weight: 700; }
.tile svg { width: 26px; height: 26px; }
.tile:active { transform: scale(.98); }
.bg-pink { background: var(--pink); } .bg-green { background: var(--green-soft); } .bg-lav { background: var(--lav); }
.bg-yellow { background: var(--yellow); } .bg-mint { background: var(--mint); } .bg-chip { background: var(--chip); }

.banner { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px dashed #d8cdbd; border-radius: var(--r); padding: 12px 14px; margin-bottom: 14px; font-size: 13px; }
.banner p { flex: 1; }
.banner b { display: block; font-size: 14px; }

/* ---------- Calendario ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-head h1 { font-size: 20px; font-weight: 800; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 4px; margin-bottom: 14px; }
.cal-grid .wd { text-align: center; font-size: 12px; color: var(--muted); font-weight: 700; padding: 6px 0; }
.day { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 0; height: 50px; }
.day .n { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; font-size: 15px; font-weight: 600; }
.day.out .n { color: #c4bcb1; font-weight: 400; }
.day.today .n { box-shadow: inset 0 0 0 1.6px var(--green); }
.day.sel .n { background: var(--green); color: #fff; box-shadow: none; }
.dots { display: flex; gap: 3px; height: 5px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; }

.agenda-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; width: 100%; font-size: 14px; }
.agenda-row .a-time { width: 74px; color: var(--muted); font-size: 13px; flex: none; }
.agenda-row .a-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agenda-row.done .a-title { text-decoration: line-through; color: var(--muted); }

/* ---------- Búsqueda ---------- */
.search { display: flex; align-items: center; gap: 8px; background: var(--chip); border-radius: 12px; padding: 0 12px; margin-bottom: 14px; }
.search svg { width: 18px; height: 18px; color: var(--muted); }
.search input { flex: 1; border: 0; background: none; padding: 11px 0; outline: none; font-size: 15px; }

/* ---------- Empresa ---------- */
.company { display: flex; align-items: center; gap: 14px; padding: 18px 16px; }
.company { display: flex; }
.logo { border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 800; letter-spacing: .5px; }
.company h2 { font-size: 20px; font-weight: 800; }
.top-sub { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }
.info-group { padding: 6px 0 4px; }
.info-group h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--green-ink); margin: 8px 0 4px; }
.info-row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.info-row:last-child { border-bottom: 0; }
.info-row span { color: var(--muted); flex: none; }
.info-row b { font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.info-row a { color: var(--green-ink); text-decoration: underline; text-underline-offset: 2px; }
.info-notes { font-size: 14px; white-space: pre-wrap; }
.form-sec { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--green-ink); margin: 14px 0 8px; }
.form-sec:first-of-type { margin-top: 0; }
.co-filter { display: flex; gap: 8px; overflow-x: auto; margin: -4px 0 12px; padding-bottom: 2px; scrollbar-width: none; }
.co-filter .chip { font-size: 13px; padding: 6px 12px; flex: none; }
.company p { color: var(--muted); font-size: 14px; }
.company i { font-size: 12px; color: var(--ink); }
.menu-row { display: flex; align-items: center; gap: 14px; padding: 12px 2px; border-bottom: 1px solid var(--line); width: 100%; }
.menu-row:last-child { border-bottom: 0; }
.menu-row > svg { color: var(--green-ink); }
.chip { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--chip); color: var(--muted); white-space: nowrap; }
.chip.green { background: var(--green-soft); color: var(--green-ink); }
.chip.yellow { background: var(--yellow); color: #8a6d1f; }
.chip.red { background: #f9dcda; color: var(--red); }

/* ---------- Cumpleaños / Finanzas ---------- */
.bubble { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-size: 18px; flex: none; }
.fin-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.fin-ico svg { width: 18px; height: 18px; }
.amt { font-weight: 800; font-size: 15px; white-space: nowrap; }
.paid .amt, .paid .row-title { color: var(--muted); text-decoration: line-through; }
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.summary div { border-radius: 14px; padding: 10px; }
.summary span { display: block; font-size: 11px; color: var(--muted); font-weight: 700; }
.summary b { font-size: 15px; }

/* ---------- Notas ---------- */
.note { display: block; width: 100%; border-radius: 16px; padding: 12px 14px; margin-bottom: 12px; }
.note h3 { font-size: 15px; font-weight: 800; display: flex; justify-content: space-between; margin-bottom: 4px; }
.note ul { list-style: none; font-size: 13px; }
.note li::before { content: '- '; }
.note small { display: block; margin-top: 8px; font-size: 11px; color: var(--muted); }

/* ---------- Hoy ---------- */
.today-head { display: flex; justify-content: space-between; align-items: flex-start; margin: 6px 0 16px; }
.today-head h1 { font-size: 26px; font-weight: 800; }
.today-head p { color: var(--muted); font-size: 14px; }
.today-head svg { width: 40px; height: 40px; color: #f4b63f; stroke-width: 2; }
.progress { height: 6px; background: var(--chip); border-radius: 9px; overflow: hidden; margin: 2px 0 8px; }
.progress i { display: block; height: 100%; background: var(--green); border-radius: 9px; transition: width .3s; }
.dream { position: relative; background: var(--pink); border-radius: var(--r); padding: 24px 28px; text-align: center; font-family: 'Caveat', cursive; font-size: 24px; line-height: 1.3; }

/* ---------- Formularios ---------- */
.sheet-bg { position: fixed; inset: 0; z-index: 50; background: rgba(40, 30, 20, 0); display: flex; align-items: flex-end; justify-content: center; transition: background .2s; }
.sheet-bg.open { background: rgba(40, 30, 20, .35); }
.sheet {
  width: 100%; max-width: 480px; max-height: 92vh; overflow-y: auto;
  background: var(--card); border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .25s ease;
}
.sheet-bg.open .sheet { transform: none; }
.sheet-grip { width: 40px; height: 4px; border-radius: 4px; background: #ddd3c5; margin: 0 auto 12px; }
.sheet h2 { font-size: 19px; font-weight: 800; margin-bottom: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; font-size: 13px; color: var(--muted); font-weight: 700; flex: 1; min-width: 0; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 12px;
  padding: 11px 12px; font-size: 16px; color: var(--ink); font-weight: 400; outline: none; min-height: 46px;
}
.field textarea { min-height: 110px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--green); }
.check-field { display: flex; align-items: center; gap: 10px; font-size: 15px; margin-bottom: 12px; }
.check-field input { width: 22px; height: 22px; accent-color: var(--green); }
.row2 { display: flex; gap: 10px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 6px; }
.btn { padding: 12px 16px; border-radius: 12px; font-weight: 800; text-align: center; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.primary { background: var(--green); color: #fff; flex: 1; }
.btn.ghost { background: var(--chip); }
.btn.danger { background: #f9dcda; color: var(--red); }
.btn.small { padding: 8px 12px; font-size: 13px; }
.btn-col { display: flex; flex-direction: column; gap: 10px; }
.btn-col .btn { width: 100%; }
.hint { font-size: 13px; color: var(--muted); margin-bottom: 10px; }

#toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: #3a3633; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px;
  transition: .25s; max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Repeticiones */
.agenda-row.ghost { opacity: .6; }
.agenda-row.ghost .a-title { font-style: italic; }
.del-choice { background: #fdf1f0; border-radius: 14px; padding: 12px; margin: 4px 0 12px; display: flex; flex-direction: column; gap: 8px; }
.del-choice[hidden] { display: none; }
.del-choice p { font-size: 14px; font-weight: 700; color: var(--red); }
.del-choice .btn { width: 100%; }

/* ---------- Entrada (iniciar sesión, crear cuenta…) ---------- */
body.locked .nav { display: none; }
.auth { padding-top: 28px; padding-bottom: 40px; }
.auth-head { text-align: center; margin-bottom: 18px; }
.auth-head img { width: 72px; height: 72px; border-radius: 20px; box-shadow: var(--shadow); }
.auth-head .title { font-size: 24px; font-weight: 800; margin-top: 10px; }
.auth-head .tags { color: var(--muted); font-size: 13px; margin-top: 4px; }
.auth-card { padding: 20px 18px; }
.auth-card h2 { font-size: 20px; font-weight: 800; margin-bottom: 14px; }
.btn.wide { width: 100%; margin-top: 4px; }
.btn:disabled { opacity: .6; cursor: wait; }
.auth-link { display: block; margin: 14px auto 0; font-size: 14px; color: var(--green-ink); font-weight: 700; text-align: center; }
.auth-alt { text-align: center; font-size: 14px; color: var(--muted); }
.auth-alt .auth-link { display: inline; margin: 0; }
.auth-foot { text-align: center; font-size: 12px; color: var(--muted); margin-top: 22px; }
.auth-wait { text-align: center; color: var(--muted); padding: 18px 0; }
.auth-msg { border-radius: 12px; padding: 10px 12px; font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.auth-msg.err { background: #f9dcda; color: #a63d38; }
.auth-msg.ok { background: var(--green-soft); color: var(--green-ink); }
.auth-msg[hidden] { display: none; }
.pw { position: relative; display: block; }
.pw input { width: 100%; padding-right: 76px; }
.pw-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); font-size: 12px; font-weight: 800; color: var(--green-ink); padding: 6px 8px; }
.code-input { font-size: 24px !important; letter-spacing: 6px; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------- Seguridad (Ajustes) ---------- */
.sync-line { margin: 8px 0 4px; }
.steps { padding-left: 20px; font-size: 14px; margin-bottom: 10px; display: flex; flex-direction: column; gap: 6px; }
.qr { display: flex; justify-content: center; margin: 4px 0 12px; }
.qr img { width: 190px; height: 190px; background: #fff; padding: 8px; border-radius: 12px; border: 1px solid var(--line); }
.secret { display: inline-block; font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--chip); padding: 2px 6px; border-radius: 6px; word-break: break-all; user-select: all; color: var(--ink); }
