/* ============================================================
   我的账本 · 清新薄荷设计系统
   纸感底色 + 薄荷绿点缀 + 衬线数字，安静清爽的手账气质
   ============================================================ */

:root {
  --accent: #10b981;
  --accent-strong: #0d9d70;
  --accent-soft: #e3f6ee;
  --accent-fade: #d5efe4;
  --ink: #26332c;
  --ink-2: #5b6b62;
  --ink-3: #93a49b;
  --paper: #f6f8f4;
  --card: #ffffff;
  --line: #e4ebe5;
  --danger: #d96a4f;
  --danger-soft: #fbeae4;
  --warn: #d9a44f;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(38, 51, 44, .05), 0 6px 24px -12px rgba(38, 51, 44, .12);
  --shadow-lg: 0 12px 40px -12px rgba(38, 51, 44, .25);
  --font-body: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --font-display: Georgia, "Times New Roman", "STZhongsong", serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

/* 纸感颗粒 + 顶部薄荷晕染 */
.page-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 340px at 18% -6%, rgba(16, 185, 129, .10), transparent 64%),
    radial-gradient(700px 300px at 92% -4%, rgba(14, 165, 233, .05), transparent 60%),
    var(--paper);
}
.page-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .04 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection { background: var(--accent-fade); }

a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  background: rgba(246, 248, 244, .74);
  /* 极细分界 + 柔和下投影，替代生硬的 border 线 */
  box-shadow: 0 1px 0 rgba(228, 235, 229, .55), 0 10px 28px -20px rgba(38, 51, 44, .3);
}
.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
  height: 60px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
.brand {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px 6px 10px;
  margin-left: -10px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 16.5px;
  color: var(--ink);
  letter-spacing: .3px;
  transition: background .18s;
}
.brand:hover { text-decoration: none; background: rgba(227, 246, 238, .75); }
.brand-icon { width: 21px; height: 21px; flex: 0 0 auto; }
.main-nav { display: flex; gap: 4px; justify-self: center; }
.main-nav a {
  color: var(--ink-2);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 14.5px;
  transition: all .18s;
}
.main-nav a:hover { color: var(--ink); text-decoration: none; background: var(--accent-soft); }
.main-nav a.active {
  color: var(--accent-strong);
  background: linear-gradient(135deg, var(--accent-soft), var(--accent-fade));
  box-shadow: inset 0 0 0 1px rgba(16, 185, 129, .14), 0 2px 10px -4px rgba(16, 185, 129, .4);
  font-weight: 600;
}
/* 右侧两分组：账本切换 | 账户（用户胶囊+弹出菜单） */
.topbar-user { display: flex; align-items: center; gap: 6px; justify-self: end; }
.user-menu { position: relative; }
.username {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border: 0;
  border-radius: 999px;
  background: rgba(38, 51, 44, .055);
  color: var(--ink-2);
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  transition: background .18s;
}
.username:hover { background: rgba(38, 51, 44, .09); }
.username-name {
  max-width: 8em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-avatar { width: 16px; height: 16px; flex: 0 0 auto; opacity: .85; }
.user-caret { width: 10px; height: 6px; flex: 0 0 auto; opacity: .45; transition: transform .18s; }
.username[aria-expanded="true"] .user-caret { transform: rotate(180deg); }
.user-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 148px;
  padding: 6px;
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 90;
  animation: rise .22s ease both;
}
.user-dropdown form { margin: 0; }
.user-dropdown-item {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 9px;
  background: none;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ink-2);
  text-align: left;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.user-dropdown-item:hover { background: var(--accent-soft); color: var(--accent-strong); }

