/* ============ Nuestro Hogar · estilos ============ */
:root {
  --bg: #f4f1fb;
  --bg-2: #ffffff;
  --card: #ffffff;
  --card-2: #f7f5fc;
  --text: #1f1a33;
  --muted: #6f6a85;
  --line: #e7e2f3;
  --brand: #7c3aed;
  --brand-2: #ec4899;
  --brand-3: #f59e0b;
  --ok: #22c55e;
  --ok-bg: #dcfce7;
  --warn: #f59e0b;
  --warn-bg: #fef3c7;
  --danger: #ef4444;
  --shadow: 0 10px 30px -12px rgba(76, 29, 149, 0.25);
  --shadow-sm: 0 4px 14px -6px rgba(76, 29, 149, 0.2);
  --radius: 22px;
  --radius-sm: 14px;
  --tabbar-h: 68px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14111f;
    --bg-2: #1c1829;
    --card: #221d33;
    --card-2: #2a2440;
    --text: #f3f0fa;
    --muted: #a9a3c2;
    --line: #342d4d;
    --ok-bg: rgba(34, 197, 94, 0.18);
    --warn-bg: rgba(245, 158, 11, 0.18);
    --shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.6);
    --shadow-sm: 0 4px 14px -6px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 900; letter-spacing: -0.01em; }
.muted { color: var(--muted); }

.app { min-height: 100dvh; display: flex; flex-direction: column; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2) 70%, var(--brand-3));
  color: #fff;
  border-bottom-left-radius: 24px; border-bottom-right-radius: 24px;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { font-size: 30px; filter: drop-shadow(0 2px 4px rgba(0,0,0,.2)); }
.brand-title { font-weight: 900; font-size: 18px; line-height: 1.1; }
.brand-sub { font-size: 12px; opacity: .9; }
.who-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 6px; border-radius: 999px;
  background: rgba(255,255,255,.22); backdrop-filter: blur(6px);
  font-weight: 800; font-size: 14px; color: #fff;
  transition: transform .15s;
}
.who-btn:active { transform: scale(.96); }
.who-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; font-size: 18px;
  background: #fff;
}

/* ---------- Main view ---------- */
.view {
  flex: 1; padding: 16px 16px calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom));
  max-width: 760px; width: 100%; margin: 0 auto;
  animation: fadeIn .25s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none; } }

.section-title {
  display: flex; align-items: center; justify-content: space-between;
  margin: 22px 0 10px; font-size: 15px; font-weight: 900; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em;
}
.section-title:first-child { margin-top: 4px; }

.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 16px;
  margin-bottom: 14px;
}

