* {
  box-sizing: border-box;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  margin: 0;
  padding: 0;
  background: #f6f7f9;
  color: #1a1a1a;
  line-height: 1.5;
}

header {
  background: #1e293b;
  color: #f8fafc;
  padding: 1rem 1.5rem 1.25rem;
}

header h1 {
  margin: 0;
  font-size: 1.35rem;
}

header h1 a {
  color: inherit;
  text-decoration: none;
}

.tagline {
  margin: 0.25rem 0 0.75rem;
  opacity: 0.85;
  font-size: 0.9rem;
}

nav a {
  color: #cbd5e1;
  margin-right: 1rem;
  text-decoration: none;
  font-size: 0.9rem;
}

nav a.active,
nav a:hover {
  color: #fff;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

section {
  background: #fff;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

section h2 {
  margin-top: 0;
  font-size: 1.1rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  text-align: left;
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid #e2e8f0;
}

th {
  font-weight: 600;
  color: #475569;
}

tr:hover td {
  background: #f8fafc;
}

a.project-link {
  color: #1d4ed8;
  text-decoration: none;
  font-weight: 500;
}

a.project-link:hover {
  text-decoration: underline;
}

.status-completed { color: #15803d; font-weight: 500; }
.status-running { color: #1d4ed8; font-weight: 500; }
.status-pending { color: #a16207; font-weight: 500; }
.status-failed { color: #b91c1c; font-weight: 500; }
.status-cancelled { color: #64748b; font-weight: 500; }

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}

/* Author `display` rules outrank the UA sheet's `[hidden] { display: none }`,
   so elements toggled via the hidden attribute stay visible without this. */
[hidden] {
  display: none !important;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: #475569;
}

label.checkbox-label {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

label.checkbox-label input[type="checkbox"] {
  width: auto;
  padding: 0;
}

input,
select,
button,
textarea {
  font: inherit;
  padding: 0.4rem 0.6rem;
}

textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85rem;
  resize: vertical;
  min-height: 4.5rem;
}

button,
.btn {
  background: #1e293b;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  padding: 0.45rem 0.85rem;
  text-decoration: none;
  display: inline-block;
  font-size: 0.9rem;
}

button:hover,
.btn:hover {
  background: #334155;
}

button.secondary {
  background: #e2e8f0;
  color: #1e293b;
}

button.secondary:hover {
  background: #cbd5e1;
}

form {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}

.progress-bar {
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
  min-width: 80px;
}

.progress-bar span {
  display: block;
  height: 100%;
  background: #1d4ed8;
}

.chart-wrap {
  position: relative;
  height: 320px;
  margin-bottom: 1rem;
}

.module-graph-wrap {
  position: relative;
  height: 420px;
  margin: 0.75rem 0 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #f8fafc;
}

.lineage-graph-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 38%);
  gap: 1rem;
  align-items: start;
  margin: 0.75rem 0 1rem;
}

.lineage-graph-layout .module-graph-wrap {
  margin: 0;
  height: 480px;
}

@media (max-width: 960px) {
  .lineage-graph-layout {
    grid-template-columns: 1fr;
  }
}

.source-panel {
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fff;
  padding: 0.75rem;
  max-height: 520px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.source-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.source-file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 140px;
  overflow: auto;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
}

.source-file-list li {
  margin: 0;
  border-bottom: 1px solid #f1f5f9;
}

.source-file-list li:last-child {
  border-bottom: none;
}

.source-file-btn {
  width: 100%;
  text-align: left;
  background: transparent;
  color: #0f172a;
  border: none;
  border-radius: 0;
  padding: 0.35rem 0.5rem;
  font-size: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.source-file-btn:hover,
.source-file-btn.active {
  background: #e2e8f0;
}

.source-content {
  margin: 0;
  flex: 1;
  min-height: 180px;
  max-height: 280px;
  overflow: auto;
  background: #0f172a;
  color: #e2e8f0;
  padding: 0.75rem;
  border-radius: 4px;
  font-size: 0.75rem;
  line-height: 1.45;
  white-space: pre;
}

.module-graph-hint {
  color: #64748b;
  font-size: 0.85rem;
  margin: 0 0 0.5rem;
}

.module-graph-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  margin: 0 0 0.65rem;
}

.module-graph-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: #334155;
  cursor: pointer;
  user-select: none;
}

.module-graph-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  font-size: 0.8rem;
  color: #64748b;
}

.module-graph-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.compare-graph {
  height: 520px;
}

.compare-impact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-top: 1rem;
}

@media (max-width: 960px) {
  .compare-impact-grid {
    grid-template-columns: 1fr;
  }
}

.change-added { color: #15803d; font-weight: 600; }
.change-removed { color: #b91c1c; font-weight: 600; }
.change-changed { color: #b45309; font-weight: 600; }
.change-unchanged { color: #64748b; }

.legend-swatch.legend-added { background: #bbf7d0; border: 1px solid #15803d; }
.legend-swatch.legend-removed { background: #fecaca; border: 1px solid #b91c1c; }
.legend-swatch.legend-changed { background: #fde68a; border: 1px solid #b45309; }
.legend-swatch.legend-unchanged { background: #e2e8f0; border: 1px solid #94a3b8; }

.legend-swatch {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 999px;
  border: 1px solid transparent;
}

.legend-module {
  background: #93c5fd;
  border-color: #1e3a8a;
}

.legend-external {
  background: #fff7ed;
  border-color: #c2410c;
  border-radius: 2px;
}

.legend-line {
  display: inline-block;
  width: 1.25rem;
  height: 0;
  border-top: 2px solid #475569;
}

.legend-external-line {
  border-top: 2px dashed #ea580c;
}

.module-graph-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.35rem;
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
}

.module-graph-breadcrumb .crumb-link {
  background: none;
  border: none;
  color: #1d4ed8;
  cursor: pointer;
  padding: 0;
  font: inherit;
  text-decoration: underline;
}

.module-graph-breadcrumb .crumb.current {
  color: #0f172a;
  font-weight: 600;
}

.module-graph-breadcrumb .crumb-sep {
  color: #94a3b8;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.chart-grid .chart-wrap {
  height: 200px;
  margin: 0;
}

.chart-card {
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 0.75rem;
}

.chart-card h3 {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  color: #475569;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  font-size: 0.9rem;
  color: #64748b;
  margin-bottom: 1rem;
}

.muted {
  color: #94a3b8;
  font-size: 0.9rem;
}

.boundary-outcome {
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #e2e8f0;
}

.boundary-outcome h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  text-transform: lowercase;
}

.boundary-bars {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-width: 36rem;
}

.boundary-bar-row {
  display: grid;
  grid-template-columns: 9rem 1fr 3.5rem;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.85rem;
}

.bar-track {
  height: 0.65rem;
  background: #e2e8f0;
  border-radius: 2px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 2px;
}

.bar-free { background: #0f766e; }
.bar-rel { background: #b45309; }

.bar-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: #475569;
}

.boundary-meta {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  color: #64748b;
}

.degenerate-note {
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  padding: 0.6rem 0.75rem;
  border-radius: 4px;
  font-size: 0.9rem;
}

.stability-badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: lowercase;
}

.badge-stable {
  background: #ecfdf5;
  color: #065f46;
}

.badge-partial {
  background: #fffbeb;
  color: #92400e;
}

.badge-unstable {
  background: #fef2f2;
  color: #991b1b;
}

.depth-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.depth-table th,
.depth-table td {
  text-align: left;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid #e2e8f0;
}

.depth-table th {
  color: #64748b;
  font-weight: 600;
}

/* Queue form: one fieldset per concern, shown only for job types that use it. */
#job-form {
  flex-direction: column;
  align-items: stretch;
  gap: 0.85rem;
}

#job-form fieldset {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.9rem 1.1rem;
  margin: 0;
  padding: 0.6rem 1rem 0.9rem;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
}

#job-form legend {
  padding: 0 0.35rem;
  color: #64748b;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

#job-form fieldset > label {
  flex: 1 1 14rem;
  min-width: 0;
}

#job-form fieldset > label.checkbox-label {
  flex: 0 1 auto;
}

#job-form fieldset > label.wide {
  flex: 1 1 100%;
}

#job-form fieldset > label.narrow {
  flex: 0 1 9rem;
}

#job-form .form-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

#job-form .fieldset-hint {
  flex: 1 1 100%;
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
  color: #64748b;
  line-height: 1.35;
}

