/* ========== 全局重置 ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f1f5f9; color: #1e293b; line-height: 1.6; font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ========== 登录页 ========== */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 50%, #7c3aed 100%);
  padding: 20px;
}
.login-card {
  background: #fff; border-radius: 16px; padding: 40px; width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-header { text-align: center; margin-bottom: 28px; }
.login-logo {
  width: 56px; height: 56px; background: #2563eb; color: #fff; border-radius: 14px;
  display: flex; align-items: center; justify-content: center; font-size: 28px; margin: 0 auto 16px;
  font-weight: 700;
}
.login-header h1 { font-size: 22px; color: #0f172a; margin-bottom: 6px; }
.login-header p { font-size: 13px; color: #64748b; }
.login-form .btn-block { margin-top: 8px; padding: 12px; font-size: 15px; }
.login-error {
  background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c;
  padding: 8px 12px; border-radius: 6px; font-size: 13px; margin-bottom: 12px;
}
.login-tip { margin-top: 20px; }

/* ========== 主应用框架 ========== */
.app-page { min-height: 100vh; }
.app-header {
  position: sticky; top: 0; z-index: 100; display: flex; align-items: center;
  justify-content: space-between; padding: 0 20px; height: 56px; background: #0f172a;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.app-logo { display: flex; align-items: center; gap: 8px; color: #fff; font-weight: 600; font-size: 15px; white-space: nowrap; }
.app-logo .logo-icon { width: 28px; height: 28px; background: #2563eb; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 16px; }
.app-nav { display: flex; gap: 4px; }
.nav-tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 14px;
  border: none; background: transparent; border-radius: 6px; cursor: pointer; font-size: 12px;
  color: #94a3b8; transition: all 0.2s;
}
.nav-tab .nav-icon { font-size: 17px; }
.nav-tab:hover { color: #fff; background: #1e293b; }
.nav-tab.active { color: #fff; background: #2563eb; }
.user-menu { display: flex; align-items: center; gap: 10px; }
.user-name { color: #e2e8f0; font-size: 13px; font-weight: 500; }
.user-company { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: #1e293b; color: #60a5fa; }
.app-main { max-width: 1300px; margin: 0 auto; padding: 24px 24px 60px; }

/* ========== 页面切换 ========== */
.page-section { display: none; }
.page-section.active { display: block; }

.page-title { font-size: 20px; font-weight: 700; color: #0f172a; }
.page-subtitle { font-size: 13px; color: #64748b; margin-top: 2px; }
.page-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }

/* ========== 指标卡片 ========== */
.metric-grid { display: grid; gap: 12px; margin-bottom: 12px; }
.metric-grid.row2 { grid-template-columns: repeat(2, 1fr); }
.metric-grid.row3 { grid-template-columns: repeat(3, 1fr); }
.metric-grid.row4 { grid-template-columns: repeat(4, 1fr); }
.metric-grid.row5 { grid-template-columns: repeat(5, 1fr); }
.metric-grid.row6 { grid-template-columns: repeat(6, 1fr); }
.metric-grid.row7 { grid-template-columns: repeat(7, 1fr); }
.metric-card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 14px; position: relative;
}
.metric-card.highlight { background: #fefce8; border-color: #fde047; }
.metric-card.primary { background: #eff6ff; border-color: #93c5fd; }
.metric-card .m-name { font-size: 13px; color: #64748b; display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.metric-card .m-name .help {
  display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px;
  border-radius: 50%; background: #e0e7ff; color: #4338ca; font-size: 10px; cursor: help;
  position: relative;
}
.metric-card .m-name .help:hover { background: #6366f1; color: #fff; }
.metric-card .m-name .help::after {
  content: attr(data-tooltip);
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: #1e293b; color: #fff; padding: 6px 10px; border-radius: 6px;
  font-size: 12px; line-height: 1.5; white-space: normal; width: 220px;
  opacity: 0; visibility: hidden; transition: opacity 0.2s, visibility 0.2s;
  z-index: 100; pointer-events: none; font-weight: 400;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.metric-card .m-name .help::before {
  content: ''; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  border: 4px solid transparent; border-top-color: #1e293b;
  opacity: 0; visibility: hidden; transition: opacity 0.2s, visibility 0.2s;
  z-index: 100;
}
.metric-card .m-name .help:hover::after,
.metric-card .m-name .help:hover::before {
  opacity: 1; visibility: visible;
}
.metric-card .m-value { font-size: 24px; font-weight: 700; color: #0f172a; }
.metric-card .m-value.positive { color: #E5484D; }
.metric-card .m-value.negative { color: #16A34A; }
.metric-card .m-sub { font-size: 11px; color: #94a3b8; margin-top: 4px; }
.metric-card .m-formula { font-size: 11px; color: #6366f1; background: #eef2ff; padding: 2px 6px; border-radius: 4px; display: inline-block; margin-top: 4px; }

/* ========== 图表 ========== */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-top: 12px; }
.chart-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 14px; }
.chart-card .c-title { font-size: 14px; font-weight: 600; color: #334155; margin-bottom: 8px; }
.chart-unit-hint { font-size: 11px; font-weight: 400; color: #94a3b8; margin-left: 4px; }
.trend-range-label { font-size: 12px; color: #64748b; text-align: center; margin-top: 8px; padding-top: 6px; border-top: 1px dashed #e2e8f0; }

/* ========== 表单 ========== */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 13px; color: #334155; margin-bottom: 5px; font-weight: 500; }
.form-label .req { color: #ef4444; }
.form-label .opt { color: #94a3b8; font-weight: 400; font-size: 12px; }
.form-input, .form-select {
  width: 100%; padding: 9px 10px; border: 1px solid #cbd5e1; border-radius: 6px;
  font-size: 14px; color: #1e293b; background: #fff; font-family: inherit;
}
.form-input:focus, .form-select:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.amount-wrap { display: flex; align-items: center; border: 1px solid #cbd5e1; border-radius: 6px; overflow: hidden; }
.amount-wrap .sign { padding: 0 12px; font-size: 20px; font-weight: 700; color: #16A34A; background: #f0fdf4; }
.amount-wrap .cur { padding: 0 4px 0 0; font-size: 18px; color: #64748b; }
.amount-wrap input { border: none; flex: 1; padding: 9px 10px; font-size: 18px; font-weight: 600; outline: none; font-family: inherit; }

/* ========== 按钮 ========== */
.btn { display: inline-flex; align-items: center; gap: 4px; padding: 8px 16px; border: none; border-radius: 6px; font-size: 13px; cursor: pointer; transition: all 0.2s; font-weight: 500; font-family: inherit; }
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary { background: #f1f5f9; color: #475569; }
.btn-secondary:hover { background: #e2e8f0; }
.btn-danger { background: #fef2f2; color: #dc2626; }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; padding: 10px; }

/* ========== 方向切换 ========== */
.dir-toggle { display: flex; gap: 8px; }
.dir-btn { flex: 1; padding: 10px; border: 2px solid #e2e8f0; border-radius: 8px; background: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 14px; font-weight: 600; color: #64748b; transition: all 0.2s; }
.dir-btn.active.expense { border-color: #16A34A; background: #f0fdf4; color: #16A34A; }
.dir-btn.active.income { border-color: #E5484D; background: #fef2f2; color: #E5484D; }

/* ========== Tab 栏 ========== */
.tab-bar { display: flex; gap: 2px; border-bottom: 2px solid #e2e8f0; margin-bottom: 16px; }
.tab-item { padding: 8px 18px; border: none; background: transparent; cursor: pointer; font-size: 14px; color: #64748b; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.2s; }
.tab-item.active { color: #2563eb; border-bottom-color: #2563eb; font-weight: 600; }
.btab-content { display: none; }
.btab-content.active { display: block; }

/* ========== 卡片 ========== */
.card { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 16px; margin-bottom: 14px; }
.card .card-title { font-size: 15px; font-weight: 600; color: #0f172a; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid #f1f5f9; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .form-group { margin-bottom: 0; }
.form-actions { display: flex; gap: 12px; justify-content: flex-end; margin: 18px 0 30px; }
@media (max-width: 800px) { .form-grid { grid-template-columns: 1fr; } }

/* ========== 记录列表 ========== */
.record-item { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
.record-item .r-left { flex: 1; }
.record-item .r-type { font-weight: 600; color: #0f172a; font-size: 13px; }
.record-item .r-unit { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: #f1f5f9; color: #475569; margin-left: 4px; }
.record-item .r-date { font-size: 12px; color: #64748b; margin-top: 2px; }
.record-item .r-date .r-opt { font-size: 11px; color: #94a3b8; }
.record-item .r-contract-line { font-size: 12px; margin-top: 4px; }
.record-item .r-contract-line.linked .r-contract { color: #2563eb; }
.record-item .r-contract-line.unlinked .r-nocontract { color: #dc2626; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
.record-item .r-relink { margin-left: 4px; padding: 1px 10px; }
.relink-list { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.relink-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid #e2e8f0; border-radius: 6px; cursor: pointer; font-size: 13px; }
.relink-item:hover { background: #f8fafc; border-color: #cbd5e1; }
.relink-item input { margin: 0; }
.record-item .r-amt { font-weight: 700; font-size: 15px; }
.record-item .r-amt.pos { color: #E5484D; }
.record-item .r-amt.neg { color: #16A34A; }
.record-item .r-edit { margin-left: 8px; }
.record-item .r-del { margin-left: 6px; }

/* 录入页右侧：记录筛选栏 + 分页 */
.rec-filters { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.form-select-sm, .form-input-sm { height: 32px; font-size: 13px; padding: 4px 8px; border: 1px solid #e2e8f0; border-radius: 6px; background: #fff; color: #0f172a; }
.form-input-sm { flex: 1; min-width: 120px; }
.rec-pager { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 12px; }
.rec-pager .rec-page-info { font-size: 13px; color: #64748b; }
.rec-pager .btn.disabled { opacity: .45; cursor: not-allowed; }

/* ========== 表格 ========== */
.list-toolbar { display: flex; justify-content: space-between; align-items: center; margin: 12px 0 10px; }
.list-title { font-size: 14px; font-weight: 600; color: #0f172a; }
.table-wrap { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { background: #f1f5f9; color: #475569; font-weight: 600; text-align: left; padding: 10px 12px; border-bottom: 2px solid #e2e8f0; font-size: 12px; white-space: nowrap; }
.data-table td { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; color: #334155; }
.data-table tr:hover td { background: #f8fafc; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tfoot td { background: #f8fafc; font-weight: 600; }
.data-table .amt.pos { color: #E5484D; font-weight: 600; }
.data-table .amt.neg { color: #16A34A; font-weight: 600; }

/* 合同明细子表（商品/服务费行） */
.sub-block-title { font-size: 13px; font-weight: 600; color: #374151; margin: 10px 0 6px; }
.sub-row { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.sub-row .form-select, .sub-row .form-input { flex: 1; min-width: 0; }
.sub-row .btn { flex: none; }

/* 合同录入：明细卡片 */
.ci-card { padding: 16px 16px 14px; }
.ci-card .card-title { margin-bottom: 8px; }
.sub-hint {
  font-size: 12px; color: #64748b; line-height: 1.5;
  padding: 4px 0 8px; margin: 0;
}
.ci-empty {
  font-size: 12px; color: #94a3b8; padding: 14px 0; text-align: center;
  background: #f8fafc; border-radius: 4px; margin-bottom: 6px;
}
.ci-add-btn {
  margin-top: 10px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; font-size: 13px;
}
.ci-add-btn .ci-add-ic {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%;
  background: rgba(255,255,255,.25); font-weight: 700; font-size: 14px; line-height: 1;
}

/* 合同明细：grid 布局对齐列标题 */
.sub-row.sub-row-item { display: grid; grid-template-columns: 2fr 0.9fr 1.2fr 72px; gap: 8px; align-items: center; margin-bottom: 6px; }
.sub-row.sub-row-svc  { display: grid; grid-template-columns: 1.8fr 1fr 1.2fr 72px; gap: 8px; align-items: center; margin-bottom: 6px; }
.sub-row.sub-row-item .ci-product { width: 100%; }
.sub-row.sub-row-item .ci-qty, .sub-row.sub-row-item .ci-price { width: 100%; }
.sub-row.sub-row-svc .cs-service { width: 100%; }
.sub-row.sub-row-svc .cs-ref, .sub-row.sub-row-svc .cs-amt { width: 100%; }
/* 参考费用只读：灰底、不可点 */
.cs-ref[readonly] {
  background: #f1f5f9 !important;
  color: #475569;
  cursor: not-allowed;
  text-align: right;
}

/* 表头：明显加粗/加大字号/底色/列分隔线 */
.sub-row.sub-row-head {
  background: #eef2f7; border-radius: 6px;
  padding: 10px 12px; margin-bottom: 4px;
  border: 1px solid #e2e8f0;
}
.sub-row.sub-row-head.sub-row-item { display: grid; grid-template-columns: 2fr 0.9fr 1.2fr 72px; }
.sub-row.sub-row-head.sub-row-svc  { display: grid; grid-template-columns: 1.8fr 1fr 1.2fr 72px; }
.sub-row.sub-row-head .ci-label {
  font-size: 14px; font-weight: 700; color: #1e293b;
  line-height: 1.4; letter-spacing: .3px;
  border-right: 1px solid #cbd5e1; padding-right: 8px;
}
.sub-row.sub-row-head .ci-label:last-child { border-right: none; padding-right: 0; }
.ci-label-action { text-align: center; }

.ci-del-btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 32px; padding: 0 10px;
  background: #fef2f2; color: #dc2626;
  border: 1px solid #fecaca; border-radius: 4px;
  font-size: 12px; font-weight: 500; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.ci-del-btn:hover { background: #fee2e2; border-color: #fca5a5; color: #b91c1c; }
/* 子页面切换（合同录入/查询） */
.sub-nav-bar { display: flex; gap: 4px; border-bottom: 2px solid #e2e8f0; margin-bottom: 16px; }
.sub-nav-tab { padding: 10px 18px; cursor: pointer; font-size: 14px; color: #64748b; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.15s; user-select: none; }
.sub-nav-tab:hover { color: #2563eb; background: #f8fafc; }
.sub-nav-tab.active { color: #2563eb; border-bottom-color: #2563eb; font-weight: 600; }
.sub-page { animation: fadeIn 0.2s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
/* 商品分析：明显的 tab 切换按钮组（收入=蓝涨红，支出=绿跌绿） */
.ana-tab-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.ana-tab { background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 10px; padding: 14px 18px; cursor: pointer; transition: all 0.15s; display: flex; align-items: center; gap: 12px; user-select: none; }
.ana-tab:hover { background: #e2e8f0; }
/* 默认 active 实心深蓝+白字（收入类），与下方白底列表形成鲜明对比 */
.ana-tab.active { border-color: transparent; background: linear-gradient(135deg, #2563eb, #1d4ed8); color: #fff; box-shadow: 0 6px 16px rgba(37,99,235,0.35); }
.ana-tab.active .ana-tab-title,
.ana-tab.active .ana-tab-sub { color: #fff; }
/* 支出类 active 实心深绿+白字 */
.ana-tab[data-tab="purchase"].active { background: linear-gradient(135deg, #16a34a, #15803d); box-shadow: 0 6px 16px rgba(22,163,74,0.35); }
.ana-tab[data-tab="purchase"].active .ana-tab-title { color: #fff; }
.ana-tab .ana-tab-icon { font-size: 26px; line-height: 1; }
.ana-tab .ana-tab-title { font-size: 15px; font-weight: 600; color: #0f172a; }
.ana-tab .ana-tab-sub { font-size: 12px; color: #64748b; margin-top: 2px; }
.data-table .amt.recv-amt { color: #F59E0B; font-weight: 600; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.badge.b { background: #dbeafe; color: #1d4ed8; }
.badge.g { background: #d1fae5; color: #047857; }
.badge.r { background: #fee2e2; color: #b91c1c; }
.badge.y { background: #fef3c7; color: #b45309; }
.badge.gray { background: #e2e8f0; color: #475569; }
.badge.p { background: #ede9fe; color: #6d28d9; }

/* ========== 设置 ========== */
.setting-row { display: flex; justify-content: space-between; align-items: center; }
.setting-name { font-size: 15px; font-weight: 600; color: #0f172a; }
.setting-desc { font-size: 12px; color: #64748b; margin-top: 2px; }
.status-tag { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: #dcfce7; color: #059669; margin-left: 6px; }
.status-tag.status-active { background: #dcfce7; color: #059669; margin-left: 0; }
.status-tag.status-left { background: #f1f1f3; color: #8a8f98; margin-left: 0; }
/* 入离职记录 / 工时页状态标签 */
.status-tag.status-onboard { background: #dcfce7; color: #059669; margin-left: 0; }
.status-tag.status-reinstate { background: #e0efff; color: #2563eb; margin-left: 0; }
.status-tag.status-dim { background: #f1f1f3; color: #8a8f98; margin-left: 0; }

/* 员工档案：离职期间提示（解决"无法得知什么期间离职"） */
.leave-hint { font-size: 11px; color: #ef6c4d; margin-top: 3px; line-height: 1.4; }

/* 工时页：当月发生状态变更时的红字提示 */
.month-change-hint { font-size: 11px; color: #e23d3d; margin-top: 3px; line-height: 1.35; }

/* 离职员工在工时表中整行灰显、不可编辑 */
.row-left td { color: #b3b8c2; }
.row-left .form-input { background: #f6f7f9; color: #b3b8c2; cursor: not-allowed; }

/* 分段筛选控件（全部/在职/离职） */
.seg-group { display: inline-flex; border: 1px solid var(--color-border-secondary, #d8dde6); border-radius: 8px; overflow: hidden; }
.seg-btn { border: none; background: #fff; padding: 6px 14px; font-size: 13px; color: #5f6b7a; cursor: pointer; }
.seg-btn + .seg-btn { border-left: 1px solid var(--color-border-secondary, #d8dde6); }
.seg-btn.active { background: #3b6d11; color: #fff; }

/* 警告按钮（标记离职） */
.btn-warning { border: 1px solid #e0a93b; background: #fff; color: #b9810f; }
.btn-warning:hover { background: #fdf6e7; }
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background: #cbd5e1; border-radius: 24px; transition: 0.3s; }
.slider:before { content: ""; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: 0.3s; }
input:checked + .slider { background: #2563eb; }
input:checked + .slider:before { transform: translateX(20px); }
.check-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid #e2e8f0; border-radius: 6px; margin-bottom: 6px; font-size: 13px; }
.check-item input { width: 16px; height: 16px; accent-color: #2563eb; }
.check-item .del-unit { margin-left: auto; color: #dc2626; cursor: pointer; font-size: 16px; }
.unit-add { display: flex; gap: 8px; margin-top: 8px; }

/* ========== Modal ========== */
.modal-overlay-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-box { background: #fff; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,0.2); max-width: 480px; width: 100%; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid #f1f5f9; position: sticky; top: 0; background: #fff; z-index: 1; }
.modal-header h3 { font-size: 16px; color: #0f172a; }
.modal-close { width: 28px; height: 28px; border: none; background: transparent; font-size: 20px; color: #94a3b8; cursor: pointer; border-radius: 4px; }
.modal-close:hover { background: #f1f5f9; }
.modal-body { padding: 20px; }
.modal-footer { padding: 12px 20px; border-top: 1px solid #f1f5f9; display: flex; justify-content: flex-end; gap: 8px; }

/* ========== Toast ========== */
#toastContainer { position: fixed; top: 70px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #fff; border-radius: 8px; padding: 12px 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  font-size: 13px; display: flex; align-items: center; gap: 8px; min-width: 240px; max-width: 360px;
  border-left: 4px solid #2563eb; animation: slideIn 0.3s ease;
}
.toast.success { border-left-color: #059669; }
.toast.error { border-left-color: #dc2626; }
.toast.warning { border-left-color: #f59e0b; }
.toast .ic { font-size: 16px; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ========== 提示框 ========== */
.info-tip { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 6px; padding: 8px 12px; font-size: 13px; color: #1e40af; display: flex; gap: 6px; align-items: flex-start; }
.info-tip .ic { flex-shrink: 0; }
.text-muted { color: #64748b; }
.empty-state { text-align: center; padding: 32px; color: #94a3b8; font-size: 14px; }

/* ========== 看板时间段标签 & 导出按钮 ========== */
.range-label {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 13px; color: #475569; background: #f1f5f9; border: 1px solid #e2e8f0;
  border-radius: 6px; padding: 4px 10px; white-space: nowrap; height: 32px; line-height: 1;
}
.range-label::before { content: "📅"; }
.btn-export {
  background: #2563eb; color: #fff; border: 1px solid #2563eb; box-shadow: 0 1px 2px rgba(37,99,235,0.2);
}
.btn-export:hover { background: #1d4ed8; border-color: #1d4ed8; }
.btn-export::before { content: "⬇"; margin-right: 3px; }

/* ========== 杂费类别备注 ========== */
.misc-note { color: #64748b; font-size: 13px; line-height: 1.5; max-width: 320px; }

/* ========== 汇率信息栏 ========== */
.rate-info-bar {
  background: #f0f9ff; border: 1px solid #bae6fd; border-radius: 6px;
  padding: 6px 12px; font-size: 12px; color: #0369a1; margin-bottom: 12px;
  display: flex; align-items: center; gap: 6px;
}
.rate-info-bar .rate-tag {
  background: #0284c7; color: #fff; padding: 1px 6px; border-radius: 3px; font-size: 11px;
}
.rate-info-bar .rate-warn {
  background: #f59e0b; color: #fff; padding: 1px 6px; border-radius: 3px; font-size: 11px;
}

/* ========== 可搜索下拉 combobox ========== */
.combobox { position: relative; }
.cb-input { width: 100%; }
.cb-panel {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 60;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15,23,42,0.12); max-height: 220px; overflow-y: auto;
  display: none;
}
.cb-panel.open { display: block; }
.cb-option { padding: 8px 12px; font-size: 13px; color: #334155; cursor: pointer; }
.cb-option:hover { background: #f1f5f9; }
.cb-option.selected { background: #eff6ff; color: #2563eb; font-weight: 500; }
.cb-empty { padding: 10px 12px; font-size: 13px; color: #94a3b8; }
.dup-hint { margin-top: 6px; font-size: 12px; color: #dc2626; min-height: 17px; }
.cb-option .tag { float: right; font-size: 11px; color: #fff; background: #10b981; padding: 1px 6px; border-radius: 4px; }
.cb-option.disabled { color: #94a3b8; cursor: not-allowed; background: #f8fafc; }
.cb-option.disabled .tag { background: #94a3b8; }

/* ========== 库存时间 / 看板库存模块 ========== */
.inv-time { color: #94a3b8; font-size: 12px; white-space: nowrap; }
/* 看板各模块统一为卡片式外框，彼此并列、风格一致 */
.dash-module {
  margin-top: 18px; background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
  padding: 16px 18px; box-shadow: 0 1px 2px rgba(15,23,42,0.04);
}
.dash-module .module-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.dash-module .module-title { font-size: 16px; font-weight: 600; color: #0f172a; }
.dash-module .module-sub { font-size: 12px; color: #94a3b8; }

/* 核心指标模块：强调色 */
.core-module { background: linear-gradient(180deg,#fbfaff 0%, #ffffff 60%); border-color: #c7d2fe; box-shadow: 0 2px 10px rgba(99,102,241,0.10); }
.core-module .module-title { color: #4338ca; }

/* 日常经营指标分组（收入类 / 支出类） */
.sub-group { margin-bottom: 14px; }
.sub-group:last-child { margin-bottom: 0; }
.sub-label {
  font-size: 12.5px; font-weight: 600; margin-bottom: 8px; display: inline-flex; align-items: center; gap: 6px;
  padding-left: 9px; position: relative;
}
.sub-label::before { content: ''; position: absolute; left: 0; top: 1px; bottom: 1px; width: 3px; border-radius: 2px; }
.sub-label.income-label { color: #E5484D; }
.sub-label.income-label::before { background: #E5484D; }
.sub-label.expense-label { color: #16A34A; }
.sub-label.expense-label::before { background: #16A34A; }

/* 员工工资模块 + 阿米巴理念说明框 */
.wage-module { border-color: #fcd34d; }
.wage-note {
  display: flex; gap: 10px; background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px;
  padding: 10px 12px; font-size: 12.5px; color: #92400e; line-height: 1.6; margin-bottom: 14px;
}
.wage-note .wn-ic { font-size: 16px; flex-shrink: 0; line-height: 1.5; }
.wage-note b { color: #b45309; }

/* 看板库存筛选条 */
.inv-filter-bar { margin-bottom: 10px; }

/* ========== 响应式 ========== */
@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
  .chart-grid { grid-template-columns: 1fr; }
  .metric-grid.row3, .metric-grid.row4, .metric-grid.row5, .metric-grid.row6, .metric-grid.row7 { grid-template-columns: repeat(3, 1fr); }
  .app-nav { overflow-x: auto; }
  .nav-tab { padding: 6px 10px; }
  .user-name, .user-company { display: none; }
}
@media (max-width: 600px) {
  .metric-grid.row3, .metric-grid.row4, .metric-grid.row5, .metric-grid.row6, .metric-grid.row7 { grid-template-columns: 1fr; }
  .app-main { padding: 16px 12px 40px; }
  .app-logo span { display: none; }
}

/* ========== 主应用框架：左侧竖排导航 + 右侧内容 ========== */
.app-page { display: flex; min-height: 100vh; }

/* 侧边栏 */
.sidebar {
  width: 220px; flex-shrink: 0; background: #0f172a; color: #cbd5e1;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 8px; padding: 16px 18px;
  font-size: 15px; font-weight: 700; color: #fff; border-bottom: 1px solid #1e293b;
  white-space: nowrap;
}
.sidebar-brand .sb-logo {
  width: 28px; height: 28px; border-radius: 6px;
  object-fit: cover;
  display: block; flex-shrink: 0; background: #fff;
}
.sidebar-nav { padding: 8px; flex: 1; }

.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px;
  cursor: pointer; color: #cbd5e1; font-size: 14px; user-select: none; margin-bottom: 2px;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: #1e293b; color: #fff; }
.nav-item.active { background: #2563eb; color: #fff; font-weight: 600; }
.nav-item .ni-ic { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-item .ni-label { flex: 1; }
.nav-item .ni-caret { font-size: 11px; color: #94a3b8; transition: transform .2s; }
.nav-group.has-sub.open > .nav-item .ni-caret { transform: rotate(90deg); }
.nav-group.has-sub.open > .nav-item { color: #fff; }

/* 默认隐藏 admin-only 入口，由 JS 根据当前用户权限显式展开 */
.admin-only { display: none; }

.sub-list { display: none; padding: 2px 0 4px 30px; }
.nav-group.has-sub.open > .sub-list { display: block; }
.nav-sub {
  display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 6px;
  cursor: pointer; font-size: 13px; color: #94a3b8; transition: background .15s, color .15s;
}
.nav-sub:hover { background: #1e293b; color: #e2e8f0; }
.nav-sub.active { background: #1e3a8a; color: #fff; font-weight: 600; }
.nav-sub .ni-dot { color: #475569; font-size: 12px; }
.nav-sub.active .ni-dot { color: #93c5fd; }

/* 内容区 */
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; background: #f1f5f9; }
.topbar {
  position: sticky; top: 0; z-index: 90; display: flex; align-items: center; justify-content: space-between;
  height: 56px; padding: 0 24px; background: #fff; border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.topbar-title { font-size: 16px; font-weight: 700; color: #0f172a; }
.user-menu { display: flex; align-items: center; gap: 10px; }
.user-name { font-size: 13px; color: #334155; font-weight: 500; }
.user-company { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: #eff6ff; color: #2563eb; }
.app-main { flex: 1; width: 100%; max-width: 1300px; margin: 0 auto; padding: 24px 24px 60px; }

/* 查询筛选工具栏（各数据页顶部） */
.query-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 10px 12px; margin-bottom: 14px;
}
.query-toolbar .q-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; width: 100%; }
.query-toolbar .q-label { font-size: 13px; color: #475569; font-weight: 500; white-space: nowrap; }
.query-toolbar .form-input, .query-toolbar .form-select { width: auto; }
.query-toolbar .q-type-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.type-chip { display: inline-flex; align-items: center; cursor: pointer; border-radius: 999px; border: 1px solid #cbd5e1; background: #fff; padding: 4px 10px; font-size: 13px; color: #334155; transition: all .15s; }
.type-chip:hover { border-color: #3b82f6; }
.type-chip input { display: none; }
.type-chip span { pointer-events: none; }
.type-chip:has(input:checked) { background: #eff6ff; border-color: #3b82f6; color: #1d4ed8; }
.type-chip.type-chip-all { font-weight: 600; border-style: dashed; }
.type-chip.type-chip-all:has(input:checked) { background: #dbeafe; border-color: #2563eb; color: #1e40af; }

/* 收支查询：更整齐的筛选布局 */
.entry-query-toolbar { display: flex; flex-direction: column; gap: 12px; }
.entry-query-toolbar .q-row { width: 100%; align-items: flex-start; }
.entry-query-toolbar .q-row-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.entry-query-toolbar .q-row-head .q-group { display: flex; align-items: center; gap: 8px; }
.entry-query-toolbar .q-row-head .q-group-date { flex: 1; min-width: 280px; }
.entry-query-toolbar .q-row-head .q-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.entry-query-toolbar .q-date-range, .entry-query-toolbar .q-amount-range { display: flex; align-items: center; gap: 6px; }
.entry-query-toolbar .q-row-types, .entry-query-toolbar .q-row-categories, .entry-query-toolbar .q-row-more {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
}
.entry-query-toolbar .q-row-types .q-label,
.entry-query-toolbar .q-row-categories .q-label,
.entry-query-toolbar .q-row-more .q-label { margin-right: 4px; }
.entry-query-toolbar .q-row-more .q-group { display: flex; align-items: center; gap: 8px; }

/* 多选搜索组件（用于杂费类别） */
.multi-select {
  position: relative; min-width: 260px; max-width: 480px; flex: 1;
  border: 1px solid #cbd5e1; border-radius: 6px; background: #fff;
  padding: 4px 6px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  transition: border-color .15s;
}
.multi-select:focus-within { border-color: #3b82f6; box-shadow: 0 0 0 2px rgba(59,130,246,0.1); }
.multi-select-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.multi-select-tag {
  background: #eff6ff; border: 1px solid #3b82f6; color: #1d4ed8; border-radius: 4px;
  padding: 2px 6px; font-size: 12px; display: inline-flex; align-items: center; gap: 4px;
}
.multi-select-tag .remove { cursor: pointer; font-weight: 700; line-height: 1; }
.multi-select-tag .remove:hover { color: #dc2626; }
.multi-select-input { border: none; outline: none; flex: 1; min-width: 120px; font-size: 13px; padding: 4px; background: transparent; }
.multi-select-panel {
  position: absolute; top: 100%; left: 0; margin-top: 4px; background: #fff; border: 1px solid #e2e8f0;
  border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); max-height: 220px; overflow-y: auto;
  z-index: 100; min-width: 100%; display: none;
}
.multi-select-panel.open { display: block; }
.multi-select-option { padding: 7px 10px; font-size: 13px; cursor: pointer; border-bottom: 1px solid #f1f5f9; }
.multi-select-option:last-child { border-bottom: none; }
.multi-select-option:hover { background: #f1f5f9; }
.multi-select-option.selected { background: #eff6ff; color: #1d4ed8; }
.multi-select-empty { padding: 10px; font-size: 13px; color: #94a3b8; text-align: center; }

/* 收支类型管理页：状态徽标与行内勾选 */
.badge-ok { display: inline-block; padding: 1px 9px; border-radius: 10px; font-size: 12px; background: #dcfce7; color: #059669; }
.badge-off { display: inline-block; padding: 1px 9px; border-radius: 10px; font-size: 12px; background: #f1f5f9; color: #64748b; }
.chk { display: inline-flex; align-items: center; gap: 4px; margin-right: 14px; font-size: 14px; color: #334155; cursor: pointer; }

/* 窄屏：侧边栏收窄，保持可用 */
@media (max-width: 768px) {
  .sidebar { width: 180px; }
  .sidebar-brand { font-size: 14px; padding: 14px 12px; }
  .nav-item { padding: 9px 10px; font-size: 13px; }
  .topbar { padding: 0 14px; }
  .app-main { padding: 16px 14px 48px; }
}

/* ========== 经营分析模块（P0）========== */
.ana-alert-box { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 14px; margin-bottom: 12px; }
.ana-alert-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.ana-alert-title { font-size: 14px; font-weight: 600; color: #0f172a; }
.alert-badge { font-size: 12px; padding: 3px 10px; border-radius: 10px; font-weight: 600; }
.alert-badge.red { background: #fef2f2; color: #b91c1c; }
.alert-badge.yellow { background: #fefce8; color: #a16207; }
.alert-badge.green { background: #ecfdf5; color: #047857; }

/* 预警配置按钮（齿轮） */
.alert-config-btn {
  font-size: 12px; padding: 5px 12px; border: 1px solid #e2e8f0; background: #fff;
  color: #475569; border-radius: 6px; cursor: pointer; font-weight: 500;
  transition: all .15s;
}
.alert-config-btn:hover { background: #f8fafc; border-color: #cbd5e1; color: #0f172a; }

/* 预警看板（3 卡片：全部/红/黄） */
.alert-kanban {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  margin-bottom: 12px;
}
.alert-kanban-card {
  padding: 14px 16px; border-radius: 8px; cursor: pointer;
  border: 2px solid #e2e8f0; background: #f8fafc;
  transition: all .15s; user-select: none;
  display: flex; flex-direction: column; gap: 4px;
  min-height: 92px; justify-content: center;
}
.alert-kanban-card:hover { transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.alert-kanban-card.active { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.alert-kanban-card.all.active { border-color: #3b82f6; background: #eff6ff; }
.alert-kanban-card.red.active { border-color: #ef4444; background: #fef2f2; }
.alert-kanban-card.yellow.active { border-color: #f59e0b; background: #fefce8; }
.akc-label { font-size: 12px; color: #64748b; font-weight: 500; }
.alert-kanban-card.all.active .akc-label { color: #1d4ed8; }
.alert-kanban-card.red.active .akc-label { color: #b91c1c; }
.alert-kanban-card.yellow.active .akc-label { color: #a16207; }
.akc-num { font-size: 28px; font-weight: 700; color: #0f172a; line-height: 1.1; }
.alert-kanban-card.red .akc-num { color: #ef4444; }
.alert-kanban-card.yellow .akc-num { color: #f59e0b; }
.akc-hint { font-size: 11px; color: #94a3b8; }
@media (max-width: 800px) {
  .alert-kanban { grid-template-columns: 1fr; }
}

/* 现金分析页空态引导：应收款 > 0 但现金收支 = 0 时提示用户去补录 */
.cash-empty-hint { display: flex; align-items: center; gap: 12px; padding: 12px 16px; margin: 4px 0 12px; background: #fffbeb; border: 1px solid #fde68a; border-left: 4px solid #f59e0b; border-radius: 6px; font-size: 13px; color: #78350f; }
.cash-empty-hint .ceh-icon { font-size: 18px; flex-shrink: 0; }
.cash-empty-hint .ceh-body { flex: 1; line-height: 1.6; }
.cash-empty-hint .ceh-body b { color: #b45309; }
.cash-empty-hint .ceh-action { padding: 6px 14px; background: #f59e0b; color: #fff; border-radius: 4px; font-weight: 600; text-decoration: none; white-space: nowrap; font-size: 13px; transition: background .2s; }
.cash-empty-hint .ceh-action:hover { background: #d97706; }

.ana-alert-list { display: flex; flex-direction: column; gap: 8px; }
.alert-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 6px; border: 1px solid; transition: box-shadow .2s; }
.alert-item:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.alert-item.red { background: #fef2f2; border-color: #fecaca; }
.alert-item.yellow { background: #fefce8; border-color: #fde68a; }
.alert-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.alert-item.red .alert-dot { background: #ef4444; }
.alert-item.yellow .alert-dot { background: #f59e0b; }
.alert-body { flex: 1; }
.alert-title { font-size: 13px; font-weight: 600; color: #0f172a; }
.alert-sub { font-size: 12px; color: #64748b; margin-top: 2px; }
.alert-link { font-size: 13px; color: #2563eb; text-decoration: none; font-weight: 500; white-space: nowrap; }
.alert-link:hover { text-decoration: underline; }

/* 预警配置模态框 - 规则列表 + 表单 */
.rule-table { font-size: 12px; }
.rule-table th { background: #f8fafc; color: #64748b; font-weight: 600; padding: 8px 10px; }
.rule-table td { padding: 10px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.rule-table code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-size: 11px; color: #475569; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.dot.on { background: #10b981; }
.dot.off { background: #cbd5e1; }

/* 开关 */
.switch { position: relative; display: inline-block; width: 36px; height: 20px; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: #cbd5e1; border-radius: 20px; transition: .2s; }
.slider:before { content: ''; position: absolute; height: 16px; width: 16px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: #3b82f6; }
.switch input:checked + .slider:before { transform: translateX(16px); }

/* 规则编辑表单 */
.rule-form-row { margin-bottom: 14px; }
.rule-form-row label { display: block; font-size: 12px; color: #475569; margin-bottom: 6px; font-weight: 500; }
.rule-form-row .form-input, .rule-form-row .form-select { width: 100%; }
.rule-form-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.rule-form-grid > div { min-width: 0; }
@media (max-width: 600px) {
  .rule-form-grid { grid-template-columns: 1fr; }
}
.rule-form-row code { background: #fef3c7; color: #92400e; padding: 2px 6px; border-radius: 4px; font-size: 11px; }

.ana-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
@media (max-width: 1000px) { .ana-two-col { grid-template-columns: 1fr; } }
.ana-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 14px; margin-bottom: 12px; }
.ana-card-title { font-size: 14px; font-weight: 600; color: #0f172a; margin-bottom: 10px; }

.ana-bar-row { display: grid; grid-template-columns: 110px 1fr 90px; align-items: center; gap: 10px; padding: 4px 0; }
.ana-bar-label { font-size: 13px; color: #334155; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ana-bar-track { height: 16px; background: #f1f5f9; border-radius: 4px; overflow: hidden; }
.ana-bar-fill { height: 100%; border-radius: 4px; transition: width .4s; }
.ana-bar-fill.sale { background: linear-gradient(90deg, #f46a6e, #E5484D); }
.ana-bar-fill.recv { background: linear-gradient(90deg, #fbbf24, #d97706); }
.ana-bar-val { font-size: 12px; color: #475569; text-align: right; font-variant-numeric: tabular-nums; }

.ana-top-table { width: 100%; font-size: 13px; }
.ana-top-table th { text-align: left; color: #64748b; font-weight: 500; padding: 6px 4px; border-bottom: 1px solid #e2e8f0; }
.ana-top-table td { padding: 8px 4px; border-bottom: 1px solid #f1f5f9; }
.ana-top-table tr:last-child td { border-bottom: none; }

.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 500; }
.badge.red { background: #fef2f2; color: #b91c1c; }
.badge.yellow { background: #fefce8; color: #a16207; }
.badge.green { background: #ecfdf5; color: #047857; }
.badge.gray { background: #f1f5f9; color: #64748b; }

.ratio-bar { position: relative; height: 16px; background: #f1f5f9; border-radius: 4px; overflow: hidden; min-width: 80px; }
.ratio-fill { height: 100%; background: linear-gradient(90deg, #60a5fa, #2563eb); transition: width .4s; }
.ratio-bar span { position: absolute; right: 6px; top: 0; line-height: 16px; font-size: 11px; color: #475569; font-weight: 600; }

.exp-month-row { display: grid; grid-template-columns: 70px 1fr 100px; align-items: center; gap: 10px; padding: 4px 0; }
.exp-month-label { font-size: 12px; color: #64748b; font-variant-numeric: tabular-nums; }
.exp-month-bars { display: flex; height: 14px; border-radius: 4px; overflow: hidden; background: #f1f5f9; }
.exp-seg { height: 100%; }
.exp-seg.mat { background: #3b82f6; }
.exp-seg.proc { background: #f59e0b; }
.exp-seg.misc { background: #8b5cf6; }
.exp-seg.tax { background: #ef4444; }
.exp-month-val { font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }

/* 堆叠图顶部横向图例 */
.trend-legend { display: flex; gap: 14px; flex-wrap: wrap; padding: 4px 0 8px; border-bottom: 1px dashed #e2e8f0; margin-bottom: 6px; }
.tl-item { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: #475569; }
.tl-dot { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

.donut-svg { display: block; margin: 0 auto 8px; max-width: 100%; width: 320px; max-height: 320px; }
/* 环形图容器：左 svg 占大部分，右图例紧凑 */
.donut-wrap { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(180px, 240px); gap: 16px; align-items: center; padding: 4px 0; }
@media (max-width: 640px) { .donut-wrap { grid-template-columns: 1fr; } }
.donut-svg .donut-seg { transition: opacity .15s, transform .15s; transform-origin: 50% 50%; cursor: pointer; }
.donut-svg .donut-seg.seg-dim { opacity: 0.35; }
.donut-svg .donut-seg.seg-hover { opacity: 1; filter: brightness(1.1) drop-shadow(0 2px 4px rgba(0,0,0,0.15)); }
.donut-legend { display: grid; grid-template-columns: 1fr; gap: 6px; font-size: 12px; color: #475569; }
.legend-item { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 4px; transition: background .15s; cursor: default; }
.legend-item.seg-dim { opacity: 0.5; }
.legend-item.seg-hover { background: #f1f5f9; font-weight: 600; }
.legend-dot { width: 12px; height: 12px; border-radius: 3px; display: inline-block; flex-shrink: 0; }
.legend-amt { color: #94a3b8; font-variant-numeric: tabular-nums; margin-left: auto; }

/* 堆叠图色块 hover 效果 */
.exp-month-bars .exp-seg { transition: opacity .15s, filter .15s; cursor: pointer; }
.exp-month-bars .exp-seg.seg-dim { opacity: 0.3; }
.exp-month-bars .exp-seg.seg-hover { opacity: 1; filter: brightness(1.15); box-shadow: 0 0 0 1px rgba(0,0,0,0.1); }

/* 全局 hover tooltip */
.chart-tooltip { position: fixed; z-index: 9999; background: rgba(15, 23, 42, 0.95); color: #fff; padding: 8px 12px; border-radius: 6px; font-size: 12px; line-height: 1.5; pointer-events: none; box-shadow: 0 4px 12px rgba(0,0,0,0.15); min-width: 140px; max-width: 240px; }
.chart-tooltip .tt-name { font-weight: 600; margin-bottom: 2px; }
.chart-tooltip .tt-val { font-variant-numeric: tabular-nums; }
.chart-tooltip .tt-pct { color: #cbd5e1; margin-left: 4px; }

.cash-month-row { display: grid; grid-template-columns: 70px 1fr 100px; align-items: center; gap: 10px; padding: 4px 0; }
.cash-month-label { font-size: 12px; color: #64748b; }
.cash-month-bars { display: flex; flex-direction: column; gap: 2px; }
.cash-bar { height: 10px; border-radius: 3px; transition: width .4s; }
.cash-bar-in { background: #E5484D; }
.cash-bar-out { background: #16A34A; }
.cash-month-net { font-size: 12px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.cash-month-net.pos { color: #E5484D; }
.cash-month-net.neg { color: #16A34A; }
/* 应收（与小程序一致，用提醒橙，不随涨红跌绿翻色） */
.recv-amt { color: #F59E0B; font-weight: 600; }
.metric-card .m-value.recv-amt { color: #F59E0B; }

@keyframes rowFlash {
  0%   { background-color: transparent; }
  20%  { background-color: #fef08a; }
  50%  { background-color: #fde68a; }
  100% { background-color: transparent; }
}
.row-flash { animation: rowFlash 2.5s ease-out; box-shadow: 0 0 0 2px #f59e0b inset; border-radius: 4px; }

/* ========== AI 对话面板 ========== */
.ai-chat-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 9998;
  transition: transform 0.2s, box-shadow 0.2s;
}
.ai-chat-toggle:hover { transform: scale(1.08); box-shadow: 0 6px 24px rgba(102, 126, 234, 0.5); }
.ai-toggle-icon { font-size: 28px; }

.ai-chat-panel {
  position: fixed;
  bottom: 0;
  right: 0;
  width: 420px;
  max-width: 100vw;
  height: 600px;
  max-height: 100vh;
  background: #fff;
  border-radius: 12px 0 0 0;
  box-shadow: -4px 0 24px rgba(0,0,0,0.12);
  display: flex;
  flex-direction: column;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
@media (max-width: 600px) {
  .ai-chat-panel { width: 100vw; height: 100vh; border-radius: 0; }
}

.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border-radius: 12px 12px 0 0;
}
.ai-chat-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; }
.ai-chat-avatar { font-size: 20px; }
.ai-chat-actions { display: flex; gap: 4px; }
.ai-chat-btn {
  background: rgba(255,255,255,0.2);
  border: none;
  color: #fff;
  width: 28px; height: 28px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.ai-chat-btn:hover { background: rgba(255,255,255,0.35); }

.ai-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f7f8fa;
}

.ai-chat-welcome { text-align: center; padding: 20px 0; }
.ai-welcome-icon { font-size: 40px; margin-bottom: 8px; }
.ai-chat-welcome p { color: #666; font-size: 14px; margin: 0 0 16px; }
.ai-quick-actions { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.ai-quick-btn {
  background: #fff;
  border: 1px solid #e0e3e8;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  color: #333;
  cursor: pointer;
  transition: all 0.15s;
  width: 90%;
  text-align: left;
}
.ai-quick-btn:hover { border-color: #667eea; color: #667eea; background: #f0f3ff; }

/* 消息气泡 */
.ai-msg { display: flex; gap: 8px; max-width: 100%; }
.ai-msg.user { flex-direction: row-reverse; }
.ai-msg-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.ai-msg.bot .ai-msg-avatar { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.ai-msg.user .ai-msg-avatar { background: #e8edf3; }
.ai-msg-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}
.ai-msg.bot .ai-msg-bubble { background: #fff; border: 1px solid #e8edf3; }
.ai-msg.user .ai-msg-bubble { background: #667eea; color: #fff; }
.ai-msg-bubble table { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 13px; }
.ai-msg-bubble th, .ai-msg-bubble td { border: 1px solid #e0e3e8; padding: 6px 10px; text-align: left; }
.ai-msg-bubble th { background: #f7f8fa; font-weight: 600; }
.ai-msg-bubble code { background: #f0f3ff; padding: 2px 6px; border-radius: 4px; font-size: 13px; }
.ai-msg-bubble ul, .ai-msg-bubble ol { margin: 8px 0; padding-left: 20px; }

/* 工具执行状态 */
.ai-tool-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #f0f3ff;
  border-radius: 8px;
  font-size: 12px;
  color: #667eea;
  max-width: 80%;
}
.ai-tool-status .spinner {
  width: 14px; height: 14px;
  border: 2px solid #667eea;
  border-top-color: transparent;
  border-radius: 50%;
  animation: ai-spin 0.6s linear infinite;
}
@keyframes ai-spin { to { transform: rotate(360deg); } }
.ai-tool-status.done { color: #52c41a; background: #f0fff4; }
.ai-tool-status.done .spinner { display: none; }
.ai-tool-status.error { color: #ff4d4f; background: #fff2f0; }
.ai-tool-status.error .spinner { display: none; }

/* 打字指示器 */
.ai-typing { display: flex; gap: 4px; padding: 10px 14px; }
.ai-typing span {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #bbb;
  animation: ai-bounce 1.4s infinite ease-in-out;
}
.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ai-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-8px); opacity: 1; }
}

.ai-chat-footer { padding: 12px 16px; border-top: 1px solid #e8edf3; background: #fff; }
.ai-chat-input-wrap { display: flex; gap: 8px; align-items: flex-end; }
.ai-chat-input {
  flex: 1;
  border: 1px solid #e0e3e8;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  resize: none;
  max-height: 120px;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}
.ai-chat-input:focus { border-color: #667eea; }
.ai-chat-send {
  background: #667eea;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.ai-chat-send:hover { background: #5a6fd8; }
.ai-chat-send:disabled { background: #ccc; cursor: not-allowed; }
.ai-chat-hint { font-size: 11px; color: #bbb; text-align: center; margin-top: 6px; }

/* ========== 使用说明书（一级入口）========== */
.nav-doc { margin-top: 2px; }
.nav-doc:hover { background: #1e293b; color: #fff; }

.manual-wrap { display: flex; align-items: flex-start; gap: 22px; }
.manual-toc {
  width: 280px; flex-shrink: 0; position: sticky; top: 16px;
  background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
  padding: 18px 16px; max-height: calc(100vh - 120px);
  box-shadow: 0 1px 3px rgba(15,23,42,0.04);
  display: flex; flex-direction: column;
}
.manual-toc-title { font-size: 16px; font-weight: 700; color: #0f172a; }
.manual-toc-sub { font-size: 12px; color: #94a3b8; margin: 2px 0 14px; }
.manual-toc ul { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; }
.manual-toc li { margin: 0; }
.manual-toc a {
  display: block; padding: 9px 12px; border-radius: 8px;
  font-size: 13.5px; color: #475569; text-decoration: none; cursor: pointer;
  border-left: 3px solid transparent; transition: all .15s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.manual-toc a:hover { background: #f1f5f9; color: #0f172a; }
.manual-toc a.active { background: #eff6ff; color: #1d4ed8; border-left-color: #2563eb; font-weight: 600; }
.manual-toc-foot { margin-top: 16px; font-size: 12px; color: #94a3b8; line-height: 1.5; }

.manual-content {
  flex: 1; min-width: 0; background: #fff;
  border: 1px solid #e2e8f0; border-radius: 12px; padding: 28px 34px 40px;
}
.manual-head { border-bottom: 1px solid #eef2f7; padding-bottom: 18px; margin-bottom: 8px; }
.manual-head h1 { font-size: 24px; margin: 0 0 8px; color: #0f172a; }
.manual-lead { font-size: 14px; color: #475569; line-height: 1.7; margin: 0; }
.manual-lead strong { color: #1d4ed8; }

.manual-ch { padding-top: 22px; scroll-margin-top: 90px; }
.manual-ch + .manual-ch { border-top: 1px solid #f1f5f9; margin-top: 8px; }
.manual-ch h2 { font-size: 19px; color: #0f172a; margin: 0 0 10px; }
.manual-ch h3 { font-size: 15px; color: #1e293b; margin: 18px 0 8px; }
.manual-ch p { font-size: 14px; color: #334155; line-height: 1.75; margin: 8px 0; }
.manual-ch ul, .manual-ch ol { font-size: 14px; color: #334155; line-height: 1.8; padding-left: 22px; margin: 8px 0; }
.manual-ch li { margin: 4px 0; }
.manual-ch strong { color: #0f172a; }
.caret { color: #94a3b8; font-size: 11px; }

.callout { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; margin: 14px 0; border: 1px solid #e2e8f0; border-left-width: 4px; font-size: 13.5px; line-height: 1.7; }
.callout .co-ic { font-size: 17px; flex-shrink: 0; line-height: 1.4; }
.callout.tip { background: #eff6ff; border-color: #bfdbfe; border-left-color: #3b82f6; }
.callout.warn { background: #fff7ed; border-color: #fed7aa; border-left-color: #f59e0b; }
.callout.formula { background: #f0fdf4; border-color: #bbf7d0; border-left-color: #22c55e; }
.callout.formula div { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: #14532d; }

.manual-shot { margin: 16px 0; border: 1px solid #e2e8f0; border-radius: 10px; overflow: hidden; background: #f8fafc; text-align: center; }
.manual-shot img { max-width: 100%; max-height: 360px; width: auto; height: auto; display: inline-block; }
.manual-shot figcaption { font-size: 12px; color: #64748b; padding: 8px 12px; text-align: center; border-top: 1px solid #eef2f7; }
.manual-shot.shot-missing { min-height: 120px; display: flex; align-items: center; justify-content: center; }
.shot-ph { text-align: center; color: #94a3b8; font-size: 13px; line-height: 1.6; padding: 18px; }
.shot-ph small { color: #cbd5e1; }

.manual-end { text-align: center; color: #94a3b8; font-size: 13px; margin-top: 30px; padding-top: 18px; border-top: 1px dashed #e2e8f0; }

@media (max-width: 900px) {
  .manual-wrap { flex-direction: column; }
  .manual-toc { width: 100%; position: static; max-height: none; }
  .manual-content { padding: 20px 18px 30px; }
}