/* ---------- Hero / progress ---------- */
.hero {
  display: flex; align-items: center; gap: 16px;
  background: var(--card); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow-sm); margin-bottom: 16px;
  position: relative; overflow: hidden;
}
.hero::after {
  content: ''; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px;
  background: radial-gradient(circle, rgba(124,58,237,.15), transparent 70%);
}
.hero h1 { font-size: 22px; line-height: 1.15; }
.hero p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.ring { position: relative; width: 84px; height: 84px; flex: none; }
.ring svg { transform: rotate(-90deg); width: 84px; height: 84px; }
.ring circle { fill: none; stroke-width: 9; stroke-linecap: round; }
.ring .track { stroke: var(--line); }
.ring .bar { stroke: url(#grad); transition: stroke-dashoffset .6s cubic-bezier(.2,.8,.2,1); }
.ring .label {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-weight: 900; font-size: 18px;
}

/* ---------- Member card ---------- */
.member-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  margin-bottom: 14px; overflow: hidden;
  border: 2px solid transparent;
}
.member-card.me { border-color: var(--mc, var(--brand)); }
.member-head {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px 10px;
}
.avatar {
  width: 46px; height: 46px; border-radius: 16px; flex: none;
  display: grid; place-items: center; font-size: 26px;
  background: color-mix(in srgb, var(--mc, var(--brand)) 18%, transparent);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--mc, var(--brand)) 40%, transparent);
}
.avatar.sm { width: 34px; height: 34px; border-radius: 12px; font-size: 19px; }
.avatar.xs { width: 26px; height: 26px; border-radius: 9px; font-size: 14px; }
.member-name { font-weight: 900; font-size: 17px; }
.member-meta { font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 800;
  background: var(--card-2); color: var(--muted);
}
.pill.ok { background: var(--ok-bg); color: #15803d; }
.pill.warn { background: var(--warn-bg); color: #b45309; }
.pill.brand { background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); }
@media (prefers-color-scheme: dark) {
  .pill.ok { color: #4ade80; } .pill.warn { color: #fbbf24; } .pill.brand { color: #c4b5fd; }
}
.member-bar { height: 6px; background: var(--line); margin: 0 16px 6px; border-radius: 99px; overflow: hidden; }
.member-bar > i { display: block; height: 100%; background: var(--mc, var(--brand)); border-radius: 99px; transition: width .5s; }

.task-list { display: flex; flex-direction: column; padding: 6px 10px 12px; gap: 8px; }
.task {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 16px;
  background: var(--card-2); transition: transform .12s, background .2s;
  min-height: 60px;
}
.task:active { transform: scale(.985); }
.task.done { background: var(--ok-bg); }
.task.done .task-name { text-decoration: line-through; opacity: .7; }
.task.pending-verify { background: var(--warn-bg); }
.task-check {
  width: 40px; height: 40px; border-radius: 13px; flex: none;
  display: grid; place-items: center; font-size: 22px;
  background: var(--card); box-shadow: var(--shadow-sm);
  transition: transform .15s;
}
.task-check.on { background: var(--ok); color: #fff; font-size: 24px; }
.task-check.wait { background: var(--warn); color: #fff; }
.task-check:active { transform: scale(.9); }
.task-check[disabled] { opacity: .6; cursor: default; }
.task-body { flex: 1; min-width: 0; }
.task-name { font-weight: 800; font-size: 15.5px; line-height: 1.2; }
.task-sub { font-size: 12px; color: var(--muted); margin-top: 2px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.task-icon { font-size: 22px; flex: none; }
.pts { font-weight: 900; color: var(--brand); font-size: 13px; white-space: nowrap; }
.verify-btn {
  padding: 8px 12px; border-radius: 12px; font-weight: 900; font-size: 13px;
  background: var(--ok); color: #fff; box-shadow: var(--shadow-sm); white-space: nowrap;
}
.verify-btn.undo { background: var(--card); color: var(--muted); }
.empty { text-align: center; padding: 26px 12px; color: var(--muted); font-weight: 700; }
.empty .big { font-size: 40px; display: block; margin-bottom: 8px; }

/* ---------- Week ---------- */
.nav-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.nav-row h2 { font-size: 18px; }
.nav-btn {
  width: 40px; height: 40px; border-radius: 12px; background: var(--card); box-shadow: var(--shadow-sm);
  font-weight: 900; font-size: 18px;
}
.week-grid { display: grid; grid-template-columns: 44px repeat(7, minmax(0, 1fr)); gap: 5px; align-items: center; }
.week-grid .dh { text-align: center; font-size: 11px; font-weight: 900; color: var(--muted); text-transform: uppercase; }
.week-grid .dh b { display: block; font-size: 15px; color: var(--text); }
.week-grid .dh.today b { color: var(--brand); }
.week-grid .cell {
  aspect-ratio: 1; border-radius: 12px; display: grid; place-items: center;
  font-size: 12px; font-weight: 900; background: var(--card-2); color: var(--muted);
  position: relative; overflow: hidden;
}
.week-grid .cell > i { position: absolute; left: 0; bottom: 0; right: 0; background: var(--mc); opacity: .35; }
.week-grid .cell > span { position: relative; }
.week-grid .cell.full { background: var(--mc); color: #fff; }
.week-grid .cell.full > i { display: none; }
.week-grid .cell.none { opacity: .45; }
.week-grid .cell.future { background: transparent; box-shadow: inset 0 0 0 2px var(--line); }
.leader { display: flex; flex-direction: column; gap: 10px; }
.leader-row { display: flex; align-items: center; gap: 10px; }
.leader-row .name { width: 90px; font-weight: 900; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.leader-row .bar { flex: 1; height: 16px; background: var(--card-2); border-radius: 99px; overflow: hidden; }
.leader-row .bar > i { display: block; height: 100%; border-radius: 99px; background: var(--mc); transition: width .6s; }
.leader-row .val { width: 60px; text-align: right; font-weight: 900; font-size: 13px; color: var(--muted); }
.star-card {
  display: flex; align-items: center; gap: 14px; padding: 16px;
  background: linear-gradient(135deg, #fde68a, #fbbf24 60%, #f59e0b); color: #4a2b00;
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 14px;
}
.star-card .avatar { background: rgba(255,255,255,.7); box-shadow: none; width: 56px; height: 56px; font-size: 32px; }
.star-card h3 { font-size: 17px; }
.star-card p { margin: 2px 0 0; font-size: 13px; font-weight: 700; }

/* ---------- Month ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.cal .dh { text-align: center; font-size: 11px; font-weight: 900; color: var(--muted); text-transform: uppercase; padding-bottom: 2px; }
.cal .day {
  aspect-ratio: 1; border-radius: 10px; background: var(--card-2);
  display: grid; place-items: center; font-size: 12px; font-weight: 800; color: var(--muted);
}
.cal .day.l1 { background: color-mix(in srgb, var(--brand) 22%, var(--card-2)); color: var(--text); }
.cal .day.l2 { background: color-mix(in srgb, var(--brand) 45%, var(--card-2)); color: #fff; }
.cal .day.l3 { background: color-mix(in srgb, var(--brand) 70%, var(--card-2)); color: #fff; }
.cal .day.l4 { background: var(--brand); color: #fff; }
.cal .day.today { outline: 2px solid var(--brand-2); outline-offset: 1px; }
.cal .day.future { opacity: .35; }
.cal .day.empty { background: transparent; }
.cal-legend { display: flex; gap: 6px; align-items: center; justify-content: flex-end; margin-top: 8px; font-size: 11px; color: var(--muted); }
.cal-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; background: var(--card-2); }
.cal-legend i.l1 { background: color-mix(in srgb, var(--brand) 22%, var(--card-2)); }
.cal-legend i.l2 { background: color-mix(in srgb, var(--brand) 45%, var(--card-2)); }
.cal-legend i.l4 { background: var(--brand); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--card); border-radius: 16px; padding: 12px; box-shadow: var(--shadow-sm); text-align: center; }
.stat b { display: block; font-size: 22px; font-weight: 900; color: var(--brand); }
.stat span { font-size: 11.5px; color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.level-list { display: flex; flex-direction: column; gap: 10px; }
.level-row { display: flex; align-items: center; gap: 12px; }
.level-row .info { flex: 1; min-width: 0; }
.level-row .info b { display: block; font-size: 14.5px; }
.level-row .info small { color: var(--muted); font-weight: 700; }
.level-row .lbar { height: 8px; background: var(--card-2); border-radius: 99px; margin-top: 5px; overflow: hidden; }
.level-row .lbar > i { display: block; height: 100%; background: var(--mc); border-radius: 99px; }
.level-badge { font-size: 26px; }
.history { display: flex; flex-direction: column; gap: 6px; }
.history .hday { font-size: 12.5px; font-weight: 900; color: var(--muted); margin: 10px 0 2px; }
.hitem {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: var(--card-2); font-size: 14px;
}
.hitem .t { flex: 1; min-width: 0; font-weight: 800; }
.hitem .t small { display: block; color: var(--muted); font-weight: 700; font-size: 12px; }

/* ---------- Tasks management ---------- */
.big-btn {
  width: 100%; padding: 14px; border-radius: 16px; font-weight: 900; font-size: 16px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.big-btn:active { transform: scale(.98); }
.mtask {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--card); border-radius: 16px; box-shadow: var(--shadow-sm); margin-bottom: 10px;
}
.mtask .task-icon { font-size: 26px; }
.mtask .body { flex: 1; min-width: 0; }
.mtask .body b { font-size: 15.5px; }
.mtask .body .sub { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; margin-top: 3px; align-items: center; }
.avatars { display: inline-flex; }
.avatars .avatar.xs { margin-left: -6px; box-shadow: 0 0 0 2px var(--card); }
.avatars .avatar.xs:first-child { margin-left: 0; }
.icon-btn { width: 38px; height: 38px; border-radius: 12px; background: var(--card-2); display: grid; place-items: center; font-size: 17px; }
.icon-btn.danger { color: var(--danger); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(20, 12, 40, .55);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn .2s;
}
@media (min-width: 600px) { .modal-backdrop { align-items: center; } }
.modal {
  width: 100%; max-width: 560px; max-height: 92dvh; overflow: auto;
  background: var(--bg-2); border-radius: 26px 26px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px rgba(0,0,0,.25);
  animation: slideUp .25s cubic-bezier(.2,.8,.2,1);
}
@media (min-width: 600px) { .modal { border-radius: 26px; } }
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal h2 { font-size: 20px; margin-bottom: 14px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 900; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.input {
  width: 100%; padding: 12px 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--card);
  font-weight: 700; font-size: 16px; outline: none;
}
.input:focus { border-color: var(--brand); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 12px; border-radius: 999px; background: var(--card-2); font-weight: 800; font-size: 14px;
  border: 2px solid transparent; display: inline-flex; align-items: center; gap: 6px;
}
.chip.on { border-color: var(--mc, var(--brand)); background: color-mix(in srgb, var(--mc, var(--brand)) 15%, var(--card-2)); }
.seg { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; background: var(--card-2); padding: 4px; border-radius: 14px; }
.seg button { padding: 9px 4px; border-radius: 10px; font-weight: 900; font-size: 13px; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--brand); box-shadow: var(--shadow-sm); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
.emoji-grid button { aspect-ratio: 1; border-radius: 12px; font-size: 24px; background: var(--card-2); border: 2px solid transparent; }
.emoji-grid button.on { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 15%, var(--card-2)); }
.days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.days button { padding: 10px 0; border-radius: 12px; font-weight: 900; background: var(--card-2); font-size: 13px; border: 2px solid transparent; }
.days button.on { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 15%, var(--card-2)); color: var(--brand); }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.btn { flex: 1; padding: 13px; border-radius: 14px; font-weight: 900; font-size: 15px; background: var(--card-2); }
.btn.primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; box-shadow: var(--shadow); }
.btn.danger { background: var(--danger); color: #fff; }
.who-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.who-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 8px; border-radius: 18px;
  background: var(--card); box-shadow: var(--shadow-sm); border: 3px solid transparent; font-weight: 900;
}
.who-card.on { border-color: var(--mc); }
.who-card .avatar { width: 56px; height: 56px; font-size: 32px; border-radius: 18px; }
.who-card small { color: var(--muted); font-weight: 800; font-size: 12px; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding: 6px 8px env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
  background: color-mix(in srgb, var(--bg-2) 85%, transparent); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border-radius: 14px; font-size: 12px; font-weight: 900; color: var(--muted);
}
.tab-icon { font-size: 22px; transition: transform .2s; }
.tab.active { color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, transparent); }
.tab.active .tab-icon { transform: translateY(-2px) scale(1.12); }

/* ---------- Toast / confetti ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 800; font-size: 14px;
  z-index: 60; box-shadow: var(--shadow); animation: fadeIn .2s; max-width: 90vw; text-align: center;
}
.confetti-layer { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.confetti-piece { display: block;
  position: absolute; top: -10px; width: 10px; height: 14px; border-radius: 3px;
  animation: fall linear forwards;
}
@keyframes fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(105vh) rotate(720deg); opacity: .8; }
}
.banner {
  padding: 10px 14px; border-radius: 14px; background: var(--warn-bg); color: #92400e; font-size: 13px; font-weight: 800;
  margin-bottom: 12px;
}
@media (prefers-color-scheme: dark) { .banner { color: #fcd34d; } }

/* ---------- Cumplimiento (barras con dos tonos) y PIN ---------- */
.member-bar { position: relative; }
.member-bar > i { position: absolute; left: 0; top: 0; }
.member-bar > i.pend { background: var(--mc, var(--brand)); opacity: .3; }
.member-pct { font-weight: 900; font-size: 20px; color: var(--mc, var(--brand)); flex: none; }
.leader-row .bar { position: relative; }
.leader-row .bar > i { position: absolute; left: 0; top: 0; }
.leader-row .bar > i.pend { opacity: .3; }
.leader-row .val { width: 62px; line-height: 1.1; }
.leader-row .val small { display: block; font-size: 11px; font-weight: 800; color: var(--muted); }
.level-row .lbar { position: relative; height: 8px; background: var(--card-2); border-radius: 99px; margin-top: 5px; overflow: hidden; }
.level-row .lbar > i { position: absolute; left: 0; top: 0; height: 100%; display: block; background: var(--mc); border-radius: 99px; }
.level-row .lbar > i.pend { opacity: .3; }
.level-row .member-pct { font-size: 17px; }
.ring .pend { stroke: var(--brand); opacity: .22; transition: stroke-dashoffset .6s cubic-bezier(.2,.8,.2,1); }
.input.pin { text-align: center; font-size: 28px; letter-spacing: .4em; font-weight: 900; }
