:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-2: #f9fbfc;
  --line: #d8e0e7;
  --line-strong: #bccbd8;
  --text: #13202b;
  --muted: #637181;
  --accent: #176b5d;
  --accent-strong: #115247;
  --info: #245f95;
  --warn: #9a670d;
  --danger: #a43b2f;
  --ok: #1b7746;
  --shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body,
#root {
  min-height: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
  color: var(--text);
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  min-width: 92px;
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
  cursor: pointer;
  white-space: nowrap;
}

button span {
  overflow: hidden;
  text-overflow: ellipsis;
}

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

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

button.secondary {
  background: #eef4f8;
  color: #17384d;
}

button.danger {
  border-color: #e8beb8;
  background: #fff6f4;
  color: var(--danger);
}

button.icon-button {
  width: 34px;
  min-width: 34px;
  padding: 6px;
}

button.button-small {
  width: 30px;
  min-width: 30px;
  min-height: 30px;
  padding: 4px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
  padding: 7px 9px;
}

textarea {
  min-height: 440px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

h1,
h2,
h3,
p {
  margin: 0;
  letter-spacing: 0;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 168px 1fr;
  grid-template-rows: 64px 1fr;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 18px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
}

.brand h1 {
  font-size: 18px;
}

.brand span,
.field span,
.meta-line,
.info span {
  color: var(--muted);
  font-size: 12px;
}

.health-strip,
.toolbar,
.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.hint-box {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #cbdceb;
  border-radius: 6px;
  background: #f1f7fc;
  color: #17384d;
  font-size: 13px;
}

.hint-box code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.action-stack {
  display: grid;
  gap: 8px;
  width: 100%;
  min-width: 0;
}

.toolbar-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar-line-inline {
  flex-wrap: nowrap;
}

.toolbar > input {
  flex: 1 1 180px;
  max-width: 240px;
}

.toolbar > select {
  flex: 0 1 170px;
  min-width: 150px;
}

.toolbar > button {
  flex: 0 0 auto;
}

.rail {
  padding: 14px 10px;
  background: #ffffff;
  border-right: 1px solid var(--line);
}

.rail button {
  width: 100%;
  min-width: 0;
  justify-content: flex-start;
  margin-bottom: 6px;
  border-color: transparent;
  background: transparent;
}

.rail button.active {
  border-color: #c5d7e5;
  background: #eef4f8;
  color: #123d62;
}

.workspace {
  min-width: 0;
  padding: 16px;
  overflow: auto;
}

.view-grid,
.stack-layout {
  display: grid;
  gap: 12px;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(430px, 1.05fr) minmax(360px, 0.95fr);
  gap: 12px;
  align-items: start;
}

.run-main-stack,
.run-console-grid {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.run-console-grid {
  grid-template-columns: 1fr;
  align-items: start;
}

.two-column,
.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.diagnostics-grid,
.diagnostics-detail-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.85fr) minmax(420px, 1.15fr);
  gap: 12px;
  align-items: start;
}

.diagnostics-detail-grid {
  grid-template-columns: 1fr;
}

.diagnostics-column {
  min-width: 0;
}

.diagnostics-search {
  width: min(760px, 100%);
}

.diagnostics-search input {
  min-width: 320px;
}

.diagnostics-stats {
  grid-template-columns: repeat(6, minmax(92px, 1fr));
}

.diagnostics-links {
  grid-template-columns: 1fr;
}

.diagnostics-links-stack {
  display: grid;
  gap: 12px;
}

.workflow-editor {
  display: grid;
  gap: 8px;
}

.workflow-editor-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.stats,
.mini-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 8px;
}

