/**
 * 网页版样式 —— 沿用小程序端的设计语言（浅灰底 + 白卡片 + 品牌蓝）。
 * 数值口径与小程序一致：卡片圆角 14、主色 #2F5597、超支红 #C00000、正向绿 #2E7D32。
 * 移动优先；桌面浏览器上限制最大宽度，观感不散。
 */

:root {
  --ink: #1F2733;
  --ink-2: #5A6270;
  --muted: #8A8F99;
  --line: #EEF0F3;
  --bg: #F5F6F8;
  --brand: #2F5597;
  --brand-ink: #1F3864;
  --hot: #C00000;
  --ok: #2E7D32;
  --warn: #E8A33D;
  --tabbar-h: 56px;
  --topbar-h: 48px;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  /* 手机上禁用下拉刷新与橡皮筋，避免记账时误触 */
  overscroll-behavior-y: none;
}

button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, textarea { font-family: inherit; font-size: inherit; color: var(--ink); }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.center { text-align: center; }
.hot { color: var(--hot); }
.ok { color: var(--ok); }

/* ---------------- 顶部栏 / 底部标签 ---------------- */
#topbar {
  position: sticky; top: 0; z-index: 20;
  background: #fff; border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  max-width: 720px; margin: 0 auto; height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between; padding: 0 8px;
}
.topbar-title { font-weight: 600; color: var(--brand-ink); font-size: 16px; }
.topbar-back {
  min-width: 72px; background: none; border: 0; color: var(--brand);
  font-size: 15px; padding: 8px; text-align: left;
}
.topbar-back.placeholder { visibility: hidden; }

#app {
  max-width: 720px; margin: 0 auto;
  padding: 12px 12px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px);
}
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; height: var(--tabbar-h); border: 0; background: none;
  color: var(--muted); font-size: 14px;
}
.tab.active { color: var(--brand); font-weight: 600; }

/* ---------------- 卡片 ---------------- */
.card {
  background: #fff; border-radius: 14px; padding: 14px 16px; margin-bottom: 12px;
  box-shadow: 0 1px 6px rgba(31, 39, 51, .06);
}
.card-title {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  font-weight: 600; color: var(--brand-ink); margin-bottom: 12px; font-size: 15px;
}

