/* ============================================================
   WealthOS 共享基础样式（所有页面继承）
   - 四层表面（靠明度差分层）：--bg-primary（页面底）< --bg-subtle（嵌套/表头）
     < --bg-card（卡片）< --bg-raised（悬浮）；--bg-secondary 用于侧栏/浮层
   - 统一侧边栏、导航、按钮、表格、分页、弹窗、表单、toast

   【设计系统使用规范（样式权限收口）】
   1. 页面只允许继承本文件 + 页面级 CSS，禁止新增第三方 CSS 文件。
   2. 颜色一律用变量（--bg-*、--text-*、--accent-*、--border-*），禁止硬编码色值。
      层次用四层表面变量；浮层 = --bg-secondary + --shadow-lg。
   3. 圆角一律用 token：--radius-sm(4 控件)/--radius-md(6 浮层)/--radius-lg(8 卡片)。
      卡片不加阴影（靠 1px 边框分层），阴影只给浮层（--shadow-lg）。
   4. 间距/字号/动效一律用 token（--spacing-* / --text-* / --transition-* / --ease-*），
      禁止散落的 20px/16px/0.2s 硬编码。
   5. 字体三栈：--font-sans（正文）/--font-serif（页面主标题、品牌、单据）/--font-mono
      （代码、单号）；数字列统一 .num-col 或 font-variant-numeric: tabular-nums。
   6. 布局类（flex 行、标题行）用工具类 .chart-title-row / .section-title-row / .toolbar-row，
      禁止内联 style="display:flex..."。
   7. 重复的 HTML 片段抽到 templates/components/ 下的宏，禁止跨页面复制粘贴。
   ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }   /* 显隐统一用 hidden 属性（避免模板内联 style 与 JS style.display 混用） */

/* ============ 深色主题（四层表面：primary < subtle < card < raised，靠明度差分层） ============ */
:root {
  color-scheme: dark;
  --bg-primary: #0a0f1c;
  --bg-secondary: #0f1626;
  --bg-card: #111a2e;
  --bg-subtle: #0d1524;
  --bg-raised: #18233c;
  --bg-hover: #1c2a45;
  --text-primary: #f1f5f9;
  --text-secondary: #b3bfcf;
  --text-muted: #aab7c9;
  --accent-blue: #3b82f6;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-yellow: #f59e0b;
  --accent-purple: #8b5cf6;
  /* 涨跌色（单一来源；默认国际习惯：绿涨红跌） */
  --up: #10b981;
  --down: #ef4444;
  --border-color: #1f2c47;
  --border-strong: #33456a;
  --radius-xs: 4px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-pill: 999px;                    /* 胶囊/药丸（徽标、滑块、进度条圆头） */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.4);
  /* 间距 / 字号 / 动效（主题无关，统一用这些变量） */
  --spacing-1: 4px;
  --spacing-2: 8px;
  --spacing-3: 12px;
  --spacing-4: 16px;
  --spacing-5: 20px;
  --spacing-6: 24px;
  --spacing-8: 32px;
  /* 字阶角色（每档只承担一个角色；13 为表格正文专用）：
     micro 10=角标/排序箭头 · caption 12=表头/提示/meta · dense 13=表格正文·表单/字段标签·小号 UI（头像首字母·紧凑控件） ·
     body 14=正文/表单/按钮/导航/统计标签 · title 16=卡片/图表标题 ·
     heading 20=页面标题 · display 24=统计数值 · hero 52=空态大图标 */
  --text-hero: 52px;
  --text-2xs: 10px;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-lg: 16px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --transition-fast: 0.15s;
  --transition-normal: 0.2s;
  --transition-slow: 0.3s;
  /* 缓动曲线（统一动效语言） */
  --ease-standard: cubic-bezier(.2, 0, 0, 1);
  --ease-emphasized: cubic-bezier(.16, 1, .3, 1);
  --ease-spring: cubic-bezier(.22, 1.22, .36, 1);
  /* 字体三栈：无衬线（UI/正文）、衬线（标题/品牌/单据）、等宽（代码/单号） */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  --font-serif: 'Noto Serif CJK SC', 'Noto Serif SC', 'Source Han Serif SC', 'Songti SC', 'SimSun', 'Times New Roman', serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
  --blue-soft: rgba(59, 130, 246, 0.15);
  --green-soft: rgba(16, 185, 129, 0.15);
  --red-soft: rgba(239, 68, 68, 0.15);
  --yellow-soft: rgba(245, 158, 11, 0.15);
  --purple-soft: rgba(139, 92, 246, 0.15);
  --gray-soft: rgba(148, 163, 184, 0.12);
  --accent-blue-hover: #2563eb;
  --accent-red-hover: #b91c1c;
  --brand-gradient: linear-gradient(135deg, #3b82f6, #8b5cf6);
  --on-accent: #fff;                       /* 彩色底上的文字（按钮/徽标/头像） */
  --on-warning: #1a1a1a;                   /* 黄底深字（警示徽标） */
  --file-pdf: #dc2626;
  --file-doc: #2563eb;
  --file-img: #059669;
  --file-xls: #16a34a;
  --file-txt: #64748b;
  --seg-knob-bg: #fff;                     /* 主题胶囊滑块（组件自带配色） */
  --seg-on: #2a2e2e;
  --col-hover: rgba(59, 130, 246, 0.12);
  --col-selected: rgba(139, 92, 246, 0.14);
  --card-pad: var(--spacing-5);            /* 卡片统一内边距 20 */
  --table-cell-pad: 12px 10px;             /* 表格单元格内边距（.data-table--compact 覆盖为 6px 8px） */
  --mask-bg: rgba(0, 0, 0, 0.6);
  --row-inset: #0d1524;
  --row-accent: #16243d;
  --row-selected: #223052;
  --row-hover: rgba(148, 163, 184, 0.04);
  --sticky-hover: #1a2740;
  --col-hover-sticky: #16243d;
  --col-selected-sticky: #223052;
}

/* ============ 浅色主题（仅颜色覆盖，布局/尺寸不变） ============ */
[data-theme="light"] {
  color-scheme: light;
  --bg-primary: #eef1f6;
  --bg-secondary: #f7f8fb;
  --bg-card: #ffffff;
  --bg-subtle: #f4f6fa;
  --bg-raised: #ffffff;
  --bg-hover: #e4e9f1;
  --text-primary: #0f172a;
  --text-secondary: #3f4b5c;
  --text-muted: #444d5a;
  --accent-blue: #1d4ed8;
  --accent-green: #047857;
  --accent-red: #b91c1c;
  --accent-yellow: #92400e;
  --accent-purple: #6d28d9;
  --up: #047857;
  --down: #b91c1c;
  --border-color: #dde3ec;
  --border-strong: #c9d2e0;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.1);
  --blue-soft: rgba(37, 99, 235, 0.10);
  --green-soft: rgba(5, 150, 105, 0.12);
  --red-soft: rgba(220, 38, 38, 0.10);
  --yellow-soft: rgba(217, 119, 6, 0.14);
  --purple-soft: rgba(124, 58, 237, 0.10);
  --gray-soft: rgba(100, 116, 139, 0.10);
  --accent-blue-hover: #1d4ed8;
  --accent-red-hover: #991b1b;
  --col-hover: rgba(37, 99, 235, 0.10);
  --col-selected: rgba(124, 58, 237, 0.10);
  --mask-bg: rgba(15, 23, 42, 0.45);
  --row-inset: #f5f7fb;
  --row-accent: #eef2fb;
  --row-selected: #ede9fe;
  --row-hover: rgba(100, 116, 139, 0.05);
  --sticky-hover: #e2e8f0;
  --col-hover-sticky: #dbeafe;
  --col-selected-sticky: #ede9fe;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);              /* 正文基准 14（Ant：主字号 14 / 行高 22） */
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  transition: background var(--transition-normal) ease, color var(--transition-normal) ease;
}

