:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-translucent: rgba(255, 255, 255, 0.96);
  --ink: #17202a;
  --muted: #667085;
  --line: #d7dce2;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --warn: #b45309;
  --danger: #b42318;
  --ok: #067647;
  --blue: #175cd3;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(246, 247, 249, 0.58), rgba(246, 247, 249, 0.68)),
    url("/static/images/csma-background.jpg?v=20260604") center / cover no-repeat;
  opacity: 1;
}

a {
  color: inherit;
}

.topbar {
  position: relative;
  z-index: 1;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-weight: 700;
  text-decoration: none;
}

.page {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 32px));
  margin: 24px auto 48px;
}

.workband,
.auth-panel {
  background: var(--panel-translucent);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(16, 24, 40, 0.08);
}

.workband {
  padding: 24px;
  margin-bottom: 20px;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

h1,
h2 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: 26px;
}

h2 {
  font-size: 20px;
}

.muted {
  color: var(--muted);
  margin: 6px 0 0;
}

.assessment-form {
  display: grid;
  gap: 20px;
}

.description-panel {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.description-panel p {
  margin: 0;
  color: #344054;
}

.description-label {
  color: #475467;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.identity-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.identity-grid div {
  min-width: 0;
  padding: 14px 16px;
  background: #ffffff;
}

.identity-grid dt {
  margin-bottom: 5px;
  color: #475467;
  font-size: 13px;
  font-weight: 800;
}

.identity-grid dd {
  margin: 0;
}

.break-value {
  overflow-wrap: anywhere;
}

.session-confirmation {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid #abefc6;
  border-radius: 6px;
  background: #ecfdf3;
  color: var(--ok);
  font-weight: 700;
}

.session-confirmation + .assessment-form {
  margin-top: 20px;
}

.configuration-warning {
  padding: 12px 14px;
  border: 1px solid #f7b27a;
  border-radius: 6px;
  background: #fff7ed;
  color: #9a3412;
  font-weight: 700;
}

fieldset {
  border: 0;
  padding: 0;
  margin: 0;
}

legend {
  font-weight: 700;
  margin-bottom: 12px;
}

.form-grid {
  display: grid;
  gap: 16px;
}

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

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

.score-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-weight: 650;
}

.field-note {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

input,
select {
  min-height: 42px;
  width: 100%;
  border: 1px solid #cbd3dc;
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  padding: 9px 11px;
  font: inherit;
}

input:focus,
select:focus {
  outline: 2px solid rgba(15, 118, 110, 0.18);
  border-color: var(--accent);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

.button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 14px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  font: inherit;
}

.button.primary {
  background: var(--accent);
  color: #ffffff;
}

.button.primary:hover {
  background: var(--accent-dark);
}

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

.button.primary:disabled:hover {
  background: var(--accent);
}

.button.subtle {
  background: #ffffff;
  color: #344054;
  border-color: var(--line);
}

.artifact-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.artifact-note {
  margin: -4px 0 0;
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th {
  color: #475467;
  font-size: 13px;
}

.table-link {
  color: var(--blue);
  font-weight: 700;
  text-decoration: none;
}

.empty {
  color: var(--muted);
  text-align: center;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  text-transform: capitalize;
  background: #eef2f6;
  color: #344054;
}

.status.running,
.status.queued {
  background: #eff8ff;
  color: var(--blue);
}

.status.waiting_for_auth,
.status.interrupted {
  background: #fffaeb;
  color: #b54708;
}

.status.completed {
  background: #ecfdf3;
  color: var(--ok);
}

.status.failed {
  background: #fef3f2;
  color: var(--danger);
}

.job-shell {
  max-width: 860px;
}

.status-panel {
  display: grid;
  gap: 16px;
}

.job-meta {
  display: grid;
  gap: 10px;
  margin: 0 0 18px;
  padding: 14px 16px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.job-meta div {
  display: grid;
  gap: 4px;
}

.job-meta dt {
  color: #475467;
  font-size: 13px;
  font-weight: 800;
}

.job-meta dd {
  margin: 0;
}

.status-row,
.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.progress-track {
  width: 100%;
  height: 14px;
  background: #e5e9ef;
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #2563eb);
  width: 0;
  transition: width 180ms ease;
}

.execution-progress-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.execution-progress-summary {
  color: #475467;
  font-size: 14px;
  font-weight: 700;
}

.execution-progress {
  border-top: 1px solid var(--line);
  padding-top: 4px;
}

.execution-phase {
  padding: 14px 0;
}

.execution-phase + .execution-phase {
  border-top: 1px solid var(--line);
}

.execution-phase-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.execution-phase-heading h2 {
  margin: 0;
  font-size: 18px;
}

.execution-phase-heading p,
.phase-metrics {
  margin: 0;
  color: #475467;
  font-size: 14px;
}

.phase-metrics {
  margin-top: 4px;
}

.running-scripts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 10px;
  margin: 12px 0;
  padding: 10px 12px;
  border-left: 3px solid #2563eb;
  background: #eff6ff;
  color: #1d2939;
  font-size: 14px;
}

.running-scripts span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.script-progress-list {
  max-height: 360px;
  margin-top: 12px;
  overflow: auto;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.script-row,
.script-summary-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  padding: 8px 4px;
}

.script-row + .script-row {
  border-top: 1px solid #eef1f5;
}

details.script-row {
  display: block;
  padding: 0 4px;
}

details.script-row > summary {
  cursor: pointer;
  display: list-item;
  padding: 0 4px 0 18px;
}

.script-summary-content {
  padding: 8px 0;
}

.script-name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
}

.script-state {
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.script-state.completed,
.script-state.empty {
  background: #ecfdf3;
  color: var(--ok);
}

.script-state.running {
  background: #eff8ff;
  color: #175cd3;
}

.script-state.failed {
  background: #fef3f2;
  color: var(--danger);
}

.script-state.auth_required {
  background: #fffaeb;
  color: #b54708;
}

.script-state.partial {
  background: #fffaeb;
  color: #b54708;
}

.script-state.pending {
  background: #f2f4f7;
  color: #475467;
}

.script-error {
  max-height: 240px;
  margin: 0 0 10px 18px;
  padding: 10px 12px;
  overflow: auto;
  border: 1px solid #fecdca;
  border-radius: 6px;
  background: #fffbfa;
  color: #912018;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.alert {
  border: 1px solid #fecdca;
  background: #fffbfa;
  color: var(--danger);
  border-radius: 6px;
  padding: 10px 12px;
}

.hidden {
  display: none !important;
}

.auth-shell {
  min-height: calc(100vh - 140px);
  display: grid;
  place-items: center;
}

.auth-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 24px;
}

.connector-panel {
  width: min(520px, 100%);
}

.connector-command {
  margin: 0;
  padding: 10px 12px;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  color: #344054;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
}

@media (max-width: 860px) {
  .form-grid.two,
  .form-grid.three,
  .score-grid,
  .identity-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding: 0 16px;
  }

  .workband {
    padding: 18px;
  }

  .section-head,
  .status-row,
  .progress-meta,
  .execution-phase-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .script-row,
  .script-summary-content {
    grid-template-columns: minmax(0, 1fr);
  }

  .script-state {
    justify-self: start;
    white-space: normal;
  }

  .running-scripts {
    grid-template-columns: 1fr;
  }
}
