.va-card {
  background: var(--va-bg-card);
  border-radius: var(--va-radius-md);
  box-shadow: var(--va-shadow-sm);
  border: 1px solid var(--va-border-light);
  position: relative;
}

.va-card__body { padding: 20px; }

.va-card__header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--va-border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-weight: 600;
  font-size: 16px;
}

.va-card__header-title {
  flex-shrink: 0;
}

.va-card__header-hint {
  flex: 1;
  min-width: 0;
  text-align: right;
  font-weight: 400;
  font-size: 12px;
  color: var(--va-text-muted);
  line-height: 1.5;
}

.va-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--va-radius-md);
  font-size: 14px;
  cursor: pointer;
  transition: all var(--va-transition);
  background: transparent;
  color: var(--va-text);
  white-space: nowrap;
}

.va-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.va-btn-primary { background: var(--va-primary); color: var(--va-text-inverse); border-color: var(--va-primary); }
.va-btn-primary:hover:not(:disabled) { background: var(--va-primary-hover); border-color: var(--va-primary-hover); }

.va-btn-default { background: var(--va-bg-card); border-color: var(--va-border); color: var(--va-text); }
.va-btn-default:hover:not(:disabled) { background: var(--va-bg-hover); }

.va-btn-danger { background: var(--va-danger); color: var(--va-text-inverse); border-color: var(--va-danger); }
.va-btn-danger:hover:not(:disabled) { opacity: 0.9; }

.va-btn-text { border: none; color: var(--va-primary); padding: 0 8px; height: auto; }
.va-btn-text:hover:not(:disabled) { color: var(--va-primary-hover); background: var(--va-bg-hover); border-radius: var(--va-radius-sm); }

.va-btn-sm { height: 28px; padding: 0 10px; font-size: 13px; }

.va-form-group { margin-bottom: 16px; }

.va-form-label {
  display: block;
  margin-bottom: 6px;
  color: var(--va-text-secondary);
  font-size: 13px;
}

.va-form-label .required { color: var(--va-danger); margin-left: 2px; }

.va-input, .va-select, .va-textarea {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--va-border);
  border-radius: var(--va-radius-md);
  font-size: 14px;
  color: var(--va-text);
  background: var(--va-bg-card);
  transition: border-color var(--va-transition), box-shadow var(--va-transition);
}

.va-textarea { height: auto; min-height: 80px; padding: 8px 12px; resize: vertical; }

.va-input:focus, .va-select:focus, .va-textarea:focus {
  outline: none;
  border-color: var(--va-primary);
  box-shadow: 0 0 0 3px var(--va-primary-light);
}

.va-input.is-error, .va-select.is-error { border-color: var(--va-danger); }

.va-form-error { font-size: 12px; color: var(--va-danger); margin-top: 4px; }

.va-table-wrap { overflow-x: auto; }

.va-table {
  width: 100%;
  border-collapse: collapse;
}

.va-table th, .va-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--va-border-light);
  vertical-align: middle;
  text-align: center;
}

.va-table th {
  background: var(--va-bg-hover);
  color: var(--va-text-secondary);
  font-weight: 500;
  font-size: 13px;
  white-space: nowrap;
}

/* 树形列表（部门/权限）首列保留左对齐，便于层级缩进 */
.va-table--tree th:first-child,
.va-table--tree td:first-child {
  text-align: left;
}

.va-table tbody tr:hover { background: var(--va-bg-hover); }

.va-table .va-actions {
  white-space: nowrap;
  text-align: center;
}

/* 列表：部门名称截断 + 悬停展示全文 */
.va-td-depts {
  max-width: 300px;
  padding: 10px 12px !important;
  position: relative;
  overflow: visible;
}

.va-dept-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 5px 8px 5px 10px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--va-text-secondary);
  background: linear-gradient(90deg, rgba(0, 102, 255, 0.07) 0%, rgba(0, 180, 216, 0.04) 100%);
  border: 1px solid rgba(0, 102, 255, 0.14);
  position: relative;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.va-dept-chip::before {
  content: '';
  width: 3px;
  height: 14px;
  margin-right: 2px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--va-primary), var(--va-accent));
  flex-shrink: 0;
  opacity: 0.85;
}

.va-dept-chip.has-tip {
  cursor: default;
}

.va-dept-chip.has-tip:hover {
  z-index: 10;
  border-color: rgba(0, 102, 255, 0.38);
  color: var(--va-primary);
  box-shadow: 0 0 0 1px rgba(0, 102, 255, 0.08), 0 4px 16px rgba(0, 102, 255, 0.14);
}

/* 悬停桥：chip 上方，配合向上展开的 fixed 浮层 */
.va-dept-chip.has-tip::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  height: 12px;
}

.va-dept-chip__text {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  max-width: 220px;
}

