html {
  --font-scale: 1;
  font-size: calc(14px * var(--font-scale));
  scroll-behavior: smooth;
}

@media (min-width: 768px) {
  html {
    font-size: calc(16px * var(--font-scale));
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem rgba(var(--theme-primary-rgb), 0.5);
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
  background: var(--theme-page-bg);
  transition: background 0.3s ease;
}

/* 网页版布局：flex 纵向排列，footer 贴底 */
body.web-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  margin-bottom: 0;
}

/* 主内容区：flex 传递链，让 .page-container 自动填满可用空间 */
main > .container-fluid {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* 页面边距与板块间距（界面风格-字体与密度全局设置，由 theme-switcher.js 写入 body 属性）
   --zy-edge-scale：页面边距缩放系数（标准 0.5 = 左右 12px、上 4px）
   --zy-block-scale：板块间距缩放系数，同时驱动下方三个派生间距
   --zy-block-gap：标题/工具栏板块与表格板块之间的间距（紧凑 0 / 标准 8px / 宽松 16px） */
body {
  --zy-edge-scale: 1;
  --zy-block-scale: 1;
  --zy-block-gap: calc(1rem * var(--zy-block-scale));
}
body[data-page-edge="none"]    { --zy-edge-scale: 0; }
body[data-page-edge="compact"] { --zy-edge-scale: 0.5; }
body[data-page-edge="loose"]   { --zy-edge-scale: 2; }
body[data-block-gap="none"]    { --zy-block-scale: 0; }
body[data-block-gap="compact"] { --zy-block-scale: 0.5; }
body[data-block-gap="loose"]   { --zy-block-scale: 2; }

/* 网页版外壳间距变量化
   外间距：main > .container-fluid 的 padding（卡片与页面边缘的呼吸间距）
   内间距：.page-content > .card-body 的 padding（内容与卡片边缘的主间距）
   内层容器（页面 .container-fluid / .page-container）不再叠加额外边距
   数值：紧凑 0+0=0 / 标准 6+10=16px / 宽松 10+18=28px */
body.web-layout main {
  padding: 0;
}
/* 外间距：紧凑 0 / 标准 6px / 宽松 10px */
body.web-layout main > .container-fluid {
  padding: 4px 10px;
  padding-bottom: 0;
}
body.web-layout[data-page-edge="none"] main > .container-fluid {
  padding: 0;
}
body.web-layout[data-page-edge="compact"] main > .container-fluid {
  padding: 2px 6px;
  padding-bottom: 0;
}
/* 内间距：紧凑 0 / 标准 10px / 宽松 18px */
body.web-layout .page-content > .card-body {
  padding: 6px 18px;
  padding-bottom: 0;
}
body.web-layout[data-page-edge="none"] .page-content > .card-body {
  padding: 0;
}
body.web-layout[data-page-edge="compact"] .page-content > .card-body {
  padding: 4px 10px;
  padding-bottom: 0;
}
/* 干掉页面内层 .container-fluid 的 Bootstrap 默认 12px padding（统一由 card-body 提供） */
body.web-layout .page-content > .card-body > .container-fluid {
  padding-left: 0;
  padding-right: 0;
}

/* 移动端外壳两层间距变量化（替代原 _MobileLayout 上的 px-2 pt-2 / px-2 py-3 固定类；
   底部 padding 由 main 内联样式控制，为底部导航留白，不参与缩放） */
body.mobile-layout main {
  padding-left: calc(0.5rem * var(--zy-edge-scale));
  padding-right: calc(0.5rem * var(--zy-edge-scale));
  padding-top: calc(0.5rem * var(--zy-edge-scale));
}
body.mobile-layout .page-content > .card-body {
  padding-left: calc(0.5rem * var(--zy-edge-scale));
  padding-right: calc(0.5rem * var(--zy-edge-scale));
  padding-top: calc(1rem * var(--zy-edge-scale));
  padding-bottom: calc(1rem * var(--zy-edge-scale));
}

/* 板块间距公共类（工具栏卡片不是 .page-container 直接子级的页面使用，替代 mb-1） */
.zy-block-gap {
  margin-bottom: var(--zy-block-gap, 0.25rem);
}

/* 区块间距公共类（设置页/详情页等多区块页面的顶层容器使用，受界面风格"板块间距"控制）
   .zy-section-gap    —— 标准档 1rem，替代 mb-3
   .zy-section-gap-lg —— 标准档 1.5rem，替代 mb-4 */
.zy-section-gap {
  margin-bottom: calc(1rem * var(--zy-block-scale, 1));
}
.zy-section-gap-lg {
  margin-bottom: calc(1.5rem * var(--zy-block-scale, 1));
}

/* 板块水平间距已移除（边距统一由 Layout 的 main > .container-fluid 提供，
   zy-section-gap / zy-section-gap-lg 仅保留垂直 margin-bottom） */
.page-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
  overflow: hidden;
}
.page-content > .card-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}
/* 页面内容的外层容器也参与 flex 传递 */
.page-content > .card-body > .container-fluid {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

/* 全局表单控件增强 */
.form-control {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--theme-input-border);
}

.form-control:hover {
  border-color: var(--theme-border-dark);
}

.form-control:focus {
  border-color: var(--theme-primary);
  box-shadow: 0 0 0 3px rgba(var(--theme-primary-rgb), 0.15);
  transform: translateY(-1px);
}

/* 下拉菜单增强 */
.form-select {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--theme-input-border);
}

.form-select:hover {
  border-color: var(--theme-border-dark);
}

.form-select:focus {
  border-color: var(--theme-primary);
  box-shadow: 0 0 0 3px rgba(var(--theme-primary-rgb), 0.15);
}

/* 复选框和单选框增强 */
.form-check-input {
  transition: all 0.2s ease;
  border: 2px solid var(--theme-border-dark);
  border-radius: 0;
}