/* 键盘焦点可见性（可访问性） */
:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 2px; }

/* ============ 布局 ============ */
.app-layout { display: flex; min-height: 100vh; }
.main-content { flex: 1; padding: var(--spacing-5); min-width: 0; }

/* 跳到主内容（仅键盘可访问性）：默认视觉隐藏，聚焦时显示 */
.skip-link {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link:focus {
  position: fixed; left: 8px; top: 8px; width: auto; height: auto;
  margin: 0; padding: 8px 14px; overflow: visible; clip: auto;
  z-index: 2000; border-radius: var(--radius-md);
  background: var(--bg-secondary); color: var(--text-primary);
  border: 1px solid var(--border-color); text-decoration: none;
  box-shadow: var(--shadow-lg);
}

/* ============ 侧边栏 ============ */
.sidebar {
  width: 220px; background: var(--bg-secondary); border-right: 1px solid var(--border-color);
  transition: width 0.2s ease; flex-shrink: 0; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow: hidden;
}
.sidebar.collapsed { width: 64px; }
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; border-bottom: 1px solid var(--border-color); height: 60px; gap: 8px;
}
.sidebar-brand-link { display: inline-flex; align-items: center; flex: 0 1 auto; min-width: 0; padding: 2px 4px; margin-left: -4px; text-decoration: none; border-radius: var(--radius-sm); }
.sidebar-brand-link:hover .sidebar-title { filter: brightness(1.15); }
.sidebar-brand-link:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 2px; }
.sidebar-title {
  font-size: var(--text-2xl); font-weight: 700; font-family: var(--font-serif); letter-spacing: .02em;
  line-height: 1; flex: 0 1 auto;
  background: var(--brand-gradient);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  white-space: nowrap;
}
.sidebar.collapsed .sidebar-title { display: none; }
.sidebar-toggle {
  background: var(--bg-hover); border: none; color: var(--text-secondary);
  width: 28px; height: 28px; border-radius: var(--radius-sm); cursor: pointer; font-size: var(--text-base); line-height: 1; flex-shrink: 0;
  transition: background-color var(--transition-normal) ease, color var(--transition-normal) ease, border-color var(--transition-normal) ease, box-shadow var(--transition-normal) ease, transform var(--transition-normal) ease;
}
.sidebar-toggle:hover { color: var(--text-primary); background: var(--border-strong); }
.sidebar-nav { padding: 12px 8px; display: flex; flex-direction: column; gap: 4px; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-secondary); text-decoration: none; font-size: var(--text-base); transition: background-color var(--transition-normal) ease, color var(--transition-normal) ease, border-color var(--transition-normal) ease, box-shadow var(--transition-normal) ease, transform var(--transition-normal) ease; white-space: nowrap;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: var(--blue-soft); color: var(--accent-blue); }
/* 当前页指示条：左侧 2px 竖线，加载时从中间展开 */
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 50%; width: 2px; height: 18px;
  border-radius: var(--radius-pill); background: var(--accent-blue);
  transform: translateY(-50%);
  animation: nav-indicator .3s var(--ease-emphasized) both;
}
@keyframes nav-indicator {
  from { transform: translateY(-50%) scaleY(0); opacity: 0; }
  to { transform: translateY(-50%) scaleY(1); opacity: 1; }
}
.nav-icon { flex-shrink: 0; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; }
.nav-icon svg { width: 18px; height: 18px; }
.sidebar.collapsed .nav-text { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px 8px; }
.sidebar-overlay { display: none; }

.mobile-menu-btn {
  display: none; background: var(--bg-secondary); border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); color: var(--text-primary); width: 40px; height: 40px; cursor: pointer;
  align-items: center; justify-content: center; flex-shrink: 0;
}
.mobile-menu-btn svg { width: 22px; height: 22px; }

/* ============ 页头 ============ */
.header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap; gap: 12px;
}
.header-left { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; min-width: 0; }
.header-right { display: flex; align-items: center; gap: 12px; min-width: 0; }
.header-actions { display: flex; flex-wrap: wrap; gap: var(--spacing-2); align-items: center; }
.logo {
  font-size: var(--text-2xl); font-weight: 700;
  background: var(--brand-gradient);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.logo-sub { color: var(--text-secondary); font-size: var(--text-base); white-space: nowrap; }
/* 极窄屏：副标题占满一行或隐藏，避免被压成逐字竖排 */
@media (max-width: 420px) { .logo-sub { white-space: normal; word-break: keep-all; } }
.page-title { font-size: var(--text-xl); font-weight: 700; font-family: var(--font-serif); letter-spacing: .01em; }
.update-time { color: var(--text-muted); font-size: var(--text-sm); }

/* ============ 统计卡片 ============ */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card { position: relative; overflow: hidden; transition: border-color 0.2s ease; }
.stat-card:hover { border-color: var(--border-strong); }
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; width: 4px; height: 100%; }
.stat-card.blue::before { background: var(--accent-blue); }
.stat-card.green::before { background: var(--accent-green); }
.stat-card.yellow::before { background: var(--accent-yellow); }
.stat-card.purple::before { background: var(--accent-purple); }
.stat-card.red::before { background: var(--accent-red); }
.stat-label { color: var(--text-secondary); font-size: var(--text-base); margin-bottom: 8px; }
.stat-value { font-size: var(--text-2xl); font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-value.is-text { font-size: var(--text-xl); }   /* 文本型统计值（姓名/标签）走 title 20 */
.stat-card.blue .stat-value { color: var(--accent-blue); }
.stat-card.green .stat-value { color: var(--accent-green); }
.stat-card.yellow .stat-value { color: var(--accent-yellow); }
.stat-card.purple .stat-value { color: var(--accent-purple); }
.stat-card.red .stat-value { color: var(--accent-red); }
.stat-change { margin-top: 6px; font-size: var(--text-sm); color: var(--text-muted); }
.stat-change.positive { color: var(--accent-green); }
.stat-change.negative { color: var(--accent-red); }

/* ============ 图表 ============ */
.chart-row { display: grid; gap: 16px; margin-bottom: 24px; }
.chart-row.row-2 { grid-template-columns: 1fr 1fr; }
.chart-row.row-1 { grid-template-columns: 1fr; }
.chart-card { min-width: 0; transition: border-color 0.2s ease; }
.chart-card:hover { border-color: var(--border-strong); }
.chart-title { font-size: var(--text-lg); font-weight: 600; margin-bottom: 16px; color: var(--text-primary); }
.chart-container { width: 100%; height: 340px; }
.compact-gap { margin-bottom: 20px; }

/* ============ 卡片 / 表格区块 ============ */
/* 卡片类容器（统一外观：底/边框/圆角/内边距一律等价，避免各页漂移） */
.card,
.table-section,
.chart-card,
.stat-card {
  background: var(--bg-card); border-radius: var(--radius-lg); padding: var(--card-pad);
  border: 1px solid var(--border-color);
}
.table-section { margin-bottom: 24px; }
.table-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 12px; }
.table-title { font-size: var(--text-lg); font-weight: 600; }
.table-actions { display: flex; gap: var(--spacing-2); align-items: center; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; }
.toolbar { display: flex; gap: var(--spacing-2); margin-bottom: var(--spacing-4); flex-wrap: wrap; align-items: center; }
/* 表格顶部横向滚动条：列不换行时无需滚到底部即可左右拖动（JS 同步 scrollLeft） */
.table-scroll-top { overflow-x: auto; overflow-y: hidden; height: 14px; margin-bottom: var(--spacing-1); }
.table-scroll-top[hidden] { display: none; }
.table-scroll-top-inner { height: 1px; }

