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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f5f6fa;
  color: #1a1a2e;
  min-height: 100vh;
}

header {
  background: #1a1a2e;
  color: #fff;
  padding: 18px 32px;
  display: flex;
  align-items: baseline;
  gap: 16px;
}
header h1 { font-size: 1.3rem; font-weight: 700; letter-spacing: 0.02em; }
header span { font-size: 0.85rem; color: #8899bb; }

main {
  max-width: 1000px;
  margin: 32px auto;
  padding: 0 24px 64px;
}

/* ── Config panels ── */
.config-panel {
  background: #fff;
  border: 1px solid #e0e4f0;
  border-radius: 10px;
  padding: 22px 26px;
  margin-bottom: 16px;
}

.step-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.step-label-row .step-label {
  margin-bottom: 0;
}

.step-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #4f6ef7;
  margin-bottom: 14px;
}

.row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  align-items: flex-end;
}

label.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.84rem;
  font-weight: 500;
  color: #444;
  margin-bottom: 14px;
}
.dataset-config-fields label.field,
.dataset-config-textareas label.field,
label.field.inline-field {
  margin-bottom: 0;
}
.field-hint {
  font-weight: 400;
  color: #999;
  font-size: 0.78rem;
}
.required-hint {
  color: #4f6ef7;
}