.form-check-input:checked {
  background-color: var(--theme-primary);
  border-color: var(--theme-primary);
  box-shadow: 0 0 0 2px rgba(var(--theme-primary-rgb), 0.2);
}

.form-check-input:focus {
  box-shadow: 0 0 0 3px rgba(var(--theme-primary-rgb), 0.15);
  border-color: var(--theme-primary);
}

/* 全局链接样式 */
a {
  transition: all 0.2s ease;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  color: var(--theme-primary);
}

/* 滚动条美化 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--theme-border-light);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--theme-border-dark);
  border-radius: 4px;
  transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--theme-gray-light);
}

/* 全局阴影效果 */
.shadow-sm {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05) !important;
}

.shadow {
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08) !important;
}

.shadow-lg {
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12) !important;
}

/* 界面密度模式（调整全局间距，字体大小由用户字体设置统一控制） */

/* ---- 紧凑模式 ---- */
body.density-compact .card-body { padding: 0.75rem; }
body.density-compact .card-header { padding: 0.5rem 0.75rem; }
body.density-compact .card-footer { padding: 0.5rem 0.75rem; }
body.density-compact .btn { padding: 0.25rem 0.6rem; font-size: 0.85rem; }
body.density-compact .btn-sm { padding: 0.2rem 0.5rem; }
body.density-compact .btn-lg { padding: 0.4rem 0.8rem; }
body.density-compact .form-control,
body.density-compact .form-select { padding: 0.3rem 0.5rem; font-size: 0.85rem; }
body.density-compact .form-label { margin-bottom: 0.25rem; }
body.density-compact .form-check { margin-bottom: 0.15rem; }
body.density-compact table th,
body.density-compact table td { padding: 0.35rem 0.5rem; }
body.density-compact .modal-body { padding: 0.75rem; }
body.density-compact .modal-header { padding: 0.5rem 0.75rem; }
body.density-compact .alert { padding: 0.5rem 0.75rem; }
body.density-compact .list-group-item { padding: 0.4rem 0.75rem; }
body.density-compact .nav-link { padding: 0.35rem 0.75rem; }
body.density-compact .mb-3 { margin-bottom: 0.5rem !important; }
body.density-compact .mb-4 { margin-bottom: 0.75rem !important; }
body.density-compact .mt-3 { margin-top: 0.5rem !important; }
body.density-compact .mt-4 { margin-top: 0.75rem !important; }
body.density-compact .py-4 { padding-top: 1rem !important; padding-bottom: 1rem !important; }

/* ---- 宽松模式 ---- */
body.density-spacious .card-body { padding: 1.75rem; }
body.density-spacious .card-header { padding: 1.25rem 1.75rem; }
body.density-spacious .card-footer { padding: 1.25rem 1.75rem; }
body.density-spacious .btn { padding: 0.6rem 1.25rem; font-size: 1rem; }
body.density-spacious .btn-sm { padding: 0.45rem 0.9rem; }
body.density-spacious .btn-lg { padding: 0.85rem 1.75rem; }
body.density-spacious .form-control,
body.density-spacious .form-select { padding: 0.65rem 1rem; font-size: 1rem; }
body.density-spacious .form-label { margin-bottom: 0.6rem; }
body.density-spacious .form-check { margin-bottom: 0.4rem; }
body.density-spacious table th,
body.density-spacious table td { padding: 1rem 1.25rem; }
body.density-spacious .modal-body { padding: 2rem; }
body.density-spacious .modal-header { padding: 1.25rem 2rem; }
body.density-spacious .alert { padding: 1.25rem 1.5rem; }
body.density-spacious .list-group-item { padding: 1rem 1.5rem; }
body.density-spacious .nav-link { padding: 0.75rem 1.25rem; }
body.density-spacious .mb-3 { margin-bottom: 1.5rem !important; }
body.density-spacious .mb-4 { margin-bottom: 2.5rem !important; }
body.density-spacious .mt-3 { margin-top: 1.5rem !important; }
body.density-spacious .mt-4 { margin-top: 2.5rem !important; }
body.density-spacious .py-4 { padding-top: 3rem !important; padding-bottom: 3rem !important; }

/* ============================================ */
/* 移动端底部导航栏样式                              */
/* ============================================ */
.mobile-footer-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: white;
  border-top: 1px solid var(--theme-border);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  padding: 0.25rem 0;
}

.mobile-footer-nav .nav-item {
  position: relative;
}

.mobile-footer-nav .nav-link {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.35rem 0.25rem;
  font-size: 0.7rem;
  color: var(--theme-primary) !important;
  transition: all 0.2s ease;
}

.mobile-footer-nav .nav-link i {
  display: block;
  font-size: 1.25rem;
  margin-bottom: 0.15rem;
  margin-top: 0;
  color: var(--theme-primary) !important;
}

.mobile-footer-nav .nav-link span {
  display: block;
  text-align: center;
  font-weight: 500;
  margin-top: 0.1rem;
  color: var(--theme-primary) !important;
  font-size: 0.7rem;
}

.mobile-footer-nav .nav-link.active,
.mobile-footer-nav .nav-link:hover {
  color: var(--theme-primary);
}

/* 移动端角标样式 */
#mobilePendingBadge {
  position: absolute !important;
  top: 2px !important;
  right: 25% !important;
  transform: translateX(50%);
}

/* ============================================ */
/* 共用样式（Web + Mobile 共享）                       */
/* ============================================ */

/* 系统助手输入框主题色焦点样式 */
#assistantInput:focus {
  border-color: var(--theme-primary) !important;
  box-shadow: 0 0 0 0.25rem rgba(var(--theme-primary-rgb), 0.25) !important;
}

/* 系统助手反馈按钮 */
.zy-feedback {
  opacity: 0.4;
  transition: opacity 0.2s;
}
.zy-feedback:hover {
  opacity: 1;
}
.zy-fb-btn {
  color: #6c757d;
  font-size: 0.75rem;
  line-height: 1;
}
.zy-fb-btn:hover {
  color: var(--theme-primary);
}
.zy-fb-btn.active {
  color: var(--theme-primary);
}

