* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: #f0f2f6;
  color: #1f2937;
  -webkit-font-smoothing: antialiased;
}

.layout {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: 260px;
  background: #ffffff;
  color: #374151;
  padding: 20px 0 24px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid #eef0f4;
  box-shadow: 2px 0 12px rgba(0,0,0,0.03);
  transition: width 0.25s cubic-bezier(0.4,0,0.2,1), padding 0.25s cubic-bezier(0.4,0,0.2,1);
}

.layout.collapsed .sidebar {
  width: 72px;
  padding: 16px 0 20px;
}

.layout.collapsed .sidebar .logo {
  justify-content: center;
  padding: 0 0 18px;
}

.layout.collapsed .sidebar .logo-icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  font-size: 24px;
}

.layout.collapsed .sidebar .logo-text,
.layout.collapsed .sidebar .nav-text,
.layout.collapsed .sidebar .nav-section-title,
.layout.collapsed .sidebar .nav-sep {
  display: none;
}

.layout.collapsed .sidebar nav {
  padding: 0 10px;
  align-items: center;
}

.layout.collapsed .nav-item {
  width: 52px;
  height: 52px;
  padding: 0;
  justify-content: center;
  border-radius: 16px;
}

.layout.collapsed .nav-item .nav-icon {
  width: auto;
  font-size: 22px;
}

/* 图标栏 tooltip */
.layout.collapsed .nav-item {
  position: relative;
}

.layout.collapsed .nav-item::after {
  content: attr(data-title);
  position: absolute;
  left: 62px;
  top: 50%;
  transform: translateY(-50%) scale(0.92);
  background: #1f2937;
  color: #fff;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 0.18s;
  box-shadow: 0 4px 14px rgba(0,0,0,0.15);
  z-index: 40;
}

.layout.collapsed .nav-item::before {
  content: "";
  position: absolute;
  left: 52px;
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-right-color: #1f2937;
  opacity: 0;
  transition: all 0.18s;
  pointer-events: none;
  z-index: 40;
}

.layout.collapsed .nav-item:hover::after,
.layout.collapsed .nav-item:hover::before {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}

.sidebar .logo {
  color: #111827;
  font-size: 19px;
  font-weight: 800;
  padding: 0 18px 24px;
  letter-spacing: -0.3px;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar .logo-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #fff;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(59,130,246,0.25);
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0 14px;
}

.nav-item {
  color: #4b5563;
  text-decoration: none;
  padding: 13px 16px;
  font-size: 14.5px;
  font-weight: 500;
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.22s cubic-bezier(0.4,0,0.2,1);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  background: #fff;
  border: 1px solid transparent;
}

.nav-item:hover {
  background: #f3f6ff;
  color: #2563eb;
  border-color: #dbe4ff;
  transform: translateX(4px) scale(1.01);
  box-shadow: 0 4px 14px rgba(37,99,235,0.10);
}

.nav-item.active {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
  box-shadow: 0 2px 10px rgba(37,99,235,0.10);
  font-weight: 600;
}

.nav-item .nav-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
  transition: transform 0.22s;
}

.nav-item:hover .nav-icon { transform: scale(1.15); }

.nav-item .nav-text { flex: 1; }

.nav-sep {
  border-top: 1px solid #eef0f4;
  margin: 14px 6px 10px;
}

.nav-section-title {
  font-size: 11px;
  font-weight: 700;
  color: #9ca3af;
  text-transform: uppercase;
  padding: 0 14px 8px;
  letter-spacing: 0.8px;
  white-space: nowrap;
}

/* ---------- System tools tray（底部小按钮） ---------- */
.sys-tray {
  margin-top: auto;
  padding: 14px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid #eef0f4;
}

.sys-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 14px;
  color: #6b7280;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  background: #f8f9fc;
  border: 1px solid #eef0f4;
  transition: all 0.2s cubic-bezier(0.4,0,0.2,1);
  white-space: nowrap;
}

.sys-btn:hover {
  background: #eff6ff;
  color: #2563eb;
  border-color: #bfdbfe;
  transform: translateX(4px) scale(1.01);
  box-shadow: 0 4px 14px rgba(37,99,235,0.10);
}

.sys-btn .sys-icon { font-size: 18px; flex-shrink: 0; transition: transform 0.2s; }
.sys-btn:hover .sys-icon { transform: scale(1.15); }
.sys-btn .sys-text { flex: 1; }

/* collapsed：图标栏模式 */
.layout.collapsed .sys-tray {
  align-items: center;
  padding: 12px 0 16px;
  gap: 10px;
}

.layout.collapsed .sys-text { display: none; }

.layout.collapsed .sys-btn {
  width: 52px;
  height: 52px;
  padding: 0;
  justify-content: center;
  border-radius: 16px;
  position: relative;
}

.layout.collapsed .sys-btn::after {
  content: attr(data-title);
  position: absolute;
  left: 62px;
  top: 50%;
  transform: translateY(-50%) scale(0.92);
  background: #1f2937;
  color: #fff;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 0.18s;
  box-shadow: 0 4px 14px rgba(0,0,0,0.15);
  z-index: 40;
}

.layout.collapsed .sys-btn::before {
  content: "";
  position: absolute;
  left: 52px;
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-right-color: #1f2937;
  opacity: 0;
  transition: all 0.18s;
  pointer-events: none;
  z-index: 40;
}

.layout.collapsed .sys-btn:hover::after,
.layout.collapsed .sys-btn:hover::before {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}

/* ---------- Main ---------- */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #f8f9fc;
}

.topbar {
  height: 64px;
  background: #fff;
  border-bottom: 1px solid #eef0f4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 26px;
}

.topbar .crumb {
  font-weight: 700;
  font-size: 17px;
  color: #111827;
}

