/* ============================================================
   公司记账本 · 玻璃拟态设计系统
   ============================================================ */

/* ---------- 设计令牌 ---------- */
:root,
:root.light {
  color-scheme: light;

  /* 品牌色（靛青-雾蓝） */
  --brand: #4f6ef7;
  --brand-strong: #3d5ae0;
  --brand-soft: rgba(79, 110, 247, 0.12);

  /* 收支状态色 */
  --income: #12a150;
  --expense: #e0524a;
  --warn: #e2952c;
  --muted: #6b7280;

  /* 中性（向品牌色偏 0.02 色度，避免死灰） */
  --ink: #1c2438;
  --ink-2: #3d465c;
  /* 小字辅助色：加深至 WCAG AA（4.5:1）可读区间 */
  --ink-3: #5f6a80;

  /* 玻璃表面 */
  --glass: rgba(255, 255, 255, 0.66);
  --glass-strong: rgba(255, 255, 255, 0.82);
  --glass-line: rgba(255, 255, 255, 0.55);
  --glass-edge: rgba(28, 40, 84, 0.06);

  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(28, 40, 84, 0.05), 0 2px 8px rgba(28, 40, 84, 0.05);
  --shadow-md: 0 6px 16px rgba(28, 40, 84, 0.08), 0 2px 6px rgba(28, 40, 84, 0.04);
  --shadow-lg: 0 20px 45px rgba(28, 40, 84, 0.18);

  /* 圆角 */
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-pill: 999px;

  --chart-split: rgba(127, 143, 190, 0.18);
  --blur: 20px;
  --sidebar-w: 232px;
  --font: "Segoe UI Variable Display", "Segoe UI", "HarmonyOS Sans SC", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
}

:root.dark {
  color-scheme: dark;

  --brand: #7d93ff;
  --brand-strong: #a5b4ff;
  --brand-soft: rgba(125, 147, 255, 0.16);

  --income: #34d17e;
  --expense: #ff7870;
  --warn: #f0b04f;
  --muted: #9aa4ba;

  --ink: #eef1f8;
  --ink-2: #c5cbd9;
  --ink-3: #828ba1;

  --glass: rgba(22, 28, 48, 0.66);
  --glass-strong: rgba(24, 31, 52, 0.88);
  --glass-line: rgba(255, 255, 255, 0.12);
  --glass-edge: rgba(255, 255, 255, 0.07);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.24), 0 2px 10px rgba(0, 0, 0, 0.24);
  --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.34);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.5);

  --chart-split: rgba(130, 139, 161, 0.22);
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg-base);
  /* 柔和雾蓝基底 */
  --bg-base: #e9edf5;
  background-image:
    radial-gradient(1200px 700px at 12% -8%, rgba(116, 141, 255, 0.34), transparent 60%),
    radial-gradient(900px 620px at 108% 4%, rgba(249, 195, 137, 0.22), transparent 55%),
    radial-gradient(1000px 760px at 50% 116%, rgba(104, 197, 182, 0.22), transparent 58%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}
:root.dark body {
  --bg-base: #0e1322;
  background-image:
    radial-gradient(1200px 700px at 12% -8%, rgba(85, 110, 220, 0.28), transparent 60%),
    radial-gradient(900px 620px at 108% 4%, rgba(190, 120, 60, 0.14), transparent 55%),
    radial-gradient(1000px 760px at 50% 116%, rgba(70, 160, 150, 0.16), transparent 58%);
}

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

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(110, 122, 158, 0.35); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 玻璃卡片（通用） ---------- */
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(160%);
  backdrop-filter: blur(var(--blur)) saturate(160%);
  border: 1px solid var(--glass-line);
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  border-radius: var(--r-lg);
}
:root.dark .glass { box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.06); }

/* ---------- 布局骨架 ---------- */
.layout {
  display: flex;
  min-height: 100vh;
  padding: 14px;
  gap: 14px;
}

