:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --ink: #1f2a2e;
  --muted: #5f6b70;
  --line: #e6e0d6;
  --primary: #2f7d6d;
  --primary-soft: #e4f3ef;
  --accent: #e8a54b;
  --accent-soft: #fff3e0;
  --danger: #c44b4b;
  --danger-soft: #fdecec;
  --overdue: #b45309;
  --overdue-bg: #fff7ed;
  --pink: #c45b7a;
  --pink-soft: #fce8ef;
  --ok: #2f7d6d;
  --shadow: 0 8px 24px rgba(31, 42, 46, 0.08);
  --radius: 16px;
  --nav-h: 68px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; font-family: var(--font); background: var(--bg); color: var(--ink); min-height: 100%; overflow-x: hidden; }
body { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 16px); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }

.app-header {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(180deg, #2f7d6d 0%, #27695c 100%);
  color: white; padding: calc(14px + env(safe-area-inset-top, 0px)) calc(16px + env(safe-area-inset-right, 0px)) 12px calc(16px + env(safe-area-inset-left, 0px));
  box-shadow: 0 4px 16px rgba(47, 125, 109, 0.25);
}
.app-header h1 { margin: 0; font-size: 1.2rem; font-weight: 700; letter-spacing: -0.02em; }
.app-header p { margin: 3px 0 0; font-size: 0.78rem; opacity: 0.9; }
.header-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.header-actions button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 12px; border-radius: 999px; font-weight: 600; font-size: 0.82rem;
}
.header-actions button {
  background: rgba(255,255,255,0.16); color: white; border: 1px solid rgba(255,255,255,0.25);
}
.header-actions select {
  background: rgba(255,255,255,0.16); color: white; border: 1px solid rgba(255,255,255,0.25);
  border-radius: 999px; padding: 8px 10px; font-size: 0.82rem; font-weight: 600;
}
.header-actions select option { color: #1f2a2e; }

.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: var(--primary-soft); color: var(--primary); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-pink { background: var(--pink); color: white; }
.btn-block { width: 100%; }
.btn:active { transform: scale(0.97); }

main { max-width: 560px; margin: 0 auto; padding: 12px 12px 0; }
.panel.active > .card:last-child { margin-bottom: 0; }
.panel { display: none; }
.panel.active { display: block; animation: fadeIn 0.18s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; margin-bottom: 12px; border: 1px solid rgba(230,224,214,0.8);
}
.card h2 { margin: 0 0 10px; font-size: 1.05rem; }
.card h3 { margin: 0 0 8px; font-size: 0.95rem; }

.form-grid { display: grid; gap: 10px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 0.78rem; color: var(--muted); font-weight: 600; }
label.field input, label.field select, label.field textarea {
  width: 100%; padding: 10px 11px; border: 1px solid var(--line); border-radius: 12px;
  background: #fbfaf8; outline: none; font-size: 1rem;
}
label.field input:focus, label.field select:focus, label.field textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47,125,109,0.15); background: white;
}

