:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-alt: #eef2ec;
  --ink: #17211c;
  --muted: #66736b;
  --line: #d9dfd6;
  --teal: #16736b;
  --teal-strong: #0e5d57;
  --amber: #a86116;
  --red: #b33838;
  --green: #2f7d46;
  --focus: #1b6fa8;
  --shadow: 0 10px 24px rgba(24, 33, 28, 0.08);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 360px;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 76px;
  padding: 16px 24px;
  background: #fbfcfa;
  border-bottom: 1px solid var(--line);
}

.topbar h1,
.section-heading h2,
.rail-header h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0;
}

.topbar p,
.section-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.topbar-actions,
.form-actions,
.range-row,
.pane-title,
.rail-header,
.section-heading,
.detail-actions,
.checkbox-row {
  display: flex;
  align-items: center;
}

.topbar-actions {
  gap: 10px;
}

.primary-button,
.ghost-button,
.danger-button,
.icon-button {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 7px;
  font-weight: 700;
  white-space: nowrap;
}

.primary-button {
  background: var(--teal);
  color: white;
}

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

.ghost-button,
.icon-button {
  background: var(--surface-alt);
  color: var(--ink);
  border: 1px solid var(--line);
}

.danger-button {
  background: #fff1ef;
  color: var(--red);
  border: 1px solid #e9c2bd;
}

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

.job-rail {
  border-right: 1px solid var(--line);
  background: #fbfcfa;
  padding: 16px;
  overflow: auto;
}

.rail-header {
  justify-content: space-between;
  margin-bottom: 12px;
}

.count-pill {
  display: inline-flex;
  min-width: 28px;
  height: 24px;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  border-radius: 999px;
  background: #e5eadf;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.job-list {
  display: grid;
  gap: 8px;
}

.job-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  width: 100%;
  padding: 11px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: none;
}

.job-row.active {
  border-color: var(--teal);
  box-shadow: inset 3px 0 0 var(--teal);
}

.job-row-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.job-row-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.status {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.status.queued {
  color: #77510b;
  background: #fff0cb;
}

.status.preparing,
.status.submitted,
.status.pending,
.status.runnable,
.status.starting {
  color: #77510b;
  background: #fff0cb;
}

.status.running {
  color: #0e5d57;
  background: #d9f0ed;
}

.status.succeeded {
  color: #236338;
  background: #dbefdf;
}

.status.failed,
.status.cancelled {
  color: #922f2f;
  background: #f8dddd;
}

.workspace {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 0;
  overflow: auto;
}

.create-section,
.detail-section {
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}

.section-heading {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.selected-prefix {
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
}

.create-grid {
  display: grid;
  grid-template-columns: minmax(280px, 42%) minmax(320px, 1fr);
  gap: 18px;
}

.folder-pane,
.job-form,
.job-detail {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.folder-pane {
  min-height: 420px;
  overflow: hidden;
}

.pane-title {
  justify-content: space-between;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
}

.pane-title h3,
.master-panel h3 {
  margin: 0;
  font-size: 14px;
}

.folder-tree {
  max-height: 490px;
  overflow: auto;
  padding: 8px;
}

.bucket-control {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.bucket-control input {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.folder-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px;
  width: 100%;
  min-height: 34px;
  padding: 0 8px;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.folder-row:hover,
.folder-row.selected {
  background: #edf5f1;
}

.folder-indent {
  width: 28px;
  color: var(--muted);
  text-align: center;
}

.folder-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-count {
  color: var(--muted);
  font-size: 12px;
}

.job-form {
  display: grid;
  align-content: start;
  gap: 16px;
  padding: 18px;
}

.job-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.job-form input[type="text"],
.job-form input[type="number"],
.job-form select {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
}

.checkbox-row {
  justify-content: flex-start;
  gap: 9px;
  color: var(--ink) !important;
  text-transform: none !important;
}

.checkbox-row input {
  width: 17px;
  height: 17px;
  accent-color: var(--teal);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: min(340px, 100%);
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-alt);
}

.segment {
  min-height: 32px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.segment.active {
  background: #fff;
  color: var(--teal-strong);
  box-shadow: 0 1px 5px rgba(24, 33, 28, 0.12);
}

.range-row {
  gap: 12px;
}

.range-row input {
  width: 100%;
  accent-color: var(--teal);
}

.range-row output {
  min-width: 52px;
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--surface-alt);
  color: var(--ink);
  text-align: center;
}

.master-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(160px, 230px);
  gap: 12px;
  align-items: center;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafbf8;
}

.master-panel p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.form-actions {
  gap: 12px;
}

.detail-actions {
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

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

.job-detail {
  min-height: 230px;
  padding: 18px;
}

.empty-state {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
  font-size: 18px;
}

.progress-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e7de;
}

.progress-bar {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--green));
}

.detail-table {
  width: 100%;
  margin-top: 16px;
  border-collapse: collapse;
  font-size: 13px;
}

.detail-table th,
.detail-table td {
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.detail-table th {
  width: 170px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.events {
  margin-top: 16px;
}

.events h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.event-row {
  display: grid;
  grid-template-columns: 165px 70px minmax(0, 1fr);
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 980px) {
  .app-shell,
  .create-grid {
    grid-template-columns: 1fr;
  }

  .job-rail {
    max-height: 290px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .selected-prefix {
    max-width: 100%;
  }

  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .topbar,
  .section-heading,
  .master-panel,
  .event-row {
    grid-template-columns: 1fr;
  }

  .topbar,
  .section-heading {
    align-items: flex-start;
  }

  .topbar {
    flex-direction: column;
  }

  .topbar-actions,
  .form-actions {
    width: 100%;
  }

  .primary-button,
  .ghost-button,
  .danger-button {
    width: 100%;
  }

  .create-section,
  .detail-section {
    padding: 18px 14px;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .detail-table th,
  .detail-table td {
    display: block;
    width: 100%;
  }
}
