:root {
  --bg: #0b1220;
  --card: rgba(255, 255, 255, 0.06);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.65);
  --primary: #4f7cff;
  --radius: 14px;
  --sidebar-w: 200px;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", Arial, sans-serif; color: var(--text); background: var(--bg); }
.admin-page { min-height: 100vh; }

.admin-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: rgba(15, 23, 42, 0.98);
  border-right: 1px solid rgba(255,255,255,.08);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform .25s ease, width .25s ease, box-shadow .25s ease;
}
.admin-layout.sidebar-hidden .sidebar {
  transform: translateX(-100%);
  width: 0;
  min-width: 0;
  overflow: hidden;
  border-right: none;
  box-shadow: none;
}
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99;
  background: rgba(0,0,0,.5);
  opacity: 0;
  transition: opacity .25s ease;
}
.admin-layout.sidebar-open-mobile .sidebar-overlay {
  display: block;
  opacity: 1;
}
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    box-shadow: 4px 0 20px rgba(0,0,0,.3);
  }
  .admin-layout.sidebar-hidden .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
  }
}
.sidebar-header {
  padding: 16px;
  font-weight: 800;
  font-size: 15px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  color: var(--muted);
  text-decoration: none;
  transition: all .2s;
  border-left: 3px solid transparent;
}
.nav-item:hover { color: var(--text); background: rgba(255,255,255,.05); }
.nav-item.active { color: var(--primary); background: rgba(79,124,255,.12); border-left-color: var(--primary); }
.nav-icon { font-size: 18px; }
.nav-text { font-size: 14px; font-weight: 600; }
.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.btn-block { width: 100%; }

.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  padding: 12px 20px;
  background: rgba(2, 6, 23, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-toggle {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 8px;
  background: rgba(255,255,255,.06);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .2s, border-color .2s;
}
.sidebar-toggle:hover {
  background: rgba(255,255,255,.12);
  border-color: rgba(255,255,255,.25);
}
.topbar-title { font-weight: 800; font-size: 16px; flex: 1; }
.topbar-user { display: flex; align-items: center; gap: 10px; }

.panel { display: none; padding: 20px; overflow-y: auto; }
.panel.active { display: block; }

.card { padding: 16px; background: var(--card); border: 1px solid rgba(255,255,255,.08); border-radius: var(--radius); margin-bottom: 16px; }
.h1 { font-size: 20px; font-weight: 900; margin: 0 0 10px; }
.h2 { font-size: 16px; font-weight: 900; margin: 0 0 10px; }
.h3 { font-size: 14px; font-weight: 900; margin: 0 0 8px; }
.desc { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.label { font-size: 13px; color: var(--muted); margin: 10px 0 6px; }
.alert { padding: 10px 12px; border-radius: 12px; border: 1px solid rgba(255, 91, 91, .35); background: rgba(255, 91, 91, .12); }
.row { display:flex; gap: 10px; align-items:center; flex-wrap: wrap; }
.col { flex: 1; min-width: 260px; }
.input, .textarea { width: 100%; border-radius: 12px; padding: 10px 12px; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.06); color: var(--text); outline: none; }
.input.short { max-width: 160px; }
.qn-stats-link-input {
  background: #f8f9fa !important;
  color: #1a1d29 !important;
  font-size: 15px !important;
  font-weight: 500 !important;
  padding: 12px 16px !important;
  border: 2px solid #e2e8f0 !important;
  cursor: text !important;
}
.qn-stats-link-input:focus {
  border-color: var(--primary) !important;
  background: #ffffff !important;
}
.textarea { resize: vertical; }
.btn { appearance: none; border: 0; border-radius: 999px; padding: 10px 12px; font-weight: 800; cursor:pointer; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-ghost { background: rgba(255,255,255,.08); color: var(--text); border: 1px solid rgba(255,255,255,.12); }
.preview { margin-top: 10px; height: 120px; border-radius: 12px; background: rgba(0,0,0,.18) center/contain no-repeat; border: 1px dashed rgba(255,255,255,.18); cursor: pointer; }
.preview:hover { border-color: rgba(79,124,255,.5); }

.image-preview-modal { position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center; padding: 20px; }
.image-preview-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.85); cursor: pointer; }
.image-preview-content { position: relative; max-width: 95vw; max-height: 95vh; display: flex; align-items: center; justify-content: center; }
.image-preview-img { max-width: 100%; max-height: 95vh; object-fit: contain; border-radius: 8px; }
.image-preview-close { position: absolute; top: -40px; right: 0; width: 36px; height: 36px; border: 0; border-radius: 50%; background: rgba(255,255,255,.2); color: #fff; font-size: 24px; line-height: 1; cursor: pointer; }
.image-preview-close:hover { background: rgba(255,255,255,.35); }
.list { display:flex; flex-direction: column; gap: 8px; }
.item { padding: 10px 12px; border-radius: 12px; background: rgba(0,0,0,.16); border: 1px solid rgba(255,255,255,.06); cursor:pointer; }
.item.active { border-color: rgba(79,124,255,.6); }
.msg { margin-top: 10px; min-height: 18px; font-size: 13px; color: var(--muted); }
.hidden { display:none; }
.hr { border: 0; border-top: 1px solid rgba(255,255,255,.08); margin: 12px 0; }

/* Dashboard */
.dashboard-grid { display: grid; gap: 16px; }
.stat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.stat-card-item {
  padding: 16px;
  background: var(--card);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius);
}
.stat-card-value { font-size: 28px; font-weight: 800; color: var(--primary); font-variant-numeric: tabular-nums; }
.stat-card-label { font-size: 13px; color: var(--muted); margin-top: 4px; }
.chart-card .chart-wrap { height: 260px; margin-top: 12px; }

