* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #B45F06;
  --primary-dark: #964E0A;
  --primary-light: #FDF5EC;
  --primary-50: #FDF5EC;
  --primary-100: #F8E5D0;
  --primary-200: #EFC9A0;
  --text: #2A211B;
  --text-secondary: #7D6F63;
  --text-muted: #A89F97;
  --bg: #FBF9F6;
  --bg-white: #FFFFFF;
  --border: #E8E2DA;
  --border-light: #F2EEE9;
  --success: #16A34A;
  --success-bg: #DCFCE7;
  --warning: #D97706;
  --warning-bg: #FEF3C7;
  --error: #DC2626;
  --error-bg: #FEE2E2;
  --info: #2563EB;
  --info-bg: #DBEAFE;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(42,33,27,0.05);
  --shadow: 0 2px 8px rgba(42,33,27,0.08);
  --shadow-lg: 0 8px 32px rgba(42,33,27,0.12);
  --sidebar-width: 220px;
  --sidebar-collapsed-width: 64px;
  --topbar-height: 60px;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}
#app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: width 0.25s ease;
  overflow: hidden;
}
#app.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed-width);
}
.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  transition: padding 0.25s ease;
  white-space: nowrap;
}
#app.sidebar-collapsed .logo-area {
  padding: 16px 12px;
  justify-content: center;
}
.logo {
  width: 36px;
  height: 36px;
  background: var(--primary);
  color: white;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  flex-shrink: 0;
}
.logo-title { font-size: 16px; font-weight: 600; }
.logo-sub { font-size: 12px; color: var(--text-muted); }
#app.sidebar-collapsed .logo-text {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.menu {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
  overflow-x: hidden;
}
.menu::-webkit-scrollbar { width: 4px; }
.menu::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Drawer groups */
.menu-drawer {
  border-bottom: 1px solid rgba(0,0,0,0.03);
}
.drawer-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
  white-space: nowrap;
}
.drawer-header:hover { background: var(--primary-50); }
.drawer-icon { font-size: 16px; flex-shrink: 0; }
.drawer-title {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  transition: opacity 0.2s;
}
.drawer-arrow {
  font-size: 10px;
  color: var(--text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.menu-drawer.open .drawer-arrow {
  transform: rotate(0deg);
}
.menu-drawer:not(.open) .drawer-arrow {
  transform: rotate(-90deg);
}
.drawer-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.menu-drawer.open .drawer-body {
  max-height: 500px;
}

/* Collapsed sidebar - icon only mode */
#app.sidebar-collapsed .drawer-title,
#app.sidebar-collapsed .drawer-arrow,
#app.sidebar-collapsed .menu-item span:not(.icon) {
  display: none;
}
#app.sidebar-collapsed .drawer-header {
  padding: 12px 0;
  justify-content: center;
  cursor: pointer;
}
#app.sidebar-collapsed .drawer-header .drawer-icon {
  margin: 0 auto;
  text-align: center;
  font-size: 18px;
}
#app.sidebar-collapsed .menu-item {
  padding: 10px 0;
  justify-content: center;
  border-left: 3px solid transparent;
}
#app.sidebar-collapsed .menu-item.active {
  border-left-color: var(--primary);
}
#app.sidebar-collapsed .drawer-body {
  display: none;
}

/* 折叠态弹出子菜单浮层 */
.collapsed-popup {
  position: fixed;
  left: calc(var(--sidebar-collapsed-width) + 4px);
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.14);
  min-width: 180px;
  max-width: 240px;
  padding: 6px;
  z-index: 1000;
  animation: popupIn 0.15s ease-out;
}
@keyframes popupIn {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}
.collapsed-popup .popup-title {
  padding: 10px 14px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.collapsed-popup .popup-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  transition: all 0.12s;
}
.collapsed-popup .popup-item:hover {
  background: var(--primary-50);
  color: var(--primary);
}
.collapsed-popup .popup-item.active {
  background: var(--primary-50);
  color: var(--primary);
  font-weight: 500;
}
.collapsed-popup .popup-item .icon { font-size: 15px; }

/* Menu items inside drawers */
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px 8px 48px;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all 0.15s;
  font-size: 13px;
  white-space: nowrap;
}
.menu-item:hover { background: var(--primary-50); }
.menu-item.active {
  background: var(--primary-50);
  border-left-color: var(--primary);
  color: var(--primary);
  font-weight: 500;
}
.menu-item .icon { font-size: 15px; }

