:root {
  --bg: #f4f6f5;
  --card: #ffffff;
  --text: #1c2a27;
  --muted: #6b7a76;
  --faint: #9aa7a3;
  --line: #e3e8e6;
  --brand: #0f766e;
  --brand-soft: #e6f4f1;
  --brand-ink: #ffffff;
  --warn: #b45309;
  --warn-soft: #fef3e2;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --ok: #1e8449;
  --ok-soft: #e8f6ee;
  --shadow: 0 1px 2px rgba(16, 40, 34, .05), 0 4px 16px rgba(16, 40, 34, .05);
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1514;
    --card: #18201e;
    --text: #e6eeec;
    --muted: #9fb0ab;
    --faint: #6f817c;
    --line: #26312e;
    --brand: #2bb3a3;
    --brand-soft: #16302c;
    --brand-ink: #062521;
    --warn: #f0a945;
    --warn-soft: #33270f;
    --danger: #ff7b6e;
    --danger-soft: #3a1d1a;
    --ok: #4cc782;
    --ok-soft: #15301f;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.num, .amount { font-variant-numeric: tabular-nums; }

/* 顶栏与导航 */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { max-width: 880px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 16px; }
.brand { font-weight: 700; font-size: 17px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.brand img { width: 26px; height: 26px; border-radius: 7px; }
.brand:hover { text-decoration: none; }
.topnav { display: none; margin-left: auto; gap: 4px; }
.topnav a { color: var(--muted); padding: 6px 12px; border-radius: 999px; font-size: 14px; }
.topnav a.on, .topnav a:hover { background: var(--brand-soft); color: var(--brand); text-decoration: none; }
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--card); border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); padding: 2px 0; }
.tabbar a svg { width: 23px; height: 23px; }
.tabbar a.on { color: var(--brand); }
.tabbar a.add svg { width: 30px; height: 30px; margin-top: -3px; }
.tabbar a:hover { text-decoration: none; }
@media (min-width: 760px) {
  .topnav { display: flex; }
  .tabbar { display: none; }
  body { padding-bottom: 0; }
}

.container { max-width: 880px; margin: 0 auto; padding: 16px; }
h1 { font-size: 22px; margin: 4px 0 14px; letter-spacing: .2px; }
h2 { font-size: 16px; margin: 22px 0 10px; color: var(--muted); font-weight: 600; }
h2:first-child { margin-top: 4px; }
.sub { color: var(--muted); font-size: 13px; }
.faint { color: var(--faint); }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.right { text-align: right; }
.mt { margin-top: 14px; }
.hide { display: none !important; }

/* 卡片 */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px; border: 1px solid var(--line); }
.card.flush { padding: 0; overflow: hidden; }
.card h3 { font-size: 16px; margin: 0 0 10px; }
.card .card-foot { border-top: 1px solid var(--line); margin: 14px -16px -16px; padding: 10px 16px; font-size: 13px; color: var(--muted); }

