:root {
  /* Pamoja's own identity - a distinct palette from Astranite's other
     client-storefront products. This is an Astranite-owned product
     shared across every community that uses it, not a client
     storefront. Teal/green reads as "community, trust, money moving
     safely" without leaning on any one client's brand. */
  --pf-teal: #0f766e;
  --pf-teal-dark: #0b5a54;
  --pf-teal-light: #e6f5f3;
  --pf-ink: #1a1f1e;
  --pf-muted: #6b7674;
  --pf-border: #e1e6e5;
  /* Stronger than --pf-border on purpose - that color is fine for a
     card's outer edge sitting on --pf-bg, but was too close to white to
     read as an actual input box edge (reported as "boxes not showing"
     on the organizer app's login form, app.css). Used for every
     input/select/textarea border, both here and in app.css. */
  --pf-input-border: #b7c1bf;
  --pf-bg: #f7faf9;
  --pf-white: #ffffff;
  --pf-danger: #b3261e;
  --pf-radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--pf-bg);
  color: var(--pf-ink);
  line-height: 1.5;
}

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 20px;
}

.hidden { display: none !important; }
.muted { color: var(--pf-muted); font-weight: normal; }

/* Header */
.site-header {
  background: var(--pf-teal);
  color: var(--pf-white);
  padding: 16px 0;
}
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.brand-block { display: flex; align-items: center; gap: 10px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-size: 1.15rem; font-weight: 700; letter-spacing: 0.2px; }
.brand-mark { display: block; flex-shrink: 0; }
.brand-astranite {
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: inherit;
  opacity: 0.85;
  transition: opacity 0.15s ease;
}
.brand-astranite:hover, .brand-astranite:focus-visible { opacity: 1; }
.brand-logo { display: block; border-radius: 4px; }
.brand-tag { font-size: 0.8rem; opacity: 0.85; }

.header-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.organizer-link {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--pf-white);
  opacity: 0.85;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: opacity 0.15s ease;
}
.organizer-link:hover, .organizer-link:focus-visible { opacity: 1; }

.lang-toggle { display: flex; gap: 4px; flex-shrink: 0; }
.lang-btn {
  background: rgba(255, 255, 255, 0.12);
  color: var(--pf-white);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 30px;
}
.lang-btn.active { background: var(--pf-white); color: var(--pf-teal-dark); border-color: var(--pf-white); }

main.wrap { padding-top: 28px; padding-bottom: 60px; }

/* Loading / error states */
.state { text-align: center; padding: 60px 0; }
.state h1 { font-size: 1.3rem; }

/* Campaign head */
.campaign-head { margin-bottom: 18px; }
.purpose-badge {
  display: inline-block;
  background: var(--pf-teal-light);
  color: var(--pf-teal-dark);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 10px;
}
.campaign-head h1 { margin: 0; font-size: 1.6rem; }
#campaign-dates { margin: 4px 0 0; font-size: 0.85rem; }
.closed-banner {
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: var(--pf-radius);
  background: #f4e4e2;
  color: var(--pf-danger);
  font-size: 0.85rem;
  font-weight: 600;
}
.invite-line {
  font-size: 1.1rem;
  font-style: italic;
  color: var(--pf-teal-dark);
  margin: 6px 0 2px;
  line-height: 1.4;
}

