:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --border: #e5e7eb;
  --text: #1f2328;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --ok: #16a34a;
  --fail: #dc2626;
  --warn: #d97706;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; }

/* ---------- 认证 ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px 28px;
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.06);
}
.auth-title { margin: 0 0 6px; font-size: 20px; font-weight: 600; }
.auth-sub { margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.auth-card input {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
}
.auth-card input:focus { border-color: var(--primary); }
.auth-error { color: var(--fail); font-size: 12px; min-height: 18px; margin: 10px 0 0; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 56px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}
.brand-name { font-weight: 600; font-size: 15px; }
.badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: var(--primary);
  border: 1px solid #dbeafe;
}
.badge.ok { background: #f0fdf4; color: var(--ok); border-color: #dcfce7; }
.badge.off { background: #fef2f2; color: var(--fail); border-color: #fee2e2; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

/* ---------- 布局 ---------- */
.container { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; }
.section { margin-bottom: 28px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 12px;
}
.section-head .section-title { margin: 0; }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 13px;
  cursor: pointer;
  background: transparent;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { border-color: var(--border); background: var(--panel); }
.btn-ghost:hover { background: #f3f4f6; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---------- 站点卡片 ---------- */
.site-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.site-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.site-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.site-name { font-weight: 600; font-size: 15px; }
.site-meta { color: var(--muted); font-size: 12px; margin-bottom: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  background: #f3f4f6;
  color: #374151;
}
.chip.on { background: #eef2ff; color: var(--primary); }
.account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
  border-top: 1px dashed var(--border);
  font-size: 13px;
}
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.dot.ok { background: var(--ok); }
.dot.unknown { background: #9ca3af; }
.site-actions { display: flex; gap: 8px; margin-top: 14px; }

/* ---------- 任务 ---------- */
.task-list { display: flex; flex-direction: column; gap: 10px; }
.task-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.task-main { min-width: 0; }
.task-title { font-weight: 600; margin-bottom: 3px; }
.task-meta { color: var(--muted); font-size: 12px; }
.task-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.type-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 500;
}
.type-checkin { background: #eff6ff; color: #1d4ed8; }
.type-grab { background: #fff7ed; color: #c2410c; }
.type-points { background: #f0fdf4; color: #15803d; }

/* ---------- 执行记录 ---------- */
.run-list { display: flex; flex-direction: column; gap: 6px; }
.run-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.run-status { font-weight: 600; width: 44px; flex-shrink: 0; }
.run-status.ok { color: var(--ok); }
.run-status.fail { color: var(--fail); }
.run-msg { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-time { color: var(--muted); font-size: 12px; flex-shrink: 0; }

/* ---------- 日志 ---------- */
.logs {
  background: #0f172a;
  color: #cbd5e1;
  border-radius: var(--radius);
  padding: 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.7;
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
}

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal-card {
  background: var(--panel);
  border-radius: 14px;
  width: 100%;
  max-width: 380px;
  padding: 22px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.2);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-head h3 { margin: 0; font-size: 16px; }

.qr-body { text-align: center; }
.qr-frame {
  width: 220px;
  height: 220px;
  margin: 0 auto 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  overflow: hidden;
}
.qr-frame img { width: 100%; height: 100%; object-fit: contain; }
.qr-hint { font-size: 13px; color: var(--muted); }
.qr-status { font-size: 13px; color: var(--muted); margin: 0 0 14px; min-height: 20px; }
.qr-actions { display: flex; gap: 8px; justify-content: center; }

/* ---------- 表单 ---------- */
.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #374151; }
.form input, .form select {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  background: #fff;
}
.form input:focus, .form select:focus { border-color: var(--primary); }
.form-error { color: var(--fail); font-size: 12px; min-height: 16px; margin: 0; }

@media (max-width: 640px) {
  .site-grid { grid-template-columns: 1fr; }
  .task-item { flex-direction: column; align-items: flex-start; }
  .task-right { width: 100%; justify-content: flex-end; }
}
