:root {
  --coke-red: #f40009;
  --coke-red-dark: #c50007;
  --cream: #fdf8f4;
  --ink: #1e1a19;
  --muted: #7a6f6b;
  --ok: #1a7f37;
  --due: #b58500;
  --card: #ffffff;
  --radius: 18px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Inter", system-ui, sans-serif;
  background: var(--cream);
  color: var(--ink);
  min-height: 100vh;
}

/* ---------- hero ---------- */
.hero {
  position: relative;
  background: radial-gradient(120% 140% at 50% -20%, #ff3b30 0%, var(--coke-red) 45%, var(--coke-red-dark) 100%);
  color: #fff;
  text-align: center;
  padding: 48px 20px 110px;
  overflow: hidden;
}
.logo {
  font-family: "Lobster", cursive;
  font-weight: 400;
  font-size: clamp(3rem, 9vw, 5.5rem);
  margin: 0;
  letter-spacing: 0.02em;
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
  transform: rotate(-3deg);
}
.tag {
  margin: 10px 0 28px;
  font-size: clamp(0.95rem, 2.5vw, 1.15rem);
  opacity: 0.95;
  font-weight: 600;
}
.stats {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}
.stat {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(4px);
  border-radius: var(--radius);
  padding: 14px 22px;
  min-width: 150px;
}
.stat-value { font-size: 1.45rem; font-weight: 800; }
.stat-value small { font-size: 0.85rem; font-weight: 600; opacity: 0.9; }
.stat-label { font-size: 0.8rem; opacity: 0.85; margin-top: 4px; }
.wave {
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  width: 100%;
  height: 70px;
  display: block;
}

/* ---------- main ---------- */
main {
  max-width: 1000px;
  margin: -40px auto 0;
  padding: 0 16px 40px;
  position: relative;
  z-index: 2;
}
.alert {
  background: #fff2f1;
  border: 1px solid #ffc9c5;
  color: #a11;
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-weight: 600;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 16px;
}

/* ---------- member card ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 6px 24px rgba(60, 20, 15, 0.08);
  border-top: 4px solid transparent;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card.overdue { border-top-color: var(--coke-red); }
.card.due { border-top-color: var(--due); }
.card.ok { border-top-color: var(--ok); }
.card.new { border-top-color: #b9b0ac; }

.card-head { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 46px; height: 46px;
  border-radius: 50%;
  background: var(--coke-red);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: "Lobster", cursive;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.member-name { font-weight: 800; font-size: 1.05rem; }
.streak { font-size: 0.85rem; color: var(--muted); margin-top: 2px; }
.streak b { color: var(--ink); }

.badge {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 5px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge.ok { background: #e3f4e8; color: var(--ok); }
.badge.due { background: #fdf3d7; color: #8a6400; }
.badge.overdue { background: #ffe3e1; color: var(--coke-red-dark); }
.badge.new { background: #efeae7; color: var(--muted); }

.card-meta { font-size: 0.83rem; color: var(--muted); line-height: 1.5; }
.card-meta .warn { color: var(--coke-red-dark); font-weight: 700; }

.btn {
  font: inherit;
  font-weight: 800;
  border: none;
  border-radius: 999px;
  padding: 11px 18px;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-pay {
  background: var(--coke-red);
  color: #fff;
  box-shadow: 0 6px 16px rgba(244, 0, 9, 0.3);
  margin-top: auto;
}
.btn-pay:hover { background: var(--coke-red-dark); }
.btn-outline {
  background: transparent;
  color: var(--coke-red);
  border: 2px solid var(--coke-red);
}
.btn-outline:hover { background: #fff; }

/* ---------- outgoing transactions ---------- */
.section-title {
  font-size: 1.05rem;
  font-weight: 800;
  margin: 30px 0 12px;
}
.tx-list {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(60, 20, 15, 0.08);
  overflow: hidden;
}
.tx {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #f3ece8;
  font-size: 0.88rem;
}
.tx:last-child { border-bottom: none; }
.tx-date { color: var(--muted); font-size: 0.78rem; white-space: nowrap; }
.tx-desc { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-amount { font-weight: 800; color: var(--coke-red-dark); white-space: nowrap; }
.tx-empty { padding: 18px 16px; color: var(--muted); font-size: 0.85rem; text-align: center; }

.footer-actions { text-align: center; margin-top: 26px; }
.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 18px 0 30px;
}

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(30, 10, 8, 0.55);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 50;
}
.modal {
  position: relative;
  background: #fff;
  border-radius: 22px;
  padding: 26px;
  width: min(420px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  text-align: center;
}
.modal-close {
  position: absolute;
  top: 12px; right: 12px;
  border: none;
  background: #f2ecea;
  border-radius: 50%;
  width: 34px; height: 34px;
  font-size: 1rem;
  cursor: pointer;
}
.modal h2 {
  font-family: "Lobster", cursive;
  font-weight: 400;
  color: var(--coke-red);
  margin: 0 0 4px;
  font-size: 1.7rem;
}
.modal .amount { font-size: 1.5rem; font-weight: 800; margin: 6px 0; }
.modal .period-label { color: var(--muted); font-size: 0.9rem; margin-bottom: 12px; }
.period-select {
  font: inherit;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1.5px solid #e3d9d5;
  margin-bottom: 14px;
  max-width: 100%;
}
.qr-wrap {
  background: #fff;
  border: 2px solid #f0e7e3;
  border-radius: 16px;
  padding: 10px;
  display: inline-block;
}
.qr-wrap img { width: 230px; height: 230px; display: block; }
.poll-note { color: var(--muted); font-size: 0.82rem; margin: 12px 0 4px; }
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid #e3d9d5;
  border-top-color: var(--coke-red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: -2px;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.bank-links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px;
  margin-top: 14px;
}
.bank-links a {
  text-decoration: none;
  color: var(--ink);
  font-size: 0.66rem;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  border-radius: 12px;
  border: 1px solid #f0e7e3;
}
.bank-links a:hover { background: var(--cream); }
.bank-links img { width: 34px; height: 34px; border-radius: 9px; object-fit: contain; }

.success {
  padding: 30px 8px;
}
.success .check {
  width: 84px; height: 84px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--ok);
  color: #fff;
  font-size: 2.6rem;
  display: grid;
  place-items: center;
  animation: pop 0.35s ease;
}
@keyframes pop {
  0% { transform: scale(0.4); opacity: 0; }
  70% { transform: scale(1.12); }
  100% { transform: scale(1); opacity: 1; }
}
.success h3 { margin: 0 0 6px; font-size: 1.3rem; }
.success p { color: var(--muted); margin: 0; }

.modal-error { color: var(--coke-red-dark); font-weight: 700; padding: 20px 0; }
