:root {
  --bg: #f4efe7;
  --bg-accent: #efe2d1;
  --surface: rgba(255, 252, 247, 0.84);
  --surface-strong: #fffaf2;
  --ink: #201a16;
  --muted: #6f6257;
  --line: rgba(32, 26, 22, 0.1);
  --brand: #0b8f72;
  --brand-strong: #087862;
  --berry: #c04d5b;
  --gold: #d98c1d;
  --shadow: 0 24px 60px rgba(78, 52, 25, 0.12);
  --radius: 28px;
  --radius-sm: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(11, 143, 114, 0.14), transparent 34%),
    radial-gradient(circle at top right, rgba(192, 77, 91, 0.18), transparent 24%),
    linear-gradient(180deg, #fbf7f1 0%, var(--bg) 58%, #ece1d2 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

button {
  font: inherit;
}

.app-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 16px 36px;
}

.hero {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 18px;
  align-items: stretch;
  margin-bottom: 18px;
}

.hero-copy,
.hero-card,
.surface {
  border: 1px solid rgba(255, 255, 255, 0.42);
  background: var(--surface);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
}

.hero-copy {
  border-radius: 32px;
  padding: 30px 28px;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.eyebrow,
.hero-subtitle,
.surface-head p,
.item-meta,
.item-date,
.calendar-day-total,
.leader-note,
.story-next p,
.hero-caption {
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 16px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
}

.hero h1 {
  font-size: clamp(34px, 6vw, 58px);
  line-height: 0.98;
  margin: 0;
}

.hero-subtitle {
  max-width: 36rem;
  font-size: 16px;
  line-height: 1.45;
  margin: 18px 0 0;
}

.hero-card {
  border-radius: 32px;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(11, 143, 114, 0.92), rgba(5, 102, 87, 0.94)),
    linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent);
  color: #f7fff8;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.hero-chip {
  display: inline-flex;
  align-self: flex-start;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 12px;
  text-transform: uppercase;
}

.hero-amount {
  font-size: clamp(36px, 5vw, 56px);
  line-height: 1;
  font-weight: 700;
}

.hero-caption {
  color: rgba(247, 255, 248, 0.72);
}

.tabbar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.tab {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.58);
  color: var(--ink);
  border-radius: 16px;
  min-height: 48px;
}

.tab.active {
  background: var(--ink);
  color: #fff8ef;
}

.panel {
  display: none;
  animation: rise 0.35s ease;
}

.panel.active {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric-card {
  border-radius: 24px;
  padding: 18px;
  background: rgba(255, 251, 245, 0.78);
  border: 1px solid rgba(32, 26, 22, 0.08);
  box-shadow: var(--shadow);
}

.metric-card p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
}

.metric-card strong {
  font-size: clamp(24px, 5vw, 28px);
  line-height: 1.1;
  word-break: break-word;
}

.content-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

.content-grid > *,
.analytics-share-layout > * {
  min-width: 0;
}

.surface {
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
}

.surface-head {
  margin-bottom: 18px;
}

.surface-head.between {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.surface-head h2 {
  margin: 0 0 6px;
  font-size: 22px;
}

.surface-head p {
  margin: 0;
}

.chart {
  min-height: 280px;
  overflow-x: auto;
  overflow-y: hidden;
}

.chart-bars {
  display: block;
}

.chart-bars-track {
  display: grid;
  grid-template-columns: repeat(6, minmax(72px, 1fr));
  gap: 14px;
  align-items: end;
  min-width: 560px;
}

.chart-bar {
  display: grid;
  gap: 10px;
  align-items: end;
}

.chart-bar-shape {
  min-height: 24px;
  border-radius: 18px 18px 8px 8px;
  background: linear-gradient(180deg, #0b8f72 0%, #075e50 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.32);
}

.chart-bar strong {
  font-size: 14px;
  line-height: 1.2;
}

.chart-bar span,
.chart-bar small {
  color: var(--muted);
}

.chart-bar small {
  font-size: 12px;
}

.breakdown-list {
  display: grid;
  gap: 12px;
}

.breakdown-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
}

.breakdown-pill {
  width: 12px;
  height: 42px;
  border-radius: 999px;
}

.list-stack {
  display: grid;
  gap: 12px;
}

.list-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 252, 247, 0.9);
}

.item-title-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.item-title {
  margin: 0;
  font-size: 17px;
}

.item-meta,
.item-date {
  margin: 6px 0 0;
  font-size: 14px;
}

.item-side {
  text-align: right;
  min-width: 92px;
}

.item-amount {
  font-size: 18px;
}

.calendar-controls {
  display: flex;
  gap: 8px;
}

.ghost-btn,
.primary-btn {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  cursor: pointer;
}

.ghost-btn {
  background: rgba(255, 255, 255, 0.74);
  color: var(--ink);
}

