:root {
  --bg: #0f1115;
  --bg-2: #161a21;
  --bg-3: #1d222b;
  --line: #2a313d;
  --fg: #e6e9ef;
  --fg-dim: #9aa4b2;
  --accent: #4c8dff;
  --accent-2: #2f6fe0;
  --ok: #35c07f;
  --warn: #e0a63a;
  --err: #e05b5b;
  --radius: 10px;
}

* { box-sizing: border-box; }

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

.hidden { display: none !important; }
.muted { color: var(--fg-dim); font-weight: 400; font-size: 12px; }
.hint { color: var(--fg-dim); font-size: 12.5px; margin: 4px 0 10px; }
code { background: var(--bg-3); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* ---------------- 登录 ---------------- */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #1b2740 0%, var(--bg) 60%);
}
.auth-card {
  width: 360px; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 14px; padding: 28px;
}
.auth-card h1 { margin: 0 0 4px; font-size: 20px; }
.auth-sub { margin: 0 0 18px; color: var(--fg-dim); font-size: 12.5px; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; }
.auth-card label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--fg-dim); }
.auth-msg { margin-top: 12px; font-size: 12.5px; color: var(--err); min-height: 18px; }

/* ---------------- 布局 ---------------- */
#app-view { display: flex; min-height: 100vh; }

.sidebar {
  width: 208px; flex: 0 0 208px; background: var(--bg-2);
  border-right: 1px solid var(--line); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand {
  padding: 18px 18px 14px; font-weight: 600; font-size: 14.5px;
  display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line);
}
.brand .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 10px var(--accent);
}
.sidebar nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  padding: 9px 12px; border-radius: 8px; color: var(--fg-dim);
  cursor: pointer; user-select: none; font-size: 13.5px;
}
.nav-item:hover { background: var(--bg-3); color: var(--fg); }
.nav-item.active { background: var(--accent); color: #fff; }
.sidebar-foot {
  padding: 14px; border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 8px;
}
.who { font-size: 12px; color: var(--fg-dim); word-break: break-all; }

.content { flex: 1; padding: 22px 26px 60px; min-width: 0; }
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.page-head h2 { margin: 0; font-size: 18px; }

/* ---------------- 组件 ---------------- */
.btn {
  background: var(--bg-3); color: var(--fg); border: 1px solid var(--line);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 13px;
  transition: .15s; font-family: inherit;
}
.btn:hover { border-color: #3b4553; background: #222833; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.full { width: 100%; }
.btn.danger { color: var(--err); border-color: #4a2b2b; }

input, select, textarea {
  background: var(--bg); border: 1px solid var(--line); color: var(--fg);
  padding: 8px 10px; border-radius: 8px; font-size: 13px; font-family: inherit;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
input[type=checkbox] { width: auto; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--fg-dim); white-space: nowrap; }
label.inline.check { flex-direction: row; }
label.inline.block { flex-direction: column; align-items: stretch; gap: 5px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }

.panel {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 16px;
}
.panel h3 { margin: 0 0 6px; font-size: 14.5px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;
}
.card .n { font-size: 24px; font-weight: 600; line-height: 1.2; }
.card .l { color: var(--fg-dim); font-size: 12px; margin-top: 2px; }
.card .v { font-size: 12.5px; margin-bottom: 6px; word-break: break-all; }
.card.ok .n { color: var(--ok); }
.card.err .n { color: var(--err); }
.card.warn .n { color: var(--warn); }

/* 监听开关 */
.switch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 12px; color: var(--fg-dim); }
.switch input { width: auto; accent-color: var(--accent); }
.switch input:checked + span { color: var(--ok); }

.badge.warn { color: var(--warn); border-color: #4a3d1f; background: #2a2416; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--fg-dim); font-weight: 500; font-size: 12px; white-space: nowrap; }
tbody tr:hover { background: var(--bg-3); }
td img.cover { width: 34px; height: 48px; object-fit: cover; border-radius: 4px; background: var(--bg-3); }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11.5px; border: 1px solid var(--line); white-space: nowrap;
}
.badge.pending { color: var(--fg-dim); }
.badge.running { color: var(--accent); border-color: #29446f; background: #16233a; }
.badge.success { color: var(--ok); border-color: #1f4b38; background: #12271f; }
.badge.failed { color: var(--err); border-color: #4a2b2b; background: #2a1717; }
.badge.cancelled { color: var(--warn); border-color: #4a3d1f; background: #2a2416; }

.bar { height: 6px; background: var(--bg-3); border-radius: 4px; overflow: hidden; min-width: 80px; }
.bar > i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.bar.done > i { background: var(--ok); }
.bar.fail > i { background: var(--err); }

.parse-result { margin-top: 12px; font-size: 12.5px; display: flex; flex-direction: column; gap: 5px; }
.parse-result .ok { color: var(--ok); }
.parse-result .bad { color: var(--err); }

.recent { display: flex; flex-direction: column; gap: 8px; }
.recent .item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  background: var(--bg-3); border-radius: 8px; font-size: 12.5px;
}

.logbox {
  max-height: 62vh; overflow-y: auto; background: #0a0c10;
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
  font-family: ui-monospace, Consolas, "Courier New", monospace; font-size: 12px;
}
.logbox .ln { padding: 2px 0; border-bottom: 1px solid #14181f; white-space: pre-wrap; word-break: break-word; }
.logbox .ln .t { color: #5b6675; margin-right: 8px; }
.logbox .ln.error { color: #ff8a8a; }
.logbox .ln.warning { color: #ffd08a; }
.logbox .ln.debug { color: #74808f; }
.logbox .ln .tid { color: #4c8dff; margin-right: 6px; }

.toast {
  position: fixed; right: 20px; bottom: 20px; background: var(--bg-3);
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  padding: 11px 16px; border-radius: 8px; font-size: 13px;
  box-shadow: 0 8px 28px rgba(0,0,0,.5); max-width: 420px; z-index: 99;
}
.toast.err { border-left-color: var(--err); }
.toast.ok { border-left-color: var(--ok); }

@media (max-width: 860px) {
  #app-view { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; }
  .sidebar nav { flex-direction: row; overflow-x: auto; }
  .content { padding: 16px; }
}
