/* ============ 基础 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --primary: #0f9d8a; --primary-dark: #0b8273; --primary-light: #e0f5f1;
  --accent: #ffb020; --danger: #e74c3c; --text: #1f2d3d; --text2: #5c6b7a;
  --bg: #f5f7f9; --card: #fff; --line: #eef1f4;
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5;
}
.hidden { display: none !important; }
.view { min-height: 100vh; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 10px; padding: 11px 18px; font-size: 15px;
  cursor: pointer; transition: .15s; text-decoration: none; font-weight: 500;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-block { width: 100%; }
.btn-ghost { background: var(--primary-light); color: var(--primary-dark); }
.btn-danger { background: #fdecea; color: var(--danger); }
.btn-gray { background: #eef1f4; color: var(--text2); }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.actions-row { display: flex; gap: 10px; margin-top: 14px; }
.actions-row .btn { flex: 1; }

/* ============ 登录页 ============ */
.login-wrap { max-width: 420px; margin: 0 auto; padding: 48px 22px; }
.app-logo { text-align: center; margin-bottom: 30px; }
.logo-mark { width: 72px; height: 72px; margin: 0 auto 10px; }
.logo-mark svg { width: 100%; height: 100%; display: block; }
.app-logo h1 { font-size: 26px; color: var(--primary); letter-spacing: 1px; }
.app-logo p { color: var(--text2); margin-top: 4px; font-size: 14px; }
.login-card { padding: 24px 22px; }
.login-tip { text-align: center; color: var(--text2); margin-top: 18px; font-size: 13px; }

/* ============ 卡片 / 表单 ============ */
.card { background: var(--card); border-radius: 14px; box-shadow: 0 1px 4px rgba(0,0,0,.05); }
.pad { padding: 16px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--text2); margin-bottom: 6px; font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  font-size: 15px; background: #fafbfc; outline: none; font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); background: #fff; }
.field textarea { min-height: 90px; resize: vertical; }
.field .hint { font-size: 12px; color: var(--text2); margin-top: 4px; }

/* 金额输入大字号 */
.amount-input { font-size: 24px !important; font-weight: 600; text-align: center; }

/* ============ 顶部栏 ============ */
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--primary); color: #fff;
  display: flex; align-items: center; height: 52px; padding: 0 12px;
}
.topbar-title { flex: 1; text-align: center; font-size: 17px; font-weight: 600; }
.topbar-logo { position: absolute; left: 14px; width: 26px; height: 26px; }
.topbar-logo svg { width: 100%; height: 100%; display: block; }
.icon-btn {
  background: rgba(255,255,255,.16); border: none; color: #fff; width: 34px; height: 34px;
  border-radius: 50%; font-size: 18px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.topbar-right { min-width: 34px; }

/* ============ 底部导航 ============ */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; background: #fff;
  display: flex; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 20;
}
.nav-item {
  flex: 1; border: none; background: none; padding: 9px 0; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--text2);
}
.nav-item .nav-icon { font-size: 22px; }
.nav-item span { font-size: 11px; }
.nav-item.active { color: var(--primary); font-weight: 600; }

/* ============ 内容区 ============ */
#content { max-width: 560px; margin: 0 auto; padding: 14px 14px 90px; min-height: calc(100vh - 52px); }

