:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --line: #e7eee9;
  --text: #1f2a24;
  --muted: #7f8c85;
  --green: #5eb48f;
  --green-soft: #dff2e9;
  --green-deep: #3d896a;
  --danger: #cf5d58;
  --shadow: 0 12px 32px rgba(31, 42, 36, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(180deg, #eff4f0 0%, #f8f8f6 100%);
  color: var(--text);
}
button,input,select,textarea { font: inherit; }
button { border: 0; cursor: pointer; }

.app {
  min-height: 100vh;
  max-width: 460px;
  margin: 0 auto;
  background: rgba(251, 252, 250, 0.98);
  box-shadow: 0 24px 54px rgba(31, 42, 36, 0.1);
  position: relative;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 64px;
  padding: 16px 20px 12px;
  background: rgba(251, 252, 250, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: flex-start;
}
.topbar-title { font-size: 18px; font-weight: 800; }
.content { padding: 18px 18px 100px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}
.hero {
  padding: 20px;
  background: linear-gradient(135deg, #eaf8f1, #f8fbf8);
  border-color: #deefe5;
}
.session-card { margin-bottom: 16px; }
.hero-kicker { color: #72877b; font-size: 12px; margin-bottom: 8px; }
.hero-title { font-size: 30px; font-weight: 800; color: var(--green); letter-spacing: -0.8px; }
.hero-header {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.hero-title-small { font-size: 22px; color: #26352d; }
.hero-copy { margin-top: 6px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.hero-grid,
.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}
.summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 0; }
.mini-stat,
.summary-card { padding: 12px; border-radius: 16px; background: rgba(255,255,255,0.78); }
.value { font-size: 17px; font-weight: 800; }
.label { margin-top: 4px; color: var(--muted); font-size: 11px; }
.action-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}
.action-row.single-stack { grid-template-columns: 1fr; margin: 0; }
.action-row.compact { gap: 10px; }
.primary,
.ghost { height: 44px; border-radius: 999px; padding: 0 18px; font-weight: 700; }
.primary { background: var(--green); color: #fff; }
.ghost { background: #edf4ef; color: #446153; }
.ghost.small { height: 34px; padding: 0 14px; border-radius: 14px; font-size: 13px; }
.link-button { padding: 0; background: transparent; color: var(--green-deep); font-size: 12px; font-weight: 700; }
.section-title {
  margin: 20px 2px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 800;
}
.muted { color: var(--muted); font-size: 12px; font-weight: 500; }
.member-form { display: flex; gap: 10px; margin-bottom: 12px; }
.field-input,.select-input,.ratio-input,.amount-input,.field-textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 16px;
  padding: 12px 14px;
}
.field-textarea { min-height: 92px; resize: vertical; }
.member-list,.bill-list,.person-list,.transfer-list,.ratio-list { display: grid; gap: 10px; }
.member-item,.bill-item,.transfer-item,.person-item,.field-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
}
.member-name,.bill-title { font-size: 15px; font-weight: 700; }
.member-meta,.bill-meta,.helper,.feedback,.empty-card,.empty-copy { color: var(--muted); font-size: 12px; }
.inline-helper { margin: -2px 2px 10px; }
.member-actions { display: flex; gap: 8px; }
.participant-card,.ratio-card,.amount-card { padding: 16px; }
.share-card { padding: 16px; margin-top: 16px; }
.share-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.share-link {
  margin-top: 12px;
  padding: 12px;
  border-radius: 16px;
  background: #f3f7f4;
  border: 1px dashed #cfe0d6;
}
.share-link-text { word-break: break-all; color: #446153; font-size: 12px; }
.segment { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 16px; }
.segment button { height: 40px; border-radius: 14px; background: #edf4ef; color: #597267; font-weight: 700; }
.segment button.active { background: var(--green-soft); color: var(--green-deep); }
.participant-list { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f2f7f4;
  color: #496356;
  border: 1px solid transparent;
}
.chip.selectable input { display: none; }
.chip.selectable.active { background: var(--green-soft); color: var(--green-deep); border-color: #9fd8bf; }
.round-icon {
  width: 36px;
  height: 36px;
  border-radius: 14px;
  background: #edf4ef;
  color: var(--green-deep);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-weight: 800;
}
.round-icon.mini { width: 28px; height: 28px; border-radius: 10px; font-size: 12px; }
.bill-main { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.bill-content { min-width: 0; }
.bill-side { text-align: right; }
.bill-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; min-width: 112px; }
.bill-tools { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.bill-amount,.transfer-amount { font-weight: 800; }
.bill-type,.transfer-main span { font-size: 12px; color: var(--muted); }
.bill-type.refund { color: var(--danger); }
.ghost.danger { background: #fff0ef; color: var(--danger); }
.amount-card { background: linear-gradient(135deg, #f0f8f3, #fbfcfa); }
.amount-label { color: var(--muted); font-size: 13px; }
.amount-input { margin-top: 10px; padding: 0; border: 0; background: transparent; font-size: 32px; font-weight: 800; }
.field-grid { display: grid; gap: 12px; margin-top: 14px; }
.field-card { flex-direction: column; align-items: stretch; }
.field-card label { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.ratio-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ratio-name { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.ratio-input { width: 92px; text-align: center; }
.bottom-action {
  position: sticky;
  bottom: 72px;
  padding: 12px 18px;
  background: linear-gradient(180deg, rgba(251,252,250,0) 0%, rgba(251,252,250,1) 30%);
}
.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(460px, 100%);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  background: rgba(251,252,250,0.98);
  backdrop-filter: blur(12px);
  padding: 10px 8px calc(10px + env(safe-area-inset-bottom));
}
.nav-item { display: grid; place-items: center; gap: 6px; color: #95a29b; background: transparent; }
.nav-icon { width: 24px; height: 24px; border-radius: 8px; display: grid; place-items: center; background: #eef3ef; font-size: 13px; }
.nav-item.active { color: var(--green); font-weight: 700; }
.nav-item.active .nav-icon { background: var(--green-soft); }
.tag { padding: 6px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.tag.receive { background: var(--green-soft); color: var(--green-deep); }
.tag.pay { background: #fff0ef; color: var(--danger); }
.tag.neutral { background: #f0f2f1; color: #73817a; }
.person-item { align-items: stretch; flex-direction: column; }
.person-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.person-name { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.person-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; font-size: 12px; color: var(--muted); }
.person-stats strong { display: block; margin-top: 4px; color: var(--text); font-size: 13px; }
.transfer-main { font-weight: 700; }
.empty-card {
  padding: 16px;
  text-align: center;
  background: #f4f8f5;
  border: 1px dashed #d3e2d9;
  border-radius: 18px;
}
.feedback { min-height: 18px; margin-top: 8px; }
.feedback.error { color: var(--danger); }
.feedback.success { color: var(--green-deep); }
.field-input[type="datetime-local"] { min-height: 48px; }

@media (max-width: 420px) {
  .content { padding-left: 14px; padding-right: 14px; }
  .hero-grid,.summary-grid,.person-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