#job-form .analysis-types {
  flex: 1 1 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  align-items: center;
  padding: 0.35rem 0;
}

#job-form .analysis-types-label {
  flex: 1 1 100%;
  font-size: 0.8rem;
  font-weight: 600;
  color: #475569;
}

#job-form .analysis-presets {
  flex: 1 1 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.15rem 0 0.35rem;
}

/* Job list: settings and errors live in a sub-row so the main row stays scannable. */
tr.job-row > td {
  border-bottom: none;
  padding-bottom: 0.3rem;
}

tr.job-detail-row > td {
  padding-top: 0;
  padding-bottom: 0.55rem;
  color: #64748b;
}

tr.job-row:hover > td,
tr.job-row:hover + tr.job-detail-row > td {
  background: #f8fafc;
}

.job-error {
  margin: 0.35rem 0 0;
  color: #b91c1c;
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.probe-verdict {
  margin: 0 0 0.75rem;
  padding: 0.6rem 0.85rem;
  border-radius: 6px;
  border-left: 3px solid #cbd5e1;
  background: #f8fafc;
  font-size: 0.88rem;
}

.probe-verdict.good {
  border-left-color: #16a34a;
  background: #f0fdf4;
}

.probe-verdict.bad {
  border-left-color: #b91c1c;
  background: #fef2f2;
  color: #7f1d1d;
}

.probe-ok {
  color: #15803d;
  font-weight: 600;
}

.probe-bad {
  color: #b91c1c;
}

/* Job parameter chips (jobs list + job detail). */
.settings-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  max-width: 32rem;
}

