.ketcher-frame-wrap {
  width: 100%;
}

#ifKetcher {
  width: 100%;
  border: 0;
  display: block;
  height: 70vh;
  max-height: 800px;
}

.ketcher-example-banner {
  margin: 0.35rem 0 0.75rem;
  padding: 0 0.5rem;
  color: #9a9a9a;
  font-size: 0.92rem;
  line-height: 1.45;
  text-align: center;
  background: transparent;
}

.ketcher-example-banner.is-hidden {
  display: none;
}

.smiles-input {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  width: 100%;
  margin: 10px 0px;
  font-size: 16px;
}

.smiles-input button {
  flex: 0 0 auto;
  padding: 5px 10px;
  font: inherit;
}

.smiles-input #smiles-input {
  flex: 1 1 auto;
  padding: 5px;
  margin-left: auto;
  flex-direction: column;
  align-items: flex-end;
  font: inherit;
}

.step-runner-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 12px 0;
  padding: 12px 14px;
  border: 1px solid #dbe4f0;
  border-radius: 10px;
  background: linear-gradient(180deg, #f8fbff 0%, #f3f7fc 100%);
  color: #1e293b;
}

.step-runner-header {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  align-items: baseline;
}

.step-runner-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.step-runner-title {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}

.step-runner-note,
.step-runner-hint {
  font-size: 12px;
  color: #64748b;
}

.step-runner-toggle {
  margin-left: auto;
  padding: 4px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #334155;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.step-runner-toggle:hover {
  border-color: #9fb6ca;
}

.step-runner-toggle:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.step-runner-panel.is-collapsed .step-runner-content {
  display: none;
}

.step-runner-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

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

.step-runner-submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.step-runner-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 160px;
  font-size: 13px;
}

.step-runner-field > span {
  font-weight: 600;
  color: #334155;
}

.step-runner-field select,
.step-runner-field input[type="file"] {
  padding: 6px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #0f172a;
  font: inherit;
}

.step-runner-select {
  appearance: none;
  -webkit-appearance: none;
  border-radius: 6px;
  border: 1px solid #d8e0e7;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5 7.5L10 12.5L15 7.5' stroke='%23475569' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  padding: 8px 34px 8px 12px;
  cursor: pointer;
}

.step-runner-select:hover {
  border-color: #9fb6ca;
}

.step-runner-select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.step-runner-field-wide {
  min-width: 240px;
}

.step-runner-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.step-runner-mode-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  padding: 8px 11px;
  border: 1px solid #d8e0e7;
  border-radius: 6px;
  background: #fff;
  color: #475569;
  font-size: 12px;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}

.step-runner-mode-option:hover {
  border-color: #9fb6ca;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
}

.step-runner-mode-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.step-runner-mode-option:has(input[type="radio"]:checked) {
  background: #e8f2ff;
  border-color: #2563eb;
  color: #1d4ed8;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.14);
}

.step-runner-file.is-hidden {
  display: none;
}

.step-runner-hint {
  line-height: 1.4;
}

.calc-progress {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid #dbe4f0;
  border-radius: 10px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  color: #0f172a;
}

.calc-progress.failed {
  border-color: #fca5a5;
  background: linear-gradient(180deg, #fffafa 0%, #fff1f1 100%);
}

.calc-progress-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 12px;
  align-items: baseline;
}

.calc-progress-title {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
}

.calc-progress-meta {
  font-size: 12px;
  color: #64748b;
}

.calc-progress-bar {
  position: relative;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #dbe4f0;
}

.calc-progress-fill {
  position: absolute;
  inset: 0;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(34, 197, 94, 0.28) 0%, rgba(14, 165, 233, 0.28) 100%);
  transition: width 0.35s ease;
}

.calc-progress-bar-sections {
  position: relative;
  z-index: 1;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  align-items: stretch;
  height: 100%;
  gap: 2px;
}

.calc-progress-bar-section {
  position: relative;
  background: rgba(148, 163, 184, 0.35);
  overflow: hidden;
}

.calc-progress-bar-section-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #22c55e 0%, #0ea5e9 100%);
  transition: width 0.3s ease;
}