/* ---------- 主容器 ---------- */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 96px;
}
.container > * { animation: rise .45s ease both; }
.container > *:nth-child(2) { animation-delay: .05s; }
.container > *:nth-child(3) { animation-delay: .1s; }
.container > *:nth-child(4) { animation-delay: .15s; }
.container > *:nth-child(5) { animation-delay: .2s; }
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}
.card-title { font-weight: 700; font-size: 15.5px; }
.card-side { color: var(--ink-3); font-size: 13px; }
.card-side.link { color: var(--accent-strong); }

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.two-col .card { margin-bottom: 0; }
.two-col + .two-col { margin-top: 18px; }

/* ---------- 统计卡片 ---------- */
/* 概览/收支统计卡：单卡多列，居中对齐带竖分隔线 */
.stat-month { margin-bottom: 18px; }
.stat-month .card-head { margin-bottom: 4px; }
.stat-month-grid { display: grid; grid-template-columns: repeat(3, 1fr); }
.stat-month-grid > * { min-width: 0; }
.stat-month-item { text-align: center; padding: 6px 8px; }
.stat-month-item + .stat-month-item { border-left: 1px solid var(--line); }
.stat-month-item .stat-num { font-size: clamp(19px, 6vw, 28px); white-space: nowrap; margin-top: 2px; }
/* 概览卡内今日小字：虚线分隔月度数据 */
.stat-today-note {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  text-align: center;
  font-size: 17px;
  color: var(--ink-2);
}
.stat-today-note .stat-income { font-size: 17px; }

