@font-face {
  font-family: Faustina;
  src: url('/fonts/faustina-normal.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: Faustina;
  src: url('/fonts/faustina-italic.woff2') format('woff2');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: Asap;
  src: url('/fonts/asap-normal.woff2') format('woff2');
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --primary: #18408D;
  --primary-deep: #0F2C66;
  --gold: #D9A93A;
  --gold-soft: rgba(217, 169, 58, 0.16);
  --coral: #E8735B;
  --coral-soft: rgba(232, 115, 91, 0.12);
  --green: #1E8A5A;
  --green-soft: rgba(30, 138, 90, 0.12);
  --bg: #F7F5F2;
  --surface: #FFFFFF;
  --text: #262C31;
  --muted: rgba(38, 44, 49, 0.68);
  --faint: rgba(38, 44, 49, 0.45);
  --line: rgba(38, 44, 49, 0.1);
  --primary-soft: rgba(24, 64, 141, 0.07);
  --primary-line: rgba(24, 64, 141, 0.22);
  --serif: Faustina, Iowan Old Style, Palatino, Georgia, serif;
  --sans: Asap, ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif;
  --radius: 1.25rem;
  --shadow: 0 0.75rem 2.5rem rgba(24, 64, 141, 0.12);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.app { max-width: 34rem; margin: 0 auto; padding: 0 1rem 9rem; }

/* ---------- hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  margin: 0 -1rem;
  padding: 2.25rem 1.25rem 2rem;
  background: radial-gradient(120% 90% at 100% 0%, #2B5BC0 0%, var(--primary) 45%, var(--primary-deep) 100%);
  color: #fff;
  border-radius: 0 0 2rem 2rem;
}
.hero::after {
  content: '';
  position: absolute;
  inset: auto -20% -60% -20%;
  height: 120%;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  transform: rotate(-8deg);
  pointer-events: none;
}
.hero-cap { font-size: 2.5rem; line-height: 1; }
.hero h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(1.9rem, 7vw, 2.4rem);
  line-height: 1.1;
  margin: 0.75rem 0 0.35rem;
}
.hero h1 em { color: var(--gold); font-style: italic; }
.hero p { margin: 0; color: rgba(255, 255, 255, 0.82); }
.hero .back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
  padding: 0.35rem 0.8rem 0.35rem 0.6rem;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 0.875rem;
}

.progress-wrap { margin-top: 1.25rem; }
.progress-label { display: flex; justify-content: space-between; font-size: 0.875rem; color: rgba(255, 255, 255, 0.85); margin-bottom: 0.4rem; }
.progress { height: 0.6rem; border-radius: 999px; background: rgba(255, 255, 255, 0.18); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--gold), #F3D27A); transition: width 0.6s ease; }

/* ---------- sections & cards ---------- */
.section { margin-top: 1.75rem; }
.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0 0 0.75rem;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.45rem;
}
.section-title small { font-family: var(--sans); font-size: 0.85rem; color: var(--muted); }
.hint { margin: -0.4rem 0 0.9rem; color: var(--muted); font-size: 0.925rem; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: 0 1px 0 var(--line); padding: 1rem; }

/* ---------- people grid ---------- */
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: 0.6rem; }
.person {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  min-height: 4.5rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--surface);
  text-align: left;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.person:active { transform: scale(0.98); }
