:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #e4e7ec;
  --text: #1b1f26;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-soft: #eaf1ff;
  --ok: #16a34a;
  --ok-soft: #e7f7ec;
  --bad: #dc2626;
  --bad-soft: #fdeaea;
  --warn: #b45309;
  --warn-soft: #fff4e5;
  --stale: #a16207;
  --stale-soft: #fef7e0;
  --radius: 10px;
  --side-w: 250px;
}

* { box-sizing: border-box; }

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

/* ---------------- 布局 ---------------- */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--side-w);
  flex: 0 0 var(--side-w);
  background: #10151f;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.side-brand { display: flex; gap: 10px; align-items: center; padding: 16px 16px 12px; }
.side-brand .logo {
  width: 30px; height: 30px; flex: 0 0 30px; display: grid; place-items: center;
  background: var(--primary); color: #fff; border-radius: 8px; font-size: 12px;
}
.side-brand strong { display: block; font-size: 13.5px; color: #f1f5f9; font-weight: 600; }

.sub { font-size: 11.5px; color: var(--muted); display: block; }
.sidebar .sub { color: #7c8899; }

.project-box { padding: 4px 14px 14px; border-bottom: 1px solid #1e2635; }
.project-box label, .side-foot label {
  font-size: 11px; color: #7c8899; display: block; margin-bottom: 5px; letter-spacing: .3px;
}
.project-row { display: flex; gap: 6px; }
.project-row select, .project-row input { flex: 1; min-width: 0; }

.progress-mini { height: 4px; background: #1e2635; border-radius: 3px; margin: 10px 0 5px; overflow: hidden; }
.progress-mini > div { height: 100%; width: 0; background: var(--primary); transition: width .3s; }

nav { flex: 1; padding: 10px 8px 20px; }
.nav-group { font-size: 10.5px; color: #5c6878; padding: 12px 10px 6px; letter-spacing: .6px; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
  font-size: 13px; color: #cbd5e1; text-decoration: none; margin-bottom: 2px;
  border-left: 2px solid transparent;
}
.nav-item:hover { background: #1a2231; }
.nav-item.active { background: #1d2941; color: #fff; font-weight: 600; border-left-color: var(--primary); }
.nav-item .badge {
  width: 20px; height: 20px; flex: 0 0 20px; display: grid; place-items: center;
  border-radius: 6px; background: #222c3d; font-size: 11px; color: #94a3b8;
}
.nav-item.active .badge { background: var(--primary); color: #fff; }
.nav-item .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #3b4657; }
.dot.done { background: #22c55e; }
.dot.failed { background: #ef4444; }
.dot.running { background: #3b82f6; }
.dot.stale { background: #f59e0b; }

.side-foot { padding: 12px 14px 16px; border-top: 1px solid #1e2635; }

/* ---------------- 主区 ---------------- */

main { flex: 1; min-width: 0; padding: 22px 26px 60px; max-width: 1180px; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.page-head h1 { margin: 0 0 4px; font-size: 19px; font-weight: 650; letter-spacing: -.2px; display: flex; align-items: center; gap: 9px; }
.page-head h1 .hbadge {
  width: 26px; height: 26px; display: grid; place-items: center; font-size: 13px;
  background: var(--primary-soft); color: var(--primary); border-radius: 8px;
}
.page-head p { margin: 0; color: var(--muted); font-size: 12.5px; max-width: 720px; }

.stepper { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.step-chip {
  display: flex; align-items: center; gap: 6px; padding: 5px 10px 5px 7px;
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
  font-size: 12px; color: #475569; cursor: pointer; text-decoration: none;
}
.step-chip:hover { border-color: #c7d2fe; }
.step-chip.active { border-color: var(--primary); background: var(--primary-soft); color: #1d4ed8; font-weight: 600; }
.step-chip .n { width: 16px; height: 16px; border-radius: 50%; display: grid; place-items: center; font-size: 10.5px; background: #eef1f5; color: #64748b; }
.step-chip.done .n { background: var(--ok-soft); color: var(--ok); }
.step-chip.failed .n { background: var(--bad-soft); color: var(--bad); }
.step-chip.stale .n { background: var(--stale-soft); color: var(--stale); }

/* 卡片与面板 */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.card h3 { margin: 0 0 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.big { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -.2px; }
.big.ok { color: var(--ok); }
.big.bad { color: var(--bad); }
.hint { margin: 4px 0 0; font-size: 12px; color: var(--muted); }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.panel > h2 { margin: 0 0 12px; font-size: 14.5px; font-weight: 600; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.panel-head h2 { margin: 0; font-size: 14.5px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.wide { grid-column: 1 / -1; }
.field label { font-size: 12px; color: var(--muted); font-weight: 500; }
.field .tip { font-size: 11px; color: #9aa4b2; }
.check { display: flex; align-items: flex-start; gap: 8px; font-size: 12.5px; color: #475569; }
.check input { margin-top: 3px; }

input, select, textarea, button {
  font: inherit; padding: 7px 10px; border: 1px solid var(--border);
  border-radius: 7px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #dbeafe; border-color: var(--primary); }
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; width: 100%; resize: vertical; }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }
button.ghost { background: #fff; }
button.mini { padding: 3px 9px; font-size: 12px; }
button.icon { width: 34px; flex: 0 0 34px; display: grid; place-items: center; padding: 0; }
.sidebar button { background: #1c2534; color: #cbd5e1; border-color: #2a3546; }
.sidebar button:hover { background: #253048; }
.sidebar input, .sidebar select { background: #161d29; color: #e2e8f0; border-color: #2a3546; }

.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.actions .spacer { flex: 1; }

.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; background: #eef1f5; color: #475569;
}
.chip.done { background: var(--ok-soft); color: #15803d; }
.chip.failed { background: var(--bad-soft); color: #b91c1c; }
.chip.running { background: var(--primary-soft); color: #1d4ed8; }
.chip.stale { background: var(--stale-soft); color: var(--stale); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.info { background: #eef4ff; color: #1e40af; }

.note-list { margin: 10px 0 0; padding-left: 18px; font-size: 12.5px; color: #475569; }
.note-list li { margin-bottom: 4px; }

.warn {
  background: var(--warn-soft); border: 1px solid #f0d48a; color: #7a5b12;
  border-radius: 8px; padding: 9px 12px; font-size: 12.5px; margin: 12px 0 0;
}
.danger { background: var(--bad-soft); border: 1px solid #f3c2c2; color: #991b1b; }
.ok-box { background: var(--ok-soft); border: 1px solid #bfe6cb; color: #14532d; }

.kv { display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: 6px 14px; font-size: 12.5px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

pre.result {
  background: #0f172a; color: #d7e3f4; border-radius: 8px; padding: 12px;
  font-size: 12px; max-height: 340px; overflow: auto; white-space: pre-wrap; word-break: break-all;
}
details summary { cursor: pointer; font-size: 12.5px; color: var(--primary); margin-top: 10px; }

table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 11.5px; color: var(--muted); font-weight: 600; background: #fafbfc; }
tbody tr:last-child td { border-bottom: none; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11.5px; }
.empty { color: var(--muted); text-align: center; padding: 18px 0; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; background: #eef1f5; color: #475569; }
.pill.s-succeeded, .pill.s-success, .pill.s-ok, .pill.s-completed, .pill.s-done { background: var(--ok-soft); color: #15803d; }
.pill.s-failed, .pill.s-error { background: var(--bad-soft); color: #b91c1c; }
.pill.s-running, .pill.s-processing, .pill.s-submitted, .pill.s-queued, .pill.s-finalizing { background: var(--primary-soft); color: #1d4ed8; }
.pill.s-cancelled, .pill.s-canceled { background: #f1f1f4; color: #64748b; }
.pill.s-partial { background: var(--warn-soft); color: var(--warn); }

code { background: #f1f3f6; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
a.link { color: var(--primary); }
.mt8 { margin-top: 8px; }
.mt16 { margin-top: 16px; }