.va-dept-chip__copy {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: rgba(0, 102, 255, 0.08);
  color: var(--va-primary);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.va-dept-chip__copy:hover {
  background: rgba(0, 102, 255, 0.18);
  color: var(--va-primary-hover);
  transform: scale(1.05);
}

.va-dept-chip__tip {
  display: block;
  visibility: hidden;
  opacity: 0;
  position: absolute;
  left: 50%;
  top: calc(100% + 10px);
  transform: translateX(-50%);
  min-width: 240px;
  max-width: 460px;
  padding: 10px 14px;
  border-radius: 8px;
  background: linear-gradient(145deg, #1a2332 0%, #243044 100%);
  color: #e8f2ff;
  font-size: 12px;
  line-height: 1.65;
  text-align: left;
  white-space: normal;
  word-break: break-all;
  box-shadow: 0 10px 28px rgba(0, 30, 80, 0.28);
  border: 1px solid rgba(0, 180, 216, 0.28);
  z-index: 40;
  pointer-events: none;
}

/* JS 固定定位：向上展开，仅内容超出最大高度时内部滚动 */
.va-dept-chip__tip.is-tip-fixed {
  position: fixed;
  left: 0;
  top: 0;
  transform: none;
  visibility: visible;
  opacity: 1;
  z-index: 1100;
  pointer-events: auto;
  overflow-x: hidden;
  overflow-y: hidden;
  overscroll-behavior: contain;
}

.va-dept-chip__tip.is-tip-fixed.is-tip-scroll {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.28) transparent;
}

.va-dept-chip__tip.is-tip-fixed.is-tip-scroll::-webkit-scrollbar {
  width: 6px;
}

.va-dept-chip__tip.is-tip-fixed.is-tip-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.28);
  border-radius: 3px;
}

.va-dept-chip__tip.is-tip-fixed.is-tip-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.4);
}

.va-dept-chip__tip.is-tip-fixed.is-measuring {
  pointer-events: none;
}

.va-dept-chip__tip::before {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-bottom-color: #243044;
}

.va-dept-chip__tip.is-tip-fixed::before {
  bottom: auto;
  top: 100%;
  border-bottom-color: transparent;
  border-top-color: #243044;
}

.va-dept-chip__tree {
  list-style: none;
  margin: 0;
  padding: 0;
}

.va-dept-chip__tree-item {
  position: relative;
  padding: 3px 0 3px 0;
  line-height: 1.5;
  color: #e8f2ff;
}

.va-dept-chip__tree-branch {
  display: inline-block;
  margin-right: 4px;
  color: rgba(0, 180, 216, 0.85);
  font-family: monospace;
}

.va-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--va-radius-sm);
  font-size: 12px;
  line-height: 1.5;
}

.va-tag-success { background: rgba(0,181,120,0.1); color: var(--va-success); }
.va-tag-danger { background: rgba(255,77,79,0.1); color: var(--va-danger); }
.va-tag-warning { background: rgba(255,159,10,0.1); color: var(--va-warning); }
.va-tag-info { background: var(--va-primary-light); color: var(--va-primary); }

.va-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.va-toolbar .va-input, .va-toolbar .va-select { width: auto; min-width: 180px; }

.va-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  color: var(--va-text-secondary);
  font-size: 13px;
}

.va-pagination__size {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  white-space: nowrap;
}

.va-select-sm {
  min-width: 72px;
  width: auto;
  padding: 4px 8px;
  font-size: 13px;
  height: 28px;
}

/* Modal */
.va-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 20, 60, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all var(--va-transition);
}

.va-modal-overlay.is-open { opacity: 1; visibility: visible; }

.va-modal {
  background: var(--va-bg-card);
  border-radius: var(--va-radius-lg);
  box-shadow: var(--va-shadow-lg);
  width: 520px;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  transform: translateY(-12px);
  transition: transform var(--va-transition);
}

.va-modal-overlay.is-open .va-modal { transform: translateY(0); }

.va-modal--lg { width: 720px; }

.va-modal--xl {
  width: 920px;
  max-width: 94vw;
  max-height: 92vh;
}

.va-modal__header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--va-border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 16px;
}

.va-modal__title {
  flex-shrink: 0;
}

.va-modal__header-extra {
  flex: 1;
  min-width: 0;
  text-align: right;
  font-weight: 400;
  font-size: 13px;
  color: var(--va-text-muted);
  padding: 0 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.va-modal__close {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--va-text-muted);
  font-size: 20px;
  padding: 4px;
  line-height: 1;
}

.va-modal__body { padding: 20px; overflow-y: auto; flex: 1; }

.va-modal__footer {
  padding: 12px 20px;
  border-top: 1px solid var(--va-border-light);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Toast */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.va-toast {
  min-width: 240px;
  padding: 12px 16px;
  background: var(--va-bg-card);
  border-radius: var(--va-radius-md);
  box-shadow: var(--va-shadow-md);
  border-left: 4px solid var(--va-primary);
  animation: va-toast-in 0.2s ease;
}

.va-toast--success { border-left-color: var(--va-success); }
.va-toast--error { border-left-color: var(--va-danger); }
.va-toast--warning { border-left-color: var(--va-warning); }

@keyframes va-toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* 树形表格 */
.va-tree-row .indent { display: inline-block; }

.va-tree-toggle {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--va-text-muted);
  padding: 0 4px;
  vertical-align: middle;
}