/* 概览卡内嵌预算进度 */
.stat-month-budget { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.stat-month-budget-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}
.stat-month-budget-head > * { min-width: 0; }
.stat-month-budget-note { font-size: 12.5px; color: var(--ink-3); }
.stat-month-budget .progress { height: 8px; }
.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 20px;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--accent);
  opacity: .55;
  border-radius: 4px 0 0 4px;
}
/* 概览卡：去掉边框，仅保留柔和阴影分层（必须放在 .stat-card 之后） */
.stat-card-tinted { border: none; }
.stat-label { color: var(--ink-3); font-size: 17px; font-weight: 600; }
.stat-num {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: .5px;
  margin-top: 2px;
}
.stat-income { color: var(--accent-strong); }
.stat-balance { color: #2b7fbf; }
.stat-negative { color: var(--danger); }

/* ---------- 预算进度条 ---------- */
.progress {
  height: 12px;
  background: var(--accent-soft);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #6ee7b7, var(--accent));
  border-radius: 999px;
  transition: width .6s ease;
}
.progress-warn { background: linear-gradient(90deg, #f3d29b, var(--warn)); }
.progress-over { background: linear-gradient(90deg, #eda48c, var(--danger)); }
.budget-note { color: var(--ink-3); font-size: 13px; margin-top: 8px; }
.text-danger { color: var(--danger); }

/* ---------- 图表 ---------- */
.trend-svg { width: 100%; height: auto; display: block; }
.chart-legend { display: inline-flex; align-items: center; gap: 6px; }
.dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  margin-right: 4px;
}
.dot-income { background: var(--accent); opacity: .45; }
.dot-expense { background: var(--accent); }

/* ---------- 统计页 ---------- */
/* 月度统计融合卡：标题+月份选择器 / 两列收支 / 日均结余率 */
.stats-month-grid { display: grid; grid-template-columns: repeat(2, 1fr); }
.stats-month-grid > * { min-width: 0; }
.stats-month-item { text-align: center; padding: 6px 8px; }
.stats-month-item + .stats-month-item { border-left: 1px solid var(--line); }
.stats-month-item .cmp-num { font-size: clamp(17px, 4.5vw, 26px); white-space: nowrap; }
.stats-month-item .cmp-deltas { justify-content: center; }
/* 日均支出 / 结余率指标行：虚线分隔，两端分布 */
.stats-extra {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  font-size: 13px;
  color: var(--ink-3);
}
.stats-extra > span { min-width: 0; }
.stats-extra b { color: var(--ink-2); font-family: var(--font-display); }
.cmp-label { color: var(--ink-3); font-size: 13px; }
.cmp-num {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: .5px;
  margin-top: 2px;
}
.cmp-deltas { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.delta {
  font-size: 12.5px;
  padding: 2px 10px;
  border-radius: 999px;
  font-weight: 600;
}
.delta.good { color: var(--accent-strong); background: var(--accent-soft); }
.delta.bad { color: var(--danger); background: var(--danger-soft); }
.delta.flat { color: var(--ink-3); background: var(--paper); }

.month-labels {
  display: flex;
  margin-top: 6px;
}
.month-labels span {
  flex: 1;
  text-align: center;
  font-size: 11px;
  color: var(--ink-3);
  white-space: nowrap;
}
.rank-list { list-style: none; margin: 0; padding: 0; }
.rank-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--line);
}
.rank-item:last-child { border-bottom: none; }
.rank-icon {
  width: 32px; height: 32px;
  background: var(--accent-soft);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.rank-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.rank-name { font-size: 13.5px; color: var(--ink-2); }
.rank-bar { height: 5px; background: var(--accent-soft); border-radius: 999px; overflow: hidden; }
.rank-bar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.rank-val {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
}
.rank-val em { font-style: normal; color: var(--ink-3); font-size: 12px; margin-left: 6px; }
/* 排行项较上月变化 */
.rank-diff { margin-left: 6px; font-size: 11.5px; font-weight: 400; }
.rank-diff.good { color: var(--accent-strong); }
.rank-diff.bad { color: var(--danger); }
.rank-diff.flat { color: var(--ink-3); }

.pm-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.pm-cell {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pm-icon { font-size: 20px; }
.pm-name { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.pm-line { font-size: 12.5px; color: var(--ink-3); display: flex; justify-content: space-between; }
.pm-line b { font-family: var(--font-display); font-weight: 700; }
.pos { color: var(--accent-strong); }
.neg { color: var(--danger); }

.year-picker { margin: 0; }
.year-picker .input { width: auto; padding: 5px 10px; font-size: 13.5px; }
.table-scroll { overflow-x: auto; }
.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.report-table th, .report-table td {
  padding: 9px 12px;
  text-align: right;
  border-bottom: 1px solid var(--line);
}
.report-table th:first-child, .report-table td:first-child { text-align: left; }
.report-table thead th {
  color: var(--ink-3);
  font-weight: 600;
  font-size: 13px;
}
.report-table tfoot td {
  font-weight: 700;
  border-top: 2px solid var(--line);
  border-bottom: none;
}
.report-actions { margin-top: 14px; }

/* ---------- 账目列表 ---------- */
.txn-list { list-style: none; margin: 0; padding: 0; }
.txn-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 2px;
  border-bottom: 1px dashed var(--line);
}
.txn-item:last-child { border-bottom: none; }
.txn-icon {
  width: 38px; height: 38px;
  background: var(--accent-soft);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.txn-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.txn-name {
  font-size: 14.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.txn-meta { color: var(--ink-3); font-size: 12.5px; }
.txn-amount {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  white-space: nowrap;
}
.txn-amount.is-income { color: var(--accent-strong); }
.txn-ops { display: flex; gap: 10px; align-items: center; flex-shrink: 0; }
.txn-ops form { margin: 0; }

.empty { color: var(--ink-3); text-align: center; padding: 26px 0; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-block;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-size: 14.5px;
  font-family: inherit;
  cursor: pointer;
  transition: all .18s;
  text-decoration: none;
  line-height: 1.5;
}
.btn:hover { text-decoration: none; }
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px -4px rgba(16, 185, 129, .5);
}
.btn-primary:hover { background: var(--accent-strong); transform: translateY(-1px); }
.btn-ghost {
  background: var(--card);
  color: var(--ink-2);
  border: 1px solid var(--line);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-strong); }
.btn-block { width: 100%; margin-top: 6px; }
.btn-link {
  background: none;
  border: none;
  color: var(--accent-strong);
  cursor: pointer;
  font-size: 13.5px;
  font-family: inherit;
  padding: 2px 4px;
}
.btn-link:hover { text-decoration: underline; }
.btn-danger { color: var(--danger); }

/* ---------- 表单 ---------- */
.input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  padding: 9px 12px;
  font-size: 14.5px;
  font-family: inherit;
  color: var(--ink);
  transition: border-color .18s, box-shadow .18s;
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
/* 紧凑型输入：卡片头右侧的小下拉（预算月份切换等） */
.input-sm {
  width: auto;
  max-width: 150px;
  padding: 5px 8px;
  font-size: 13px;
}
.field-label {
  display: block;
  color: var(--ink-2);
  font-size: 13px;
  margin: 10px 0 5px;
}
.field-row { display: flex; gap: 12px; }
.field-row .grow { flex: 1; }
.field-row .field-label { margin-top: 0; }
.field-group { margin-bottom: 6px; }

/* 表单内就地错误提示 */
.form-error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #f2d4c9;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 12px;
  animation: rise .25s ease both;
}
.form-error[hidden] { display: none; }
/* 弹窗底部按钮行：右对齐 */
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

/* 收/支切换 */
.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
  margin-bottom: 8px;
}
.seg-item input { position: absolute; opacity: 0; pointer-events: none; }
.seg-item span {
  display: block;
  text-align: center;
  padding: 8px 0;
  border-radius: 9px;
  color: var(--ink-3);
  cursor: pointer;
  font-weight: 600;
  transition: all .18s;
}
.seg-item input:checked + span {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 3px 10px -3px rgba(16, 185, 129, .55);
}
.seg-item input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 金额大输入框 */
.amount-field {
  display: flex;
  align-items: baseline;
  gap: 6px;
  border-bottom: 2px solid var(--line);
  padding: 2px 6px 8px;
  margin: 4px 0 12px;
  transition: border-color .18s;
}
.amount-field:focus-within { border-color: var(--accent); }
.amount-field .yen {
  font-family: var(--font-display);
  font-size: 24px;
  color: var(--ink-3);
}
.amount-field input {
  border: none;
  outline: none;
  background: none;
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 700;
  width: 100%;
  color: var(--ink);
  letter-spacing: .5px;
}
.amount-field input::placeholder { color: var(--line); }

/* 分类/支付方式 chip */
.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block;
  padding: 7px 13px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13.5px;
  color: var(--ink-2);
  cursor: pointer;
  transition: all .15s;
}
.chip span:hover { border-color: var(--accent); }
.chip input:checked + span {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
  font-weight: 600;
}
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip-disabled span { opacity: .45; cursor: not-allowed; }

/* ---------- 筛选区 ---------- */
.filter-card { padding-bottom: 14px; }
.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0 14px;
}
.filter-grid .field-label { margin-top: 8px; }
.filter-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  align-items: center;
}

