:root {
  --bg: #06101b;
  --sidebar: #07111d;
  --sidebar-soft: #0f2340;
  --surface: #0b1a2b;
  --surface-soft: #0f2135;
  --text: #eef6ff;
  --muted: #91a3b7;
  --border: #1d3148;
  --accent: #3dd06d;
  --accent-strong: #46d375;
  --blue: #126bff;
  --warning: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 20px 48px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Manrope", "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at 68% 12%, rgba(18, 107, 255, 0.18), transparent 34%),
    radial-gradient(circle at 12% 88%, rgba(61, 208, 109, 0.08), transparent 28%),
    var(--bg);
  color: var(--text);
}

.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
}

.admin-shell.sidebar-collapsed {
  grid-template-columns: minmax(0, 1fr);
}

.admin-shell.sidebar-collapsed .admin-sidebar {
  display: none;
}

.admin-sidebar {
  min-height: 100vh;
  padding: 24px 18px;
  background:
    linear-gradient(180deg, rgba(13, 30, 49, 0.98), rgba(6, 16, 27, 0.98)),
    var(--sidebar);
  border-right: 1px solid var(--border);
  color: #f2f7f9;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  position: relative;
  padding-left: 54px;
  min-height: 50px;
}

.brand::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 5px;
  width: 34px;
  height: 34px;
  background:
    linear-gradient(45deg, transparent 37%, #ffffff 38% 62%, transparent 63%),
    linear-gradient(-45deg, transparent 37%, #ffffff 38% 62%, transparent 63%);
  filter: drop-shadow(0 0 16px rgba(255, 255, 255, 0.22));
  transform: rotate(45deg);
}

.brand span {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  color: #b8c7d7;
}

.brand h1,
.topbar h2,
.panel h3,
.details-section h4,
.quality-block h4,
.debug-block h4 {
  margin: 6px 0;
}

.brand h1 {
  max-width: 170px;
  font-size: 25px;
  line-height: 1.12;
}

.brand p,
.topbar p {
  margin: 0;
  color: #c0d4db;
  line-height: 1.45;
}

.topbar p {
  color: var(--muted);
}

.topbar h2,
.topbar p {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.panel-caption {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.side-tab {
  width: 100%;
  justify-content: flex-start;
  border-color: transparent;
  background: transparent;
  color: #d7e5f2;
  text-align: left;
  min-height: 42px;
  padding: 10px 12px;
}

.side-tab:hover,
.side-tab.active {
  background: linear-gradient(135deg, #126bff, #0648c7);
  border-color: rgba(83, 153, 255, 0.45);
  box-shadow: 0 10px 26px rgba(18, 107, 255, 0.22);
  color: #ffffff;
}

.side-tab.system-tab:not(.active) {
  color: #b6c7d8;
}

.webhook-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(12, 29, 47, 0.75);
}

.webhook-panel span,
.sidebar-meta {
  font-size: 13px;
  color: #b7d0d8;
}

.webhook-panel code {
  display: block;
  padding: 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.28);
  color: #ffffff;
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.admin-main {
  min-width: 0;
  padding: 22px 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.topbar,
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
}

.tab-panel {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.tab-panel.active {
  display: flex;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.ops-overview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.section-grid {
  display: grid;
  gap: 16px;
  align-items: start;
}

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

.latest-panel {
  grid-column: 1 / -1;
}

.panel {
  background:
    linear-gradient(180deg, rgba(14, 31, 50, 0.98), rgba(8, 22, 37, 0.98)),
    var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.panel-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.pipeline-command-panel,
.pipeline-stage-settings {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pipeline-map {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: visible;
  padding: 0;
}

.pipeline-stage-card {
  position: relative;
  width: 100%;
  min-height: 92px;
  display: grid;
  grid-template-columns: 44px minmax(220px, 1fr) minmax(420px, 1.2fr) auto;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  text-align: left;
  color: var(--text);
}

.pipeline-stage-card:first-child {
  border-top: 1px solid var(--border);
}

.pipeline-stage-card:hover,
.pipeline-stage-card.selected {
  background: linear-gradient(90deg, rgba(18, 107, 255, 0.16), rgba(18, 107, 255, 0.04));
}

.pipeline-stage-number {
  position: relative;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #126bff;
  color: #ffffff;
  font-weight: 800;
  box-shadow: 0 0 0 6px rgba(18, 107, 255, 0.1);
}

.pipeline-stage-card:nth-child(2) .pipeline-stage-number {
  background: #8b5cf6;
}

.pipeline-stage-card:nth-child(3) .pipeline-stage-number {
  background: #f97316;
}

.pipeline-stage-card:nth-child(4) .pipeline-stage-number {
  background: #22c55e;
}

.pipeline-stage-card:nth-child(5) .pipeline-stage-number {
  background: #eab308;
}

.pipeline-stage-card:nth-child(6) .pipeline-stage-number {
  background: #ef4444;
}

.pipeline-stage-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pipeline-stage-card strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.25;
}

.pipeline-stage-card em {
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  line-height: 1.45;
}

.pipeline-stage-card dl {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.pipeline-stage-card dl div {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
}

.pipeline-stage-card dt {
  color: var(--muted);
}

.pipeline-stage-card dd {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.stage-routing {
  width: fit-content;
  max-width: 100%;
  border-radius: 999px;
  padding: 5px 8px;
  background: rgba(61, 208, 109, 0.12);
  color: #78e39a;
  font-size: 11px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pipeline-stage-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.55fr);
  gap: 16px;
  align-items: start;
}

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

.stage-settings-grid > * {
  min-width: 0;
}

.stage-settings-grid .wide {
  grid-column: 1 / -1;
}

.stage-settings-grid .check-field {
  min-height: 40px;
  align-self: end;
}

.model-routing-table {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.model-routing-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(130px, 0.8fr) minmax(130px, 0.8fr) 80px 90px 90px;
  gap: 10px;
  align-items: center;
  min-height: 46px;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  text-align: left;
}

.model-routing-row:last-child {
  border-bottom: 0;
}

.model-routing-row.head {
  min-height: 40px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.model-routing-row:not(.head):hover,
.model-routing-row.selected {
  background: rgba(18, 107, 255, 0.12);
}

.model-routing-row > * {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.validation-switches {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.guardrails-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.guardrails-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 0.38fr) minmax(260px, 1fr);
  gap: 12px;
  align-items: end;
}

.guardrail-price-field {
  min-width: 0;
}

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

.guardrails-summary article {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.guardrails-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.guardrails-summary strong {
  display: block;
  font-size: 18px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.guardrails-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(5, 16, 28, 0.44);
}

.guardrails-table {
  min-width: 980px;
}

.guardrail-group-label {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.guardrail-group-label:first-child {
  border-top: 0;
}

.guardrail-row {
  display: grid;
  grid-template-columns: 110px 190px minmax(240px, 1.25fr) minmax(260px, 1.35fr) 120px;
  gap: 12px;
  align-items: start;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.4;
}

.guardrail-row:last-child {
  border-bottom: 0;
}

.guardrail-row.head {
  min-height: 40px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-weight: 800;
}

.guardrail-row > * {
  min-width: 0;
  overflow-wrap: anywhere;
}

.guardrail-row strong {
  color: #ffffff;
}

.guardrail-row.critical {
  background: rgba(239, 68, 68, 0.08);
}

.guardrail-row.warning {
  background: rgba(245, 158, 11, 0.08);
}

.guardrail-row.action {
  background: rgba(18, 107, 255, 0.06);
}

.guardrail-row.muted {
  color: var(--muted);
}

.guardrails-editors {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(5, 16, 28, 0.38);
  overflow: hidden;
}

.guardrails-editors summary {
  cursor: pointer;
  padding: 13px 14px;
  color: var(--text);
  font-weight: 800;
}

.guardrails-editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 0 14px 14px;
}

.guardrails-editor-grid textarea {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 12px;
  min-height: 210px;
  white-space: pre;
  overflow: auto;
}

.test-output {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

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

.test-stage-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.test-stage {
  display: grid;
  grid-template-columns: 32px minmax(140px, 0.4fr) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.test-stage.done {
  border-left-color: var(--accent-strong);
}

.test-stage.warning {
  border-left-color: var(--warning);
}

.test-stage.error {
  border-left-color: var(--danger);
}

.test-stage span {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(18, 107, 255, 0.16);
  color: #9fc3ff;
  font-weight: 800;
}

.test-stage strong,
.test-stage em {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.35;
}

.test-stage em {
  color: var(--muted);
  font-style: normal;
}

.webhook-panel.light {
  background: var(--surface-soft);
  border-color: var(--border);
  color: var(--text);
}

.webhook-panel.light span {
  color: var(--muted);
}

.webhook-panel.light code {
  background: rgba(0, 0, 0, 0.28);
  color: #ffffff;
}

.compact-webhook code {
  max-height: 86px;
  overflow: auto;
}

.control-panel,
.control-toolbar,
.files-panel,
.history-panel,
.run-details-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.control-toolbar p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.logic-subtabs {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  overflow-x: auto;
}

.logic-subtab {
  min-height: 34px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
}

.logic-subtab.active {
  background: rgba(18, 107, 255, 0.16);
  border-color: rgba(83, 153, 255, 0.45);
  color: var(--text);
  font-weight: 700;
}

.logic-tab-panel {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.logic-tab-panel.active {
  display: flex;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.control-grid.single {
  grid-template-columns: 1fr;
}

.control-field.wide {
  grid-column: 1 / -1;
}

.check-field.wide,
.field-hint.wide,
.section-divider.wide {
  grid-column: 1 / -1;
}

.field-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.section-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.section-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--border);
}

.criteria-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  padding-top: 4px;
}

.criteria-head strong {
  font-size: 14px;
}

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

.criteria-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.criterion-item {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

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

.criterion-grid > * {
  min-width: 0;
}

.criterion-grid .field select,
.criterion-grid .field input {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.criterion-grid .check-field {
  min-height: 40px;
}

.criterion-grid button {
  justify-self: start;
  white-space: nowrap;
}

.criterion-value input {
  text-align: center;
}

.criterion-active {
  align-self: end;
}

.proposal-settings-grid,
.client-prompt-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.client-prompt-grid .wide {
  grid-column: 1 / -1;
}

.event-prompt-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.event-prompt-item {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.event-prompt-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.75fr) minmax(0, 1.25fr) 96px auto;
  gap: 10px;
  align-items: end;
}

.event-prompt-grid > * {
  min-width: 0;
}

.event-prompt-active {
  align-self: end;
  min-height: 40px;
}

.event-prompt-grid button {
  justify-self: start;
  white-space: nowrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field span,
.number-field span {
  font-size: 13px;
  color: var(--muted);
}

.field input,
.field select,
.field textarea,
.number-field input,
.history-tools input,
.proposal-preview {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 12px;
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
  resize: vertical;
  background: rgba(5, 16, 28, 0.72);
  color: var(--text);
}

.field input::placeholder,
.field textarea::placeholder,
.history-tools input::placeholder {
  color: #66798c;
}

.field select {
  color-scheme: dark;
}

textarea {
  min-height: 120px;
}

.actions,
.upload-line,
.history-tools {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.actions.compact {
  gap: 8px;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--border);
  background: rgba(9, 24, 40, 0.88);
  color: var(--text);
  padding: 9px 13px;
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  line-height: 1.2;
  cursor: pointer;
}

button:hover {
  border-color: rgba(83, 153, 255, 0.48);
  background: rgba(18, 107, 255, 0.12);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

button.primary {
  background: linear-gradient(135deg, #126bff, #0648c7);
  border-color: rgba(83, 153, 255, 0.58);
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 12px 28px rgba(18, 107, 255, 0.22);
}

.inline-status {
  min-height: 18px;
  color: var(--muted);
  font-size: 13px;
}

.inline-status.error,
.sidebar-meta .error {
  color: var(--danger);
}

.status-list,
.latest-run {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.status-list div,
.latest-run div,
.summary-row,
.detail-item {
  display: grid;
  grid-template-columns: minmax(130px, 0.45fr) minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}

.status-list div:last-child,
.latest-run div:last-child {
  border-bottom: 0;
}

.status-list span,
.latest-run span,
.summary-row span,
.detail-item span {
  color: var(--muted);
  font-size: 13px;
}

.status-list strong,
.latest-run strong,
.summary-row strong,
.detail-item strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.control-row {
  grid-column: 1 / -1;
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.check-field,
.number-field {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--text);
  font-size: 14px;
}

.number-field {
  align-items: flex-start;
  flex-direction: column;
}

.number-field input {
  max-width: 180px;
}

.upload-line input {
  max-width: 320px;
}

.file-list,
.trace-list,
.quality-checks {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.file-item,
.empty-state {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.file-item strong,
.file-item span {
  display: block;
}

.file-item span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.run-row {
  width: 100%;
  display: grid;
  grid-template-columns: 1.35fr 0.8fr 1fr 0.9fr 0.55fr 1fr;
  gap: 10px;
  align-items: center;
  min-height: 48px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  text-align: left;
}

.run-row:hover,
.run-row.selected {
  border-color: rgba(83, 153, 255, 0.48);
  background: rgba(18, 107, 255, 0.12);
}

.run-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.run-date,
.run-stage,
.run-comment {
  color: var(--muted);
}

.run-result {
  width: fit-content;
  max-width: 100%;
  border-radius: 999px;
  padding: 5px 8px;
  font-weight: 700;
}

.status-ready {
  background: rgba(61, 208, 109, 0.14);
  color: #78e39a;
}

.status-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.status-error {
  background: rgba(239, 68, 68, 0.14);
  color: #ff8a8a;
}

.status-muted {
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted);
}

.run-details,
.details-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.detail-item {
  padding: 8px 0;
}

.details-section ul {
  margin: 0;
  padding-left: 20px;
  color: var(--text);
  line-height: 1.55;
}

.notice {
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border-left: 3px solid var(--border);
}

.notice.error {
  border-left-color: var(--danger);
  color: var(--danger);
}

.trace-overview-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.trace-overview-card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.trace-overview-card strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 18px;
  line-height: 1.25;
}

.trace-overview-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.trace-overview-card.ok {
  border-left-color: var(--accent-strong);
}

.trace-overview-card.warning {
  border-left-color: var(--warning);
}

.trace-overview-card.error {
  border-left-color: var(--danger);
}

.trace-overview-card.muted {
  border-left-color: #9aa7ad;
}

.trace-diagnostics-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.72fr) minmax(0, 1.28fr);
  gap: 16px;
  align-items: start;
}

.trace-issues,
.trace-health {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.trace-issue {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.trace-issue strong {
  font-size: 14px;
}

.trace-issue span,
.trace-issue em {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
  line-height: 1.45;
}

.trace-issue em {
  color: var(--text);
  font-weight: 700;
}

.trace-issue.ok {
  border-left-color: var(--accent-strong);
  background: rgba(61, 208, 109, 0.08);
}

.trace-issue.warning {
  border-left-color: var(--warning);
  background: rgba(245, 158, 11, 0.1);
}

.trace-issue.error {
  border-left-color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

.health-table {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.health-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.7fr) 110px minmax(160px, 1fr) minmax(180px, 1.2fr);
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.025);
}

.health-row:last-child {
  border-bottom: 0;
}

.health-row.head {
  background: rgba(255, 255, 255, 0.045);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.health-row strong,
.health-row span {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.35;
}

.health-row span {
  color: var(--muted);
}

.health-row b {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  padding: 5px 8px;
  font-size: 11px;
  line-height: 1;
}

.health-row.ok b {
  background: rgba(61, 208, 109, 0.14);
  color: #78e39a;
}

.health-row.warning b {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.health-row.error b {
  background: rgba(239, 68, 68, 0.14);
  color: #ff8a8a;
}

.health-row.muted b {
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted);
}

.trace-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.8fr) minmax(0, 1.45fr);
  gap: 16px;
  align-items: start;
}

.trace-output-panel {
  grid-column: 1 / -1;
}

.trace-list {
  max-height: calc(100vh - 210px);
  overflow: auto;
  padding-right: 2px;
}

.trace-group-label {
  margin: 10px 0 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.trace-group-label:first-child {
  margin-top: 0;
}

.trace-item {
  width: 100%;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  text-align: left;
  color: inherit;
  min-height: 96px;
  line-height: 1.4;
  cursor: pointer;
  overflow: hidden;
}

.trace-item:focus-visible {
  outline: 2px solid rgba(47, 141, 66, 0.35);
  outline-offset: 2px;
}

.trace-item-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: hidden;
}

.trace-item-main strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  line-height: 1.25;
}

.trace-item:hover,
.trace-item.selected {
  border-color: rgba(83, 153, 255, 0.48);
  background: rgba(18, 107, 255, 0.12);
}

.trace-step-index {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}

.trace-item.done .trace-step-index {
  background: rgba(61, 208, 109, 0.14);
  color: #78e39a;
}

.trace-item.warning .trace-step-index {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.trace-item.skipped .trace-step-index {
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}

.trace-item.error .trace-step-index {
  background: rgba(239, 68, 68, 0.14);
  color: #ff8a8a;
}

.trace-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.trace-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 0;
  max-height: 24px;
  overflow: hidden;
}

.trace-badges span {
  display: inline-flex;
  border-radius: 999px;
  padding: 4px 7px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

.trace-compact-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 0;
  max-height: 24px;
  overflow: hidden;
}

.trace-compact-meta span {
  display: inline-flex;
  max-width: 100%;
  border-radius: 6px;
  padding: 4px 7px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: #b8c9da;
  font-size: 11px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trace-item dl {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin: 10px 0 0;
}

.trace-item dl div {
  display: grid;
  grid-template-columns: minmax(120px, 0.45fr) minmax(0, 1fr);
  gap: 8px;
  font-size: 13px;
}

.trace-item dt {
  color: var(--muted);
}

.trace-item dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.source-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 16px;
}

.debug-details {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.debug-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.debug-title strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.debug-title span {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 700;
}

.debug-detail {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.debug-section,
.debug-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.debug-section {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.debug-section-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.debug-section-head h4 {
  margin: 0;
  font-size: 14px;
}

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

.debug-block h4 {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.debug-readable-row {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(5, 16, 28, 0.55);
}

.debug-readable-row.wide,
.debug-readable-row.text-row {
  grid-column: 1 / -1;
}

.debug-readable-row > span {
  color: var(--muted);
  font-size: 12px;
}

.debug-readable-row strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.45;
}

.muted-value {
  color: var(--muted);
  font-weight: 500;
}

.debug-text {
  max-height: 260px;
  overflow: auto;
  padding: 10px;
  border-radius: 7px;
  background: rgba(2, 8, 15, 0.78);
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.55;
}

.debug-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.debug-chip-list b {
  display: inline-flex;
  max-width: 100%;
  border-radius: 999px;
  padding: 5px 8px;
  background: rgba(61, 208, 109, 0.13);
  color: #78e39a;
  font-size: 12px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

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

.debug-mini-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(5, 16, 28, 0.55);
}

.debug-mini-card div {
  display: grid;
  grid-template-columns: minmax(92px, 0.38fr) minmax(0, 1fr);
  gap: 8px;
}

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

.debug-mini-card strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 12px;
  line-height: 1.35;
}

.debug-collapse {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(5, 16, 28, 0.55);
}

.debug-collapse summary {
  cursor: pointer;
  padding: 12px 14px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.debug-collapse .debug-readable-grid,
.debug-collapse pre {
  margin: 0 14px 14px;
}

.debug-block pre {
  width: 100%;
  max-height: 360px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #02080f;
  color: #dfefff;
  font: 12px/1.55 "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.debug-collapse pre {
  max-height: 360px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #02080f;
  color: #dfefff;
  font: 12px/1.55 "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.debug-section .empty-state {
  display: block;
}

.quality-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quality {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  border-radius: 999px;
  padding: 6px 9px;
  font-size: 12px;
  line-height: 1.35;
}

.quality.good {
  background: rgba(61, 208, 109, 0.14);
  color: #78e39a;
}

.quality.bad {
  background: rgba(239, 68, 68, 0.14);
  color: #ff8a8a;
}

.quality.muted {
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted);
}

.proposal-preview {
  margin-top: 16px;
  min-height: 320px;
}

.empty-state {
  color: var(--muted);
}

@media (max-width: 1180px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    min-height: auto;
  }

  .side-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .side-tab {
    width: auto;
  }

  .overview-grid,
  .ops-overview-grid,
  .section-grid.two-columns,
  .pipeline-stage-layout,
  .control-grid,
  .criterion-grid,
  .proposal-settings-grid,
  .client-prompt-grid,
  .event-prompt-grid,
  .stage-settings-grid,
  .guardrails-toolbar,
  .guardrails-summary,
  .guardrails-editor-grid,
  .validation-switches,
  .test-summary-grid,
  .trace-overview-grid,
  .trace-diagnostics-layout,
  .trace-layout {
    grid-template-columns: 1fr;
  }

  .pipeline-map {
    display: flex;
    flex-direction: column;
  }

  .pipeline-stage-card {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .pipeline-stage-card dl,
  .stage-routing {
    grid-column: 2;
  }

  .model-routing-row {
    grid-template-columns: minmax(160px, 1fr) minmax(120px, 0.8fr) minmax(120px, 0.8fr) 70px 80px 80px;
  }

  .trace-output-panel {
    grid-column: auto;
  }

  .trace-list {
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 760px) {
  body {
    overflow-x: hidden;
  }

  .admin-main,
  .admin-sidebar {
    padding: 16px;
  }

  .admin-main {
    overflow-x: hidden;
  }

  .side-nav {
    display: grid;
    grid-template-columns: 1fr;
  }

  .side-nav > * {
    min-width: 0;
  }

  .side-tab {
    width: 100%;
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    font-size: 13px;
    line-height: 1.3;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .topbar-actions button {
    flex: 1 1 100%;
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .topbar,
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .details-grid,
  .compact-grid,
  .debug-readable-grid,
  .debug-card-list,
  .health-row,
  .model-routing-row,
  .test-stage,
  .status-list div,
  .latest-run div,
  .summary-row,
  .detail-item,
  .debug-mini-card div,
  .trace-item dl div {
    grid-template-columns: 1fr;
  }

  .source-summary {
    grid-template-columns: 1fr;
  }

  .run-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .run-row span {
    white-space: normal;
  }
}