/* 工具条内的表单控件按内容排布（.form-input/.form-select 默认 width:100% 会让每个控件独占一行） */
.toolbar > .form-input, .toolbar .filter-group > .form-input { width: auto; flex: 1 1 200px; min-width: 140px; }
.toolbar > .form-select, .toolbar .filter-group > .form-select { width: auto; flex: 0 1 160px; min-width: 120px; }
.actions-cell { display: flex; gap: 6px; }

/* ============ 输入 / 按钮 ============ */
.search-input {
  padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-color);
  background: var(--bg-primary); color: var(--text-primary); font-size: var(--text-base); width: 200px; outline: none; transition: border 0.2s;
}
.search-input:focus { border-color: var(--accent-blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.filter-select {
  padding: 8px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-color);
  background: var(--bg-primary); color: var(--text-primary); font-size: var(--text-sm); outline: none; cursor: pointer;
}
.filter-select:focus { border-color: var(--accent-blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.date-input {
  padding: 8px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-color);
  background: var(--bg-primary); color: var(--text-primary); font-size: var(--text-sm); outline: none;
}
.date-input:focus { border-color: var(--accent-blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.btn {
  white-space: nowrap; padding: 8px 16px; border-radius: var(--radius-sm); border: none; font-size: var(--text-base); cursor: pointer;
  transition: background-color var(--transition-normal) ease, color var(--transition-normal) ease, border-color var(--transition-normal) ease, box-shadow var(--transition-normal) ease, transform var(--transition-normal) ease; font-weight: 500; text-decoration: none;
  /* 统一 <a class="btn"> 与 <button class="btn"> 的高度/基线，避免并排时错位 */
  display: inline-flex; align-items: center; justify-content: center; line-height: 1.3; vertical-align: middle;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent-blue); color: white; }
.btn-primary:hover { background: var(--accent-blue-hover); }
.btn-secondary { background: var(--bg-hover); color: var(--text-primary); }
.btn-secondary:hover { background: var(--border-strong); }
.btn-danger { background: var(--accent-red); color: var(--on-accent); }
.btn-danger:hover { background: var(--accent-red-hover); }
.btn-sm { padding: 4px 10px; font-size: var(--text-xs); border-radius: var(--radius-sm); }

/* ============ 表格 ============ */
.data-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); line-height: 1.5; }
.data-table--compact { --table-cell-pad: 6px 8px; }   /* 明细类表格：更紧凑的密度 */
.data-table th { font-size: var(--text-xs); }   /* 表头 caption 12（表体 dense 13） */
.data-table thead th { position: sticky; top: 0; z-index: 2; background: var(--bg-card); }
.data-table th {
  text-align: left; padding: var(--table-cell-pad); color: var(--text-secondary); font-weight: 600;
  border-bottom: 1px solid var(--border-color); cursor: default; user-select: none; white-space: nowrap;
}
.data-table th .sort-icon { margin-left: 4px; opacity: 0.5; font-size: var(--text-2xs); }
.data-table th.active .sort-icon { opacity: 1; color: var(--accent-blue); }
.data-table td { padding: var(--table-cell-pad); border-bottom: 1px solid var(--border-color); color: var(--text-primary); }
.data-table tbody tr { transition: background var(--transition-fast) ease; }
.data-table tbody tr:nth-child(even) { background: var(--row-hover); }
.data-table tbody tr:hover { background: var(--gray-soft); }
.drill-cell { cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.drill-cell:hover { color: var(--accent-blue); }
.num-col { text-align: right; font-variant-numeric: tabular-nums; }
.data-table th.num-col { text-align: right; }   /* 数字列表头与数值同向右对齐（可读性） */
.cell-detail-table { width: max-content; max-width: 100%; }
.adj-detail-table { width: max-content; min-width: 100%; }

/* 表格行错峰进场（前 10 行依次浮现，其余立即显示，避免长表拖沓）
   终态用 transform:none，避免创建 containing block 破坏移动端 sticky 首列 */
body:not(.anim-done) .data-table tbody tr { animation: row-enter .24s var(--ease-emphasized) both; }
body:not(.anim-done) .data-table tbody tr:nth-child(2) { animation-delay: 18ms; }
body:not(.anim-done) .data-table tbody tr:nth-child(3) { animation-delay: 36ms; }
body:not(.anim-done) .data-table tbody tr:nth-child(4) { animation-delay: 54ms; }
body:not(.anim-done) .data-table tbody tr:nth-child(5) { animation-delay: 72ms; }
body:not(.anim-done) .data-table tbody tr:nth-child(6) { animation-delay: 90ms; }
body:not(.anim-done) .data-table tbody tr:nth-child(7) { animation-delay: 108ms; }
body:not(.anim-done) .data-table tbody tr:nth-child(8) { animation-delay: 126ms; }
body:not(.anim-done) .data-table tbody tr:nth-child(9) { animation-delay: 144ms; }
body:not(.anim-done) .data-table tbody tr:nth-child(10) { animation-delay: 162ms; }
body:not(.anim-done) .data-table tbody tr:nth-child(n+11) { animation: none; }
@keyframes row-enter {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* ============ 标签 ============ */
.tag { display: inline-block; padding: 2px 8px; border-radius: var(--radius-xs); font-size: var(--text-xs); background: var(--bg-subtle); color: var(--text-secondary); border: 1px solid color-mix(in srgb, currentColor 35%, transparent); }
.tag.active { background: var(--green-soft); color: var(--accent-green); }
.tag.matured { background: var(--yellow-soft); color: var(--accent-yellow); }
.tag.redeemed { background: var(--gray-soft); color: var(--text-secondary); }
.tag.koed { background: var(--blue-soft); color: var(--accent-blue); }
.tag.manual { background: var(--purple-soft); color: var(--accent-purple); }
.tag.market { background: var(--blue-soft); color: var(--accent-blue); }
.tag.kied { background: var(--red-soft); color: var(--accent-red); }

/* ============ 提示文字 ============ */
.hint { color: var(--text-muted); font-size: var(--text-xs); line-height: 1.5; }
.positive { color: var(--accent-green); }
.negative { color: var(--accent-red); }
.zero { color: var(--text-secondary); }

/* ============ 文本溢出（超长名称/备注截断，hover 用 title 显示完整） ============ */
.text-ellipsis { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.text-ellipsis-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ============ Tab 切换 ============ */
.tab-bar { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border-color); overflow-x: auto; scrollbar-width: thin; }
.tab { padding: 10px 20px; background: none; border: none; border-bottom: 2px solid transparent; color: var(--text-secondary); cursor: pointer; font-size: var(--text-base); font-weight: 500; transition: background-color var(--transition-normal) ease, color var(--transition-normal) ease, border-color var(--transition-normal) ease, box-shadow var(--transition-normal) ease, transform var(--transition-normal) ease; white-space: nowrap; flex-shrink: 0; }
.tab:hover { color: var(--text-primary); background: var(--gray-soft); }
.tab.active { color: var(--accent-blue); border-bottom-color: var(--accent-blue); }

/* ============ 分页 ============ */
.pagination {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border-color); flex-wrap: wrap; gap: 10px;
}
.pagination-info { color: var(--text-secondary); font-size: var(--text-sm); }
.pagination-controls { display: flex; gap: 6px; align-items: center; }
.page-btn {
  padding: 6px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-color);
  background: var(--bg-primary); color: var(--text-primary); cursor: pointer; font-size: var(--text-sm); transition: background-color var(--transition-normal) ease, color var(--transition-normal) ease, border-color var(--transition-normal) ease, box-shadow var(--transition-normal) ease, transform var(--transition-normal) ease;
}
.page-btn:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--accent-blue); }
.page-btn.active { background: var(--accent-blue); border-color: var(--accent-blue); color: white; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.page-size-select {
  padding: 6px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border-color);
  background: var(--bg-primary); color: var(--text-primary); font-size: var(--text-sm);
}