.topbar .user {
  font-size: 14px;
  color: #4b5563;
  background: #f3f4f6;
  padding: 7px 14px;
  border-radius: 20px;
}

.topbar .user a {
  color: #2563eb;
  text-decoration: none;
  margin-left: 8px;
  font-weight: 600;
}

.topbar .user a:hover { text-decoration: underline; }

/* ---------- Topbar quick links（各模块前后端快捷入口） ---------- */
.quick-links {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 6px;
}

.ql-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 13px;
  border-radius: 9px;
  background: #f3f4f6;
  color: #4b5563;
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
}

.ql-link:hover {
  background: #eff6ff;
  color: #2563eb;
  border-color: #bfdbfe;
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(37,99,235,0.10);
}

.ql-link.primary {
  background: #3b82f6;
  color: #fff;
  border-color: #3b82f6;
}

.ql-link.primary:hover {
  background: #2563eb;
  border-color: #2563eb;
}

.ql-icon { font-size: 13px; }

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 0;
}

.topbar-extra {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: #555;
  flex-shrink: 0;
}

.topbar-extra .btn {
  padding: 5px 12px;
  font-size: 12px;
}

.sidebar-toggle {
  width: 38px;
  height: 38px;
  border: 1px solid #e5e7eb;
  background: #fff;
  border-radius: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4b5563;
  transition: all 0.18s;
}

.sidebar-toggle svg { width: 20px; height: 20px; }
.sidebar-toggle:hover {
  background: #eff6ff;
  color: #2563eb;
  border-color: #bfdbfe;
  transform: scale(1.05);
}

/* 收起后浮动展开按钮（在图标栏右侧） */
.sidebar-expand {
  position: fixed;
  top: 74px;
  left: 82px;
  z-index: 30;
  width: 38px;
  height: 38px;
  border: 1px solid #e5e7eb;
  background: #fff;
  border-radius: 12px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  color: #2563eb;
  box-shadow: 0 4px 14px rgba(0,0,0,0.10);
  transition: all 0.18s;
}

.sidebar-expand svg { width: 20px; height: 20px; }
.sidebar-expand:hover {
  background: #eff6ff;
  border-color: #bfdbfe;
  transform: scale(1.08);
}

.layout.collapsed .sidebar-expand { display: flex; }

.content {
  padding: 26px;
  flex: 1;
  overflow: auto;
}

/* ---------- Cards / Panels ---------- */
.cards {
  display: flex;
  gap: 16px;
  margin-bottom: 22px;
}

.card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 20px 22px;
  flex: 1;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.card .num {
  font-size: 32px;
  font-weight: 700;
  color: #111827;
}

.card .lbl {
  color: #6b7280;
  font-size: 13px;
  margin-top: 5px;
}

.panel {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 22px 26px;
  max-width: 900px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.panel h2 { margin-top: 0; font-size: 18px; color: #111827; }
.panel h3 { margin-top: 0; font-size: 16px; color: #111827; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.mod-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 18px;
  display: flex;
  gap: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.mod-icon { font-size: 36px; }
.mod-body { flex: 1; }
.mod-body h3 { margin: 0 0 5px; font-size: 16px; color: #111827; }
.mod-body .ver { font-size: 12px; color: #6b7280; font-weight: 400; }
.mod-body .meta { font-size: 12px; color: #6b7280; margin-bottom: 10px; }
.mod-body p { font-size: 13px; color: #4b5563; margin: 6px 0 14px; line-height: 1.5; }

.mod-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  border: 1px solid #d1d5db;
  background: #fff;
  color: #374151;
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.12s;
}

.btn:hover {
  background: #f9fafb;
  border-color: #9ca3af;
}

.btn.primary {
  background: #3b82f6;
  border-color: #3b82f6;
  color: #fff;
}

.btn.primary:hover {
  background: #2563eb;
  border-color: #2563eb;
}

.btn.danger {
  color: #dc2626;
  border-color: #fecaca;
  background: #fff;
}

.btn.danger:hover {
  background: #fef2f2;
}

.badge {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 500;
}

.badge.ok { background: #d1fae5; color: #065f46; }
.badge.off { background: #f3f4f6; color: #6b7280; }

/* ---------- Login ---------- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f8f9fc 0%, #eef2ff 100%);
  min-height: 100vh;
}

.login-box {
  background: #fff;
  width: 380px;
  padding: 40px;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.10);
  border: 1px solid #eef0f4;
}

.login-box h1 { margin: 0 0 6px; font-size: 22px; }
.login-logo { display: flex; align-items: center; justify-content: center; gap: 10px; }
.login-box .sub { color: #6b7280; margin: 0 0 22px; font-size: 14px; }
.login-box input {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 14px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  font-size: 14px;
}
.login-box input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
.login-box button {
  width: 100%;
  padding: 12px;
  background: #3b82f6;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}
.login-box button:hover { background: #2563eb; }
.login-box .hint { color: #9ca3af; font-size: 12px; text-align: center; margin-top: 14px; }

.alert { background: #fee2e2; color: #991b1b; padding: 10px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; }
code { background: #eef2ff; color: #4338ca; padding: 2px 7px; border-radius: 6px; font-size: 13px; }

/* ---------- Accounts page ---------- */
.hint { color: #6b7280; font-size: 13px; margin: 6px 0 16px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row input { padding: 9px 12px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 14px; }
.sub-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.mod-assign { border-top: 1px dashed #e5e7eb; padding-top: 16px; }
.chips { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #d1d5db;
  border-radius: 20px;
  padding: 6px 13px;
  font-size: 13px;
  cursor: pointer;
  background: #fff;
  transition: all 0.12s;
}
.chip input { margin: 0; }
.chip:has(input:checked) { border-color: #3b82f6; background: #eff6ff; color: #1d4ed8; }
