/* FundNest — Green, Blue, Orange, Yellow */
:root {
  --green: #1a7a4c;
  --green-dark: #0f5a36;
  --green-soft: #e8f6ee;
  --blue: #1d6fb8;
  --blue-dark: #14548c;
  --blue-soft: #e8f2fb;
  --orange: #e67a1a;
  --orange-dark: #c25f0a;
  --orange-soft: #fff2e6;
  --yellow: #f0c419;
  --yellow-dark: #d4a80a;
  --yellow-soft: #fff8d9;
  --ink: #14231b;
  --muted: #5c6b62;
  --line: rgba(20, 35, 27, 0.12);
  --surface: rgba(255, 255, 255, 0.88);
  --shadow: 0 18px 50px rgba(15, 50, 35, 0.12);
  --radius: 18px;
  --font-display: "Outfit", sans-serif;
  --font-body: "Source Sans 3", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background: #f3faf6;
  position: relative;
  line-height: 1.5;
}
h1, h2, h3, .brand-text, .brand-mark {
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}
a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-dark); }
img { max-width: 100%; display: block; }
code {
  font-family: ui-monospace, Consolas, monospace;
  background: var(--yellow-soft);
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
  font-size: 0.92em;
  word-break: break-all;
}

.bg-atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 60% at 10% -10%, rgba(240, 196, 25, 0.35), transparent 55%),
    radial-gradient(ellipse 70% 50% at 100% 0%, rgba(29, 111, 184, 0.28), transparent 50%),
    radial-gradient(ellipse 60% 50% at 80% 100%, rgba(230, 122, 26, 0.22), transparent 45%),
    linear-gradient(160deg, #eef8f2 0%, #eaf3fb 45%, #fff6e8 100%);
}

.main {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.25rem 0 3rem;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  /* anchor mobile dropdown nav */
  isolation: isolate;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--ink);
  font-weight: 700;
}
.brand-link {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
}
.brand-center {
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.brand-logo {
  height: 2.35rem;
  width: auto;
  max-width: 130px;
  object-fit: contain;
  display: block;
}
.brand-logo-lg {
  height: 4.25rem;
  max-width: 200px;
  margin: 0 auto 0.75rem;
}
.admin-brand .brand-logo {
  height: 2.5rem;
  max-width: 100px;
  border-radius: 8px;
}
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--green), var(--blue));
  color: #fff;
  font-size: 0.85rem;
  font-weight: 800;
}
.brand-mark.lg {
  width: 3.5rem;
  height: 3.5rem;
  font-size: 1.15rem;
  border-radius: 16px;
  margin: 0 auto 0.75rem;
}
.brand-text { font-size: 1.2rem; }
.topnav {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.topnav a { color: var(--ink); font-weight: 600; }
.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0.35rem;
}
.nav-toggle span {
  width: 22px;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 0;
  border-radius: 12px;
  padding: 0.7rem 1.15rem;
  font-family: var(--font-display);
  font-weight: 650;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-block { width: 100%; }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.82rem; border-radius: 9px; }