/* ============ 加载 / 空态 ============ */
.loading { text-align: center; padding: 40px; color: var(--text-secondary); display: flex; align-items: center; justify-content: center; gap: 8px; }
.loading::before { content: ''; flex-shrink: 0; width: 16px; height: 16px; border: 2px solid var(--border-color); border-top-color: var(--accent-blue); border-radius: 50%; animation: spin 0.8s linear infinite; }
.empty { text-align: center; padding: 40px 20px; color: var(--text-muted); }
/* 空态占位符号：虚线圈（线条语言，居中于纯文字空态之上） */
.empty::before {
  content: ''; display: block; width: 38px; height: 38px; margin: 0 auto 12px;
  border: 1px dashed var(--border-strong); border-radius: 50%; opacity: .55;
}
.spinner, .loading-spinner {
  display: inline-block; width: 32px; height: 32px; border: 3px solid var(--border-color);
  border-top-color: var(--accent-blue); border-radius: 50%; animation: spin 0.8s linear infinite; margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed; inset: 0; background: var(--mask-bg); display: flex;
  align-items: center; justify-content: center; z-index: 100; padding: 20px;
  opacity: 0; visibility: hidden; transition: opacity 0.18s ease, visibility 0.18s ease;
}
.modal-mask.show { opacity: 1; visibility: visible; }
.modal {
  background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: var(--radius-lg);
  width: 100%; max-width: 760px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
  transform: scale(0.96) translateY(10px); opacity: 0;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.18s ease;
}
.modal-mask.show .modal { transform: scale(1) translateY(0); opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .modal-mask, .modal { transition: none; }
  .modal { transform: none; opacity: 1; }
  .nav-item.active::before { animation: none; }
  .data-table tbody tr { animation: none; }
  body.page-enter .sidebar { animation: none !important; }
}
.modal-header {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--border-color);
  flex-shrink: 0; background: var(--bg-secondary); z-index: 1;
}
.modal-title { font-size: var(--text-lg); font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-secondary); font-size: var(--text-xl); cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 20px; overflow-y: auto; overflow-x: auto; flex: 1 1 auto; min-height: 0; }

/* ============ 表单 ============ */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field.full { grid-column: 1 / -1; }
.form-label { font-size: var(--text-sm); color: var(--text-secondary); }
.form-label .required { color: var(--accent-red); }
.form-input, .form-select, .form-textarea {
  padding: 9px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-color);
  background: var(--bg-primary); color: var(--text-primary); font-size: var(--text-base); outline: none; width: 100%; font-family: inherit;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--accent-blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.form-textarea { min-height: 70px; resize: vertical; }
.form-actions {
  display: flex; justify-content: flex-end; gap: 10px;
  margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border-color);
}