select, input[type="file"] {
  font-size: 0.88rem;
  border: 1px solid #cdd3e0;
  border-radius: 6px;
  padding: 7px 10px;
  background: #fff;
  color: #1a1a2e;
  min-width: 160px;
}
select:focus { outline: 2px solid #4f6ef7; border-color: transparent; }

/* ── Metric toggles ── */
.toggle-columns {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0 24px;
}
.toggle-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toggle-section-label {
  font-size: 0.78rem;
  color: #666;
  font-weight: 600;
}
.toggle-col label.sub {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.83rem;
  color: #333;
  cursor: pointer;
  padding-left: 4px;
}
.toggle-col input[type="checkbox"] { accent-color: #4f6ef7; width: 14px; height: 14px; flex-shrink: 0; }

/* ── Actions panel ── */
.actions-row {
  display: flex;
  gap: 0;
  align-items: stretch;
}

.action-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.action-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  flex-shrink: 0;
  font-size: 0.78rem;
  color: #bbb;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.action-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #1a1a2e;
}
.action-desc {
  font-size: 0.82rem;
  color: #666;
  line-height: 1.5;
  flex: 1;
}
.action-desc code {
  background: #f0f2f8;
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 0.8rem;
  color: #333;
}

#gen-btn {
  align-self: flex-start;
  background: #1a1a2e;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 9px 20px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
#gen-btn:hover { background: #2e2e50; }

.load-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.file-btn {
  display: inline-block;
  background: #4f6ef7;
  color: #fff;
  border-radius: 6px;
  padding: 9px 20px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.file-btn:hover { background: #3a56e0; }
input[type="file"]#result-file { display: none; }
input[type="file"]#syn-file-input { display: none; }

/* ── Generate command panel ── */
.gen-panel {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid #e8eaf2;
  position: relative;
}
.gen-panel-label {
  font-size: 0.8rem;
  color: #888;
  margin-bottom: 10px;
}
.gen-panel pre {
  background: #1a1a2e;
  color: #c8d6ff;
  border-radius: 8px;
  padding: 16px 20px;
  font-size: 0.82rem;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.copy-btn {
  margin-top: 8px;
  background: transparent;
  border: 1px solid #cdd3e0;
  border-radius: 5px;
  padding: 5px 14px;
  font-size: 0.78rem;
  color: #555;
  cursor: pointer;
}
.copy-btn:hover { background: #f0f2f8; }

/* ── Results ── */
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.results-header h2 { font-size: 1.3rem; font-weight: 700; }
.results-subheader { font-size: 1rem; font-weight: 700; color: #2c2f3a; margin: 20px 0 10px; }
#summary-bar .results-subheader { margin-top: 0; }
.download-btn {
  background: transparent;
  border: 1px solid #cdd3e0;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 0.8rem;
  color: #555;
  cursor: pointer;
}
.download-btn:hover { background: #f0f2f8; }

.summary-bar {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.summary-card {
  flex: 1;
  min-width: 130px;
  background: #fff;
  border: 1px solid #e0e4f0;
  border-radius: 10px;
  padding: 16px 18px;
  text-align: center;
}
.summary-card .cat-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #aaa;
  margin-bottom: 6px;
}
.summary-card .score { font-size: 1.8rem; font-weight: 700; color: #1a1a2e; }
.summary-card .score.na { color: #ccc; font-size: 1.2rem; }

.summary-card.score-high { background: #edfaf3; border-color: #6fcf97; }
.summary-card.score-high .cat-label { color: #27ae60; }
.summary-card.score-high .score { color: #1e8449; }

.summary-card.score-mid { background: #fefae9; border-color: #f0c040; }
.summary-card.score-mid .cat-label { color: #b7950b; }
.summary-card.score-mid .score { color: #9a7d0a; }

.summary-card.score-low { background: #fdf0ef; border-color: #e07070; }
.summary-card.score-low .cat-label { color: #c0392b; }
.summary-card.score-low .score { color: #a93226; }

.section {
  background: #fff;
  border: 1px solid #e0e4f0;
  border-radius: 10px;
  margin-bottom: 12px;
  overflow: hidden;
}
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 18px;
  cursor: pointer;
  user-select: none;
}
.section-header:hover { background: #fafbfd; }
.section-header-text { display: flex; flex-direction: column; gap: 2px; }
.section-header h3 { font-size: 0.92rem; font-weight: 600; }
.section-desc { font-size: 0.77rem; font-weight: 400; color: #999; }
.section-header .chevron { font-size: 0.78rem; color: #bbb; transition: transform 0.2s; }
.section.open .chevron { transform: rotate(180deg); }
.section-body { display: none; border-top: 1px solid #e8eaf2; }
.section.open .section-body { display: block; }

.subgroup-header {
  padding: 9px 18px 6px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #bbb;
  background: #fafbfd;
  border-bottom: 1px solid #f0f2f8;
}

table.metric-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; table-layout: fixed; }
table.metric-table th {
  padding: 7px 18px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #888;
  text-align: right;
  border-bottom: 2px solid #e8eaf2;
  background: #fafbfd;
}
table.metric-table th:first-child { text-align: left; }
table.metric-table th:not(:first-child) { width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.metric-table td:not(:first-child) { width: 110px; }
table.metric-table td {
  padding: 8px 18px;
  border-bottom: 1px solid #f0f2f8;
  color: #333;
}
table.metric-table tr:last-child td { border-bottom: none; }
.metric-arrow { font-size: 0.75rem; color: #bbb; margin-right: 5px; }
table.metric-table td:not(:first-child) {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  min-width: 80px;
}

.badge-na {
  display: inline-block;
  background: #f0f0f5;
  color: #bbb;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.73rem;
  font-weight: 600;
}

.metric-green  { color: #1e8449; font-weight: 600; }
.metric-yellow { color: #9a7d0a; font-weight: 600; }
.metric-red    { color: #a93226; font-weight: 600; }

/* ── Dataset config section ── */
.dataset-config-section {
  margin-top: 16px;
}
.dataset-config-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.dataset-config-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #666;
}
label.field.inline-field {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 500;
  color: #444;
}
label.field.inline-field select {
  min-width: 130px;
}
.inline-field-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.reset-btn {
  background: transparent;
  border: 1px solid #cdd3e0;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.8rem;
  color: #666;
  cursor: pointer;
  white-space: nowrap;
}
.reset-btn:hover { background: #f0f2f8; }
.dataset-config-fields {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px 16px;
  align-items: end;
}
.dataset-config-fields input[type="text"],
input[type="password"] {
  font-size: 0.85rem;
  border: 1px solid #cdd3e0;
  border-radius: 6px;
  padding: 6px 9px;
  background: #fff;
  color: #1a1a2e;
  width: 100%;
}
.dataset-config-fields input[type="text"]:focus,
input[type="password"]:focus {
  outline: 2px solid #4f6ef7;
  border-color: transparent;
}
.dataset-config-fields textarea {
  font-size: 0.85rem;
  font-family: inherit;
  border: 1px solid #cdd3e0;
  border-radius: 6px;
  padding: 6px 9px;
  background: #fff;
  color: #1a1a2e;
  width: 100%;
  resize: vertical;
}
.dataset-config-fields textarea:focus {
  outline: 2px solid #4f6ef7;
  border-color: transparent;
}
.dataset-config-textareas {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px 16px;
  margin-top: 10px;
}
.dataset-config-textareas textarea {
  font-size: 0.82rem;
  font-family: monospace;
  border: 1px solid #cdd3e0;
  border-radius: 6px;
  padding: 7px 9px;
  background: #fff;
  color: #1a1a2e;
  width: 100%;
  resize: vertical;
}
.dataset-config-textareas textarea:focus {
  outline: 2px solid #4f6ef7;
  border-color: transparent;
}

/* ── CSV format note ── */
.docs-section-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.docs-section-heading {
  font-size: 0.9rem;
  font-weight: 600;
  color: #1a1a2e;
  margin-bottom: 2px;
}

.docs-section-body p {
  font-size: 0.85rem;
  color: #555;
  line-height: 1.6;
  margin: 0;
}

.docs-link {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.8rem;
  color: #4f6ef7;
  text-decoration: none;
  font-weight: 500;
}
.docs-link:hover { text-decoration: underline; }

.docs-note {
  margin-bottom: 16px;
  padding: 11px 14px;
  background: #f5f7ff;
  border: 1px solid #dde2f5;
  border-radius: 7px;
  font-size: 0.81rem;
  color: #555;
  line-height: 1.6;
}
.docs-note-title {
  display: block;
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #4f6ef7;
  margin-bottom: 4px;
}
.docs-note code {
  background: #e8edff;
  color: #3a56e0;
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 0.8rem;
  font-weight: 600;
}
.input-format-example {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
  margin-bottom: 8px;
}
.col-tag {
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  font-family: monospace;
}
.col-tag.required {
  background: #dde8ff;
  color: #2a45c0;
  border: 1px solid #b0c0f0;
}
.col-tag.optional {
  background: #f0f2f8;
  color: #777;
  border: 1px dashed #c0c8e0;
}
.col-tag.attr-key-tag {
  background: #f5f0f8;
  color: #8a6fa0;
  border-color: #c8b8d8;
}

.error-msg {
  background: #fff0f0;
  border: 1px solid #f8c8c8;
  border-radius: 8px;
  padding: 12px 16px;
  color: #c0392b;
  font-size: 0.86rem;
  margin-bottom: 14px;
}

/* ── Synthetic datasets (Step 1) ── */
.synthetic-datasets-section {
  margin-top: 18px;
}

.synthetic-datasets-label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.84rem;
  font-weight: 500;
  color: #444;
  margin-bottom: 10px;
}

.library-add-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.library-label-input {
  flex: 1;
  min-width: 200px;
  font-size: 0.85rem;
  border: 1px solid #cdd3e0;
  border-radius: 6px;
  padding: 7px 10px;
  background: #fff;
  color: #1a1a2e;
}
.library-label-input:focus {
  outline: 2px solid #4f6ef7;
  border-color: transparent;
}

.dataset-library-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 28px;
  align-items: center;
}

.library-empty {
  font-size: 0.82rem;
  color: #bbb;
  font-style: italic;
}

.dataset-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: #f5f6fa;
  border: 1px solid #e0e4f0;
  border-radius: 20px;
  padding: 5px 10px 5px 8px;
}

.chip-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.chip-label {
  font-size: 0.84rem;
  font-weight: 500;
  color: #333;
}

.chip-filename {
  font-size: 0.78rem;
  color: #999;
  font-family: monospace;
}

.chip-remove {
  background: none;
  border: none;
  color: #bbb;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 1px;
  display: flex;
  align-items: center;
}
.chip-remove:hover { color: #e74c3c; }

/* ── Per-synthetic result loaders (Step 3) ── */
.syn-results-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.syn-result-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid #f0f2f8;
}
.syn-result-row:last-child { border-bottom: none; }

.syn-result-label {
  flex: 1;
  font-size: 0.84rem;
  font-weight: 500;
  color: #333;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.syn-result-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.file-btn-sm {
  display: inline-block;
  background: transparent;
  color: #4f6ef7;
  border: 1px solid #4f6ef7;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.file-btn-sm:hover { background: #f0f2ff; }

.syn-result-loaded {
  font-size: 0.76rem;
  color: #27ae60;
  font-family: monospace;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.view-btn {
  background: transparent;
  border: 1px solid #cdd3e0;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #555;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.view-btn:hover { background: #f0f2f8; }

/* ── Multi-dataset summary ── */
.summary-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.summary-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 14px;
  border-bottom: 1px solid #f0f2f8;
}
.summary-group:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

#summary-bar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
}

.summary-group-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #555;
}

.summary-group-label-left {
  display: flex;
  align-items: center;
  gap: 7px;
}

.summary-group-swatch {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ── Compare section ── */
.compare-controls {
  display: flex;
  gap: 32px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.compare-controls-left { flex: 1; min-width: 200px; }
.compare-section-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #666;
  margin-bottom: 10px;
}
.compare-checkboxes { display: flex; flex-wrap: wrap; gap: 10px 20px; }
.compare-cb-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.84rem;
  cursor: pointer;
  color: #333;
  user-select: none;
}
.compare-cb-label input[type="checkbox"] { accent-color: #4f6ef7; width: 14px; height: 14px; flex-shrink: 0; }
.compare-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}
.compare-controls-right {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}
#compare-error-area:not(:empty) { margin-top: 14px; }
.compare-axes-label {
  font-size: 0.82rem;
  color: #555;
}
.compare-axes-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
#compare-plot-btn {
  background: #1a1a2e;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 9px 22px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
#compare-plot-btn:hover { background: #2e2e50; }
.chart-container {
  max-width: 500px;
  margin: 24px auto 0;
}

/* ── LLM settings ── */
.llm-settings {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid #e0e4f0;
}
.llm-settings-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #1a1a2e;
  margin-bottom: 4px;
}
.llm-settings-hint {
  font-size: 0.78rem;
  color: #666;
  margin-bottom: 12px;
  line-height: 1.5;
}
.llm-settings-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Evaluation spinner ── */
.eval-spinner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 0.85rem;
  color: #4f6ef7;
}
.spinner-icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid #c5cdf9;
  border-top-color: #4f6ef7;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
#run-btn {
  display: inline-block;
  background: #27ae60;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 9px 20px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
  align-self: flex-start;
}
#run-btn:hover { background: #1e8449; }
#run-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