.btn-primary { background: linear-gradient(135deg, var(--green), var(--blue)); color: #fff; }
.btn-primary:hover { color: #fff; box-shadow: 0 10px 24px rgba(26,122,76,.28); }
.btn-green { background: var(--green); color: #fff; }
.btn-orange { background: var(--orange); color: #fff; }
.btn-outline {
  background: transparent;
  color: var(--ink);
  border: 1.5px solid var(--line);
}
.btn-outline:hover { border-color: var(--blue); color: var(--blue); }

/* Alerts */
.alert {
  position: relative;
  padding: 0.9rem 2.2rem 0.9rem 1rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  font-weight: 550;
}
.alert-success { background: var(--green-soft); color: var(--green-dark); }
.alert-error { background: #fde8e8; color: #9b1c1c; }
.alert-info { background: var(--blue-soft); color: var(--blue-dark); }
.alert-close {
  position: absolute;
  right: 0.7rem;
  top: 0.55rem;
  border: 0;
  background: transparent;
  font-size: 1.2rem;
  cursor: pointer;
  color: inherit;
}

/* Auth */
.auth-page .main { display: grid; place-items: center; min-height: calc(100vh - 5rem); }
.auth-shell { width: min(440px, 100%); }
.auth-shell.wide-shell { width: min(760px, 100%); }
.auth-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  padding: 1.75rem 1.5rem;
  box-shadow: var(--shadow);
  animation: rise 0.45s ease;
}
.auth-panel.wide { width: min(680px, 100%); }
.auth-brand { text-align: center; margin-bottom: 1.25rem; }
.auth-brand h1 { margin: 0.2rem 0; font-size: clamp(1.8rem, 4vw, 2.3rem); }
.auth-brand p { margin: 0; color: var(--muted); }
.auth-form { display: grid; gap: 0.9rem; }
.auth-form label { display: grid; gap: 0.35rem; font-weight: 600; font-size: 0.92rem; }
.auth-form label span em { font-weight: 400; color: var(--muted); font-style: normal; }
.auth-form input, .auth-form select, .auth-form textarea,
.search-form input, .generate-form input, .form-grid input, .form-grid select,
.stage-edit-card input, .stage-edit-card textarea, .stage-edit-card select {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  font: inherit;
  background: #fff;
  color: var(--ink);
}
.auth-form input:focus, .auth-form select:focus, .auth-form textarea:focus,
.search-form input:focus, .generate-form input:focus,
.stage-edit-card input:focus, .stage-edit-card textarea:focus, .stage-edit-card select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(29,111,184,0.15);
}
.checkbox {
  display: flex !important;
  align-items: flex-start;
  gap: 0.6rem;
  grid-template-columns: none !important;
  font-weight: 500 !important;
}
.checkbox input { width: auto; margin-top: 0.2rem; }
.form-row.between { display: flex; justify-content: flex-end; }
.link { font-weight: 650; }
.auth-switch { text-align: center; margin: 1.1rem 0 0; color: var(--muted); }
.waiting-panel { text-align: center; }
.waiting-spinner {
  width: 52px;
  height: 52px;
  margin: 0 auto 1rem;
  border: 4px solid var(--blue-soft);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
.muted { color: var(--muted); }
.terms-content h2 { font-size: 1.05rem; margin: 1.2rem 0 0.35rem; color: var(--green-dark); }
.terms-content p { margin: 0; color: var(--muted); }

/* Dashboard */
.page-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  animation: rise 0.4s ease;
}
.page-hero.compact { align-items: center; }
.page-hero h1 { margin: 0.15rem 0 0.35rem; font-size: clamp(1.7rem, 4vw, 2.4rem); }
.page-hero p { margin: 0; color: var(--muted); max-width: 36rem; }
.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--orange);
}
.invite-chip {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.7rem 0.9rem;
  box-shadow: var(--shadow);
}
.invite-chip span { color: var(--muted); font-size: 0.85rem; }
.invite-chip strong { font-family: var(--font-display); font-size: 1.15rem; color: var(--blue-dark); }

.stage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.15rem;
}
.stage-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 10px 28px rgba(15,50,35,0.06);
  display: flex;
  flex-direction: column;
  transition: transform .2s ease, box-shadow .2s ease;
  animation: rise 0.5s ease both;
}
.stage-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.stage-card.status-active { border-color: rgba(26,122,76,0.35); box-shadow: 0 12px 30px rgba(26,122,76,0.12); }
.stage-card.status-locked { opacity: 0.88; }
.stage-card.status-closed { background: #fafcfb; }
.stage-media {
  position: relative;
  aspect-ratio: 16/10;
  background: linear-gradient(135deg, var(--green-soft), var(--blue-soft), var(--yellow-soft));
  overflow: hidden;
}
.stage-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.stage-number {
  position: absolute;
  left: 0.75rem;
  top: 0.75rem;
  background: rgba(20,35,27,0.78);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
}
.stage-badge {
  position: absolute;
  right: 0.75rem;
  top: 0.75rem;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stage-badge.status-active { background: var(--green); color: #fff; }
.stage-badge.status-locked { background: var(--blue-soft); color: var(--blue-dark); }
.stage-badge.status-closed,
.stage-badge.status-completed { background: var(--orange-soft); color: var(--orange-dark); }
.stage-body { padding: 1rem 1.05rem 1.15rem; display: grid; gap: 0.7rem; flex: 1; }
.stage-body h2 { margin: 0; font-size: 1.3rem; }
.stage-amount { margin: 0; color: var(--muted); }
.stage-amount strong { color: var(--green-dark); font-size: 1.05rem; }
.stage-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  background: var(--green-soft);
  border-radius: 12px;
  padding: 0.7rem;
}
.stage-meta span { display: block; font-size: 0.72rem; color: var(--muted); }
.stage-meta strong { font-family: var(--font-display); font-size: 1.05rem; }
.text-orange { color: var(--orange-dark); }
.text-green { color: var(--green); }
.progress-bar {
  height: 8px;
  background: #e6efe9;
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--yellow));
  border-radius: inherit;
  transition: width .4s ease;
}
.code-form { display: grid; gap: 0.6rem; }
.wa-link {
  display: inline-flex;
  justify-content: center;
  font-weight: 700;
  color: var(--green);
}
.hint { margin: 0; font-size: 0.92rem; color: var(--muted); }
.share-hint { margin: 0; font-size: 0.8rem; color: var(--muted); }