/* ============ 滚动条 ============ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--radius-sm); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============ 响应式 ============ */
/* 超宽屏：内容居中限宽，避免 4K 下无限拉伸 */
@media (min-width: 1600px) {
  .main-content { max-width: 90rem; margin-inline: auto; }
}
@media (max-width: 1200px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .chart-row.row-2 { grid-template-columns: 1fr; }
  .chart-container { height: 300px; }
}
@media (max-width: 768px) {
  .skip-link { display: none; }
  .main-content { padding: 12px; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 240px; height: 100vh; height: 100dvh;
    z-index: 1000; transform: translateX(-100%); transition: transform 0.2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar.collapsed { width: 240px; }
  .sidebar.collapsed .nav-text { display: block; }
  .sidebar.collapsed .nav-item { justify-content: flex-start; padding: 10px 12px; }
  .sidebar.collapsed .sidebar-title { display: block; }
  .sidebar-toggle { display: none; }
  .sidebar-overlay {
    position: fixed; inset: 0; background: var(--mask-bg); z-index: 999; display: none;
  }
  .sidebar-overlay.show { display: block; }
  .mobile-menu-btn { display: flex; }
  .header { flex-direction: column; align-items: stretch; gap: 12px; }
  .header-left { gap: 10px; }
  .logo { font-size: var(--text-xl); }
  .logo-sub { font-size: var(--text-xs); }
  .header-right { width: 100%; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
  .stats-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px 16px; }
  .stat-label { font-size: var(--text-xs); }
  .stat-value { font-size: var(--text-xl); }
  .chart-card { padding: 14px; }
  .chart-container { height: 260px; }
  .chart-title { font-size: var(--text-base); margin-bottom: 10px; }
  .table-section { padding: 14px; }
  .table-header { flex-direction: column; align-items: stretch; }
  .table-actions { width: 100%; }
  .search-input { width: 100%; flex: 1 1 100%; }
  .filter-select { flex: 1 1 auto; }
  .toolbar .form-input, .toolbar .filter-select { width: 100% !important; }
  .pagination { flex-direction: column; gap: 12px; align-items: stretch; }
  .pagination-controls { justify-content: space-between; flex-wrap: wrap; }
  .form-grid { grid-template-columns: 1fr; }
  /* 移动端触控：增大点击区域（≥40px 触控标准） */
  .btn { padding: 10px 16px; min-height: 40px; }
  .btn-sm { padding: 6px 12px; min-height: 40px; }
  .nav-item { padding: 13px 14px; }
  .tab { padding: 12px 16px; }
  .page-btn { padding: 8px 14px; min-height: 40px; }
  .page-size-select { min-height: 40px; }
  /* 移动端表格：减小内边距，提高信息密度与可读性 */
  .data-table th, .data-table td { padding: 9px 8px; }
  /* 移动端表格：横向滚动时首列固定，保留行锚点 */
  .data-table th:first-child,
  .data-table td:first-child { position: sticky; left: 0; background: var(--bg-card); z-index: 1; }
}

/* ============ 设备精细化响应式：直板手机 / 折叠屏 / 平板 ============ */

/* 平板（821-1024px）：图表恢复双列，充分利用横向空间 */
@media (min-width: 821px) and (max-width: 1024px) {
  .chart-row.row-2 { grid-template-columns: 1fr 1fr; }
}

/* 折叠屏展开（481-820px）：卡片双列（沿用上方）、图表单列、高度适中 */
@media (min-width: 481px) and (max-width: 820px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .chart-row.row-2 { grid-template-columns: 1fr; }
  .chart-container { height: 280px; }
}

/* 直板手机（≤480px）：卡片单列、图表更紧凑、区块标题换行 */
@media (max-width: 480px) {
  .stats-row { grid-template-columns: 1fr; gap: 10px; }
  .stat-value { font-size: var(--text-xl); }
  .stat-label { font-size: var(--text-sm); }
  .chart-container { height: 220px; }
  .chart-card { padding: 12px; }
  .chart-title { font-size: var(--text-base); }
  .table-section { padding: 12px; }
  .fcn-section-header { flex-direction: column; align-items: flex-start; gap: 10px; }
}

/* ============ 统一组件：分段控件（独立圆角胶囊） ============ */
.seg-control { display: flex; gap: 4px; }
.seg-control .seg { padding: 6px 14px; background: var(--bg-primary); border: 1px solid var(--border-color); border-radius: var(--radius-sm); color: var(--text-secondary); cursor: pointer; font-size: var(--text-sm); font-weight: 500; transition: background-color var(--transition-normal) ease, color var(--transition-normal) ease, border-color var(--transition-normal) ease, box-shadow var(--transition-normal) ease, transform var(--transition-normal) ease; }
.seg-control .seg:hover { color: var(--text-primary); border-color: var(--border-strong); }
.seg-control .seg.active { background: var(--accent-blue); border-color: var(--accent-blue); color: var(--on-accent); }

/* ============ 统一组件：区块标题渐变条（3×16px） ============ */
.fcn-section-title::before,
.settings-section-title::before { content: ''; width: 3px; height: 16px; background: var(--brand-gradient); border-radius: var(--radius-pill); }

/* 分段控件移动端触控（≥40px） */
@media (max-width: 768px) {
  .seg-control .seg { padding: 10px 16px; min-height: 40px; }
}

/* ============ 全局搜索面板 ============ */

/* ============ 骨架屏 ============ */
.skeleton { background: linear-gradient(90deg, var(--bg-hover) 25%, var(--border-color) 37%, var(--bg-hover) 63%); background-size: 400% 100%; animation: skeleton-shimmer 1.4s ease infinite; border-radius: var(--radius-sm); }
.skeleton-row { height: 16px; margin: 10px 0; }
@keyframes skeleton-shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* ============ 可折叠区块 + 锚点导航 ============ */
.section-collapsible .section-head { display: flex; align-items: center; justify-content: space-between; cursor: pointer; user-select: none; }
.section-collapsible .section-head .caret { transition: transform 0.2s; color: var(--text-muted); }
.section-collapsible.collapsed .section-body { display: none; }
.section-collapsible.collapsed .caret { transform: rotate(-90deg); }

/* ============ 通用工具类（替代内联样式） ============ */
.chart-title-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--spacing-2); }
.section-title-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--spacing-2); cursor: pointer; }
.toolbar-row { display: flex; align-items: center; gap: var(--spacing-2); flex-wrap: wrap; }
.anchor-nav { position: fixed; right: 12px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.anchor-nav a { display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; }
.anchor-nav a::after { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--border-strong); transition: background 0.2s, transform 0.2s; }
.anchor-nav a.active::after { background: var(--accent-blue); transform: scale(1.35); }
.anchor-nav a:hover::after { background: var(--accent-blue); }

/* ============ 列配置面板 ============ */
.col-config { position: absolute; background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); padding: 8px; z-index: 40; min-width: 180px; display: none; }
.col-config.open { display: block; }
.col-config label { display: flex; align-items: center; gap: 8px; padding: var(--spacing-1) var(--spacing-2); font-size: var(--text-sm); color: var(--text-primary); cursor: pointer; border-radius: var(--radius-sm); }
.col-config label:hover { background: var(--bg-hover); }
.col-config input[type=checkbox] { accent-color: var(--accent-blue); }

/* ============ 文档左右分栏 ============ */
.doc-split { display: flex; gap: 16px; align-items: flex-start; }
.doc-split-side { width: 240px; flex-shrink: 0; position: sticky; top: 12px; max-height: calc(100vh - 100px); overflow-y: auto; }
.doc-split-main { flex: 1; min-width: 0; }
@media (max-width: 820px) { .doc-split { flex-direction: column; } .doc-split-side { width: 100%; position: static; max-height: none; } }

/* ============ 文件类型图标 ============ */
.file-ico { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: var(--radius-sm); font-size: var(--text-2xs); font-weight: 700; flex-shrink: 0; color: var(--on-accent); }
.file-ico.pdf { background: var(--file-pdf); }
.file-ico.doc { background: var(--file-doc); }
.file-ico.img { background: var(--file-img); }
.file-ico.xls { background: var(--file-xls); }
.file-ico.txt { background: var(--file-txt); }

/* ============ 危险操作弹窗（ESC/蒙层不关闭） ============ */
.modal-mask.danger .modal-close { display: none; }

/* ============ 系统通知（铃铛 + 面板） ============ */
.notify-badge { margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--radius-pill); background: var(--accent-red); color: var(--on-accent); font-size: var(--text-xs); line-height: 18px; text-align: center; font-weight: 600; }
.notify-badge.warn { background: var(--accent-yellow); color: var(--on-warning); }
.notify-panel { position: absolute; top: calc(100% - 4px); left: 12px; right: 12px; max-height: 360px; overflow: hidden; background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); z-index: 45; display: none; flex-direction: column; }
.notify-panel.open { display: flex; }
.notify-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--border-color); font-size: var(--text-sm); font-weight: 600; }
.notify-updated { font-size: var(--text-xs); font-weight: 400; color: var(--text-muted); }
.notify-list { overflow-y: auto; padding: 6px; }
.notify-item { display: flex; gap: 8px; padding: 8px 10px; border-radius: var(--radius-sm); font-size: var(--text-xs); line-height: 1.5; text-decoration: none; }
.notify-item + .notify-item { margin-top: 4px; }
.notify-item.crit { background: var(--red-soft); color: var(--accent-red); }
.notify-item.warn { background: var(--yellow-soft); color: var(--accent-yellow); }
.notify-item.info { background: var(--blue-soft); color: var(--text-secondary); }
.notify-tag { flex: 0 0 auto; align-self: flex-start; padding: 1px 6px; border-radius: var(--radius-lg); background: var(--bg-hover); color: var(--text-secondary); font-size: var(--text-xs); line-height: 16px; white-space: nowrap; }
.notify-body { flex: 1 1 auto; min-width: 0; display: flex; gap: 8px; align-items: flex-start; color: inherit; text-decoration: none; }
.notify-text { flex: 1 1 auto; min-width: 0; overflow-wrap: break-word; }
.notify-empty { padding: 16px; text-align: center; color: var(--text-muted); font-size: var(--text-sm); }
.notify-meta { padding: 8px 12px; border-top: 1px solid var(--border-color); font-size: var(--text-xs); color: var(--text-muted); }
.notify-more { display: block; padding: 8px 12px; border-top: 1px solid var(--border-color); font-size: var(--text-xs); color: var(--accent-blue); text-decoration: none; }
.notify-more:hover { background: var(--bg-hover); }