/* ---------- 分页 ---------- */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 14px;
}
.pager-info { color: var(--ink-3); font-size: 13.5px; }

/* ---------- 设置页 ---------- */
.setting-list { list-style: none; margin: 0 0 10px; padding: 0; }
.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 2px;
  border-bottom: 1px dashed var(--line);
  font-size: 14.5px;
}
.setting-item:last-child { border-bottom: none; }
.setting-item[hidden] { display: none; }
.setting-item.is-archived { color: var(--ink-3); }
.setting-item .txn-ops form { margin: 0; }
.cat-display { flex: 1; min-width: 0; }
.cat-edit {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.cat-edit[hidden] { display: none; }
.cat-edit .input { flex: 1; min-width: 0; padding: 6px 8px; font-size: 13.5px; }
.cat-edit .input-icon { flex: 0 0 52px; text-align: center; }
.cat-edit .btn-link { flex-shrink: 0; }
/* 分类列表折叠切换按钮 */
.fold-toggle {
  display: block;
  width: 100%;
  text-align: center;
  padding: 8px 0 2px;
  font-size: 13px;
  color: var(--ink-3);
}
.inline-form {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.inline-form .input { flex: 1; width: auto; min-width: 0; }
.inline-form .input-icon { flex: 0 0 72px; text-align: center; }
/* grid/flex 子项允许收缩到固有宽度以下，防止窄屏横向溢出 */
.two-col > *, .filter-grid > * { min-width: 0; }
.stack-form .btn { margin-top: 12px; }
.hint { color: var(--ink-3); font-size: 12.5px; margin: 8px 0 0; }

/* ---------- 账本切换器与账本管理 ---------- */
/* 右侧细竖线把「账本切换」与「账户」两个分组隔开 */
.ledger-switch-form {
  margin: 0;
  padding-right: 12px;
  border-right: 1px solid rgba(148, 164, 155, .22);
}
.ledger-switch {
  appearance: none;
  -webkit-appearance: none;
  max-width: 140px;
  padding: 5px 28px 5px 13px;
  border: none;
  border-radius: 999px;
  background: rgba(227, 246, 238, .85) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2393a49b' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 11px center;
  font-size: 13.5px;
  font-family: inherit;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  transition: background-color .18s, box-shadow .18s;
}
.ledger-switch:hover { background-color: var(--accent-fade); }
.ledger-switch:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, .18);
}
.ledger-item .cat-display { display: flex; align-items: center; gap: 6px; }
.ledger-icon { font-size: 15px; flex: 0 0 auto; }
.ledger-badge {
  flex: 0 0 auto;
  font-size: 11px;
  line-height: 1;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
}