/* 首页大数字 */
.hero { background: linear-gradient(135deg, #0f766e, #115e59 60%, #134e4a); color: #fff; border: 0; }
.hero .hero-label { color: rgba(255, 255, 255, .86); font-size: 13px; }
.hero .big { font-size: 34px; font-weight: 700; letter-spacing: .3px; margin: 2px 0 6px; }
.hero .meta { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; opacity: .92; }
.hero .meta b { font-weight: 600; }
.hero .next { margin-top: 12px; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, .18); font-size: 14px; }
@media (prefers-color-scheme: dark) { .hero { background: linear-gradient(135deg, #115e59, #0d3d39); } }

/* 提示条 */
.notice { border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; font-size: 14px; border: 1px solid transparent; }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice.error { background: var(--danger-soft); color: var(--danger); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.info { background: var(--brand-soft); color: var(--brand); }
.notice a { font-weight: 600; }

/* 日期分组 */
.day { margin-bottom: 12px; }
.day-head { display: flex; align-items: baseline; justify-content: space-between; padding: 0 4px 6px; }
.day-head .d { font-weight: 600; }
.day-head .d .w { color: var(--muted); font-weight: 400; margin-left: 4px; font-size: 13px; }
.day-head .t { font-size: 13px; color: var(--muted); }

/* 账单行 */
.bill { display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.bill:last-child { border-bottom: 0; }
.bill .ico { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none; font-size: 15px; font-weight: 700; color: var(--brand); background: var(--brand-soft); }
.bill .ico.loan { color: #7c3aed; background: color-mix(in srgb, #7c3aed 12%, transparent); }
.bill .ico.other { color: var(--warn); background: var(--warn-soft); }
.bill .info { flex: 1; min-width: 0; }
.bill .name { font-weight: 600; overflow-wrap: anywhere; line-height: 1.4; }
.bill .name a { color: inherit; }
.bill .meta { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 2px; }
.bill .money { text-align: right; flex: none; }
.bill .money .amount { font-size: 17px; font-weight: 700; }
.bill .money .min { font-size: 12px; color: var(--muted); }
.bill.paid .amount, .bill.skipped .amount { color: var(--faint); text-decoration: line-through; text-decoration-thickness: 1px; }
.bill .act { flex: none; }

.chip { display: inline-block; font-size: 11.5px; line-height: 1; padding: 4px 7px; border-radius: 999px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.chip.soon { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.today, .chip.over { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.chip.paid { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip.brand { background: var(--brand-soft); color: var(--brand); border-color: transparent; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 10px; padding: 9px 16px; font: inherit; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.btn:hover { text-decoration: none; border-color: var(--brand); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 9px; }
.btn.pay { border-color: var(--brand); color: var(--brand); background: transparent; font-weight: 600; }
.btn.pay:hover { background: var(--brand-soft); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; }
form.inline { display: inline; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

/* 表单 */
.field { margin-bottom: 14px; }
.field label, .label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field .hint { font-size: 12.5px; color: var(--faint); margin-top: 4px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=month], input[type=time], input[type=email], input[type=url], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none; min-height: 42px;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { min-height: 84px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .grid2.collapse { grid-template-columns: 1fr; } }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--brand); flex: none; }
.check .t { font-size: 14.5px; }
.check .t small { display: block; color: var(--faint); font-size: 12.5px; }
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg label { margin: 0; }
.seg input { display: none; }
.seg span { display: block; padding: 6px 12px; border-radius: 8px; font-size: 13.5px; color: var(--muted); cursor: pointer; }
.seg input:checked + span { background: var(--card); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }

.pills { display: inline-flex; gap: 2px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; flex-wrap: wrap; }
.pills a { padding: 6px 11px; border-radius: 8px; font-size: 13px; color: var(--muted); }
.pills a.on { background: var(--card); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.pills a:hover { text-decoration: none; color: var(--text); }

/* 月份切换 */
.month-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.month-nav .cur { font-size: 20px; font-weight: 700; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 17px; font-weight: 700; }

/* 设置页 */
.settings-nav { display: flex; gap: 6px; overflow-x: auto; margin: 0 -16px 12px; padding: 0 16px 4px; scrollbar-width: none; }
.settings-nav a { flex: none; font-size: 13px; padding: 6px 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--muted); }
.channel { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.channel:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
.copy { display: flex; gap: 8px; }
.copy input { font-size: 12.5px; }
details { margin-top: 8px; }
details summary { cursor: pointer; color: var(--brand); font-size: 13.5px; }
.steps { padding-left: 20px; margin: 8px 0; font-size: 13.5px; color: var(--muted); }
.steps li { margin-bottom: 4px; }
pre.mail { white-space: pre-wrap; word-break: break-all; font-size: 12.5px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px; max-height: 420px; overflow: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.list td { padding: 8px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tr:last-child td { border-bottom: 0; }

.empty { text-align: center; padding: 28px 16px; color: var(--muted); }
.empty .big { font-size: 34px; }
.credit { text-align: right; font-size: 11px; color: var(--faint); opacity: .8; padding: 22px 2px 6px; letter-spacing: .2px; }
.credit a { color: inherit; }
.changes { margin: 6px 0 0; padding-left: 20px; line-height: 1.7; }

/* 登录页 */
.login-wrap { min-height: 82vh; display: grid; place-items: center; }
.login { width: 100%; max-width: 360px; }
.login .logo { width: 56px; height: 56px; border-radius: 15px; display: block; margin: 0 auto 10px; }
.login h1 { text-align: center; }