.settings-block {
  max-width: none;
}

.setting-chip .o {
  color: #94a3b8;
  font-size: 0.66rem;
  border-left: 1px solid #dbeafe;
  padding-left: 0.3rem;
}

.setting-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3rem;
  padding: 0.1rem 0.45rem;
  border: 1px solid #dbeafe;
  border-radius: 999px;
  background: #eff6ff;
  font-size: 0.72rem;
  line-height: 1.5;
  white-space: nowrap;
}

.setting-chip .k {
  color: #64748b;
  text-transform: lowercase;
}

.setting-chip .v {
  color: #1e3a8a;
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.setting-chip.danger {
  background: #fef2f2;
  border-color: #fecaca;
}

.setting-chip.danger .v {
  color: #b91c1c;
}

.setting-chip.muted {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.setting-chip.muted .v {
  color: #64748b;
  font-weight: 500;
}

.setting-empty {
  color: #94a3b8;
  font-size: 0.75rem;
}

.error-box {
  background: #fef2f2;
  color: #b91c1c;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

.triggered-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tag-pill {
  background: #f1f5f9;
  border-radius: 4px;
  padding: 0.15rem 0.45rem;
  font-size: 0.8rem;
  font-family: ui-monospace, monospace;
}

.tag-pill.positive { background: #dcfce7; color: #166534; }
.tag-pill.negative { background: #fee2e2; color: #991b1b; }

@media (max-width: 640px) {
  main { padding: 1rem; }
  .chart-wrap { height: 260px; }
}

table.heatmap th,
table.heatmap td {
  font-size: 0.75rem;
  text-align: center;
  min-width: 2.5rem;
}

table.heatmap th:first-child {
  text-align: left;
  min-width: 6rem;
}

.analysis-nav a {
  margin-right: 0.75rem;
}

.button, button[type="submit"] {
  display: inline-block;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 0.5rem 0.9rem;
  text-decoration: none;
  cursor: pointer;
  font-size: 0.95rem;
}
.button:hover { background: #1d4ed8; }
.muted { opacity: 0.75; font-size: 0.95rem; }
.card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
}