/* Sidebar footer collapse button */
.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 12px;
  display: flex;
  justify-content: center;
}
.sidebar-collapse-btn {
  width: 100%;
  padding: 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.sidebar-collapse-btn:hover {
  background: var(--primary-50);
  color: var(--primary);
  border-color: var(--primary);
}
.collapse-icon {
  font-size: 14px;
  transition: transform 0.25s;
}
#app.sidebar-collapsed .collapse-icon {
  transform: rotate(180deg);
}
#app.sidebar-collapsed .sidebar-collapse-btn {
  display: none;
}

/* Topbar collapse button */
.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar-collapse-btn {
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.topbar-collapse-btn:hover {
  background: var(--primary-50);
  color: var(--primary);
  border-color: var(--primary);
}

.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: margin-left 0.25s ease;
}
#app.sidebar-collapsed .main {
  margin-left: var(--sidebar-collapsed-width);
}
.topbar {
  height: var(--topbar-height);
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 90;
}
.breadcrumb { font-size: 16px; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.admin-info { display: flex; align-items: center; gap: 10px; }
.admin-avatar {
  width: 36px; height: 36px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
}
.admin-name { font-weight: 500; }
.btn-logout {
  padding: 6px 14px;
  background: var(--border-light);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}
.btn-logout:hover { background: var(--border); }
.content { flex: 1; padding: 24px; }

.card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.card-title { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}
.stat-label { font-size: 13px; color: var(--text-secondary); }
.stat-change { font-size: 12px; margin-top: 8px; }
.stat-up { color: var(--success); }
.stat-down { color: var(--error); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--bg-white); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--border-light); }
.btn-danger { background: var(--error); color: white; }
.btn-danger:hover { opacity: 0.9; }
.btn-sm { padding: 4px 12px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }

/* ===== 通用：操作列固定右侧 + 不换行 ===== */
/* 1. 任何 table 的最后一个带 .col-actions 的 th/td 自动 sticky 到右侧 */
th.col-actions, td.col-actions {
  position: sticky;
  right: 0;
  z-index: 2;
  background: var(--bg-white);
  box-shadow: -6px 0 8px -6px rgba(0, 0, 0, 0.12);
  white-space: nowrap;
}
thead th.col-actions { background: var(--bg); z-index: 3; }
tbody tr:hover td.col-actions { background: var(--primary-50); }
tbody td.col-actions { background: var(--bg-white); }
/* 2. 操作列里的按钮不换行 + 紧凑间距 */
.col-actions .btn { white-space: nowrap; flex-shrink: 0; margin: 2px 4px 2px 0; padding: 4px 10px; font-size: 12px; }
.col-actions .btn-sm { padding: 3px 8px; font-size: 11px; }
/* 3. 兼容旧 .sticky-col（只 sticky，nowrap 统一用 .col-actions）*/
.sticky-col { position: sticky; right: 0; z-index: 2; background: var(--bg-white); box-shadow: -6px 0 8px -6px rgba(0,0,0,0.12); }
thead .sticky-col { background: var(--bg); z-index: 3; }
th {
  text-align: left;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  font-size: 14px;
}
tr:hover td { background: var(--primary-50); }
tr:last-child td { border-bottom: none; }

.tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}
.tag-success { background: var(--success-bg); color: var(--success); }
.tag-warning { background: var(--warning-bg); color: var(--warning); }
.tag-error { background: var(--error-bg); color: var(--error); }
.tag-info { background: var(--info-bg); color: var(--info); }
.tag-default { background: var(--border-light); color: var(--text-secondary); }
.tag-primary { background: var(--primary-50); color: var(--primary); }

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  align-items: flex-end;
}
.filter-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.filter-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}
.filter-bar input,
.filter-bar select {
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--bg-white);
  color: var(--text);
}
.filter-bar input:focus,
.filter-bar select:focus { outline: none; border-color: var(--primary); }

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
}
.pagination-info { font-size: 13px; color: var(--text-secondary); }
.pagination-controls { display: flex; gap: 4px; }
.page-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  background: var(--bg-white);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
}
.page-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.page-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 1100px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.modal.modal-sm { max-width: 480px !important; }
.modal.modal-lg { max-width: 1100px !important; }
.modal.modal-xl { max-width: 1480px !important; }
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: none; cursor: pointer;
  font-size: 20px; color: var(--text-secondary);
}
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}
.form-label .required { color: var(--error); }
.form-control {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--bg-white);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-50); }
.form-control textarea { height: auto; min-height: 100px; padding: 8px 12px; resize: vertical; }
.form-textarea { min-height: 80px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; resize: vertical; line-height: 1.5; width: 100%; }

