:root {
  --bg: #f3f6f4;
  --surface: #ffffff;
  --sidebar: #12241c;
  --sidebar-text: #c5d5cb;
  --line: #e3ebe6;
  --text: #1a2420;
  --muted: #66756e;
  --primary: #178a4b;
  --primary-dark: #0f6b39;
  --danger: #c24141;
  --warn: #b7791f;
  --shadow: 0 1px 2px rgba(16, 32, 24, 0.04);
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "Cascadia Mono", Consolas, "Sarasa Mono SC", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
h1, h2, h3 { margin: 0; font-weight: 650; }

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(900px 420px at 0% -10%, rgba(23, 138, 75, 0.16), transparent 55%),
    #e7eee9;
}
.login-card {
  width: min(400px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 28px 22px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}
.login-card h1 { font-size: 22px; }
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: white;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.login-card label, .form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
}
textarea { min-height: 76px; resize: vertical; }
textarea.code, .log { font-family: var(--mono); font-size: 12px; }
input:focus, textarea:focus, select:focus {
  outline: 2px solid rgba(23, 138, 75, 0.25);
  border-color: var(--primary);
}
.form-error { min-height: 18px; color: var(--danger); font-size: 13px; margin: 0; }
.hint { color: var(--muted); font-size: 12px; margin: 0; }

.app { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 228px;
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 0 8px 16px; }
.brand strong { display: block; color: white; }
.brand small { color: #8ea497; }
nav { display: grid; gap: 4px; }
nav button {
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--sidebar-text);
  border-radius: 8px;
  padding: 9px 12px;
}
nav button.active, nav button:hover { background: rgba(255, 255, 255, 0.08); color: white; }
nav button.active { box-shadow: inset 3px 0 0 var(--primary); }
.side-foot { margin-top: auto; padding: 12px 8px 0; color: #7f9487; font-size: 12px; }

.main { margin-left: 228px; min-height: 100vh; }
.topbar {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  background: rgba(243, 246, 244, 0.92);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar h1 { font-size: 18px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.content { padding: 20px 22px 40px; }

.btn {
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
}
.btn:hover { border-color: #c9d7ce; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: white; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { color: var(--danger); }
.btn.sm { height: 26px; padding: 0 8px; font-size: 12px; }
.btn.block { width: 100%; height: 38px; }
.btn:disabled { opacity: 0.6; cursor: default; }
.icon-btn {
  border: 0;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  color: var(--muted);
}

.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.card, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.card { padding: 14px 16px; }
.card-label { color: var(--muted); font-size: 12px; }
.card-value { font-size: 26px; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.card-sub { color: var(--muted); font-size: 12px; min-height: 16px; }
.meter { height: 6px; background: #e7eee9; border-radius: 99px; margin-top: 10px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--primary); }
.meter.warn span { background: var(--warn); }
.meter.bad span { background: var(--danger); }

.grid-2 { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 12px; margin-top: 12px; }
.panel { padding: 16px; }
.panel h3 { font-size: 15px; margin-bottom: 12px; }
.facts, .detail { display: grid; gap: 8px; margin: 0; }
.facts div, .detail div { display: grid; grid-template-columns: 96px 1fr; gap: 8px; }
.facts dt, .detail dt { color: var(--muted); }
.facts dd, .detail dd { margin: 0; word-break: break-all; }
.detail dd { white-space: pre-wrap; }
.stats { display: flex; gap: 18px; margin-bottom: 8px; }
.stats b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.stats span { color: var(--muted); font-size: 12px; }

.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .search { max-width: 260px; }
.spacer { flex: 1; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; background: white; border: 1px solid var(--line); border-radius: 12px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; font-weight: 650; background: #f8fbf9; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #f7faf8; }
.empty { text-align: center; color: var(--muted); padding: 28px; }
.ops { display: flex; flex-wrap: wrap; gap: 6px; }
.name { font-weight: 650; }
.sub { color: var(--muted); font-size: 12px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 99px;
  padding: 2px 8px;
  font-size: 12px;
  background: #eef2f0;
  color: #52615a;
  white-space: nowrap;
}
.pill.run { background: #e5f6ec; color: #0f7a3a; }
.pill.pause, .pill.warn { background: #fff4df; color: #8a5a00; }
.pill.bad { background: #fdecec; color: #a33131; }
.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.banner {
  background: #fff4f2;
  color: #8d2d2d;
  border: 1px solid #f3d0cb;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
.check input { width: auto; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 16, 0.46);
  display: grid;
  place-items: center;
  z-index: 20;
  padding: 16px;
}
.dialog {
  width: min(680px, 100%);
  max-height: calc(100vh - 32px);
  background: white;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
}
.dialog.wide { width: min(920px, 100%); }
.dialog-head, .dialog-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
}
.dialog-head { border-bottom: 1px solid var(--line); }
.dialog-foot { border-top: 1px solid var(--line); justify-content: flex-end; }
.dialog-body { padding: 16px; overflow: auto; }
.form { display: grid; gap: 12px; }
.log {
  background: #101814;
  color: #d7e7dc;
  border-radius: 8px;
  padding: 12px;
  max-height: 420px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 8px 0 0;
}
.log.light { background: #f6f8f7; color: var(--text); }

.split { display: grid; grid-template-columns: 240px 1fr; gap: 12px; min-height: 520px; }
.split-side, .split-main { background: white; border: 1px solid var(--line); border-radius: 12px; }
.split-side { padding: 12px; }
.project {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 8px;
  margin-top: 4px;
}
.project.active, .project:hover { background: #eef6f1; }
.editor { display: grid; gap: 10px; padding: 12px; }
.editor textarea { min-height: 420px; }
.filebar { flex-wrap: wrap; }
.filebar #path-jump { max-width: 360px; }
.crumbs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.crumb, .linkish { border: 0; background: transparent; color: var(--primary); padding: 0; text-align: left; }
.linkish { font-weight: 650; }
#f-text { min-height: 360px; }

.task-anchor { position: relative; }
.count {
  display: inline-grid;
  place-items: center;
  min-width: 16px;
  height: 16px;
  margin-left: 4px;
  padding: 0 4px;
  border-radius: 99px;
  background: var(--primary);
  color: white;
  font-size: 11px;
}
.task-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(380px, calc(100vw - 32px));
  max-height: 460px;
  overflow: auto;
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(16, 32, 24, 0.16);
  z-index: 15;
}
.task-head {
  position: sticky;
  top: 0;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: white;
  font-weight: 650;
}
.task-empty { padding: 22px 14px; color: var(--muted); }
.task-item { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.task-item:last-child { border-bottom: 0; }
.task-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.task-title { font-weight: 650; }
.task-detail { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.task-lines {
  margin: 8px 0 0;
  max-height: 140px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: 12px;
  color: #314039;
  background: #f6f8f7;
  border-radius: 8px;
  padding: 8px;
}

#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 40; }
.toast {
  background: #1c2823;
  color: white;
  border-radius: 8px;
  padding: 10px 12px;
  max-width: 360px;
  box-shadow: var(--shadow);
}
.toast.err { background: #8d2d2d; }
.toast.ok { background: #146c3a; }

@media (max-width: 980px) {
  .cards, .grid-2, .split { grid-template-columns: 1fr; }
  .sidebar { position: static; width: auto; }
  .main { margin-left: 0; }
  .app { display: block; }
  nav { grid-auto-flow: column; justify-content: start; overflow: auto; }
  .side-foot { display: none; }
}