.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  display: flex; align-items: flex-start; gap: 10px; padding: 11px;
  background: #fbfaf8; border: 1px solid var(--line); border-radius: 14px; position: relative;
}
.item.checked { opacity: 0.55; }
.item.checked .item-title { text-decoration: line-through; }
.item.overdue { background: var(--overdue-bg); border-color: #fcd9a8; }
.item-main { flex: 1; min-width: 0; }
.item-title { font-weight: 650; font-size: 0.95rem; margin: 0 0 2px; word-break: break-word; }
.item-meta { font-size: 0.75rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: #8a5a12; font-weight: 700; font-size: 0.7rem;
}
.badge.green { background: var(--primary-soft); color: var(--primary); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.amber { background: var(--overdue-bg); color: var(--overdue); }
.badge.pink { background: var(--pink-soft); color: var(--pink); }

.check {
  width: 24px; height: 24px; border-radius: 8px; border: 2px solid var(--primary);
  display: grid; place-items: center; flex-shrink: 0; margin-top: 1px; background: white;
}
.check.on { background: var(--primary); color: white; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  color: var(--muted); flex-shrink: 0;
}
@media (hover: hover) { .icon-btn:hover { background: var(--danger-soft); color: var(--danger); } }
.icon-btn:active { background: var(--danger-soft); color: var(--danger); }
.empty { text-align: center; color: var(--muted); padding: 18px 10px; font-size: 0.9rem; }

.summary-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.stat { background: var(--primary-soft); border-radius: 14px; padding: 10px; text-align: center; }
.stat.expense { background: var(--danger-soft); }
.stat.balance { background: var(--accent-soft); }
.stat .label { font-size: 0.68rem; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.stat .value { font-size: 0.88rem; font-weight: 800; margin-top: 4px; word-break: break-word; }

.section-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 10px; }
.section-title h3 { margin: 0; font-size: 0.95rem; }

.child-tabs, .seg-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.child-tabs.three, .seg-tabs.three { grid-template-columns: 1fr 1fr 1fr; }
.child-tab, .seg-tab {
  padding: 11px; border-radius: 14px; background: #f0ebe3; font-weight: 700; color: var(--muted); font-size: 0.85rem;
}
.child-tab.active, .seg-tab.active { background: var(--primary); color: white; }

.timeline { position: relative; padding-left: 18px; }
.timeline::before {
  content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: var(--line);
}
.timeline-item {
  position: relative; margin-bottom: 10px; padding: 10px 12px;
  background: #fbfaf8; border: 1px solid var(--line); border-radius: 12px;
}
.timeline-item::before {
  content: ""; position: absolute; left: -16px; top: 16px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--primary); border: 2px solid white; box-shadow: 0 0 0 1px var(--primary);
}
.timeline-time { font-size: 0.75rem; font-weight: 700; color: var(--primary); }

.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.quick-btn {
  padding: 16px 10px; border-radius: 16px; background: var(--primary-soft); color: var(--primary);
  font-weight: 800; font-size: 0.95rem; border: 1px solid rgba(47,125,109,0.15);
}
.quick-btn:active { background: var(--primary); color: white; }

.home-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.home-tile {
  background: var(--surface); border-radius: 16px; padding: 16px 12px; text-align: center;
  box-shadow: var(--shadow); border: 1px solid rgba(230,224,214,0.8);
  font-weight: 700; font-size: 0.88rem; color: var(--ink);
}
.home-tile .emoji { display: block; font-size: 1.6rem; margin-bottom: 6px; }
.home-tile:active { transform: scale(0.98); }

.highlight {
  background: linear-gradient(135deg, #2f7d6d 0%, #3a9a86 50%, #e8a54b 130%);
  color: white; border: none; border-radius: 18px; padding: 16px; margin-bottom: 12px;
  box-shadow: 0 10px 28px rgba(47,125,109,0.28);
}
.highlight .eyebrow { font-size: 0.72rem; font-weight: 700; opacity: 0.85; text-transform: uppercase; letter-spacing: 0.04em; }
.highlight h3 { margin: 4px 0 6px; font-size: 1.15rem; }
.highlight p { margin: 0; font-size: 0.88rem; opacity: 0.95; }

.couple-hero {
  background: linear-gradient(135deg, #c45b7a 0%, #e08aa3 45%, #e8a54b 120%);
  color: white; border-radius: 18px; padding: 18px; margin-bottom: 12px;
  box-shadow: 0 10px 28px rgba(196,91,122,0.28);
}
.couple-hero h2 { margin: 0 0 6px; font-size: 1.2rem; }
.couple-hero p { margin: 0; opacity: 0.95; font-size: 0.9rem; }
.anniv-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.anniv-card {
  background: rgba(255,255,255,0.18); border-radius: 14px; padding: 12px; text-align: center;
}
.anniv-card strong { display: block; font-size: 1.3rem; }

.menu-day { margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px dashed var(--line); }
.menu-day h4 { margin: 0 0 6px; font-size: 0.88rem; color: var(--primary); }
.menu-meal { display: grid; gap: 4px; margin-bottom: 8px; font-size: 0.85rem; }
.progress {
  height: 8px; background: #eee; border-radius: 999px; overflow: hidden; margin-top: 4px;
}
.progress > span { display: block; height: 100%; background: var(--primary); }
.progress.warn > span { background: var(--accent); }
.progress.over > span { background: var(--danger); }

.photo-thumb { width: 100%; max-height: 180px; object-fit: cover; border-radius: 12px; margin-top: 8px; }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  background: rgba(255,255,255,0.96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, 1fr);
  z-index: 30; max-width: 560px; margin: 0 auto; padding-bottom: env(safe-area-inset-bottom, 0px);
}
.nav-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--muted); font-size: 0.66rem; font-weight: 700;
}
.nav-btn .nav-icon { font-size: 1.2rem; line-height: 1; }
.nav-btn.active { color: var(--primary); }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 16px);
  transform: translateX(-50%) translateY(20px); background: #1f2a2e; color: white;
  padding: 10px 16px; border-radius: 999px; font-size: 0.85rem; opacity: 0;
  pointer-events: none; transition: all 0.2s ease; z-index: 50;
  max-width: 90vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.money-pos { color: var(--ok); }