/* ============ 项目卡片 ============ */
.project-card {
  display: block; background: #fff; border-radius: 14px; padding: 16px; margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,.05); text-decoration: none; color: inherit; cursor: pointer;
  border-left: 4px solid var(--primary);
}
.project-card .p-name { font-size: 17px; font-weight: 600; }
.project-card .p-meta { font-size: 13px; color: var(--text2); margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.project-card .p-tags { margin-top: 10px; display: flex; gap: 8px; }
.badge { font-size: 11px; padding: 3px 9px; border-radius: 20px; background: var(--primary-light); color: var(--primary-dark); }
.badge.done { background: #eef1f4; color: var(--text2); }
.empty { text-align: center; color: var(--text2); padding: 60px 20px; }
.empty .e-icon { font-size: 40px; margin-bottom: 8px; opacity: .5; }

/* ============ 项目详情 ============ */
.seg { margin-bottom: 16px; }
.seg-title { font-size: 14px; font-weight: 600; color: var(--text2); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.hero { background: linear-gradient(135deg,#0f9d8a,#0b8273); color: #fff; border-radius: 14px; padding: 18px; margin-bottom: 14px; }
.hero h2 { font-size: 20px; }
.hero .hero-meta { margin-top: 10px; font-size: 13px; opacity: .95; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.hero .hero-stats { margin-top: 14px; display: flex; gap: 18px; border-top: 1px solid rgba(255,255,255,.2); padding-top: 12px; }
.stat .v { font-size: 20px; font-weight: 700; }
.stat .l { font-size: 12px; opacity: .85; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: #fff; border: 1px solid var(--line); padding: 5px 11px; border-radius: 20px; font-size: 13px; color: var(--text2); }
.chip.on { background: var(--primary); color: #fff; border-color: var(--primary); }

/* markdown 渲染 */
.md { background: #fff; border-radius: 12px; padding: 14px; }
.md h1,.md h2,.md h3 { margin: 10px 0 6px; font-size: 16px; }
.md p { margin: 4px 0; }
.md ul,.md ol { margin: 4px 0 4px 18px; }
.md code { background: #f0f2f5; padding: 1px 5px; border-radius: 4px; font-size: 13px; }

/* ============ 记账列表 ============ */
.expense-item {
  display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 12px;
  padding: 12px 14px; margin-bottom: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.cat-icon { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.e-main { flex: 1; min-width: 0; }
.e-top { display: flex; justify-content: space-between; align-items: baseline; }
.e-user { font-size: 13px; color: var(--text2); margin-top: 3px; }
.e-amount { font-weight: 700; font-size: 17px; }
.e-actions { display: flex; gap: 6px; }
.mini-btn { border: none; background: #f0f2f5; color: var(--text2); width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 14px; }

/* ============ 结算报告 ============ */
.report-total { background: linear-gradient(135deg,#ffb020,#ff9d00); color: #fff; border-radius: 14px; padding: 18px; text-align: center; margin-bottom: 14px; }
.report-total .big { font-size: 30px; font-weight: 800; }
.report-total .sub { font-size: 13px; opacity: .95; margin-top: 4px; }
.section { margin-bottom: 18px; }
.section > h3 { font-size: 15px; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.g-table { width: 100%; background: #fff; border-radius: 12px; overflow-x: auto; }
.g-table table { width: 100%; border-collapse: collapse; }
.g-table th, .g-table td { padding: 10px 12px; font-size: 14px; text-align: left; border-bottom: 1px solid var(--line); }
.g-table th { background: #f7f9fa; color: var(--text2); font-weight: 500; }
.g-table tr:last-child td { border-bottom: none; }
.t-color { font-size: 13px; font-weight: 600; }
.balance-ok { color: var(--primary); }
.balance-in { color: var(--primary); font-weight: 600; }
.balance-out { color: var(--danger); font-weight: 600; }
.transfer-row { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 12px; padding: 14px; margin-bottom: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.arrow { flex: 1; text-align: center; color: var(--text2); font-size: 18px; position: relative; }
.arrow .t-amount { font-weight: 800; color: var(--primary-dark); font-size: 16px; }
.arrow .t-line { position: relative; height: 2px; background: var(--primary-light); margin: 2px 0; border-radius: 2px; }
.arrow .t-line:before { content:""; position:absolute; right:-2px; top:-4px; border:5px solid transparent; border-left:7px solid var(--primary); }
.person-tag { width: 46px; text-align: center; }
.person-tag .avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--primary-light); color: var(--primary-dark); display: flex; align-items: center; justify-content: center; font-weight: 700; margin: 0 auto 3px; }
.person-tag span { font-size: 11px; color: var(--text2); }

/* ============ 弹窗 ============ */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: #fff; width: 100%; max-width: 560px; border-radius: 18px 18px 0 0; padding: 20px 18px 26px; animation: slideUp .22s ease; }
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-title { font-size: 17px; font-weight: 600; margin-bottom: 14px; text-align: center; }
.modal-body { max-height: 62vh; overflow-y: auto; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }
.modal-mask.center-mode { align-items: center; }
.center-mode .modal { border-radius: 16px; max-height: 82vh; }

.check-row { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line); margin-bottom: 8px; cursor: pointer; background: #fff; }
.check-row .cb { width: 22px; height: 22px; border: 2px solid #c9d2da; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.check-row.on .cb { border-color: var(--primary); background: var(--primary); }
.check-row.on .cb:after { content:"✓"; color:#fff; font-size:13px; font-weight:700; }
.check-row .cr-name { flex: 1; font-weight: 500; }
.check-row .cr-tag { font-size: 12px; color: var(--text2); }

/* ============ Toast ============ */
.toast {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%); z-index: 60;
  background: rgba(31,45,61,.92); color: #fff; padding: 11px 20px; border-radius: 24px;
  font-size: 14px; max-width: 82%; text-align: center; animation: fade .25s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ============ 附件 ============ */
.file-item { display: flex; align-items: center; gap: 10px; background: #f7f9fa; padding: 10px 12px; border-radius: 10px; margin-bottom: 8px; }
.file-item .f-icon { font-size: 20px; }
.file-item .f-name { flex: 1; font-size: 13px; word-break: break-all; }
.file-item a { color: var(--primary); font-size: 13px; text-decoration: none; }

/* 工具栏按钮 */
.toolbar { display: flex; gap: 6px; margin-bottom: 8px; }
.tool-btn { border: 1px solid var(--line); background: #fafbfc; border-radius: 8px; padding: 6px 10px; font-size: 13px; cursor: pointer; }
.tool-btn.on { background: var(--primary); color: #fff; border-color: var(--primary); }

/* 日期筛选 */
.filter-bar { display: flex; gap: 8px; margin-bottom: 12px; align-items: center; }
.filter-bar input[type=date] { flex: 1; border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; font-size: 14px; background: #fff; }

.row-line { display: flex; gap: 10px; }
.row-line .field { flex: 1; }

/* 富文本编辑器样式 */
.rich-toolbar { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; background: #f7f9fa; border-radius: 10px 10px 0 0; border: 1px solid var(--line); border-bottom: none; }
.rich-toolbar button { border: none; background: #fff; border-radius: 6px; padding: 6px 9px; cursor: pointer; font-size: 13px; color: var(--text); }
.rich-toolbar button.on { background: var(--primary); color: #fff; }
.rich-editor { border: 1px solid var(--line); border-radius: 0 0 10px 10px; min-height: 140px; padding: 12px; outline: none; font-size: 15px; background: #fff; }
.rich-preview { border: 1px solid var(--line); border-radius: 10px; min-height: 140px; padding: 12px; background: #fff; overflow-x: auto; }
.rich-switch { display: flex; gap: 6px; margin-bottom: 8px; }

/* 活动相册 */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.photo-cell { position: relative; border-radius: 10px; overflow: hidden; background: #f0f2f5; }
.photo-cell img { width: 100%; height: 100%; aspect-ratio: 1; object-fit: cover; display: block; cursor: zoom-in; }
.photo-meta { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: center; padding: 4px 6px; background: linear-gradient(transparent, rgba(0,0,0,.55)); color: #fff; font-size: 11px; }
.photo-meta .mini-btn { color: #fff; background: rgba(0,0,0,.35); border: none; }

/* 相册评论 */
.comment-box { margin-top: 10px; }
.comment-box textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px; font-size: 14px; min-height: 60px; resize: vertical; box-sizing: border-box; }
.comment-box-act { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.cmt { padding: 12px 0; border-bottom: 1px solid var(--line); }
.cmt:last-child { border-bottom: none; }
.cmt-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.cmt-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--primary-light); color: var(--primary-dark); display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; }
.cmt-name { font-weight: 600; font-size: 14px; }
.cmt-time { font-size: 12px; color: var(--text2); flex: 1; }
.cmt-body { font-size: 14px; line-height: 1.5; word-break: break-word; }
.cmt-act { margin-top: 6px; }
.cmt-replies { margin-top: 8px; padding-left: 12px; border-left: 2px solid var(--line); }
.cmt.reply { padding: 8px 0; border-bottom: none; }
.link-btn { background: none; border: none; color: var(--accent, #0f9d8a); font-size: 12px; cursor: pointer; padding: 0; }

/* ============ 结算报告美化 ============ */
.report-total { position: relative; overflow: hidden; background: linear-gradient(135deg,#0f9d8a,#0a7c6e 55%,#07675c); }
.report-total .rt-tag { display: inline-block; font-size: 12px; letter-spacing: 1px; background: rgba(255,255,255,.18); padding: 3px 12px; border-radius: 20px; margin-bottom: 10px; }
.report-total .rt-time { margin-top: 8px; font-size: 12px; opacity: .8; }
.report-total::after { content:""; position: absolute; right: -30px; top: -30px; width: 120px; height: 120px; border-radius: 50%; background: rgba(255,255,255,.08); }
.report-total::before { content:""; position: absolute; right: 40px; bottom: -40px; width: 90px; height: 90px; border-radius: 50%; background: rgba(255,255,255,.06); }

.cat-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.cat-row + .cat-row { border-top: 1px solid var(--line); }
.cat-lab { width: 88px; display: flex; align-items: center; gap: 7px; font-size: 14px; flex-shrink: 0; }
.cat-ico { width: 28px; height: 28px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; }
.cat-track { flex: 1; height: 10px; background: #f0f2f5; border-radius: 6px; overflow: hidden; }
.cat-fill { height: 100%; border-radius: 6px; min-width: 2px; transition: width .4s ease; }
.cat-amt { width: 82px; text-align: right; font-weight: 700; font-size: 14px; flex-shrink: 0; }

.row-avatar { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; background: var(--primary-light); color: var(--primary-dark); font-size: 12px; font-weight: 700; margin-right: 6px; vertical-align: middle; }

.transfer-card { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 14px; padding: 14px 12px; margin-bottom: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.05); }
.t-person { width: 64px; text-align: center; flex-shrink: 0; }
.t-ava { width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 17px; margin: 0 auto 4px; }
.t-ava.from { background: #ffe9e3; color: #d35400; }
.t-ava.to { background: #e3f0ff; color: #1e6fd9; }
.t-person span { font-size: 12px; color: var(--text2); word-break: break-all; }
.t-mid { flex: 1; text-align: center; min-width: 0; }
.t-amt { font-weight: 800; font-size: 17px; color: var(--primary-dark); }
.t-arrow { font-size: 20px; color: var(--primary); line-height: 1; }
.t-cap { font-size: 11px; color: var(--text2); }

.reverse-hint { text-align: center; color: var(--text2); font-size: 12px; margin-top: 8px; }

/* ============ 结算选择 + 比例输入 ============ */
.sm-item { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }
.sm-item.forced { border-color: var(--accent); background: #fffaf0; }
.sm-top { display: flex; align-items: center; gap: 10px; }
.sm-top .cb { width: 22px; height: 22px; border: 2px solid #c9d2da; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.sm-item.on .cb { border-color: var(--primary); background: var(--primary); }
.sm-item.on .cb:after { content: "✓"; color: #fff; font-size: 13px; font-weight: 700; }
.sm-top .cr-name { flex: 1; font-weight: 500; cursor: pointer; }
.sm-top .cr-tag { font-size: 12px; color: var(--text2); flex-shrink: 0; }
.sm-ratio { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding-left: 32px; }
.sm-label { font-size: 12px; color: var(--text2); flex-shrink: 0; }
.ratio-input-wrap { display: flex; align-items: center; gap: 4px; }
.ratio-input { width: 76px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 14px; text-align: right; background: #fafbfc; }
.ratio-input:focus { border-color: var(--primary); background: #fff; }
.ratio-input:disabled { background: #f0f2f5; color: #aab3bc; }
.pct-suf { font-size: 13px; color: var(--text2); }
.ratio-hint { font-size: 12px; color: var(--primary-dark); flex-shrink: 0; }
.settle-summary { font-size: 12px; color: var(--text2); margin-top: 8px; line-height: 1.6; }

/* ===== 头像 ===== */
.ava-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mine-avatar { width: 64px; height: 64px; border-radius: 50%; position: relative; flex-shrink: 0; overflow: hidden; background: var(--primary-light); color: var(--primary-dark); display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 700; cursor: pointer; }
.mine-avatar .ava-edit { position: absolute; right: -2px; bottom: -2px; width: 22px; height: 22px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 11px; display: flex; align-items: center; justify-content: center; border: 2px solid #fff; }
.cat-avatar { position: relative; cursor: pointer; }
.cat-avatar .ava-edit { position: absolute; right: -2px; bottom: -2px; width: 18px; height: 18px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 10px; display: flex; align-items: center; justify-content: center; border: 2px solid #fff; }

/* ===== 会员排行榜 ===== */
.rank-item { display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; }
.rank-medal { width: 28px; text-align: center; font-size: 20px; flex-shrink: 0; }
.rank-num { font-size: 16px; font-weight: 700; color: var(--text2); }
.rank-avatar { width: 44px; height: 44px; border-radius: 50%; overflow: hidden; background: var(--primary-light); color: var(--primary-dark); display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 700; flex-shrink: 0; }
.rank-main { flex: 1; min-width: 0; }
.rank-name { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 6px; }
.rank-level { font-size: 13px; margin-top: 4px; }
.lv-ico { display: inline-block; margin-right: 6px; font-size: 13px; }
.rank-count { font-size: 13px; color: var(--text2); flex-shrink: 0; }