/* ============ 浮层进入动画（通知面板 / 搜索面板 / 列配置） ============ */
.notify-panel.open, .col-config.open {
  animation: popover-in .16s var(--ease-standard) both;
}
@keyframes popover-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

/* ============ 打印样式（全站：隐藏界面外壳，输出白纸黑字） ============ */
@media print {
  /* 强制浅色变量（覆盖深色主题），保证打印可读 */
  :root, html[data-theme] {
    --bg-primary: #fff; --bg-secondary: #fff; --bg-card: #fff;
    --bg-subtle: #fff; --bg-raised: #fff; --bg-hover: #fff;
    --text-primary: #000; --text-secondary: #333; --text-muted: #555;
    --border-color: #bbb; --border-strong: #888;
    --shadow: none; --shadow-lg: none;
    color-scheme: light;
  }
  html[data-theme], body { background: #fff !important; color: #000 !important; }
  /* 隐藏界面外壳与交互控件 */
  .sidebar, .sidebar-overlay, .mobile-menu-btn, .theme-row,
  .anchor-nav, .tab-bar, .toolbar, .pagination, .btn, .header-right, .skip-link,
  #hintBar, #snapshotBanner, .no-print { display: none !important; }
  .app-layout { display: block; }
  .main-content { padding: 0 !important; max-width: none !important; }
  .header { border-bottom: 1px solid #999; margin: 0 0 12px; padding: 0 0 8px; }
  /* 区块去阴影、避免跨页断行 */
  .card, .table-section, .chart-card, .stat-card {
    box-shadow: none !important; border: 1px solid #bbb !important;
    break-inside: avoid; page-break-inside: avoid;
  }
  .table-wrap { overflow: visible !important; }
  .data-table thead { display: table-header-group; }
  .data-table tr { break-inside: avoid; page-break-inside: avoid; }
  .data-table tbody tr:nth-child(even) { background: transparent !important; }
  a { color: #000 !important; text-decoration: none !important; }
  /* 报表标题用衬线，贴近纸质单据 */
  .page-title, .table-title, .chart-title,
  .fcn-section-title, .settings-section-title {
    font-family: var(--font-serif);
  }
}

/* 校验失败字段定位高亮（配合 manage.js focusField） */
.field-error { border-color: var(--accent-red) !important; box-shadow: 0 0 0 3px var(--red-soft) !important; }

/* 快捷键帮助浮层（? 唤起） */
.shortcut-help { position: fixed; inset: 0; background: var(--mask-bg); z-index: 3000; display: flex; align-items: center; justify-content: center; }
.sh-panel { background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 20px 24px; min-width: 260px; }
.sh-panel h3 { font-size: var(--text-lg); margin-bottom: 12px; }
.sh-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 0; font-size: var(--text-sm); color: var(--text-secondary); }
.sh-row kbd { background: var(--bg-hover); border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 1px 6px; font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-primary); }
.sh-row span { margin-left: auto; }
.sh-hint { margin-top: 10px; font-size: var(--text-xs); color: var(--text-muted); text-align: center; }

/* WCAG 2.2 focus-not-obscured：聚焦元素不被 sticky 表头遮挡 */
.data-table a, .data-table button, .data-table input, .data-table [tabindex] { scroll-margin-top: 3rem; }

/* 弹窗出场更快（Ant Motion 高效原则；reduced-motion 下不生效） */
@media (prefers-reduced-motion: no-preference) {
  .modal-mask:not(.show) { transition-duration: 0.14s; }
  .modal-mask:not(.show) .modal { transition: transform 0.15s ease, opacity 0.15s ease; }
}

/* 通用：分区小标题（跨页复用，勿依赖各页私有 CSS） */
.panel-caption { font-size: var(--text-xs); color: var(--text-muted); padding: 10px 4px 2px; }
/* 通用：统计卡的文本型数值（非纯数字，字号略小防溢出） */
.stat-value.is-text { font-size: var(--text-xl); line-height: 1.4; }

/* ============ 头部通知铃铛 + 用户头像（右上角） ============ */
.header-notify { position: relative; display: flex; align-items: center; margin-left: auto; }
.header-icon-btn { position: relative; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; border-radius: 50%; background: var(--bg-secondary); border: 1px solid var(--border-color); color: var(--text-secondary); cursor: pointer; transition: color var(--transition-normal) ease, border-color var(--transition-normal) ease, background-color var(--transition-normal) ease; }
.header-icon-btn:hover { color: var(--text-primary); background: var(--bg-hover); border-color: var(--border-strong); }
.header-icon-btn:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 2px; }
.header-icon-btn .nav-icon { display: flex; align-items: center; justify-content: center; color: inherit; }
.header-icon-btn .nav-icon svg { width: 18px; height: 18px; }
.header-icon-btn .notify-badge { position: absolute; top: -4px; right: -4px; margin-left: 0; }
.header-notify .notify-panel { top: calc(100% + 8px); left: auto; right: 0; width: min(360px, 92vw); max-height: min(360px, 70vh); }
.header-avatar { flex: 0 0 auto; border: 0; display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; min-width: 36px; border-radius: 50%; background: var(--brand-gradient); color: var(--on-accent); font-size: var(--text-sm); font-weight: 600; text-decoration: none; text-transform: uppercase; }
.header-avatar:hover { filter: brightness(1.12); }
.header-avatar:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 2px; }
@media (max-width: 640px) {
  .header-right { gap: 8px; }
  .header-icon-btn, .header-avatar { flex: 0 0 auto; width: 32px; height: 32px; }
}
/* 窄屏通知面板：锚点由「铃铛右缘」改为「头部操作行整行」——
   手机布局视口 390px 时铃铛右缘仅 334px，而面板宽 min(360px,92vw)=359px，会向左溢出 25px（360px 机型溢出 27px）。
   这里让 .header-right 成为定位祖先、.header-notify 退出定位，面板用 left/right:0 撑满该行，永不越界。 */
@media (max-width: 460px) {
  .header-right { position: relative; }
  .header-notify { position: static; }
  .header-notify .notify-panel { left: 0; right: 0; width: auto; max-height: min(420px, 70vh); }
}

