* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: "Segoe UI", "PingFang SC", sans-serif;
  background: linear-gradient(180deg, #f4f0ea 0%, #ece7df 100%);
  color: #2a2a2a;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
}

header {
  background: linear-gradient(135deg, #1f3a5f 0%, #15263d 100%);
  color: #fff;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: 0 0 auto;
}

header h1 {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.2;
}

header .subtitle {
  color: #b5c5da;
  font-size: 12px;
  margin-top: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

main {
  width: 100%;
  max-width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  padding: 12px;
}

.card {
  background: rgba(255, 255, 255, 0.92);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: 0 14px 40px rgba(28, 42, 61, 0.08);
  border: 1px solid rgba(31, 58, 95, 0.08);
}

.panel-card {
  margin-bottom: 0;
  min-height: 0;
  overflow: hidden;
}

.card h2 {
  font-size: 17px;
  margin-bottom: 12px;
  color: #1f3a5f;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.compact-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.card-header h2 {
  margin-bottom: 0;
}

.compact-header {
  margin-bottom: 10px;
}

.panel-tip {
  color: #738194;
  font-size: 12px;
}

.form-row {
  margin-bottom: 8px;
}

.form-row label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: #555;
  margin-bottom: 3px;
}

.form-row input,
.form-row select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #cdd7e4;
  border-radius: 9px;
  font-size: 13px;
  background: #fff;
}

.form-row input:focus,
.form-row select:focus {
  outline: none;
  border-color: #1f6aa5;
  box-shadow: 0 0 0 3px rgba(31, 106, 165, 0.12);
}

.btn {
  background: linear-gradient(135deg, #1f6aa5 0%, #194d7a 100%);
  color: #fff;
  border: none;
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  margin-top: 8px;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    opacity 0.18s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(25, 77, 122, 0.22);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
  margin-top: 0;
}

.full-width-btn {
  width: 100%;
  margin-top: 2px;
}

.btn-danger {
  background: linear-gradient(135deg, #c75745 0%, #a63f31 100%);
}

.btn-danger:hover {
  box-shadow: 0 8px 18px rgba(166, 63, 49, 0.22);
}

.btn-secondary {
  background: #eef3f9;
  color: #24476b;
}

.btn-secondary:hover {
  box-shadow: none;
  background: #e1ebf6;
}

.workspace-layout {
  display: grid;
  grid-template-columns: 430px minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
  height: 100%;
  min-height: 0;
}

.sidebar-column {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  min-height: 0;
}

.create-card {
  flex: 0 0 auto;
}

.jobs-panel,
.detail-panel,
.sidebar-column {
  min-height: 0;
}

.jobs-panel {
  display: flex;
  flex-direction: column;
}

.job-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
  padding-right: 4px;
}

.empty {
  text-align: center;
  color: #999;
  padding: 24px;
}

.job-item {
  padding: 10px 12px;
  border: 1px solid #d8e1eb;
  border-radius: 12px;
  background: #fafcfe;
  cursor: pointer;
  transition:
    border-color 0.18s ease,
    transform 0.18s ease,
    box-shadow 0.18s ease;
}

.job-item:hover {
  transform: translateY(-1px);
  border-color: #8fb3d1;
  box-shadow: 0 10px 24px rgba(36, 71, 107, 0.08);
}

.job-item.selected {
  border-color: #1f6aa5;
  background: linear-gradient(180deg, #f3f8fd 0%, #eef5fb 100%);
  box-shadow: 0 12px 28px rgba(31, 106, 165, 0.12);
}

.job-item-header,
.job-item-meta,
.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.job-item-header {
  margin-bottom: 6px;
}

.job-name {
  font-size: 14px;
  font-weight: 600;
  color: #18324f;
  line-height: 1.25;
}

.job-id,
.job-time,
.detail-meta {
  color: #6a7480;
  font-size: 12px;
}

.job-item-meta {
  margin-top: 6px;
}

.job-item > div:not(.job-item-header):not(.job-item-meta) {
  font-size: 13px;
  line-height: 1.3;
}

.detail-header {
  margin-bottom: 12px;
  flex: 0 0 auto;
}

.detail-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex: 0 0 auto;
}

.tab-btn {
  border: 1px solid #d5dfeb;
  background: #f8fafc;
  color: #42556a;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
}

.tab-btn.active {
  background: #1f3a5f;
  border-color: #1f3a5f;
  color: #fff;
}

.tab-panel {
  display: none;
  min-height: 0;
  flex: 1 1 auto;
}

.tab-panel.active {
  display: flex;
}

.status {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.status-pending {
  background: #fff3cd;
  color: #856404;
}
.status-submitted {
  background: #cce5ff;
  color: #004085;
}
.status-running {
  background: #d4edda;
  color: #155724;
}
.status-complete {
  background: #d1ecf1;
  color: #0c5460;
}
.status-failed {
  background: #f8d7da;
  color: #721c24;
}
.status-stopped {
  background: #e2e3e5;
  color: #383d41;
}

.result {
  margin-top: 12px;
  padding: 10px;
  background: #eef5fb;
  border-radius: 10px;
  font-size: 12px;
}

pre {
  background: #f7f8fa;
  padding: 14px;
  border-radius: 14px;
  overflow-x: auto;
  font-size: 12px;
  overflow-y: auto;
  min-height: 0;
  height: 100%;
  width: 100%;
  border: 1px solid #e3e8ef;
}

.logs {
  background: #15263d;
  color: #c5f3cb;
  font-family: "Courier New", monospace;
}

.actions button {
  margin-right: 4px;
  margin-bottom: 4px;
}

code {
  font-family: "Courier New", monospace;
  color: #30557a;
}

.detail-panel {
  display: flex;
  flex-direction: column;
}

#selected-job-title {
  margin-bottom: 6px;
}

#selected-job-meta {
  line-height: 1.4;
}

