:root {
  --red: #b4232a;
  --red-dark: #8c1a20;
  --green: #1f5c3f;
  --green-dark: #143f2b;
  --gold: #d9a441;
  --cream: #fbf6ec;
  --paper: #ffffff;
  --ink: #2a2522;
  --muted: #776d65;
  --line: #eadfce;
  --danger: #b4232a;
  --ok: #2f7a4f;
  --radius: 16px;
  --shadow: 0 6px 20px rgba(60, 30, 10, 0.08);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--cream);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--green); }
h1, h2, h3 { margin: 0 0 0.4em; line-height: 1.2; }
.festive { font-family: 'Mountains of Christmas', 'Nunito', serif; font-weight: 700; }

/* ---------- Layout ---------- */
.topbar {
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  color: #fff;
  padding: calc(14px + env(safe-area-inset-top)) 16px 18px;
  position: relative;
  overflow: hidden;
}
.topbar::after {
  content: '';
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,.35) 1.2px, transparent 1.6px);
  background-size: 22px 22px;
  opacity: .35;
  pointer-events: none;
}
.topbar-inner { max-width: 720px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; position: relative; z-index: 1; }
.topbar h1 { font-size: 1.9rem; margin: 0; }
.topbar .sub { opacity: .9; font-size: .95rem; }
.topbar button.link { color: #fff; }

main { max-width: 720px; margin: 0 auto; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }

.card {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
}
.card h2 { font-size: 1.15rem; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
.hidden { display: none !important; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 700; font-size: .9rem; margin-bottom: 6px; }
input, textarea, select {
  width: 100%;
  font: inherit;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fffdf9;
  color: var(--ink);
  outline: none;
  transition: border-color .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--green); }
textarea { min-height: 90px; resize: vertical; }
.field { margin-bottom: 14px; }
.pin-input { font-size: 2rem; letter-spacing: .6em; text-align: center; padding-left: .6em; font-weight: 800; }
.phone-input { font-size: 1.3rem; text-align: center; letter-spacing: .05em; }

button, .btn {
  font: inherit;
  font-weight: 800;
  border: 0;
  border-radius: 12px;
  padding: 12px 18px;
  cursor: pointer;
  background: var(--green);
  color: #fff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform .08s, background .15s, opacity .15s;
}
button:active, .btn:active { transform: scale(.98); }
button:disabled { opacity: .55; cursor: default; }
button.block, .btn.block { width: 100%; }
button.red, .btn.red { background: var(--red); }
button.ghost, .btn.ghost { background: transparent; color: var(--green); border: 1.5px solid var(--line); }
button.danger { background: transparent; color: var(--danger); border: 1.5px solid #f0cfcf; }
button.link { background: none; color: var(--green); padding: 4px 6px; font-weight: 700; text-decoration: underline; }
button.sm, .btn.sm { padding: 7px 12px; font-size: .88rem; border-radius: 10px; }

.error { color: var(--danger); font-weight: 700; margin: 8px 0 0; min-height: 1.2em; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px 16px; background: linear-gradient(160deg, var(--red) 0%, var(--red-dark) 55%, var(--green-dark) 100%); position: relative; overflow: hidden; }
.login-wrap .card { max-width: 400px; width: 100%; margin: 0 auto; padding: 26px 22px; position: relative; z-index: 1; }
.login-logo { text-align: center; color: #fff; margin-bottom: 18px; position: relative; z-index: 1; }
.login-logo img { width: 84px; height: 84px; border-radius: 22px; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.login-logo h1 { font-size: 2.6rem; margin: 10px 0 0; }
.login-logo p { margin: 4px 0 0; opacity: .9; }

.snow { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.snow i { position: absolute; top: -10px; width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.8); animation: fall linear infinite; }
@keyframes fall { to { transform: translateY(110vh) translateX(30px); } }
@media (prefers-reduced-motion: reduce) { .snow { display: none; } }

/* ---------- Tabs ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--paper);
  border-top: 1px solid var(--line);
  display: flex; justify-content: center;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}
.tabbar-inner { display: flex; max-width: 720px; width: 100%; }
.tabbar button { flex: 1; background: none; color: var(--muted); border-radius: 0; padding: 10px 8px 12px; flex-direction: column; gap: 2px; font-size: .8rem; }
.tabbar button .ico { font-size: 1.4rem; line-height: 1; }
.tabbar button.active { color: var(--red); }

/* ---------- Posadas ---------- */
.posada-card { cursor: pointer; display: flex; gap: 14px; align-items: center; }
.posada-card .badge-ico { width: 52px; height: 52px; border-radius: 14px; background: #fcebea; display: grid; place-items: center; font-size: 1.7rem; flex-shrink: 0; }
.posada-card .info { flex: 1; min-width: 0; }
.posada-card .info h2 { margin: 0 0 2px; }
.chev { color: var(--muted); font-size: 1.4rem; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 800; background: #eef5f0; color: var(--green); }
.pill.wait { background: #fbf1df; color: #9a6a12; }
.pill.red { background: #fcebea; color: var(--red); }

.meta { display: grid; gap: 8px; margin: 6px 0 0; }
.meta div { display: flex; gap: 10px; align-items: flex-start; }
.meta .k { width: 22px; text-align: center; }

.reveal {
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  color: #fff;
  padding: 26px 18px;
  text-align: center;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.reveal .gift { font-size: 4rem; display: inline-block; animation: wiggle 2.2s ease-in-out infinite; }
@keyframes wiggle { 0%, 70%, 100% { transform: rotate(0); } 75% { transform: rotate(-10deg); } 85% { transform: rotate(10deg); } 95% { transform: rotate(-4deg); } }
.reveal .who { font-size: 2.6rem; margin: 6px 0 2px; animation: pop .5s cubic-bezier(.2,1.6,.4,1); }
@keyframes pop { from { transform: scale(.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.reveal button { background: var(--gold); color: #3a2a08; margin-top: 12px; }
.reveal.waiting { background: linear-gradient(135deg, #7a6a55, #5a4c3c); }

.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 12px; border-radius: 2px; animation: drop 1.6s ease-in forwards; }
@keyframes drop { to { transform: translateY(320px) rotate(540deg); opacity: 0; } }

.members { display: flex; flex-wrap: wrap; gap: 6px; }
.members span { background: var(--cream); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: .88rem; }

/* ---------- Wishes ---------- */
.wish { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--line); }
.wish:first-child { border-top: 0; padding-top: 0; }
.wish .w-ico { width: 40px; height: 40px; border-radius: 10px; background: #fbf1df; display: grid; place-items: center; font-size: 1.2rem; flex-shrink: 0; }
.wish .w-body { flex: 1; min-width: 0; }
.wish .w-title { font-weight: 800; word-break: break-word; }
.wish .w-domain { font-size: .82rem; color: var(--muted); word-break: break-all; }
.wish .w-notes { font-size: .9rem; margin-top: 4px; white-space: pre-wrap; word-break: break-word; }
.wish .w-actions { display: flex; gap: 6px; flex-shrink: 0; flex-direction: column; }

.back { margin-bottom: 10px; }
.empty { text-align: center; padding: 26px 10px; color: var(--muted); }
.empty .big { font-size: 2.6rem; }

.install-banner { background: #fff8e8; border: 1px solid #f0dcae; }

.toast {
  position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 700; z-index: 50;
  box-shadow: var(--shadow); max-width: calc(100% - 32px); text-align: center;
  animation: toastIn .2s ease-out;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ---------- Admin ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 6px; border-top: 1px solid var(--line); vertical-align: middle; font-size: .92rem; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-top: 0; }
.table-wrap { overflow-x: auto; margin: 0 -6px; }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; background: #d6ccbd; }
.status-dot.on { background: var(--ok); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }
.actions-cell { white-space: nowrap; text-align: right; }
details summary { cursor: pointer; font-weight: 800; color: var(--green); }
.excl { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.excl:first-child { border-top: 0; }

/* ---------- Links e importación ---------- */
input[type=checkbox] { width: 20px; height: 20px; padding: 0; accent-color: var(--red); flex-shrink: 0; margin: 0; }
.w-img { width: 56px; height: 56px; object-fit: contain; border-radius: 10px; background: #fff; border: 1px solid var(--line); flex-shrink: 0; }
.w-price { color: var(--red); font-weight: 800; }
.link-preview { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.link-preview img { width: 72px; height: 72px; object-fit: contain; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
.import-box { border: 1.5px dashed var(--gold); background: #fffaf0; border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.check-row { display: flex; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 6px; cursor: pointer; }
.imp-items { max-height: 380px; overflow-y: auto; margin: 0 -4px 12px; padding: 0 4px; }
.imp-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-weight: 400; margin: 0; cursor: pointer; }
.imp-item img { width: 44px; height: 44px; object-fit: contain; border-radius: 8px; background: #fff; border: 1px solid var(--line); flex-shrink: 0; }
.imp-item .w-ico { width: 44px; height: 44px; border-radius: 8px; background: #fbf1df; display: grid; place-items: center; flex-shrink: 0; }
.imp-text { display: flex; flex-direction: column; min-width: 0; }
.imp-title { font-size: .88rem; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.share-tip { background: var(--cream); border-radius: 10px; padding: 10px 12px; margin: 14px 0 0; }
.wish .w-title { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