/* ---------- 邀请码列表 ---------- */
/* 三列布局：码固定宽 | 状态信息弹性 | 操作右对齐，各行对齐不漂移 */
.invite-item { justify-content: flex-start; gap: 12px; }
.invite-code {
  flex: 0 0 auto;
  min-width: 7.5ch;
  font-family: ui-monospace, SFMono-Regular, Consolas, 'Courier New', monospace;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 3px;
  color: var(--ink);
}
.invite-meta {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--ink-3);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.invite-item .txn-ops { margin-left: auto; }
.invite-item .txn-ops form { margin: 0; }

/* ---------- 管理后台 ---------- */
/* 用户行三段：徽标名 | 统计元信息 | 操作右对齐；封禁行整体弱化 */
.admin-user { justify-content: flex-start; gap: 12px; }
.admin-user.is-banned .admin-user-main,
.admin-user.is-banned .admin-user-meta { color: var(--ink-3); }
.admin-user-main { display: flex; align-items: center; gap: 6px; min-width: 0; }
.admin-user-name {
  font-weight: 600;
  color: var(--ink);
  max-width: 16em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-user-meta { flex: 1 1 auto; min-width: 0; color: var(--ink-3); font-size: 12.5px; }
.admin-user-hint { color: var(--ink-3); }
.admin-user .txn-ops { margin-left: auto; }
.admin-user .txn-ops form { margin: 0; }
.ledger-badge.is-danger { background: var(--danger-soft); color: var(--danger); }
.admin-search { display: flex; gap: 8px; }
.admin-backup-ok { margin: 0 0 6px; }
.admin-backup-warn { margin: 0 0 6px; color: var(--warn); font-weight: 600; }

/* ---------- 编辑表单卡片 ---------- */
.form-card { max-width: 560px; margin: 0 auto; }

/* ---------- 记一笔 FAB 与弹窗 ---------- */
.fab {
  position: fixed;
  right: 26px;
  bottom: 30px;
  width: 56px; height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 10px 28px -6px rgba(16, 185, 129, .6);
  transition: transform .18s, background .18s;
  z-index: 60;
}
.fab:hover { transform: scale(1.08) rotate(90deg); background: var(--accent-strong); }

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(38, 51, 44, .38);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 16px 16px;
  z-index: 100;
  overflow-y: auto;
}
.modal-mask[hidden] { display: none; }
.modal {
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 460px;
  padding: 18px 22px 22px;
  animation: pop .25s ease;
}
@keyframes pop {
  from { opacity: 0; transform: translateY(14px) scale(.98); }
  to { opacity: 1; transform: none; }
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 6px;
}
.modal-close {
  border: none;
  background: var(--paper);
  color: var(--ink-3);
  width: 30px; height: 30px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
}
.modal-close:hover { color: var(--ink); }