.mini-grid {
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.stat,
.panel,
.health-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.stat {
  min-width: 0;
  padding: 10px;
}

.stat strong {
  display: block;
  margin-top: 3px;
  font-size: 21px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.stat span {
  color: var(--muted);
  font-size: 12px;
}

.stat.info strong {
  color: var(--info);
}

.stat.warn strong {
  color: var(--warn);
}

.stat.bad strong {
  color: var(--danger);
}

.panel {
  min-width: 0;
}

.panel-header {
  min-height: 56px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.panel-header h2 {
  font-size: 15px;
}

.panel-body {
  padding: 12px;
  min-width: 0;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 228px);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.data-table th,
.data-table td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.data-table tr {
  cursor: pointer;
}

.data-table tr.selected,
.data-table tr:hover {
  background: #f1f6fa;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.status-pill.ok {
  color: var(--ok);
  background: #eaf7ef;
  border-color: #bfe5cb;
}

.status-pill.bad {
  color: var(--danger);
  background: #fff0ee;
  border-color: #efc2bc;
}

.status-pill.warn {
  color: var(--warn);
  background: #fff7e5;
  border-color: #edd29c;
}

.status-pill.info {
  color: var(--info);
  background: #edf5ff;
  border-color: #c8dbee;
}

.status-pill.neutral {
  color: var(--text);
  background: #f2f5f8;
  border-color: #d9dfe8;
}

.status-pill-audit.ok,
.status-pill-audit.info,
.status-pill-audit.warn,
.status-pill-audit.bad,
.status-pill-audit.neutral {
  font-size: 12px;
}

.status-pill-audit {
  min-width: 88px;
  min-height: 24px;
  display: inline-flex !important;
  align-items: center !important;
  white-space: nowrap !important;
  justify-content: center !important;
  border-radius: 999px !important;
  padding: 2px 10px !important;
  border: 1px solid var(--line);
  background: #f2f5f8;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.1;
}

.status-pill-audit.ok {
  color: var(--ok);
  background: #eaf7ef;
  border-color: #bfe5cb;
}

.status-pill-audit.info {
  color: var(--info);
  background: #edf5ff;
  border-color: #c8dbee;
}

.status-pill-audit.warn {
  color: var(--warn);
  background: #fff7e5;
  border-color: #edd29c;
}

.status-pill-audit.bad {
  color: var(--danger);
  background: #fff0ee;
  border-color: #efc2bc;
}

.status-pill-audit.neutral {
  color: var(--text);
  background: #f2f5f8;
  border-color: #d9dfe8;
}

.event-row .status-pill-audit {
  margin-left: auto;
}

.detail-stack,
.card-list,
.event-list,
.health-grid,
.ops-actions {
  display: grid;
  gap: 10px;
}

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.detail-head h2 {
  margin-top: 2px;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.info {
  min-width: 0;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
}

.info b {
  display: block;
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.subsection {
  display: grid;
  gap: 8px;
}

.flow {
  display: grid;
  gap: 8px;
}

.flow-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
}

.flow-step > span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #e7eef4;
  color: #17384d;
  font-weight: 700;
}

.flow-step.active {
  border-color: #82aeca;
  background: #f0f7fb;
}

.flow-step div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.mini-records {
  display: grid;
  gap: 8px;
}

.mini-records article {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
}

.mini-records span {
  color: var(--muted);
  font-size: 11px;
}

.mini-records b {
  display: block;
  margin-top: 2px;
  overflow-wrap: anywhere;
  font-size: 12px;
}

.recovery-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid #edd29c;
  border-radius: 7px;
  color: var(--warn);
  background: #fff7e5;
  font-weight: 650;
}

.failure-summary {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid #f0c3bc;
  border-radius: 7px;
  color: #8f2d23;
  background: #fff0ed;
}

.failure-summary > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.failure-summary ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.failure-summary li {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.failure-summary span {
  color: #9d5148;
  font-size: 11px;
  font-weight: 700;
}

.failure-summary p {
  margin: 0;
  color: #4b1712;
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.match-list,
.problem-list,
.diagnostics-timeline,
.artifact-link-list {
  display: grid;
  gap: 8px;
}

.match-row {
  width: 100%;
  min-width: 0;
  min-height: 58px;
  justify-content: space-between;
  gap: 12px;
  border-color: var(--line);
  background: var(--panel-2);
  text-align: left;
}

.match-row div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.match-row span,
.match-row code {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.match-row code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.artifact-link {
  min-width: 0;
  display: grid;
  gap: 3px;
  padding: 10px;
  border: 1px solid #cbdceb;
  border-radius: 7px;
  background: #f8fbfd;
  color: var(--text);
  text-decoration: none;
}

.artifact-link:hover {
  border-color: #82aeca;
  background: #f1f7fc;
}

.artifact-link.disabled {
  color: var(--muted);
  border-color: var(--line);
  background: var(--panel-2);
}

.artifact-link b,
.artifact-link span {
  overflow-wrap: anywhere;
}

.artifact-link span {
  color: var(--muted);
  font-size: 12px;
}

.problem-row,
.diagnostic-event {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
}

.problem-row {
  grid-template-columns: auto minmax(0, 1fr);
}

.problem-row.error,
.problem-row.bad {
  border-color: #efc2bc;
  background: #fff6f4;
}

.problem-row.warn {
  border-color: #edd29c;
  background: #fffaf0;
}

.problem-row div,
.diagnostic-event div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.problem-row span,
.diagnostic-event span,
.diagnostic-event time {
  color: var(--muted);
  font-size: 12px;
}

.problem-row p,
.diagnostic-event p {
  overflow-wrap: anywhere;
}

.diagnostic-event {
  grid-template-columns: minmax(148px, 0.35fr) auto minmax(0, 1fr);
  align-items: start;
}

.diagnostic-event.bad {
  border-color: #efc2bc;
}

.diagnostic-event.warn {
  border-color: #edd29c;
}

.diagnostic-event-meta {
  display: flex !important;
  flex-wrap: wrap;
  gap: 5px !important;
  margin-top: 6px;
}

.diagnostic-event-meta code {
  display: inline-flex;
  max-width: 100%;
  padding: 2px 6px;
  border: 1px solid #cbdceb;
  border-radius: 999px;
  background: #f1f7fc;
  color: #17384d;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  overflow-wrap: anywhere;
}

.console-section {
  display: grid;
  gap: 10px;
}

.console-summary {
  display: grid;
  gap: 3px;
  padding: 9px;
  border: 1px solid #cbdce8;
  border-radius: 7px;
  background: linear-gradient(180deg, #f8fbfd, #eef5f9);
}

.console-summary b {
  overflow-wrap: anywhere;
}

.console-summary span {
  color: var(--muted);
  font-size: 12px;
}

.timeline-list,
.run-log {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
}

.timeline-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  padding: 9px;
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: 7px;
  background: var(--panel-2);
}

.timeline-item .status-pill,
.log-row .status-pill {
  align-self: start;
  justify-self: start;
  line-height: 1.1;
  white-space: nowrap;
}

.timeline-item.ok {
  border-left-color: var(--ok);
}

.timeline-item.warn {
  border-left-color: var(--warn);
}

.timeline-item.bad {
  border-left-color: var(--danger);
}

.timeline-item.info {
  border-left-color: var(--info);
}

.timeline-item b,
.timeline-item p,
.timeline-item span {
  overflow-wrap: anywhere;
}

.timeline-item p {
  margin-top: 3px;
  color: var(--text);
  font-size: 12px;
}

.timeline-item span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.timeline-notes {
  display: grid;
  gap: 3px;
  margin: 6px 0 0;
  padding-left: 16px;
  color: var(--muted);
  font-size: 11px;
}

.timeline-notes li {
  overflow-wrap: anywhere;
}

.run-log {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.log-row {
  display: grid;
  grid-template-columns: minmax(115px, 0.9fr) minmax(0, 1.2fr) auto minmax(70px, 0.6fr);
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #101820;
  color: #dbeafe;
}

.log-row time,
.log-row span {
  color: #92a7b8;
  font-size: 11px;
  overflow-wrap: anywhere;
}

.log-row b {
  font-size: 12px;
  overflow-wrap: anywhere;
}

.outbox-card,
.event-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.outbox-card h3 {
  font-size: 14px;
}

.outbox-card p {
  margin-top: 4px;
  color: var(--muted);
}

.meta-line {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 5px;
}

.event-row {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.event-row span,
.event-row time {
  color: var(--muted);
  font-size: 12px;
}

.ops-action {
  display: grid;
  grid-template-columns: auto 150px auto auto;
  align-items: end;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.field {
  display: grid;
  gap: 4px;
}

.check-field {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  color: var(--muted);
}

.check-field input {
  width: auto;
}

.json-block {
  max-height: 520px;
  overflow: auto;
  margin: 0;
  padding: 10px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #0f1720;
  color: #dbeafe;
  font-size: 12px;
}

.health-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  box-shadow: none;
}

.empty-state {
  padding: 20px;
  text-align: center;
  color: var(--muted);
}

.validation {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 36px));
  padding: 10px 12px;
  border-radius: 8px;
  background: #13202b;
  color: #ffffff;
  box-shadow: var(--shadow);
}

.toast.bad {
  background: var(--danger);
}

.toast.warn {
  background: var(--warn);
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
  }

  .rail {
    display: flex;
    gap: 6px;
    overflow: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .rail button {
    width: auto;
    margin: 0;
  }

	  .split-layout,
	  .run-console-grid,
	  .two-column,
	  .editor-grid,
  .diagnostics-grid,
  .diagnostics-detail-grid {
	    grid-template-columns: 1fr;
	  }

  .stats {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 12px;
  }

  .workspace {
    padding: 10px;
  }

  .panel-header,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-line-inline {
    flex-wrap: wrap;
  }

  .toolbar > input,
  .toolbar > select,
  .toolbar > button {
    width: 100%;
    max-width: none;
  }

	  .outbox-card,
	  .event-row,
	  .log-row,
	  .ops-action,
  .diagnostic-event {
	    grid-template-columns: 1fr;
	  }

  .diagnostics-search input {
    min-width: 0;
  }

  .info-grid,
  .stats {
    grid-template-columns: 1fr;
  }
}
