* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --danger: #ef4444;
  --ok: #16a34a;
  --warn: #f59e0b;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }

/* 认证页 */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  padding: 20px;
}
.auth-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.brand { text-align: center; margin-bottom: 24px; }
.brand .logo { font-size: 48px; margin-bottom: 12px; }
.brand h1 { font-size: 22px; margin-bottom: 8px; }
.brand p { color: var(--muted); font-size: 14px; }

.tabs { display: flex; margin-bottom: 20px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.tab { flex: 1; padding: 12px; background: #f8fafc; border: none; cursor: pointer; font-size: 15px; color: var(--muted); }
.tab.active { background: var(--primary); color: #fff; }

.auth-card form { display: flex; flex-direction: column; gap: 12px; }
input {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  outline: none;
  transition: border-color .2s;
}
input:focus { border-color: var(--primary); }

button { cursor: pointer; font-size: 15px; border: none; border-radius: 8px; }
button.primary {
  padding: 12px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  transition: background .2s;
}
button.primary:hover { background: var(--primary-dark); }
button.ghost {
  padding: 8px 14px;
  background: #f1f5f9;
  color: var(--text);
  border: 1px solid var(--border);
}
button.ghost:hover { background: #e2e8f0; }
button.ghost.disabled { opacity: 0.5; cursor: not-allowed; }
button.ghost.disabled:hover { background: #f1f5f9; }

.msg { margin-top: 14px; text-align: center; font-size: 14px; color: var(--danger); min-height: 20px; }
.msg.ok { color: var(--ok); }

/* 主界面 */
.topbar {
  background: #fff;
  padding: 14px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand-row { display: flex; align-items: center; gap: 10px; }
.logo-sm { font-size: 24px; }
.app-name { font-size: 18px; font-weight: 700; }
.user-row { display: flex; align-items: center; gap: 14px; }
.username { color: var(--muted); }

/* 导航栏 */
.main-nav { display: flex; gap: 4px; }
.nav-btn {
  padding: 8px 16px;
  background: transparent;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  color: var(--muted);
  cursor: pointer;
  transition: all .15s;
}
.nav-btn:hover { background: #f1f5f9; color: var(--text); }
.nav-btn.active { background: var(--primary); color: #fff; }

.container { max-width: 1000px; margin: 0 auto; padding: 24px 20px 60px; }

/* 页面切换 */
.page { display: none; flex-direction: column; gap: 20px; }
.page.active { display: flex; }

.card { background: var(--card); border-radius: 12px; padding: 24px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.card h2 { font-size: 18px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-head h2 { margin: 0; font-size: 18px; }
.head-actions { display: flex; gap: 8px; }

.check-form { display: flex; gap: 12px; flex-wrap: wrap; }
.check-form input { flex: 1; min-width: 160px; }
.check-form button { padding: 12px 24px; white-space: nowrap; }
.hint { color: var(--muted); font-size: 13px; margin-top: 10px; }

/* 参数网格 */
.param-grid { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 14px; }
.param-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}
.param-grid input {
  width: 120px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  outline: none;
}

/* 进度 */
.progress-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.progress-head h3 { font-size: 16px; }
.badge { padding: 4px 12px; border-radius: 20px; font-size: 13px; font-weight: 600; }
.badge.running { background: #e0e7ff; color: var(--primary); }
.badge.done { background: #dcfce7; color: var(--ok); }
.badge.failed { background: #fee2e2; color: var(--danger); }
.badge.pending { background: #fef3c7; color: var(--warn); }
.badge.cancelled { background: #e2e8f0; color: var(--muted); }

.progress-bar { height: 8px; background: #e2e8f0; border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--primary); transition: width .3s; }

/* 历史 */
.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s;
}
.history-item:hover { background: #f8fafc; }
.history-info { flex: 1; min-width: 0; }
.history-url { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 4px; }
.history-meta { font-size: 13px; color: var(--muted); }
.history-actions { display: flex; gap: 8px; align-items: center; }

/* 汇总 */
.summary { display: flex; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.summary-item {
  flex: 1;
  min-width: 120px;
  padding: 16px;
  border-radius: 8px;
  text-align: center;
}
.summary-item .num { font-size: 28px; font-weight: 700; display: block; }
.summary-item .label { font-size: 13px; color: var(--muted); }
.summary-item.total { background: #f1f5f9; }
.summary-item.ok { background: #dcfce7; }
.summary-item.bad { background: #fee2e2; }

.filters { display: flex; gap: 8px; margin-bottom: 16px; }
.filter { padding: 6px 16px; background: #f1f5f9; border: 1px solid var(--border); border-radius: 20px; color: var(--muted); }
.filter.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* 结果列表 */
.detail-list { display: flex; flex-direction: column; gap: 8px; max-height: 520px; overflow-y: auto; }
.result-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.status-pill {
  flex-shrink: 0;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  min-width: 52px;
  text-align: center;
}
.status-pill.ok { background: #dcfce7; color: var(--ok); }
.status-pill.bad { background: #fee2e2; color: var(--danger); }
.result-body { flex: 1; min-width: 0; }
.result-url { font-size: 14px; word-break: break-all; }
.result-source { font-size: 12px; color: var(--muted); margin-top: 4px; word-break: break-all; }
.empty { text-align: center; color: var(--muted); padding: 40px; }

/* 表单 select */
select {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  background: #fff;
  outline: none;
  cursor: pointer;
}

/* 用户管理 */
.user-list { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.user-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.user-info { flex: 1; min-width: 0; }
.user-username { font-weight: 600; margin-bottom: 4px; }
.tag-self {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  background: #e0e7ff;
  color: var(--primary);
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
}
.tag-owner {
  display: inline-block;
  margin-right: 8px;
  padding: 1px 8px;
  background: #fef3c7;
  color: #b45309;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
}
.user-meta { font-size: 13px; color: var(--muted); }
.badge.role-superadmin { background: #ede9fe; color: #7c3aed; }
.badge.role-admin { background: #e0e7ff; color: var(--primary); }
.badge.role-user { background: #f1f5f9; color: var(--muted); }

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

/* 弹窗 */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  background: #fff;
  border-radius: 12px;
  padding: 28px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.modal h3 { margin-bottom: 20px; font-size: 18px; }
.modal form { display: flex; flex-direction: column; gap: 12px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }
.modal-actions .primary { padding: 10px 20px; }
.modal .msg { margin-top: 12px; }
.modal-lg { max-width: 680px; max-height: 85vh; overflow-y: auto; }
.modal-lg .user-list { margin-top: 16px; }

/* 审计日志 */
.audit-list { display: flex; flex-direction: column; gap: 8px; max-height: 480px; overflow-y: auto; }
.audit-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.audit-action {
  flex-shrink: 0;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  background: #e0e7ff;
  color: var(--primary);
}
.audit-body { flex: 1; min-width: 0; }
.audit-detail { font-size: 14px; word-break: break-all; }
.audit-meta { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* 分页 */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.pagination-info { font-size: 13px; color: var(--muted); margin-right: 8px; }
.pg-btn {
  padding: 6px 12px;
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: all .15s;
}
.pg-btn:hover:not(:disabled) { background: #e2e8f0; }
.pg-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pg-btn:disabled { opacity: 0.4; cursor: not-allowed; }