/* 侧边栏 */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 14px;
  height: calc(100vh - 28px);
  padding: 18px 14px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(160%);
  backdrop-filter: blur(var(--blur)) saturate(160%);
  border: 1px solid var(--glass-line);
  box-shadow: var(--shadow-md);
  border-radius: var(--r-lg);
  overflow-y: auto;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.4px;
  padding: 4px 8px 16px;
}
.logo-mark {
  width: 34px; height: 34px;
  border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), #7c5cf0);
  color: #fff;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: 0 6px 14px rgba(79, 110, 247, 0.35);
}
.sidebar nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background 0.18s ease-out, color 0.18s ease-out, transform 0.18s ease-out;
}
.nav-item:hover { background: rgba(127, 143, 190, 0.12); color: var(--ink); }
.nav-item.active {
  background: var(--brand-soft);
  color: var(--brand-strong);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 28%, transparent);
}
.nav-item .ic { width: 18px; text-align: center; opacity: 0.9; }
.sidebar-foot { padding: 12px 8px 2px; font-size: 12px; color: var(--ink-3); }
.sidebar-foot .theme-toggle {
  margin-top: 8px;
  width: 100%;
  display: flex; justify-content: space-between; align-items: center;
  border: 1px solid var(--glass-edge);
  border-radius: 10px;
  padding: 7px 10px;
  background: transparent;
  color: var(--ink-2);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.18s ease-out;
}
.sidebar-foot .theme-toggle:hover { background: rgba(127, 143, 190, 0.12); }