/* 系统助手快捷指令菜单 */
.quick-cmd-item:hover {
  background: var(--theme-light, #f8f9fa);
}

/* 页面加载动画 */
.page-content {
  animation: fadeInUp 0.5s ease forwards;
}

/*
 * 修复：.page-content 作为 @RenderBody() 的外层容器，被所有页面的 modal 当作父元素。
 * 若 transform 不为 none（包括 translateY(0) 与 .card:hover 的 translateY(-2px)），
 * 会创建新的 stacking context，导致子元素 .modal 的 z-index 被困在该上下文内，
 * 而 Bootstrap 动态创建的 .modal-backdrop 在 body 下，
 * 最终 modal 被 backdrop 遮住，表现为“弹窗弹出但内部元素全部变灰不可点”。
 * 解决方案：动画终态用 transform: none，并在 hover 时强制 none。
 */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.page-content:hover {
  transform: none;
}

/* 卡片悬停效果增强 */
.card {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--theme-border);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--theme-card-hover-shadow) !important;
  border-color: var(--theme-border-dark);
}

/* PC端隐藏工具类 */
.desktop-hide {
  display: none !important;
}

/* 组合框紧凑模式：与 form-select 单行高度一致 */
.combobox-compact .form-control,
.combobox-compact .btn {
  height: 2rem !important;
  line-height: 1 !important;
  padding-top: 0.15rem !important;
  padding-bottom: 0.15rem !important;
}

/* ============================================ */
/* Web Layout 顶部标题栏紧凑化                    */
/* Bootstrap 默认 navbar 上下 8px + brand 5px，  */
/* 压缩后总高度 58px → 48px，内容高度不变        */
/* ============================================ */

.web-layout header.navbar {
  --bs-navbar-padding-y: 0.3125rem;
  --bs-navbar-brand-padding-y: 0.125rem;
}

/* ============================================ */
/* Web Layout 侧边栏样式                              */
/* ============================================ */

.sidebar {
  min-width: 200px;
  max-width: 200px;
  background: white;
  border-right: 1px solid var(--theme-border);
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
}

/* 侧边栏内部滚动容器：自适应父容器高度 */
.sidebar #sidebarAccordion {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar.hidden {
  min-width: 0;
  max-width: 0;
  overflow: hidden;
  border-right: none;
  box-shadow: none;
}

/* 只显示图标模式（仅 PC 端）：收窄为 56px，分组与子菜单均只显示图标，点分组图标就地展开/收起子图标 */
@media (min-width: 768px) {
  .sidebar.icon-only {
    min-width: 56px;
    max-width: 56px;
  }

  .sidebar.icon-only .nav-group-toggle,
  .sidebar.icon-only .nav-group-single,
  .sidebar.icon-only .nav-item {
    justify-content: center;
    font-size: 0; /* 隐藏图标后的文字节点 */
  }

  .sidebar.icon-only .nav-group-toggle,
  .sidebar.icon-only .nav-group-single {
    padding: 0.6rem 0;
  }

  .sidebar.icon-only .nav-group-toggle i,
  .sidebar.icon-only .nav-group-single i {
    margin-right: 0;
    font-size: 1.2rem;
  }

  /* 子菜单图标缩小 + 降低透明度，与一级分组图标形成双通道区分（颜色沿用 .nav-item 的偏灰色） */
  .sidebar.icon-only .nav-item {
    padding: 0.45rem 0;
    opacity: 0.75;
  }

  .sidebar.icon-only .nav-item i {
    margin-right: 0;
    font-size: 0.85rem;
  }

  /* 当前页高亮项恢复全亮，保证定位清晰 */
  .sidebar.icon-only .nav-item.active {
    opacity: 1;
  }

  /* 窄栏下取消悬停横移，避免图标溢出 */
  .sidebar.icon-only .nav-group-toggle:hover,
  .sidebar.icon-only .nav-group-single:hover,
  .sidebar.icon-only .nav-item:hover {
    transform: none;
  }

  /* 隐藏待办徽章（窄栏放不下数字，悬停提示已含名称） */
  .sidebar.icon-only .nav-group-toggle .badge {
    display: none !important;
  }
}

/* 图标模式悬停名称提示（fixed 定位，不受侧边栏 overflow 裁剪） */
.sidebar-icon-tip {
  position: fixed;
  z-index: 2000;
  padding: 0.25rem 0.6rem;
  background: var(--theme-dark, #212529);
  color: #fff;
  font-size: 0.8rem;
  border-radius: 0.25rem;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* ============================================ */
/* 侧边栏拖拽手柄（PanelResizer 组件）          */
/* ============================================ */

.zy-resizer {
  position: absolute;
  top: 0;
  right: 0;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 100;
  background: transparent;
  transition: background 0.15s;
  touch-action: none;
}

/* 悬停时显示 2px 主题色竖线 */
.zy-resizer::after {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  width: 2px;
  height: 100%;
  transform: translateX(-50%);
  background: transparent;
  border-radius: 1px;
  transition: background 0.15s;
}

.zy-resizer:hover::after,
.zy-resizer:focus-visible::after,
.zy-resizer--active::after {
  background: var(--theme-primary);
}

.zy-resizer:focus-visible {
  outline: 2px solid var(--theme-primary);
  outline-offset: -2px;
}

/* 拖动中高亮加宽 */
.zy-resizer--active {
  background: rgba(var(--theme-primary-rgb), 0.08);
}

/* 拖动中禁用面板过渡动画（防卡顿） */
.zy-resizing {
  transition: none !important;
}

/* 拖动遮罩：防止 iframe/表格抢占鼠标事件 */
.zy-resizer-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  cursor: col-resize;
  user-select: none;
}

/* 侧边栏需要 relative 定位以承载手柄 */
.zy-resizer-host {
  position: relative;
}

.sidebar-nav .nav-group {
  margin-bottom: 0.5rem;
}

.sidebar-nav .nav-group-toggle {
  display: flex;
  align-items: center;
  padding: 0.6rem 1rem;
  color: var(--theme-dark);
  text-decoration: none;
  border-radius: 0.375rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.sidebar-nav .nav-group-toggle::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: 0.5s;
}

.sidebar-nav .nav-group-toggle:hover::before {
  left: 100%;
}

.sidebar-nav .nav-group-toggle:hover {
  background: rgba(var(--theme-primary-rgb), 0.1);
  color: var(--theme-primary);
  transform: translateX(4px);
}

.sidebar-nav .nav-group-toggle i {
  margin-right: 0.5rem;
  font-size: 1.1rem;
}

/* 侧边栏单项链接（无子菜单时，复用 toggle 样式） */
.sidebar-nav .nav-group-single {
  padding: 0.6rem 1rem;
  color: var(--theme-dark);
  position: relative;
  overflow: hidden;
}

.sidebar-nav .nav-group-single::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: 0.5s;
}

