/* ==========================================================================
   记账系统 · 前端样式（阶段5）
   移动优先，桌面端居中成 App 视图；无框架、无构建。
   配色：主色青绿 #12b3a6 / 辅助深蓝 #0f766e；支出红 #e5484d、收入绿 #12a150
   ========================================================================== */

/* ---------- 变量 ---------- */
:root {
  --brand: #12b3a6;
  --brand-dark: #0e9187;
  --brand-soft: #e6f7f5;
  --expense: #e5484d;
  --expense-soft: #fdecec;
  --income: #12a150;
  --income-soft: #e7f7ee;

  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1a2027;
  --text-2: #5b6673;
  --text-3: #96a0ac;
  --line: #e8ecf0;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .16);

  --tabbar-h: 58px;
  --app-max: 560px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

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

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body.modal-open { overflow: hidden; }

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

a { color: var(--brand-dark); }

.hidden { display: none !important; }

/* 金额等宽突出 */
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.amt-expense { color: var(--expense); }
.amt-income { color: var(--income); }

/* ---------- 应用外壳 ---------- */
#app {
  max-width: var(--app-max);
  margin: 0 auto;
  min-height: 100%;
  background: var(--bg);
  position: relative;
}

/* 桌面端：给 App 外壳一点边界感 */
@media (min-width: 640px) {
  body { background: #e9edf1; }
  #app {
    box-shadow: 0 0 0 1px rgba(16, 24, 40, .05), 0 8px 40px rgba(16, 24, 40, .10);
    min-height: 100vh;
  }
}

.page { padding: 12px 14px calc(var(--tabbar-h) + 28px); }
.page-title {
  font-size: 19px;
  font-weight: 700;
  margin: 4px 0 12px;
}

/* ---------- 顶部栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--brand);
  color: #fff;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
}
.topbar .tb-title { font-size: 17px; font-weight: 700; flex: 1; }
.topbar .tb-btn {
  background: rgba(255, 255, 255, .18);
  border: 0;
  color: #fff;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  cursor: pointer;
  min-height: 34px;
}
.topbar .tb-btn:active { background: rgba(255, 255, 255, .3); }

/* 账本切换器 */
.book-switch {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, .18);
  border: 0;
  color: #fff;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 14px;
  font-weight: 600;
  max-width: 62%;
  cursor: pointer;
}
.book-switch .bs-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.book-switch .caret { font-size: 10px; opacity: .9; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 12px;
}
.card-title {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title .sub {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-3);
}

/* 仪表盘 hero */
.hero {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 18px 16px;
  margin-bottom: 12px;
  box-shadow: 0 6px 20px rgba(18, 179, 166, .28);
}
.hero .hero-label {
  font-size: 13px;
  opacity: .92;
  margin-bottom: 4px;
}
.hero .hero-amount {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 40px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -1px;
  word-break: break-all;
}
.hero .hero-amount.over { color: #ffe08a; }
.hero .hero-sub {
  margin-top: 8px;
  font-size: 13px;
  opacity: .95;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
}
.hero .hero-period {
  font-size: 12px;
  opacity: .85;
  margin-top: 6px;
}

/* ---------- 统计块 ---------- */
.stat-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.stat-box {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
}
.stat-box .sb-label {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 4px;
}
.stat-box .sb-val {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 19px;
  font-weight: 700;
}

/* ---------- 条形占比 ---------- */
.bar-item { margin-bottom: 12px; }
.bar-item:last-child { margin-bottom: 0; }
.bar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 5px;
  gap: 8px;
}
.bar-head .bl {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.bar-head .bl .nm {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar-head .bv {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
  flex-shrink: 0;
}
.bar-track {
  height: 8px;
  background: #eef1f4;
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand) 0%, var(--brand-dark) 100%);
  transition: width .45s ease;
}
.bar-fill.warn { background: linear-gradient(90deg, #f5a524 0%, #e5484d 100%); }

/* ---------- 环形图 ---------- */
.donut-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
}
.donut {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
  background: #eef1f4;
}
.donut::after {
  content: "";
  position: absolute;
  inset: 26%;
  background: var(--card);
  border-radius: 50%;
}
.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2;
  text-align: center;
}
.donut-center .dc-label { font-size: 11px; color: var(--text-3); }
.donut-center .dc-val {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  font-weight: 700;
}
.donut-legend { flex: 1; min-width: 0; }
.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  margin-bottom: 7px;
}
.legend-item:last-child { margin-bottom: 0; }
.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  flex-shrink: 0;
}
.legend-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.legend-val {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
}

