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

html, body { margin: 0; padding: 0; min-height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: #e9edee;
  color: #1f2937;
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

.hidden { display: none !important; }

input, select, textarea, button { font-family: inherit; font-size: 16px; }

/* ============================ 登录 ============================ */

.join-wrap {
  min-height: 100vh;
  background: linear-gradient(160deg, #0f766e 0%, #14b8a6 55%, #7fd9c9 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
}

.join-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 20px;
  padding: 28px 22px 22px;
  box-shadow: 0 18px 40px rgba(6, 60, 52, .22);
}

.join-logo {
  width: 56px; height: 56px;
  border-radius: 16px;
  background: linear-gradient(140deg, #0f766e, #22c1a8);
  color: #fff;
  font-size: 26px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}

.join-title { margin: 0 0 6px; font-size: 22px; font-weight: 700; letter-spacing: .5px; }

.join-sub { margin: 0 0 20px; font-size: 13px; color: #6b7280; line-height: 1.6; }

.field { display: block; margin-bottom: 14px; }

.field > span {
  display: block;
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 6px;
}

.input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid #d8dee3;
  border-radius: 12px;
  background: #fbfcfc;
  color: #111827;
  outline: none;
}

.input:focus { border-color: #14b8a6; background: #fff; }

select.input { padding: 0 10px; }

.phone-row { display: flex; gap: 8px; }

.phone-row .input { flex: 1; }

.sms-btn {
  flex: 0 0 110px;
  height: 46px;
  border-radius: 12px;
  font-size: 14px;
  padding: 0 8px;
}

.btn-primary {
  height: 46px;
  padding: 0 18px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #0f766e, #14b8a6);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}

.btn-primary:disabled { opacity: .55; }

.btn-ghost {
  height: 46px;
  padding: 0 16px;
  border: 1px solid #cfd8dd;
  border-radius: 12px;
  background: #fff;
  color: #374151;
  font-size: 15px;
}

.btn-ghost:disabled { opacity: .55; }

.btn-ghost.full { width: 100%; margin-top: 4px; }

.join-btn { width: 100%; margin-top: 6px; height: 50px; font-size: 16px; }

.join-tip { min-height: 18px; margin: 12px 0 0; font-size: 13px; color: #b91c1c; text-align: center; }

.btn-mini {
  height: 32px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid #d8dee3;
  background: #fff;
  color: #374151;
  font-size: 13px;
  white-space: nowrap;
}

.btn-mini.ok { border-color: #14b8a6; background: #14b8a6; color: #fff; }

.btn-mini.danger { border-color: #f3c1c1; background: #fff5f5; color: #b91c1c; }

.danger-text { color: #b91c1c; border-color: #f3c1c1; }

/* ============================ 主框架 ============================ */

#appView {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: #f6f7f8;
  display: flex;
  flex-direction: column;
  position: relative;
}

.page { flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  flex: none;
  height: 54px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border-bottom: 1px solid #eef1f2;
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar-left { display: flex; align-items: center; gap: 7px; flex: 1; min-width: 0; }

.topbar-title {
  font-size: 17px;
  font-weight: 700;
  color: #111827;
  max-width: 60vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: none;
  border: none;
  padding: 0;
  text-align: left;
}

.chat-title { flex: 1; text-align: center; max-width: none; }

.topbar-right { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }

.dot-live {
  width: 7px; height: 7px; border-radius: 50%;
  background: #14b8a6;
  box-shadow: 0 0 0 3px rgba(20, 184, 166, .16);
}

.dot-live.on { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .16); }

.icon-btn {
  width: 36px; height: 36px;
  border: none;
  border-radius: 10px;
  background: #f1f5f6;
  color: #0f766e;
  font-size: 20px;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}

.icon-btn:active { background: #e2e8ea; }

.back-btn { font-size: 26px; font-weight: 600; }

.today-net { font-size: 13px; color: #0f766e; font-weight: 600; }

/* 底部导航（加高，点起来更稳） */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: flex;
  background: #fff;
  border-top: 1px solid #eaeff0;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
  box-shadow: 0 -4px 14px rgba(15, 23, 42, .05);
}

.tab-btn {
  flex: 1;
  position: relative;
  padding: 18px 0 16px;
  min-height: 58px;
  border: none;
  background: none;
  color: #8a9aa1;
  font-size: 14px;
  font-weight: 500;
}

.tab-btn.active { color: #0f766e; font-weight: 700; }

.tab-dot {
  position: absolute;
  top: 12px;
  right: 50%;
  margin-right: -30px;
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 9px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  line-height: 17px;
  text-align: center;
  font-weight: 600;
}

.badge {
  display: inline-block;
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  margin-left: 6px;
  border-radius: 9px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  line-height: 17px;
  text-align: center;
  vertical-align: middle;
  font-weight: 600;
}

/* ============================ 列表 / 卡片 ============================ */

.list-body, .contacts-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 12px 86px;
}

.empty-tip, .people-empty {
  padding: 28px 16px;
  font-size: 13.5px;
  color: #8a9aa1;
  text-align: center;
  line-height: 1.7;
}

.people-empty { padding: 14px 4px; text-align: left; }

.panel {
  background: #fff;
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .04);
}

.panel-title {
  font-size: 14px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 10px;
}

.sum-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.sum-head .panel-title { margin: 0; }

.hint { margin: 8px 0 0; font-size: 12.5px; color: #8a9aa1; line-height: 1.6; }

.newroom-row { display: flex; gap: 8px; }

.newroom-row .input { flex: 1; }

.newroom-row .btn-primary { height: 46px; flex: 0 0 auto; padding: 0 16px; }

/* 群列表 */
.room-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 12px;
  margin-bottom: 8px;
  background: #fff;
  border: none;
  border-radius: 14px;
  text-align: left;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .04);
}

.room-item:active { background: #f3f7f7; }

.avatar {
  flex: none;
  width: 44px; height: 44px;
  border-radius: 12px;
  background: linear-gradient(140deg, #0f766e, #2dd4bf);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  position: relative;
}

.avatar-img { width: 100%; height: 100%; object-fit: cover; display: block; }

.room-mid { flex: 1; min-width: 0; }

.room-name {
  font-size: 15.5px;
  font-weight: 600;
  color: #111827;
  display: flex;
  align-items: center;
  gap: 6px;
}

.room-count { font-size: 11.5px; color: #9aa7ad; font-weight: 400; }

.room-last {
  font-size: 13px;
  color: #8a9aa1;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-right { flex: none; text-align: right; }

.room-time { font-size: 11.5px; color: #a6b2b7; }

.room-amount { font-size: 11.5px; color: #0f766e; margin-top: 4px; }

/* 账本统计 */
.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }

.stat-card {
  background: #f7fafa;
  border-radius: 11px;
  padding: 9px 8px;
  text-align: center;
}

.stat-label { display: block; font-size: 11.5px; color: #8a9aa1; margin-bottom: 4px; }

.stat-value { display: block; font-size: 15px; font-weight: 700; color: #111827; }

.stat-value.expense { color: #b91c1c; }

.stat-value.income { color: #0f766e; }

/* 账目 */
.rec-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px;
  margin-bottom: 8px;
  background: #fff;
  border: none;
  border-radius: 13px;
  text-align: left;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .04);
}

.rec-item:active { background: #f3f7f7; }

.rec-cat {
  flex: none;
  width: 40px; height: 40px;
  border-radius: 11px;
  background: #eef7f5;
  color: #0f766e;
  font-size: 12.5px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

.rec-mid { flex: 1; min-width: 0; }

.rec-title { font-size: 15px; color: #111827; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.rec-sub { font-size: 12px; color: #9aa7ad; margin-top: 3px; }

.rec-right { flex: none; font-size: 15.5px; font-weight: 700; }

.rec-right.expense { color: #b91c1c; }

.rec-right.income { color: #0f766e; }

/* 表决卡 */
.request-panel {
  border: 1px solid #fde68a;
  background: #fffbeb;
  box-shadow: none;
}

.request-panel .panel-title { color: #92400e; }

.req-item {
  background: #fff;
  border-radius: 11px;
  padding: 11px;
  margin-bottom: 9px;
  border: 1px solid #fef3c7;
}

.req-item:last-child { margin-bottom: 0; }

.req-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }

.req-who { font-size: 13.5px; font-weight: 600; color: #111827; }

.req-type {
  font-size: 11.5px;
  color: #92400e;
  background: #fef3c7;
  border-radius: 6px;
  padding: 1px 6px;
}

.req-text { font-size: 14px; color: #1f2937; line-height: 1.5; }

.req-meta { font-size: 12px; color: #9aa7ad; margin-top: 5px; }

.req-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 9px; }

/* ============================ 聊天 ============================ */

.messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 12px 14px;
  background: #f1f4f5;
}

.msg-row { display: flex; gap: 9px; margin-bottom: 14px; }

.msg-row.mine { flex-direction: row-reverse; }

.msg-row .avatar { width: 36px; height: 36px; border-radius: 10px; font-size: 15px; }

.bubble-wrap { max-width: 76%; }

.msg-row.mine .bubble-wrap { display: flex; flex-direction: column; align-items: flex-end; }

.msg-name { font-size: 11.5px; color: #8a9aa1; margin-bottom: 4px; padding: 0 2px; }

.bubble {
  background: #fff;
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 15px;
  line-height: 1.5;
  color: #111827;
  word-break: break-word;
  box-shadow: 0 1px 4px rgba(15, 23, 42, .05);
}

.msg-row.mine .bubble { background: #d9f6ee; }

.bubble img { max-width: 100%; border-radius: 8px; display: block; }

.tag {
  display: inline-block;
  margin-top: 7px;
  padding: 2px 8px;
  border-radius: 7px;
  background: #eef7f5;
  color: #0f766e;
  font-size: 12px;
  font-weight: 600;
}

.msg-time { font-size: 11px; color: #a6b2b7; margin-top: 4px; padding: 0 2px; }

.composer {
  flex: none;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 10px calc(9px + env(safe-area-inset-bottom));
  background: #fff;
  border-top: 1px solid #eaeff0;
}

.plus-btn { flex: none; width: 38px; height: 38px; }

.composer-input {
  flex: 1;
  height: 40px;
  padding: 0 13px;
  border: 1px solid #dde5e7;
  border-radius: 20px;
  background: #f7fafa;
  outline: none;
  font-size: 16px;
}

.composer-input:focus { border-color: #14b8a6; background: #fff; }

.send-btn {
  flex: none;
  height: 38px;
  padding: 0 15px;
  border: none;
  border-radius: 19px;
  background: #0f766e;
  color: #fff;
  font-size: 14.5px;
  font-weight: 600;
}

.send-btn:active { background: #0b5f58; }

/* ============================ 通讯录 / 我 ============================ */

.people-list { display: flex; flex-direction: column; gap: 2px; }

.people-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 2px;
  border: none;
  background: none;
  text-align: left;
  width: 100%;
}

.people-item.as-button { background: none; }

.people-item .avatar { width: 40px; height: 40px; border-radius: 11px; font-size: 16px; }

.people-mid { flex: 1; min-width: 0; }

.people-name {
  font-size: 15px;
  color: #111827;
  display: flex;
  align-items: center;
  gap: 6px;
}

.people-sub {
  font-size: 12.5px;
  color: #9aa7ad;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.people-state { font-size: 12.5px; color: #9aa7ad; }

.role-tag {
  font-size: 10.5px;
  padding: 1px 5px;
  border-radius: 5px;
  background: #fef3c7;
  color: #92400e;
}

.role-tag.me { background: #e6f7f3; color: #0f766e; }

.chev { color: #c4ced3; font-size: 20px; }

.pick-item { display: flex; align-items: center; gap: 10px; padding: 8px 2px; }

.pick-box { width: 19px; height: 19px; accent-color: #0f766e; flex: none; }

.search-result { margin-top: 8px; }

.me-head-panel { padding: 16px 14px; }

.me-head { display: flex; align-items: center; gap: 13px; }

.avatar-btn {
  flex: none;
  width: 62px; height: 62px;
  border-radius: 18px;
  border: none;
  padding: 0;
  overflow: hidden;
  background: linear-gradient(140deg, #0f766e, #2dd4bf);
  display: flex; align-items: center; justify-content: center;
}

.avatar-fallback { color: #fff; font-size: 24px; font-weight: 700; }

.me-head-info { flex: 1; min-width: 0; }

.me-head-name { font-size: 18px; font-weight: 700; color: #111827; }

.me-head-sub { font-size: 12.5px; color: #8a9aa1; margin-top: 3px; }

/* ============================ 抽屉 / 弹层 ============================ */

.sheet-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .38);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 30;
}

.sheet {
  width: 100%;
  max-width: 480px;
  background: #fff;
  border-radius: 18px 18px 0 0;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}

.sheet-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 8px;
  border-bottom: 1px solid #f1f5f6;
}

.sheet-title { font-size: 16px; font-weight: 700; }

.sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  -webkit-overflow-scrolling: touch;
}

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

.field-row .field { flex: 1; }

.sheet-hint { margin-top: 4px; }

/* ====================== 应收应付 ====================== */

.bal-box {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 11px 12px 10px;
  border: 1px solid #cfe9e4;
  background: linear-gradient(180deg, #f2fbf8, #ffffff);
  border-radius: 12px;
  text-align: left;
  cursor: pointer;
}

.bal-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.bal-cell { text-align: center; }

.bal-num { display: block; font-size: 16px; font-weight: 700; color: #111827; margin-top: 3px; }

.bal-num.income { color: #0f766e; }

.bal-num.expense { color: #c2410c; }

.bal-tip { margin-top: 8px; font-size: 11.5px; color: #7c8b92; text-align: center; }

.bal-sec { margin-bottom: 16px; }

.bal-sec:last-of-type { margin-bottom: 6px; }

.bal-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px dashed #e5ecee;
  font-size: 14px;
}

.bal-line:last-child { border-bottom: 0; }

.bal-name { color: #1f2937; }

.bal-amt { font-weight: 600; font-variant-numeric: tabular-nums; color: #4b5563; }

.bal-amt.income { color: #0f766e; }

.bal-amt.expense { color: #c2410c; }

.share-box {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid #e2e8ea;
  border-radius: 10px;
  background: #fbfdfd;
}

.share-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border-radius: 8px;
  background: #f4f8f8;
  font-size: 13.5px;
  color: #374151;
}

.share-item input { width: 15px; height: 15px; }


.sheet-actions {
  flex: none;
  display: flex;
  gap: 9px;
  padding: 11px 14px 14px;
  border-top: 1px solid #f1f5f6;
}

.sheet-actions .btn-primary { flex: 1; }

.sheet-actions .btn-ghost { flex: 0 0 auto; }

/* toast / 图片预览 */
.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  max-width: 78vw;
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(17, 24, 39, .88);
  color: #fff;
  font-size: 13.5px;
  line-height: 1.5;
  z-index: 40;
  text-align: center;
}

.img-viewer {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 18px;
}

.img-viewer img { max-width: 100%; max-height: 100%; border-radius: 8px; }