/* ---------- 提示消息 ---------- */
.flash-stack { margin-bottom: 16px; }
.flash {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 8px;
  animation: rise .3s ease both;
}
.flash-success { background: var(--accent-soft); color: var(--accent-strong); border: 1px solid var(--accent-fade); }
.flash-error { background: var(--danger-soft); color: var(--danger); border: 1px solid #f2d4c9; }

/* ---------- 登录/初始化页 ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  padding: 44px 40px 36px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  animation: rise .5s ease both;
}
.auth-logo { font-size: 44px; }
.auth-logo-img { width: 52px; height: 52px; display: inline-block; }
.auth-title { font-size: 22px; margin: 10px 0 4px; letter-spacing: 1px; }
.auth-sub { color: var(--ink-3); font-size: 13.5px; margin: 0 0 18px; }
.auth-form { text-align: left; }
.auth-form .field-label { margin-top: 14px; }
.auth-form .btn { margin-top: 22px; }
.auth-form .input-code { text-transform: uppercase; letter-spacing: 3px; }
.auth-alt { margin-top: 18px; font-size: 13.5px; text-align: center; }
.auth-alt a { color: var(--accent-strong); }

/* ---------- 移动端底部导航 ---------- */
.mobile-nav {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: rgba(255, 255, 255, .98);
  border-top: 1px solid var(--line);
  z-index: 80;
  padding: 4px 8px calc(6px + env(safe-area-inset-bottom));
  grid-template-columns: 1fr 1fr 64px 1fr 1fr;
}
.mobile-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--ink-3);
  font-size: 11.5px;
  padding: 4px 0;
  border-radius: 10px;
}
.mobile-nav a.active { color: var(--accent-strong); font-weight: 600; }
.mobile-nav a:hover { text-decoration: none; }
.m-icon { width: 22px; height: 22px; display: block; opacity: .58; transition: opacity .18s; }
.mobile-nav a.active .m-icon { opacity: 1; }
.m-add {
  width: 52px; height: 52px;
  margin-top: -18px;
  border-radius: 50%;
  border: 4px solid var(--paper);
  background: var(--accent);
  color: #fff;
  font-size: 26px;
  cursor: pointer;
  box-shadow: 0 8px 20px -6px rgba(16, 185, 129, .6);
  justify-self: center;
}

/* ---------- 响应式 ---------- */
@media (max-width: 720px) {
  .main-nav { display: none; }
  .ledger-switch { max-width: 108px; font-size: 12.5px; }
  .topbar-inner { grid-template-columns: auto auto; height: 54px; }
  /* 窄屏保留用户胶囊，收紧限宽防挤压 */
  .username-name { max-width: 5.5em; }
  .container { padding: 16px 14px 110px; }
  .mobile-nav { display: grid; }
  .fab { display: none; }
  .stat-card { padding: 12px 12px; }
  .stat-num { font-size: 19px; }
  .two-col { grid-template-columns: 1fr; }
  .two-col .card { margin-bottom: 0; }
  .filter-grid { grid-template-columns: repeat(2, 1fr); }
  .pm-grid { grid-template-columns: repeat(2, 1fr); }
  .txn-ops { flex-direction: column; gap: 2px; align-items: flex-end; }
  .modal-mask { padding: 4vh 12px 12px; }
}