/* Log table */
.log-table-wrap { overflow-x: auto; margin-top: 10px; max-height: 400px; overflow-y: auto; }
.log-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.log-table th, .log-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid rgba(255,255,255,.08); }
.log-table th { color: var(--muted); font-weight: 700; position: sticky; top: 0; background: rgba(0,0,0,.3); }
.log-table td { color: rgba(255,255,255,.88); }
.pagination { margin-top: 10px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pagination .btn { width: auto; padding: 6px 12px; font-size: 13px; }
.pagination .info { color: var(--muted); font-size: 13px; }
.form-row { display:flex; flex-wrap:wrap; gap:10px; align-items:center; margin: 0 0 12px; }

/* 登录页 */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
}
.login-wrap { width: 100%; max-width: 420px; padding: 20px; }
.login-card {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 20px;
  padding: 32px 28px;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
}
.login-header { text-align: center; margin-bottom: 28px; }
.login-title { font-size: 24px; font-weight: 900; margin: 0 0 8px; }
.login-desc { color: var(--muted); font-size: 14px; margin: 0; }
.login-form .form-group { margin-bottom: 18px; }
.login-form .form-label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}
.login-form .form-input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(0,0,0,0.2);
  color: var(--text);
  font-size: 15px;
  outline: none;
}
.login-form .form-input:focus { border-color: var(--primary); }
.login-form .btn-lg { padding: 14px; font-size: 16px; margin-top: 8px; }
.login-footer {
  margin-top: 24px;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}
.login-footer a { color: var(--primary); text-decoration: none; }
.login-footer a:hover { text-decoration: underline; }
.alert-error { background: rgba(239,68,68,0.15); border-color: rgba(239,68,68,0.4); color: #fca5a5; }

/* 顶部栏用户信息 */
.topbar-user {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
}
.topbar-user .user-info { font-size: 13px; color: var(--muted); }
.topbar-user .user-name { color: var(--text); font-weight: 700; }
.topbar .topbar-inner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }

/* 可折叠菜单 */
.menu-group { margin-bottom: 4px; }
.menu-group-title {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  transition: all .2s;
  border-left: 3px solid transparent;
}
.menu-group-title:hover { color: var(--text); background: rgba(255,255,255,.05); }
.menu-group-title .nav-icon { font-size: 18px; }
.menu-group-title .nav-text { font-size: 14px; font-weight: 600; flex: 1; }
.menu-group-title .menu-chevron {
  font-size: 12px;
  transition: transform .2s;
}
.menu-group.expanded .menu-chevron { transform: rotate(90deg); }
.menu-group-items { display: none; }
.menu-group.expanded .menu-group-items { display: block; }
.menu-group-items .nav-item { padding-left: 44px; }
