/* Mopitu Swarm runtime UI — compact inspector + execution telemetry. */
:root {
  --swarm-bg: #1d1e21;
  --swarm-panel: #202124;
  --swarm-panel-raised: #242529;
  --swarm-border: #3b3e44;
  --swarm-border-soft: #30333a;
  --swarm-text: #f2f3f5;
  --swarm-muted: #aeb4bd;
  --swarm-dim: #7f8793;
  --swarm-blue: #23b9e8;
  --swarm-focus: #2f8cff;
}

.swarm-execution-workspace {
  position: absolute;
  inset-block: 0;
  right: 0;
  z-index: 90;
  min-width: 430px;
  max-width: min(920px, calc(100vw - 56px));
  display: grid;
  grid-template-rows: 53px minmax(0, 1fr);
  overflow: hidden;
  color: var(--swarm-text);
  background: var(--swarm-bg);
  border-left: 1px solid var(--swarm-border);
  box-shadow: -18px 0 44px rgba(0, 0, 0, .32);
  font: 400 12px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.swarm-execution-workspace--full {
  inset: 0;
  width: 100% !important;
  max-width: none;
  border-left: 0;
  box-shadow: none;
}

.swarm-execution-workspace__resize {
  position: absolute;
  inset-block: 0;
  left: -3px;
  z-index: 4;
  width: 7px;
  cursor: ew-resize;
}

.swarm-execution-workspace__resize::after {
  content: "";
  position: absolute;
  inset-block: 0;
  left: 3px;
  width: 1px;
  background: transparent;
  transition: background 140ms ease;
}

.swarm-execution-workspace__resize:hover::after { background: var(--swarm-blue); }

.swarm-execution-workspace__header {
  min-width: 0;
  height: 53px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 0 12px 0 18px;
  border-bottom: 1px solid var(--swarm-border);
  box-shadow: inset 3px 0 0 var(--swarm-blue);
  background: #202124;
}

.swarm-execution-workspace__header > :first-child {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.swarm-execution-workspace__header strong {
  display: block;
  overflow: hidden;
  color: var(--swarm-text);
  font-size: 13px;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.swarm-execution-workspace__header small {
  display: block;
  overflow: hidden;
  color: var(--swarm-muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.swarm-execution-workspace__header nav {
  display: flex;
  align-items: center;
  gap: 3px;
}

.swarm-execution-workspace__header button {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--swarm-muted);
  cursor: pointer;
}

.swarm-execution-workspace__header button:hover {
  border-color: var(--swarm-border);
  background: #292b30;
  color: #fff;
}

.swarm-execution-workspace__header button.is-active {
  border-color: #1ca4d1;
  background: rgba(0, 174, 226, .11);
  color: #56d3fa;
}

.swarm-execution-workspace__header svg { width: 15px; height: 15px; }

.swarm-execution-workspace__scroll {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 10px 12px 22px;
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
}

.swarm-execution-workspace__scroll,
.swarm-execution-workspace__scroll * { box-sizing: border-box; }

.swarm-workflow-header {
  min-width: 0;
  min-height: 56px;
  display: grid;
  grid-template-columns: minmax(220px, 1.45fr) minmax(300px, 1fr) 34px;
  align-items: stretch;
  border: 1px solid var(--swarm-border);
  border-radius: 7px;
  background: var(--swarm-panel);
  overflow: hidden;
}

.swarm-workflow-header > span {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 1px;
  padding: 8px 10px;
  border-right: 1px solid var(--swarm-border-soft);
  box-shadow: inset 3px 0 0 var(--swarm-blue);
}

.swarm-workflow-header small,
.swarm-overview-filter-fields label > span {
  color: var(--swarm-muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .035em;
  text-transform: uppercase;
}

.swarm-workflow-header strong {
  overflow: hidden;
  color: var(--swarm-text);
  font-size: 12px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.swarm-workflow-header p { display: none; }

.swarm-workflow-header dl {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
}

.swarm-workflow-header dl > div {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 7px 10px;
  border-right: 1px solid var(--swarm-border-soft);
}

.swarm-workflow-header dt {
  color: var(--swarm-muted);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.swarm-workflow-header dd {
  overflow: hidden;
  margin: 0;
  color: #e5e7eb;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.swarm-workflow-header__compact-stats { display: none; }

.swarm-workflow-header__toggle {
  width: 34px;
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: #24262a;
  color: var(--swarm-muted);
  cursor: pointer;
}

.swarm-workflow-header__toggle:hover { background: #2a2d32; color: #fff; }
.swarm-workflow-header__toggle svg { width: 14px; height: 14px; }

.swarm-overview-filters {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px;
  align-items: end;
  gap: 7px;
  margin-top: 8px;
}

.swarm-overview-filter-fields {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.swarm-overview-filter-fields label {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.swarm-select { position: relative; min-width: 0; }

.swarm-select__trigger,
.swarm-overview-view-options > summary {
  width: 100%;
  height: 34px;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid #42464e;
  border-radius: 6px;
  background: #181a1e;
  color: #e8eaed;
  font: 650 10.5px/1 Inter, ui-sans-serif, system-ui, sans-serif;
  cursor: pointer;
  list-style: none;
}

.swarm-select__trigger:hover,
.swarm-overview-view-options > summary:hover { border-color: #59606b; background: #202328; }

.swarm-select__trigger > span,
.swarm-overview-view-options > summary > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.swarm-overview-view-options { position: relative; min-width: 0; }
.swarm-overview-view-options > summary::-webkit-details-marker { display: none; }
.swarm-overview-view-options > summary { justify-content: flex-start; }
.swarm-overview-view-options > summary svg:last-child { margin-left: auto; }

.swarm-overview-view-options > [role="menu"] {
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  z-index: 12;
  width: 220px;
  display: grid;
  gap: 2px;
  padding: 5px;
  border: 1px solid var(--swarm-border);
  border-radius: 7px;
  background: #24262b;
  box-shadow: 0 16px 38px rgba(0, 0, 0, .42);
}

.swarm-overview-view-options [role^="menuitem"] {
  width: 100%;
  min-height: 30px;
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) 14px;
  align-items: center;
  gap: 7px;
  padding: 0 8px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #dfe3e8;
  font-size: 10px;
  text-align: left;
  cursor: pointer;
}

.swarm-overview-view-options [role^="menuitem"]:hover { background: #30333a; }
.swarm-overview-view-options__reset { margin-top: 3px; border-top: 1px solid var(--swarm-border-soft) !important; }

.swarm-metric-grid {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  margin: 9px 0 10px;
}

.swarm-metric {
  min-width: 0;
  min-height: 50px;
  display: grid;
  align-content: center;
  gap: 0;
  padding: 7px 10px;
  border: 1px solid var(--swarm-border);
  border-radius: 6px;
  background: var(--swarm-panel);
}

.swarm-metric strong {
  color: #f5f6f7;
  font-size: 20px;
  font-weight: 760;
  line-height: 1;
}

.swarm-metric span,
.swarm-metric small {
  overflow: hidden;
  color: var(--swarm-muted);
  font-size: 9px;
  font-weight: 650;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.swarm-overview-columns { min-width: 0; display: grid; gap: 10px; }

.swarm-overview-section {
  min-width: 0;
  margin: 0 0 10px;
  border: 1px solid var(--swarm-border);
  border-radius: 7px;
  background: var(--swarm-panel);
  overflow: clip;
}

.swarm-overview-section > summary {
  min-width: 0;
  min-height: 48px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 16px;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  list-style: none;
  cursor: pointer;
}

.swarm-overview-section > summary::-webkit-details-marker { display: none; }
.swarm-overview-section > summary:hover { background: #24262a; }

.swarm-overview-section > summary > span {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.swarm-overview-section > summary strong {
  overflow: hidden;
  color: #eef0f2;
  font-size: 10.5px;
  font-weight: 780;
  letter-spacing: .02em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.swarm-overview-section > summary small {
  overflow: hidden;
  color: var(--swarm-muted);
  font-size: 9.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.swarm-overview-section > summary > svg {
  width: 13px;
  height: 13px;
  color: #e4e7eb;
  transition: transform 120ms ease;
}

.swarm-overview-section:not([open]) > summary > svg { transform: rotate(-90deg); }

.swarm-overview-section__body {
  min-width: 0;
  padding: 0 10px 11px;
}

.swarm-overview-progress,
.swarm-load-grid__bar {
  width: 100%;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: #353943;
}

.swarm-overview-progress > span,
.swarm-load-grid__bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--agent-color, var(--swarm-focus));
}

.swarm-empty {
  margin: 7px 0 0;
  color: #b5bbc4;
  font-size: 10.5px;
}

.swarm-critical-path { min-width: 0; color: var(--swarm-muted); font-size: 10.5px; }

.swarm-load-grid {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.swarm-load-grid > button {
  min-width: 0;
  min-height: 106px;
  display: grid;
  align-content: start;
  gap: 7px;
  padding: 10px;
  border: 1px solid color-mix(in srgb, var(--agent-color, #4b5563) 58%, #34363b);
  border-left: 2px solid var(--agent-color, #4b5563);
  border-radius: 6px;
  background: #202124;
  color: #e9ebee;
  text-align: left;
  cursor: pointer;
}

.swarm-load-grid > button:hover {
  background: #25272b;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--agent-color, #4b5563) 22%, transparent);
}

.swarm-load-grid > button > span:first-child {
  min-width: 0;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
}

.swarm-load-grid > button > span:first-child > span:nth-child(2) {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.swarm-load-grid strong {
  overflow: hidden;
  color: #f2f3f5;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.swarm-load-grid b { color: #f5f6f8; font-size: 13px; }

.swarm-load-grid small {
  overflow: hidden;
  color: #c0c5cd;
  font-size: 9.5px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.swarm-avatar {
  position: relative;
  isolation: isolate;
  flex: 0 0 auto;
  width: 30px !important;
  height: 30px !important;
  display: grid !important;
  place-items: center;
  border-radius: 50%;
}

.swarm-avatar__portrait {
  position: absolute;
  inset: 3px;
  z-index: 1;
  display: block;
  overflow: hidden;
  border-radius: 50%;
  background: #111319;
}

.swarm-avatar__portrait img {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  display: block !important;
  object-fit: cover !important;
  object-position: var(--portrait-focal-point, center 34%) !important;
}

.swarm-progress {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 30px !important;
  height: 30px !important;
  display: block;
  pointer-events: none;
}

.swarm-progress svg { width: 30px !important; height: 30px !important; display: block; transform: rotate(-90deg); }
.swarm-progress__track { fill: none; stroke: #3a3e46; stroke-width: 2; }
.swarm-progress__value { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.swarm-progress__dot { position: absolute; right: 0; bottom: 1px; width: 7px; height: 7px; border: 1px solid #202124; border-radius: 50%; background: #8b929d; }
.swarm-progress--running .swarm-progress__dot { background: #2f8cff; }
.swarm-progress--blocked .swarm-progress__dot,
.swarm-progress--error .swarm-progress__dot { background: #ef5965; }
.swarm-progress--complete .swarm-progress__dot { background: #27b87a; }

.swarm-role-badge {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  min-height: 17px;
  padding: 0 5px;
  border: 1px solid var(--agent-color, #59606b);
  border-radius: 3px;
  background: color-mix(in srgb, var(--agent-color, #59606b) 10%, transparent);
  color: var(--agent-color, #b8bec8);
  font-size: 8px;
  font-weight: 780;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.swarm-scheduling-grid,
.swarm-diagnostics-grid,
.swarm-overview-timeline,
.swarm-provenance-timeline {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.swarm-scheduling-card,
.swarm-diagnostics-card,
.swarm-bottleneck-card,
.swarm-memory-card,
.swarm-artifact-card,
.swarm-provenance-card {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--swarm-border-soft);
  border-radius: 6px;
  background: #24262a;
  color: #d7dbe0;
  font-size: 10px;
}

@media (max-width: 680px) {
  .swarm-execution-workspace { min-width: 0; width: calc(100vw - 48px) !important; max-width: none; }
  .swarm-workflow-header { grid-template-columns: minmax(0, 1fr) 34px; }
  .swarm-workflow-header dl { display: none; }
  .swarm-overview-filters { grid-template-columns: 1fr; }
  .swarm-overview-filter-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .swarm-metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .swarm-load-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .swarm-execution-workspace *,
  .swarm-execution-workspace *::before,
  .swarm-execution-workspace *::after { scroll-behavior: auto !important; transition: none !important; }
}