/* 统计卡片 */
.va-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.va-stat-card {
  background: var(--va-bg-card);
  border-radius: var(--va-radius-md);
  padding: 20px;
  border: 1px solid var(--va-border-light);
  box-shadow: var(--va-shadow-sm);
}

.va-stat-card__label { color: var(--va-text-muted); font-size: 13px; margin-bottom: 8px; }
.va-stat-card__value { font-size: 28px; font-weight: 600; color: var(--va-text); }
.va-stat-card__value.is-primary { color: var(--va-primary); }
.va-stat-card__value.is-success { color: var(--va-success); }
.va-stat-card__value.is-warning { color: var(--va-warning); }
.va-stat-card__value.is-danger { color: var(--va-danger); }

/* 权限树 checkbox */
.va-perm-tree { max-height: 400px; overflow-y: auto; }
.va-perm-tree label { display: flex; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer; }
.va-perm-tree .children { padding-left: 24px; }

/* 用户表单：部门选择（左侧单位列表 + 右侧分支树） */
.va-dept-checkboxes {
  max-height: clamp(320px, 48vh, 480px);
  overflow: hidden;
}
.va-dept-picker {
  display: flex;
  border: 1px solid var(--va-border, #e8e8e8);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
  height: clamp(320px, 48vh, 480px);
  max-height: clamp(320px, 48vh, 480px);
}
.va-dept-picker--single {
  display: block;
  height: clamp(280px, 40vh, 400px);
  max-height: clamp(280px, 40vh, 400px);
}
.va-dept-picker--single .va-dept-panel {
  position: static;
  display: block;
  height: 100%;
  min-height: inherit;
  overflow-y: auto;
  padding: 10px 12px;
}
.va-dept-nav {
  flex: 0 0 220px;
  width: 220px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--va-border, #e8e8e8);
  background: var(--va-bg-soft, #f7f9fc);
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}
.va-dept-nav-search-wrap {
  flex-shrink: 0;
  padding: 8px;
  border-bottom: 1px solid var(--va-border-light, #eef0f3);
}
.va-dept-nav-search {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  font-size: 13px;
}
.va-dept-tabs {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  overflow-x: hidden;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}
.va-dept-tabs::-webkit-scrollbar {
  width: 6px;
}
.va-dept-tabs::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.18);
  border-radius: 3px;
}
.va-dept-tabs::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.28);
}
.va-dept-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--va-text, #333);
  font-size: 13px;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.va-dept-tab.is-hidden { display: none; }
.va-dept-tab__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.va-dept-tab:hover {
  background: rgba(22, 119, 255, 0.08);
  color: var(--va-primary, #1677ff);
}
.va-dept-tab.is-active {
  background: var(--va-primary, #1677ff);
  color: #fff;
}
.va-dept-tab-badge {
  flex-shrink: 0;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}
.va-dept-tab.is-active .va-dept-tab-badge {
  background: rgba(255, 255, 255, 0.28);
}
.va-dept-tab:not(.is-active) .va-dept-tab-badge {
  background: var(--va-primary, #1677ff);
  color: #fff;
}
.va-dept-panels {
  flex: 1;
  min-width: 0;
  min-height: 0;
  position: relative;
  overflow: hidden;
}
.va-dept-panel {
  display: none;
  position: absolute;
  inset: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 10px 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}
.va-dept-panel::-webkit-scrollbar {
  width: 6px;
}
.va-dept-panel::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.18);
  border-radius: 3px;
}
.va-dept-panel.is-active { display: block; }
.va-dept-picker--single .va-dept-tree-list { padding: 4px 0; }
.va-dept-tree-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.va-dept-tree-node { list-style: none; }
.va-dept-tree-row {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
}
.va-dept-tree-toggle {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--va-text-muted, #888);
  font-size: 10px;
  line-height: 20px;
  text-align: center;
}
.va-dept-tree-toggle:disabled {
  cursor: default;
  opacity: 0;
}
.va-dept-tree-toggle--expanded::before { content: '▼'; }
.va-dept-tree-toggle--collapsed::before { content: '▶'; }
.va-dept-tree-children.is-collapsed { display: none; }
.va-dept-checkboxes .va-dept-tree-item {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 2px 4px;
  line-height: 1.5;
  cursor: pointer;
  border-radius: 4px;
}
.va-dept-checkboxes .va-dept-tree-item:hover {
  background: var(--va-bg-hover, rgba(0, 0, 0, 0.04));
}
.va-dept-checkboxes .va-dept-tree-item input[type="checkbox"] {
  flex-shrink: 0;
  margin: 0;
  cursor: pointer;
}
.va-dept-tree-item__name {
  word-break: break-all;
}
.va-dept-select-summary {
  font-size: 12px;
  line-height: 1.6;
  color: var(--va-primary, #1677ff);
  background: var(--va-bg-soft, #f0f6ff) !important;
  border: 1px solid rgba(22, 119, 255, 0.15);
}
.va-dept-select-summary.is-empty {
  color: var(--va-text-muted, #888);
  background: var(--va-bg-soft, #f5f7fa) !important;
  border-color: transparent;
}