.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 24px;
  border-radius: var(--radius);
  background: var(--text);
  color: white;
  font-size: 14px;
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.toast.show { opacity: 1; }
.toast.success { background: var(--success); }
.toast.error { background: var(--error); }
.toast.warning { background: var(--warning); }

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}
.login-box {
  background: white;
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 360px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  width: 56px; height: 56px;
  background: var(--primary);
  color: white;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 700;
  margin: 0 auto 16px;
}
.login-title { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 4px; }
.login-subtitle { color: var(--text-secondary); text-align: center; margin-bottom: 32px; }
.login-form .form-group { margin-bottom: 16px; }
.login-form .form-control { height: 44px; }
.login-btn { width: 100%; height: 44px; font-size: 15px; box-sizing: border-box; padding: 0; display: flex; justify-content: center; align-items: center; }

.placeholder-chart {
  height: 280px;
  background: linear-gradient(135deg, var(--primary-50), var(--bg));
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 13px;
}

.quick-actions { display: flex; gap: 8px; }

/* Action icon buttons */
.action-icons {
  display: flex;
  gap: 4px;
  white-space: nowrap;
}
.action-icon-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  background: var(--bg-white);
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.15s ease;
}
.action-icon-btn:hover {
  border-color: var(--primary);
  background: var(--primary-50);
  transform: translateY(-1px);
}
.action-icon-btn.action-icon-danger:hover {
  border-color: var(--error);
  background: #FEF2F2;
}
.action-icon {
  font-size: 14px;
  line-height: 1;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== 菜单权限：树形 checkbox（角色分配弹窗）===== */
.perm-tree-node { }
.perm-tree-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  transition: background 0.15s;
}
.perm-tree-label:hover { background: rgba(180, 95, 6, 0.08); }
.perm-tree-label input[type="checkbox"] {
  width: 14px; height: 14px;
  accent-color: var(--primary);
  flex-shrink: 0;
}
.perm-tree-icon { font-size: 14px; flex-shrink: 0; }
.perm-tree-name { font-weight: 500; }
.perm-tree-children { padding-left: 4px; }
.perm-tree-toggle {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 11px;
  padding: 0 4px;
}

/* ===== 菜单权限管理页面树形 ===== */
.perm-admin-tree { }
.perm-admin-node { }
.perm-admin-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  font-size: 14px;
  transition: background 0.15s;
}
.perm-admin-row:hover { background: var(--primary-50); }
.perm-admin-toggle {
  color: var(--text-muted);
  font-size: 11px;
  width: 16px;
  text-align: center;
}
.perm-admin-name { font-weight: 500; }
.perm-admin-children {
  background: rgba(180, 95, 6, 0.02);
  border-left: 2px dashed var(--border);
  margin-left: 12px;
}

/* ===== 数据字典页面 ===== */
.dicts-layout { display: grid; grid-template-columns: 320px 1fr; gap: 16px; }
.dicts-left { display: flex; flex-direction: column; min-height: 0; }
.dicts-left .card-body { flex: 1; overflow-y: auto; padding: 0; max-height: calc(100vh - 200px); }
.dict-type-list { padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.dict-type-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; border-radius: 6px; cursor: pointer;
  transition: background 0.15s;
}
.dict-type-item:hover { background: var(--bg-hover, rgba(0,0,0,0.04)); }
.dict-type-item.active { background: var(--primary-bg, rgba(52,152,219,0.12)); }
.dict-type-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dict-type-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dict-type-code { font-size: 11px; color: var(--text-muted, #888); }
.dict-type-code code { background: transparent; padding: 0; }
.dict-type-meta { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.dict-count { font-size: 12px; color: var(--text-muted, #888); background: var(--bg-secondary, #f5f5f5); padding: 2px 8px; border-radius: 10px; }
.dict-edit { cursor: pointer; opacity: 0; font-size: 13px; padding: 2px 4px; border-radius: 4px; transition: opacity 0.15s; }
.dict-type-item:hover .dict-edit { opacity: 1; }
.dict-edit:hover { background: var(--bg-hover, rgba(0,0,0,0.08)); }
.dicts-right .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 800px) { .dicts-layout { grid-template-columns: 1fr; } }