.sidebar-nav .nav-group-single:hover::before {
  left: 100%;
}

.sidebar-nav .nav-group-single:hover {
  background: rgba(var(--theme-primary-rgb), 0.1);
  color: var(--theme-primary);
  transform: translateX(4px);
}

.sidebar-nav .nav-group-single i {
  font-size: 1.1rem;
}

.sidebar-nav .nav-item {
  display: flex;
  align-items: center;
  padding: 0.5rem 1rem 0.5rem 2.5rem;
  color: var(--theme-gray);
  text-decoration: none;
  border-radius: 0.375rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 0.9rem;
  position: relative;
}

.sidebar-nav .nav-item:hover {
  background: rgba(var(--theme-primary-rgb), 0.08);
  color: var(--theme-primary);
  transform: translateX(6px);
}

.sidebar-nav .nav-item i {
  margin-right: 0.5rem;
  font-size: 0.95rem;
}

/* 主内容区 - 添加过渡效果 */
.main-content {
  flex: 1;
  overflow: auto;
  transition: all 0.3s ease;
}

/* ============================================ */
/* Mobile Layout 专属样式                             */
/* ============================================ */

/* 回到顶部按钮 - 移动端 */
.btn-back-to-top-mobile {
  position: fixed;
  bottom: 70px;
  left: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-color: var(--theme-primary);
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(var(--theme-primary-rgb), 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  cursor: pointer;
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.3s ease;
}

.btn-back-to-top-mobile.show {
  opacity: 0.8;
  visibility: visible;
  transform: translateY(0);
}

.btn-back-to-top-mobile:hover {
  opacity: 1;
  background-color: var(--theme-secondary);
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(var(--theme-primary-rgb), 0.4);
}

.btn-back-to-top-mobile:active {
  transform: translateY(0) scale(0.95);
}

/* ============================================ */
/* 响应式样式                                        */
/* ============================================ */

/* Web端移动端侧边栏 */
@media (max-width: 767.98px) {
  .sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    z-index: 1000;
    height: calc(100vh - 56px);
    width: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;
    overflow: hidden !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .sidebar.mobile-show {
    width: 200px !important;
    min-width: 200px !important;
    max-width: 200px !important;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
  }

  .sidebar .sidebar-nav {
    opacity: 0;
    transition: opacity 0.3s;
  }

  .sidebar.mobile-show .sidebar-nav {
    opacity: 1;
  }

  /* 移动端优化：禁用卡片悬停效果（触摸设备不需要） */
  .card:hover {
    transform: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
  }
}

/* PC端隐藏回到顶部按钮 */
@media (min-width: 768px) {
  .btn-back-to-top-mobile {
    display: none !important;
  }
}

/* ======================== 内部聊天样式 ======================== */

/* 聊天容器：左右分栏 */
.chat-container {
  display: flex;
  height: calc(100vh - 100px);
  background: var(--theme-page-bg, #f8f9fa);
  border-radius: 8px;
  overflow: hidden;
}

/* 左侧会话列表 */
.chat-sidebar {
  width: 320px;
  min-width: 280px;
  border-right: 1px solid var(--theme-border, #dee2e6);
  background: white;
  display: flex;
  flex-direction: column;
}

.chat-sidebar-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--theme-border, #dee2e6);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
  background: white;
}

/* Tab 切换栏 */
.chat-tab-bar {
  display: flex;
  width: 100%;
  gap: 2px;
  background: rgba(var(--theme-primary-rgb), 0.04);
  border-radius: 8px;
  padding: 3px;
}

.chat-tab {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--theme-text-muted, #6c757d);
  font-weight: 500;
  font-size: 0.9rem;
  padding: 6px 0;
  border-radius: 6px;
  transition: all 0.15s;
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
}

.chat-tab:hover {
  background: rgba(var(--theme-primary-rgb), 0.08);
  color: var(--theme-primary);
}

.chat-tab.active {
  background: rgba(var(--theme-primary-rgb), 0.12);
  color: var(--theme-primary);
}

.chat-tab-panel {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* 群聊面板底部创建按钮 */
.chat-group-footer {
  flex-shrink: 0;
  padding: 10px 12px;
  border-top: 1px solid var(--theme-border, #dee2e6);
  background: white;
}

.chat-conversation-list {
  flex: 1;
  overflow-y: auto;
  min-width: 0;
}

.chat-conversation-list .text-center {
  padding: 2rem 1rem;
  white-space: nowrap;
}

/* 联系人列表 */
.chat-contact-list {
  flex: 1;
  overflow-y: auto;
}

.chat-contact-item {
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  transition: background 0.15s;
}

.chat-contact-item:hover {
  background: rgba(var(--theme-primary-rgb), 0.05);
}

/* 部门折叠组 */
.chat-dept-header {
  display: flex;
  align-items: center;
  padding: 6px 16px;
  cursor: pointer;
  user-select: none;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--theme-text-muted, #6c757d);
  background: rgba(0, 0, 0, 0.02);
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.chat-dept-header:hover {
  background: rgba(var(--theme-primary-rgb), 0.04);
}

.chat-dept-arrow {
  font-size: 0.7rem;
  margin-right: 6px;
  transition: transform 0.2s;
}

/* 展开时箭头从向右旋转向下 */
.chat-dept-arrow.expanded {
  transform: rotate(90deg);
}

.chat-dept-name {
  flex: 1;
}

.chat-dept-count {
  font-weight: 400;
  font-size: 0.75rem;
  color: var(--theme-text-muted, #adb5bd);
  margin-left: 4px;
}

.chat-dept-group.collapsed {
  display: none;
}

.chat-company-users.collapsed {
  display: none;
}

.chat-company-header:hover {
  background: rgba(var(--theme-primary-rgb, 13,110,253), 0.06);
  border-radius: 0.375rem;
}

.chat-contact-item {
  padding-left: 24px !important;
}

.chat-conversation-item {
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  transition: background 0.15s;
}

.chat-conversation-item:hover {
  background: rgba(var(--theme-primary-rgb), 0.05);
}

.chat-conversation-item.active {
  background: rgba(var(--theme-primary-rgb), 0.1);
  border-left: 3px solid var(--theme-primary);
}

.chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(var(--theme-primary-rgb), 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  color: var(--theme-primary);
  flex-shrink: 0;
}

/* 联系人在线状态圆点（头像右下角） */
.online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bs-success);
  border: 2px solid #fff;
  pointer-events: none;
}

/* 头部头像内的在线圆点缩小版（跨平台在线指示器） */
.user-avatar .online-dot {
  width: 6px;
  height: 6px;
  border-width: 1.5px;
  bottom: 0;
  right: 0;
}

/* 姓名首字头像 */
.chat-avatar-initial {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  background: var(--theme-primary);
  flex-shrink: 0;
}
.chat-avatar-img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.chat-msg-avatar {
  width: 36px;
  flex-shrink: 0;
}
.chat-msg-avatar .chat-avatar-initial,
.chat-msg-avatar .chat-avatar-img {
  width: 32px;
  height: 32px;
  font-size: 0.85rem;
}
.chat-msg-body {
  max-width: 70%;
  min-width: 0;
}

/* 右侧聊天主区域 */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.chat-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.chat-window {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--theme-border, #dee2e6);
  background: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--theme-light, #f8f9fa);
}

/* 消息气泡 */
.chat-message {
  margin-bottom: 12px;
}

.chat-bubble {
  display: inline-block;
  /* max-width 已由外层 .chat-msg-body (70%) 控制，此处不再重复设置，避免双重缩窄 */
  padding: 8px 14px;
  border-radius: 12px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  line-height: 1.5;
}

.chat-bubble-mine {
  background: rgba(var(--theme-primary-light-rgb), 0.1);
  color: #000;
  border-bottom-right-radius: 4px;
}

.chat-bubble-other {
  background: rgba(var(--theme-secondary-light-rgb), 0.1);
  color: #000;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.chat-recalled {
  opacity: 0.6;
}

.chat-image {
  max-width: 250px;
  max-height: 200px;
  border-radius: 8px;
  cursor: pointer;
}

.chat-file-link {
  color: inherit;
  text-decoration: none;
}

.chat-file-link:hover {
  text-decoration: underline;
}

/* 日期分隔线 */
.chat-date-separator {
  margin: 8px 0;
  position: relative;
}
.chat-date-separator::before {
  content: '';
  position: absolute;
  left: 10%;
  right: 10%;
  top: 50%;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}
.chat-date-separator small {
  position: relative;
  background: var(--theme-light, #f8f9fa);
  padding: 0 12px;
}

/* 文件下载卡片 */
.chat-file-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  text-decoration: none !important;
  color: inherit !important;
  background: rgba(255, 255, 255, 0.6);
  min-width: 200px;
  max-width: 280px;
  transition: background 0.15s;
  cursor: pointer;
}
.chat-file-card:hover {
  background: rgba(var(--theme-primary-rgb, 13, 110, 253), 0.06);
}
.chat-file-card-icon {
  font-size: 1.5rem;
  color: var(--theme-primary, #0d6efd);
  flex-shrink: 0;
}
.chat-file-card-name {
  flex: 1;
  font-size: 0.85rem;
  word-break: break-all;
  line-height: 1.3;
}
.chat-file-card-dl {
  font-size: 0.9rem;
  opacity: 0.4;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.chat-file-card:hover .chat-file-card-dl {
  opacity: 0.8;
}

/* 转发按钮（已迁移到操作栏 .chat-action-btn，保留兼容） */
.forward-btn {
  opacity: 0.5;
  transition: opacity 0.15s;
}

.forward-btn:hover {
  opacity: 0.9;
}

/* 转发弹窗会话项 */
.forward-conversation-item:hover {
  background: rgba(var(--theme-primary-rgb, 13,110,253), 0.08);
}

/* 图片预览全屏遮罩 */
.chat-image-preview {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.chat-image-preview img {
  max-width: 92vw;
  max-height: 92vh;
  object-fit: contain;
  cursor: default;
  border-radius: 4px;
}

.chat-image-preview-close {
  position: absolute;
  top: 16px;
  right: 20px;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 12px;
  border-radius: 4px;
  transition: background 0.15s;
}

.chat-image-preview-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* 输入区域 */
.chat-input-area {
  padding: 12px 16px;
  border-top: 1px solid var(--theme-border, #dee2e6);
  background: white;
}

.chat-input-area textarea {
  resize: none;
  max-height: 120px;
  border-radius: 8px;
}

/* 拖拽图片悬停视觉反馈 */
.chat-input-area.chat-drag-over {
  background: rgba(var(--theme-primary-rgb, 13, 110, 253), 0.06);
  outline: 2px dashed var(--theme-primary, #0d6efd);
  outline-offset: -2px;
  transition: background 0.15s, outline 0.15s;
}

/* 人员搜索项 */
.user-search-item:hover {
  background: rgba(var(--theme-primary-rgb), 0.08);
}

/* 群聊成员多选清单 */
.group-selected-members {
  min-height: 32px;
  padding: 6px 8px;
  border: 1px solid var(--theme-border, #dee2e6);
  border-radius: 6px;
  background: rgba(var(--theme-primary-rgb), 0.02);
}

.group-member-list {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--theme-border, #dee2e6);
  border-radius: 6px;
}

.group-member-item {
  display: flex;
  align-items: center;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.group-member-item:last-child {
  border-bottom: none;
}

.group-member-item:hover {
  background: rgba(var(--theme-primary-rgb), 0.06);
}

.group-member-item .form-check-input {
  margin-right: 10px;
  cursor: pointer;
  flex-shrink: 0;
}

.group-member-item.selected {
  background: rgba(var(--theme-primary-rgb), 0.08);
}

/* 主题色按钮（.btn-theme-primary 系列统一定义在 theme.css，此处不再重复） */
.btn-outline-theme {
  color: var(--theme-primary);
  border-color: var(--theme-primary);
}

.btn-outline-theme:hover {
  background: var(--theme-primary);
  color: white;
}

/* 引用预览条（输入区顶部） */
.chat-quote-preview {
  padding: 0 0 8px 0;
}

.chat-quote-preview-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-left: 3px solid var(--theme-primary, #0d6efd);
  background: rgba(var(--theme-primary-rgb, 13, 110, 253), 0.06);
  border-radius: 4px;
}

.chat-quote-preview-bar .bi-quote {
  color: var(--theme-primary, #0d6efd);
  font-size: 1.1rem;
  flex-shrink: 0;
}

/* 消息操作栏（气泡下方） */
.chat-msg-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  font-size: 0.7rem;
  min-height: 18px;
}

.chat-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  color: var(--theme-text-muted, #6c757d);
  opacity: 0.35;
  transition: opacity 0.15s;
  font-size: 0.75rem;
  cursor: pointer;
  line-height: 1;
}

.chat-action-btn:hover {
  opacity: 0.9;
}

.chat-msg-time {
  color: var(--theme-text-muted, #6c757d);
  font-size: 0.7rem;
  margin-left: auto;
}

/* 未读状态标记（与时间、操作按钮同行） */
.chat-read-status {
  font-size: 0.7rem;
  margin-left: 4px;
  opacity: 0.75;
}

.chat-read-status .bi-check2 {
  color: var(--theme-text-muted, #6c757d);
}

/* 消息内引用块 */
.chat-quote-block {
  padding: 6px 10px;
  margin-bottom: 6px;
  border-left: 3px solid rgba(var(--theme-primary-rgb, 13, 110, 253), 0.5);
  background: rgba(var(--theme-primary-rgb, 13, 110, 253), 0.06);
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.15s;
  text-align: start;
}

.chat-quote-block:hover {
  background: rgba(var(--theme-primary-rgb, 13, 110, 253), 0.12);
}

.chat-quote-block-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--theme-primary, #0d6efd);
  margin-bottom: 2px;
}

.chat-quote-block-content {
  font-size: 0.8rem;
  color: var(--theme-text-muted, #6c757d);
  line-height: 1.3;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 引用跳转高亮动画 */
.chat-msg-highlight {
  animation: chatHighlight 1.5s ease-out;
}

@keyframes chatHighlight {
  0% { background: rgba(var(--theme-primary-rgb, 13, 110, 253), 0.2); }
  100% { background: transparent; }
}

.bg-theme-primary {
  background: var(--theme-primary) !important;
  color: white;
}

/* 移动端响应式 */
@media (max-width: 767px) {
  /* 聊天填满可用空间（卡片内边距由页面 @section Styles 移除） */
  .chat-container {
    height: calc(100vh - 106px);
    border-radius: 0;
  }

  .chat-sidebar {
    width: 100%;
    min-width: auto;
    border-right: none;
  }

  /* 移动端默认隐藏右侧聊天区域，仅显示会话列表（JS 通过 inline style 控制显示） */
  .chat-main {
    display: none;
  }

  .chat-msg-body {
    max-width: 85%;
  }

  /* 移动端输入区：input-group 风格（与系统助手一致） */
  .chat-input-area {
    padding: 6px 8px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #eee;
    background: #fff;
  }

  /* 移动端聊天头部：更紧凑 */
  .chat-header {
    padding: 6px 10px;
  }

  .chat-header h6 {
    font-size: 0.88rem;
  }

  .chat-header small {
    font-size: 0.7rem;
  }

  /* 将 d-flex 行包装成 input-group 风格的整体容器 */
  .chat-input-area .d-flex {
    background: #f5f7fa;
    border: 1px solid var(--theme-primary, #0d6efd);
    border-radius: 8px;
    padding: 3px;
    gap: 0;
    align-items: stretch;
  }

  .chat-input-area .btn-group {
    flex: 0 0 auto;
    margin: 0;
  }

  .chat-input-area .btn-group .btn {
    padding: 8px 12px;
    font-size: 1.1rem;
    border: none;
    background: transparent;
    color: #555;
    border-radius: 6px 0 0 6px;
    min-height: 40px;
  }

  .chat-input-area .btn-group .btn:active {
    background: rgba(0, 0, 0, 0.06);
  }

  .chat-input-area textarea {
    flex: 1 1 0 !important;
    min-width: 0;
    font-size: 0.9rem;
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 8px 10px;
    resize: none;
    max-height: 120px;
    line-height: 1.4;
    overflow-y: auto;
  }

  .chat-input-area textarea:focus {
    background: transparent !important;
    box-shadow: none !important;
  }

  .chat-input-area #btnSend {
    border-radius: 0 6px 6px 0;
    border: none;
    padding: 8px 14px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
  }

  .chat-input-area #btnSend i {
    font-size: 1.1rem;
  }

  /* 移动端隐藏图片按钮（统一走“上传附件”），截图按钮改用摄像头拍照 */
  .chat-input-area #btnUploadImage {
    display: none !important;
  }
}

/* ========== 用户头像样式 ========== */
.user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
}

.user-avatar img {
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.avatar-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    font-weight: 600;
    font-size: 0.85rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    user-select: none;
    flex-shrink: 0;
}

/* === 弹窗标题栏统一使用主题色 ===
 * 排除 modal-helper.js 的语义色弹窗（bg-success/bg-danger/bg-warning/bg-info）
 */
.modal-header:not(.bg-success):not(.bg-danger):not(.bg-warning):not(.bg-info) {
  background: var(--theme-btn-gradient) !important;
  color: #fff !important;
  border-bottom: none;
}
.modal-header:not(.bg-success):not(.bg-danger):not(.bg-warning):not(.bg-info) .btn-close {
  filter: invert(1) brightness(2);
}
.modal-header:not(.bg-success):not(.bg-danger):not(.bg-warning):not(.bg-info) .modal-title,
.modal-header:not(.bg-success):not(.bg-danger):not(.bg-warning):not(.bg-info) .modal-title i {
  color: #fff !important;
}
/* 黑白主题下保持白色头部 + 黑色文字（与 theme.css 的 theme-header 规则一致） */
[data-theme="white"] .modal-header:not(.bg-success):not(.bg-danger):not(.bg-warning):not(.bg-info) {
  background: #FFFFFF !important;
  color: #000000 !important;
  border-bottom: 2px solid #000000 !important;
}
[data-theme="white"] .modal-header:not(.bg-success):not(.bg-danger):not(.bg-warning):not(.bg-info) .modal-title,
[data-theme="white"] .modal-header:not(.bg-success):not(.bg-danger):not(.bg-warning):not(.bg-info) .modal-title i {
  color: #000000 !important;
}
[data-theme="white"] .modal-header:not(.bg-success):not(.bg-danger):not(.bg-warning):not(.bg-info) .btn-close {
  filter: none !important;
  opacity: 1 !important;
}

/* ============================================================
 *  弹窗内表格统一紧凑小字
 *  所有弹窗（含 showModal 动态弹窗）中的表格字体与报告清单
 *  .report-list-table 保持一致；rem 单位跟随界面风格字体缩放
 * ============================================================ */
.modal .table {
  font-size: 0.78rem;
}

/* ============================================================
 *  弹窗动态提示区域
 *  显示在标题下方、表单上方，根据字段动态更新内容
 * ============================================================ */
.modal-prompt {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    color: var(--bs-secondary-color, #6c757d);
    background: var(--bs-tertiary-bg, #f8f9fa);
    border-bottom: 1px solid var(--bs-border-color, #dee2e6);
    white-space: pre-line;
    word-break: break-word;
    line-height: 1.5;
}
.modal-prompt:empty {
    display: none;
}

/* ============================================================
 *  操作按钮统一 Tooltip
 *  tooltip 元素由 site.js 动态创建并挂载到 body，
 *  通过 fixed 定位避免 td overflow:hidden 裁剪
 * ============================================================ */

.table-btn-tip {
    position: fixed;
    z-index: 99999;
    pointer-events: none;
    background: var(--theme-primary, #0d6efd);
    color: #fff;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1.5;
    white-space: nowrap;
    letter-spacing: 0.03em;
    box-shadow: 0 3px 12px rgba(var(--theme-primary-rgb, 13, 110, 253), 0.35);
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    display: none;
}

.table-btn-tip.show {
    opacity: 1;
    transform: translateY(0);
}

.table-btn-tip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--theme-primary, #0d6efd);
}

/* td 截断语义类（§2.9.3：替代内联样式，供各页面共享 JS 使用；截断 tooltip 由 site.js initCellOverflowTips 接管） */
td.td-truncate {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

td.td-truncate-lg {
    max-width: 200px;
}

/* 表格单元格截断内容 Tooltip（site.js initCellOverflowTips 自动管理） */
.table-cell-tip {
    position: fixed;
    z-index: 99999;
    pointer-events: none;
    background: var(--theme-primary, #0d6efd);
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    line-height: 1.5;
    max-width: 560px;
    /* pre-wrap：保留内容中的换行符（如报告方法多行文本），同时超出 max-width 自动换行 */
    white-space: pre-wrap;
    word-break: break-all;
    box-shadow: 0 3px 12px rgba(var(--theme-primary-rgb, 13, 110, 253), 0.35);
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    display: none;
}

.table-cell-tip.show {
    opacity: 1;
    transform: translateY(0);
}

/* ==================== 弹窗默认屏幕居中 ==================== */
/* 所有 Bootstrap 弹窗默认垂直居中，无需在每个 modal-dialog 上加 modal-dialog-centered */
.modal-dialog {
    display: flex;
    align-items: center;
    min-height: calc(100% - var(--bs-modal-margin) * 2);
}

/* ==================== 编辑弹窗固定宽度 ==================== */
/* 防止拖动或内容变化时弹窗尺寸改变 */
#editPlanModal .modal-dialog {
    min-width: 400px !important;
    max-width: 600px !important;
    width: 500px !important;
}

#editPlanModal .modal-content {
    min-width: 400px !important;
    width: 100% !important;
}

#editPlanModal textarea {
    min-height: 57px !important;
}

/* ==================== BIT 三态勾选框（与 DictHelper BIT 字段渲染一致） ==================== */
/* 三态勾选框容器 */
#editPlanBitContainer .d-flex {
    padding: 6px 10px;
    border-radius: 6px;
    transition: background 0.2s ease;
}

/* 空值状态：主题色浅底（同 DictHelper 的 --theme-primary-faint） */
#bitTriState.bit-null {
    outline: 2px solid var(--theme-primary, #0d6efd);
    outline-offset: 1px;
    background-color: transparent !important;
}

#editPlanBitContainer.bit-null-state .d-flex {
    background: var(--theme-primary-faint, rgba(13,110,253,0.1));
}

/* 勾选状态：显式 class + :checked 双保险，主题色填充 + SVG 对勾 */
#bitTriState.bit-checked,
#bitTriState:checked {
    background-color: var(--theme-primary, #0d6efd) !important;
    border-color: var(--theme-primary, #0d6efd) !important;
    --bs-form-check-bg-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/%3e%3c/svg%3e") !important;
}

/* 状态标签字体加粗 */
#bitTriStateLabel {
    font-weight: 500;
    cursor: pointer;
    user-select: none;
}

/* ============================================ */
/* 公司级设置 - 工作日日历样式                   */
/* ============================================ */
.wd-cal-table td {
    min-width: 50px;
    height: 50px;
    vertical-align: middle;
    font-size: 1rem;
    font-weight: 500;
}
.wd-day-work  { background: var(--theme-primary) !important; color: #ffffff !important; font-weight: 600; }
.wd-day-off   { background: var(--theme-gray) !important; color: #ffffff !important; }
.wd-day:hover { filter: brightness(0.9); cursor: pointer; }
.wd-day:focus { outline: 2px solid var(--theme-primary); outline-offset: -2px; }

/* 折叠按钮箭头旋转 */
[aria-expanded="true"] .bi-chevron-down { transform: rotate(180deg); transition: transform 0.2s; }
[aria-expanded="false"] .bi-chevron-down { transform: rotate(0deg); transition: transform 0.2s; }

/* ============================================ */
/* 迷你进度条（表格内使用）                              */
/* ============================================ */
.progress-mini {
    height: 8px;
    border-radius: 4px;
    background-color: var(--bs-progress-bg, #e9ecef);
}

.progress-mini .progress-bar {
    border-radius: 4px;
    background-color: var(--theme-primary);
}

/* ============================================ */
/* 任务面板拖动调整高度                              */
/* ============================================ */
.panel-drag-handle {
    height: 6px;
    cursor: ns-resize;
    background: transparent;
    position: relative;
    flex-shrink: 0;
    user-select: none;
}

.panel-drag-handle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 3px;
    background: var(--theme-border-dark, #adb5bd);
    border-radius: 2px;
    transition: background 0.2s, width 0.2s;
}

.panel-drag-handle:hover::after {
    background: var(--theme-primary, #0d6efd);
    width: 60px;
}

/* ============================================ */
/* 合同/任务行内展开详情卡片                        */
/* ============================================ */
.contract-detail-expand td {
    padding: 0 !important;
    background: var(--bs-tertiary-bg, #f8f9fa);
    border-top: none;
}

.contract-detail-card {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px 16px;
    animation: slideDown 0.15s ease-out;
}

.contract-detail-card > .cd-group {
    flex: 1 1 0;
    min-width: 0;
}

.contract-detail-card > .cd-group:nth-child(1),
.contract-detail-card > .cd-group:nth-child(2) {
    flex: 3 1 0;
}

.contract-detail-card > .cd-group:nth-child(3),
.contract-detail-card > .cd-group:nth-child(4) {
    flex: 2 1 0;
}

.cd-col-right {
    flex: 4 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.cd-group {
    min-width: 0;
    background: var(--bs-body-bg, #fff);
    border: 1px solid var(--theme-border, #dee2e6);
    border-radius: 8px;
    overflow: hidden;
}

.cd-group-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--theme-primary, #0d6efd);
    padding: 6px 10px;
    background: rgba(var(--theme-primary-rgb, 13, 110, 253), 0.06);
    border-bottom: 1px solid var(--theme-border, #dee2e6);
}

.cd-group-body {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    padding: 4px 0;
}

.cd-field {
    flex: 1 1 100%;
    display: flex;
    align-items: baseline;
    padding: 3px 10px;
    font-size: 0.82rem;
    line-height: 1.4;
}

.cd-label {
    color: var(--bs-secondary-color, #6c757d);
    white-space: nowrap;
    margin-right: 6px;
    flex-shrink: 0;
}

.cd-label::after {
    content: '\FF1A';  /* 中文冒号 ： */
}

.cd-value {
    color: var(--bs-body-color, #212529);
    word-break: break-all;
    font-weight: 500;
}

/* DataSync 同步指示圆点（仅开发人员/重度用户可见） */
#data-sync-dot {
    position: fixed;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--theme-primary, #0d6efd);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 1080;
}
#data-sync-dot.active {
    opacity: 0.35;
    pointer-events: auto;
    cursor: help;
}

/* ============================================ */
/* 系统助手动画与组件样式                              */
/* ============================================ */

@keyframes zy-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.spinning {
    animation: zy-spin 1s linear infinite;
    display: inline-block;
}

@keyframes zy-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}
#voiceBtn.listening {
    animation: zy-pulse 1s infinite;
}

.streaming-cursor {
    display: inline-block;
    width: 8px;
    height: 1em;
    background: var(--theme-primary, #0dcaf0);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: zy-blink 1s step-end infinite;
}
@keyframes zy-blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* 助手内 Toast 提示 */
.assistant-toast {
    position: absolute;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 8px 12px 8px 16px;
    border-radius: 8px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
    transition: opacity 0.3s;
}
.assistant-toast button {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    padding: 0 2px;
    font-size: 1rem;
    line-height: 1;
}

/* 助手停止生成按钮 */
.btn-stop-stream {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: #6c757d;
    border: 1px solid #dee2e6;
    background: #fff;
    border-radius: 12px;
    padding: 2px 10px;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-stop-stream:hover {
    color: #dc3545;
    border-color: #dc3545;
}

/* 助手消息重试按钮 */
.btn-retry-msg {
    font-size: 0.75rem;
    color: #6c757d;
    cursor: pointer;
    text-decoration: underline;
}
.btn-retry-msg:hover {
    color: var(--theme-primary);
}