/* ---------- 柱状图（月度趋势） ---------- */
.chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 150px;
  padding-top: 18px;
}
.chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  position: relative;
}
.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 100%;
  width: 100%;
  justify-content: center;
}
.chart-bar {
  width: 45%;
  max-width: 18px;
  border-radius: 4px 4px 0 0;
  min-height: 3px;
  transition: height .45s ease;
}
.chart-bar.exp { background: linear-gradient(180deg, #f2777b 0%, var(--expense) 100%); }
.chart-bar.inc { background: linear-gradient(180deg, #4fc47f 0%, var(--income) 100%); }
.chart-val {
  position: absolute;
  top: -16px;
  font-size: 10px;
  color: var(--text-3);
  font-family: var(--mono);
  white-space: nowrap;
}
.chart-label {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 6px;
  flex-shrink: 0;
}

/* ---------- 流水列表 ---------- */
.day-group { margin-bottom: 12px; }
.day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-3);
  padding: 0 4px 6px;
}
.day-head .dh-sum { font-family: var(--mono); }
.rec-list {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.rec-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  background: var(--card);
  border-left: 0;
  border-right: 0;
  border-top: 0;
  width: 100%;
  text-align: left;
}
.rec-item:last-child { border-bottom: 0; }
.rec-item:active { background: #f7f9fa; }
.rec-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--brand-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
}
.rec-main { flex: 1; min-width: 0; }
.rec-cat {
  font-size: 14.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rec-note {
  font-size: 12px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 1px;
}
.rec-amt {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 15.5px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ---------- 空状态 / 加载 ---------- */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-3);
}
.empty .em-icon { font-size: 42px; margin-bottom: 10px; opacity: .75; }
.empty .em-text { font-size: 14px; }
.empty .em-hint { font-size: 12.5px; margin-top: 5px; opacity: .8; }

.loading {
  text-align: center;
  padding: 28px;
  color: var(--text-3);
  font-size: 13px;
}
.spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  margin: 0 auto 9px;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  background: var(--brand);
  color: #fff;
  min-height: 46px;
  transition: opacity .15s, background .15s;
  text-decoration: none;
}
.btn:active { opacity: .82; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-ghost {
  background: var(--card);
  color: var(--text);
  border-color: var(--line);
}
.btn-soft {
  background: var(--brand-soft);
  color: var(--brand-dark);
}
.btn-danger {
  background: var(--card);
  color: var(--expense);
  border-color: #f6c9cb;
}
.btn-danger-solid { background: var(--expense); color: #fff; }
.btn-sm {
  padding: 8px 12px;
  font-size: 13.5px;
  min-height: 38px;
  border-radius: 8px;
}
.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
.btn-row .btn { flex: 1; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 13px; }
.field label {
  display: block;
  font-size: 12.5px;
  color: var(--text-2);
  margin-bottom: 5px;
  font-weight: 600;
}
.input, .select, .textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: #fff;
  outline: none;
  min-height: 46px;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
  appearance: none;
}
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%2396a0ac' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.textarea { min-height: 74px; resize: vertical; }

/* 筛选栏 */
.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}
.filter-grid .full { grid-column: 1 / -1; }

/* ---------- 分类网格（记一笔） ---------- */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
@media (max-width: 360px) {
  .cat-grid { grid-template-columns: repeat(4, 1fr); }
}
.cat-cell {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 9px 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  transition: all .15s;
}
.cat-cell .cc-icon { font-size: 20px; line-height: 1.1; }
.cat-cell .cc-name {
  font-size: 11px;
  color: var(--text-2);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cat-cell.active {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.cat-cell.active .cc-name { color: var(--brand-dark); font-weight: 600; }

/* ---------- 类型切换（支出/收入） ---------- */
.seg {
  display: flex;
  background: #eef1f4;
  border-radius: 999px;
  padding: 3px;
  gap: 3px;
}
.seg button {
  flex: 1;
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 9px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  min-height: 40px;
}
.seg button.active {
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow);
}
.seg button.active.exp { color: var(--expense); }
.seg button.active.inc { color: var(--income); }

/* ---------- 记一笔：金额区 ---------- */
.amount-display {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 40px;
  font-weight: 700;
  padding: 10px 4px 8px;
  min-height: 62px;
  word-break: break-all;
  line-height: 1.1;
}
.amount-display .cur { font-size: 22px; color: var(--text-3); margin-right: 4px; }
.amount-display.exp { color: var(--expense); }
.amount-display.inc { color: var(--income); }

/* 数字键盘 */
.keypad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}
.key {
  border: 0;
  background: #f2f4f6;
  border-radius: var(--radius-sm);
  padding: 15px 0;
  font-size: 21px;
  font-family: var(--mono);
  font-weight: 600;
  cursor: pointer;
  min-height: 52px;
  user-select: none;
}
.key:active { background: #e4e8eb; }
.key.fn { font-size: 16px; background: #e9edf0; }
.key.ok {
  background: var(--brand);
  color: #fff;
  font-size: 16px;
}
.key.ok:active { background: var(--brand-dark); }
.key[disabled] { opacity: .45; }

/* ---------- 弹层 ---------- */
.mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 32, .45);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@media (min-width: 640px) {
  .mask { align-items: center; }
}
.sheet {
  background: var(--bg);
  width: 100%;
  max-width: var(--app-max);
  max-height: 92vh;
  border-radius: 18px 18px 0 0;
  display: flex;
  flex-direction: column;
  animation: slideUp .22s ease;
  overflow: hidden;
}
@media (min-width: 640px) {
  .sheet { border-radius: 18px; max-height: 86vh; }
}
@keyframes slideUp { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  flex-shrink: 0;
}
.sheet-head .sh-title { font-size: 16px; font-weight: 700; flex: 1; }
.sheet-head .sh-btn {
  border: 0;
  background: transparent;
  font-size: 14px;
  color: var(--text-2);
  cursor: pointer;
  padding: 6px 4px;
  min-height: 34px;
}
.sheet-head .sh-btn.primary { color: var(--brand-dark); font-weight: 700; }
.sheet-body {
  padding: 13px 14px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}
.sheet-foot {
  padding: 11px 14px calc(11px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: #fff;
  flex-shrink: 0;
}

/* ---------- 底部 Tab ---------- */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-max);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  display: flex;
  z-index: 40;
}
.tab {
  flex: 1;
  border: 0;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-3);
  cursor: pointer;
  font-size: 11px;
  padding: 0;
}
.tab .tab-icon { font-size: 19px; line-height: 1; }
.tab.active { color: var(--brand-dark); font-weight: 700; }

