:root {
  --text: #313b47;
  --muted: #667281;
  --soft: #8a94a3;
  --primary: #2555ff;
  --green: #34de4c;
  --cyan: #05c9e5;
  --sky: #00aeff;
  --accent: #ffc540;
  --danger: #f05252;
  --page: #f6f8fb;
  --line: #e7ebf0;
  --card: #ffffff;
  --shadow: 0 16px 40px rgba(49, 59, 71, 0.08);
  font-family: "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; color: var(--text); background: var(--page); }
body { font-size: 14px; line-height: 1.5; }
button, input { font: inherit; }
button { border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
input { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; color: var(--text); background: #fff; outline: none; }
input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 85, 255, 0.12); }

.app-shell { width: 100%; max-width: 720px; min-height: 100vh; margin: 0 auto; background: var(--page); }
.page { min-height: 100vh; padding: 16px 16px calc(28px + env(safe-area-inset-bottom)); }
.page-with-nav { padding-bottom: calc(82px + env(safe-area-inset-bottom)); }
.topbar { position: sticky; top: 0; z-index: 10; min-height: 52px; margin: -16px -16px 16px; padding: 8px 12px; display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: center; background: rgba(255,255,255,0.94); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.topbar-title { text-align: center; font-size: 16px; font-weight: 700; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.icon-btn { width: 40px; height: 40px; border-radius: 20px; color: var(--text); background: transparent; font-size: 24px; display: grid; place-items: center; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.caption { color: var(--soft); font-size: 12px; }
.body-copy { color: var(--muted); font-size: 13px; }
.title { font-size: 24px; font-weight: 700; }
.subtitle { font-size: 18px; font-weight: 700; }
.section-title { font-size: 16px; font-weight: 700; }
.success { color: #13af37; }
.danger { color: var(--danger); }
.primary { color: var(--primary); }

.login-page { display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.brand { text-align: center; padding: 18px 0; }
.brand-mark { width: 72px; height: 72px; margin: 0 auto 14px; border-radius: 18px; color: #fff; background: var(--primary); display: grid; place-items: center; font-size: 34px; font-weight: 700; }
.login-card { padding: 22px; }
.form-stack { display: grid; gap: 14px; }
.notice-card { padding: 16px; border-left: 4px solid var(--accent); background: #fffdf3; }

.btn { min-height: 44px; padding: 0 16px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; color: var(--text); background: #eef3ff; font-weight: 700; }
.btn-primary { color: #fff; background: var(--primary); }
.btn-green { color: #fff; background: #15b83a; }
.btn-outline { color: var(--primary); background: #fff; border: 1px solid #cdd9ff; }
.btn-danger { color: #fff; background: var(--danger); }
.btn-ghost { color: var(--muted); background: #f1f4f8; }
.btn-full { width: 100%; }
.btn-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

.profile { padding: 24px 18px; text-align: center; }
.avatar { width: 76px; height: 76px; border-radius: 50%; background: #f1f4f8; display: grid; place-items: center; color: var(--soft); overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile .avatar { margin: 0 auto 10px; }
.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin-top: 20px; background: var(--line); border-radius: 8px; overflow: hidden; }
.metric { padding: 16px 10px; background: #fff; text-align: center; }
.metric-value { font-size: 24px; font-weight: 700; }
.stat-line { margin: 16px -18px -24px; padding: 16px; display: flex; justify-content: center; gap: 18px; border-top: 1px solid var(--line); color: var(--muted); flex-wrap: wrap; }
.year-list { margin-top: 14px; overflow: hidden; }
.year-row { padding: 14px; display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 10px; align-items: center; border-bottom: 1px solid var(--line); }
.year-row:last-child { border-bottom: 0; }

.room-notice { margin: -16px -16px 0; min-height: 42px; padding: 10px 16px; display: flex; gap: 8px; align-items: center; color: #7a5a00; background: #fff9df; border-bottom: 1px solid #ffe8a0; }
.member-grid { padding: 22px 8px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px 8px; background: #fff; }
.member { min-width: 0; text-align: center; }
.member .avatar { width: 58px; height: 58px; margin: 0 auto 6px; border: 2px solid #e4e9f1; }
.member.self .avatar { border-color: var(--primary); }
.member-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-score { font-size: 18px; font-weight: 700; }
.tea-pill { margin: 4px auto 0; max-width: 96px; height: 24px; border-radius: 12px; color: #00a8c0; background: #eafffc; font-size: 12px; display: grid; place-items: center; }
.hint { padding: 12px 16px; color: #4da96a; background: #fff; border-top: 3px solid var(--green); }
.flow-section { padding: 18px 0; }
.room-page-h5 {
  height: 100vh;
  min-height: 100vh;
  padding-bottom: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.room-page-h5 .topbar,
.room-page-h5 .room-notice,
.room-page-h5 .member-grid,
.room-page-h5 .hint {
  flex: 0 0 auto;
}
.room-page-h5 .flow-section {
  flex: 1 1 auto;
  height: 0;
  min-height: 0;
  padding: 18px 0 calc(76px + env(safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.section-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.flow-card { padding: 14px; margin-bottom: 10px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.flow-title { font-size: 16px; font-weight: 700; overflow-wrap: anywhere; }
.bottom-nav { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 720px; min-height: calc(58px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: flex; background: #fff; border-top: 1px solid var(--line); z-index: 30; }
.bottom-nav button { flex: 1 1 0; min-width: 0; height: 58px; border-right: 1px solid var(--line); color: var(--muted); background: #fff; font-weight: 700; }
.bottom-nav button:last-child { border-right: 0; }

.timeline { overflow: hidden; background: #fff; }
.record { position: relative; min-height: 98px; padding: 18px 14px 16px 54px; border-bottom: 1px solid var(--line); }
.record:before { content: ""; position: absolute; left: 23px; top: 0; bottom: 0; width: 1px; background: #e4e8ef; }
.record-dot { position: absolute; left: 16px; top: 26px; width: 15px; height: 15px; border-radius: 50%; background: var(--accent); z-index: 1; }
.record-main { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center; }
.badge { min-width: 34px; height: 34px; padding: 0 8px; border-radius: 6px; color: #fff; display: grid; place-items: center; font-weight: 700; }
.badge-blue { background: var(--primary); }
.badge-green { background: #16b93a; }
.status-pill { height: 28px; padding: 0 10px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; background: #f1f4f8; color: var(--soft); }
.status-open { color: var(--primary); background: #eef3ff; }
.segment { padding: 6px; display: grid; gap: 6px; border-radius: 10px; background: #eef3ff; }
.segment.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.segment.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.segment.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.segment button { height: 38px; border-radius: 8px; color: var(--muted); background: transparent; font-weight: 700; }
.segment button.active { color: #fff; background: var(--primary); }
.rank-row { padding: 14px; display: grid; grid-template-columns: 42px 54px minmax(0, 1fr) auto; gap: 10px; align-items: center; border-bottom: 1px solid var(--line); background: #fff; }
.medal { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: #ffc540; color: #fff; font-weight: 700; }
.ranking-control-card { padding: 16px; margin-bottom: 14px; }
.control-label { margin-top: 16px; color: var(--text); font-size: 15px; font-weight: 700; }
.ranking-segment { margin-top: 10px; }
.ranking-date-grid { margin-top: 12px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ranking-date-grid label,
.ranking-year-select { min-width: 0; display: grid; gap: 6px; color: var(--muted); font-size: 12px; }
.ranking-year-select { margin-top: 12px; }
.ranking-date-grid input,
.ranking-year-select select { min-width: 0; width: 100%; height: 42px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; color: var(--text); background: #fff; outline: none; }
.ranking-current { margin-top: 10px; }
.rank-list { overflow: hidden; }
.rank-row-rich { grid-template-columns: 42px 54px minmax(0, 1fr) minmax(58px, auto); }
.rank-main { min-width: 0; }
.rank-main strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) 64px; gap: 12px; align-items: center; margin: 18px 0; }
.bar-track { height: 12px; border-radius: 8px; background: #edf0f5; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 8px; background: var(--primary); }
.bar-fill.positive { background: #31d84c; }
.settlement-row { padding: 14px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.manual-card { padding: 16px; margin-bottom: 12px; }
.manual-card ul { margin: 8px 0 0; padding-left: 18px; color: var(--muted); }

.modal-backdrop { position: fixed; inset: 0; z-index: 80; padding: 28px 16px; display: grid; place-items: center; background: rgba(49, 59, 71, 0.58); }
.modal { width: min(100%, 520px); max-height: 86vh; overflow: auto; padding: 18px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.close-btn { width: 38px; height: 38px; border-radius: 19px; color: var(--soft); background: #f1f4f8; font-size: 22px; }
.field-label { margin: 18px 0 10px; color: var(--text); font-size: 15px; font-weight: 700; }
.payment-notice { color: #d86a32; }
.payment-list { display: grid; gap: 10px; }
.payment-empty { min-height: 44px; padding: 12px; border-radius: 8px; color: var(--soft); background: #f6f8fb; text-align: center; }
.payment-row { min-width: 0; display: grid; grid-template-columns: 48px minmax(90px, 1fr) minmax(108px, 160px); gap: 10px; align-items: center; }
.payment-avatar.avatar { width: 44px; height: 44px; margin: 0; }
.payment-tea-avatar { color: #fff; background: #aeb4bd; font-size: 13px; font-weight: 700; }
.payment-name, .score-name { min-width: 0; color: var(--text); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.payment-input { height: 44px; padding: 0 10px; text-align: center; }
.score-direction { margin: 8px 0 18px; display: grid; grid-template-columns: minmax(0, 1fr) 76px minmax(0, 1fr); gap: 10px; align-items: center; text-align: center; }
.score-person { min-width: 0; }
.score-avatar.avatar { width: 68px; height: 68px; margin: 0 auto 8px; }
.score-arrow { color: var(--soft); font-weight: 700; }
.score-arrow-line { color: var(--primary); font-size: 26px; line-height: 1; }
.option-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 8px 0 14px; }
.option-grid button { min-height: 40px; border-radius: 8px; background: #f5f7ff; color: var(--text); }
.option-grid button.active { color: #fff; background: var(--primary); }
.rule-card { margin-top: 16px; padding: 14px; border-radius: 8px; background: #f8fbff; }
.rule-desc { margin: 6px 0 10px; }
.rule-row { min-height: 44px; display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; gap: 10px; align-items: center; color: var(--muted); font-size: 13px; }
.rule-input { height: 38px; padding: 0 10px; text-align: right; }
.toast { position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 120; max-width: min(320px, calc(100vw - 40px)); padding: 10px 14px; border-radius: 8px; color: #fff; background: rgba(49, 59, 71, 0.92); text-align: center; }
.empty { padding: 60px 16px; text-align: center; color: var(--soft); }

@media (max-width: 420px) {
  .page { padding-left: 12px; padding-right: 12px; }
  .topbar { margin-left: -12px; margin-right: -12px; }
  .member-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .btn-grid { grid-template-columns: 1fr; }
}

@media (max-width: 360px) {
  .ranking-date-grid { grid-template-columns: 1fr; }
}


.settlement-flow-card {
  display: block;
}

.settlement-flow-head {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.settlement-flow-avatar.avatar {
  width: 38px;
  height: 38px;
  margin: 0;
}

.settlement-flow-head strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settlement-flow-total {
  font-size: 20px;
  font-weight: 700;
}

.settlement-flow-total.positive {
  color: var(--primary);
}

.settlement-flow-total.negative {
  color: #13af37;
}

.settlement-flow-lines {
  margin: 12px 0 8px 52px;
  display: grid;
  gap: 6px;
}

.settlement-flow-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 56px;
  gap: 10px;
  align-items: center;
  color: var(--muted);
}

.settlement-flow-line span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settlement-flow-line strong {
  color: var(--text);
  text-align: right;
}

.settlement-flow-empty {
  margin: 0;
}

.settlement-flow-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

.settlement-leave-btn {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 8px;
}


.settlement-history-card {
  margin-top: 12px;
  overflow: hidden;
}

.settlement-history-head {
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.settlement-history-card > .caption {
  padding: 10px 14px 0;
}


.room-flow-list {
  display: grid;
  gap: 10px;
}

.room-flow-detail-card {
  padding: 14px;
}

.room-flow-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.room-flow-detail-card .section-title {
  overflow-wrap: anywhere;
}

.room-flow-detail-card .body-copy {
  margin-top: 6px;
  overflow-wrap: anywhere;
}