/* History / Profile */
.history-list { display: grid; gap: 0.85rem; }
.history-item {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 1rem;
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.85rem;
}
.history-item img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 12px;
  background: var(--yellow-soft);
}
.history-item h2 { margin: 0 0 0.25rem; font-size: 1.1rem; }
.history-item p { margin: 0; }
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  background: #fff;
  border-radius: var(--radius);
  border: 1px dashed var(--line);
}
.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}
.info-block {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem;
}
.info-block h2 { margin: 0 0 0.8rem; }
.info-block dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.55rem 1rem;
  margin: 0;
}
.info-block dt { color: var(--muted); }
.info-block dd { margin: 0; font-weight: 650; }
.share-box {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-top: 0.8rem;
}

/* Share link banner */
.share-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.85rem 1rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 8px 24px rgba(15,50,35,0.06);
}
.share-link {
  display: block;
  word-break: break-all;
  font-weight: 600;
  font-size: 0.92rem;
  margin-top: 0.25rem;
}
.wa-btn { margin-bottom: 0.5rem; }

.page-hero.compact { align-items: center; }
.page-hero.stack-mobile { flex-wrap: wrap; }
.stack-mobile .btn { flex-shrink: 0; }
.btn-back { white-space: nowrap; }

/* Guidelines & levels */
.guidelines-content { display: grid; gap: 1rem; }
.guidelines-intro h2 { margin-top: 0; }
.sauce-journey {
  font-weight: 600;
  color: var(--green-dark);
  line-height: 1.6;
  word-break: break-word;
}
.level-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.85rem;
  margin-top: 0.75rem;
}
.level-card {
  border-radius: 14px;
  padding: 1rem;
  border: 1px solid var(--line);
}
.level-card h3 { margin: 0.35rem 0; font-size: 1.05rem; }
.level-card p { margin: 0; color: var(--muted); font-size: 0.92rem; }
.level-num {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
}
.level-prep { background: var(--yellow-soft); }
.level-prep .level-num { background: var(--yellow); color: var(--ink); }
.level-cook { background: var(--orange-soft); }
.level-cook .level-num { background: var(--orange); color: #fff; }
.level-serve { background: var(--green-soft); }
.level-serve .level-num { background: var(--green); color: #fff; }
.terms-extra { margin-top: 0.5rem; }
.terms-content .info-block { margin-bottom: 0; }

/* Stage hero */
.stage-hero-text { min-width: 0; flex: 1; }
.stage-hero-text h1 { word-break: break-word; }

/* Profile photo */
.profile-photo-block { grid-column: 1 / -1; }
.photo-upload-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  align-items: flex-start;
}
.profile-photo-lg {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--green-soft);
  background: var(--blue-soft);
}
.photo-form { display: grid; gap: 0.65rem; flex: 1; min-width: 200px; }
.file-label { display: grid; gap: 0.35rem; font-weight: 600; font-size: 0.92rem; }
.file-label input[type="file"] { font-size: 0.88rem; }