/* 悬浮记一笔 */
.fab {
  position: fixed;
  right: max(14px, calc(50% - var(--app-max) / 2 + 14px));
  bottom: calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom));
  z-index: 45;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  padding: 14px 20px;
  box-shadow: 0 6px 20px rgba(18, 179, 166, .42);
  cursor: pointer;
  min-height: 52px;
}
.fab:active { transform: scale(.96); }

/* ---------- 列表行（设置/管理） ---------- */
.list {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 12px;
}
.list-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
  width: 100%;
  text-align: left;
  border-left: 0;
  border-right: 0;
  border-top: 0;
}
.list-row:last-child { border-bottom: 0; }
.list-row.tappable { cursor: pointer; }
.list-row.tappable:active { background: #f7f9fa; }
.list-row .lr-main { flex: 1; min-width: 0; }
.list-row .lr-title {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.list-row .lr-sub {
  font-size: 12.5px;
  color: var(--text-3);
  margin-top: 2px;
}
.list-row .lr-right { flex-shrink: 0; color: var(--text-3); font-size: 13px; }

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 1.5px 7px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-weight: 600;
}
.badge.gray { background: #eef1f4; color: var(--text-2); }

/* ---------- Toast ---------- */
#toast-wrap {
  position: fixed;
  left: 50%;
  top: 16%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: max-content;
  max-width: 88vw;
}
.toast {
  background: rgba(26, 32, 39, .93);
  color: #fff;
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  max-width: 88vw;
  text-align: center;
  animation: toastIn .2s ease;
  word-break: break-word;
}
.toast.err { background: rgba(190, 40, 45, .96); }
.toast.ok { background: rgba(14, 145, 135, .96); }
@keyframes toastIn { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 登录页 ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px 20px;
  max-width: 420px;
  margin: 0 auto;
}
.auth-logo {
  text-align: center;
  margin-bottom: 26px;
}
.auth-logo .al-icon { font-size: 52px; line-height: 1; }
.auth-logo .al-name {
  font-size: 23px;
  font-weight: 800;
  margin-top: 10px;
  letter-spacing: 1px;
}
.auth-logo .al-slogan {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 5px;
}
.auth-tabs {
  display: flex;
  gap: 22px;
  margin-bottom: 18px;
  justify-content: center;
}
.auth-tab {
  border: 0;
  background: transparent;
  font-size: 16px;
  color: var(--text-3);
  padding: 6px 2px 9px;
  cursor: pointer;
  border-bottom: 2.5px solid transparent;
  font-weight: 600;
}
.auth-tab.active {
  color: var(--brand-dark);
  border-bottom-color: var(--brand);
}
.auth-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.auth-foot {
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
  margin-top: 18px;
  line-height: 1.7;
}

/* ---------- 预算 ---------- */
.budget-item {
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.budget-item:last-child { border-bottom: 0; padding-bottom: 0; }
.budget-top {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  margin-bottom: 6px;
}
.budget-top .bt-name { flex: 1; font-weight: 600; }
.budget-top .bt-num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  color: var(--text-2);
}
.budget-item.over .bt-name { color: var(--expense); }

/* ---------- 杂项 ---------- */
.muted { color: var(--text-3); font-size: 12.5px; }
.center { text-align: center; }
.mt8 { margin-top: 8px; }
.mt12 { margin-top: 12px; }
.nowrap { white-space: nowrap; }
.code-box {
  font-family: var(--mono);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 7px;
  text-align: center;
  padding: 14px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  border-radius: var(--radius-sm);
  user-select: all;
}
.link-row {
  word-break: break-all;
  font-size: 12px;
  color: var(--text-2);
  background: #f4f6f8;
  padding: 9px;
  border-radius: 8px;
  margin-top: 8px;
}
.divider { height: 1px; background: var(--line); margin: 12px 0; }
.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* ============================================================
   阶段 5d 追加样式：账本 / 预算 / 账户 / 分类 / 我的
   仅追加，不修改上方任何既有规则
   ============================================================ */

/* ---------- 5d 通用：返回条 ---------- */
.nav-back {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -4px 0 10px;
}
.nav-back .nb-btn {
  border: 0;
  background: transparent;
  color: var(--brand-dark);
  font-size: 14px;
  padding: 6px 4px;
  cursor: pointer;
}
.nav-back .nb-title {
  flex: 1;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.nav-back .nb-holder { width: 52px; }

/* ---------- 5d 账本页 ---------- */
.hero-slim {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
}
.hero-slim .hs-ico { font-size: 24px; }
.hero-slim .hs-body { flex: 1; min-width: 0; }
.hero-slim .hs-name {
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hero-slim .hs-sub { font-size: 12px; opacity: .88; margin-top: 2px; }
.hero-slim .hs-badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .22);
}

.bk-row { align-items: center; }
.bk-row.active { background: var(--brand-soft); }
.bk-row .lr-title { display: flex; align-items: center; gap: 6px; }
.badge-cur {
  background: var(--brand);
  color: #fff;
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 999px;
}

.bm-ops { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.bm-ops .btn { padding: 4px 10px; font-size: 12px; }

/* ---------- 5d 预算页 ---------- */
.bg-amt {
  width: 96px;
  text-align: right;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 14px;
  background: #fff;
}
.bg-amt:focus { outline: none; border-color: var(--brand); }
.bg-amt.dirty { border-color: #f0a020; background: #fffdf5; }

/* ---------- 5d 分类管理 ---------- */
.icon-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}
.icon-cell {
  aspect-ratio: 1 / 1;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-cell.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: 0 0 0 1px var(--brand) inset;
}
.cat-manage .lr-title { display: flex; align-items: center; gap: 6px; }

/* ---------- 5d 我的页 ---------- */
.me-profile { display: flex; align-items: center; gap: 12px; }
.me-avatar {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.me-info { flex: 1; min-width: 0; }
.me-name { font-size: 17px; font-weight: 700; color: var(--text); }

/* ---------- 5d 弹层补丁：只有底部按钮的面板 ---------- */
.sheet-foot-only .sheet-head { border-bottom: 0; }
.sheet-foot-only .sheet-body { padding-top: 4px; }

/* ---------- 5d 小屏适配 ---------- */
@media (max-width: 340px) {
  .icon-grid { grid-template-columns: repeat(6, 1fr); }
  .code-box { font-size: 25px; letter-spacing: 5px; }
}

/* ==========================================================================
   S7批次：iOS 快捷记账（阶段7）
   追加式补丁，不改动以上任何既有规则。
   ========================================================================== */

.s7-intro {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-2);
  background: var(--brand-soft);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  margin-bottom: 12px;
}

.s7-actions { display: flex; gap: 10px; }
.s7-actions .btn { flex: 1; }

/* 请求地址展示块：等宽字体 + 可换行，长 URL 不会被截断 */
.s7-url {
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-2);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-top: 8px;
  word-break: break-all;
  white-space: pre-wrap;
  user-select: all;
}
.s7-url.muted { color: var(--text-3); }

/* 新生成的完整令牌：仅此一次展示，用醒目底色提示「快复制」 */
.s7-fresh { border: 1px solid var(--brand); }
.s7-token-full {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  background: var(--brand-soft);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  word-break: break-all;
  user-select: all;
}

.s7-warn {
  font-size: 12px;
  line-height: 1.6;
  color: var(--expense);
  margin-top: 10px;
}

/* 令牌列表行 */
.s7-token-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.s7-token-row:last-child { border-bottom: 0; }
.s7-token-row.off { opacity: .55; }
.s7-token-row .lr-main { flex: 1; min-width: 0; }
.s7-token-row .lr-title {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.s7-token-row .lr-sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 3px;
  word-break: break-all;
}
.s7-revoke { flex: none; }

.s7-tag {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-3);
  background: var(--bg);
  border-radius: 4px;
  padding: 1px 6px;
}