.calc-progress-fill.is-indeterminate {
  width: 72%;
  opacity: 0.85;
  animation: calc-progress-pulse 1.2s ease-in-out infinite;
}

.calc-progress-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
}

.calc-progress-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
  color: #475569;
}

.calc-progress-step-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #cbd5e1;
  color: #0f172a;
  font-size: 12px;
  font-weight: 700;
}

.calc-progress-step-body {
  min-width: 0;
}

.calc-progress-step-label {
  font-size: 13px;
  font-weight: 600;
  color: inherit;
}

.calc-progress-step-state {
  margin-top: 2px;
  font-size: 11px;
  color: #94a3b8;
}

.calc-progress-step.is-active {
  border-color: #38bdf8;
  background: #eff8ff;
  color: #0f172a;
}

.calc-progress-step.is-active .calc-progress-step-index {
  background: #0ea5e9;
  color: #fff;
}

.calc-progress-step.is-complete {
  border-color: #86efac;
  background: #f0fdf4;
  color: #14532d;
}

.calc-progress-step.is-complete .calc-progress-step-index {
  background: #22c55e;
  color: #fff;
}

.calc-progress-error {
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff5f5;
  border: 1px solid #fecaca;
  color: #b91c1c;
  font-size: 13px;
  line-height: 1.4;
}

@keyframes calc-progress-pulse {
  0% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0.55;
  }
}

.ketcher-result {
  display: flex;
  flex-wrap: wrap-reverse;
  gap: 5px;
  width: 100%;
  margin: 5px 0px 10px;
}

.ketcher-result #ketcher-prompt {
  flex: 1 1 200px;
  margin: 0px;
  padding: 10px;
  word-wrap: break-word;
  word-break: break-all;
}

.ketcher-result button {
  flex: 0 0 auto;
  margin-left: auto;
  align-self: self-start;
}

#calc-result-container.disabled {
  display: none;
}

.table-container {
  overflow-x: auto;
  width: 100%;
  border: 1px solid #dbe4f0;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
}

.results-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  table-layout: fixed;
  border: 0;
}

.results-table th,
.results-table td {
  vertical-align: top;
  padding: 9px 12px;
  border-bottom: 1px solid #e2e8f0;
  border-right: 1px solid #edf2f7;
  text-align: center;
  line-height: 1.4;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.results-table th:last-child,
.results-table td:last-child {
  border-right: 0;
}

.results-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: normal;
  word-break: normal;
  border-bottom: 1px solid #cfd8e3;
}

.results-table tbody tr:nth-child(even) {
  background: #fcfdff;
}

.results-table tbody tr:hover {
  background: #f3f8ff;
}

.results-table tbody tr:last-child td {
  border-bottom: 0;
}

.results-table .checkbox-col {
  width: 52px;
  min-width: 52px;
  max-width: 52px;
  white-space: nowrap;
  text-align: center;
  padding: 0 6px;
  box-sizing: border-box;
  overflow: hidden;
}

.results-table th.checkbox-col,
.results-table td.checkbox-col {
  width: 52px;
  min-width: 52px;
  max-width: 52px;
}

.results-table col.col-checkbox {
  width: 52px;
}

.results-table col.col-smiles {
  width: 28%;
}

.results-table col.col-data-narrow {
  width: 4.75rem;
}

.results-table col.col-data {
  width: 11%;
}

.results-table col.col-status {
  width: 42%;
  min-width: 17rem;
}

.results-table .checkbox-col input[type="checkbox"] {
  display: block;
  margin: 0 auto !important;
}

.results-table .smiles-cell {
  text-align: center;
  max-width: none;
  min-width: 0;
  white-space: normal;
  word-break: normal;
  overflow-wrap: anywhere;
}

.results-table .data-cell {
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
  min-width: 0;
}

.results-table .data-cell-narrow {
  width: 1%;
  max-width: 5.5rem;
  padding-left: 8px;
  padding-right: 8px;
  font-variant-numeric: tabular-nums;
}

