:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --border: #e3e8ef;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --green: #059669;
  --red: #dc2626;
  --orange: #d97706;
  --sidebar: #0f172a;
  --sidebar-text: #cbd5e1;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #0f172a 100%);
}
.login-card {
  background: var(--panel);
  padding: 40px 36px;
  border-radius: 14px;
  width: 360px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
}
.login-logo { font-size: 44px; text-align: center; margin-bottom: 12px; }
.login-card h1 { font-size: 20px; text-align: center; margin-bottom: 6px; }
.login-sub { text-align: center; color: var(--muted); margin-bottom: 24px; font-size: 13px; }
.login-card input {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  margin-bottom: 14px;
  outline: none;
}
.login-card input:focus { border-color: var(--primary); }
.login-card button {
  padding: 12px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
  font-weight: 500;
}
.login-card button:hover { background: var(--primary-dark); }
.login-error { color: var(--red); font-size: 13px; text-align: center; min-height: 18px; margin-top: 8px; }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 200px;
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.brand {
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
#nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: block;
  padding: 11px 14px;
  color: var(--sidebar-text);
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  font-size: 14px;
  transition: background 0.15s;
  user-select: none;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.sidebar-footer { padding: 12px 10px; border-top: 1px solid rgba(255, 255, 255, 0.08); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar h2 { font-size: 18px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.refresh-hint { color: var(--muted); font-size: 12px; }
.content { padding: 24px; flex: 1; }

/* ---------- 组件 ---------- */
.btn {
  padding: 8px 16px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-danger { color: var(--red); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.card .label { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.card .value { font-size: 24px; font-weight: 600; line-height: 1.2; }
.card .sub { font-size: 12px; margin-top: 6px; }
.up { color: var(--green); }
.down { color: var(--red); }
.flat { color: var(--muted); }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-head h3 { font-size: 15px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
th { background: #f8fafc; color: var(--muted); font-weight: 500; font-size: 12px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  background: var(--panel);
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.toolbar label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.toolbar input, .toolbar select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 13px;
}

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-failed { background: #fee2e2; color: #991b1b; }
.badge-running { background: #dbeafe; color: #1e40af; }

.empty { padding: 36px; text-align: center; color: var(--muted); }
.loading { padding: 36px; text-align: center; color: var(--muted); }

/* 配置表单 */
.config-form { padding: 20px 22px; }
.form-row { margin-bottom: 16px; max-width: 560px; }
.form-row label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.form-row input[type="text"], .form-row input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}
.form-row label.checkbox { display: flex; align-items: center; gap: 8px; color: var(--text); }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }
.form-msg { margin-top: 12px; font-size: 13px; color: var(--green); min-height: 18px; }

/* 图表 */
#trend-chart { padding: 20px; overflow-x: auto; }
#trend-chart svg { display: block; min-width: 600px; width: 100%; height: auto; }
.chart-legend { display: flex; gap: 18px; margin-bottom: 12px; font-size: 12px; color: var(--muted); }
.chart-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; }

/* toast */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 11px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 1000;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }

@media (max-width: 768px) {
  .sidebar { width: 64px; }
  .brand, .nav-item { font-size: 0; }
  .nav-item { text-align: center; }
}

/* ---------- 目标进度 ---------- */
.goal-progress { padding: 20px 22px; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 22px; }
.goal-item .goal-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.goal-item .goal-label { font-size: 13px; color: var(--muted); }
.goal-item .goal-val { font-size: 13px; font-variant-numeric: tabular-nums; }
.goal-bar { height: 10px; background: #eef2f7; border-radius: 6px; overflow: hidden; }
.goal-bar > i { display: block; height: 100%; border-radius: 6px; background: var(--primary); transition: width 0.4s; }
.goal-bar > i.over { background: var(--green); }
.goal-item .goal-note { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5); display: flex; align-items: center; justify-content: center; z-index: 900; }
.modal-card { background: var(--panel); border-radius: 12px; width: 420px; max-width: 92vw; box-shadow: 0 20px 50px rgba(0,0,0,0.25); overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; }
.modal-close { background: none; border: none; font-size: 24px; line-height: 1; color: var(--muted); cursor: pointer; }
.modal-card form { padding: 20px 22px; }