.money-neg { color: var(--danger); }
.cat-summary { display: flex; flex-direction: column; gap: 6px; }
.cat-row {
  display: flex; justify-content: space-between; gap: 8px; font-size: 0.88rem;
  padding: 8px 10px; background: #fbfaf8; border-radius: 10px;
}
.small { font-size: 0.78rem; color: var(--muted); }


.chart-box {
  margin-top: 12px;
  background: #fbfaf8;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 8px 6px;
  overflow-x: auto;
}
.chart-box svg { display: block; width: 100%; height: auto; }
.bar-row {
  display: grid;
  grid-template-columns: 1fr 64px;
  gap: 8px;
  align-items: center;
  font-size: 0.82rem;
  margin-bottom: 6px;
}
.bar-track {
  height: 10px;
  background: #eee;
  border-radius: 999px;
  overflow: hidden;
}
.bar-track > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #4aa891);
  border-radius: 999px;
}

.bell-btn {
  position: relative;
  background: rgba(255,255,255,0.16) !important;
  color: white !important;
  border: 1px solid rgba(255,255,255,0.25) !important;
  border-radius: 999px !important;
  padding: 8px 12px !important;
  font-size: 1.05rem !important;
}
.bell-badge {
  position: absolute;
  top: -4px; right: -4px;
  min-width: 18px; height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #c44b4b;
  color: white;
  font-size: 0.68rem;
  font-weight: 800;
  display: grid; place-items: center;
  border: 2px solid #27695c;
}
.aviso-unread { border-color: #fcd9a8; background: var(--overdue-bg); }
.aviso-alta .item-title::before { content: "⚠ "; }

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px 6px 8px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 650;
  line-height: 1.2;
  max-width: 100%;
  white-space: nowrap;
}
.chip-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(31,42,46,0.08);
}

/* ——— iOS / PWA ——— */
html { -webkit-text-size-adjust: 100%; }
input, select, textarea { font-size: 16px !important; } /* evita zoom no iPhone */
main { padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
.toast { bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 16px); }
.bottom-nav { padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
.nav-btn, .btn, .home-tile, .header-actions button { touch-action: manipulation; }
.btn:active, .home-tile:active, .nav-btn:active { opacity: .75; }
.ios-hint { position: relative; border: 1px solid var(--primary); background: var(--primary-soft); }
.ios-hint h2 { margin-top: 0; }
.ios-hint-close { position: absolute; top: 8px; right: 8px; }

/* ——— Login ——— */
body.locked { padding-bottom: 0; }
body.locked > .app-header, body.locked > main, body.locked > .bottom-nav { display: none !important; }
.login-screen {
  min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: calc(24px + env(safe-area-inset-top, 0px)) 20px calc(24px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, #2f7d6d 0%, #f6f3ee 60%);
}
.login-screen[hidden] { display: none; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px 20px; text-align: center; }
.login-card h1 { margin: 8px 0 4px; font-size: 1.35rem; }
.login-card .form-grid { text-align: left; margin-top: 14px; }
.login-logo { border-radius: 16px; }
.login-msg { min-height: 1.2em; margin-top: 12px; }
.login-msg.error { color: var(--danger); font-weight: 600; }
#login-code { letter-spacing: .3em; text-align: center; font-size: 22px !important; }
.ios-hint-inline { margin-top: 14px; padding: 10px 12px; border-radius: 12px; text-align: left; }

[hidden] { display: none !important; }