@media (max-width: 1100px) {
  html,
  body {
    overflow: auto;
  }

  body {
    display: block;
  }

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

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

  .workspace-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  main {
    min-height: auto;
  }

  .sidebar-column {
    grid-template-rows: auto auto;
  }

  .job-list,
  pre {
    max-height: 45vh;
  }
}

@media (max-width: 720px) {
  main {
    padding: 12px;
  }

  header {
    padding: 12px 14px;
    flex-direction: column;
    align-items: flex-start;
  }

  .card {
    padding: 18px;
  }

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

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

  .detail-header,
  .job-item-header,
  .job-item-meta {
    flex-direction: column;
  }

  .detail-actions,
  .detail-tabs {
    flex-wrap: wrap;
  }
}

/* Result file list */
.results-file-list {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.result-file-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.result-file-row:last-child {
  border-bottom: none;
}
.result-file-name {
  flex: 1;
  font-family: monospace;
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.result-file-size {
  color: var(--secondary-text);
  font-size: 0.8rem;
  min-width: 70px;
  text-align: right;
}
.result-file-row .btn {
  text-decoration: none;
}

/* Command panel */
.commands-section {
  padding: 16px;
  overflow-y: auto;
}
.commands-section h3 {
  margin: 16px 0 8px;
  font-size: 0.95rem;
  color: var(--secondary-text);
}
.commands-section h3:first-child {
  margin-top: 0;
}
.cmd-quick-buttons {
  display: flex;
  gap: 12px;
}
.cmd-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: end;
}
.cmd-form .form-row {
  flex: 1;
  min-width: 120px;
}
.cmd-form .btn {
  align-self: end;
}
.cmd-history {
  max-height: 200px;
  overflow-y: auto;
}
.cmd-entry {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.cmd-entry-type {
  font-weight: 600;
  min-width: 80px;
}
.cmd-entry-params {
  flex: 1;
  font-family: monospace;
  font-size: 0.8rem;
  color: var(--secondary-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cmd-entry-status {
  min-width: 60px;
  text-align: center;
}
.cmd-entry-time {
  color: var(--secondary-text);
  font-size: 0.8rem;
  min-width: 140px;
  text-align: right;
}