/* Song suggestions (EVT-002 + Deezer search) */
.song-search-label { position: relative; }
.song-results {
  position: absolute;
  left: 0; right: 0; top: 100%;
  margin-top: 2px;
  background: var(--pf-white);
  border: 1.5px solid var(--pf-input-border);
  border-radius: 7px;
  max-height: 260px;
  overflow-y: auto;
  z-index: 20;
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
}
.song-result-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--pf-border);
}
.song-result-row:last-child { border-bottom: none; }
.song-result-row:hover, .song-result-row:focus { background: var(--pf-teal-light); }
.song-result-art {
  width: 36px; height: 36px;
  border-radius: 4px;
  background: var(--pf-teal-light);
  flex-shrink: 0;
  object-fit: cover;
}
.song-result-text { flex: 1; min-width: 0; }
.song-result-title { font-size: 0.88rem; font-weight: 600; color: var(--pf-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-result-artist { font-size: 0.78rem; color: var(--pf-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-preview-btn {
  flex-shrink: 0;
  width: 26px; height: 26px;
  border-radius: 50%;
  border: none;
  background: var(--pf-teal);
  color: var(--pf-white);
  font-size: 0.75rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.song-preview-btn:hover { background: var(--pf-teal-dark); }

.song-selected-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--pf-teal-light);
  border-radius: 8px;
  padding: 6px 10px;
  margin: -4px 0 10px;
  font-size: 0.85rem;
}
.song-selected-chip img { width: 28px; height: 28px; border-radius: 4px; object-fit: cover; }
.song-selected-clear { margin-left: auto; background: none; border: none; color: var(--pf-muted); cursor: pointer; font-size: 0.8rem; text-decoration: underline; }

.song-mine { margin-bottom: 14px; }
.song-mine-heading { font-size: 0.8rem; font-weight: 700; color: var(--pf-muted); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 6px; }
.song-mine-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}
.song-mine-row img { width: 34px; height: 34px; border-radius: 4px; object-fit: cover; background: var(--pf-teal-light); }
.song-mine-title { font-size: 0.88rem; font-weight: 600; }
.song-mine-artist { font-size: 0.78rem; color: var(--pf-muted); }

/* Totals card */
.totals-card {
  background: var(--pf-white);
  border: 1px solid var(--pf-border);
  border-radius: var(--pf-radius);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.totals-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; }
.totals-label { font-size: 0.8rem; color: var(--pf-muted); margin-bottom: 4px; }
.totals-amount { font-size: 1.5rem; font-weight: 700; color: var(--pf-teal-dark); }
.totals-amount--muted { color: var(--pf-muted); font-weight: 600; }
.progress-track {
  margin-top: 14px;
  height: 8px;
  border-radius: 999px;
  background: var(--pf-teal-light);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--pf-teal);
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* Generic card */
.card {
  background: var(--pf-white);
  border: 1px solid var(--pf-border);
  border-radius: var(--pf-radius);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.card h2 { margin: 0 0 10px; font-size: 1.05rem; }

/* How-to-contribute card content (built dynamically in js/render.js) */
.pay-line { margin: 4px 0; }
.pay-value { font-weight: 700; }
.pay-line--account {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}
.btn-copy {
  padding: 4px 12px;
  font-size: 0.8rem;
  min-width: 84px;
  text-align: center;
}
.verified-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--pf-teal-dark);
  background: var(--pf-teal-light);
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
}

/* Contribution list */
.contrib-list { display: flex; flex-direction: column; gap: 10px; }
.contrib-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--pf-border);
}
.contrib-row:last-child { border-bottom: none; }
.contrib-main { display: flex; flex-direction: column; }
.contrib-name { font-weight: 600; }
.contrib-meta { font-size: 0.78rem; color: var(--pf-muted); margin-top: 2px; }
.contrib-amount { font-weight: 700; white-space: nowrap; }
.provenance-tag {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  margin-right: 6px;
}
.provenance-tag--app { background: var(--pf-teal-light); color: var(--pf-teal-dark); }
.provenance-tag--manual { background: #f1efe9; color: #7a6a3f; }
.period-tag { font-size: 0.68rem; color: var(--pf-muted); }

/* Monthly dues status - "Excel tabs" per month/year */
.dues-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 12px;
  -webkit-overflow-scrolling: touch;
}
.dues-tab {
  flex: 0 0 auto;
  background: var(--pf-teal-light);
  color: var(--pf-teal-dark);
  border: none;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  min-height: 34px;
}
.dues-tab.active { background: var(--pf-teal); color: var(--pf-white); }
.dues-table-wrap { overflow-x: auto; }
.dues-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.dues-table th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--pf-muted);
  padding: 6px 8px;
  border-bottom: 1px solid var(--pf-border);
  white-space: nowrap;
}
.dues-table td { padding: 9px 8px; border-bottom: 1px solid var(--pf-border); }
.dues-status-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.dues-status-badge--paid { background: #e3f6e6; color: #1c7a34; }
.dues-status-badge--short { background: #fff2d9; color: #9a6400; }
.dues-status-badge--none { background: #f4e4e2; color: var(--pf-danger); }

/* Buttons */
.btn {
  display: inline-block;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary { background: var(--pf-teal); color: var(--pf-white); }
.btn-primary:hover { background: var(--pf-teal-dark); }
.btn-secondary { background: var(--pf-teal-light); color: var(--pf-teal-dark); }
.btn-link { background: none; color: var(--pf-muted); padding: 10px 8px; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* Flag form */
.flag-form { margin-top: 14px; display: flex; flex-direction: column; gap: 12px; }
.flag-form label { display: flex; flex-direction: column; gap: 5px; font-size: 0.85rem; font-weight: 600; }
.flag-form input, .flag-form textarea, .flag-form select {
  font: inherit;
  color: var(--pf-ink);
  padding: 9px 10px;
  border: 1.5px solid var(--pf-input-border);
  border-radius: 7px;
  background: var(--pf-white);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.flag-form input:focus, .flag-form textarea:focus, .flag-form select:focus {
  outline: none;
  border-color: var(--pf-teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}
.flag-form-actions { display: flex; align-items: center; gap: 10px; }
.form-error { color: var(--pf-danger); font-size: 0.85rem; }
.flag-success {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--pf-teal-light);
  color: var(--pf-teal-dark);
  border-radius: 8px;
  font-weight: 600;
}

/* In-app checkout waiting state (js/render.js's renderAppPay, checkoutStep
   "waiting"/"timeout") - "Open payment page" is a real link (not just a
   button) since it has to work even if window.open() was popup-blocked
   when the checkout form was submitted. */
.checkout-waiting-actions {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.footer-note { text-align: center; color: var(--pf-muted); font-size: 0.78rem; margin-top: 24px; }

/* Mobile - this is the primary way most contributors will open a share
   link (SMS/WhatsApp on a phone), so small-screen layout isn't an
   afterthought here. Breakpoints tuned around common phone widths
   (360-430px), not desktop-down thinking. */
@media (max-width: 600px) {
  .wrap { padding: 0 16px; }
  main.wrap { padding-top: 20px; padding-bottom: 40px; }

  .site-header { padding: 12px 0; }
  .brand-tag { display: none; } /* saves header space; lang toggle stays visible */

  .campaign-head h1 { font-size: 1.35rem; }

  .totals-card { padding: 16px; }
  .totals-row { flex-wrap: wrap; row-gap: 12px; }
  .totals-amount { font-size: 1.2rem; }

  .card { padding: 14px 16px; }
  .card h2 { font-size: 1rem; }

  /* Was flex-direction: column + a hardcoded margin-top: -22px on
     .contrib-amount to visually pull it back up next to the name - a
     fixed offset that assumed a fixed one-line height for .contrib-main.
     Once the meta line grew (period tag + date + an optional pledge
     line), that guess stopped matching reality and the amount overlapped
     the text underneath it. Staying in a normal flex ROW (name/meta on
     the left, amount on the right) and just top-aligning instead of
     center-aligning avoids the whole class of bug - no offset to keep
     in sync with content that can vary in height. */
  .contrib-row { align-items: flex-start; padding: 12px 0; }

  .btn { width: 100%; text-align: center; }
  /* The copy-account button sits inline next to the account number
     (.pay-line--account, flex row) - the blanket .btn full-width rule
     above would stretch it onto its own line and defeat that layout, so
     it opts back out here. */
  .pay-line--account .btn-copy { width: auto; }
  .flag-form-actions { flex-direction: column-reverse; align-items: stretch; }
  .flag-form-actions .btn-link { text-align: center; }
}

@media (max-width: 360px) {
  .totals-row { gap: 10px; }
  .totals-amount { font-size: 1.05rem; }
}
