:root {
  color-scheme: light;
  font-family: system-ui, sans-serif;
  font-size: 14px;
  color: #0f172a;
  background: #f1f5f9;
  --border: #e2e8f0;
  --muted: #64748b;
  --accent: #1d4ed8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  font-size: 1rem;
  margin: 0;
}

.topbar-end {
  margin-left: auto;
}

.badge {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(280px, 20%) 1fr;
  transition: grid-template-columns 0.2s ease;
}

.sidebar {
  overflow-y: auto;
  padding: 12px;
  display: grid;
  align-content: start;
  gap: 12px;
  border-right: 1px solid var(--border);
}

.sidebar-collapsed .layout {
  grid-template-columns: 0 1fr;
}

.sidebar-collapsed .sidebar {
  visibility: hidden;
  padding: 0;
  border: 0;
}

.panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.panel h2 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.row {
  display: flex;
  gap: 6px;
}

label {
  display: grid;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--muted);
}

input,
select,
button {
  font: inherit;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 6px 10px;
  background: #fff;
  color: inherit;
}

button {
  cursor: pointer;
  background: #0f172a;
  color: #fff;
  border-color: #0f172a;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  padding: 8px 10px;
  font-weight: 600;
}

button.icon {
  background: transparent;
  color: inherit;
  border-color: var(--border);
  padding: 2px 8px;
  line-height: 1.2;
}

button.ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
  padding: 2px 6px;
}

button:disabled {
  opacity: 0.45;
  cursor: default;
}

.row input {
  flex: 1;
  min-width: 0;
}

#run-detail {
  margin: 0;
}

.detail {
  display: grid;
  gap: 2px;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
  color: var(--muted);
}

.list button {
  width: 100%;
  text-align: left;
  background: #fff;
  color: inherit;
  border-color: var(--border);
  display: grid;
  gap: 2px;
}

.list button:hover {
  border-color: var(--accent);
}

.item-title {
  color: #0f172a;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-meta {
  font-size: 0.75rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 6px;
  background: #f59e0b;
}

.dot.completed {
  background: #16a34a;
}

.dot.failed {
  background: #dc2626;
}

.error {
  color: #b91c1c;
  margin: 0;
}

.error:empty {
  display: none;
}

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

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgb(15 23 42 / 0.2);
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(480px, 90vw);
  background: #fff;
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px rgb(15 23 42 / 0.08);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.2s ease;
}

.log-open .drawer {
  transform: none;
}

.drawer-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.drawer-head h2 {
  font-size: 0.95rem;
  margin: 0 auto 0 0;
}

#log {
  flex: 1;
  overflow-y: auto;
  margin: 0;
  padding: 12px 16px 12px 32px;
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  display: grid;
  align-content: start;
  gap: 6px;
  overflow-wrap: anywhere;
}

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

.mini summary {
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--muted);
}

.mini[open] summary {
  margin-bottom: 6px;
}

.mini .ghost {
  margin-top: 4px;
}

label.inline {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 12px;
  gap: 8px;
}

.stage-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.stage-title {
  font-size: 1.05rem;
  font-weight: 600;
}

.stage-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.stage-body {
  flex: 1;
  min-height: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  display: grid;
}

.empty {
  place-self: center;
  color: var(--muted);
  padding: 24px;
  text-align: center;
}

.stage-body iframe {
  width: 100%;
  height: 100%;
  border: 0;
}
