/* ========== 管理后台样式（与前台同套主题变量） ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--accent-blue); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ---- 登录页 ---- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  width: 360px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
}
.login-card h1 {
  font-size: 18px;
  text-align: center;
  margin-bottom: 6px;
}
.login-card .sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 24px;
}

/* ---- 布局 ---- */
.admin-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 200px;
  flex-shrink: 0;
  background: var(--bg-card);
  border-right: 1px solid var(--border-color);
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand {
  font-size: 15px;
  font-weight: 700;
  padding: 6px 10px 18px;
}
.sidebar .brand span { color: var(--accent-cyan); }
.side-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  transition: all 0.2s;
}
.side-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.side-item.active {
  background: var(--bg-input-focus);
  color: var(--accent-blue);
  font-weight: 600;
}
.sidebar .bottom { margin-top: auto; display: flex; flex-direction: column; gap: 4px; }

.main { flex: 1; padding: 24px 28px; min-width: 0; }
.page-title { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.page-desc { color: var(--text-muted); font-size: 12px; margin-bottom: 20px; }

/* ---- 通用组件 ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}
.btn {
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-secondary);
  font-size: 13px;
  transition: all 0.2s;
}
.btn:hover { color: var(--accent-blue); border-color: var(--accent-blue); }
.btn.primary {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: #fff;
}
.btn.primary:hover { opacity: 0.85; color: #fff; }
.btn.danger:hover { color: var(--tag-hot); border-color: var(--tag-hot); }
.btn.small { padding: 4px 10px; font-size: 12px; }

input[type="text"], input[type="password"], input[type="number"], select, textarea {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent-blue); }
textarea { resize: vertical; min-height: 70px; font-family: ui-monospace, monospace; font-size: 12px; }

.form-row { margin-bottom: 14px; }
.form-row label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 5px;
}
.form-row .hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 16px; }

/* ---- 统计卡片 ---- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat-card .label { font-size: 12px; color: var(--text-muted); }
.stat-card .value { font-size: 24px; font-weight: 700; margin-top: 6px; color: var(--accent-blue); }
.stat-card .value.warn { color: var(--tag-hot); }

/* ---- 表格 ---- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border-color); }
th { color: var(--text-muted); font-size: 12px; font-weight: 500; white-space: nowrap; }
td { vertical-align: middle; }
tr:hover td { background: var(--bg-hover); }

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 8px;
  white-space: nowrap;
}
.badge.ok { background: rgba(82,196,26,0.12); color: #52c41a; }
.badge.fail { background: var(--tag-hot-bg); color: var(--tag-hot); }
.badge.warn { background: rgba(255,169,64,0.12); color: #ffa940; }
.badge.muted { background: var(--bg-hover); color: var(--text-muted); }
.badge.type { background: var(--tag-new-bg); color: var(--tag-new); }
.badge.cat { background: rgba(114,46,209,0.12); color: #b37feb; }

/* ---- 开关 ---- */
.switch {
  width: 36px; height: 20px;
  border-radius: 10px;
  background: var(--bg-hover);
  border: 1px solid var(--border-color);
  position: relative;
  transition: all 0.2s;
  flex-shrink: 0;
}
.switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: all 0.2s;
}
.switch.on { background: var(--accent-blue); border-color: var(--accent-blue); }
.switch.on::after { left: 18px; background: #fff; }

/* ---- 弹窗 ---- */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  display: none;
  align-items: flex-start;
  justify-content: center;
  z-index: 100;
  padding: 40px 16px;
  overflow-y: auto;
}
.modal-mask.show { display: flex; }
.modal {
  width: 640px;
  max-width: 100%;
  background: var(--bg-dropdown);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
}
.modal-body { padding: 18px; max-height: 65vh; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--border-color);
}
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 16px; }

/* ---- 提示 ---- */
.toast {
  position: fixed;
  top: 20px; left: 50%;
  transform: translateX(-50%);
  background: var(--bg-dropdown);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 13px;
  box-shadow: var(--shadow);
  z-index: 200;
  display: none;
}
.toast.show { display: block; }
.toast.error { border-color: var(--tag-hot); color: var(--tag-hot); }

.section-sub {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-cyan);
  margin: 18px 0 12px;
  padding-top: 14px;
  border-top: 1px dashed var(--border-color);
}
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; margin-top: 12px; font-size: 12px; color: var(--text-muted); }

.preview-list { font-size: 12px; }
.preview-list div { padding: 5px 0; border-bottom: 1px dashed var(--border-color); color: var(--text-secondary); }

@media (max-width: 768px) {
  .sidebar { width: 64px; }
  .sidebar .brand, .side-item span.text { display: none; }
  .main { padding: 16px; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
}