.results-table .status-cell {
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
  vertical-align: top;
  /* Do not use min-width: 0 here — with table-layout:fixed it lets this column
     collapse and hides SDF controls; respect col-status / intrinsic content. */
  min-width: 10rem;
  max-width: 100%;
  overflow-x: visible;
  box-sizing: border-box;
}

.results-table .status-cell .result-retry-btn {
  margin-left: 0;
  margin-top: 0.35rem;
}

.results-table thead .status-cell {
  text-align: center;
  vertical-align: middle;
}

/* Success row: label above SDF actions so buttons are not squeezed horizontally */
.status-success-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.45rem;
  width: 100%;
  min-width: min-content;
  overflow: visible;
}

.results-table .status-cell .status-success-block {
  align-items: stretch;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.results-table .status-cell .status-success-label {
  align-self: center;
  text-align: center;
}

.status-success-label {
  font-weight: 600;
  white-space: nowrap;
}

.sdf-actions-loading {
  font-size: 11px;
  color: #94a3b8;
}

.sdf-no-saved,
.sdf-fetch-error {
  display: block;
  max-width: 18rem;
  margin: 0 auto;
  font-size: 11px;
  line-height: 1.35;
  color: #64748b;
  text-align: center;
}

.sdf-fetch-error {
  color: #b45309;
}

.result-card-status .status-success-block {
  max-width: 100%;
}

.results-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
  width: 100%;
}

.result-card {
  border: 1px solid #d9e3e0;
  border-radius: 10px;
  background: #ffffff;
  padding: 12px;
  min-width: 0;
  overflow: hidden;
}

.result-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: nowrap;
  gap: 8px;
  margin-bottom: 8px;
}

.result-card-title {
  font-weight: 700;
  font-size: 0.9rem;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-card-head .result-retry-btn {
  margin-left: auto;
  flex: 0 0 auto;
}

.result-card-retry {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: #4b5563;
  margin-left: auto;
  white-space: nowrap;
}

.result-card-retry input[type="checkbox"] {
  margin: 0;
}

.result-retry-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid #fca5a5;
  background: #fff1f2;
  color: #b91c1c;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.result-retry-btn:hover {
  background: #ffe4e6;
}

.result-retry-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.result-card-smiles {
  margin-bottom: 10px;
}

.result-card-smiles .text-highlight {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.result-card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.result-card-row {
  display: grid;
  grid-template-columns: minmax(120px, 36%) 1fr;
  gap: 8px;
  align-items: baseline;
}

.result-card-key {
  font-size: 0.78rem;
  color: #6b7280;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-card-value {
  font-size: 0.86rem;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
}

.result-card-status {
  margin-top: 10px;
  font-size: 0.82rem;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

@media (max-width: 700px) {
  .results-cards {
    grid-template-columns: 1fr;
  }

  .result-card-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}

.results-table input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
}

/* For columns that should wrap */
.results-table .wrap-column {
  white-space: normal;
  word-break: break-word;
}

.page-link {
  display: inline-block;
  padding: 4px 8px;
  margin: 0 4px;
  border: 1px solid #ddd;
  border-radius: 4px;
  text-decoration: none;
  color: #333;
  cursor: pointer;
  transition: all 0.3s ease;
}

.page-link:hover {
  background-color: #f5f5f5;
}

.page-link.active {
  background-color: #34dbb7;
  color: white;
  border-color: #34dbb7;
}

.page-ellipsis {
  display: inline-block;
  padding: 8px;
  color: #666;
}

#page-list {
  text-align: left;
  margin: 10px 0;
  user-select: none;
}

/* Retry failed jobs button */
.page-link.retry-failed {
  background-color: #f0f0f0;
  border-color: #ccc;
  color: #666;
}

.page-link.retry-failed:hover {
  background-color: #e0e0e0;
}

.page-link.retry-failed.has-selection {
  background-color: #ff6b6b;
  border-color: #ff5252;
  color: white;
}

.page-link.retry-failed.has-selection:hover {
  background-color: #ff5252;
}

.page-link.retry-failed.loading {
  background-color: #ffa726;
  border-color: #ff9800;
  color: white;
  cursor: wait;
}