/* 主内容 */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* 页头 */
.page { display: flex; flex-direction: column; gap: 14px; animation: fadeUp 0.26s ease-out; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.page-head h2 {
  margin: 0;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: 0.3px;
}
.page-head .desc { font-size: 12.5px; color: var(--ink-3); font-weight: 500; }

/* ---------- 表单控件 ---------- */
.input, select.input {
  height: 40px;
  padding: 0 12px;
  border-radius: 11px;
  border: 1px solid var(--glass-edge);
  background: var(--glass-strong);
  color: var(--ink);
  font-size: 14px;
  outline: none;
  transition: border-color 0.16s ease-out, box-shadow 0.16s ease-out;
}
:root.dark .input, :root.dark select.input { border-color: rgba(255, 255, 255, 0.14); }
.input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.input.big { font-size: 22px; font-weight: 700; height: 46px; }
.input:disabled { opacity: 0.55; }
label.field, .field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field .field-note { font-size: 11.5px; font-weight: 500; color: var(--ink-3); margin-top: -1px; line-height: 1.5; }

/* 按钮 */
.btn {
  height: 38px;
  padding: 0 16px;
  border-radius: 11px;
  border: 1px solid var(--glass-edge);
  background: var(--glass-strong);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.14s ease-out, background 0.16s ease-out, box-shadow 0.16s ease-out, border-color 0.16s;
  white-space: nowrap;
}
.btn:hover { background: rgba(127, 143, 190, 0.16); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(135deg, var(--brand), #6a5af0);
  color: #fff;
  border: none;
  box-shadow: 0 8px 18px rgba(79, 110, 247, 0.32);
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger {
  background: color-mix(in srgb, var(--expense) 12%, transparent);
  color: var(--expense);
  border-color: color-mix(in srgb, var(--expense) 35%, transparent);
}
.btn.danger:hover { background: color-mix(in srgb, var(--expense) 22%, transparent); }
.btn.small { height: 30px; padding: 0 11px; font-size: 12.5px; border-radius: 9px; }
.btn.ghost { background: transparent; color: var(--ink-2); box-shadow: none; border: 1px solid color-mix(in srgb, var(--ink) 14%, transparent); }
.btn.ghost:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }

/* ---------- 统计卡片 ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}
/* 固定 3 列 × 2 行：避免 6 张卡 5+1 断行失衡 */
.card-grid.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat-card {
  position: relative;
  padding: 16px 18px;
  overflow: hidden;
}
.stat-card::after {
  content: "";
  position: absolute;
  right: -30px; top: -40px;
  width: 130px; height: 130px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--brand) 18%, transparent), transparent 70%);
  pointer-events: none;
}
.stat-label { font-size: 12.5px; font-weight: 600; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.stat-label .dot { width: 8px; height: 8px; border-radius: 50%; }
.stat-value { font-size: 26px; font-weight: 800; margin-top: 6px; letter-spacing: -0.3px; }
.stat-value.income { color: var(--income); }
.stat-value.expense { color: var(--expense); }
.stat-sub { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; font-weight: 600; }

/* ---------- 面板 ---------- */
.panel { padding: 18px; }
.panel > h3 { margin: 0 0 12px; font-size: 15px; font-weight: 700; }
.chart-row { display: grid; grid-template-columns: 2fr 1.2fr; gap: 14px; }
.chart-box { width: 100%; height: 300px; }
.chart-box.compact { height: 300px; }
/* 分类汇总：定高滚动容器（鼠标滚轮上下浏览），小节标题吸顶 */
.cat-scroll { max-height: 280px; overflow-y: auto; padding-right: 4px; }
.cat-scroll .subhead {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0;
  padding: 8px 0 6px;
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.panel-head-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-head-row h3 { margin: 0; font-size: 15px; font-weight: 700; }
.subhead { margin: 14px 0 6px; font-size: 13px; font-weight: 700; color: var(--ink-2); }
.subhead:first-of-type { margin-top: 2px; }
.hint { font-size: 12.5px; color: var(--ink-3); margin: 0 0 12px; }
.tag { display: inline-block; padding: 2px 9px; border-radius: var(--r-pill); font-size: 11.5px; font-weight: 700; }
.tag.income { background: color-mix(in srgb, var(--income) 14%, transparent); color: var(--income); }
.tag.expense { background: color-mix(in srgb, var(--expense) 13%, transparent); color: var(--expense); }
.tag.transfer { background: color-mix(in srgb, var(--brand) 13%, transparent); color: var(--brand-strong); }
.tag.settled { background: color-mix(in srgb, var(--income) 12%, transparent); color: var(--income); }
.tag.overdue { background: color-mix(in srgb, var(--expense) 14%, transparent); color: var(--expense); }
.tag.open { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.tag.role-admin { background: color-mix(in srgb, var(--brand) 13%, transparent); color: var(--brand-strong); }
.tag.role-user { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.tag.role-viewer { background: color-mix(in srgb, var(--muted) 16%, transparent); color: var(--muted); }

/* ---------- 弹层表单（账号管理等）：统一节奏与字号 ---------- */
.user-manage { display: flex; flex-direction: column; gap: 14px; }

/* 角色三选卡片 */
.role-opts { display: flex; flex-direction: column; gap: 8px; }
.role-opt {
  display: flex; align-items: flex-start; gap: 10px; cursor: pointer;
  padding: 11px 13px; border: 1px solid var(--glass-edge); border-radius: 12px;
  background: var(--glass);
  transition: border-color .16s ease-out, background .16s ease-out;
}
.role-opt:hover { border-color: color-mix(in srgb, var(--brand) 45%, transparent); }
.role-opt.on { border-color: var(--brand); background: var(--brand-soft); }
.role-opt.dis { cursor: not-allowed; opacity: .72; }
.role-radio { position: absolute; width: 0; height: 0; opacity: 0; pointer-events: none; }
.role-dot {
  position: relative; flex: none; width: 16px; height: 16px; margin-top: 1.5px;
  border-radius: 50%; border: 2px solid color-mix(in srgb, var(--ink) 26%, transparent);
  transition: border-color .16s ease-out;
}
.role-dot::after {
  content: ''; position: absolute; inset: 2.5px; border-radius: 50%;
  background: var(--brand); transform: scale(0); transition: transform .16s ease-out;
}
.role-opt.on .role-dot { border-color: var(--brand); }
.role-opt.on .role-dot::after { transform: scale(1); }
.role-opt-main { display: flex; flex-direction: column; gap: 3px; }
.role-opt-main b { font-size: 13.5px; font-weight: 700; color: var(--ink); line-height: 1.35; }
.role-opt-main small { font-size: 11.5px; color: var(--ink-3); line-height: 1.55; }

/* 账号状态：双段切换（两段均分宽度） */
.status-seg { display: flex; width: 100%; }
.status-seg .seg { flex: 1; height: 32px; padding: 0 24px; font-size: 13px; border-radius: 9px; }

/* 弹层内的说明条 */
.form-hint {
  display: flex; align-items: flex-start; gap: 7px;
  margin: 0; padding: 9px 12px;
  font-size: 11.5px; line-height: 1.65; color: var(--ink-3);
  background: color-mix(in srgb, var(--brand) 5%, transparent);
  border: 1px solid color-mix(in srgb, var(--brand) 11%, transparent);
  border-radius: 10px;
}
.form-hint::before { content: 'i'; flex: none; width: 15px; height: 15px; margin-top: 1.5px; border-radius: 50%; background: color-mix(in srgb, var(--brand) 18%, transparent); color: var(--brand-strong); font-size: 10.5px; font-weight: 800; font-style: italic; text-align: center; line-height: 15px; }

/* 弹层底部按钮：主次分明、触控区达标 */
.modal-foot { padding: 10px 20px 18px; gap: 10px; }
.modal-foot .btn { min-width: 92px; height: 40px; font-size: 14px; border-radius: 11px; }
.modal-foot .btn:not(.primary):not(.danger) { background: transparent; box-shadow: none; }
.modal-foot .btn:not(.primary):not(.danger):hover { background: rgba(127, 143, 190, 0.14); }

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left;
  padding: 9px 10px;
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  border-bottom: 1px solid var(--glass-edge);
  white-space: nowrap;
}
.table td { padding: 10px; border-bottom: 1px solid color-mix(in srgb, var(--glass-edge) 60%, transparent); vertical-align: middle; }
.table tbody tr { transition: background 0.14s ease-out; }
.table tbody tr:hover { background: rgba(127, 143, 190, 0.09); }
.table .right { text-align: right; }
.table .amount { font-variant-numeric: tabular-nums; font-weight: 700; }
.table .muted { color: var(--ink-3); }
.empty-td { text-align: center; color: var(--ink-3); padding: 34px 0 !important; font-size: 13px; }
.table-wrap { overflow-x: auto; }

/* ---------- 账户余额表：合计行 / 选中行 / 缩略走势 / 弱入口 ---------- */
.table tfoot td {
  font-weight: 800;
  padding-top: 12px;
  border-bottom: 0;
  border-top: 2px solid color-mix(in srgb, var(--glass-edge) 85%, transparent);
  color: var(--ink);
}
.table tbody tr.row-sel { background: var(--brand-soft); }
.table tbody tr.row-sel td:first-child { box-shadow: inset 3px 0 0 var(--brand); }
/* 逾期行：淡红背景 + 左侧红条（应收应付警示） */
.table tbody tr.row-overdue { background: color-mix(in srgb, var(--expense) 7%, transparent); }
.table tbody tr.row-overdue td:first-child { box-shadow: inset 3px 0 0 var(--expense); }
.table td.text-overdue { color: var(--expense); }
.spark { display: block; }
.spark polyline { fill: none; stroke: var(--brand); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark.flat polyline { stroke: var(--ink-3); opacity: 0.55; }
.bal-link {
  cursor: pointer;
  border-bottom: 1.5px dashed color-mix(in srgb, var(--brand) 55%, transparent);
  transition: color 0.14s ease-out;
}
.bal-link:hover { color: var(--brand); }
/* 「走势 / 流水」入口：真按钮（键盘可达），弱入口样式 */
.bal-link-btn {
  border: none;
  background: transparent;
  padding: 4px 6px;
  border-radius: 8px;
  color: var(--brand-strong);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.14s ease-out;
}
.bal-link-btn:hover { background: var(--brand-soft); }
/* 账户余额表：宽表保底宽度走横滚，避免小屏压缩折行 */
.bal-table { min-width: 920px; }
.bal-table th, .bal-table td { white-space: nowrap; }
/* 数据表防挤压（推广 .bal-table 模式）：按列数分级保底宽度，窄屏由 .table-wrap / .tx-scroll 横向滚动 */
.table.w6 { min-width: 720px; }
.table.w7 { min-width: 860px; }
.table.w8 { min-width: 960px; }
.table.w9 { min-width: 1040px; }
.table.w6 th, .table.w6 td,
.table.w7 th, .table.w7 td,
.table.w8 th, .table.w8 td,
.table.w9 th, .table.w9 td { white-space: nowrap; }
/* 备注列：ellipsis 需配 min-width 才生效 */
.cell-note { min-width: 110px; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 构成流水等定高滚动表：表头吸顶（滚动时日期/摘要/金额列标题常驻可见） */
.sticky-head .table { border-collapse: separate; border-spacing: 0; }
.sticky-head .table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  /* 吸顶表头需近不透明，防止滚动行透出 */
  background: rgba(255, 255, 255, 0.96);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
:root.dark .sticky-head .table thead th { background: rgba(24, 31, 52, 0.96); }

/* ---------- 收支明细：固定查询栏 + 吸顶表头 + 记录区单页滚动 ---------- */
.tx-panel { display: flex; flex-direction: column; min-height: 0; }
.tx-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  max-height: calc(100vh - 330px);
  min-height: 260px;
  border: 1px solid color-mix(in srgb, var(--glass-edge) 55%, transparent);
  border-radius: var(--r-sm);
}
.tx-scroll .table { border-collapse: separate; border-spacing: 0; }
/* 吸顶表头：滚动时表头保持在容器顶部 */
.tx-scroll .table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--glass-strong);
  backdrop-filter: blur(10px);
}
/* 除日期列外，其余栏目统一居中 */
.tx-table th:not(:first-child), .tx-table td:not(:first-child) { text-align: center; }
.tx-table td:first-child { padding-left: 14px; }
/* 编辑 / 删除按钮拉开间距 */
.tx-table .actions .btn + .btn { margin-left: 10px; }
/* 收支明细页：页面高度与侧边栏相同（底部对齐左侧功能菜单最下沿），记录区弹性占满剩余高度 */
.page.tx-page { height: calc(100vh - 28px); }
.page.tx-page .tx-panel { flex: 1 1 auto; min-height: 0; }
.page.tx-page .tx-scroll { flex: 1 1 auto; max-height: none; min-height: 0; }

/* ---------- 筛选栏 ---------- */
/* filter-bar 需建立高于内容面板的层叠上下文，否则下拉菜单会被 .glass 面板（backdrop-filter 创建层叠上下文）盖住 */
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px 16px; position: relative; z-index: 40; }
.filter-bar .input { height: 36px; }
.filter-bar .grow { flex: 1; min-width: 140px; }

/* ---------- 分页 ---------- */
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 12px; font-size: 12.5px; color: var(--ink-2); }