/* ============ 个人设置页 ============ */
.profile-wrap { max-width: 620px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.profile-card { padding: 20px; }
.profile-h { margin: 0 0 12px; font-size: var(--text-lg); }
.profile-dl { display: grid; grid-template-columns: 96px 1fr; gap: 8px 12px; margin: 0; font-size: var(--text-sm); }
.profile-dl dt { color: var(--text-muted); }
.profile-dl dd { margin: 0; color: var(--text-primary); }
.profile-msg { padding: 10px 14px; border-radius: var(--radius-sm); font-size: var(--text-sm); }
.profile-msg-ok { background: var(--blue-soft); color: var(--accent-blue); }
.profile-msg-error { background: var(--red-soft); color: var(--accent-red); }

/* ============ 头部搜索框（右上角，头像左侧） ============ */

/* ============ 个人设置弹窗 ============ */
/* 两栏自适应：按内容定尺寸，桌面端不产生横/竖滚动条（窄屏回落单栏，允许纵向滚动兜底） */
.modal--profile { max-height: calc(100dvh - 24px); }          /* 按内容定高，尽量不触发纵向滚动 */
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--spacing-5); align-items: start; }
.profile-col { display: flex; flex-direction: column; min-width: 0; }
.profile-col .form-field { gap: var(--spacing-1); }
.profile-col .form-actions { margin-top: var(--spacing-4); padding-top: var(--spacing-3); }
.profile-modal-body { overflow-x: hidden; padding: var(--spacing-4); }   /* 收紧内边距，内容更矮 */
.profile-footer { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center;
  gap: var(--spacing-3); margin-top: var(--spacing-4); padding-top: var(--spacing-3); border-top: 1px solid var(--border-color); }
.profile-footer-group { display: flex; flex-wrap: wrap; align-items: center; gap: var(--spacing-2); }
@media (max-width: 760px) {
  .profile-grid { grid-template-columns: 1fr; gap: var(--spacing-3); }
}
.profile-block { margin-bottom: var(--spacing-3); }
.profile-block:last-child { margin-bottom: 0; }
.profile-h { margin: 0 0 8px; font-size: var(--text-base); }
.profile-dl { display: grid; grid-template-columns: 72px 1fr; gap: 6px 12px; margin: 0; font-size: var(--text-sm); }
.profile-dl dt { color: var(--text-muted); }
.profile-dl dd { margin: 0; color: var(--text-primary); }
.profile-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.profile-row { display: flex; gap: 8px; align-items: center; }
.profile-row .form-input { flex: 1; min-width: 0; }
.profile-row .profile-cc { flex: 0 0 auto; }
.profile-row-del { flex: 0 0 auto; }
@media (max-width: 480px) { .profile-row { flex-wrap: wrap; } .profile-row .profile-cc { flex: 1 1 40%; } }

/* ============ 头部：刷新图标按钮 + 更新时间 ============ */
.header-left .update-time { white-space: nowrap; }
.header-left .header-icon-btn { width: 30px; height: 30px; margin-left: -4px; }   /* 跟时间同排，略收窄以贴合文本 */
.header-left .update-time::before { content: '·'; margin: 0 8px 0 2px; color: var(--text-muted); }
@media (max-width: 640px) { .header-left .update-time::before { content: ''; margin: 0; } }
.header-icon-btn:disabled { opacity: .65; cursor: default; }
.header-icon-btn.is-loading .nav-icon svg { animation: header-spin .8s linear infinite; }
@keyframes header-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .header-icon-btn.is-loading .nav-icon svg { animation: none; } }

/* ============ 侧栏分组：仅管理员 ============ */
.nav-divider { display: flex; align-items: center; gap: 8px; margin: 12px 10px 6px; color: var(--text-muted); font-size: var(--text-xs); letter-spacing: .5px; user-select: none; }
.nav-divider::before, .nav-divider::after { content: ''; height: 1px; background: var(--border-color); flex: 1 1 auto; }
.nav-divider span { white-space: nowrap; }
.sidebar.collapsed .nav-divider { margin: 10px 8px 6px; }
.sidebar.collapsed .nav-divider span { display: none; }


/* ============ 禁止逐字竖排（全局防护） ============
   CJK 在极窄 flex 容器里会被逐字换行（看起来像竖排文字）。约定：
   - 短标签/按钮/徽标（本就 1~6 字）：整块不换行；
   - 标题类：给最小可读宽度 + 所在行允许换行（行内 wrap 由各容器负责），
     绝不被挤到「一字一行」；
   - 长文本：仅在必要时断行（overflow-wrap: break-word），不使用 break-all/anywhere
     （那会放宽 min-content，使 flex 容器可被压到 1 字宽）。 */
.seg, .tab, th, .stat-label, .nav-text, .todo-chip, .fcn-badge, .fcn-line, .kyc-badge,
.doc-type-badge, .event-badge, .notify-tag, .doc-chip { white-space: nowrap; }
.table-title, .chart-title, .fcn-section-title, .card-title { flex: 1 1 auto; min-width: 10ch; }
.stat-change, .hint, .nw-sub, .empty-inline { overflow-wrap: break-word; }
@media (max-width: 380px) {
  /* 双列统计卡在 <=380px 时标签可能超出卡宽：允许自然换行（仍不会逐字） */
  .stat-label { white-space: normal; overflow-wrap: break-word; }
}