/* Checkbox styling */
.retry-checkbox {
  cursor: pointer;
  width: 16px;
  height: 16px;
}

#select-all-failed {
  cursor: pointer;
  width: 16px;
  height: 16px;
}

/* Highlight failed rows */
tr[data-status="4"] {
  background-color: #fff5f5;
}

tr[data-status="4"]:hover {
  background-color: #ffe0e0;
}

.sdf-step-toggles {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  margin: 12px 0;
  background: linear-gradient(180deg, #f8fafc 0%, #fdfefe 100%);
  border: 1px solid #dbe3ea;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
  font-family: Arial, sans-serif;
  font-size: 13px;
  color: #334155;
}

.sdf-step-toggles.is-hidden {
  visibility: hidden;
  pointer-events: none;
}
.sdf-step-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 12px;
}
.sdf-step-label { font-weight: 700; color: #0f172a; }
.sdf-step-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.sdf-step-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  padding: 8px 9px;
  border: 1px solid #d8e0e7;
  border-radius: 6px;
  background: #fff;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.sdf-step-option:hover {
  border-color: #9fb6ca;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
}
.sdf-step-option input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}
.sdf-step-option:has(input[type="checkbox"]:checked) {
  background: #e8f2ff;
  border-color: #2563eb;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.14);
}
.sdf-step-all:has(input[type="checkbox"]:checked) {
  background: linear-gradient(135deg, #dbeafe 0%, #e0f2fe 100%);
  border-color: #0ea5e9;
}
.sdf-step-option:has(input[type="checkbox"]:checked) .sdf-step-name,
.sdf-step-option:has(input[type="checkbox"]:checked) > span:first-of-type {
  color: #1d4ed8;
}
.sdf-step-option:has(input[type="checkbox"]:checked) .sdf-step-name {
  font-weight: 700;
}
.sdf-step-name {
  color: #475569;
  font-size: 12px;
  font-weight: 600;
}
.sdf-step-hint {
  font-size: 11px;
  color: #64748b;
  font-style: italic;
}

/* ── SDF buttons inside table ── */
.sdf-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.5rem;
  width: 100%;
  max-width: 100%;
  min-width: min-content;
  margin: 0;
  vertical-align: middle;
  overflow: visible;
}

.results-table .status-cell .sdf-actions {
  min-width: 0;
  max-width: 100%;
  align-self: stretch;
  overflow-x: visible;
  box-sizing: border-box;
}

/* One row per step: download + view, rows stacked with clear spacing (no grid overlap) */
.sdf-actions:has(.sdf-step-group) {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.65rem;
  width: 100%;
}

.sdf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.38rem 0.7rem;
  font-size: 0.8rem;
  font-family: Arial, sans-serif;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: none;
  border-radius: 0.45rem;
  border: 1px solid;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease;
  line-height: 1.2;
}

.sdf-download-btn {
  color: #2563eb !important;
  border-color: rgba(37, 99, 235, 0.25) !important;
}

.sdf-download-btn:hover {
  background: #dbeafe !important;
}

.sdf-view-btn {
  min-width: 2.5rem;
  font-size: 0.95rem;
  padding-left: 0.55rem;
  padding-right: 0.55rem;
  color: #16a34a !important;
  border-color: rgba(22, 163, 74, 0.25) !important;
}

.sdf-view-btn:hover {
  background: #dcfce7 !important;
}

/* Per-step download + view pair (no outer box — only button chrome) */
.sdf-step-group {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 0.65rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.results-table .status-cell .sdf-step-group {
  justify-content: center;
}

/* Same vertical box so download + view line up cleanly */
.sdf-step-group .sdf-btn {
  min-height: 2.35rem;
  box-sizing: border-box;
  align-self: center;
}

.sdf-step-group .sdf-view-btn {
  font-size: 0.8rem;
  line-height: 1;
}

@media (max-width: 700px) {
  .sdf-step-options {
    flex-direction: column;
    align-items: stretch;
  }

  .sdf-step-option {
    justify-content: flex-start;
    border-radius: 12px;
  }
}