/* ---------- 下拉选择器（替代原生 select：菜单定高滚动、紧凑） ---------- */
.ui-select { position: relative; display: inline-block; }
.ui-select-btn {
  display: inline-flex; align-items: center; justify-content: space-between; gap: 8px;
  min-width: 108px; cursor: pointer; text-align: left;
}
.ui-select-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ui-select-caret { font-size: 10px; color: var(--ink-3); flex-shrink: 0; transition: transform 0.15s ease-out; }
.ui-select-btn.open .ui-select-caret { transform: rotate(180deg); }
.ui-select-menu {
  /* teleport 到 body + fixed 定位（坐标由 UiSelect 按触发按钮计算）：
     脱离 .modal-card（overflow:hidden + backdrop-filter 包含块）、.modal-body
     （overflow-y:auto）等裁剪上下文，弹窗内下拉完整显示在最上层 */
  position: fixed;
  z-index: 950;
  min-width: 108px;
  width: max-content;
  max-width: 320px;
  /* 菜单紧凑：约 7 项可见，超出滚动 */
  max-height: 248px;
  overflow-y: auto;
  padding: 6px;
  /* 近不透明背景：玻璃底会透出下方表格文字 */
  background: rgba(255, 255, 255, 0.96);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  backdrop-filter: blur(16px) saturate(160%);
  border: 1px solid var(--glass-line);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
}
:root.dark .ui-select-menu { background: rgba(24, 31, 52, 0.96); }
.ui-select-item {
  padding: 7px 12px; border-radius: 8px; font-size: 13px; line-height: 1.5;
  cursor: pointer; white-space: nowrap;
  transition: background 0.12s ease-out;
}
.ui-select-item:hover { background: rgba(127, 143, 190, 0.14); }
.ui-select-item.active { background: var(--brand-soft); color: var(--brand-strong); font-weight: 700; }
.ui-fade-enter-active, .ui-fade-leave-active { transition: opacity 0.14s ease-out, transform 0.14s ease-out; }
.ui-fade-enter-from, .ui-fade-leave-to { opacity: 0; transform: translateY(-4px); }

