:root {
  --bg: #f3f5f1;
  --surface: #ffffff;
  --surface-soft: #eef3ee;
  --ink: #17211f;
  --muted: #69736f;
  --line: #d7ded8;
  --rail: #17211f;
  --rail-text: #ecf2ed;
  --green: #137253;
  --green-strong: #0c5d44;
  --cyan: #236c84;
  --amber: #9a6418;
  --red: #a33a31;
  --shadow: 0 16px 42px rgba(23, 33, 31, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(19, 114, 83, 0.05) 1px, transparent 1px),
    linear-gradient(0deg, rgba(35, 108, 132, 0.04) 1px, transparent 1px),
    var(--bg);
  background-size: 32px 32px;
  font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  letter-spacing: 0;
}

.login-view {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(90deg, rgba(19, 114, 83, 0.06) 1px, transparent 1px),
    linear-gradient(0deg, rgba(35, 108, 132, 0.05) 1px, transparent 1px),
    var(--bg);
  background-size: 32px 32px;
}

.login-panel {
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-panel label,
.form-grid label,
.run-grid label,
.import-box label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.login-hint {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.rail {
  color: var(--rail-text);
  background: var(--rail);
  padding: 26px 18px;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 30px;
}

.brand-mark {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  box-sizing: border-box;
  display: block;
  padding: 5px;
  object-fit: contain;
  background: #f8fff7;
  border-radius: 6px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.brand strong {
  display: block;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  height: 42px;
  padding: 0 12px;
  color: #dce5df;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
}

.nav-item.active,
.nav-item:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.14);
}

.workspace {
  padding: 28px;
  overflow: auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.top-actions,
.project-actions,
.profile-actions,
.rerun-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
  font-weight: 760;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  font-weight: 740;
}

.lead {
  max-width: 680px;
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.hint {
  color: var(--muted);
  font-size: 13px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.layout {
  display: grid;
  gap: 18px;
}

.layout.two {
  grid-template-columns: minmax(420px, 0.95fr) minmax(420px, 1.05fr);
}

.project-layout {
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
}

.project-main {
  display: grid;
  gap: 18px;
  align-content: start;
}

.panel,
.hero-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 150px;
  margin-bottom: 18px;
  padding: 24px;
  background:
    linear-gradient(90deg, rgba(19, 114, 83, 0.12), transparent 58%),
    var(--surface);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-head.inline {
  border-top: 1px solid var(--line);
}

.composer {
  margin-bottom: 18px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat-item {
  min-height: 96px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stat-item span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.stat-item strong {
  display: block;
  margin-top: 10px;
  font-size: 34px;
  line-height: 1;
}

.flow {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.flow-step {
  display: grid;
  grid-template-columns: 36px minmax(100px, 0.35fr) minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.flow-step span {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  color: #fff;
  background: var(--green);
  border-radius: 6px;
  font-weight: 800;
}

.flow-step small {
  color: var(--muted);
  line-height: 1.5;
}

.form-grid,
.run-grid {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.form-grid {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.run-grid {
  grid-template-columns: repeat(4, minmax(170px, 1fr));
}

.task-form-simple {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.run-grid label:has(textarea),
.toggles,
.wide {
  grid-column: span 2;
}

.task-form-simple label:has(textarea),
.task-form-simple .wide {
  grid-column: 1 / -1;
}

.import-box {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(220px, 1.1fr) minmax(120px, 0.45fr) minmax(150px, 0.6fr) minmax(170px, 0.7fr) auto;
  gap: 12px;
  align-items: end;
  padding: 18px 18px 0;
}

.import-box .hint {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #c7d0ca;
  border-radius: 6px;
  outline: none;
}

textarea {
  min-height: 86px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(19, 114, 83, 0.14);
}

.primary,
.secondary,
.icon-button {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 700;
}

.primary {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}

.primary:hover {
  background: var(--green-strong);
}

.primary.small {
  min-height: 34px;
  padding: 0 12px;
}

.secondary {
  color: var(--green);
  background: #fff;
  border-color: var(--green);
}

.secondary:hover {
  background: rgba(19, 114, 83, 0.08);
}

.secondary.danger {
  color: var(--red);
  border-color: var(--red);
}

.secondary.danger:hover {
  background: rgba(163, 58, 49, 0.08);
}

.icon-button {
  color: var(--ink);
  background: #fff;
  border-color: var(--line);
}

.toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.toggles label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
}

.toggles input {
  width: 16px;
  min-height: 16px;
}

.list,
.task-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.empty {
  color: var(--muted);
}

.list-row,
.project-row,
.task-row {
  display: grid;
  width: 100%;
  gap: 8px;
  padding: 12px;
  color: var(--ink);
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}

.list-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.project-row {
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
}

.task-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.list-row:hover,
.project-row:hover,
.project-row.selected,
.task-row:hover,
.task-row.selected {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(19, 114, 83, 0.1);
}

.list-row strong,
.project-row strong,
.task-row strong {
  display: block;
  overflow-wrap: anywhere;
}

.list-row small,
.project-row small,
.task-row small,
.project-row em,
.task-row em {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  line-height: 1.5;
}

.task-row-right {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.task-row button[data-delete-job-id] {
  display: inline-grid;
  min-height: 28px;
  place-items: center;
  padding: 0 9px;
  color: var(--red);
  background: #fff;
  border: 1px solid var(--red);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.badge {
  display: inline-grid;
  min-width: 70px;
  min-height: 28px;
  place-items: center;
  padding: 0 10px;
  color: #fff;
  background: var(--muted);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
}

.badge.completed {
  background: var(--green);
}

.badge.completed_with_warnings {
  background: var(--amber);
}

.badge.running,
.badge.queued {
  background: var(--cyan);
}

.badge.failed {
  background: var(--red);
}

.badge.canceled,
.badge.neutral {
  background: var(--muted);
}

.project-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
}

.project-meta {
  margin: 8px 0 0;
  color: var(--muted);
}

.info-grid,
.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 10px;
  padding: 0 18px 18px;
}

.summary-grid {
  padding-top: 14px;
}

.info-grid div,
.summary-grid div {
  min-height: 72px;
  padding: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.info-grid span,
.summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.info-grid strong,
.summary-grid strong {
  display: block;
  margin-top: 7px;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.empty-state {
  display: grid;
  min-height: 220px;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.empty-state h2 {
  color: var(--ink);
}

.empty-state.compact {
  min-height: 96px;
}

.artifact-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 14px 0;
}

.artifact-list a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 11px;
  color: var(--green);
  text-decoration: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-weight: 700;
}

.artifact-list a:hover {
  border-color: var(--green);
}

.summary-list,
.step-list {
  display: grid;
  gap: 8px;
  padding: 14px 14px 0;
}

.summary-item,
.step-item {
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--cyan);
  border-radius: 6px;
}

.summary-item strong,
.summary-item span,
.step-meta {
  display: block;
  line-height: 1.5;
}

.summary-item span,
.step-meta {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.summary-item.warn {
  border-left-color: var(--amber);
}

.summary-item.error,
.step-item.failed {
  border-left-color: var(--red);
}

.summary-item.ok,
.step-item.completed {
  border-left-color: var(--green);
}

.step-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 700;
}

.rerun-actions {
  padding: 14px;
}

.diagnostics {
  margin: 0 14px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.diagnostics summary {
  padding: 12px;
  cursor: pointer;
  font-weight: 700;
}

.log {
  min-height: 360px;
  max-height: 58vh;
  margin: 14px;
  padding: 14px;
  overflow: auto;
  color: #e7eee9;
  background: #17211f;
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.6;
}

.log.compact {
  min-height: 260px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  max-width: 420px;
  padding: 12px 14px;
  color: #fff;
  background: #17211f;
  border-radius: 6px;
  box-shadow: var(--shadow);
}

@media (max-width: 1180px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .rail {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
  }

  .brand {
    margin: 0;
  }

  .nav {
    grid-auto-flow: column;
  }

  .layout.two,
  .project-layout,
  .form-grid,
  .run-grid,
  .import-box,
  .info-grid,
  .summary-grid,
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .run-grid label:has(textarea),
  .toggles,
  .wide,
  .import-box .hint {
    grid-column: auto;
  }
}

@media (max-width: 680px) {
  .workspace {
    padding: 16px;
  }

  .topbar,
  .rail,
  .hero-panel,
  .project-header {
    align-items: flex-start;
    flex-direction: column;
  }

  h1 {
    font-size: 24px;
  }

  .flow-step,
  .list-row,
  .project-row,
  .task-row {
    grid-template-columns: 1fr;
  }

  .task-row-right {
    justify-content: flex-start;
  }
}
