:root {
  --app-bg: #F5F6F8;
  --app-card: #FFFFFF;
  --app-border: #E5E7EB;
  --app-text: #111827;
  --app-muted: #6B7280;
  --app-primary: #2563EB;
  --app-primary-hover: #1D4ED8;
  --app-radius: 8px;
  --app-radius-sm: 6px;
  --app-shadow: 0 1px 3px rgba(0, 0, 0, .06);
  --app-shadow-lg: 0 8px 24px rgba(0, 0, 0, .10);
}

* { font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif; }
body { background-color: var(--app-bg); color: var(--app-text); }

/* 启动加载占位 */
.boot-loading { min-height: 100vh; display: flex; align-items: center; justify-content: center; }

/* ---------- Login ---------- */
.auth-body { background-color: #F5F6F8; }
.auth-wrap { min-height: 100vh; display: flex; }
.auth-brand {
  flex: 1.2;
  background: linear-gradient(135deg, #1D4ED8 0%, #3B82F6 100%);
  background-size: cover;
  background-position: center;
  color: #FFFFFF;
  position: relative; overflow: hidden;
}
.auth-brand.has-bg { color: #1F2937; background-color: #fff; }
.auth-brand.has-bg::before {
  content: ""; position: absolute; inset: 0; z-index: 0;
  background: rgba(255, 255, 255, .55);
}
.auth-brand .brand-inner { position: relative; z-index: 1; }
.auth-brand .brand-sub { color: rgba(255, 255, 255, .8); }
.auth-brand.has-bg .brand-sub { color: #4B5563; }
.auth-brand.has-bg .brand-inner h1,
.auth-brand.has-bg .brand-sub {
  -webkit-text-stroke: 2px rgba(255, 255, 255, .95);
  paint-order: stroke fill;
}
.auth-logo {
  width: 52px; height: 52px; font-size: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 12px; background: #fff; color: #1F2937; overflow: hidden;
}
.auth-logo img { width: 100%; height: 100%; object-fit: contain; border-radius: 12px; }
.auth-form-area { flex: 1; background-color: #F5F6F8; }

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; background: #fff; border-right: 1px solid var(--app-border);
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 1030;
  display: flex; flex-direction: column; overflow: hidden;
  transition: width .25s cubic-bezier(.4, 0, .2, 1), left .25s ease;
}
.sidebar.collapsed { width: 56px; }
.sidebar.collapsed .brand-text,
.sidebar.collapsed .menu-text,
.sidebar.collapsed .menu-arrow,
.sidebar.collapsed .submenu { display: none; }
.sidebar.collapsed .menu-link { justify-content: center; padding: 10px; }
.sidebar.collapsed .brand { justify-content: center; padding: 0; }

.brand { height: 60px; padding: 0 16px; border-bottom: 1px solid var(--app-border); }
.brand-logo {
  width: 30px; height: 30px; font-size: 18px; border-radius: 8px;
  background: var(--app-primary); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.brand-logo img { width: 100%; height: 100%; object-fit: contain; border-radius: 6px; }
.brand-text, .menu-text { white-space: nowrap; }

.sidebar-body { flex: 1; overflow-y: auto; padding: 10px 8px; }
.main { flex: 1; min-width: 0; margin-left: 240px; transition: margin-left .25s cubic-bezier(.4, 0, .2, 1); }
.main.expanded { margin-left: 56px; }

.topbar {
  height: 60px; background: #fff; border-bottom: 1px solid var(--app-border);
  display: flex; align-items: center; padding: 0 20px; gap: 12px;
  position: sticky; top: 0; z-index: 1020;
}
.content { padding: 22px 24px; }
.avatar-sm {
  width: 30px; height: 30px; font-size: 13px; border-radius: 50%;
  background: var(--app-primary); color: #fff; display: inline-flex;
  align-items: center; justify-content: center;
}
.topbar-title { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-menu-toggle { display: flex; align-items: center; gap: 6px; color: var(--app-text); text-decoration: none; font-weight: 600; font-size: 14px; }
.user-menu-toggle:hover { color: var(--app-primary); }

/* ---------- Sidebar menu ---------- */
.menu-list { list-style: none; margin: 0; padding: 0; }
.menu-item { margin: 2px 0; }
.menu-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--app-radius-sm);
  color: var(--app-text); text-decoration: none; font-size: 14px;
  position: relative; transition: background .15s ease, color .15s ease;
}
.menu-link:hover { background: #F3F4F6; color: var(--app-text); }
.menu-link.active { background: var(--app-primary); color: #fff; }
.menu-link.parent { font-weight: 600; }
.menu-arrow { margin-left: auto; font-size: 12px; transition: transform .2s ease; }
.menu-item.open > .menu-link.parent .menu-arrow { transform: rotate(90deg); }

.submenu { list-style: none; margin: 2px 0 2px 0; padding-left: 20px; position: relative; }
.submenu::before {
  content: ""; position: absolute; left: 16px; top: 0; bottom: 0;
  width: 1px; background: var(--app-border);
}
.submenu .menu-link { padding: 8px 12px 8px 24px; font-size: 13px; color: var(--app-muted); position: relative; }
.submenu .menu-link::before {
  content: ""; position: absolute; left: 15px; top: 50%; width: 10px; height: 1px; background: var(--app-border);
}
.submenu .menu-link:hover { color: var(--app-text); background: #F9FAFB; }
.submenu .menu-link.active { background: var(--app-primary); color: #fff; }
.submenu .menu-link.active::before { background: rgba(255,255,255,.6); }

/* ---------- Cards / Buttons / Badges / Tables ---------- */
.card { border-radius: var(--app-radius); box-shadow: var(--app-shadow); border: 1px solid #EEF0F3; }
.btn { border-radius: var(--app-radius-sm); }
.btn-dark { background: var(--app-primary); border-color: var(--app-primary); }
.btn-dark:hover { background: var(--app-primary-hover); border-color: var(--app-primary-hover); }
.btn-outline-dark { color: var(--app-primary); border-color: #D1D5DB; }
.btn-outline-dark:hover { background: var(--app-primary); border-color: var(--app-primary); color: #fff; }
.btn-icon {
  width: 30px; height: 30px; padding: 0; display: inline-flex;
  align-items: center; justify-content: center; border-radius: 6px;
}
.btn i.bi, .dropdown-item i.bi { margin-right: .45rem !important; }
.btn-icon i.bi { margin-right: 0 !important; }
.badge-soft {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; font-size: 12px; font-weight: 500;
  border-radius: 999px; line-height: 1;
}
.badge-soft.success { background: #ECFDF3; color: #16A34A; }
.badge-soft.secondary { background: #F3F4F6; color: #6B7280; }
.badge-soft.dark { background: #1F2937; color: #fff; }
.badge-soft.warning { background: #FFFBEB; color: #D97706; }
.badge-soft.danger { background: #FEF2F2; color: #DC2626; }
.badge-soft.info { background: #EFF6FF; color: #2563EB; }
.badge-soft.violet { background: #F5F3FF; color: #7C3AED; }
.badge-soft.teal { background: #F0FDFA; color: #0D9488; }
.dashboard-role { font-size: 13px; padding: 5px 12px; }

/* 发文单位多选：数字直接充当勾选标记（选中=深色方块内显示选择顺序数字） */
.dept-check {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border: 1px solid #9CA3AF; border-radius: 3px;
  margin-right: 6px; vertical-align: middle; cursor: pointer;
  font-size: 10px; font-weight: 700; line-height: 1; user-select: none;
  background: #fff; color: transparent;
}
.dept-check.on { background: #0d6efd; border-color: #0d6efd; color: #fff; }

.table { font-size: 13px; }
.table th { white-space: nowrap; }
.table td, .table th { overflow-wrap: anywhere; word-break: break-word; }
.table-striped > tbody > tr:nth-of-type(odd) > * { background-color: #FAFBFC; }
.table-light { background-color: #F9FAFB; }
.table > :not(caption) > * > * { padding: 10px 12px; }

.dropdown-menu { border-radius: 10px; box-shadow: var(--app-shadow-lg); border: 1px solid #EEF0F3; padding: 6px; animation: dropdownFade .12s ease; }
.dropdown-item { border-radius: 6px; padding: 8px 10px; font-size: 14px; }
.dropdown-item:hover { background: #F3F4F6; }
@keyframes dropdownFade { from { opacity: 0; } to { opacity: 1; } }

.modal-content { border-radius: 12px; box-shadow: var(--app-shadow-lg); border: none; }
.modal-header { border-bottom: 1px solid #F3F4F6; }
.modal-footer { border-top: 1px solid #F3F4F6; }
.form-control, .form-select { border-radius: var(--app-radius-sm); font-size: 14px; }
.form-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%236B7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M2.5 5.5L8 11l5.5-5.5'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right .75rem center;
  background-size: 16px 12px;
  padding-right: 2.5rem;
}
.form-control:focus, .form-select:focus { border-color: var(--app-primary); box-shadow: 0 0 0 .15rem rgba(31,41,55,.08); }

/* 输入框后缀（级/班） */
.input-suffix { position: relative; }
.input-suffix .suffix-text {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  color: #9CA3AF; pointer-events: none; font-size: 14px;
}
.pagination .page-link { color: var(--app-primary); border-radius: 6px; margin: 0 2px; }
.pagination .page-item.active .page-link { background: var(--app-primary); border-color: var(--app-primary); color: #fff; }

.toast-container { z-index: 2000; }
.toast { border-radius: 10px; box-shadow: var(--app-shadow-lg); min-width: 280px; overflow: hidden; }
.toast-icon { padding-left: 16px; font-size: 18px; display: inline-flex; align-items: center; }
.toast-enter-active, .toast-leave-active { transition: all .3s cubic-bezier(.4, 0, .2, 1); }
.toast-enter-from, .toast-leave-to { opacity: 0; transform: translateX(24px); }
.tooltip .tooltip-inner { background: #1F2937; border-radius: 6px; font-size: 12px; padding: 5px 10px; }

/* 悬浮提示：黑底小气泡（向上浮出；data-tip-pos="down" 则向下浮出） */
[data-tip] { position: relative; }
[data-tip]:hover::after,
[data-tip]:hover::before { animation: tip-pop .16s ease-out; }
[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 8px); left: 50%;
  transform: translateX(-50%);
  background: #111827; color: #fff; font-size: 12px;
  padding: 5px 10px; border-radius: 6px; white-space: nowrap;
  z-index: 1060; pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,.22);
}
[data-tip]:hover::before {
  content: ""; position: absolute; bottom: calc(100% + 3px); left: 50%;
  transform: translateX(-50%); border: 5px solid transparent;
  border-top-color: #111827; z-index: 1060; pointer-events: none;
}
/* 向下浮出 */
[data-tip-pos="down"]:hover::after { bottom: auto; top: calc(100% + 8px); }
[data-tip-pos="down"]:hover::before {
  bottom: auto; top: calc(100% + 3px);
  border-top-color: transparent; border-bottom-color: #111827;
}
/* 空提示不显示 */
[data-tip=""]::after, [data-tip=""]::before { content: none; }
@keyframes tip-pop {
  from { opacity: 0; transform: translateX(-50%) translateY(4px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* 问号帮助提示：空心 ↔ 实心 渐变切换 */
.help-tip {
  position: relative; display: inline-block;
  width: 14px; height: 14px; vertical-align: -2px; cursor: help;
  color: var(--app-muted);
}
.help-tip i {
  position: absolute; inset: 0;
  font-size: 14px; line-height: 1;
  transition: opacity .22s ease;
}
.help-tip .bi-question-circle-fill { opacity: 0; color: var(--app-primary); }
.help-tip:hover .bi-question-circle { opacity: 0; }
.help-tip:hover .bi-question-circle-fill { opacity: 1; }

/* 验证码图片 */
.captcha-img { width: 100px; height: 38px; object-fit: cover; cursor: pointer; border: 1px solid var(--app-border); border-left: none; border-radius: 0 var(--app-radius-sm) var(--app-radius-sm) 0; }

/* 子菜单展开动画 */
.slide-enter-active, .slide-leave-active { transition: all .18s ease; overflow: hidden; }
.slide-enter-from, .slide-leave-to { opacity: 0; transform: translateY(-6px); }

/* 页面切换动画 */
.page-enter-active, .page-leave-active { transition: opacity .18s ease, transform .18s ease; }
.page-enter-from { opacity: 0; transform: translateY(8px); }
.page-leave-to { opacity: 0; transform: translateY(-8px); }

/* 顶层视图切换（登录/初始化/应用壳） */
.view-enter-active, .view-leave-active { transition: opacity .22s ease; }
.view-enter-from, .view-leave-to { opacity: 0; }

/* flatpickr 日期选择器主题 */
.flatpickr-calendar { border-radius: 10px; box-shadow: var(--app-shadow-lg); font-family: inherit; }
.flatpickr-day.selected, .flatpickr-day.selected:hover, .flatpickr-day.selected:focus { background: var(--app-primary); border-color: var(--app-primary); }
.flatpickr-day.today { border-color: var(--app-primary); }
.flatpickr-day:hover { background: #EFF6FF; border-color: var(--app-primary); }

/* 多选下拉（复选框） */
.multi-select { position: relative; }
.multi-select-toggle { cursor: pointer; }
.multi-select-toggle .bi { font-size: 12px; }
.multi-select-menu {
  position: absolute; top: calc(100% + 4px); left: 0; min-width: 100%; width: max-content; z-index: 1050;
  background: #fff; border: 1px solid #EEF0F3; border-radius: 8px;
  box-shadow: var(--app-shadow-lg); max-height: 220px; overflow-y: auto; padding: 6px;
}
.multi-select-item {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px;
  cursor: pointer; font-size: 14px; margin: 0; white-space: nowrap;
}
.multi-select-item:hover { background: #F3F4F6; }
.multi-select-item .form-check-input { margin: 0; }
.multi-select-group { padding: 4px 8px; font-size: 12px; font-weight: 600; color: #6B7280; }

/* 单选下拉（与多选同款设计） */
.select-dropdown { position: relative; }

/* 我的签到码（二维码/条形码）居中显示 */
.sign-code-box { display: flex; justify-content: center; align-items: center; }
.sign-code-box canvas,
.sign-code-box img,
.sign-code-box svg { display: block; margin: 0 auto; }
.select-toggle { cursor: pointer; }
.select-toggle .bi { font-size: 12px; }
.select-menu {
  position: absolute; top: calc(100% + 4px); left: 0; min-width: 100%; width: max-content; z-index: 1050;
  background: #fff; border: 1px solid #EEF0F3; border-radius: 8px;
  box-shadow: var(--app-shadow-lg); max-height: 220px; overflow-y: auto; padding: 6px;
}
.select-item {
  display: block; width: 100%; text-align: left; border: none; background: none;
  padding: 7px 10px; border-radius: 6px; font-size: 14px; color: var(--app-text); cursor: pointer;
  white-space: nowrap;
}
.select-item:hover { background: #F3F4F6; }
.select-item.active { background: #EFF6FF; color: var(--app-primary); font-weight: 500; }
.select-item.disabled { color: #9CA3AF; cursor: not-allowed; }
.select-item.disabled:hover { background: none; }

/* 审批规则构建器（if 条件嵌套 + 顺序 elseif） */
.rule-node { border: 1px solid #E5E7EB; border-radius: 10px; padding: 10px; background: #fff; }
.rule-node .rule-node { margin: 8px 0 0 12px; background: #FBFCFE; }
.rule-node-head { margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid #EEF0F3; }
.rule-cond-group { padding: 10px; background: #F7F9FC; border: 1px solid #E5E7EB; border-radius: 8px; }
.rule-group-title { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: #374151; margin-bottom: 8px; }
.rule-group-title .bi { color: var(--app-primary); }
.rule-cond-row { display: flex; gap: 6px; margin-bottom: 6px; align-items: center; }
.rule-cond-row .select-dropdown { min-width: 128px; flex: 0 0 auto; }
.rule-cond-row input.form-control-sm { flex: 1 1 auto; min-width: 90px; }
.rule-cond-actions { display: flex; align-items: center; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.rule-branch { margin-top: 10px; padding: 10px; border-radius: 8px; }
.rule-branch.then { border: 1px solid #D1FAE5; background: #ECFDF5; }
.rule-branch.else { border: 1px solid #E5E7EB; background: #F9FAFB; }
.rule-branch-label { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; margin-bottom: 6px; }
.rule-branch.then .rule-branch-label { color: #059669; }
.rule-branch.else .rule-branch-label { color: #6B7280; }
.rule-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.rule-chip { display: inline-flex; align-items: center; gap: 6px; background: #EFF6FF; color: #1D4ED8; padding: 4px 10px; border-radius: 999px; font-size: 12px; }
.rule-chip .rule-chip-idx { background: rgba(29, 78, 216, 0.12); border-radius: 999px; width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; }
.rule-chip .bi { cursor: pointer; opacity: 0.55; }
.rule-chip .bi:hover { opacity: 1; }
.rule-empty { font-size: 12px; color: #9CA3AF; }
.rule-chip-role { background: #F5F3FF; color: #7C3AED; }
.rule-chip-role .rule-chip-idx { background: rgba(124, 58, 237, 0.12); }
.rule-approver-add { margin-top: 8px; padding-top: 8px; border-top: 1px solid #EEF0F3; }
.rule-elseif { margin-top: 10px; padding: 10px; border: 1px dashed #93C5FD; border-radius: 8px; background: #FBFDFF; }
.rule-elseif-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px dashed #E5E7EB; }
.rule-elseif-label { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: #1D4ED8; }
.rule-add-elseif { margin-top: 10px; }

/* 排班项目周表格 */
.project-table { table-layout: fixed; }
.project-table th, .project-table td { text-align: center; vertical-align: middle; }
.project-cell { min-height: 44px; min-width: 72px; }
.project-cell:hover { background: #EFF6FF; }

/* 到岗日历（月历：周数 + 星期表头） */
.att-calendar { display: grid; grid-template-columns: 56px repeat(7, 1fr); gap: 6px; }
.att-cal-weekno, .att-cal-weekday { font-size: 12px; color: #6B7280; text-align: center; align-self: center; font-weight: 600; }
.att-cal-weekno { color: #9CA3AF; }
.att-cal-day { border: 1px solid #E5E7EB; border-radius: 8px; min-height: 68px; padding: 6px; text-align: center; background: #fff; }
.att-cal-day:not(.cal-blank) { cursor: pointer; }
.att-cal-day:not(.cal-blank):hover { border-color: #2563EB; }
.att-cal-day .day-num { font-size: 12px; color: #6B7280; }
.att-cal-day .day-info { font-size: 12px; font-weight: 600; margin-top: 2px; }
.cal-none { background: #F3F4F6; color: #9CA3AF; }
.cal-full { background: #D1FAE5; }
.cal-partial { background: #FEF3C7; }
.cal-absent { background: #FEE2E2; }
.cal-future { background: #F9FAFB; color: #D1D5DB; }
.cal-blank { border: none; background: transparent; min-height: 68px; cursor: default; }

/* 周总览：可点击单元格（无圆角外框） */
.weekly-cell-clickable { cursor: pointer; transition: background .12s ease; }
.weekly-cell-clickable:hover { background: #EFF6FF !important; }

/* 可编辑下拉（combobox） */
.combobox { position: relative; }
.combobox-control.form-control { display: flex; align-items: center; padding: 0; overflow: hidden; }
.combobox-input { flex: 1; border: none; outline: none; background: transparent; padding: 6px 10px; font-size: 13px; color: var(--app-text); min-width: 0; }
.combobox-control.form-control-sm .combobox-input { padding: 4px 8px; font-size: 12px; }
.combobox-arrow { border: none; background: transparent; padding: 0 10px; align-self: stretch; color: #9CA3AF; cursor: pointer; font-size: 12px; }
.combobox-arrow:hover { color: var(--app-primary); }
.combobox-menu { position: absolute; top: calc(100% + 4px); left: 0; min-width: 100%; width: max-content; z-index: 1050; background: #fff; border: 1px solid #EEF0F3; border-radius: 8px; box-shadow: var(--app-shadow-lg); max-height: 200px; overflow-y: auto; padding: 6px; }
.combobox-item { display: block; width: 100%; text-align: left; border: none; background: none; padding: 6px 10px; border-radius: 6px; font-size: 13px; color: var(--app-text); cursor: pointer; white-space: nowrap; }
.combobox-item:hover { background: #F3F4F6; }

/* 筛选栏标签（与输入框垂直对齐） */
.filter-label { display: inline-flex; align-items: center; gap: 5px; color: var(--app-muted); font-size: 13px; line-height: 1; }
.filter-label .bi { font-size: 14px; line-height: 1; vertical-align: 0; }

/* ---------- Permission tree rows ---------- */
.perm-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; }
.perm-row:hover { background: #F9FAFB; }
.perm-row .form-check { margin: 0; }

/* ---------- 组织架构树 ---------- */
.org-tree { display: flex; flex-direction: column; }
.org-node {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 6px; cursor: grab;
  border: 1px solid transparent; transition: background .12s ease;
}
.org-node:hover { background: #F9FAFB; }
.org-node-icon { color: var(--app-primary); }
.member-avatar {
  width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  background: #EEF2FF; color: var(--app-primary);
}
.member-avatar.placeholder { font-size: 16px; }

/* ---------- 自定义滚动条（主题风格，替代浏览器默认） ---------- */
* { scrollbar-width: thin; scrollbar-color: #C7CBD4 #F0F1F4; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #F0F1F4; border-radius: 8px; }
::-webkit-scrollbar-thumb { background: #C7CBD4; border-radius: 8px; border: 2px solid #F0F1F4; }
::-webkit-scrollbar-thumb:hover { background: #A9AEB9; }
::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-track-piece { background: transparent; }

/* ---------- Responsive ---------- */
@media (max-width: 991.98px) {
  .sidebar { left: -240px; width: 240px; }
  .sidebar.mobile-open { left: 0; }
  .main, .main.expanded { margin-left: 0; }
}