/* ---------- 日期 / 月份选择器（UiDatePicker，面板复用 .ui-select-menu 基底） ---------- */
.ui-date { position: relative; display: inline-block; min-width: 132px; }
.ui-date-btn { width: 100%; cursor: pointer; }
.ui-date-btn:disabled { cursor: not-allowed; }
.ui-date-btn .ui-select-label.ui-date-ph { color: var(--ink-3); font-weight: 500; }
.ui-date-ic { flex-shrink: 0; opacity: 0.55; }
.ui-date-panel { width: 272px; padding: 10px; overflow: hidden; }
.uid-head-row { display: flex; align-items: center; justify-content: space-between; gap: 4px; margin-bottom: 6px; }
.uid-navs { display: inline-flex; gap: 2px; }
.uid-title { font-size: 13.5px; font-weight: 700; white-space: nowrap; }
.uid-nav {
  width: 28px; height: 28px; border: none; border-radius: 8px;
  background: transparent; color: var(--ink-2); font-size: 15px; line-height: 1; cursor: pointer;
  transition: background 0.12s ease-out;
}
.uid-nav:hover { background: rgba(127, 143, 190, 0.14); }
.uid-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.uid-week { margin-bottom: 2px; }
.uid-head { text-align: center; font-size: 11px; font-weight: 700; color: var(--ink-3); padding: 3px 0; }
.uid-day {
  height: 34px; border: none; border-radius: 9px; background: transparent;
  color: var(--ink); font-size: 12.5px; cursor: pointer; font-variant-numeric: tabular-nums;
  transition: background 0.12s ease-out;
}
.uid-day:hover { background: rgba(127, 143, 190, 0.16); }
.uid-day.dim { color: var(--ink-3); opacity: 0.5; }
.uid-day.today { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--brand) 55%, transparent); }
.uid-day.sel { background: var(--brand); color: #fff; font-weight: 700; box-shadow: none; }
.uid-day.cur:not(.sel) { outline: 2px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: -2px; }
.uid-months { grid-template-columns: repeat(3, 1fr); gap: 6px; }
.uid-mon {
  height: 40px; border: none; border-radius: 10px; background: transparent;
  color: var(--ink); font-size: 12.5px; font-weight: 600; cursor: pointer;
  transition: background 0.12s ease-out;
}
.uid-mon:hover { background: rgba(127, 143, 190, 0.16); }
.uid-mon.today { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--brand) 55%, transparent); }
.uid-mon.sel { background: var(--brand); color: #fff; box-shadow: none; }
.uid-foot {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--glass-edge);
}
.uid-link {
  border: none; background: transparent; color: var(--brand-strong);
  font-size: 12.5px; font-weight: 700; cursor: pointer; padding: 4px 8px; border-radius: 8px;
  transition: background 0.12s ease-out;
}
.uid-link:hover { background: var(--brand-soft); }