.primary-btn {
  background: var(--brand);
  border-color: transparent;
  color: #f4fff8;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.calendar-weekdays {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.calendar-day {
  border: 1px solid rgba(32, 26, 22, 0.08);
  background: rgba(255, 251, 245, 0.84);
  border-radius: 18px;
  min-height: 96px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.calendar-day.empty {
  background: rgba(255, 255, 255, 0.28);
}

.calendar-day.has-items {
  background:
    linear-gradient(180deg, rgba(11, 143, 114, 0.12), rgba(255, 255, 255, 0.8)),
    rgba(255, 251, 245, 0.92);
  cursor: pointer;
}

.calendar-day.selected {
  outline: 2px solid var(--berry);
}

.calendar-day-number {
  font-weight: 700;
}

.calendar-dots {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.calendar-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
}

.empty-state {
  color: var(--muted);
  padding: 10px 0;
}

.leaderboard-badge {
  border-radius: 22px;
  padding: 18px;
  background: rgba(255, 249, 241, 0.9);
  color: var(--ink);
  border: 1px solid rgba(32, 26, 22, 0.08);
  margin-bottom: 14px;
}

.leader-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
}

.leader-row.me {
  border-color: rgba(11, 143, 114, 0.24);
  background: rgba(233, 247, 242, 0.95);
  box-shadow: 0 10px 30px rgba(11, 143, 114, 0.08);
}

.leader-rank {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: rgba(11, 143, 114, 0.12);
  display: grid;
  place-items: center;
  font-weight: 700;
}

.leader-row.me .leader-rank {
  background: rgba(11, 143, 114, 0.2);
  color: var(--brand-strong);
}

.leader-you {
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 600;
  margin-top: 2px;
}

.leader-separator {
  margin: 8px 0 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.analytics-share-surface {
  overflow: hidden;
  background:
    radial-gradient(circle at top right, rgba(11, 143, 114, 0.08), transparent 34%),
    linear-gradient(180deg, rgba(255, 252, 247, 0.98), rgba(250, 245, 237, 0.98));
}

.analytics-share-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 26px;
  align-items: center;
}

.analytics-share-copy {
  display: grid;
  gap: 14px;
  align-content: center;
  padding: 28px;
  border-radius: 28px;
  border: 1px solid rgba(32, 26, 22, 0.06);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.92), rgba(248, 244, 236, 0.82)),
    radial-gradient(circle at top left, rgba(11, 143, 114, 0.08), transparent 40%);
  box-shadow: 0 18px 46px rgba(32, 26, 22, 0.08);
}

.share-copy-badge {
  display: inline-flex;
  align-self: flex-start;
  padding: 9px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(11, 143, 114, 0.14), rgba(11, 143, 114, 0.08));
  color: var(--brand-strong);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 700;
}

.analytics-share-copy h3 {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 0.94;
  max-width: 14ch;
}

.analytics-share-copy p {
  margin: 0;
  max-width: 28rem;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.55;
}

.story-card {
  aspect-ratio: 9 / 16;
  width: 100%;
  border-radius: 26px;
  overflow: hidden;
  background: rgba(15, 42, 43, 0.08);
}

.story-card-frame {
  box-shadow: var(--shadow);
}

.story-preview-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: 26px;
  box-shadow: 0 24px 52px rgba(12, 34, 34, 0.22);
}

.story-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 18px;
}

.story-actions-inline {
  justify-content: flex-start;
  margin-top: 0;
  flex-wrap: wrap;
}

.leaderboard-share {
  margin-top: 18px;
  padding: 18px;
  border-radius: 22px;
  border: 1px solid rgba(32, 26, 22, 0.08);
  background: linear-gradient(135deg, rgba(11, 143, 114, 0.08), rgba(255, 252, 247, 0.96));
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}

.leaderboard-share strong {
  display: block;
  margin-bottom: 6px;
  font-size: 18px;
}

.leaderboard-share p {
  margin: 0;
  color: var(--muted);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .hero,
  .content-grid,
  .analytics-share-layout {
    grid-template-columns: 1fr;
  }

  .analytics-share-copy {
    padding: 22px;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .leaderboard-share {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 14px 12px 28px;
  }

  .hero-copy,
  .hero-card,
  .surface {
    border-radius: 24px;
  }

  .tabbar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-card {
    min-height: 110px;
  }

  .surface {
    padding: 18px;
  }

  .calendar-day {
    min-height: 74px;
    padding: 8px;
  }

  .calendar-day-total {
    display: none;
  }

  .list-item {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .breakdown-row {
    grid-template-columns: auto 1fr;
    align-items: start;
  }

  .breakdown-row > strong {
    grid-column: 2;
    margin-top: 4px;
    font-size: 16px;
  }

  .item-side {
    min-width: 0;
    text-align: left;
  }

  .item-amount {
    display: block;
    margin-top: 4px;
  }

  .calendar-weekdays,
  .calendar-grid {
    gap: 6px;
  }

  .chart-bars-track {
    min-width: 0;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
  }

  .chart-bar strong {
    font-size: 12px;
  }

  .chart-bar span {
    font-size: 11px;
  }

  .chart-bar small {
    display: none;
  }

  .story-actions {
    flex-direction: column;
  }
}
