* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', sans-serif;
  background: #f2f2f7;
  color: #1c1c1e;
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 80px;
}

/* ── Navigation Bar ── */
.navbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(242,242,247,0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 0.5px solid #c6c6c8;
  padding: 12px 16px 10px;
  display: flex; align-items: center; justify-content: space-between;
}
.navbar-title { font-size: 17px; font-weight: 700; }
.navbar-btn { background: none; border: none; color: #007aff; font-size: 16px; padding: 4px 8px; cursor: pointer; }
.navbar-back { display: flex; align-items: center; gap: 2px; }

/* ── Tab Bar ── */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 430px;
  background: rgba(242,242,247,0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 0.5px solid #c6c6c8;
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 8px 0 4px; cursor: pointer; border: none; background: none;
  color: #8e8e93; font-size: 10px; gap: 3px;
}
.tab-item.active { color: #007aff; }
.tab-icon { font-size: 24px; line-height: 1; }

/* ── Cards ── */
.card { background: #fff; border-radius: 12px; overflow: hidden; margin-bottom: 1px; }
.card-group { margin-bottom: 16px; }
.section-label { font-size: 13px; color: #6c6c70; padding: 0 4px 6px; }

/* ── Summary ── */
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.summary-card { background: #fff; border-radius: 12px; padding: 14px; }
.summary-label { font-size: 12px; color: #8e8e93; margin-bottom: 4px; }
.summary-amount { font-size: 20px; font-weight: 700; }
.summary-net { background: #fff; border-radius: 12px; padding: 14px; margin-bottom: 16px; }
.summary-net .summary-amount { font-size: 24px; }

/* ── Row items ── */
.row-item {
  display: flex; align-items: center; padding: 12px 14px;
  gap: 12px; cursor: pointer; background: #fff;
  border-bottom: 0.5px solid #f2f2f7; text-decoration: none; color: inherit;
}
.row-item:last-child { border-bottom: none; }
.row-item:active { background: #f2f2f7; }

.avatar {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; flex-shrink: 0;
}
.item-info { flex: 1; min-width: 0; }
.item-name { font-size: 15px; font-weight: 500; }
.item-sub { font-size: 13px; color: #8e8e93; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-right { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.chevron { color: #c6c6c8; font-size: 14px; }

/* ── Amount ── */
.amount-col { text-align: right; }
.amount-val { font-size: 15px; font-weight: 600; }
.amount-label { font-size: 11px; color: #8e8e93; }
.lent { color: #c0392b; }
.borrowed { color: #1a7a3c; }

/* ── Badges ── */
.badge { display: inline-block; border-radius: 6px; padding: 2px 8px; font-size: 11px; font-weight: 500; margin-top: 4px; }
.badge-repaid { background: #d6f5e3; color: #1a7a3c; }
.badge-due { background: #fff3cd; color: #856404; }
.badge-overdue { background: #ffd6d6; color: #c0392b; }

/* ── Add Button ── */
.add-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: #007aff; color: #fff; border: none; border-radius: 12px;
  padding: 14px; font-size: 16px; font-weight: 600; width: 100%;
  margin-bottom: 16px; cursor: pointer;
}
.add-btn:active { background: #0062cc; }

/* ── FAB ── */
.fab {
  position: fixed; right: 20px; bottom: 90px;
  width: 56px; height: 56px; border-radius: 28px;
  background: #34c759; color: #fff; border: none;
  font-size: 28px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* ── Modal / Sheet ── */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  z-index: 200; display: flex; align-items: flex-end;
}
.sheet {
  background: #f2f2f7; border-radius: 20px 20px 0 0;
  width: 100%; max-height: 90vh; overflow-y: auto;
  padding: 0 0 env(safe-area-inset-bottom);
}
.sheet-handle { width: 36px; height: 4px; background: #c6c6c8; border-radius: 2px; margin: 12px auto 0; }
.sheet-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px; border-bottom: 0.5px solid #c6c6c8;
}
.sheet-title { font-size: 17px; font-weight: 600; }
.sheet-body { padding: 16px; }

/* ── Form ── */
.form-section { margin-bottom: 16px; }
.form-label { font-size: 13px; color: #6c6c70; margin-bottom: 6px; }
.form-card { background: #fff; border-radius: 12px; overflow: hidden; }
.form-row {
  display: flex; align-items: center; padding: 12px 14px;
  border-bottom: 0.5px solid #f2f2f7;
}
.form-row:last-child { border-bottom: none; }
.form-row label { font-size: 15px; flex: 1; }
.form-row input, .form-row select, .form-row textarea {
  border: none; outline: none; font-size: 15px; color: #1c1c1e;
  text-align: right; background: transparent; flex: 1;
  font-family: inherit;
}
.form-row textarea { text-align: left; resize: none; min-height: 60px; padding-top: 2px; line-height: 1.5; }
.form-row:has(textarea) { align-items: flex-start; padding-top: 14px; }
.form-row input[type="date"] { color: #007aff; }

.seg-control { display: flex; background: #e5e5ea; border-radius: 9px; padding: 2px; margin-bottom: 16px; }
.seg-btn {
  flex: 1; padding: 7px; border-radius: 7px; border: none;
  font-size: 14px; font-weight: 500; cursor: pointer;
  background: transparent; color: #636366;
}
.seg-btn.active { background: #fff; color: #1c1c1e; }
.seg-btn.active.lent-active { background: #ffd6d6; color: #c0392b; }
.seg-btn.active.borrowed-active { background: #d6f5e3; color: #1a7a3c; }

.save-btn {
  background: #007aff; color: #fff; border: none; border-radius: 12px;
  padding: 14px; font-size: 16px; font-weight: 600; width: 100%;
  margin-top: 8px; cursor: pointer;
}
.save-btn:active { background: #0062cc; }
.danger-btn {
  background: none; color: #ff3b30; border: none;
  font-size: 15px; font-weight: 500; width: 100%; padding: 14px;
  cursor: pointer; text-align: center;
}

/* ── Detail ── */
.detail-header { display: flex; justify-content: space-between; align-items: center; padding: 14px; }
.detail-amount { font-size: 28px; font-weight: 700; }
.detail-remaining { font-size: 13px; color: #8e8e93; margin-top: 2px; }
.detail-row { display: flex; justify-content: space-between; padding: 12px 14px; border-bottom: 0.5px solid #f2f2f7; }
.detail-row:last-child { border-bottom: none; }
.detail-key { font-size: 15px; color: #8e8e93; }
.detail-val { font-size: 15px; font-weight: 500; }
.action-row { padding: 14px; border-bottom: 0.5px solid #f2f2f7; cursor: pointer; }
.action-row:last-child { border-bottom: none; }
.action-row:active { background: #f2f2f7; }

/* ── Search ── */
.search-bar {
  display: flex; align-items: center; gap: 8px;
  background: #e5e5ea; border-radius: 10px;
  margin: 8px 16px; padding: 8px 12px;
}
.search-bar input { border: none; outline: none; background: transparent; font-size: 15px; flex: 1; }

/* ── Filter chips ── */
.filter-row { display: flex; gap: 8px; padding: 8px 16px; overflow-x: auto; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-chip {
  padding: 6px 16px; border-radius: 20px; border: none;
  background: #e5e5ea; color: #1c1c1e; font-size: 14px;
  white-space: nowrap; cursor: pointer;
}
.filter-chip.active { background: #007aff; color: #fff; font-weight: 600; }

/* ── Pages ── */
.page { display: none; padding: 16px; }
.page.active { display: block; }

/* ── Empty state ── */
.empty { text-align: center; padding: 60px 20px; color: #8e8e93; }
.empty-icon { font-size: 48px; margin-bottom: 12px; }

/* ── Avatar colors ── */
.av0 { background: #ffd6d6; color: #c0392b; }
.av1 { background: #d6eaff; color: #0055c8; }
.av2 { background: #d6f5e3; color: #1a7a3c; }
.av3 { background: #ffe8cc; color: #a0520a; }
.av4 { background: #edd6ff; color: #720092; }

/* ── Scroll content ── */
.scroll-content { padding: 16px; }

.hidden { display: none !important; }