/* 收支明细：快捷区间（近7天/本月…） */
.range-chips { display: inline-flex; gap: 6px; flex-wrap: wrap; }

/* ---------- 段切换 ---------- */
.seg-group {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  border-radius: 13px;
  background: var(--glass);
  border: 1px solid var(--glass-edge);
}
.seg {
  height: 34px;
  padding: 0 18px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.16s ease-out, color 0.16s ease-out;
}
.seg.active { background: var(--glass-strong); color: var(--brand-strong); box-shadow: var(--shadow-sm); }

/* 页签（应收应付） */
.tabs { display: flex; gap: 6px; }
.tab {
  height: 38px;
  padding: 0 20px;
  border-radius: 12px;
  border: 1px solid var(--glass-edge);
  background: var(--glass);
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.16s ease-out, color 0.16s;
}
.tab.active { background: var(--brand-soft); color: var(--brand-strong); border-color: color-mix(in srgb, var(--brand) 30%, transparent); }

/* ---------- 表单网格（记一笔 / 弹窗） ---------- */
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-3 { grid-column: span 3; }
.form-grid .input, .form-grid select.input { width: 100%; min-width: 0; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }
.quick-form { padding: 20px; }

/* ---------- 进度条（预算） ---------- */
.progress-outer { height: 8px; border-radius: 6px; background: color-mix(in srgb, var(--ink) 9%, transparent); overflow: hidden; }
.progress-inner { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--brand), #6a5af0); transition: width 0.4s ease-out; }
.progress-inner.over { background: linear-gradient(90deg, var(--expense), #ff8f6b); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 22px;
  border-radius: 13px;
  background: rgba(35, 43, 66, 0.92);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease-out, transform 0.22s ease-out;
  box-shadow: var(--shadow-lg);
  max-width: 80vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: rgba(190, 48, 42, 0.94); }

/* ---------- 模态框 ---------- */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(20, 26, 46, 0.4);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 900;
  padding: 20px;
}
.modal-card {
  width: 460px; max-width: 100%;
  max-height: 86vh;
  display: flex; flex-direction: column;
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(26px) saturate(160%);
  backdrop-filter: blur(26px) saturate(160%);
  border: 1px solid var(--glass-line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px;
}
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 800; }
.modal-close {
  width: 36px; height: 36px;
  border: none; background: transparent;
  border-radius: 10px; color: var(--ink-3);
  font-size: 19px; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.modal-close:hover { background: rgba(127, 143, 190, 0.14); color: var(--ink); }
.modal-body { padding: 6px 20px 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 20px 18px; }
.modal-enter-active, .modal-leave-active { transition: opacity 0.2s ease-out; }
.modal-enter-from, .modal-leave-to { opacity: 0; }
.modal-enter-active .modal-card, .modal-leave-active .modal-card { transition: transform 0.22s ease-out; }
.modal-enter-from .modal-card, .modal-leave-to .modal-card { transform: translateY(14px) scale(0.98); }

/* ---------- 移动端适配 ---------- */
@media (max-width: 920px) {
  .layout { flex-direction: column; padding: 10px; gap: 10px; }
  .sidebar {
    width: 100%;
    position: sticky; top: 0; z-index: 50;
    height: auto;
    flex-direction: row;
    align-items: center;
    padding: 8px 10px;
    border-radius: 16px;
    overflow-x: auto;
    gap: 0;
  }
  .logo { padding: 0 8px 0 2px; font-size: 15px; }
  .logo span { white-space: nowrap; }
  .logo-mark { width: 30px; height: 30px; font-size: 14px; border-radius: 9px; }
  .sidebar nav { flex-direction: row; gap: 4px; flex: 1; min-width: max-content; }
  .nav-item { padding: 8px 11px; font-size: 13px; flex-wrap: nowrap; }
  .nav-item .ic { font-size: 15px; }
  .sidebar-foot { display: none; }
  .chart-row { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .card-grid { grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); }
  .card-grid.grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-value { font-size: 21px; }
  .page-head { padding: 0 2px; }
  .main { gap: 10px; }
  .chart-box { height: 240px; }
  .chart-box.compact { height: 220px; }
  .cat-scroll { max-height: 240px; }
  .table-wrap { margin: 0 -2px; }
}
@media (max-width: 520px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2, .form-grid .span-3 { grid-column: span 1; }
  .card-grid { grid-template-columns: 1fr 1fr; }
  .modal-card { border-radius: 18px; }
  .filter-bar .input { flex: 1 1 100%; }
  .tx-scroll { max-height: calc(100vh - 400px); }
}
@media (max-width: 480px) {
  /* 窄屏隐藏 logo 文字，只留「账」标，避免竖排折行挤占导航 */
  .logo span { display: none; }
}

/* ---------- 无障碍 / 动效 ---------- */
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- 设置页 ---------- */
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px 12px; }
.panel-head h3 { margin: 0; font-size: 15px; font-weight: 700; }
.setting-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; padding: 0 18px 18px; }
.setting-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 14px; background: color-mix(in srgb, var(--ink) 4%, transparent); border: 1px solid color-mix(in srgb, var(--ink) 7%, transparent); }
.si-main { flex: 1; min-width: 0; }
.si-name { display: block; font-weight: 700; font-size: 14px; }
.si-sub { display: block; margin-top: 3px; font-size: 12px; color: var(--ink-3); }
.si-bal { color: var(--brand-strong); }
.si-ops { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
/* 状态徽章弱化为纯标签（无可点暗示） */
.si-state {
  padding: 2px 10px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 700;
  background: color-mix(in srgb, var(--income) 12%, transparent);
  color: var(--income);
  border: none;
  cursor: default;
  user-select: none;
}
.si-state.off { background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink-3); }
.type-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 18px 18px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: var(--r-pill); background: color-mix(in srgb, var(--brand) 10%, transparent); color: var(--brand-strong); font-size: 12.5px; font-weight: 700; }
.chip-x { width: 18px; height: 18px; border: none; border-radius: 50%; background: color-mix(in srgb, var(--ink) 14%, transparent); color: var(--ink-2); font-size: 12px; line-height: 1; cursor: pointer; }
.chip-x:hover { background: var(--expense); color: #fff; }

/* ---------- 预算进度 ---------- */
.progress { height: 8px; border-radius: 6px; background: color-mix(in srgb, var(--ink) 9%, transparent); overflow: hidden; }
.progress .bar { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--brand), #6a5af0); transition: width 0.4s ease-out; }
.progress .bar.over { background: linear-gradient(90deg, var(--expense), #ff8f6b); }

/* ---------- 杂项补充 ---------- */
/* 预算进度：百分比与进度条同行右对齐 */
.prog-row { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.prog-row .progress { flex: 1; }
.prog-pct { flex-shrink: 0; min-width: 40px; text-align: right; font-size: 11.5px; font-weight: 700; color: var(--ink-3); }

/* 表格骨架：加载中占位（shimmer） */
.skeleton {
  display: block;
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--ink) 8%, transparent) 25%,
    color-mix(in srgb, var(--ink) 15%, transparent) 50%,
    color-mix(in srgb, var(--ink) 8%, transparent) 75%);
  background-size: 200% 100%;
  animation: sk-shimmer 1.2s ease-in-out infinite;
}
@keyframes sk-shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

/* 设置页：删除按钮 hover/聚焦再提亮，降低满屏红色噪音 */
.btn.quiet-danger {
  background: transparent;
  border-color: color-mix(in srgb, var(--expense) 28%, transparent);
  color: var(--expense);
  opacity: 0.72;
  transition: opacity 0.16s ease-out, background 0.16s ease-out;
}
.setting-item:hover .btn.quiet-danger,
.setting-item:focus-within .btn.quiet-danger { opacity: 1; background: color-mix(in srgb, var(--expense) 10%, transparent); }

/* ---------- 登录页 ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 360px; padding: 32px 28px 28px; border-radius: 20px; background: var(--glass-strong); border: 1px solid var(--glass-edge); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 14px; }
.login-logo { display: flex; justify-content: center; margin-bottom: 2px; }
.login-card .logo-mark { width: 52px; height: 52px; font-size: 26px; }
.login-card h2 { margin: 0; text-align: center; font-size: 20px; }
.login-sub { text-align: center; font-size: 12.5px; color: var(--ink-3); margin-top: -8px; }
.login-error { margin: 0; min-height: 18px; font-size: 12.5px; color: var(--expense); }
.login-notice { margin: 0; min-height: 18px; font-size: 12.5px; color: var(--warn); }
.login-btn { height: 42px; width: 100%; }

/* ---------- 侧栏用户栏 ---------- */
.user-bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; margin: 4px 8px 2px; border-radius: 12px; background: color-mix(in srgb, var(--brand) 10%, transparent); }
.user-avatar { width: 28px; height: 28px; flex-shrink: 0; border-radius: 50%; background: var(--brand); color: #fff; font-size: 14px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.user-name { flex: 1; min-width: 0; font-size: 13px; font-weight: 700; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* 用户名下方的角色标识（管理员 / 记账员） */
.user-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.user-role { font-size: 11px; line-height: 1.2; color: var(--ink); opacity: .55; }
.logout-btn { flex-shrink: 0; }