/* Stage detail / leaderboard */
.stage-hero-row {
  display: flex;
  gap: 1rem;
  align-items: center;
}
.stage-hero-img {
  width: 88px;
  height: 88px;
  border-radius: 16px;
  object-fit: cover;
}
.leaderboard-section {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem;
}
.leaderboard-section .panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}
.leaderboard-section h2 { margin: 0; font-size: 1.15rem; }
.section-note { margin: 0 0 1rem; font-size: 0.9rem; }
.leaderboard {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
}
.leaderboard-item {
  display: grid;
  grid-template-columns: 36px 48px minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem;
  background: var(--green-soft);
  border-radius: 12px;
}
.rank {
  font-family: var(--font-display);
  font-weight: 800;
  color: var(--orange-dark);
  text-align: center;
}
.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--blue-soft);
  flex-shrink: 0;
}
.member-info { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; min-width: 0; }
.member-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.you-tag {
  background: var(--blue);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  text-transform: uppercase;
  flex-shrink: 0;
}
.invite-stat { text-align: right; flex-shrink: 0; min-width: 3.5rem; }
.invite-stat span { display: block; font-size: 0.72rem; color: var(--muted); }
.invite-stat strong { font-family: var(--font-display); font-size: 1.2rem; color: var(--green-dark); }
.progress-bar.lg { height: 12px; margin-top: 0.5rem; }
.empty-state.compact { padding: 1.5rem; }

/* About page */
.about-content {
  display: grid;
  gap: 1rem;
}
.about-list {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--muted);
}
.about-list li { margin-bottom: 0.5rem; }
.about-list strong { color: var(--ink); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

.status-pill {
  display: inline-block;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}
.status-pending { background: var(--yellow-soft); color: var(--yellow-dark); }
.status-approved { background: var(--green-soft); color: var(--green-dark); }
.status-rejected { background: #fde8e8; color: #9b1c1c; }
.status-completed { background: var(--blue-soft); color: var(--blue-dark); }
.status-none { background: #f0f0f0; color: #666; }

.site-footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 760px) {
  .main { width: calc(100% - 1.25rem); padding: 1rem 0 2.5rem; }
  .nav-toggle { display: flex; }
  .topbar { padding: 0.75rem 1rem; position: relative; }
  .topnav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    background: #fff;
    padding: 0.75rem 1rem 1rem;
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
    z-index: 60;
  }
  .topnav.open { display: flex; }
  .topnav a, .topnav .btn { width: 100%; text-align: center; }
  .page-hero {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }
  .page-hero.compact.stack-mobile {
    align-items: stretch;
  }
  .page-hero.stack-mobile .btn-back {
    width: 100%;
    text-align: center;
  }
  .invite-chip {
    width: 100%;
    justify-content: space-between;
  }
  .share-banner {
    flex-direction: column;
    align-items: stretch;
  }
  .share-banner .btn { width: 100%; }
  .stage-grid { grid-template-columns: 1fr; }
  .profile-grid { grid-template-columns: 1fr; }
  .photo-upload-wrap { flex-direction: column; align-items: center; text-align: center; }
  .history-item {
    grid-template-columns: 56px 1fr;
  }
  .history-item .stage-badge { grid-column: 2; justify-self: start; }
  .stage-meta { grid-template-columns: 1fr 1fr 1fr; font-size: 0.85rem; }
  .auth-panel.wide { padding: 1.25rem 1rem; }
  .level-cards { grid-template-columns: 1fr; }
  .leaderboard-section { padding: 1rem; }
  .leaderboard-section .panel-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }
  .leaderboard-item {
    grid-template-columns: 32px 44px minmax(0, 1fr);
    grid-template-areas:
      "rank avatar info"
      "rank avatar stat";
    gap: 0.35rem 0.65rem;
    padding: 0.85rem 0.75rem;
  }
  .leaderboard-item .rank { grid-area: rank; align-self: start; padding-top: 0.35rem; }
  .leaderboard-item .avatar { grid-area: avatar; width: 44px; height: 44px; }
  .leaderboard-item .member-info { grid-area: info; min-width: 0; }
  .leaderboard-item .member-name { white-space: normal; word-break: break-word; }
  .leaderboard-item .invite-stat {
    grid-area: stat;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding-left: 0;
  }
  .leaderboard-item .invite-stat span { display: inline; font-size: 0.8rem; }
  .leaderboard-item .invite-stat strong { font-size: 1rem; }
  .stage-hero-row {
    flex-direction: row;
    align-items: flex-start;
    width: 100%;
  }
  .stage-hero-img { width: 72px; height: 72px; flex-shrink: 0; }
}

@media (max-width: 400px) {
  .brand-text { font-size: 1rem; }
  .brand-logo { max-width: 100px; }
  .stage-meta { grid-template-columns: 1fr 1fr; }
  .stage-meta div:last-child { grid-column: 1 / -1; }
}
