* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #1c2230;
  background: #eef1f5;
}
.topbar {
  background: #11203a;
  color: #fff;
  padding: 14px 28px;
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.topbar .brand { font-weight: 700; letter-spacing: .02em; }
.topbar .tag { color: #8fa6c8; font-size: 13px; }
.topbar .operator { margin-left: auto; color: #8fa6c8; font-size: 13px; }
.topbar .operator a { color: #cdddf2; }
main { max-width: 880px; margin: 0 auto; padding: 28px 20px 80px; }
h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 14px; color: #11203a; }
.lede { color: #4a5468; margin: 0 0 22px; }
code { background: #e3e8f0; border-radius: 4px; padding: 1px 5px; font-size: 90%; }
.card {
  background: #fff;
  border: 1px solid #d6dce6;
  border-radius: 10px;
  padding: 20px 22px;
  margin-bottom: 18px;
}
.card.login { max-width: 460px; margin: 48px auto; }
.card.login .go { margin-top: 6px; }
.card.login .status { margin-top: 14px; }

.fld { margin-bottom: 14px; }
.fld label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 3px; }
.req { color: #c0392b; font-weight: 700; }
.cond { color: #b9770e; font-weight: 400; font-size: 12px; }
.hint { color: #6b7689; font-size: 12px; margin: 0 0 6px; }
input[type=text], textarea, select {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid #b9c2d0;
  border-radius: 6px;
  font: inherit;
  background: #fff;
}
textarea { resize: vertical; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.check { font-weight: 400; display: flex; align-items: center; gap: 5px; }
.check input { width: auto; }
fieldset.grp {
  border: 1px solid #d6dce6;
  border-radius: 8px;
  padding: 12px 14px;
  margin: 0 0 14px;
}
fieldset.grp > legend { font-weight: 700; font-size: 13px; padding: 0 6px; }
fieldset.row {
  border: 1px dashed #c7cedb;
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 10px;
}
fieldset.row > legend { color: #6b7689; font-size: 12px; }
button.go {
  background: #1d6fe0;
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 12px 26px;
  font: 600 15px/1 inherit;
  cursor: pointer;
}
button.go:hover { background: #1559b8; }
a { color: #1d6fe0; }

/* delivery surface */
.status { font-weight: 600; }
.status.ok, .step.ok .badge { color: #1e7d34; }
.status.fail, .step.fail .badge { color: #c0392b; }
.badge {
  font-size: 12px;
  font-weight: 700;
  border: 1px solid currentColor;
  border-radius: 4px;
  padding: 1px 6px;
  vertical-align: middle;
}
.step.ok { border-left: 4px solid #1e7d34; }
.step.fail { border-left: 4px solid #c0392b; }
dl.detail {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 6px 14px;
  margin: 12px 0 0;
}
dl.detail dt { font-weight: 600; color: #4a5468; font-size: 13px; }
dl.detail dd { margin: 0; font-size: 13px; word-break: break-word; }
pre.output {
  background: #11203a;
  color: #d6e2f5;
  padding: 14px;
  border-radius: 8px;
  overflow: auto;
  font-size: 12px;
  margin: 4px 0 0;
}

/* Engine per-step status */
ul.esteps { list-style: none; margin: 4px 0 0; padding: 0; }
li.estep {
  border: 1px solid #d6dce6;
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 8px;
}
li.estep.ok { border-left: 3px solid #1e7d34; }
li.estep.fail { border-left: 3px solid #c0392b; }
li.estep .dur { color: #6b7689; font-size: 12px; margin-left: 6px; }
ul.vals { list-style: none; margin: 6px 0 0; padding: 0; font-size: 13px; }
ul.vals li.ok { color: #1e7d34; }
ul.vals li.fail { color: #c0392b; }
.estep .err { color: #c0392b; font-size: 13px; margin: 6px 0 0; }

/* Form validation — required-fields summary + per-field highlight. */
.error-summary {
  background: #fff4f2;
  border: 1px solid #c0392b;
  color: #842611;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 18px;
}
.error-summary strong { display: block; margin-bottom: 6px; font-weight: 700; }
.error-summary ul { margin: 0; padding-left: 22px; }
.error-summary li { font-size: 14px; }
.fld.is-invalid > label { color: #842611; }
.fld.is-invalid input[type=text],
.fld.is-invalid textarea,
.fld.is-invalid select {
  border-color: #c0392b;
  box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.18);
}
.fld.is-invalid .checks {
  border: 1px solid #c0392b;
  border-radius: 6px;
  padding: 6px 8px;
  background: rgba(192, 57, 43, 0.05);
}

/* SDR-025 description-driven onboarding layout. */
button.go.small { padding: 8px 16px; font-size: 14px; }
button.secondary {
  background: transparent;
  color: #4a5468;
  border: 1px solid #b9c2d0;
  border-radius: 8px;
  padding: 10px 22px;
  font: 600 14px/1 inherit;
  cursor: pointer;
}
button.secondary:hover { background: #f3f5f9; }

.sources-tabs { display: flex; gap: 18px; margin-bottom: 8px; }
.sources-pane { margin-top: 4px; }

.review-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}
@media (max-width: 760px) {
  .review-grid { grid-template-columns: 1fr; }
}

.review-header h1 { margin-bottom: 0; }
.review-header code { font-size: 17px; }

.file-list ul { list-style: none; margin: 0; padding: 0; }
.file-entry {
  border: 1px solid #d6dce6;
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 8px;
  background: #fbfcfe;
}
.file-entry summary {
  cursor: pointer;
  font-size: 14px;
  display: flex;
  gap: 10px;
  align-items: baseline;
}
.file-entry .file-path { font-weight: 700; color: #11203a; }
.file-entry .file-meta { color: #6b7689; font-size: 12px; }
.file-entry pre {
  background: #11203a;
  color: #d6e2f5;
  padding: 12px;
  border-radius: 6px;
  overflow: auto;
  font-size: 12px;
  margin: 8px 0 0;
  max-height: 360px;
}

.chat-panel { display: flex; flex-direction: column; min-height: 240px; }
.chat-history {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  flex: 1 1 auto;
  overflow-y: auto;
  max-height: 320px;
}
.chat-msg {
  padding: 8px 10px;
  margin-bottom: 6px;
  border-radius: 6px;
  font-size: 13px;
  background: #f3f5f9;
}
.chat-msg.you { background: #e6efff; }
.chat-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: #1d6fe0;
  margin-right: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
#chat-form textarea { width: 100%; }
#chat-form button { margin-top: 6px; }

.commit-bar {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}
.commit-bar .error-summary { flex-basis: 100%; margin: 0; }

.done-info {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 6px 12px;
  margin: 16px 0;
}
.done-info dt { font-weight: 700; color: #4a5468; font-size: 14px; }
.done-info dd { margin: 0; font-size: 14px; word-break: break-word; }

/* SDR-026 / Brief E §4 — operator dashboard at /onboardings/. */
.onb-toolbar h1 { margin-bottom: 4px; }
.onb-toolbar .lede { margin-bottom: 0; }
.onb-toolbar .lede a.dim { margin-left: 12px; color: #6b7689; }
.onb-group { margin: 0 0 26px; }
.onb-group h2 {
  margin: 18px 0 10px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b7689;
}
.onb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}
.onb-card {
  background: #fff;
  border: 1px solid #d6dce6;
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-left-width: 4px;
}
.onb-card.state-queued     { border-left-color: #6b7689; }
.onb-card.state-ingesting  { border-left-color: #1d6fe0; }
.onb-card.state-generating { border-left-color: #1d6fe0; }
.onb-card.state-ready      { border-left-color: #1e7d34; }
.onb-card.state-failed     { border-left-color: #c0392b; }
.onb-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.onb-slug {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #11203a;
  word-break: break-word;
}
.onb-slug a { color: inherit; text-decoration: none; }
.onb-slug a:hover { text-decoration: underline; }
.state-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 4px;
  padding: 2px 7px;
  white-space: nowrap;
}
.state-badge.state-queued     { background: #e3e8f0; color: #4a5468; }
.state-badge.state-ingesting  { background: #e6efff; color: #1559b8; }
.state-badge.state-generating { background: #e6efff; color: #1559b8; }
.state-badge.state-ready      { background: #def0e1; color: #1e5d2a; }
.state-badge.state-failed     { background: #fde0dc; color: #842611; }
.onb-badges { display: flex; gap: 6px; align-items: baseline; }
.cost-badge {
  font-size: 11px;
  font-weight: 700;
  background: #f3f5f9;
  color: #1c2230;
  border-radius: 4px;
  padding: 2px 7px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.cost-badge .dim { color: #6b7689; font-weight: 500; margin-left: 1px; }
.cost-badge.cost-high {
  background: #fff4f2;
  color: #842611;
}
.cost-badge.cost-high .dim { color: #b06556; }
.onb-meta {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 4px 10px;
  margin: 0;
  font-size: 13px;
}
.onb-meta dt { color: #6b7689; font-weight: 600; }
.onb-meta dd { margin: 0; color: #1c2230; }
.onb-meta .dim { color: #6b7689; font-size: 12px; }
.onb-error {
  color: #842611;
  background: #fff4f2;
  border: 1px solid #f1c1b9;
  border-radius: 4px;
  padding: 4px 7px;
  font-size: 12px;
  word-break: break-word;
}
.onb-card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: auto;
}
.onb-card-foot .small-link { font-size: 12px; text-decoration: none; }
.onb-card-foot .small-link:hover { text-decoration: underline; }
.onb-card-foot .go.small { padding: 6px 12px; font-size: 13px; text-decoration: none; }

/* Subtle cross-page nav link on the intake card → dashboard. */
.intake-nav {
  margin: 0 0 18px;
  font-size: 13px;
  color: #6b7689;
}
.intake-nav a { color: #1d6fe0; text-decoration: none; }
.intake-nav a:hover { text-decoration: underline; }

/* Working-state polling — phase checklist + meta footer. */
.working-steps {
  list-style: none;
  margin: 8px 0 14px;
  padding: 0;
  font-size: 14px;
  display: grid;
  gap: 6px;
}
.wstep {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid transparent;
  color: #6b7689;
}
.wstep .wmark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
}
.wstep.pending { background: transparent; }
.wstep.pending .wmark { color: #b9c2d0; }
.wstep.active {
  background: #e6efff;
  border-color: #b8d0f5;
  color: #1559b8;
  font-weight: 600;
}
.wstep.active .wmark {
  background: #1d6fe0;
  color: #fff;
  /* Tiny pulse so the eye knows what's running right now. */
  animation: wstep-pulse 1.4s ease-in-out infinite;
}
.wstep.done {
  color: #1e5d2a;
}
.wstep.done .wmark {
  background: #1e7d34;
  color: #fff;
}
@keyframes wstep-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(29, 111, 224, 0.45); }
  50%      { box-shadow: 0 0 0 6px rgba(29, 111, 224, 0); }
}
.working-meta {
  font-size: 12px;
  color: #6b7689;
  margin: 4px 0 6px;
}
.working-meta code { font-size: 12px; }
