:root {
  --bg: #f4f6f7;
  --card: #ffffff;
  --ink: #16211f;
  --ink-2: #5a6b68;
  --ink-3: #93a29f;
  --line: #e6ebea;
  --brand: #0e7c66;
  --brand-dark: #0a5f4e;
  --brand-soft: #e7f4f0;
  --danger: #d92d20;
  --danger-soft: #fdecea;
  --warn: #b54708;
  --warn-soft: #fef4e6;
  --ok: #067647;
  --ok-soft: #e8f5ee;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 16px -8px rgba(16, 24, 40, .12);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--brand); text-decoration: none; }

#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

/* ---------- 顶栏 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: calc(14px + env(safe-area-inset-top)) 20px 12px;
  background: rgba(244, 246, 247, .92);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}
.topbar h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.3px; }
.topbar .sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.topbar .action {
  font-size: 13px; color: var(--brand); font-weight: 600;
  padding: 8px 12px; border-radius: 999px; background: var(--brand-soft);
  white-space: nowrap;
}

.page { padding: 0 16px 24px; }

/* ---------- 金额总览卡 ---------- */

.hero {
  background: linear-gradient(135deg, #127a64 0%, #0a5f4e 100%);
  color: #fff;
  border-radius: 20px;
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: 0 10px 24px -12px rgba(10, 95, 78, .6);
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute;
  right: -40px; top: -60px;
  width: 160px; height: 160px;
  border-radius: 50%;
  background: rgba(255,255,255,.07);
}
.hero .label { font-size: 13px; opacity: .82; }
.hero .amount {
  font-size: 36px; font-weight: 750; letter-spacing: -1px;
  margin: 6px 0 16px; font-variant-numeric: tabular-nums;
}
.hero .amount small { font-size: 18px; font-weight: 600; opacity: .8; margin-right: 2px; }
.hero-row { display: flex; gap: 10px; }
.hero-chip {
  flex: 1;
  background: rgba(255,255,255,.12);
  border-radius: 12px;
  padding: 10px 12px;
}
.hero-chip .k { font-size: 11px; opacity: .8; }
.hero-chip .v { font-size: 18px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.hero-chip.alert { background: rgba(255, 138, 122, .28); }

/* ---------- 区块 ---------- */

.section-title {
  display: flex; align-items: center; justify-content: space-between;
  margin: 20px 4px 10px;
  font-size: 13px; font-weight: 600; color: var(--ink-2);
}
.section-title .count { color: var(--ink-3); font-weight: 500; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* ---------- 待办 / 账单行 ---------- */

.bill-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  width: 100%;
  text-align: left;
  background: var(--card);
  transition: background .12s;
}
.bill-item:last-child { border-bottom: none; }
.bill-item:active { background: #fafbfb; }

.avatar {
  width: 42px; height: 42px; flex: none;
  border-radius: 12px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  letter-spacing: -.3px;
}
.avatar.warn { background: var(--warn-soft); color: var(--warn); }
.avatar.danger { background: var(--danger-soft); color: var(--danger); }

.bill-main { flex: 1; min-width: 0; }
.bill-title { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 6px; }
.bill-sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.bill-right { text-align: right; flex: none; }
.bill-amount { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.bill-amount.muted { color: var(--ink-3); font-weight: 600; }

.badge {
  display: inline-block;
  font-size: 11px; font-weight: 600;
  padding: 2px 7px; border-radius: 6px;
  line-height: 1.6;
}
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.gray { background: #f0f2f2; color: var(--ink-3); }

.banner {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  background: var(--warn-soft); color: var(--warn);
  border-radius: 12px; padding: 11px 14px;
  font-size: 13.5px; font-weight: 600;
  margin-bottom: 12px;
}
.banner .n {
  flex: none; min-width: 20px; height: 20px; padding: 0 6px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 999px; background: var(--warn); color: #fff; font-size: 11px;
}

/* ---------- 房间卡 ---------- */

.room-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
}
.room-card:active { transform: scale(.995); }
.room-card .room-no {
  font-size: 18px; font-weight: 750; letter-spacing: -.5px;
  width: 56px; flex: none;
}
.room-card .room-no small { display: block; font-size: 11px; font-weight: 500; color: var(--ink-3); letter-spacing: 0; }
.room-meta { flex: 1; min-width: 0; }
.room-meta .t { font-size: 14px; font-weight: 600; }
.room-meta .d { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.room-price { text-align: right; flex: none; }
.room-price .p { font-weight: 700; font-variant-numeric: tabular-nums; }
.room-price .c { font-size: 11px; color: var(--ink-3); }

/* ---------- 详情 ---------- */

.detail-head {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.detail-head .big { display: flex; align-items: baseline; gap: 10px; }
.detail-head .big .n { font-size: 28px; font-weight: 750; letter-spacing: -1px; }
.detail-head .big .tag { font-size: 12px; }

.kv { display: grid; grid-template-columns: 84px 1fr; gap: 8px 12px; margin-top: 14px; font-size: 13px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; font-weight: 500; }

.actions { display: flex; gap: 10px; margin-top: 16px; }
.btn {
  flex: 1;
  border-radius: 12px;
  padding: 12px;
  font-weight: 650;
  font-size: 15px;
  background: #f1f3f3;
  color: var(--ink);
}
.btn.primary { background: var(--brand); color: #fff; }
.btn.ghost { background: var(--brand-soft); color: var(--brand-dark); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn:active { opacity: .85; }
.btn:disabled { opacity: .45; }

/* ---------- 流水 ---------- */

.pay-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}
.pay-item:last-child { border-bottom: none; }
.pay-icon {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  background: #f1f3f3; color: var(--ink-2);
}
.pay-icon.rent { background: var(--brand-soft); color: var(--brand-dark); }
.pay-main { flex: 1; min-width: 0; }
.pay-t { font-size: 14px; font-weight: 600; }
.pay-d { font-size: 12px; color: var(--ink-3); margin-top: 1px; }
.pay-a { font-weight: 700; font-variant-numeric: tabular-nums; }
.pay-a.neg { color: var(--danger); }

.month-head {
  font-size: 12px; font-weight: 600; color: var(--ink-3);
  padding: 16px 4px 8px;
  background: transparent;
}

/* ---------- 筛选 chips ---------- */

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 16px 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  padding: 7px 14px; border-radius: 999px;
  background: #fff; color: var(--ink-2);
  font-size: 13px; font-weight: 600;
  box-shadow: 0 1px 2px rgba(16,24,40,.05);
}
.chip.on { background: var(--ink); color: #fff; }

/* ---------- 底部 tab ---------- */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: 30;
  max-width: 520px; margin: 0 auto;
  background: rgba(255,255,255,.94);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--line);
  display: flex;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tab {
  flex: 1; text-align: center; padding: 6px 0;
  color: var(--ink-3); font-size: 11px; font-weight: 600;
}
.tab .ico { display: block; font-size: 19px; line-height: 1.35; }
.tab.on { color: var(--brand); }

/* ---------- 弹层 ---------- */

.sheet-mask {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(15, 23, 22, .42);
  display: flex; align-items: flex-end;
  animation: fade .16s ease-out;
}
.sheet {
  background: #fff;
  width: 100%; max-width: 520px; margin: 0 auto;
  border-radius: 22px 22px 0 0;
  padding: 8px 18px calc(20px + env(safe-area-inset-bottom));
  max-height: 88vh; overflow-y: auto;
  animation: up .22s cubic-bezier(.2,.8,.2,1);
}
.sheet-grip { width: 38px; height: 4px; border-radius: 2px; background: #d9e0df; margin: 8px auto 14px; }
.sheet h2 { margin: 0 0 4px; font-size: 18px; font-weight: 700; }
.sheet .hint { font-size: 12px; color: var(--ink-3); margin-bottom: 16px; }

@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes up { from { transform: translateY(20px); opacity: .6 } to { transform: none; opacity: 1 } }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 12px 13px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: #fafbfb;
  font-size: 15px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--brand); background: #fff;
  box-shadow: 0 0 0 3px rgba(14,124,102,.1);
}
.field .row2 { display: flex; gap: 10px; }
.field .row2 > * { flex: 1; }

.seg { display: flex; gap: 6px; }
.seg button {
  flex: 1; padding: 10px; border-radius: 10px;
  background: #f4f6f5; color: var(--ink-2); font-size: 13px; font-weight: 600;
}
.seg button.on { background: var(--brand); color: #fff; }

.quick-amounts { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.quick-amounts button {
  padding: 7px 12px; border-radius: 9px;
  background: #f1f3f3; font-size: 13px; font-weight: 600; color: var(--ink-2);
}

/* ---------- 登录 ---------- */

.login-wrap {
  min-height: 100vh;
  display: flex; flex-direction: column; justify-content: center;
  padding: 32px 28px calc(48px + env(safe-area-inset-bottom));
  max-width: 420px; margin: 0 auto;
}
.login-logo {
  width: 64px; height: 64px; border-radius: 20px;
  background: linear-gradient(135deg, #127a64, #0a5f4e);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 800;
  margin-bottom: 22px;
  box-shadow: 0 12px 24px -12px rgba(10,95,78,.7);
}
.login-wrap h1 { font-size: 26px; margin: 0 0 6px; letter-spacing: -.6px; }
.login-wrap p { color: var(--ink-3); font-size: 13px; margin: 0 0 28px; }
.login-wrap input {
  width: 100%; padding: 14px 16px; border-radius: 13px;
  border: 1px solid var(--line); background: #fff; font-size: 16px;
  margin-bottom: 12px; outline: none;
}
.login-wrap input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(14,124,102,.1); }
.login-wrap .btn {
  flex: 0 0 auto;
  align-self: flex-end;
  width: auto; min-width: 116px;
  padding: 11px 30px; border-radius: 11px; font-size: 15px;
}
.login-err { color: var(--danger); font-size: 13px; min-height: 20px; margin-bottom: 4px; }

/* ---------- 空态 ---------- */

.empty {
  text-align: center; padding: 46px 20px;
  color: var(--ink-3); font-size: 13px;
}
.empty .e-ico { font-size: 30px; margin-bottom: 8px; opacity: .5; }

/* ---------- toast ---------- */

#toast-root { position: fixed; inset: 0; pointer-events: none; z-index: 60; display: flex; align-items: center; justify-content: center; }
.toast {
  background: rgba(22,33,31,.92); color: #fff;
  padding: 11px 18px; border-radius: 12px;
  font-size: 14px; font-weight: 500;
  animation: fade .15s;
  max-width: 80vw; text-align: center;
}

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.stat-cell { background: #fff; border-radius: 14px; padding: 14px; box-shadow: var(--shadow); }
.stat-cell .k { font-size: 12px; color: var(--ink-3); }
.stat-cell .v { font-size: 20px; font-weight: 750; margin-top: 4px; font-variant-numeric: tabular-nums; }

.list-link {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 16px; border-bottom: 1px solid var(--line);
  width: 100%; text-align: left; background: #fff; font-size: 15px;
}
.list-link:last-child { border-bottom: none; }
.list-link .r { color: var(--ink-3); font-size: 13px; }