/* ============ AI 助手浮动对话框（全站，只读） ============ */
.assistant-fab { position: fixed; right: 22px; bottom: 22px; z-index: 1200; width: 54px; height: 54px; display: flex; align-items: center; justify-content: center; border: 1px solid color-mix(in srgb, var(--accent-blue) 55%, transparent); border-radius: 50%; background: var(--brand-gradient); color: var(--on-accent); cursor: pointer; box-shadow: var(--shadow-lg); transition: transform var(--transition-normal) ease, filter var(--transition-normal) ease; }
.assistant-fab svg { width: 26px; height: 26px; }
.assistant-fab:hover { transform: translateY(-2px); filter: brightness(1.08); }
.assistant-fab:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 3px; }
.assistant-fab.is-open { transform: scale(.94); }
.assistant-fab-panel { position: fixed; right: 22px; bottom: 88px; z-index: 1200; width: min(380px, calc(100vw - 32px)); height: min(560px, 72vh); display: flex; flex-direction: column; background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; }
.assistant-fab-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border-color); }
.assistant-fab-title { font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); white-space: nowrap; }
.assistant-fab-module { font-size: var(--text-xs); color: var(--accent-blue); background: var(--blue-soft); border-radius: var(--radius-pill); padding: 1px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 12ch; }
.assistant-fab-close { margin-left: auto; width: 26px; height: 26px; line-height: 24px; text-align: center; border: none; border-radius: 50%; background: transparent; color: var(--text-muted); font-size: var(--text-lg); cursor: pointer; }
.assistant-fab-close:hover { color: var(--text-primary); background: var(--bg-hover); }
.assistant-fab-msgs { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.assistant-fab-tip { font-size: var(--text-xs); color: var(--text-muted); background: var(--bg-hover); border-radius: var(--radius-sm); padding: 8px 10px; }
.assistant-fab-attach { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0; border: 1px solid var(--border-color); border-radius: var(--radius-sm); background: var(--bg-secondary); color: var(--text-secondary); cursor: pointer; }
.assistant-fab-attach:hover { color: var(--text-primary); border-color: var(--border-strong); }
.assistant-fab-attach svg { width: 16px; height: 16px; }
.assistant-fab-kv { margin: 6px 0 0; padding: 0; list-style: none; }
.assistant-fab-kv li { display: flex; gap: var(--spacing-2); font-size: var(--text-sm); color: var(--text-primary); overflow-wrap: break-word; }
.assistant-fab-kv .assistant-fab-k { flex: 0 0 5.5em; color: var(--text-muted); }
.assistant-fab-actions { display: flex; flex-wrap: wrap; gap: var(--spacing-2); margin-top: var(--spacing-2); }
.assistant-fab-msg { max-width: 88%; font-size: var(--text-sm); line-height: 1.6; border-radius: var(--radius-md); padding: 8px 10px; overflow-wrap: break-word; }
.assistant-fab-msg.is-user { align-self: flex-end; background: var(--accent-blue); color: var(--on-accent); }
.assistant-fab-msg.is-ai { align-self: flex-start; background: var(--bg-hover); color: var(--text-primary); }
.assistant-fab-src { margin-top: 6px; font-size: var(--text-xs); color: var(--text-muted); }
.assistant-fab-err { color: var(--accent-red); font-size: var(--text-sm); }
.assistant-fab-loading { color: var(--text-muted); }
.assistant-fab-quick { display: flex; flex-wrap: wrap; gap: var(--spacing-2); padding: 8px 12px 0; }
.assistant-fab-quick[hidden] { display: none; }
.assistant-fab-chip { border: 1px solid var(--border-color); background: var(--bg-secondary); color: var(--accent-blue);
  border-radius: var(--radius-pill); padding: 4px 10px; font-size: var(--text-xs); cursor: pointer; }
.assistant-fab-chip:hover { background: var(--bg-hover); }
.assistant-fab-chip[hidden] { display: none; }
.assistant-fab-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border-color); }
.assistant-fab-form textarea { flex: 1 1 auto; min-width: 0; resize: none; max-height: 120px; padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border-color); background: var(--bg-primary); color: var(--text-primary); font-size: var(--text-sm); font-family: inherit; }
.assistant-fab-form textarea:focus { border-color: var(--accent-blue); box-shadow: 0 0 0 3px var(--blue-soft); outline: none; }
@media (max-width: 640px) {
  .assistant-fab { right: 14px; bottom: 14px; }
  .assistant-fab-panel { right: 0; bottom: 0; width: 100vw; height: 66vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
}

/* ============ 文档协同模块标签（文档管理 / 协同办公 / 会议纪要） ============ */
.module-tabs { margin-bottom: 14px; }
.module-tabs .tab { text-decoration: none; display: inline-flex; align-items: center; }

/* ============ 无权限页 ============ */
.forbidden-empty { padding: 72px 20px; }
.forbidden-icon { font-size: var(--text-hero); margin-bottom: 16px; }
.forbidden-title { font-size: var(--text-lg); font-weight: 600; color: var(--text-primary); margin-bottom: 8px; }
.forbidden-hint { font-size: var(--text-sm); color: var(--text-secondary); }
.forbidden-actions { margin-top: 20px; display: flex; justify-content: center; gap: 10px; }

/* 通知面板「全部已读」 */
.notify-readall { margin-left: 8px; padding: 1px 8px; border: 1px solid var(--border-color); border-radius: var(--radius-pill); background: transparent; color: var(--text-secondary); font-size: var(--text-xs); cursor: pointer; white-space: nowrap; }
.notify-readall:hover { color: var(--accent-blue); border-color: var(--accent-blue); }
.notify-readall:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 1px; }
.notify-head .notify-updated { margin-left: auto; }


/* ============ 登录后的入场动画（仅同页动画，不用跨文档 View Transition） ============
   历史：2026-09-26 曾用 `@view-transition { navigation: auto }` 做「登录页 → 首页」共享元素
   morph。但在较新版 Chrome（实测 154）上会卡住 root 快照交叉淡入：整页空白，只剩带
   `view-transition-name` 的元素（主题胶囊）可见。跨文档过渡无法从 JS 兜底，故**弃用**，
   登录页改用自身 `leaving` 淡出 + 本页目录栏一次性滑入，跨浏览器稳定可控。 */
@keyframes sidebar-enter { from { transform: translateX(-18px); opacity: 0; } to { transform: none; opacity: 1; } }
body.page-enter .sidebar { animation: sidebar-enter .8s var(--ease-emphasized) both; }


/* 通知条目：只读，点击标记已读（无删除按钮） */
.notify-body-btn { width: 100%; padding: 0; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.notify-body-btn:hover { text-decoration: underline; }
.notify-body-btn:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 2px; }


/* ============ 主题切换：图标胶囊滑块（登录页与侧栏共用组件） ============ */
.theme-seg { display: flex; align-items: center; padding: 2px; width: 110px; height: 32px; border-radius: var(--radius-pill);
  background: var(--bg-hover); border: 1px solid var(--border-color); position: relative;
  transition: background-color .32s ease, border-color .32s ease; }
.theme-seg .seg-opt { position: relative; z-index: 1; flex: 1 1 0; height: 100%; display: flex; align-items: center; justify-content: center;
  background: none; border: none; padding: 0; border-radius: var(--radius-pill); color: var(--text-muted); cursor: pointer; transition: color .28s ease; }
.theme-seg .seg-opt svg { width: 15px; height: 15px; transition: transform .15s ease; }
.theme-seg .seg-opt:hover { color: var(--text-primary); }
.theme-seg .seg-opt:active svg { transform: scale(.88); }
.theme-seg .seg-opt:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 1px; }
.theme-seg .seg-opt[aria-checked="true"] { color: var(--seg-on); }
.theme-seg .seg-knob { position: absolute; top: 2px; left: 2px; width: calc((100% - 4px) / 3); height: calc(100% - 4px);
  border-radius: var(--radius-pill); background: var(--seg-knob-bg); box-shadow: 0 1px 3px rgba(0, 0, 0, .28), 0 0 0 .5px rgba(0, 0, 0, .04);
  transition: transform .38s var(--ease-emphasized); }
[data-theme-mode="auto"] .theme-seg .seg-knob { transform: translateX(100%); }
[data-theme-mode="dark"] .theme-seg .seg-knob { transform: translateX(200%); }
/* 侧栏内的主题胶囊：不固定定位，随侧栏宽度自适应 */
.theme-row .theme-seg { width: 100%; }
.sidebar.collapsed .theme-row { display: none; }
/* 折叠态：头部只剩折叠按钮，居中摆放更稳 */
.sidebar.collapsed .sidebar-header { justify-content: center; }

/* 邮箱账户弹窗（全局：头像 → 个人设置 → 邮箱账户） */
  .ea-status { display: inline-flex; align-items: center; gap: var(--spacing-1); font-size: var(--text-xs); }
  .ea-status .status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); flex: 0 0 auto; }
  .ea-status.on .status-dot { background: var(--accent-green); }
  .ea-status.off .status-dot { background: var(--accent-red); }
  .ea-sub { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; }

/* 提示条（邮件正文拦图提示 / OAuth 授权状态等，全站可用） */
  .em-img-note { display: flex; flex-wrap: wrap; align-items: center; gap: var(--spacing-2);
    padding: var(--spacing-2); margin-bottom: var(--spacing-2); background: var(--bg-hover); border-radius: var(--radius-sm);
    font-size: var(--text-xs); color: var(--text-muted); }