.person:hover { border-color: var(--primary-line); }
.person-name { font-family: var(--serif); font-size: 1.2rem; line-height: 1.2; }
.person.host { background: var(--primary-soft); border-color: var(--primary-line); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}
.chip.pendiente { background: var(--line); color: var(--muted); }
.chip.avisado { background: var(--gold-soft); color: #8A6512; }
.chip.pagado { background: var(--green-soft); color: var(--green); }
.chip.host { background: var(--primary); color: #fff; }

/* ---------- items ---------- */
.items { display: grid; gap: 0.6rem; }
.item { background: var(--surface); border: 1px solid var(--line); border-radius: 1rem; padding: 0.85rem 0.9rem; transition: border-color 0.15s ease, background 0.15s ease; }
.item.on { border-color: var(--primary-line); background: linear-gradient(0deg, var(--primary-soft), var(--primary-soft)), var(--surface); }
.item-head { display: flex; align-items: center; gap: 0.75rem; }
.item-emoji { font-size: 1.6rem; width: 2.2rem; text-align: center; flex: none; }
.item-info { flex: 1; min-width: 0; }
.item-name { font-weight: 600; }
.item-meta { font-size: 0.85rem; color: var(--muted); }
.item-price { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.item-price.free { color: var(--green); }
.item-others { margin-top: 0.45rem; font-size: 0.82rem; color: var(--muted); }
.item-others b { color: var(--text); font-weight: 600; }
.steps { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.7rem; padding-left: 2.95rem; }
.step {
  min-width: 2.9rem;
  min-height: 2.6rem;
  padding: 0 0.8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  font-weight: 600;
}
.step[aria-pressed='true'] { background: var(--primary); border-color: var(--primary); color: #fff; }
.step:disabled { opacity: 0.45; cursor: not-allowed; }
.courtesy { display: flex; gap: 0.75rem; align-items: center; padding: 0.85rem 1rem; border-radius: 1rem; background: var(--gold-soft); font-size: 0.925rem; }

/* ---------- bill (sticky footer) ---------- */
.bill {
  position: fixed;
  left: 50%;
  bottom: max(0.75rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(32rem, calc(100% - 1.5rem));
  padding: 0.9rem 1rem;
  border-radius: 1.25rem;
  background: var(--surface);
  box-shadow: var(--shadow), 0 0 0 1px var(--line);
  z-index: 10;
}
.bill-rows { display: grid; gap: 0.15rem; font-size: 0.9rem; color: var(--muted); }
.bill-row { display: flex; justify-content: space-between; gap: 1rem; font-variant-numeric: tabular-nums; }
.bill-row.gift { color: var(--green); }
.bill-total { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 0.5rem; padding-top: 0.5rem; border-top: 1px dashed var(--line); }
.bill-total .label { font-size: 0.85rem; color: var(--muted); }
.bill-total .amount { font-family: var(--serif); font-size: 1.9rem; line-height: 1; font-variant-numeric: tabular-nums; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 3rem;
  padding: 0 1.25rem;
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.gold { background: var(--gold); color: #2A1E00; }
.btn.ghost { background: var(--primary-soft); color: var(--primary); }
.btn.green { background: var(--green); }
.btn.small { min-height: 2.5rem; padding: 0 0.95rem; font-size: 0.9rem; }
.btn.block { width: 100%; }
.link { border: 0; background: none; padding: 0; color: var(--primary); text-decoration: underline; text-underline-offset: 3px; font-size: 0.925rem; }

/* ---------- pay ---------- */
.pay { display: grid; gap: 0.9rem; padding: 1.25rem; border-radius: var(--radius); background: var(--surface); box-shadow: 0 1px 0 var(--line); }
.yape { display: flex; align-items: center; gap: 0.9rem; padding: 0.9rem; border-radius: 1rem; background: #F3EEFB; }
.yape-logo { display: grid; place-items: center; width: 3rem; height: 3rem; border-radius: 0.9rem; background: #742384; color: #fff; font-weight: 700; font-size: 0.8rem; flex: none; }
.yape-number { font-family: var(--serif); font-size: 1.5rem; line-height: 1.1; letter-spacing: 0.02em; }
.yape-name { font-size: 0.85rem; color: var(--muted); }
.pay-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.done { text-align: center; padding: 1.5rem 1.25rem; border-radius: var(--radius); background: var(--green-soft); }
.done .big { font-size: 2.5rem; }
.done h3 { font-family: var(--serif); font-weight: 400; font-size: 1.5rem; margin: 0.4rem 0 0.25rem; }
.done p { margin: 0; color: var(--muted); }
.waiting { background: var(--gold-soft); }

/* ---------- admin ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; margin-top: 1rem; }
.stat { padding: 0.7rem 0.6rem; border-radius: 1rem; background: rgba(255, 255, 255, 0.1); text-align: center; }
.stat b { display: block; font-family: var(--serif); font-weight: 400; font-size: 1.5rem; line-height: 1.1; }
.stat span { font-size: 0.78rem; color: rgba(255, 255, 255, 0.8); }
.alerts { display: grid; gap: 0.5rem; }
.alert { display: flex; gap: 0.7rem; align-items: flex-start; padding: 0.75rem 0.9rem; border-radius: 1rem; background: var(--coral-soft); font-size: 0.925rem; }
.alert.ok { background: var(--green-soft); }
.rows { display: grid; gap: 0.6rem; }
.row { padding: 0.9rem; border-radius: 1rem; background: var(--surface); border: 1px solid var(--line); }
.row.avisado { border-color: rgba(217, 169, 58, 0.55); box-shadow: 0 0 0 3px var(--gold-soft); }
.row-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.row-name { font-family: var(--serif); font-size: 1.25rem; }
.row-amount { font-weight: 600; font-variant-numeric: tabular-nums; }
.row-items { margin: 0.35rem 0 0.7rem; font-size: 0.85rem; color: var(--muted); }
.row-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.mine { display: grid; gap: 0.25rem; font-size: 0.925rem; }
.mine .bill-row { color: var(--muted); }
.mine .bill-row b { color: var(--text); }

/* ---------- pin dialog ---------- */
dialog { width: min(22rem, calc(100% - 2rem)); border: 0; border-radius: 1.5rem; padding: 1.5rem; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(15, 44, 102, 0.45); backdrop-filter: blur(3px); }
dialog h3 { margin: 0 0 0.25rem; font-family: var(--serif); font-weight: 400; font-size: 1.5rem; }
dialog p { margin: 0 0 1rem; color: var(--muted); font-size: 0.925rem; }
.pin-input { width: 100%; padding: 0.8rem 1rem; border: 1px solid var(--line); border-radius: 1rem; font-size: 1.5rem; letter-spacing: 0.4em; text-align: center; }
.dialog-actions { display: flex; gap: 0.5rem; margin-top: 1rem; }
.dialog-actions .btn { flex: 1; }
.error { color: #B3412A; font-size: 0.875rem; min-height: 1.3rem; margin-top: 0.4rem; }

/* ---------- misc ---------- */
.toast {
  position: fixed;
  left: 50%;
  top: max(1rem, env(safe-area-inset-top));
  transform: translate(-50%, -150%);
  padding: 0.6rem 1rem;
  border-radius: 999px;
  background: var(--text);
  color: #fff;
  font-size: 0.9rem;
  transition: transform 0.25s ease;
  z-index: 30;
  max-width: calc(100% - 2rem);
}
.toast.show { transform: translate(-50%, 0); }
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 25; }
.footer-note { margin: 2rem 0 0; text-align: center; color: var(--faint); font-size: 0.85rem; }
.center { text-align: center; }
.mt { margin-top: 1rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