/* ---------------- 指标 / 进度 ---------------- */
.metric-grid { display: flex; gap: 10px; }
.metric-item { flex: 1; background: #F7F8FA; border-radius: 12px; padding: 12px; }
.metric-item .label { color: var(--muted); font-size: 12.5px; }
.metric-item .value { font-size: 20px; font-weight: 600; margin-top: 4px; letter-spacing: .3px; }
.progress-track {
  height: 8px; border-radius: 4px; background: #EDEFF3; overflow: hidden; margin: 14px 0 6px;
}
.progress-fill {
  height: 100%; border-radius: 4px; background: var(--brand);
  transition: width .35s ease;
}
.progress-fill.warn { background: var(--warn); }
.progress-fill.over { background: var(--hot); }

/* ---------------- 行 / 流水 ---------------- */
.row {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 0; border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: none; }
.row.no-border { border-bottom: none; padding: 2px 0; }
.row-main { flex: 1; min-width: 0; }
.row-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row-label { color: var(--ink-2); }
.row-value { font-variant-numeric: tabular-nums; }
.row .note {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 42vw;
}
.tappable { border-radius: 10px; }
.tappable:active { background: #F3F5F9; }

.tag {
  display: inline-block; font-size: 11.5px; line-height: 1.7; padding: 0 7px;
  border-radius: 6px; background: #EEF1F6; color: var(--ink-2); flex: none;
}
.tag-daily { background: #EEF3FC; color: var(--brand); }
.tag-extra { background: #FDF3E6; color: #A96A12; }
.tag-extra-plus { background: #F6ECFA; color: #7A3E9D; }
.tag-income { background: #E8F5E9; color: var(--ok); }

.amount { font-variant-numeric: tabular-nums; font-weight: 600; }
.amount-md { font-size: 17px; }
.empty { color: var(--muted); text-align: center; padding: 18px 0; font-size: 14px; }

/* ---------------- 提示条 ---------------- */
.notice {
  border-radius: 10px; padding: 10px 12px; font-size: 13px; line-height: 1.7; margin: 10px 0;
}
.notice-info { background: #EEF3FC; color: var(--brand-ink); }
.notice-warn { background: #FDF6E7; color: #8A5A0B; }
.notice-error { background: #FDEEEE; color: #A02020; }

/* ---------------- 按钮 ---------------- */
.btn {
  display: block; width: 100%; border: 0; border-radius: 10px;
  padding: 12px 0; font-size: 15px; font-weight: 600; background: #EDEFF3; color: var(--ink);
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-ghost { background: #fff; color: var(--brand); border: 1px solid #C9D4E8; }
.btn-danger { background: #fff; color: var(--hot); border: 1px solid #F0C9C9; }
.btn-lg { padding: 15px 0; font-size: 16px; }
.btn.disabled { opacity: .45; }
.btn-wrap { margin: 4px 0 18px; display: flex; flex-direction: column; gap: 10px; }

/* ---------------- 胶囊选择 ---------------- */
.chip-wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  border-radius: 999px; padding: 7px 14px; font-size: 13.5px;
}
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.chip-add { border-style: dashed; color: var(--brand); border-color: #C9D4E8; }

/* ---------------- 表单 ---------------- */
.amount-input-wrap {
  display: flex; align-items: baseline; gap: 6px; border-bottom: 2px solid var(--line);
  padding-bottom: 6px;
}
.amount-input-wrap .currency { font-size: 22px; color: var(--muted); }
.amount-input {
  flex: 1; border: 0; outline: none; font-size: 32px; font-weight: 600;
  letter-spacing: .5px; font-variant-numeric: tabular-nums; background: none;
}
.field { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.field-label { color: var(--ink-2); flex: none; min-width: 96px; }
.field-input {
  flex: 1; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; outline: none; background: #FBFCFD; min-width: 0;
}
.field-input:focus { border-color: var(--brand); background: #fff; }
.field-hint { margin: -2px 0 10px; }
.note-input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; outline: none; background: #FBFCFD;
}
.note-input:focus { border-color: var(--brand); background: #fff; }

/* ---------------- 类型选择 ---------------- */
.type-item {
  display: flex; align-items: center; gap: 10px; padding: 12px 2px;
  border-bottom: 1px solid var(--line);
}
.type-item:last-child { border-bottom: none; }
.type-item.active .type-label { color: var(--brand); font-weight: 600; }
.type-radio {
  width: 20px; height: 20px; border-radius: 50%; border: 2px solid #C9D4E8;
  flex: none; display: flex; align-items: center; justify-content: center;
}
.type-item.active .type-radio { border-color: var(--brand); }
.type-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
.type-label { font-size: 15px; }

/* ---------------- 动作行 ---------------- */
.action-row {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  padding: 12px 2px; border-bottom: 1px solid var(--line);
}
.action-row:last-child { border-bottom: none; }
.action-row:active { background: #F7F8FA; }
.action-row.danger .action-name { color: var(--hot); }
.action-name { font-size: 15px; }

/* ---------------- 遮罩 / 面板 / 提示 ---------------- */
.mask {
  position: fixed; inset: 0; z-index: 60; background: rgba(20, 24, 32, .45);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; transition: opacity .16s ease;
}
.mask.in { opacity: 1; }
.mask-sheet { align-items: flex-end; padding: 0; }
.panel {
  width: 100%; max-width: 420px; background: #fff; border-radius: 16px;
  padding: 18px 16px 14px; transform: scale(.96); transition: transform .16s ease;
}
.mask.in .panel { transform: scale(1); }
.panel-sheet {
  border-radius: 16px 16px 0 0; padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  transform: translateY(12px);
}
.mask.in .panel-sheet { transform: translateY(0); }
.panel-title { font-weight: 600; color: var(--brand-ink); font-size: 16px; margin-bottom: 8px; }
.panel-body { color: var(--ink-2); font-size: 14px; line-height: 1.75; margin-bottom: 14px; word-break: break-word; }
.panel-input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; outline: none; background: #FBFCFD; margin-bottom: 14px;
}
.panel-input:focus { border-color: var(--brand); background: #fff; }
.panel-actions { display: flex; gap: 10px; }
.sheet-item {
  display: block; width: 100%; border: 0; background: #fff; text-align: center;
  padding: 15px 0; font-size: 16px; border-bottom: 1px solid var(--line); color: var(--ink);
}
.sheet-item.danger { color: var(--hot); }
.sheet-cancel { border-bottom: none; color: var(--muted); margin-top: 6px; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 28px); z-index: 80;
  transform: translate(-50%, 8px); background: rgba(31, 39, 51, .92); color: #fff;
  padding: 10px 18px; border-radius: 10px; font-size: 14px; max-width: 84vw;
  text-align: center; opacity: 0; transition: all .2s ease; pointer-events: none;
}
.toast.in { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- 月份导航 / 分段控制（统计页） ---------------- */
.month-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.month-label { flex: 1; text-align: center; font-weight: 600; color: var(--brand-ink); font-size: 16px; }
.nav-btn {
  width: 40px; height: 34px; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; color: var(--brand); font-size: 18px; line-height: 1;
}
.nav-btn.disabled { color: #C7CCD4; }
.segment {
  display: flex; background: #fff; border-radius: 12px; padding: 4px;
  margin-bottom: 12px; box-shadow: 0 1px 6px rgba(31, 39, 51, .06);
}
.segment-item {
  flex: 1; border: 0; background: none; padding: 9px 0; border-radius: 9px;
  color: var(--ink-2); font-size: 14px;
}
.segment-item.active { background: var(--brand); color: #fff; font-weight: 600; }

/* ---------------- 热力日历 ---------------- */
.heat-head, .heat-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.heat-head { margin-bottom: 4px; }
.heat-h { text-align: center; color: var(--muted); font-size: 12px; }
.heat-cell {
  aspect-ratio: 1 / 1; border-radius: 9px; background: #F1F3F7;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; font-size: 12px; color: var(--ink-2); border: 1px solid transparent;
}
.heat-cell.empty-cell { background: none; }
.heat-day { font-size: 12.5px; }
.heat-amt { font-size: 10px; color: #fff; opacity: .95; font-variant-numeric: tabular-nums; }
.heat-cell.weekend .heat-day { color: var(--muted); }
.heat-cell.today { border-color: var(--brand); font-weight: 600; }
.heat-cell.picked { border-color: var(--hot); box-shadow: 0 0 0 2px rgba(192, 0, 0, .15); }
.heat-1 { background: #DCE6F7; color: var(--ink-2); }
.heat-1 .heat-amt { color: var(--ink-2); }
.heat-2 { background: #A9C1E8; }
.heat-3 { background: #6E93CD; }
.heat-4 { background: var(--brand); }
.heat-legend { display: flex; align-items: center; gap: 4px; margin-top: 10px; }
.heat-dot { width: 12px; height: 12px; border-radius: 3px; background: #F1F3F7; }
.heat-dot.heat-1 { background: #DCE6F7; }
.heat-dot.heat-2 { background: #A9C1E8; }
.heat-dot.heat-3 { background: #6E93CD; }
.heat-dot.heat-4 { background: var(--brand); }

/* ---------------- 柱状图 ---------------- */
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 190px; padding-top: 18px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar-val { font-size: 10.5px; color: var(--muted); margin-bottom: 3px; font-variant-numeric: tabular-nums; }
.bar-track { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.bar-fill {
  width: 100%; border-radius: 6px 6px 3px 3px; background: #A9C1E8; min-height: 2px;
  transition: height .3s ease;
}
.bar-fill.max { background: var(--brand); }
.bar-fill.current { background: var(--hot); }
.bar-label { font-size: 11.5px; color: var(--muted); margin-top: 5px; }

/* ---------------- 日明细 ---------------- */
.day-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.day-row:last-child { border-bottom: none; }
.day-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.day-date { font-size: 14.5px; font-weight: 600; color: var(--brand-ink); }
.day-cells { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.day-cell {
  font-size: 11.5px; background: #F3F5F9; color: var(--ink-2);
  border-radius: 6px; padding: 2px 7px; font-variant-numeric: tabular-nums;
}
.note-line { margin-top: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------- 资产页 ---------------- */
.card.hero { text-align: center; padding: 18px 16px; }
.amount-lg { font-size: 30px; margin: 6px 0; }
.month-block { padding: 11px 0; border-bottom: 1px solid var(--line); }
.month-block:last-child { border-bottom: none; }
.month-line { line-height: 1.8; }

/* ---------------- 分类管理 ---------------- */
.cat-name { font-size: 15px; font-weight: 600; }
.cat-kw {
  margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 74vw;
}

/* ---------------- 分类占比（统计页） ---------------- */
.cat-row { padding: 7px 0; }
.cat-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.cat-track { height: 6px; border-radius: 3px; background: #EDEFF3; margin-top: 5px; overflow: hidden; }
.cat-fill { height: 100%; border-radius: 3px; background: #6E93CD; }
.cat-fill.meal { background: var(--brand); }

/* ---------------- 开关（月度结转） ---------------- */
.toggle {
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 999px; padding: 5px 16px; font-size: 13.5px; font-weight: 600;
}
.toggle.on { background: var(--brand); border-color: var(--brand); color: #fff; }
