/* ═══════════════════════════════════════════════════════════════
   管理后台样式
   ═══════════════════════════════════════════════════════════════ */
*{margin:0;padding:0;box-sizing:border-box}
body{
  font-family:'Microsoft YaHei','PingFang SC',sans-serif;
  background:#f0f2f5;
  color:#333;
  overflow-x:hidden;
  min-height:100vh;
}

/* ═══════════════════════════════════════════════════════════════
   Header（只占右侧，永远浅色，不跟随主题）
   ═══════════════════════════════════════════════════════════════ */
.header{
  position:fixed;
  top:0;
  left:220px;
  right:0;
  height:56px;
  background:#ffffff;
  border-bottom:1px solid #e6eaf2;
  box-shadow:0 1px 4px rgba(0,0,0,.04);
  display:flex;
  align-items:center;
  padding:0 20px;
  z-index:100;
  gap:16px;
  transition:left .3s ease;
}

.header-toggle{
  background:#f4f7fb;
  border:0;
  color:#5a6478;
  width:36px;height:36px;
  border-radius:8px;
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  transition:.2s;
  flex-shrink:0;
}
.header-toggle svg{width:20px;height:20px;display:block}
.header-toggle:hover{background:#e8eef9;color:#1a3c6e}
.header-toggle:active{transform:scale(.96)}

.header-logo-icon{font-size:20px;display:none}

.header-spacer{flex:1;min-width:0}

.header-link{
  display:inline-flex;
  align-items:center;
  gap:5px;
  padding:7px 12px;
  border-radius:8px;
  font-size:12px;
  color:#5a6478;
  text-decoration:none;
  cursor:pointer;
  transition:.2s;
  white-space:nowrap;
  flex-shrink:0;
}
.header-link svg{width:16px;height:16px;flex-shrink:0;display:block}
.header-link:hover{background:#e8f0fe;color:#1a3c6e}

.header-user{display:flex;align-items:center;gap:4px;flex-shrink:0}
.header-user .user-name{
  font-size:13px;
  font-weight:600;
  color:#1a3c6e;
  padding:6px 12px;
  background:#f4f7fb;
  border-radius:8px;
  margin-right:6px;
  white-space:nowrap;
  max-width:160px;
  overflow:hidden;
  text-overflow:ellipsis;
}

/* ═══════════════════════════════════════════════════════════════
   侧边栏（顶到底，含 Logo）
   ═══════════════════════════════════════════════════════════════ */
.sidebar{
  width:220px;
  background:#ffffff;
  color:#333;
  position:fixed;
  left:0;
  top:0;
  bottom:0;
  z-index:200;
  border-right:1px solid #e6eaf2;
  box-shadow:2px 0 8px rgba(0,0,0,.02);
  transition:width .3s ease;
  display:flex;
  flex-direction:column;
}
.sidebar.collapsed{width:56px}

/* Logo 区 */
.sidebar-logo{
  height:56px;
  display:flex;
  align-items:center;
  gap:8px;
  padding:0 16px;
  border-bottom:1px solid #eef1f6;
  flex-shrink:0;
  overflow:hidden;
}
.sidebar-logo-img{
  width:30px;height:30px;
  object-fit:contain;
  flex-shrink:0;display:block;
}
.sidebar-logo-icon{font-size:20px;flex-shrink:0}
.sidebar-logo-text{
  font-size:20px;font-weight:700;color:#1a3c6e;
  letter-spacing:.5px;white-space:nowrap;
  overflow:hidden;text-overflow:ellipsis;
}
.sidebar.collapsed .sidebar-logo{justify-content:center;padding:0}
.sidebar.collapsed .sidebar-logo-text{display:none}

.sidebar .nav{flex:1;padding:10px 0;overflow-y:auto}
.sidebar .nav::-webkit-scrollbar{width:6px}
.sidebar .nav::-webkit-scrollbar-thumb{background:#d0d8e8;border-radius:3px}
.sidebar .nav::-webkit-scrollbar-track{background:transparent}

.sidebar .nav-group-title{
  padding:14px 20px 6px;
  font-size:11px;
  color:#9aa3b2;
  font-weight:700;
  letter-spacing:1px;
  text-transform:uppercase;
}
.sidebar.collapsed .nav-group-title{display:none}

.sidebar .nav-item{
  padding:13px 18px;
  cursor:pointer;
  display:flex;
  align-items:center;
  gap:10px;
  font-size:14px;
  color:#5a6478;
  transition:.2s;
  border-left:3px solid transparent;
  user-select:none;
  overflow:hidden;
  white-space:nowrap;
}
.sidebar.collapsed .nav-item{padding:13px 0;justify-content:center;gap:0}
.sidebar.collapsed .nav-item .nav-text{display:none}

.sidebar .nav-item:hover{background:#f4f7fb;color:#1a3c6e}
.sidebar .nav-item.active{
  background:#e8f0fe;
  color:#1a3c6e;
  border-left-color:#1a3c6e;
  font-weight:600;
}

/* SVG 图标 */
.sidebar .nav-svg{
  width:20px;
  height:20px;
  flex-shrink:0;
  color:#8892a5;
  transition:color .2s;
}
.sidebar .nav-item:hover .nav-svg{color:#1a3c6e}
.sidebar .nav-item.active .nav-svg{color:#1a3c6e}
.sidebar.collapsed .nav-item .nav-svg{margin:0 auto}

/* 兼容 emoji 图标（如果某个菜单没配 SVG） */
.sidebar .nav-item .nav-ic{
  font-size:18px;
  width:24px;
  text-align:center;
  flex-shrink:0;
}

.sidebar .nav-empty{
  padding:24px 20px;
  font-size:12px;
  color:#9aa3b2;
  text-align:center;
  line-height:1.8;
}
.sidebar.collapsed .nav-empty{display:none}

/* ═══════════════════════════════════════════════════════════════
   主内容区
   ═══════════════════════════════════════════════════════════════ */
.main{
  margin-left:220px;
  margin-top:56px;
  padding:24px 28px 80px;
  min-height:calc(100vh - 56px);
  max-width:calc(100% - 220px);
  transition:margin-left .3s ease,max-width .3s ease;
  min-width:0;
  overflow-x:hidden;
}
.main.expanded{margin-left:56px;max-width:calc(100% - 56px)}

/* 折叠时 header 跟随 */
.sidebar.collapsed ~ .header{left:56px}
.sidebar.collapsed ~ .main{margin-left:56px;max-width:calc(100% - 56px)}

.page-header{margin-bottom:20px}
.page-header h2 {
  display: flex;
  align-items: center;
  gap: 8px;
}
.page-header h2 .page-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: #1a3c6e;
  display: block;
}
.page-header .desc{font-size:12px;color:#999;margin-top:4px}

.card{
  background:#fff;
  border-radius:12px;
  box-shadow:0 2px 12px rgba(0,0,0,.06);
  padding:22px 26px;
  margin-bottom:20px;
  min-width:0;
  max-width:100%;
  overflow:hidden;
}
.card-toolbar{
  display:flex;
  gap:10px;
  align-items:center;
  margin-bottom:16px;
  flex-wrap:wrap;
}
.card-toolbar .spacer{margin-left:auto}

/* 按钮 */
.btn{
  padding:9px 18px;
  border:0;
  border-radius:8px;
  font-size:13px;
  font-weight:600;
  cursor:pointer;
  transition:.25s;
  display:inline-flex;
  align-items:center;
  gap:5px;
  white-space:nowrap;
}
.btn-pri{background:linear-gradient(135deg,#1a3c6e,#4a7fd0);color:#fff;box-shadow:0 3px 10px rgba(26,60,110,.25)}
.btn-pri:hover{transform:translateY(-1px)}
.btn-suc{background:linear-gradient(135deg,#1d8a4f,#34c774);color:#fff}
.btn-suc:hover{transform:translateY(-1px)}
.btn-danger{background:#ffe0e0;color:#d33}
.btn-danger:hover{background:#ffd0d0}
.btn-grey{background:#f0f2f5;color:#666}
.btn-grey:hover{background:#e4e7eb}
.btn-sm{padding:5px 12px;font-size:12px;white-space:nowrap}
.btn:disabled{opacity:.55;cursor:not-allowed;transform:none!important}

/* 表格 */
.tbl-wrap{
  overflow-x:auto;
  border:1px solid #eef1f6;
  border-radius:8px;
  max-width:100%;
}
table{
  width:100%;
  border-collapse:collapse;
  font-size:13px;
  table-layout:auto;
}
thead th{
  background:#1a3c6e;
  color:#fff;
  padding:11px 10px;
  text-align:left;
  font-size:12px;
  font-weight:600;
  white-space:nowrap;
}
tbody td{
  padding:10px;
  border-bottom:1px solid #eef1f6;
  color:#444;
  vertical-align:middle;
}
tbody tr:last-child td{border-bottom:0}
tbody tr:hover{background:#f8fafd}
.cell-actions{white-space:nowrap}
.cell-actions .btn{margin-right:4px}
.empty{text-align:center;padding:40px;color:#bbb;font-size:13px}

/* 徽章 */
.badge{
  display:inline-block;
  padding:2px 8px;
  border-radius:10px;
  font-size:11px;
  font-weight:600;
}
.badge-green{background:#d4f5e9;color:#1d8a4f}
.badge-red{background:#ffe0e0;color:#d33}
.badge-blue{background:#e8f0fe;color:#1a3c6e}
.badge-grey{background:#f0f2f5;color:#999}
.badge-orange{background:#fff3e0;color:#c07000}

/* 模态框 */
.modal-mask{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.4);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index:1000;
  padding:20px;
}
.modal-box{
  width:520px;
  max-width:100%;
  max-height:90vh;
  background:#fff;
  border-radius:12px;
  box-shadow:0 12px 40px rgba(0,0,0,.25);
  display:flex;
  flex-direction:column;
  overflow:hidden;
}
.modal-header{
  padding:18px 22px;
  border-bottom:1px solid #eef1f6;
  display:flex;
  justify-content:space-between;
  align-items:center;
}
.modal-header>span:first-child{font-size:15px;font-weight:700;color:#1a3c6e}
.modal-close{
  font-size:24px;
  color:#999;
  cursor:pointer;
  line-height:1;
  padding:0 4px;
  transition:.2s;
}
.modal-close:hover{color:#333}
.modal-body{padding:22px;overflow-y:auto;flex:1}
.modal-footer{
  padding:14px 22px;
  border-top:1px solid #eef1f6;
  display:flex;
  justify-content:flex-end;
  gap:10px;
  background:#fafbfd;
}

/* 表单 */
.form-row{margin-bottom:16px}
.form-row label{
  display:block;
  font-size:12px;
  color:#555;
  font-weight:600;
  margin-bottom:6px;
}
.form-row label .req{color:#d33;margin-left:2px}
.form-row input[type=text],
.form-row input[type=password],
.form-row input[type=email],
.form-row input[type=number],
.form-row select,
.form-row textarea{
  width:100%;
  padding:9px 12px;
  border:1px solid #d0d8e8;
  border-radius:8px;
  font-size:13px;
  outline:0;
  background:#fafbfd;
  font-family:inherit;
  transition:.2s;
}
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus{
  border-color:#4a7fd0;
  box-shadow:0 0 0 3px rgba(74,127,208,.12);
}
.form-row .hint{font-size:11px;color:#999;margin-top:4px}
.form-row .checkbox-row{
  display:flex;
  align-items:center;
  gap:8px;
  font-size:13px;
  color:#333;
  cursor:pointer;
}
.form-row .checkbox-row input{width:auto;cursor:pointer}

/* 多选列表 */
.checkbox-list{
  max-height:280px;
  overflow-y:auto;
  border:1px solid #eef1f6;
  border-radius:8px;
  padding:12px;
  background:#fafbfd;
}
.checkbox-list .group-title{
  font-size:11px;
  color:#888;
  font-weight:700;
  padding:6px 4px;
  letter-spacing:.5px;
  text-transform:uppercase;
}
.checkbox-item{
  display:flex;
  align-items:center;
  gap:8px;
  padding:6px 4px;
  font-size:13px;
  cursor:pointer;
  border-radius:4px;
}
.checkbox-item:hover{background:#eef4ff}
.checkbox-item input{cursor:pointer}

/* Toast */
.toast{
  position:fixed;
  top:20px;
  left:50%;
  transform:translateX(-50%) translateY(-60px);
  padding:11px 26px;
  border-radius:8px;
  font-size:13px;
  color:#fff;
  box-shadow:0 4px 14px rgba(0,0,0,.2);
  transition:.3s;
  z-index:9999;
  opacity:0;
  pointer-events:none;
}
.toast.show{transform:translateX(-50%) translateY(0);opacity:1}
.toast.ok{background:#1d8a4f}
.toast.err{background:#d33}
.toast.warn{background:#e8910c}

/* 日志筛选 */
.filter-bar{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:flex-end;
  margin-bottom:14px;
}
.filter-bar .fi{min-width:140px}
.filter-bar label{
  font-size:11px;
  color:#666;
  font-weight:600;
  display:block;
  margin-bottom:4px;
}
.filter-bar input,.filter-bar select{
  padding:7px 10px;
  border:1px solid #d0d8e8;
  border-radius:6px;
  font-size:12px;
  outline:0;
  background:#fafbfd;
}

/* 分页 */
.pagination{
  display:flex;
  gap:6px;
  align-items:center;
  justify-content:center;
  margin-top:14px;
  font-size:12px;
  color:#666;
}
.pagination button{
  padding:5px 10px;
  border:1px solid #d0d8e8;
  border-radius:5px;
  background:#fff;
  cursor:pointer;
  font-size:12px;
}
.pagination button:hover:not(:disabled){background:#eef4ff}
.pagination button:disabled{opacity:.4;cursor:not-allowed}

/* ═══════════════════════════════════════════════════════════════
   深色主题（只影响侧边栏，Header 永远浅色）
   ═══════════════════════════════════════════════════════════════ */
.sidebar.theme-dark{
  background:#0f172a;
  color:#fff;
  border-right:0;
  box-shadow:3px 0 12px rgba(0,0,0,.25);
}
.sidebar.theme-dark .sidebar-logo{
  border-bottom-color:rgba(255,255,255,.08);
}
.sidebar.theme-dark .sidebar-logo-text{color:#fff}
.sidebar.theme-dark .sidebar-logo-img{filter:brightness(0) invert(1)}

.sidebar.theme-dark .nav::-webkit-scrollbar-thumb{
  background:rgba(255,255,255,.15);
}
.sidebar.theme-dark .nav-group-title{color:#64748b}

.sidebar.theme-dark .nav-item{color:#94a3b8}
.sidebar.theme-dark .nav-item:hover{
  background:rgba(30,41,59,.6);
  color:#fff;
}
.sidebar.theme-dark .nav-item:hover .nav-svg{color:#fff}
.sidebar.theme-dark .nav-item.active{
  background:linear-gradient(90deg,rgba(37,99,235,.18) 0%,transparent 100%);
  color:#fff;
  border-left-color:#3b82f6;
  font-weight:500;
}
.sidebar.theme-dark .nav-item.active .nav-svg{color:#3b82f6}

.sidebar.theme-dark .nav-empty{color:rgba(255,255,255,.5)}

/* ═══════════════════════════════════════════════════════════════
   响应式
   ═══════════════════════════════════════════════════════════════ */
@media(max-width:900px){
  .header-link span{display:none}
  .header-link{padding:7px 10px}
  .header-user .user-name{max-width:80px;padding:6px 8px;font-size:12px}
}
@media(max-width:640px){
  .header{padding:0 12px;gap:10px;left:56px}
  .header-toggle{width:32px;height:32px}
  .main{padding:16px 14px 60px;margin-left:56px;max-width:calc(100% - 56px)}
  .card{padding:16px 14px;border-radius:8px}
  .modal-box{width:100%}
  .sidebar{width:56px}
  .sidebar .sidebar-logo{justify-content:center;padding:0}
  .sidebar .sidebar-logo-text{display:none}
}

/* 抽屉 */
.drawer-mask{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.4);
  z-index:1000;
  opacity:0;
  visibility:hidden;
  transition:opacity .25s;
}
.drawer-mask.show{opacity:1;visibility:visible}
.drawer{
  position:fixed;
  top:0;right:0;bottom:0;
  width:60%;
  min-width:520px;
  max-width:1100px;
  background:#fff;
  box-shadow:-4px 0 20px rgba(0,0,0,.15);
  z-index:1001;
  transform:translateX(100%);
  transition:transform .3s cubic-bezier(.4,0,.2,1);
  display:flex;
  flex-direction:column;
}
.drawer-mask.show .drawer{transform:translateX(0)}
.drawer-header{
  padding:16px 24px;
  border-bottom:1px solid #eef1f6;
  display:flex;
  align-items:center;
  justify-content:space-between;
  flex-shrink:0;
}
.drawer-header .title{
  font-size:16px;
  font-weight:700;
  color:#1a3c6e;
  display:flex;
  align-items:center;
  gap:8px;
}
.drawer-header .close{
  font-size:24px;
  color:#999;
  cursor:pointer;
  line-height:1;
  transition:color .15s;
}
.drawer-header .close:hover{color:#333}
.drawer-body{flex:1;overflow-y:auto;padding:20px 24px}
@media(max-width:768px){
  .drawer{width:100%;min-width:0;max-width:none}
}

/* Tab */
.tabs{
  display:flex;
  gap:4px;
  border-bottom:1px solid #eef1f6;
  margin-bottom:14px;
}
.tabs .tab{
  padding:10px 18px;
  font-size:13px;
  color:#666;
  cursor:pointer;
  border-bottom:2px solid transparent;
  transition:.2s;
  user-select:none;
}
.tabs .tab:hover{color:#1a3c6e}
.tabs .tab.active{
  color:#1a3c6e;
  font-weight:600;
  border-bottom-color:#1a3c6e;
}