/* 可折叠教程 */
.card-title.tappable { cursor: pointer; }
.card-title.tappable:active { opacity: .7; }
.s7-guide { margin-top: 4px; }
.s7-step {
  font-size: 13px;
  line-height: 1.75;
  color: var(--text-2);
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
}
.s7-step:last-child { border-bottom: 0; padding-bottom: 0; }
.s7-step b { color: var(--text); }
.s7-step code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--brand-dark);
  background: var(--brand-soft);
  border-radius: 4px;
  padding: 1px 5px;
}

/* =====================================================================
 * 阶段8 · 最近记账记录（操作日志）
 * 只追加，不改上面任何既有规则。
 * ===================================================================== */

/* 弹层内说明文字 */
.s8-hint {
  margin: 0 0 10px;
  line-height: 1.6;
}

/* 列表容器 */
.s8-log-list { border-top: 1px solid var(--line); }

/* 单行日志：原话可能较长，允许换行且不撑破布局 */
.s8-log-row { align-items: flex-start; }
.s8-log-row .s8-lr-raw {
  word-break: break-all;
  white-space: normal;
  line-height: 1.45;
}

/* 右侧结果区：金额 + 分类·日期 两行右对齐 */
.s8-lr-right {
  text-align: right;
  max-width: 42%;
  flex-shrink: 0;
}
.s8-lr-amount {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.s8-lr-cat {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
  word-break: break-all;
}
/* 解析失败：红字，一眼区分于成功 */
.s8-lr-fail {
  font-size: 13px;
  font-weight: 600;
  color: var(--expense);
}
.s8-log-row .s8-lr-fail + .s8-lr-cat { color: var(--text-3); }

/* 空态 / 加载中 */
.s8-empty {
  padding: 18px 4px;
  text-align: center;
  line-height: 1.7;
}

/* ---------- 记一笔/编辑：底部中间悬浮保存按钮 (2026-10-14) ---------- */
.sheet-save-fab {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 20;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  padding: 14px 40px;
  min-height: 50px;
  box-shadow: 0 6px 20px rgba(18, 179, 166, .42);
  cursor: pointer;
}
.sheet-save-fab:active { transform: translateX(-50%) scale(.96); }
.sheet-save-fab:disabled { opacity: .6; cursor: default; }
/* 给 body 底部留出悬浮按钮的空间，避免遮挡最后一行字段 */
.sheet-body { padding-bottom: 84px; }
